diff options
author | nyamatongwe <devnull@localhost> | 2009-10-27 00:03:30 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2009-10-27 00:03:30 +0000 |
commit | dbe307598244e62b0f16c39eee078f1c19fa396c (patch) | |
tree | bc59a48190f73bd0babbe041bccd423afea8f05d | |
parent | 6085a182d195a0a7d73548f321ce1ba9da005a4d (diff) | |
download | scintilla-mirror-dbe307598244e62b0f16c39eee078f1c19fa396c.tar.gz |
Added GetLexerLanguage.
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 4 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 15 | ||||
-rw-r--r-- | test/simpleTests.py | 19 |
4 files changed, 30 insertions, 9 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h index e9bba868c..c7d30ca3a 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -788,6 +788,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPROPERTYEXPANDED 4009 #define SCI_GETPROPERTYINT 4010 #define SCI_GETSTYLEBITSNEEDED 4011 +#define SCI_GETLEXERLANGUAGE 4012 #define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_DELETETEXT 0x2 #define SC_MOD_CHANGESTYLE 0x4 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 647506cf4..c524b7195 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2097,6 +2097,10 @@ get int GetPropertyInt=4010(string key,) # Retrieve the number of bits the current lexer needs for styling. get int GetStyleBitsNeeded=4011(,) +# Retrieve the name of the lexer. +# Return the length of the text. +get int GetLexerLanguage=4012(, stringresult text) + # Notifications # Type of modification and the action which caused the modification. # These are defined as a bit mask to make it easy to specify which notifications are wanted. diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 344b7e296..8b1a0485f 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -730,15 +730,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara reinterpret_cast<const char *>(lParam)); break; - case SCI_GETPROPERTY: { - const char *val = props.Get(reinterpret_cast<const char *>(wParam)); - const int n = strlen(val); - if (lParam != 0) { - char *ptr = reinterpret_cast<char *>(lParam); - strcpy(ptr, val); - } - return n; // Not including NUL - } + case SCI_GETPROPERTY: + return StringResult(lParam, props.Get(reinterpret_cast<const char *>(wParam))); case SCI_GETPROPERTYEXPANDED: { char *val = props.Expanded(reinterpret_cast<const char *>(wParam)); @@ -765,8 +758,12 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara SetLexerLanguage(reinterpret_cast<const char *>(lParam)); break; + case SCI_GETLEXERLANGUAGE: + return StringResult(lParam, lexCurrent ? lexCurrent->languageName : ""); + case SCI_GETSTYLEBITSNEEDED: return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5; + #endif default: diff --git a/test/simpleTests.py b/test/simpleTests.py index 581653b7f..feab296b9 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -1015,6 +1015,25 @@ class TestMultiSelection(unittest.TestCase): self.assertEquals(self.ed.GetSelectionNCaret(0), 3) self.assertEquals(self.ed.GetSelectionNCaretVirtualSpace(0), 0) +class TestLexer(unittest.TestCase): + def setUp(self): + self.xite = XiteWin.xiteFrame + self.ed = self.xite.ed + self.ed.ClearAll() + self.ed.EmptyUndoBuffer() + + def testLexerNumber(self): + self.ed.Lexer = self.ed.SCLEX_CPP + self.assertEquals(self.ed.GetLexer(), self.ed.SCLEX_CPP) + + def testLexerName(self): + self.ed.LexerLanguage = b"cpp" + self.assertEquals(self.ed.GetLexer(), self.ed.SCLEX_CPP) + name = b"-" * 100 + length = self.ed.GetLexerLanguage(0, name) + name = name[:length] + self.assertEquals(name, b"cpp") + class TestAutoComplete(unittest.TestCase): def setUp(self): |