diff options
author | Neil <nyamatongwe@gmail.com> | 2013-09-05 16:37:34 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2013-09-05 16:37:34 +1000 |
commit | 80781c95bbdaa770cce026c6e0461c803ead84bb (patch) | |
tree | 0209a2b3a5bf2f1116c89f4b62c7ce659606b09d | |
parent | eee3ce336ae78e9bf3d75f2c84aba97a7c623ea4 (diff) | |
download | scintilla-mirror-80781c95bbdaa770cce026c6e0461c803ead84bb.tar.gz |
Added SCI_GETPRIMARYSTYLEFROMSTYLE.
-rw-r--r-- | doc/ScintillaDoc.html | 9 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 6 | ||||
-rw-r--r-- | include/ILexer.h | 1 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | lexers/LexCPP.cxx | 3 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 11 | ||||
-rw-r--r-- | 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 @@ <h1>Scintilla Documentation</h1> - <p>Last edited 3 September 2013 NH</p> + <p>Last edited 5 September 2013 NH</p> <p>There is <a class="jump" href="Design.html">an overview of the internal design of Scintilla</a>.<br /> @@ -5931,6 +5931,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_GETSUBSTYLESSTART">SCI_GETSUBSTYLESSTART(int styleBase)</a><br /> <a class="message" href="#SCI_GETSUBSTYLESLENGTH">SCI_GETSUBSTYLESLENGTH(int styleBase)</a><br /> <a class="message" href="#SCI_GETSTYLEFROMSUBSTYLE">SCI_GETSTYLEFROMSUBSTYLE(int subStyle)</a><br /> + <a class="message" href="#SCI_GETPRIMARYSTYLEFROMSTYLE">SCI_GETPRIMARYSTYLEFROMSTYLE(int style)</a><br /> <a class="message" href="#SCI_SETIDENTIFIERS">SCI_SETIDENTIFIERS(int style, const char *identifiers)</a><br /> </div> @@ -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.</p> <p><b id="SCI_GETSTYLEFROMSUBSTYLE">SCI_GETSTYLEFROMSUBSTYLE(int subStyle)</b><br /> - Returns the base style of a substyle.</p> + For a sub style, return the base style, else return the argument.</p> + + <p><b id="SCI_GETPRIMARYSTYLEFROMSTYLE">SCI_GETPRIMARYSTYLEFROMSTYLE(int style)</b><br /> + For a secondary style, return the primary style, else return the argument.</p> <p><b id="SCI_SETIDENTIFIERS">SCI_SETIDENTIFIERS(int style, const char *identifiers)</b><br /> Similar to <code>SCI_SETKEYWORDS</code> but for substyles.</p> @@ -6242,6 +6246,7 @@ To allow lexers to report which line ends they support, and to support substyles <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SubStylesStart<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>styleBase<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SubStylesLength<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>styleBase<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>StyleFromSubStyle<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>subStyle<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> +<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>PrimaryStyleFromStyle<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>style<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>FreeSubStyles<span class="S10">()</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SetIdentifiers<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>style<span class="S10">,</span><span class="S0"> </span><span class="S5">const</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span><span class="S10">*</span>identifiers<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>DistanceToSecondaryStyles<span class="S10">()</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br /> 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. </li> <li> - 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. </li> <li> 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<ILexerWithSubStyles *>(instance)->PrimaryStyleFromStyle(style); + } + return 0; +} + void LexState::FreeSubStyles() { if (instance && (interfaceVersion >= lvSubStyles)) { static_cast<ILexerWithSubStyles *>(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): |