aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2005-08-30 11:07:33 +0000
committernyamatongwe <devnull@localhost>2005-08-30 11:07:33 +0000
commit95a714f8a63361dc6301e45173cdfa047e0f6b5c (patch)
tree1f359ea0977818f6efbafb8d5c5d2fbfa7bdd473
parentaf030da0ca3350e14457afd71776d37fb84d6f7d (diff)
downloadscintilla-mirror-95a714f8a63361dc6301e45173cdfa047e0f6b5c.tar.gz
Added StyleBitsNeeded property and implemented to return 5 for all lexers
except HTML, XML, ... (7) and Ruby (6).
-rw-r--r--doc/ScintillaDoc.html11
-rw-r--r--include/KeyWords.h12
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--src/KeyWords.cxx18
-rw-r--r--src/LexHTML.cxx10
-rw-r--r--src/LexRuby.cxx2
-rw-r--r--src/ScintillaBase.cxx3
8 files changed, 44 insertions, 16 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index fc1871e65..218e99d89 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -452,7 +452,9 @@
<b id="SCI_GETSTYLEBITS">SCI_GETSTYLEBITS</b><br />
This pair of routines sets and reads back the number of bits in each cell to use for styling,
to a maximum of 7 style bits. The remaining bits can be used as indicators. The standard
- setting is <code>SCI_SETSTYLEBITS(5)</code>.</p>
+ setting is <code>SCI_SETSTYLEBITS(5)</code>.
+ The number of styling bits needed by the current lexer can be found with
+ <a class="message" href="#SCI_GETSTYLEBITSNEEDED">SCI_GETSTYLEBITSNEEDED</a>.</p>
<p><b id="TextRange">TextRange</b> and <b id="CharacterRange">CharacterRange</b><br />
These structures are defined to be exactly the same shape as the Win32 <code>TEXTRANGE</code>
@@ -4293,6 +4295,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<a class="message" href="#SCI_GETPROPERTYINT">SCI_GETPROPERTYINT(const char *key, int default)</a><br />
<a class="message" href="#SCI_SETKEYWORDS">SCI_SETKEYWORDS(int keyWordSet, const char
*keyWordList)</a><br />
+ <a class="message" href="#SCI_GETSTYLEBITSNEEDED">SCI_GETSTYLEBITSNEEDED</a>
+ <br />
</code>
<p><b id="SCI_SETLEXER">SCI_SETLEXER(int lexer)</b><br />
@@ -4402,6 +4406,11 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
There is nothing to stop you building your own keyword lists into the lexer, but this means
that the lexer must be rebuilt if more keywords are added.</p>
+ <p><b id="SCI_GETSTYLEBITSNEEDED">SCI_GETSTYLEBITSNEEDED</b><br />
+ Retrieve the number of bits the current lexer needs for styling. This should normally be the argument
+ to <a class="message" href="#SCI_SETSTYLEBITS">SCI_SETSTYLEBITS</a>.
+ </p>
+
<h2 id="Notifications">Notifications</h2>
<p>Notifications are sent (fired) from the Scintilla control to its container when an event has
diff --git a/include/KeyWords.h b/include/KeyWords.h
index cc81b73df..059ac0da0 100644
--- a/include/KeyWords.h
+++ b/include/KeyWords.h
@@ -20,15 +20,19 @@ protected:
LexerFunction fnLexer;
LexerFunction fnFolder;
const char * const * wordListDescriptions;
+ int styleBits;
static const LexerModule *base;
static int nextLanguage;
public:
const char *languageName;
- LexerModule(int language_, LexerFunction fnLexer_,
- const char *languageName_=0, LexerFunction fnFolder_=0,
- const char * const wordListDescriptions_[] = NULL);
+ LexerModule(int language_,
+ LexerFunction fnLexer_,
+ const char *languageName_=0,
+ LexerFunction fnFolder_=0,
+ const char * const wordListDescriptions_[] = NULL,
+ int styleBits_=5);
virtual ~LexerModule() {
}
int GetLanguage() const { return language; }
@@ -37,6 +41,8 @@ public:
int GetNumWordLists() const;
const char *GetWordListDescription(int index) const;
+ int GetStyleBitsNeeded() const;
+
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 359db9c8f..cb91cba6f 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -616,6 +616,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETPROPERTY 4008
#define SCI_GETPROPERTYEXPANDED 4009
#define SCI_GETPROPERTYINT 4010
+#define SCI_GETSTYLEBITSNEEDED 4011
#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 b7a9b7d13..652d45858 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1670,6 +1670,9 @@ fun int GetPropertyExpanded=4009(string key, stringresult buf)
# interpreted as an int AFTER any "$()" variable replacement.
get int GetPropertyInt=4010(string key,)
+# Retrieve the number of bits the current lexer needs for styling.
+get int GetStyleBitsNeeded=4011(,)
+
# 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/KeyWords.cxx b/src/KeyWords.cxx
index d1b9614e5..f932b877e 100644
--- a/src/KeyWords.cxx
+++ b/src/KeyWords.cxx
@@ -22,14 +22,18 @@
const LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
-LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
- const char *languageName_, LexerFunction fnFolder_,
- const char * const wordListDescriptions_[]) :
+LexerModule::LexerModule(int language_,
+ LexerFunction fnLexer_,
+ const char *languageName_,
+ LexerFunction fnFolder_,
+ const char * const wordListDescriptions_[],
+ int styleBits_) :
language(language_),
fnLexer(fnLexer_),
fnFolder(fnFolder_),
wordListDescriptions(wordListDescriptions_),
- languageName(languageName_) {
+ languageName(languageName_),
+ styleBits(styleBits_) {
next = base;
base = this;
if (language == SCLEX_AUTOMATIC) {
@@ -52,7 +56,7 @@ int LexerModule::GetNumWordLists() const {
}
}
-const char * LexerModule::GetWordListDescription(int index) const {
+const char *LexerModule::GetWordListDescription(int index) const {
static const char *emptyStr = "";
PLATFORM_ASSERT(index < GetNumWordLists());
@@ -63,6 +67,10 @@ const char * LexerModule::GetWordListDescription(int index) const {
}
}
+int LexerModule::GetStyleBitsNeeded() const {
+ return styleBits;
+}
+
const LexerModule *LexerModule::Find(int language) {
const LexerModule *lm = base;
while (lm) {
diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx
index 036bf1a8f..616b3acfd 100644
--- a/src/LexHTML.cxx
+++ b/src/LexHTML.cxx
@@ -1993,9 +1993,9 @@ static const char * const phpscriptWordListDesc[] = {
0,
};
-LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext", 0, htmlWordListDesc);
-LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml", 0, htmlWordListDesc);
+LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext", 0, htmlWordListDesc, 7);
+LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml", 0, htmlWordListDesc, 7);
// SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead.
-LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc);
-LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc);
-LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc);
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 7);
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 7);
+LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 7);
diff --git a/src/LexRuby.cxx b/src/LexRuby.cxx
index 878071a53..e8a4d2917 100644
--- a/src/LexRuby.cxx
+++ b/src/LexRuby.cxx
@@ -1253,4 +1253,4 @@ static const char * const rubyWordListDesc[] = {
0
};
-LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc);
+LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc, 6);
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index b650d19c5..9c88af0d6 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -689,7 +689,6 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_GETPROPERTYINT:
return props.GetInt(reinterpret_cast<const char *>(wParam), lParam);
-
case SCI_SETKEYWORDS:
if (wParam < numWordLists) {
keyWordLists[wParam]->Clear();
@@ -701,6 +700,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
SetLexerLanguage(reinterpret_cast<const char *>(lParam));
break;
+ case SCI_GETSTYLEBITSNEEDED:
+ return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
#endif
default: