From 258060914b6c1aa88197619e87e4393b4dc9fa65 Mon Sep 17 00:00:00 2001
From: Neil
Date: Thu, 5 Sep 2013 16:37:34 +1000
Subject: Added SCI_GETPRIMARYSTYLEFROMSTYLE.
---
doc/ScintillaDoc.html | 9 +++++++--
doc/ScintillaHistory.html | 6 ++++--
include/ILexer.h | 1 +
include/Scintilla.h | 1 +
include/Scintilla.iface | 3 +++
lexers/LexCPP.cxx | 3 +++
src/ScintillaBase.cxx | 11 +++++++++++
test/simpleTests.py | 4 ++++
8 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 5b3ca0717..98f9bb844 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -82,7 +82,7 @@
Scintilla Documentation
- Last edited 3 September 2013 NH
+ Last edited 5 September 2013 NH
There is an overview of the internal design of
Scintilla.
@@ -5931,6 +5931,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
SCI_GETSUBSTYLESSTART(int styleBase)
SCI_GETSUBSTYLESLENGTH(int styleBase)
SCI_GETSTYLEFROMSUBSTYLE(int subStyle)
+ SCI_GETPRIMARYSTYLEFROMSTYLE(int style)
SCI_SETIDENTIFIERS(int style, const char *identifiers)
@@ -6107,7 +6108,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
Return the start and length of the substyles allocated for a base style.
SCI_GETSTYLEFROMSUBSTYLE(int subStyle)
- Returns the base style of a substyle.
+ For a sub style, return the base style, else return the argument.
+
+ SCI_GETPRIMARYSTYLEFROMSTYLE(int style)
+ For a secondary style, return the primary style, else return the argument.
SCI_SETIDENTIFIERS(int style, const char *identifiers)
Similar to SCI_SETKEYWORDS but for substyles.
@@ -6242,6 +6246,7 @@ To allow lexers to report which line ends they support, and to support substyles
virtual int SCI_METHOD SubStylesStart(int styleBase) = 0;
virtual int SCI_METHOD SubStylesLength(int styleBase) = 0;
virtual int SCI_METHOD StyleFromSubStyle(int subStyle) = 0;
+ virtual int SCI_METHOD PrimaryStyleFromStyle(int style) = 0;
virtual void SCI_METHOD FreeSubStyles() = 0;
virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0;
virtual int SCI_METHOD DistanceToSecondaryStyles() = 0;
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 476241297..66c552611 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -449,9 +449,11 @@
Released 3 September 2013.
- Added SCI_GETSTYLEFROMSUBSTYLE function to find the base style of substyles.
+ Added functions to help convert between substyles and base styles and between secondary and primary styles.
+ SCI_GETSTYLEFROMSUBSTYLE finds the base style of substyles.
Can be used to treat all substyles of a style equivalent to that style.
- A StyleFromSubStyle method was added to ILexerWithSubStyles so each lexer can implement this.
+ SCI_GETPRIMARYSTYLEFROMSTYLE finds the primary style of secondary styles.
+ StyleFromSubStyle and PrimaryStyleFromStyle methods were added to ILexerWithSubStyles so each lexer can implement these.
On Qt, turn off idle events on destruction to prevent repeatedly calling idle.
diff --git a/include/ILexer.h b/include/ILexer.h
index 16ae4a28f..b90092750 100644
--- a/include/ILexer.h
+++ b/include/ILexer.h
@@ -76,6 +76,7 @@ public:
virtual int SCI_METHOD SubStylesStart(int styleBase) = 0;
virtual int SCI_METHOD SubStylesLength(int styleBase) = 0;
virtual int SCI_METHOD StyleFromSubStyle(int subStyle) = 0;
+ virtual int SCI_METHOD PrimaryStyleFromStyle(int style) = 0;
virtual void SCI_METHOD FreeSubStyles() = 0;
virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0;
virtual int SCI_METHOD DistanceToSecondaryStyles() = 0;
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 8391bae3e..720ef21fc 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -998,6 +998,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETSUBSTYLESSTART 4021
#define SCI_GETSUBSTYLESLENGTH 4022
#define SCI_GETSTYLEFROMSUBSTYLE 4027
+#define SCI_GETPRIMARYSTYLEFROMSTYLE 4028
#define SCI_FREESUBSTYLES 4023
#define SCI_SETIDENTIFIERS 4024
#define SCI_DISTANCETOSECONDARYSTYLES 4025
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index b5ba48f65..b3e34ac3b 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -4406,6 +4406,9 @@ get int GetSubStylesLength=4022(int styleBase,)
# For a sub style, return the base style, else return the argument.
get int GetStyleFromSubStyle=4027(int subStyle,)
+# For a secondary style, return the primary style, else return the argument.
+get int GetPrimaryStyleFromStyle=4028(int style,)
+
# Free allocated sub styles
fun void FreeSubStyles=4023(,)
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx
index 70af0343f..6f7afc23d 100644
--- a/lexers/LexCPP.cxx
+++ b/lexers/LexCPP.cxx
@@ -392,6 +392,9 @@ public:
int active = subStyle & activeFlag;
return styleBase | active;
}
+ int SCI_METHOD PrimaryStyleFromStyle(int style) {
+ return MaskActive(style);
+ }
void SCI_METHOD FreeSubStyles() {
subStyles.Free();
}
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index e65b3ecf7..75f0d5a16 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -504,6 +504,7 @@ public:
int SubStylesStart(int styleBase);
int SubStylesLength(int styleBase);
int StyleFromSubStyle(int subStyle);
+ int PrimaryStyleFromStyle(int style);
void FreeSubStyles();
void SetIdentifiers(int style, const char *identifiers);
int DistanceToSecondaryStyles();
@@ -686,6 +687,13 @@ int LexState::StyleFromSubStyle(int subStyle) {
return 0;
}
+int LexState::PrimaryStyleFromStyle(int style) {
+ if (instance && (interfaceVersion >= lvSubStyles)) {
+ return static_cast(instance)->PrimaryStyleFromStyle(style);
+ }
+ return 0;
+}
+
void LexState::FreeSubStyles() {
if (instance && (interfaceVersion >= lvSubStyles)) {
static_cast(instance)->FreeSubStyles();
@@ -994,6 +1002,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_GETSTYLEFROMSUBSTYLE:
return DocumentLexState()->StyleFromSubStyle(wParam);
+ case SCI_GETPRIMARYSTYLEFROMSTYLE:
+ return DocumentLexState()->PrimaryStyleFromStyle(wParam);
+
case SCI_FREESUBSTYLES:
DocumentLexState()->FreeSubStyles();
break;
diff --git a/test/simpleTests.py b/test/simpleTests.py
index 496488157..e814f45ca 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -1675,6 +1675,10 @@ class TestSubStyles(unittest.TestCase):
self.assertEquals(self.ed.GetStyleFromSubStyle(subs+inactiveDistance), self.ed.SCE_C_IDENTIFIER+inactiveDistance)
self.ed.FreeSubStyles()
+ def testSecondary(self):
+ inactiveDistance = self.ed.DistanceToSecondaryStyles()
+ self.assertEquals(self.ed.GetPrimaryStyleFromStyle(self.ed.SCE_C_IDENTIFIER+inactiveDistance), self.ed.SCE_C_IDENTIFIER)
+
class TestAutoComplete(unittest.TestCase):
def setUp(self):
--
cgit v1.2.3