]> git.saurik.com Git - wxWidgets.git/commitdiff
Updated to version 1.40 of Scintilla
authorRobin Dunn <robin@alldunn.com>
Thu, 18 Oct 2001 01:24:58 +0000 (01:24 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 18 Oct 2001 01:24:58 +0000 (01:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12050 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

62 files changed:
contrib/include/wx/stc/stc.h
contrib/src/stc/Makefile.in
contrib/src/stc/PlatWX.cpp
contrib/src/stc/ScintillaWX.cpp
contrib/src/stc/makefile.b32
contrib/src/stc/makefile.g95
contrib/src/stc/makefile.vc
contrib/src/stc/scintilla/README.txt
contrib/src/stc/scintilla/include/SciLexer.h
contrib/src/stc/scintilla/include/Scintilla.h
contrib/src/stc/scintilla/include/Scintilla.iface
contrib/src/stc/scintilla/include/ScintillaWidget.h
contrib/src/stc/scintilla/include/WinDefs.h [deleted file]
contrib/src/stc/scintilla/src/Document.cxx
contrib/src/stc/scintilla/src/Editor.cxx
contrib/src/stc/scintilla/src/Editor.h
contrib/src/stc/scintilla/src/KeyWords.cxx
contrib/src/stc/scintilla/src/LexCPP.cxx
contrib/src/stc/scintilla/src/LexCrontab.cxx [new file with mode: 0644]
contrib/src/stc/scintilla/src/LexEiffel.cxx
contrib/src/stc/scintilla/src/LexHTML.cxx
contrib/src/stc/scintilla/src/LexPython.cxx
contrib/src/stc/scintilla/src/LineMarker.cxx
contrib/src/stc/scintilla/src/LineMarker.h
contrib/src/stc/scintilla/src/RESearch.cxx
contrib/src/stc/scintilla/src/ScintillaBase.cxx
contrib/src/stc/scintilla/src/ScintillaBase.h
contrib/src/stc/scintilla/src/StyleContext.cxx [new file with mode: 0644]
contrib/src/stc/scintilla/src/StyleContext.h [new file with mode: 0644]
contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
include/wx/stc/stc.h
src/stc/Makefile.in
src/stc/PlatWX.cpp
src/stc/ScintillaWX.cpp
src/stc/makefile.b32
src/stc/makefile.g95
src/stc/makefile.vc
src/stc/scintilla/README.txt
src/stc/scintilla/include/SciLexer.h
src/stc/scintilla/include/Scintilla.h
src/stc/scintilla/include/Scintilla.iface
src/stc/scintilla/include/ScintillaWidget.h
src/stc/scintilla/include/WinDefs.h [deleted file]
src/stc/scintilla/src/Document.cxx
src/stc/scintilla/src/Editor.cxx
src/stc/scintilla/src/Editor.h
src/stc/scintilla/src/KeyWords.cxx
src/stc/scintilla/src/LexCPP.cxx
src/stc/scintilla/src/LexCrontab.cxx [new file with mode: 0644]
src/stc/scintilla/src/LexEiffel.cxx
src/stc/scintilla/src/LexHTML.cxx
src/stc/scintilla/src/LexPython.cxx
src/stc/scintilla/src/LineMarker.cxx
src/stc/scintilla/src/LineMarker.h
src/stc/scintilla/src/RESearch.cxx
src/stc/scintilla/src/ScintillaBase.cxx
src/stc/scintilla/src/ScintillaBase.h
src/stc/scintilla/src/StyleContext.cxx [new file with mode: 0644]
src/stc/scintilla/src/StyleContext.h [new file with mode: 0644]
src/stc/stc.cpp
src/stc/stc.cpp.in

index 46dcb91225c191eb964e916697dad8e7c4ae28d9..99553d810b9e2afab6fbbdd7681c88acd4e42904 100644 (file)
@@ -72,6 +72,7 @@
 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
 #define wxSTC_MARK_CIRCLEMINUS 20
 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
 #define wxSTC_MARK_CIRCLEMINUS 20
 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
+#define wxSTC_MARK_CHARACTER 10000
 
 // Markers used for outlining column
 #define wxSTC_MARKNUM_FOLDEREND 25
 
 // Markers used for outlining column
 #define wxSTC_MARKNUM_FOLDEREND 25
 #define wxSTC_MARKNUM_FOLDEROPEN 31
 #define wxSTC_MARGIN_SYMBOL 0
 #define wxSTC_MARGIN_NUMBER 1
 #define wxSTC_MARKNUM_FOLDEROPEN 31
 #define wxSTC_MARGIN_SYMBOL 0
 #define wxSTC_MARGIN_NUMBER 1
+
+// Styles in range 32..37 are predefined for parts of the UI and are not used as normal styles.
+// Styles 38 and 39 are for future use.
 #define wxSTC_STYLE_DEFAULT 32
 #define wxSTC_STYLE_LINENUMBER 33
 #define wxSTC_STYLE_BRACELIGHT 34
 #define wxSTC_STYLE_BRACEBAD 35
 #define wxSTC_STYLE_CONTROLCHAR 36
 #define wxSTC_STYLE_INDENTGUIDE 37
 #define wxSTC_STYLE_DEFAULT 32
 #define wxSTC_STYLE_LINENUMBER 33
 #define wxSTC_STYLE_BRACELIGHT 34
 #define wxSTC_STYLE_BRACEBAD 35
 #define wxSTC_STYLE_CONTROLCHAR 36
 #define wxSTC_STYLE_INDENTGUIDE 37
+#define wxSTC_STYLE_LASTPREDEFINED 39
 #define wxSTC_STYLE_MAX 127
 
 // Character set identifiers are used in StyleSetCharacterSet.
 #define wxSTC_STYLE_MAX 127
 
 // Character set identifiers are used in StyleSetCharacterSet.
 #define wxSTC_LEX_EIFFEL 23
 #define wxSTC_LEX_EIFFELKW 24
 #define wxSTC_LEX_TCL 25
 #define wxSTC_LEX_EIFFEL 23
 #define wxSTC_LEX_EIFFELKW 24
 #define wxSTC_LEX_TCL 25
+#define wxSTC_LEX_NNCRONTAB 26
 
 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 // value assigned in sequence from SCLEX_AUTOMATIC+1.
 
 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 // value assigned in sequence from SCLEX_AUTOMATIC+1.
 #define wxSTC_C_REGEX 14
 #define wxSTC_C_COMMENTLINEDOC 15
 #define wxSTC_C_WORD2 16
 #define wxSTC_C_REGEX 14
 #define wxSTC_C_COMMENTLINEDOC 15
 #define wxSTC_C_WORD2 16
+#define wxSTC_C_COMMENTDOCKEYWORD 17
+#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
 
 // Lexical states for SCLEX_HTML, SCLEX_XML
 #define wxSTC_H_DEFAULT 0
 
 // Lexical states for SCLEX_HTML, SCLEX_XML
 #define wxSTC_H_DEFAULT 0
 #define wxSTC_H_XCCOMMENT 20
 
 // SGML
 #define wxSTC_H_XCCOMMENT 20
 
 // SGML
-#define wxSTC_H_SGML 21
+#define wxSTC_H_SGML_DEFAULT 21
+#define wxSTC_H_SGML_COMMAND 22
+#define wxSTC_H_SGML_1ST_PARAM 23
+#define wxSTC_H_SGML_DOUBLESTRING 24
+#define wxSTC_H_SGML_SIMPLESTRING 25
+#define wxSTC_H_SGML_ERROR 26
+#define wxSTC_H_SGML_SPECIAL 27
+#define wxSTC_H_SGML_ENTITY 28
+#define wxSTC_H_SGML_COMMENT 29
+#define wxSTC_H_SGML_1ST_PARAM_COMMENT 30
+#define wxSTC_H_SGML_BLOCK_DEFAULT 31
 
 // Embedded Javascript
 #define wxSTC_HJ_START 40
 
 // Embedded Javascript
 #define wxSTC_HJ_START 40
 #define wxSTC_EIFFEL_IDENTIFIER 7
 #define wxSTC_EIFFEL_STRINGEOL 8
 
 #define wxSTC_EIFFEL_IDENTIFIER 7
 #define wxSTC_EIFFEL_STRINGEOL 8
 
+// Lexical states for the SCLEX_NNCRONTAB (nnCron crontab Lexer)
+#define wxSTC_NNCRONTAB_DEFAULT 0
+#define wxSTC_NNCRONTAB_COMMENT 1
+#define wxSTC_NNCRONTAB_TASK 2
+#define wxSTC_NNCRONTAB_SECTION 3
+#define wxSTC_NNCRONTAB_KEYWORD 4
+#define wxSTC_NNCRONTAB_MODIFIER 5
+#define wxSTC_NNCRONTAB_ASTERISK 6
+#define wxSTC_NNCRONTAB_NUMBER 7
+#define wxSTC_NNCRONTAB_STRING 8
+#define wxSTC_NNCRONTAB_ENVIRONMENT 9
+#define wxSTC_NNCRONTAB_IDENTIFIER 10
+
 // END of generated section
 //----------------------------------------------------------------------
 // Others
 // END of generated section
 //----------------------------------------------------------------------
 // Others
@@ -1223,10 +1254,12 @@ public:
     int GetTargetEnd();
 
     // Replace the target text with the argument text.
     int GetTargetEnd();
 
     // Replace the target text with the argument text.
+    // Text is counted so it can contain nulls.
     // Returns the length of the replacement text.
     int ReplaceTarget(const wxString& text);
 
     // Replace the target text with the argument text after \d processing.
     // Returns the length of the replacement text.
     int ReplaceTarget(const wxString& text);
 
     // Replace the target text with the argument text after \d processing.
+    // Text is counted so it can contain nulls.
     // Looks for \d where d is between 1 and 9 and replaces these with the strings
     // matched in the last search operation which were surrounded by \( and \).
     // Returns the length of the replacement text including any change
     // Looks for \d where d is between 1 and 9 and replaces these with the strings
     // matched in the last search operation which were surrounded by \( and \).
     // Returns the length of the replacement text including any change
@@ -1234,7 +1267,7 @@ public:
     int ReplaceTargetRE(const wxString& text);
 
     // Search for a counted string in the target and set the target to the found
     int ReplaceTargetRE(const wxString& text);
 
     // Search for a counted string in the target and set the target to the found
-    // range.
+    // range. Text is counted so it can contain nulls.
     // Returns length of range or -1 for failure in which case target is not moved.
     int SearchInTarget(const wxString& text);
 
     // Returns length of range or -1 for failure in which case target is not moved.
     int SearchInTarget(const wxString& text);
 
index 3deb9ba6ba53535539a8e3444a2686457b39f7ba..d6fdd6bc607d3e77741978701866d636add20e80 100644 (file)
@@ -37,6 +37,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
        LexAda.o                \
        LexCPP.o                \
        LexConf.o               \
        LexAda.o                \
        LexCPP.o                \
        LexConf.o               \
+       LexCrontab.o            \
        LexEiffel.o             \
        LexHTML.o               \
        LexLisp.o               \
        LexEiffel.o             \
        LexHTML.o               \
        LexLisp.o               \
@@ -53,6 +54,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
        RESearch.o              \
         ScintillaBase.o                \
         Style.o                        \
        RESearch.o              \
         ScintillaBase.o                \
         Style.o                        \
+       StyleContext.o          \
        UniConversion.o         \
         ViewStyle.o            \
        WindowAccessor.o        \
        UniConversion.o         \
         ViewStyle.o            \
        WindowAccessor.o        \
index 0e7390741484ce8e61b0d2123c91f9db2edc4a95..35a85e67ae30b7596152c2a1caa7a39d26b1c547 100644 (file)
@@ -531,24 +531,20 @@ ListBox::~ListBox() {
 
 void ListBox::Create(Window &parent, int ctrlID) {
     id = new wxSTCListBox(parent.id, ctrlID);
 
 void ListBox::Create(Window &parent, int ctrlID) {
     id = new wxSTCListBox(parent.id, ctrlID);
-//    id = new wxListBox(parent.id, ctrlID,  wxDefaultPosition, wxDefaultSize,
-//                       0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER);
 }
 
 void ListBox::SetVisibleRows(int rows) {
        desiredVisibleRows = rows;
 }
 
 void ListBox::SetVisibleRows(int rows) {
        desiredVisibleRows = rows;
-        printf("SetVisibleRows: %d\n", rows);
 }
 
 PRectangle ListBox::GetDesiredRect() {
     wxSize sz = ((wxListBox*)id)->GetBestSize();
 }
 
 PRectangle ListBox::GetDesiredRect() {
     wxSize sz = ((wxListBox*)id)->GetBestSize();
-    printf("GetDesiredRect: %d, %d\n", sz.x, sz.y);
     PRectangle rc;
     rc.top = 0;
     rc.left = 0;
     if (sz.x > 400)
         sz.x = 400;
     PRectangle rc;
     rc.top = 0;
     rc.left = 0;
     if (sz.x > 400)
         sz.x = 400;
-    if (sz.y > 150)
+    if (sz.y > 150)  // TODO:  Use desiredVisibleRows??
         sz.y = 150;
     rc.right = sz.x;
     rc.bottom = sz.y;
         sz.y = 150;
     rc.right = sz.x;
     rc.bottom = sz.y;
@@ -592,13 +588,7 @@ int ListBox::GetSelection() {
 }
 
 int ListBox::Find(const char *prefix) {
 }
 
 int ListBox::Find(const char *prefix) {
-    if (prefix) {
-        for (int x=0; x < ((wxListBox*)id)->GetCount(); x++) {
-            wxString text = ((wxListBox*)id)->GetString(x);
-            if (text.StartsWith(prefix))
-                return x;
-        }
-    }
+    // No longer used
     return -1;
 }
 
     return -1;
 }
 
index 103ce927962f45cb8b23b8421579be49116221ea..d5f2648dd163791a3b8e33dac2b215a5ead9448f 100644 (file)
@@ -122,9 +122,10 @@ void ScintillaWX::Finalise() {
 
 void ScintillaWX::StartDrag() {
     wxDropSource        source(wMain.GetID());
 
 void ScintillaWX::StartDrag() {
     wxDropSource        source(wMain.GetID());
-    wxTextDataObject    data(dragChars);
+    wxTextDataObject    data(wxString(drag.s, drag.len));
     wxDragResult        result;
 
     wxDragResult        result;
 
+    dropWentOutside = true;
     source.SetData(data);
     result = source.DoDragDrop(TRUE);
     if (result == wxDragMove && dropWentOutside)
     source.SetData(data);
     result = source.DoDragDrop(TRUE);
     if (result == wxDragMove && dropWentOutside)
@@ -217,9 +218,10 @@ void ScintillaWX::NotifyParent(SCNotification scn) {
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
-        char* text = CopySelectionRange();
+        SelectionText st;
+        CopySelectionRange(&st);
         wxTheClipboard->Open();
         wxTheClipboard->Open();
-        wxTheClipboard->SetData(new wxTextDataObject(text));
+        wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len)));
         wxTheClipboard->Close();
     }
 }
         wxTheClipboard->Close();
     }
 }
@@ -494,14 +496,15 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
 
 
 wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
 
 
 wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
-    return def;
+    dragResult = def;
+    return dragResult;
 }
 
 
 wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
     SetDragPosition(PositionFromLocation(Point(x, y)));
     dragResult = def;
 }
 
 
 wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
     SetDragPosition(PositionFromLocation(Point(x, y)));
     dragResult = def;
-    return def;
+    return dragResult;
 }
 
 
 }
 
 
index 492b4e26dfeadca9546bc022a6645ae7737b4fc8..7a74f314afdf214f63d43e95dd14e40c672ee1f1 100644 (file)
@@ -22,36 +22,45 @@ STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
 
 OBJECTS = \
 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
 
 OBJECTS = \
-    AutoComplete.obj        \
-    CallTip.obj             \
-    CellBuffer.obj          \
-    ContractionState.obj    \
-    Document.obj            \
-    DocumentAccessor.obj    \
-    Editor.obj              \
-    Indicator.obj           \
-    KeyMap.obj              \
-    KeyWords.obj            \
-    LexCPP.obj              \
-    LexHTML.obj             \
-    LexLua.obj              \
-    LexOthers.obj           \
-    LexPerl.obj             \
-    LexPython.obj           \
-    LexSQL.obj              \
-    LexVB.obj               \
-    LineMarker.obj          \
-    PosRegExp.obj           \
-    PropSet.obj             \
-    ScintillaBase.obj       \
-    Style.obj               \
-    UniConversion.obj       \
-    ViewStyle.obj           \
-    WindowAccessor.obj      \
-                            \
-    PlatWX.obj              \
-    ScintillaWX.obj         \
-    stc.obj                 \
+        AutoComplete.obj       \
+        CallTip.obj            \
+        CellBuffer.obj         \
+        ContractionState.obj   \
+        Document.obj           \
+       DocumentAccessor.obj    \
+        Editor.obj             \
+        Indicator.obj          \
+        KeyMap.obj             \
+        KeyWords.obj           \
+       LexAVE.obj              \
+       LexAda.obj              \
+       LexCPP.obj              \
+       LexConf.obj             \
+       LexCrontab.obj          \
+       LexEiffel.obj           \
+       LexHTML.obj             \
+       LexLisp.obj             \
+       LexLua.obj              \
+       LexOthers.obj           \
+       LexPascal.obj           \
+       LexPerl.obj             \
+       LexPython.obj           \
+       LexRuby.obj             \
+       LexSQL.obj              \
+       LexVB.obj               \
+        LineMarker.obj         \
+        PropSet.obj            \
+       RESearch.obj            \
+        ScintillaBase.obj      \
+        Style.obj              \
+       StyleContext.obj        \
+       UniConversion.obj       \
+        ViewStyle.obj          \
+       WindowAccessor.obj      \
+                               \
+       PlatWX.obj              \
+       ScintillaWX.obj         \
+       stc.obj                 \
 
 
 !include $(WXDIR)\src\makelib.b32
 
 
 !include $(WXDIR)\src\makelib.b32
index ea3cbd9c0ccf58b36bf12e6f6031683020c7d87b..cf708ed801b8ddbb1a51f0b2cadb7cf4492fa72b 100644 (file)
@@ -10,32 +10,42 @@ S=$(SCINTILLA)/src
 EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
 
 OBJECTS = \
 EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
 
 OBJECTS = \
-       $(S)/AutoComplete.$(OBJSUFF) \
-       $(S)/CallTip.$(OBJSUFF) \
-       $(S)/CellBuffer.$(OBJSUFF) \
-       $(S)/ContractionState.$(OBJSUFF)\
-       $(S)/Document.$(OBJSUFF) \
-       $(S)/Editor.$(OBJSUFF) \
-       $(S)/Indicator.$(OBJSUFF) \
-       $(S)/KeyMap.$(OBJSUFF) \
-       $(S)/KeyWords.$(OBJSUFF) \
-       $(S)/LineMarker.$(OBJSUFF) \
-       $(S)/PropSet.$(OBJSUFF) \
-       $(S)/ScintillaBase.$(OBJSUFF) \
-       $(S)/Style.$(OBJSUFF) \
-       $(S)/ViewStyle.$(OBJSUFF) \
-       $(S)/LexCPP.$(OBJSUFF)  \
-       $(S)/LexHTML.$(OBJSUFF) \
-       $(S)/LexLua.$(OBJSUFF) \
-       $(S)/LexOthers.$(OBJSUFF) \
-       $(S)/LexPerl.$(OBJSUFF) \
-       $(S)/LexPython.$(OBJSUFF) \
-       $(S)/LexSQL.$(OBJSUFF)  \
-       $(S)/LexVB.$(OBJSUFF)   \
-       $(S)/DocumentAccessor.$(OBJSUFF)\
+        $(S)/AutoComplete.$(OBJSUFF)   \
+        $(S)/CallTip.$(OBJSUFF)                \
+        $(S)/CellBuffer.$(OBJSUFF)     \
+        $(S)/ContractionState.$(OBJSUFF) \
+        $(S)/Document.$(OBJSUFF)       \
+       $(S)/DocumentAccessor.$(OBJSUFF) \
+        $(S)/Editor.$(OBJSUFF)         \
+        $(S)/Indicator.$(OBJSUFF)      \
+        $(S)/KeyMap.$(OBJSUFF)         \
+        $(S)/KeyWords.$(OBJSUFF)       \
+       $(S)/LexAVE.$(OBJSUFF)          \
+       $(S)/LexAda.$(OBJSUFF)          \
+       $(S)/LexCPP.$(OBJSUFF)          \
+       $(S)/LexConf.$(OBJSUFF)         \
+       $(S)/LexCrontab.$(OBJSUFF)      \
+       $(S)/LexEiffel.$(OBJSUFF)       \
+       $(S)/LexHTML.$(OBJSUFF)         \
+       $(S)/LexLisp.$(OBJSUFF)         \
+       $(S)/LexLua.$(OBJSUFF)          \
+       $(S)/LexOthers.$(OBJSUFF)       \
+       $(S)/LexPascal.$(OBJSUFF)       \
+       $(S)/LexPerl.$(OBJSUFF)         \
+       $(S)/LexPython.$(OBJSUFF)       \
+       $(S)/LexRuby.$(OBJSUFF)         \
+       $(S)/LexSQL.$(OBJSUFF)          \
+       $(S)/LexVB.$(OBJSUFF)           \
+        $(S)/LineMarker.$(OBJSUFF)     \
+        $(S)/PropSet.$(OBJSUFF)                \
+       $(S)/RESearch.$(OBJSUFF)        \
+        $(S)/ScintillaBase.$(OBJSUFF)  \
+        $(S)/Style.$(OBJSUFF)          \
+       $(S)/StyleContext.$(OBJSUFF)    \
        $(S)/UniConversion.$(OBJSUFF)   \
        $(S)/UniConversion.$(OBJSUFF)   \
+        $(S)/ViewStyle.$(OBJSUFF)      \
        $(S)/WindowAccessor.$(OBJSUFF)  \
        $(S)/WindowAccessor.$(OBJSUFF)  \
-       $(S)/PosRegExp.$(OBJSUFF) \
+       \
        PlatWX.$(OBJSUFF) \
        ScintillaWX.$(OBJSUFF) \
        stc.$(OBJSUFF)
        PlatWX.$(OBJSUFF) \
        ScintillaWX.$(OBJSUFF) \
        stc.$(OBJSUFF)
index fa0f4a7e77471f6ed7f70d5ee1bd2fe7d436377c..9c6d478b878317c07aa30aa96e4abf57ae82b343 100644 (file)
@@ -15,40 +15,41 @@ NOPCH=1
 !include $(WXDIR)\src\makevc.env
 
 OBJECTS = \
 !include $(WXDIR)\src\makevc.env
 
 OBJECTS = \
-       $(D)\AutoComplete.obj   \
-       $(D)\CallTip.obj        \
-       $(D)\CellBuffer.obj     \
-       $(D)\ContractionState.obj\
-       $(D)\Document.obj       \
-       $(D)\DocumentAccessor.obj\
-       $(D)\Editor.obj         \
-       $(D)\Indicator.obj      \
-       $(D)\KeyMap.obj         \
-       $(D)\KeyWords.obj       \
-       $(D)\LineMarker.obj     \
-       $(D)\PropSet.obj        \
-       $(D)\RESearch.obj       \
-       $(D)\ScintillaBase.obj  \
-       $(D)\Style.obj          \
-       $(D)\UniConversion.obj  \
-       $(D)\ViewStyle.obj      \
-       $(D)\WindowAccessor.obj \
-                               \
-       $(D)\LexAda.obj         \
-       $(D)\LexAVE.obj         \
-       $(D)\LexConf.obj        \
-       $(D)\LexCPP.obj         \
-       $(D)\LexEiffel.obj      \
-       $(D)\LexHTML.obj        \
-       $(D)\LexLisp.obj        \
-       $(D)\LexLua.obj         \
-       $(D)\LexOthers.obj      \
-       $(D)\LexPascal.obj      \
-       $(D)\LexPerl.obj        \
-       $(D)\LexPython.obj      \
-       $(D)\LexRuby.obj        \
-       $(D)\LexSQL.obj         \
-       $(D)\LexVB.obj          \
+        $(D)\AutoComplete.obj          \
+        $(D)\CallTip.obj               \
+        $(D)\CellBuffer.obj            \
+        $(D)\ContractionState.obj      \
+        $(D)\Document.obj              \
+       $(D)\DocumentAccessor.obj       \
+        $(D)\Editor.obj                        \
+        $(D)\Indicator.obj             \
+        $(D)\KeyMap.obj                        \
+        $(D)\KeyWords.obj              \
+       $(D)\LexAVE.obj                 \
+       $(D)\LexAda.obj                 \
+       $(D)\LexCPP.obj                 \
+       $(D)\LexConf.obj                \
+       $(D)\LexCrontab.obj             \
+       $(D)\LexEiffel.obj              \
+       $(D)\LexHTML.obj                \
+       $(D)\LexLisp.obj                \
+       $(D)\LexLua.obj                 \
+       $(D)\LexOthers.obj              \
+       $(D)\LexPascal.obj              \
+       $(D)\LexPerl.obj                \
+       $(D)\LexPython.obj              \
+       $(D)\LexRuby.obj                \
+       $(D)\LexSQL.obj                 \
+       $(D)\LexVB.obj                  \
+        $(D)\LineMarker.obj            \
+        $(D)\PropSet.obj               \
+       $(D)\RESearch.obj               \
+        $(D)\ScintillaBase.obj         \
+        $(D)\Style.obj                 \
+       $(D)\StyleContext.obj           \
+       $(D)\UniConversion.obj          \
+        $(D)\ViewStyle.obj             \
+       $(D)\WindowAccessor.obj         \
                                \
        $(D)\PlatWX.obj         \
        $(D)\ScintillaWX.obj    \
                                \
        $(D)\PlatWX.obj         \
        $(D)\ScintillaWX.obj    \
index 598da70f58b7750830d6a3857bfd8e80903418f9..98c4018245daeece4d84dea59b1f5d5876cd94d5 100644 (file)
@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
 distribution.  All other code needed to implement Scintilla on top of
 wxWindows is located in the directory above this one.
 
 distribution.  All other code needed to implement Scintilla on top of
 wxWindows is located in the directory above this one.
 
-The current version of the Scintilla code is 1.39
+The current version of the Scintilla code is 1.40
 
 
index 591bd06aa1a4a6a8bbd4765d3da8aa34af146cc3..680cb1513855d47b6221908c7f717ba3cca2a7b5 100644 (file)
@@ -40,6 +40,7 @@
 #define SCLEX_EIFFEL 23
 #define SCLEX_EIFFELKW 24
 #define SCLEX_TCL 25
 #define SCLEX_EIFFEL 23
 #define SCLEX_EIFFELKW 24
 #define SCLEX_TCL 25
+#define SCLEX_NNCRONTAB 26
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -72,6 +73,8 @@
 #define SCE_C_REGEX 14
 #define SCE_C_COMMENTLINEDOC 15
 #define SCE_C_WORD2 16
 #define SCE_C_REGEX 14
 #define SCE_C_COMMENTLINEDOC 15
 #define SCE_C_WORD2 16
+#define SCE_C_COMMENTDOCKEYWORD 17
+#define SCE_C_COMMENTDOCKEYWORDERROR 18
 #define SCE_H_DEFAULT 0
 #define SCE_H_TAG 1
 #define SCE_H_TAGUNKNOWN 2
 #define SCE_H_DEFAULT 0
 #define SCE_H_TAG 1
 #define SCE_H_TAGUNKNOWN 2
 #define SCE_H_QUESTION 18
 #define SCE_H_VALUE 19
 #define SCE_H_XCCOMMENT 20
 #define SCE_H_QUESTION 18
 #define SCE_H_VALUE 19
 #define SCE_H_XCCOMMENT 20
-#define SCE_H_SGML 21
+#define SCE_H_SGML_DEFAULT 21
+#define SCE_H_SGML_COMMAND 22
+#define SCE_H_SGML_1ST_PARAM 23
+#define SCE_H_SGML_DOUBLESTRING 24
+#define SCE_H_SGML_SIMPLESTRING 25
+#define SCE_H_SGML_ERROR 26
+#define SCE_H_SGML_SPECIAL 27
+#define SCE_H_SGML_ENTITY 28
+#define SCE_H_SGML_COMMENT 29
+#define SCE_H_SGML_1ST_PARAM_COMMENT 30
+#define SCE_H_SGML_BLOCK_DEFAULT 31
 #define SCE_HJ_START 40
 #define SCE_HJ_DEFAULT 41
 #define SCE_HJ_COMMENT 42
 #define SCE_HJ_START 40
 #define SCE_HJ_DEFAULT 41
 #define SCE_HJ_COMMENT 42
 #define SCE_EIFFEL_OPERATOR 6
 #define SCE_EIFFEL_IDENTIFIER 7
 #define SCE_EIFFEL_STRINGEOL 8
 #define SCE_EIFFEL_OPERATOR 6
 #define SCE_EIFFEL_IDENTIFIER 7
 #define SCE_EIFFEL_STRINGEOL 8
+#define SCE_NNCRONTAB_DEFAULT 0
+#define SCE_NNCRONTAB_COMMENT 1
+#define SCE_NNCRONTAB_TASK 2
+#define SCE_NNCRONTAB_SECTION 3
+#define SCE_NNCRONTAB_KEYWORD 4
+#define SCE_NNCRONTAB_MODIFIER 5
+#define SCE_NNCRONTAB_ASTERISK 6
+#define SCE_NNCRONTAB_NUMBER 7
+#define SCE_NNCRONTAB_STRING 8
+#define SCE_NNCRONTAB_ENVIRONMENT 9
+#define SCE_NNCRONTAB_IDENTIFIER 10
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #endif
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #endif
index 0185d3e5be6cac69c7b19f8e888bba79cc4235b0..abe1581a49c018373e9c7c1a148e0e942193aba0 100644 (file)
@@ -11,9 +11,6 @@
 #ifndef SCINTILLA_H
 #define SCINTILLA_H
 
 #ifndef SCINTILLA_H
 #define SCINTILLA_H
 
-// Compile-time configuration options
-#define MACRO_SUPPORT 1  // Comment out to remove macro hooks
-
 #if PLAT_WIN
 #ifdef STATIC_BUILD
 void Scintilla_RegisterClasses(HINSTANCE hInstance);
 #if PLAT_WIN
 #ifdef STATIC_BUILD
 void Scintilla_RegisterClasses(HINSTANCE hInstance);
@@ -102,6 +99,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SC_MARK_CIRCLEPLUSCONNECTED 19
 #define SC_MARK_CIRCLEMINUS 20
 #define SC_MARK_CIRCLEMINUSCONNECTED 21
 #define SC_MARK_CIRCLEPLUSCONNECTED 19
 #define SC_MARK_CIRCLEMINUS 20
 #define SC_MARK_CIRCLEMINUSCONNECTED 21
+#define SC_MARK_CHARACTER 10000
 #define SC_MARKNUM_FOLDEREND 25
 #define SC_MARKNUM_FOLDEROPENMID 26
 #define SC_MARKNUM_FOLDERMIDTAIL 27
 #define SC_MARKNUM_FOLDEREND 25
 #define SC_MARKNUM_FOLDEROPENMID 26
 #define SC_MARKNUM_FOLDERMIDTAIL 27
@@ -134,6 +132,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define STYLE_BRACEBAD 35
 #define STYLE_CONTROLCHAR 36
 #define STYLE_INDENTGUIDE 37
 #define STYLE_BRACEBAD 35
 #define STYLE_CONTROLCHAR 36
 #define STYLE_INDENTGUIDE 37
+#define STYLE_LASTPREDEFINED 39
 #define STYLE_MAX 127
 #define SC_CHARSET_ANSI 0
 #define SC_CHARSET_DEFAULT 1
 #define STYLE_MAX 127
 #define SC_CHARSET_ANSI 0
 #define SC_CHARSET_DEFAULT 1
@@ -507,12 +506,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCN_DWELLEND 2017
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #define SCN_DWELLEND 2017
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
-// Optional module for macro recording
-#ifdef MACRO_SUPPORT
-typedef void (tMacroRecorder)(unsigned int iMessage, unsigned long wParam, 
-       long lParam, void *userData);
-#endif
-
 // These structures are defined to be exactly the same shape as the Win32
 // CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
 // So older code that treats Scintilla as a RichEdit will work.
 // These structures are defined to be exactly the same shape as the Win32
 // CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
 // So older code that treats Scintilla as a RichEdit will work.
@@ -566,11 +559,9 @@ struct SCNotification {
        const char *text;       // SCN_MODIFIED
        int length;             // SCN_MODIFIED
        int linesAdded; // SCN_MODIFIED
        const char *text;       // SCN_MODIFIED
        int length;             // SCN_MODIFIED
        int linesAdded; // SCN_MODIFIED
-#ifdef MACRO_SUPPORT
        int message;    // SCN_MACRORECORD
        uptr_t wParam;  // SCN_MACRORECORD
        int message;    // SCN_MACRORECORD
        uptr_t wParam;  // SCN_MACRORECORD
-       sptr_t lParam;          // SCN_MACRORECORD
-#endif
+       sptr_t lParam;  // SCN_MACRORECORD
        int line;               // SCN_MODIFIED
        int foldLevelNow;       // SCN_MODIFIED
        int foldLevelPrev;      // SCN_MODIFIED
        int line;               // SCN_MODIFIED
        int foldLevelNow;       // SCN_MODIFIED
        int foldLevelPrev;      // SCN_MODIFIED
index 90360076fa5f48bd032cd19ed705ef3b50ca48b2..7724efdb00180d95b9e04c16859135aaee82fd7c 100644 (file)
@@ -229,6 +229,8 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
 val SC_MARK_CIRCLEMINUS=20
 val SC_MARK_CIRCLEMINUSCONNECTED=21
 
 val SC_MARK_CIRCLEMINUS=20
 val SC_MARK_CIRCLEMINUSCONNECTED=21
 
+val SC_MARK_CHARACTER=10000
+
 # Markers used for outlining column
 val SC_MARKNUM_FOLDEREND=25
 val SC_MARKNUM_FOLDEROPENMID=26
 # Markers used for outlining column
 val SC_MARKNUM_FOLDEREND=25
 val SC_MARKNUM_FOLDEROPENMID=26
@@ -292,12 +294,15 @@ set void SetMarginSensitiveN=2246(int margin, bool sensitive)
 # Retrieve the mouse click sensitivity of a margin.
 get bool GetMarginSensitiveN=2247(int margin,)
 
 # Retrieve the mouse click sensitivity of a margin.
 get bool GetMarginSensitiveN=2247(int margin,)
 
+# Styles in range 32..37 are predefined for parts of the UI and are not used as normal styles.
+# Styles 38 and 39 are for future use.
 val STYLE_DEFAULT=32
 val STYLE_LINENUMBER=33
 val STYLE_BRACELIGHT=34
 val STYLE_BRACEBAD=35
 val STYLE_CONTROLCHAR=36
 val STYLE_INDENTGUIDE=37
 val STYLE_DEFAULT=32
 val STYLE_LINENUMBER=33
 val STYLE_BRACELIGHT=34
 val STYLE_BRACEBAD=35
 val STYLE_CONTROLCHAR=36
 val STYLE_INDENTGUIDE=37
+val STYLE_LASTPREDEFINED=39
 val STYLE_MAX=127
 
 # Character set identifiers are used in StyleSetCharacterSet.
 val STYLE_MAX=127
 
 # Character set identifiers are used in StyleSetCharacterSet.
@@ -759,10 +764,12 @@ set void SetTargetEnd=2192(position pos,)
 get position GetTargetEnd=2193(,)
 
 # Replace the target text with the argument text.
 get position GetTargetEnd=2193(,)
 
 # Replace the target text with the argument text.
+# Text is counted so it can contain nulls.
 # Returns the length of the replacement text.
 fun int ReplaceTarget=2194(int length, string text)
 
 # Replace the target text with the argument text after \d processing.
 # Returns the length of the replacement text.
 fun int ReplaceTarget=2194(int length, string text)
 
 # Replace the target text with the argument text after \d processing.
+# Text is counted so it can contain nulls.
 # Looks for \d where d is between 1 and 9 and replaces these with the strings
 # matched in the last search operation which were surrounded by \( and \).
 # Returns the length of the replacement text including any change
 # Looks for \d where d is between 1 and 9 and replaces these with the strings
 # matched in the last search operation which were surrounded by \( and \).
 # Returns the length of the replacement text including any change
@@ -770,7 +777,7 @@ fun int ReplaceTarget=2194(int length, string text)
 fun int ReplaceTargetRE=2195(int length, string text)
 
 # Search for a counted string in the target and set the target to the found
 fun int ReplaceTargetRE=2195(int length, string text)
 
 # Search for a counted string in the target and set the target to the found
-# range.
+# range. Text is counted so it can contain nulls.
 # Returns length of range or -1 for failure in which case target is not moved.
 fun int SearchInTarget=2197(int length, string text)
 
 # Returns length of range or -1 for failure in which case target is not moved.
 fun int SearchInTarget=2197(int length, string text)
 
@@ -1265,6 +1272,7 @@ val SCLEX_RUBY=22
 val SCLEX_EIFFEL=23
 val SCLEX_EIFFELKW=24
 val SCLEX_TCL=25
 val SCLEX_EIFFEL=23
 val SCLEX_EIFFELKW=24
 val SCLEX_TCL=25
+val SCLEX_NNCRONTAB=26
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
 val SCLEX_AUTOMATIC=1000
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
 val SCLEX_AUTOMATIC=1000
@@ -1301,6 +1309,8 @@ val SCE_C_VERBATIM=13
 val SCE_C_REGEX=14
 val SCE_C_COMMENTLINEDOC=15
 val SCE_C_WORD2=16
 val SCE_C_REGEX=14
 val SCE_C_COMMENTLINEDOC=15
 val SCE_C_WORD2=16
+val SCE_C_COMMENTDOCKEYWORD=17
+val SCE_C_COMMENTDOCKEYWORDERROR=18
 # Lexical states for SCLEX_HTML, SCLEX_XML
 val SCE_H_DEFAULT=0
 val SCE_H_TAG=1
 # Lexical states for SCLEX_HTML, SCLEX_XML
 val SCE_H_DEFAULT=0
 val SCE_H_TAG=1
@@ -1327,7 +1337,17 @@ val SCE_H_VALUE=19
 # X-Code
 val SCE_H_XCCOMMENT=20
 # SGML
 # X-Code
 val SCE_H_XCCOMMENT=20
 # SGML
-val SCE_H_SGML=21
+val SCE_H_SGML_DEFAULT=21
+val SCE_H_SGML_COMMAND=22
+val SCE_H_SGML_1ST_PARAM=23
+val SCE_H_SGML_DOUBLESTRING=24
+val SCE_H_SGML_SIMPLESTRING=25
+val SCE_H_SGML_ERROR=26
+val SCE_H_SGML_SPECIAL=27
+val SCE_H_SGML_ENTITY=28
+val SCE_H_SGML_COMMENT=29
+val SCE_H_SGML_1ST_PARAM_COMMENT=30
+val SCE_H_SGML_BLOCK_DEFAULT=31
 # Embedded Javascript
 val SCE_HJ_START=40
 val SCE_HJ_DEFAULT=41
 # Embedded Javascript
 val SCE_HJ_START=40
 val SCE_HJ_DEFAULT=41
@@ -1547,6 +1567,18 @@ val SCE_EIFFEL_CHARACTER=5
 val SCE_EIFFEL_OPERATOR=6
 val SCE_EIFFEL_IDENTIFIER=7
 val SCE_EIFFEL_STRINGEOL=8
 val SCE_EIFFEL_OPERATOR=6
 val SCE_EIFFEL_IDENTIFIER=7
 val SCE_EIFFEL_STRINGEOL=8
+# Lexical states for the SCLEX_NNCRONTAB (nnCron crontab Lexer)
+val SCE_NNCRONTAB_DEFAULT=0
+val SCE_NNCRONTAB_COMMENT=1
+val SCE_NNCRONTAB_TASK=2
+val SCE_NNCRONTAB_SECTION=3
+val SCE_NNCRONTAB_KEYWORD=4
+val SCE_NNCRONTAB_MODIFIER=5
+val SCE_NNCRONTAB_ASTERISK=6
+val SCE_NNCRONTAB_NUMBER=7
+val SCE_NNCRONTAB_STRING=8
+val SCE_NNCRONTAB_ENVIRONMENT=9
+val SCE_NNCRONTAB_IDENTIFIER=10
 
 # Events
 
 
 # Events
 
@@ -1574,171 +1606,3 @@ evt void DwellStart=2016(int position)
 evt void DwellEnd=2017(int position)
 
 cat Deprecated
 evt void DwellEnd=2017(int position)
 
 cat Deprecated
-
-val SCFIND_DOWN=1
-
-################################################
-# From WinDefs.h
-
-# ***** DEPRECATED from here to end of file ******
-
-# Will a paste succeed?
-fun bool EM_CanPaste=1074(,)
-
-# Are there any undoable actions in the undo history.
-fun bool EM_CanUndo=198(,)
-
-# Find the position and line from a point within the window.
-fun int EM_CharFromPos=215(,point pt)
-
-# Delete the undo history.
-fun void EM_EmptyUndoBuffer=205(,)
-
-# Retrieve the selection range.
-fun void EM_ExGetSel=1076(,charrangeresult cr)
-
-# Retrieve the line number of a position in the document.
-get int EM_ExLineFromChar=1078(,position pos)
-
-# Select a range of text.
-fun void EM_ExSetSel=1079(,charrange cr)
-
-# Find some text in the document.
-fun position EM_FindText=1080(int flags, findtext ft)
-
-# Find some text in the document. Returns range of found text in ft argument.
-fun position EM_FindTextEx=1103(int flags, findtextex ft)
-
-# On Windows will draw the document into a display context such as a printer.
-fun void EM_FormatRange=1081(bool draw, formatrange fr)
-
-# Retrieve the line at the top of the display.
-get int EM_GetFirstVisibleLine=206(,)
-
-# Retrieve the contents of a line.
-# Returns the length of the line.
-fun int EM_GetLine=196(int line, countedstring text)
-
-# Returns the number of lines in the document. There is always at least one.
-fun int EM_GetLineCount=186(,)
-
-# Returns the size in pixels of left and right margins packed into one integer.
-# The left margin is in the low half and the right margin in the high half.
-fun int EM_GetMargins=212(,)
-
-# Is the document different from when it was last saved?
-get bool EM_GetModify=184(,)
-
-# Get the area used to display the document.
-fun void EM_GetRect=178(,rectangle r)
-
-# Return the selection packed into one integer with the start of the selection
-# in the low half and the end in the high half.
-fun int EM_GetSel=176(,)
-
-# Retrieve the selected text.
-# Return the length of the text.
-fun int EM_GetSelText=1086(,stringresult text)
-
-# Retrieve a range of text.
-# Return the length of the text.
-fun int EM_GetTextRange=1099(, textrange tr)
-
-# Draw the selection in normal style or with selection highlighted.
-fun void EM_HideSelection=1087(bool normal,)
-
-# Retrieve the line of a position.
-fun int EM_LineFromChar=201(position pos,)
-
-# Retrieve the position at the start of a line.
-fun position EM_LineIndex=187(int line,)
-
-# Retrieve the number of characters on a line not including end of line characters.
-fun int EM_LineLength=193(int line,)
-
-# Scroll horizontally and vertically.
-fun void EM_LineScroll=182(int columns, int lines)
-
-# Retrieve the point in the window where a position is displayed.
-fun void EM_PosFromChar=214(pointresult pt, position pos)
-
-# Replace the selected text with the argument text.
-fun void EM_ReplaceSel=194(, string text)
-
-# Ensure the caret is visible.
-fun void EM_ScrollCaret=183(,)
-
-# Returns SEL_EMPTY if selection contains no characters, otherwise SEL_TEXT.
-fun void EM_SelectionType=1090(,)
-
-# Set the width of the left and right margins
-fun void EM_SetMargins=211(int flags, int values)
-
-# Set to read only or read write.
-set void EM_SetReadOnly=207(bool readOnly,)
-
-# Select the range of text from start to end.
-fun void EM_SetSel=177(position start, position end)
-
-# Undo one action in the undo history.
-fun void EM_Undo=199(,)
-
-# Null operation.
-fun void WM_Null=0(,)
-
-# Clear the selection.
-fun void WM_Clear=771(,)
-
-fun void WM_Command=273(,)
-
-# Copy the selection to the clipboard.
-fun void WM_Copy=769(,)
-
-# Cut the selection to the clipboard.
-fun void WM_Cut=768(,)
-
-# Retrieve all the text in the document.
-# Returns number of characters retrieved.
-fun int WM_GetText=13(int length, stringresult text)
-
-# Retrieve the number of characters in the document.
-fun int WM_GetTextLength=14(,)
-
-# Notification back to container
-fun void WM_Notify=78(int id, int stuff)
-
-# Paste the contents of the clipboard into the document replacing the selection.
-fun void WM_Paste=770(,)
-
-# Replace the contents of the document with the argument text.
-fun void WM_SetText=12(, string text)
-
-# Undo one action in the undo history.
-fun void WM_Undo=772(,)
-
-# Notification codes
-val EN_CHANGE=768
-val EN_KILLFOCUS=512
-val EN_SETFOCUS=256
-
-# Flags for setting margins.
-val EC_LEFTMARGIN=1
-val EC_RIGHTMARGIN=2
-val EC_USEFONTINFO=0xffff
-
-# Selection type.
-val SEL_EMPTY=0
-val SEL_TEXT=1
-
-# Find replace mask constants
-val FR_MATCHCASE=0x4
-val FR_WHOLEWORD=0x2
-val FR_DOWN=0x1
-
-# Key modifier flag.
-val SHIFT_PRESSED=1
-val LEFT_CTRL_PRESSED=2
-val LEFT_ALT_PRESSED=4
-
-#events
-evt void EN_Change=768(void)
index f6c2fc3542c343af2c1cd05622063e6c6da084d3..6e22f58f8b6b3b19427950d43a7bd2a2cf036582 100644 (file)
 
 #if PLAT_GTK
 
 
 #if PLAT_GTK
 
-#ifndef SCINTILLA_H
-#ifdef _MSC_VER
-#pragma message(__FILE__ "(1) : warning : Scintilla.h should be included before ScintillaWidget.h")
-#pragma message("This will be required in the next version of Scintilla")
-#else
-#warning Scintilla.h should be included before ScintillaWidget.h
-#warning This will be required in the next version of Scintilla
-#endif
-#include "Scintilla.h"
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/contrib/src/stc/scintilla/include/WinDefs.h b/contrib/src/stc/scintilla/include/WinDefs.h
deleted file mode 100644 (file)
index b3421c0..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-// Scintilla source code edit control
-/** @file WinDefs.h
- ** The subset of definitions from Windows needed by Scintilla for GTK+.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef WINDEFS_H
-#define WINDEFS_H
-
-/* Running GTK version on win32 */
-#if PLAT_GTK_WIN32
-#include "Windows.h"
-#include "Richedit.h"
-
-/* Name conflicts */
-#undef DrawText
-#undef FindText
-#else
-
-#define WORD short
-#define WPARAM unsigned long
-#define LPARAM long
-#define LRESULT long
-#define DWORD long
-
-#define UINT unsigned int
-#define LPSTR char *
-#define LONG long
-
-//#if 0
-/* RTF control */
-#define EM_CANPASTE    (1074)
-#define EM_CANUNDO     (198)
-#define EM_CHARFROMPOS (215)
-#define EM_EMPTYUNDOBUFFER     (205)
-#define EM_EXGETSEL    (1076)
-#define EM_EXLINEFROMCHAR      (1078)
-#define EM_EXSETSEL    (1079)
-#define EM_FINDTEXT    (1080)
-#define EM_FINDTEXTEX  (1103)
-#define EM_FORMATRANGE (1081)
-#define EM_GETFIRSTVISIBLELINE (206)
-#define EM_GETLINE     (196)
-#define EM_GETLINECOUNT        (186)
-#define EM_GETMARGINS  (212)
-#define EM_GETMODIFY   (184)
-#define EM_GETRECT     (178)
-#define EM_GETSEL      (176)
-#define EM_GETSELTEXT  (1086)
-#define EM_GETTEXTRANGE        (1099)
-#define EM_HIDESELECTION       (1087)
-#define EM_LINEFROMCHAR        (201)
-#define EM_LINEINDEX   (187)
-#define EM_LINELENGTH  (193)
-#define EM_LINESCROLL  (182)
-#define EM_POSFROMCHAR (214)
-#define EM_REPLACESEL  (194)
-#define EM_SCROLLCARET (183)
-#define EM_SELECTIONTYPE       (1090)
-#define EM_SETMARGINS  (211)
-#define EM_SETREADONLY (207)
-#define EM_SETSEL      (177)
-#define EM_UNDO        (199)
-
-#define WM_NULL                (0)
-#define WM_CLEAR       (771)
-#define WM_COPY        (769)
-#define WM_CUT (768)
-#define WM_GETTEXT     (13)
-#define WM_GETTEXTLENGTH       (14)
-#define WM_PASTE       (770)
-#define WM_SETTEXT     (12)
-#define WM_UNDO        (772)
-
-#define EN_CHANGE      (768)
-#define EN_KILLFOCUS (512)
-#define EN_SETFOCUS (256)
-
-#define EC_LEFTMARGIN 1
-#define EC_RIGHTMARGIN 2
-#define EC_USEFONTINFO 0xffff
-
-//#endif
-
-#if 0
-#if PLAT_GTK
-#define VK_DOWN GDK_Down
-#define VK_UP GDK_Up
-#define VK_LEFT GDK_Left
-#define VK_RIGHT GDK_Right
-#define VK_HOME GDK_Home
-#define VK_END GDK_End
-#define VK_PRIOR GDK_Page_Up
-#define VK_NEXT GDK_Page_Down
-#define VK_DELETE GDK_Delete
-#define VK_INSERT GDK_Insert
-#define VK_ESCAPE GDK_Escape
-#define VK_BACK GDK_BackSpace
-#define VK_TAB GDK_Tab
-#define VK_RETURN GDK_Return
-#define VK_ADD GDK_KP_Add
-#define VK_SUBTRACT GDK_KP_Subtract
-#define VK_DIVIDE GDK_KP_Divide
-#endif
-
-#if PLAT_WX
-#define VK_DOWN         WXK_DOWN
-#define VK_UP           WXK_UP
-#define VK_LEFT         WXK_LEFT
-#define VK_RIGHT        WXK_RIGHT
-#define VK_HOME         WXK_HOME
-#define VK_END          WXK_END
-#define VK_PRIOR        WXK_PRIOR
-#define VK_NEXT         WXK_NEXT
-#define VK_DELETE       WXK_DELETE
-#define VK_INSERT       WXK_INSERT
-#define VK_ESCAPE       WXK_ESCAPE
-#define VK_BACK         WXK_BACK
-#define VK_TAB          WXK_TAB
-#define VK_RETURN       WXK_RETURN
-#define VK_ADD          WXK_ADD
-#define VK_SUBTRACT     WXK_SUBTRACT
-//TODO:
-#define VK_DIVIDE      WXK_DIVIDE
-#endif
-
-#define SHIFT_PRESSED 1
-#define LEFT_CTRL_PRESSED 2
-#define LEFT_ALT_PRESSED 4
-
-// Are these needed any more
-#define LPSTR char *
-#define LONG long
-#define LPDWORD (long *)
-
-/* SELCHANGE structure */
-#define SEL_EMPTY      (0)
-#define SEL_TEXT       (1)
-#define SEL_OBJECT     (2)
-#define SEL_MULTICHAR  (4)
-#define SEL_MULTIOBJECT        (8)
-
-struct RECT {
-       LONG left;
-       LONG top;
-       LONG right;
-       LONG bottom;
-};
-
-/* FINDREPLACE structure */
-
-#define FR_MATCHCASE   (0x4)
-#define FR_WHOLEWORD   (0x2)
-#define FR_DOWN                (0x1)
-
-#endif
-
-#if 0
-struct CHARRANGE {
-       LONG cpMin;
-       LONG cpMax;
-};
-
-struct TEXTRANGE {
-       CHARRANGE chrg;
-       LPSTR lpstrText;
-};
-
-struct FINDTEXTEX {
-       CHARRANGE chrg;
-       LPSTR lpstrText;
-       CHARRANGE chrgText;
-};
-
-struct NMHDR {
-       WindowID hwndFrom;
-       UINT idFrom;
-       UINT code;
-};
-
-struct FORMATRANGE {
-       SurfaceID hdc;
-       SurfaceID hdcTarget;
-       RECT rc;
-       RECT rcPage;
-       CHARRANGE chrg;
-};
-#endif
-
-//#define MAKELONG(a, b) ((a) | ((b) << 16))
-//#define LOWORD(x) (x & 0xffff)
-//#define HIWORD(x) (x >> 16)
-
-#endif /* !_MSC_VER */
-
-#endif
index 10403242b9378ffc64a181c3de46197a753fddbd..abbb87d5dc9cce22a177a954c75fd6018311a433 100644 (file)
@@ -357,8 +357,10 @@ void Document::ModifiedAt(int pos) {
 
 // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 void Document::DeleteChars(int pos, int len) {
 
 // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 void Document::DeleteChars(int pos, int len) {
+       if (len == 0)
+               return;
        if ((pos + len) > Length())
        if ((pos + len) > Length())
-               return ;
+               return;
        if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
                enteredReadOnlyCount++;
                NotifyModifyAttempt();
        if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
                enteredReadOnlyCount++;
                NotifyModifyAttempt();
index 5b72ac579d28886b60c18035c20d7f1ddd955c85..2171924f0fd5eea90a496b6d8b5a139b573c0ba0 100644 (file)
 
 #include "Scintilla.h"
 
 
 #include "Scintilla.h"
 
-#if PLAT_WX || PLAT_GTK
-#include "WinDefs.h"
-#endif 
-
 #include "ContractionState.h"
 #include "SVector.h"
 #include "CellBuffer.h"
 #include "ContractionState.h"
 #include "SVector.h"
 #include "CellBuffer.h"
@@ -58,7 +54,6 @@ Editor::Editor() {
        dwelling = false;
        ptMouseLast.x = 0;
        ptMouseLast.y = 0;
        dwelling = false;
        ptMouseLast.x = 0;
        ptMouseLast.y = 0;
-       firstExpose = true;
        inDragDrop = false;
        dropWentOutside = false;
        posDrag = invalidPosition;
        inDragDrop = false;
        dropWentOutside = false;
        posDrag = invalidPosition;
@@ -69,9 +64,6 @@ Editor::Editor() {
        lineAnchor = 0;
        originalAnchorPos = 0;
 
        lineAnchor = 0;
        originalAnchorPos = 0;
 
-       dragChars = 0;
-       lenDrag = 0;
-       dragIsRectangle = false;
        selType = selStream;
        xStartSelect = 0;
        xEndSelect = 0;
        selType = selStream;
        xStartSelect = 0;
        xEndSelect = 0;
@@ -85,9 +77,6 @@ Editor::Editor() {
 
        searchAnchor = 0;
 
 
        searchAnchor = 0;
 
-       ucWheelScrollLines = 0;
-       cWheelDelta = 0;   //wheel delta from roll
-
        xOffset = 0;
        xCaretMargin = 50;
        horizontalScrollBarVisible = true;
        xOffset = 0;
        xCaretMargin = 50;
        horizontalScrollBarVisible = true;
@@ -114,15 +103,11 @@ Editor::Editor() {
 
        modEventMask = SC_MODEVENTMASKALL;
 
 
        modEventMask = SC_MODEVENTMASKALL;
 
-       displayPopupMenu = true;
-
        pdoc = new Document();
        pdoc ->AddRef();
        pdoc->AddWatcher(this, 0);
 
        pdoc = new Document();
        pdoc ->AddRef();
        pdoc->AddWatcher(this, 0);
 
-#ifdef MACRO_SUPPORT
-       recordingMacro = 0;
-#endif 
+       recordingMacro = false;
        foldFlags = 0;
 }
 
        foldFlags = 0;
 }
 
@@ -131,10 +116,6 @@ Editor::~Editor() {
        pdoc->Release();
        pdoc = 0;
        DropGraphics();
        pdoc->Release();
        pdoc = 0;
        DropGraphics();
-
-       delete []dragChars;
-       dragChars = 0;
-       lenDrag = 0;
 }
 
 void Editor::Finalise() {
 }
 
 void Editor::Finalise() {
@@ -874,7 +855,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
                                if (marks) {
                                        for (int markBit = 0; (markBit < 32) && marks; markBit++) {
                                                if (marks & 1) {
                                if (marks) {
                                        for (int markBit = 0; (markBit < 32) && marks; markBit++) {
                                                if (marks & 1) {
-                                                       vs.markers[markBit].Draw(surface, rcMarker);
+                                                       vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font);
                                                }
                                                marks >>= 1;
                                        }
                                                }
                                                marks >>= 1;
                                        }
@@ -1917,14 +1898,12 @@ void Editor::NotifyChar(int ch) {
        scn.nmhdr.code = SCN_CHARADDED;
        scn.ch = ch;
        NotifyParent(scn);
        scn.nmhdr.code = SCN_CHARADDED;
        scn.ch = ch;
        NotifyParent(scn);
-#ifdef MACRO_SUPPORT
        if (recordingMacro) {
                char txt[2];
                txt[0] = static_cast<char>(ch);
                txt[1] = '\0';
                NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<long>(txt));
        }
        if (recordingMacro) {
                char txt[2];
                txt[0] = static_cast<char>(ch);
                txt[1] = '\0';
                NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<long>(txt));
        }
-#endif 
 }
 
 void Editor::NotifySavePoint(bool isSavePoint) {
 }
 
 void Editor::NotifySavePoint(bool isSavePoint) {
@@ -2150,7 +2129,6 @@ void Editor::NotifyDeleted(Document *, void *) {
        /* Do nothing */
 }
 
        /* Do nothing */
 }
 
-#ifdef MACRO_SUPPORT
 void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam) {
 
        // Enumerates all macroable messages
 void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam) {
 
        // Enumerates all macroable messages
@@ -2159,10 +2137,6 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
        case SCI_COPY:
        case SCI_PASTE:
        case SCI_CLEAR:
        case SCI_COPY:
        case SCI_PASTE:
        case SCI_CLEAR:
-       case WM_CUT:
-       case WM_COPY:
-       case WM_PASTE:
-       case WM_CLEAR:
        case SCI_REPLACESEL:
        case SCI_ADDTEXT:
        case SCI_INSERTTEXT:
        case SCI_REPLACESEL:
        case SCI_ADDTEXT:
        case SCI_INSERTTEXT:
@@ -2236,7 +2210,6 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
        scn.lParam = lParam;
        NotifyParent(scn);
 }
        scn.lParam = lParam;
        NotifyParent(scn);
 }
-#endif 
 
 // Force scroll and keep position relative to top of window
 void Editor::PageMove(int direction, bool extend) {
 
 // Force scroll and keep position relative to top of window
 void Editor::PageMove(int direction, bool extend) {
@@ -2674,7 +2647,6 @@ void Editor::Indent(bool forwards) {
  * @return The position of the found text, -1 if not found.
  */
 long Editor::FindText(
  * @return The position of the found text, -1 if not found.
  */
 long Editor::FindText(
-    unsigned int iMessage,     ///< Can be @c EM_FINDTEXT or @c EM_FINDTEXTEX or @c SCI_FINDTEXT.
     unsigned long wParam,      ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
     ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP.
     long lParam) {                     ///< @c TextToFind structure: The text to search for in the given range.
     unsigned long wParam,      ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
     ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP.
     long lParam) {                     ///< @c TextToFind structure: The text to search for in the given range.
@@ -2688,10 +2660,8 @@ long Editor::FindText(
                                 wParam & SCFIND_REGEXP,
                                 &lengthFound);
        if (pos != -1) {
                                 wParam & SCFIND_REGEXP,
                                 &lengthFound);
        if (pos != -1) {
-               if (iMessage != EM_FINDTEXT) {
-                       ft->chrgText.cpMin = pos;
-                       ft->chrgText.cpMax = pos + lengthFound;
-               }
+               ft->chrgText.cpMin = pos;
+               ft->chrgText.cpMax = pos + lengthFound;
        }
        return pos;
 }
        }
        return pos;
 }
@@ -2800,33 +2770,23 @@ char *Editor::CopyRange(int start, int end) {
        return text;
 }
 
        return text;
 }
 
-int Editor::SelectionRangeLength() {
+void Editor::CopySelectionRange(SelectionText *ss) {
+       char *text = 0;
+       int size = 0;
        if (selType == selRectangle) {
                int lineStart = pdoc->LineFromPosition(SelectionStart());
                int lineEnd = pdoc->LineFromPosition(SelectionEnd());
        if (selType == selRectangle) {
                int lineStart = pdoc->LineFromPosition(SelectionStart());
                int lineEnd = pdoc->LineFromPosition(SelectionEnd());
-               int totalSize = 0;
-               for (int line = lineStart; line <= lineEnd; line++) {
-                       totalSize += SelectionEnd(line) - SelectionStart(line) + 1;
+               int line;
+               for (line = lineStart; line <= lineEnd; line++) {
+                       size += SelectionEnd(line) - SelectionStart(line) + 1;
                        if (pdoc->eolMode == SC_EOL_CRLF)
                        if (pdoc->eolMode == SC_EOL_CRLF)
-                               totalSize++;
+                               size++;
                }
                }
-               return totalSize;
-       } else {
-               return SelectionEnd() - SelectionStart();
-       }
-}
-
-char *Editor::CopySelectionRange() {
-       if (selType == selRectangle) {
-               char *text = 0;
-               int lineStart = pdoc->LineFromPosition(SelectionStart());
-               int lineEnd = pdoc->LineFromPosition(SelectionEnd());
-               int totalSize = SelectionRangeLength();
-               if (totalSize > 0) {
-                       text = new char[totalSize + 1];
+               if (size > 0) {
+                       text = new char[size + 1];
                        if (text) {
                                int j = 0;
                        if (text) {
                                int j = 0;
-                               for (int line = lineStart; line <= lineEnd; line++) {
+                               for (line = lineStart; line <= lineEnd; line++) {
                                        for (int i = SelectionStart(line);i < SelectionEnd(line);i++) {
                                                text[j++] = pdoc->CharAt(i);
                                        }
                                        for (int i = SelectionStart(line);i < SelectionEnd(line);i++) {
                                                text[j++] = pdoc->CharAt(i);
                                        }
@@ -2835,24 +2795,14 @@ char *Editor::CopySelectionRange() {
                                        if (pdoc->eolMode != SC_EOL_CR)
                                                text[j++] = '\n';
                                }
                                        if (pdoc->eolMode != SC_EOL_CR)
                                                text[j++] = '\n';
                                }
-                               text[totalSize] = '\0';
+                               text[size] = '\0';
                        }
                }
                        }
                }
-               return text;
        } else {
        } else {
-               return CopyRange(SelectionStart(), SelectionEnd());
-       }
-}
-
-void Editor::CopySelectionIntoDrag() {
-       delete []dragChars;
-       dragChars = 0;
-       lenDrag = SelectionRangeLength();
-       dragChars = CopySelectionRange();
-       dragIsRectangle = selType == selRectangle;
-       if (!dragChars) {
-               lenDrag = 0;
+               size = SelectionEnd() - SelectionStart();
+               text = CopyRange(SelectionStart(), SelectionEnd());
        }
        }
+       ss->Set(text, size, selType == selRectangle);
 }
 
 void Editor::SetDragPosition(int newPos) {
 }
 
 void Editor::SetDragPosition(int newPos) {
@@ -2882,8 +2832,6 @@ void Editor::StartDrag() {
        //DisplayCursor(Window::cursorArrow);
 }
 
        //DisplayCursor(Window::cursorArrow);
 }
 
-
-
 void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
        //Platform::DebugPrintf("DropAt %d\n", inDragDrop);
        if (inDragDrop)
 void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
        //Platform::DebugPrintf("DropAt %d\n", inDragDrop);
        if (inDragDrop)
@@ -3115,7 +3063,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
                        if (inDragDrop) {
                                SetMouseCapture(false);
                                SetDragPosition(newPos);
                        if (inDragDrop) {
                                SetMouseCapture(false);
                                SetDragPosition(newPos);
-                               CopySelectionIntoDrag();
+                               CopySelectionRange(&drag);
                                StartDrag();
                        } else {
                                xStartSelect = pt.x - vs.fixedColumnWidth + xOffset;
                                StartDrag();
                        } else {
                                xStartSelect = pt.x - vs.fixedColumnWidth + xOffset;
@@ -3220,25 +3168,23 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
                        int selStart = SelectionStart();
                        int selEnd = SelectionEnd();
                        if (selStart < selEnd) {
                        int selStart = SelectionStart();
                        int selEnd = SelectionEnd();
                        if (selStart < selEnd) {
-                               if (dragChars && lenDrag) {
+                               if (drag.len) {
                                        if (ctrl) {
                                        if (ctrl) {
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else if (newPos < selStart) {
                                        } else if (newPos < selStart) {
-                                               pdoc->DeleteChars(selStart, lenDrag);
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->DeleteChars(selStart, drag.len);
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else if (newPos > selEnd) {
                                        } else if (newPos > selEnd) {
-                                               pdoc->DeleteChars(selStart, lenDrag);
-                                               newPos -= lenDrag;
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->DeleteChars(selStart, drag.len);
+                                               newPos -= drag.len;
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else {
                                                SetEmptySelection(newPos);
                                        }
                                        } else {
                                                SetEmptySelection(newPos);
                                        }
-                                       delete []dragChars;
-                                       dragChars = 0;
-                                       lenDrag = 0;
+                                       drag.Set(0, 0);
                                }
                                selectionType = selChar;
                        }
                                }
                                selectionType = selChar;
                        }
@@ -3545,14 +3491,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
        // Optional macro recording hook
        //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
        // Optional macro recording hook
-#ifdef MACRO_SUPPORT
        if (recordingMacro)
                NotifyMacroRecord(iMessage, wParam, lParam);
        if (recordingMacro)
                NotifyMacroRecord(iMessage, wParam, lParam);
-#endif 
 
        switch (iMessage) {
 
 
        switch (iMessage) {
 
-       case WM_GETTEXT:
        case SCI_GETTEXT:
                {
                        if (lParam == 0)
        case SCI_GETTEXT:
                {
                        if (lParam == 0)
@@ -3565,7 +3508,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return iChar;
                }
 
                        return iChar;
                }
 
-       case WM_SETTEXT:
        case SCI_SETTEXT:
                {
                        if (lParam == 0)
        case SCI_SETTEXT:
                {
                        if (lParam == 0)
@@ -3576,130 +3518,45 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return TRUE;
                }
 
                        return TRUE;
                }
 
-       case WM_GETTEXTLENGTH:
        case SCI_GETTEXTLENGTH:
                return pdoc->Length();
 
        case SCI_GETTEXTLENGTH:
                return pdoc->Length();
 
-       case WM_CUT:
        case SCI_CUT:
                Cut();
                SetLastXChosen();
                break;
 
        case SCI_CUT:
                Cut();
                SetLastXChosen();
                break;
 
-       case WM_COPY:
        case SCI_COPY:
                Copy();
                break;
 
        case SCI_COPY:
                Copy();
                break;
 
-       case WM_PASTE:
        case SCI_PASTE:
                Paste();
                SetLastXChosen();
                EnsureCaretVisible();
                break;
 
        case SCI_PASTE:
                Paste();
                SetLastXChosen();
                EnsureCaretVisible();
                break;
 
-       case WM_CLEAR:
        case SCI_CLEAR:
                Clear();
                SetLastXChosen();
                break;
 
        case SCI_CLEAR:
                Clear();
                SetLastXChosen();
                break;
 
-       case WM_UNDO:
        case SCI_UNDO:
                Undo();
                SetLastXChosen();
                break;
 
        case SCI_UNDO:
                Undo();
                SetLastXChosen();
                break;
 
-               // Edit control messages
-
-               // Not supported (no-ops):
-               //              EM_GETWORDBREAKPROC
-               //              EM_GETWORDBREAKPROCEX
-               //              EM_SETWORDBREAKPROC
-               //              EM_SETWORDBREAKPROCEX
-               //              EM_GETWORDWRAPMODE
-               //              EM_SETWORDWRAPMODE
-               //              EM_LIMITTEXT
-               //              EM_EXLIMITTEXT
-               //              EM_SETRECT
-               //              EM_SETRECTNP
-               //              EM_FMTLINES
-               //              EM_GETHANDLE
-               //              EM_SETHANDLE
-               //              EM_GETPASSWORDCHAR
-               //              EM_SETPASSWORDCHAR
-               //              EM_SETTABSTOPS
-               //              EM_FINDWORDBREAK
-               //              EM_GETCHARFORMAT
-               //              EM_SETCHARFORMAT
-               //              EM_GETOLEINTERFACE
-               //              EM_SETOLEINTERFACE
-               //              EM_SETOLECALLBACK
-               //              EM_GETPARAFORMAT
-               //              EM_SETPARAFORMAT
-               //              EM_PASTESPECIAL
-               //              EM_REQUESTRESIZE
-               //              EM_GETBKGNDCOLOR
-               //              EM_SETBKGNDCOLOR
-               //              EM_STREAMIN
-               //              EM_STREAMOUT
-               //              EM_GETIMECOLOR
-               //              EM_SETIMECOLOR
-               //              EM_GETIMEOPTIONS
-               //              EM_SETIMEOPTIONS
-               //              EM_GETOPTIONS
-               //              EM_SETOPTIONS
-               //              EM_GETPUNCTUATION
-               //              EM_SETPUNCTUATION
-               //              EM_GETTHUMB
-               //              EM_SETTARGETDEVICE
-
-               // Not supported but should be:
-               //              EM_GETEVENTMASK
-               //              EM_SETEVENTMASK
-               //              For printing:
-               //                      EM_DISPLAYBAND
-
-       case EM_CANUNDO:
        case SCI_CANUNDO:
                return pdoc->CanUndo() ? TRUE : FALSE;
 
        case SCI_CANUNDO:
                return pdoc->CanUndo() ? TRUE : FALSE;
 
-       case EM_UNDO:
-               Undo();
-               SetLastXChosen();
-               break;
-
-       case EM_EMPTYUNDOBUFFER:
        case SCI_EMPTYUNDOBUFFER:
                pdoc->DeleteUndoHistory();
                return 0;
 
        case SCI_EMPTYUNDOBUFFER:
                pdoc->DeleteUndoHistory();
                return 0;
 
-       case EM_GETFIRSTVISIBLELINE:
        case SCI_GETFIRSTVISIBLELINE:
                return topLine;
 
        case SCI_GETFIRSTVISIBLELINE:
                return topLine;
 
-       case EM_GETLINE: {
-                       if (lParam == 0) {
-                               return 0;
-                       }
-                       char *ptr = reinterpret_cast<char *>(lParam);
-                       short *pBufSize = reinterpret_cast<short *>(lParam);
-                       short bufSize = *pBufSize;
-                       ptr[0] = '\0';  // If no characters copied, have to put a NUL into buffer
-                       if (static_cast<int>(wParam) > pdoc->LinesTotal()) {
-                               return 0;
-                       }
-                       int lineStart = pdoc->LineStart(wParam);
-                       int lineEnd = pdoc->LineStart(wParam + 1);
-                       // The first word of the buffer is the size, in TCHARs, of the buffer
-                       int iPlace = 0;
-                       for (int iChar = lineStart; iChar < lineEnd && iPlace < bufSize; iChar++) {
-                               ptr[iPlace++] = pdoc->CharAt(iChar);
-                       }
-                       return iPlace;
-               }
-
-       case SCI_GETLINE: {     // Simpler than EM_GETLINE, but with risk of overwriting the end of the buffer
+       case SCI_GETLINE: {     // Risk of overwriting the end of the buffer
                        if (lParam == 0) {
                                return 0;
                        }
                        if (lParam == 0) {
                                return 0;
                        }
@@ -3713,42 +3570,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return iPlace;
                }
 
                        return iPlace;
                }
 
-       case EM_GETLINECOUNT:
        case SCI_GETLINECOUNT:
                if (pdoc->LinesTotal() == 0)
                        return 1;
                else
                        return pdoc->LinesTotal();
 
        case SCI_GETLINECOUNT:
                if (pdoc->LinesTotal() == 0)
                        return 1;
                else
                        return pdoc->LinesTotal();
 
-       case EM_GETMODIFY:
        case SCI_GETMODIFY:
                return !pdoc->IsSavePoint();
 
        case SCI_GETMODIFY:
                return !pdoc->IsSavePoint();
 
-       case EM_GETRECT:
-               if (lParam == 0)
-                       return 0;
-               *(reinterpret_cast<PRectangle *>(lParam)) = GetClientRectangle();
-               break;
-
-       case EM_GETSEL:
-               if (wParam)
-                       *reinterpret_cast<int *>(wParam) = SelectionStart();
-               if (lParam)
-                       *reinterpret_cast<int *>(lParam) = SelectionEnd();
-               return Platform::LongFromTwoShorts(
-                          static_cast<short>(SelectionStart()),
-                          static_cast<short>(SelectionEnd()));
-
-       case EM_EXGETSEL: {
-                       if (lParam == 0)
-                               return 0;
-                       CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
-                       pCR->cpMin = SelectionStart();
-                       pCR->cpMax = SelectionEnd();
-               }
-               break;
-
-       case EM_SETSEL:
        case SCI_SETSEL: {
                        int nStart = static_cast<int>(wParam);
                        int nEnd = static_cast<int>(lParam);
        case SCI_SETSEL: {
                        int nStart = static_cast<int>(wParam);
                        int nEnd = static_cast<int>(lParam);
@@ -3762,55 +3592,28 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                }
                break;
 
                }
                break;
 
-       case EM_EXSETSEL: {
-                       if (lParam == 0)
-                               return 0;
-                       CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
-                       selType = selStream;
-                       if (pCR->cpMax == -1) {
-                               SetSelection(pCR->cpMin, pdoc->Length());
-                       } else {
-                               SetSelection(pCR->cpMin, pCR->cpMax);
-                       }
-                       EnsureCaretVisible();
-                       return pdoc->LineFromPosition(SelectionStart());
-               }
-
-       case EM_GETSELTEXT:
        case SCI_GETSELTEXT: {
                        if (lParam == 0)
                                return 0;
        case SCI_GETSELTEXT: {
                        if (lParam == 0)
                                return 0;
+                       SelectionText selectedText;
+                       CopySelectionRange(&selectedText);
                        char *ptr = reinterpret_cast<char *>(lParam);
                        char *ptr = reinterpret_cast<char *>(lParam);
-                       int selSize = SelectionRangeLength();
-                       char *text = CopySelectionRange();
                        int iChar = 0;
                        int iChar = 0;
-                       if (text) {
-                               for (; iChar < selSize; iChar++)
-                                       ptr[iChar] = text[iChar];
+                       if (selectedText.len) {
+                               for (; iChar < selectedText.len; iChar++)
+                                       ptr[iChar] = selectedText.s[iChar];
                                ptr[iChar] = '\0';
                                ptr[iChar] = '\0';
-                               delete []text;
                        } else {
                                ptr[0] = '\0';
                        }
                        return iChar;
                }
 
                        } else {
                                ptr[0] = '\0';
                        }
                        return iChar;
                }
 
-       case EM_LINEFROMCHAR:
-               if (static_cast<int>(wParam) < 0)
-                       wParam = SelectionStart();
-               return pdoc->LineFromPosition(wParam);
-
-       case EM_EXLINEFROMCHAR:
-               if (static_cast<int>(lParam) < 0)
-                       lParam = SelectionStart();      // Not specified, but probably OK
-               return pdoc->LineFromPosition(lParam);
-
        case SCI_LINEFROMPOSITION:
                if (static_cast<int>(wParam) < 0)
                        return 0;
                return pdoc->LineFromPosition(wParam);
 
        case SCI_LINEFROMPOSITION:
                if (static_cast<int>(wParam) < 0)
                        return 0;
                return pdoc->LineFromPosition(wParam);
 
-       case EM_LINEINDEX:
        case SCI_POSITIONFROMLINE:
                if (static_cast<int>(wParam) < 0)
                        wParam = pdoc->LineFromPosition(SelectionStart());
        case SCI_POSITIONFROMLINE:
                if (static_cast<int>(wParam) < 0)
                        wParam = pdoc->LineFromPosition(SelectionStart());
@@ -3822,28 +3625,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                //      return -1;
                return pdoc->LineStart(wParam);
 
                //      return -1;
                return pdoc->LineStart(wParam);
 
-       case EM_LINELENGTH: {
-                       if (static_cast<int>(wParam) < 0)       // Who use this anyway?
-                               return 0;       // Should be... Too complex to describe here, see MS specs!
-                       if (static_cast<int>(wParam) > pdoc->Length())  // Useful test, anyway...
-                               return 0;
-                       int line = pdoc->LineFromPosition(wParam);
-                       int charsOnLine = 0;
-                       for (int pos = pdoc->LineStart(line); pos < pdoc->LineStart(line + 1); pos++) {
-                               if ((pdoc->CharAt(pos) != '\r') && (pdoc->CharAt(pos) != '\n'))
-                                       charsOnLine++;
-                       }
-                       return charsOnLine;
-               }
-
-               // Replacement of the old Scintilla interpretation of EM_LINELENGTH
+       // Replacement of the old Scintilla interpretation of EM_LINELENGTH
        case SCI_LINELENGTH:
                if ((static_cast<int>(wParam) < 0) ||
                        (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
                        return 0;
                return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam);
 
        case SCI_LINELENGTH:
                if ((static_cast<int>(wParam) < 0) ||
                        (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
                        return 0;
                return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam);
 
-       case EM_REPLACESEL:
        case SCI_REPLACESEL: {
                        if (lParam == 0)
                                return 0;
        case SCI_REPLACESEL: {
                        if (lParam == 0)
                                return 0;
@@ -3890,18 +3678,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETSEARCHFLAGS:
                return searchFlags;
 
        case SCI_GETSEARCHFLAGS:
                return searchFlags;
 
-       case EM_LINESCROLL:
        case SCI_LINESCROLL:
                ScrollTo(topLine + lParam);
                HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
                return TRUE;
 
        case SCI_LINESCROLL:
                ScrollTo(topLine + lParam);
                HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
                return TRUE;
 
-       case EM_SCROLLCARET:
        case SCI_SCROLLCARET:
                EnsureCaretVisible();
                break;
 
        case SCI_SCROLLCARET:
                EnsureCaretVisible();
                break;
 
-       case EM_SETREADONLY:
        case SCI_SETREADONLY:
                pdoc->SetReadOnly(wParam);
                return TRUE;
        case SCI_SETREADONLY:
                pdoc->SetReadOnly(wParam);
                return TRUE;
@@ -3909,33 +3694,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETREADONLY:
                return pdoc->IsReadOnly();
 
        case SCI_GETREADONLY:
                return pdoc->IsReadOnly();
 
-       case EM_CANPASTE:
        case SCI_CANPASTE:
                return CanPaste();
 
        case SCI_CANPASTE:
                return CanPaste();
 
-       case EM_CHARFROMPOS: {
-                       if (lParam == 0)
-                               return 0;
-                       Point *ppt = reinterpret_cast<Point *>(lParam);
-                       int pos = PositionFromLocation(*ppt);
-                       int line = pdoc->LineFromPosition(pos);
-                       return Platform::LongFromTwoShorts(
-                                  static_cast<short>(pos), static_cast < short > (line));
-               }
-
-       case EM_POSFROMCHAR: {
-                       // The MS specs for this have changed 3 times: using the RichEdit 3 version
-                       if (wParam == 0)
-                               return 0;
-                       Point *ppt = reinterpret_cast<Point *>(wParam);
-                       if (lParam < 0) {
-                               *ppt = Point(0, 0);
-                       } else {
-                               *ppt = LocationFromPosition(lParam);
-                       }
-                       return 0;
-               }
-
        case SCI_POINTXFROMPOSITION:
                if (lParam < 0) {
                        return 0;
        case SCI_POINTXFROMPOSITION:
                if (lParam < 0) {
                        return 0;
@@ -3952,14 +3713,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return pt.y;
                }
 
                        return pt.y;
                }
 
-       case EM_FINDTEXT:
-               return FindText(iMessage, wParam, lParam);
-
-       case EM_FINDTEXTEX:
        case SCI_FINDTEXT:
        case SCI_FINDTEXT:
-               return FindText(iMessage, wParam, lParam);
+               return FindText(wParam, lParam);
 
 
-       case EM_GETTEXTRANGE:
        case SCI_GETTEXTRANGE: {
                        if (lParam == 0)
                                return 0;
        case SCI_GETTEXTRANGE: {
                        if (lParam == 0)
                                return 0;
@@ -3974,53 +3730,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return len;     // Not including NUL
                }
 
                        return len;     // Not including NUL
                }
 
-
-
-       case EM_SELECTIONTYPE:
-#ifdef SEL_EMPTY
-               if (currentPos == anchor)
-                       return SEL_EMPTY;
-               else
-                       return SEL_TEXT;
-#else 
-               return 0;
-#endif 
-
-       case EM_HIDESELECTION:
+       case SCI_HIDESELECTION:
                hideSelection = wParam;
                Redraw();
                break;
 
                hideSelection = wParam;
                Redraw();
                break;
 
-       case EM_FORMATRANGE:
        case SCI_FORMATRANGE:
                return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
 
        case SCI_FORMATRANGE:
                return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
 
-       case EM_GETMARGINS:
-               return Platform::LongFromTwoShorts(static_cast<short>(vs.leftMarginWidth),
-                                                  static_cast<short>(vs.rightMarginWidth));
-
        case SCI_GETMARGINLEFT:
                return vs.leftMarginWidth;
 
        case SCI_GETMARGINRIGHT:
                return vs.rightMarginWidth;
 
        case SCI_GETMARGINLEFT:
                return vs.leftMarginWidth;
 
        case SCI_GETMARGINRIGHT:
                return vs.rightMarginWidth;
 
-       case EM_SETMARGINS:
-#ifdef EC_LEFTMARGIN
-               if (wParam & EC_LEFTMARGIN) {
-                       vs.leftMarginWidth = Platform::LowShortFromLong(lParam);
-               }
-               if (wParam & EC_RIGHTMARGIN) {
-                       vs.rightMarginWidth = Platform::HighShortFromLong(lParam);
-               }
-               if (wParam == EC_USEFONTINFO) {
-                       vs.leftMarginWidth = vs.aveCharWidth / 2;
-                       vs.rightMarginWidth = vs.aveCharWidth / 2;
-               }
-               InvalidateStyleRedraw();
-#endif 
-               break;
-
        case SCI_SETMARGINLEFT:
                vs.leftMarginWidth = lParam;
                InvalidateStyleRedraw();
        case SCI_SETMARGINLEFT:
                vs.leftMarginWidth = lParam;
                InvalidateStyleRedraw();
@@ -4667,10 +4390,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_LINESONSCREEN:
                return LinesOnScreen();
 
        case SCI_LINESONSCREEN:
                return LinesOnScreen();
 
-       case SCI_USEPOPUP:
-               displayPopupMenu = wParam;
-               break;
-
        case SCI_SETSELFORE:
                vs.selforeset = wParam;
                vs.selforeground.desired = Colour(lParam);
        case SCI_SETSELFORE:
                vs.selforeset = wParam;
                vs.selforeground.desired = Colour(lParam);
@@ -4711,7 +4430,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
        case SCI_CLEARCMDKEY:
                kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
 
        case SCI_CLEARCMDKEY:
                kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
-                                 Platform::HighShortFromLong(wParam), WM_NULL);
+                                 Platform::HighShortFromLong(wParam), SCI_NULL);
                break;
 
        case SCI_CLEARALLCMDKEYS:
                break;
 
        case SCI_CLEARALLCMDKEYS:
@@ -4915,15 +4634,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETCURSOR:
                return cursorMode;
 
        case SCI_GETCURSOR:
                return cursorMode;
 
-#ifdef MACRO_SUPPORT
        case SCI_STARTRECORD:
        case SCI_STARTRECORD:
-               recordingMacro = 1;
+               recordingMacro = true;
                return 0;
 
        case SCI_STOPRECORD:
                return 0;
 
        case SCI_STOPRECORD:
-               recordingMacro = 0;
+               recordingMacro = false;
                return 0;
                return 0;
-#endif 
 
        case SCI_MOVECARETINSIDEVIEW:
                MoveCaretInsideView();
 
        case SCI_MOVECARETINSIDEVIEW:
                MoveCaretInsideView();
index d42f5ad14a133b0d53b1f31f12a7cc05b5cfe9a2..a51fd86f91682853dc507729b28b8843e38a9010 100644 (file)
@@ -50,6 +50,26 @@ public:
        int positions[maxLineLength+1];
 };
 
        int positions[maxLineLength+1];
 };
 
+class SelectionText {
+public:
+       char *s;
+       int len;
+       bool rectangular;
+       SelectionText() : s(0), len(0), rectangular(false) {}
+       ~SelectionText() {
+               Set(0, 0);
+       }
+       void Set(char *s_, int len_, bool rectangular_=false) {
+               delete []s;
+               s = s_;
+               if (s)
+                       len = len_;
+               else
+                       len = 0;
+               rectangular = rectangular_;
+       }
+};
+
 /**
  */
 class Editor : public DocWatcher {
 /**
  */
 class Editor : public DocWatcher {
@@ -68,6 +88,7 @@ protected:    // ScintillaBase subclass needs access to much of Editor
        bool stylesValid;       
        ViewStyle vs;
        Palette palette;
        bool stylesValid;       
        ViewStyle vs;
        Palette palette;
+
        int printMagnification;
        int printColourMode;
        int cursorMode;
        int printMagnification;
        int printColourMode;
        int cursorMode;
@@ -91,9 +112,6 @@ protected:   // ScintillaBase subclass needs access to much of Editor
        Surface pixmapSelPattern;
        Surface pixmapIndentGuide;
        Surface pixmapIndentGuideHighlight;
        Surface pixmapSelPattern;
        Surface pixmapIndentGuide;
        Surface pixmapIndentGuideHighlight;
-       // Intellimouse support - currently only implemented for Windows
-       unsigned int ucWheelScrollLines;
-       int cWheelDelta; ///< Wheel delta from roll
 
        KeyMap kmap;
 
 
        KeyMap kmap;
 
@@ -109,7 +127,6 @@ protected:  // ScintillaBase subclass needs access to much of Editor
        bool dwelling;
        enum { selChar, selWord, selLine } selectionType;
        Point ptMouseLast;
        bool dwelling;
        enum { selChar, selWord, selLine } selectionType;
        Point ptMouseLast;
-       bool firstExpose;
        bool inDragDrop;
        bool dropWentOutside;
        int posDrag;
        bool inDragDrop;
        bool dropWentOutside;
        int posDrag;
@@ -138,9 +155,7 @@ protected:  // ScintillaBase subclass needs access to much of Editor
        
        int modEventMask;
        
        
        int modEventMask;
        
-       char *dragChars;
-       int lenDrag;
-       bool dragIsRectangle;
+       SelectionText drag;
        enum { selStream, selRectangle, selRectangleFixed } selType;
        int xStartSelect;
        int xEndSelect;
        enum { selStream, selRectangle, selRectangleFixed } selType;
        int xStartSelect;
        int xEndSelect;
@@ -154,11 +169,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
        
        int searchAnchor;
 
        
        int searchAnchor;
 
-       int displayPopupMenu;
-
-#ifdef MACRO_SUPPORT
-       int recordingMacro;
-#endif
+       bool recordingMacro;
 
        int foldFlags;
        ContractionState cs;
 
        int foldFlags;
        ContractionState cs;
@@ -270,11 +281,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
        void NotifyModified(Document *document, DocModification mh, void *userData);
        void NotifyDeleted(Document *document, void *userData);
        void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
        void NotifyModified(Document *document, DocModification mh, void *userData);
        void NotifyDeleted(Document *document, void *userData);
        void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
-
-       
-#ifdef MACRO_SUPPORT
        void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
        void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
-#endif
 
        void PageMove(int direction, bool extend=false);
        void ChangeCaseOfSelection(bool makeUpperCase);
 
        void PageMove(int direction, bool extend=false);
        void ChangeCaseOfSelection(bool makeUpperCase);
@@ -289,16 +296,14 @@ protected:        // ScintillaBase subclass needs access to much of Editor
 
        void Indent(bool forwards);
 
 
        void Indent(bool forwards);
 
-       long FindText(unsigned int iMessage, unsigned long wParam, long lParam);
+       long FindText(unsigned long wParam, long lParam);
        void SearchAnchor();
        long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
        long SearchInTarget(const char *text, int length);
        void GoToLine(int lineNo);
 
        char *CopyRange(int start, int end);
        void SearchAnchor();
        long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
        long SearchInTarget(const char *text, int length);
        void GoToLine(int lineNo);
 
        char *CopyRange(int start, int end);
-       int SelectionRangeLength();
-       char *CopySelectionRange();
-       void CopySelectionIntoDrag();
+       void CopySelectionRange(SelectionText *ss);
        void SetDragPosition(int newPos);
        void DisplayCursor(Window::Cursor c);
        virtual void StartDrag();
        void SetDragPosition(int newPos);
        void DisplayCursor(Window::Cursor c);
        virtual void StartDrag();
index 0728580fdfeb69c50b434c377f58726b7ed659ca..756037a9a4cf1b1ae7006721791a56e9a4550bd0 100644 (file)
@@ -108,22 +108,26 @@ LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
 int wxForceScintillaLexers(void) {
   extern LexerModule lmAda;
   extern LexerModule lmAVE;
 int wxForceScintillaLexers(void) {
   extern LexerModule lmAda;
   extern LexerModule lmAVE;
+  extern LexerModule lmBatch;
   extern LexerModule lmConf;
   extern LexerModule lmConf;
-  extern LexerModule lmDiff;
-  extern LexerModule lmLatex;
-  extern LexerModule lmPascal;
   extern LexerModule lmCPP;
   extern LexerModule lmCPP;
-  extern LexerModule lmHTML;
-  extern LexerModule lmXML;
-  extern LexerModule lmProps;
+  extern LexerModule lmDiff;
+  extern LexerModule lmEiffel;
+  extern LexerModule lmEiffelkw;
   extern LexerModule lmErrorList;
   extern LexerModule lmErrorList;
+  extern LexerModule lmHTML;
+  extern LexerModule lmLatex;
+  extern LexerModule lmLISP;
+  extern LexerModule lmLua;
   extern LexerModule lmMake;
   extern LexerModule lmMake;
-  extern LexerModule lmBatch;
+  extern LexerModule lmPascal;
   extern LexerModule lmPerl;
   extern LexerModule lmPerl;
+  extern LexerModule lmProps;  
   extern LexerModule lmPython;
   extern LexerModule lmPython;
+  extern LexerModule lmRuby;
   extern LexerModule lmSQL;
   extern LexerModule lmVB;
   extern LexerModule lmSQL;
   extern LexerModule lmVB;
-  extern LexerModule lmRuby;
+  extern LexerModule lmXML;
 
   if (
       &lmAda
 
   if (
       &lmAda
@@ -143,7 +147,12 @@ int wxForceScintillaLexers(void) {
       && &lmPython
       && &lmSQL
       && &lmVB
       && &lmPython
       && &lmSQL
       && &lmVB
-      && &lmRuby      
+      && &lmRuby
+      && &lmEiffel
+      && &lmEiffelkw
+      && &lmLISP
+      && &lmLua
+      && &lmNull
       )
     {
       return 1;
       )
     {
       return 1;
index 19aa329bafdc2cf76f762de6be183260f54e8d54..b0471b8e527ec7f9bef18d4944cf73149353efd0 100644 (file)
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
-static bool IsOKBeforeRE(int ch) {
+static bool IsOKBeforeRE(const int ch) {
        return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
        return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
-static void getRange(unsigned int start,
-               unsigned int end,
-               Accessor &styler,
-               char *s,
-               unsigned int len) {
-       unsigned int i = 0;
-       while ((i < end - start + 1) && (i < len-1)) {
-               s[i] = styler[start + i];
-               i++;
-       }
-       s[i] = '\0';
-}
-
-inline bool IsASpace(int ch) {
-    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
-}
-
-inline bool IsAWordChar(int  ch) {
+inline bool IsAWordChar(const int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 
-inline bool IsAWordStart(int ch) {
+inline bool IsAWordStart(const int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
-inline bool IsADigit(int ch) {
-       return (ch >= '0') && (ch <= '9');
+inline bool IsADoxygenChar(const int ch) {
+       return (islower(ch) || ch == '$' || ch == '@' ||
+                   ch == '\\' || ch == '&' || ch == '<' ||
+                       ch == '>' || ch == '#' || ch == '{' ||
+                       ch == '}' || ch == '[' || ch == ']');
 }
 
 }
 
-// All languages handled so far can treat all characters >= 0x80 as one class
-// which just continues the current token or starts an identifier if in default.
-// DBCS treated specially as the second character can be < 0x80 and hence 
-// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
-class ColouriseContext {
-       Accessor &styler;
-       int lengthDoc;
-       int currentPos;
-       ColouriseContext& operator=(const ColouriseContext&) {
-               return *this;
-       }
-public:
-       bool atEOL;
-       int state;
-       int chPrev;
-       int ch;
-       int chNext;
+inline bool IsStateComment(const int state) {
+       return ((state == SCE_C_COMMENT) ||
+                     (state == SCE_C_COMMENTLINE) ||
+                     (state == SCE_C_COMMENTDOC) ||
+                     (state == SCE_C_COMMENTDOCKEYWORD) ||
+                     (state == SCE_C_COMMENTDOCKEYWORDERROR));
+}
 
 
-       ColouriseContext(unsigned int startPos, int length,
-                        int initStyle, Accessor &styler_) : 
-               styler(styler_),
-               lengthDoc(startPos + length),
-               currentPos(startPos), 
-               atEOL(false),
-               state(initStyle), 
-               chPrev(0),
-               ch(0), 
-               chNext(0) {
-               styler.StartAt(startPos);
-               styler.StartSegment(startPos);
-               int pos = currentPos;
-               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               if (styler.IsLeadByte(static_cast<char>(ch))) {
-                       pos++;
-                       ch = ch << 8;
-                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               }
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
-               }
-               atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-       }
-       void Complete() {
-               styler.ColourTo(currentPos - 1, state);
-       }
-       bool More() {
-               return currentPos <= lengthDoc;
-       }
-       void Forward() {
-               // A lot of this is repeated from the constructor - TODO: merge code
-               chPrev = ch;
-               currentPos++;
-               if (ch >= 0x100)
-                       currentPos++;
-               ch = chNext;
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
-               }
-               // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
-               // Avoid triggering two times on Dos/Win
-               // End of line
-               atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-       }
-       void ChangeState(int state_) {
-               state = state_;
-       }
-       void SetState(int state_) {
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void ForwardSetState(int state_) {
-               Forward();
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void GetCurrent(char *s, int len) {
-               getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-       }
-       int LengthCurrent() {
-               return currentPos - styler.GetStartSegment();
-       }
-       bool Match(char ch0) {
-               return ch == ch0;
-       }
-       bool Match(char ch0, char ch1) {
-               return (ch == ch0) && (chNext == ch1);
-       }
-       bool Match(const char *s) {
-               if (ch != *s)
-                       return false;
-               s++;
-               if (chNext != *s)
-                       return false;
-               s++;
-               for (int n=2; *s; n++) {
-                       if (*s != styler.SafeGetCharAt(currentPos+n))
-                               return false;
-                       s++;
-               }
-               return true;
-       }
-};
+inline bool IsStateString(const int state) {
+       return ((state == SCE_C_STRING) || (state == SCE_C_VERBATIM));
+}
 
 static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler) {
 
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
 
 static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler) {
 
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
+       WordList &keywords3 = *keywordlists[2];
 
        bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
 
 
        bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
 
-       if (initStyle == SCE_C_STRINGEOL)       // Does not leak onto next line
+       // Do not leak onto next line
+       if (initStyle == SCE_C_STRINGEOL)
                initStyle = SCE_C_DEFAULT;
 
        int chPrevNonWhite = ' ';
        int visibleChars = 0;
                initStyle = SCE_C_DEFAULT;
 
        int chPrevNonWhite = ' ';
        int visibleChars = 0;
+       int noDocChars = 0;
        bool lastWordWasUUID = false;
 
        bool lastWordWasUUID = false;
 
-       ColouriseContext cc(startPos, length, initStyle, styler);
-
-       for (; cc.More(); cc.Forward()) {
+       StyleContext sc(startPos, length, initStyle, styler);
 
 
-               if (cc.state == SCE_C_STRINGEOL) {
-                       if (cc.atEOL) {
-                               cc.SetState(SCE_C_DEFAULT);
+       for (; sc.More(); sc.Forward()) {
+       
+               // Handle line continuation generically.
+               if (sc.ch == '\\') {
+                       if (sc.Match("\\\n")) {
+                               sc.Forward();
+                               sc.Forward();
+                               continue;
                        }
                        }
-               } else if (cc.state == SCE_C_OPERATOR) {
-                       cc.SetState(SCE_C_DEFAULT);
-               } else if (cc.state == SCE_C_NUMBER) {
-                       if (!IsAWordChar(cc.ch)) {
-                               cc.SetState(SCE_C_DEFAULT);
+                       if (sc.Match("\\\r\n")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.Forward();
+                               continue;
                        }
                        }
-               } else if (cc.state == SCE_C_IDENTIFIER) {
-                       if (!IsAWordChar(cc.ch) || (cc.ch == '.')) {
+               }
+
+               // Determine if the current state should terminate.
+               if (sc.state == SCE_C_OPERATOR) {
+                       sc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_C_DEFAULT);
+                       }
+               } else if (sc.state == SCE_C_IDENTIFIER) {
+                       if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
                                char s[100];
                                char s[100];
-                               cc.GetCurrent(s, sizeof(s));
+                               sc.GetCurrent(s, sizeof(s));
                                if (keywords.InList(s)) {
                                        lastWordWasUUID = strcmp(s, "uuid") == 0;
                                if (keywords.InList(s)) {
                                        lastWordWasUUID = strcmp(s, "uuid") == 0;
-                                       cc.ChangeState(SCE_C_WORD);
+                                       sc.ChangeState(SCE_C_WORD);
                                } else if (keywords2.InList(s)) {
                                } else if (keywords2.InList(s)) {
-                                       cc.ChangeState(SCE_C_WORD2);
+                                       sc.ChangeState(SCE_C_WORD2);
                                }
                                }
-                               cc.SetState(SCE_C_DEFAULT);
+                               sc.SetState(SCE_C_DEFAULT);
                        }
                        }
-               } if (cc.state == SCE_C_PREPROCESSOR) {
+               } else if (sc.state == SCE_C_PREPROCESSOR) {
                        if (stylingWithinPreprocessor) {
                        if (stylingWithinPreprocessor) {
-                               if (IsASpace(cc.ch)) {
-                                       cc.SetState(SCE_C_DEFAULT);
+                               if (IsASpace(sc.ch)) {
+                                       sc.SetState(SCE_C_DEFAULT);
                                }
                        } else {
                                }
                        } else {
-                               if (cc.atEOL && (cc.chPrev != '\\')) {
-                                       cc.SetState(SCE_C_DEFAULT);
+                               if (sc.atLineEnd) {
+                                       sc.SetState(SCE_C_DEFAULT);
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_COMMENT) {
-                       if (cc.Match('*', '/')) {
-                               cc.Forward();
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENT) {
+                       if (sc.Match('*', '/')) {
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       }
+               } else if (sc.state == SCE_C_COMMENTDOC) {
+                       if (sc.Match('*', '/')) {
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) {
+                               sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+                       } else if (sc.atLineEnd) {
+                               noDocChars = 0;
+                       } else if (!isspace(sc.ch) && (sc.ch != '*')) {
+                               noDocChars++;
                        }
                        }
-               } else if (cc.state == SCE_C_COMMENTDOC) {
-                       if (cc.Match('*', '/')) {
-                               cc.Forward();
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
+                       if (sc.atLineEnd) {
+                               sc.SetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
                        }
                        }
-               } else if (cc.state == SCE_C_COMMENTLINE || cc.state == SCE_C_COMMENTLINEDOC) {
-                       if (cc.ch == '\r' || cc.ch == '\n') {
-                               cc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENTDOCKEYWORD) {
+                       if (sc.Match('*', '/')) {
+                               sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (!IsADoxygenChar(sc.ch)) {
+                               char s[100];
+                               sc.GetCurrent(s, sizeof(s));
+                               if (!isspace(sc.ch) || !keywords3.InList(s+1)) {
+                                       sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+                               }
+                               sc.SetState(SCE_C_COMMENTDOC);
                        }
                        }
-               } else if (cc.state == SCE_C_STRING) {
-                       if (cc.ch == '\\') {
-                               if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_STRING) {
+                       if (sc.ch == '\\') {
+                               if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                                       sc.Forward();
                                }
                                }
-                       } else if (cc.ch == '\"') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
-                       } else if ((cc.atEOL) && (cc.chPrev != '\\')) {
-                               cc.ChangeState(SCE_C_STRINGEOL);
+                       } else if (sc.ch == '\"') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.atLineEnd) {
+                               sc.ChangeState(SCE_C_STRINGEOL);
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
                        }
                        }
-               } else if (cc.state == SCE_C_CHARACTER) {
-                       if ((cc.ch == '\r' || cc.ch == '\n') && (cc.chPrev != '\\')) {
-                               cc.ChangeState(SCE_C_STRINGEOL);
-                       } else if (cc.ch == '\\') {
-                               if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_CHARACTER) {
+                       if (sc.atLineEnd) {
+                               sc.ChangeState(SCE_C_STRINGEOL);
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
+                       } else if (sc.ch == '\\') {
+                               if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                                       sc.Forward();
                                }
                                }
-                       } else if (cc.ch == '\'') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.ch == '\'') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
                        }
                        }
-               } else if (cc.state == SCE_C_REGEX) {
-                       if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == '/') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
-                       } else if (cc.ch == '\\') {
+               } else if (sc.state == SCE_C_REGEX) {
+                       if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == '/') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.ch == '\\') {
                                // Gobble up the quoted character
                                // Gobble up the quoted character
-                               if (cc.chNext == '\\' || cc.chNext == '/') {
-                                       cc.Forward();
+                               if (sc.chNext == '\\' || sc.chNext == '/') {
+                                       sc.Forward();
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_VERBATIM) {
-                       if (cc.ch == '\"') {
-                               if (cc.chNext == '\"') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_VERBATIM) {
+                       if (sc.ch == '\"') {
+                               if (sc.chNext == '\"') {
+                                       sc.Forward();
                                } else {
                                } else {
-                                       cc.ForwardSetState(SCE_C_DEFAULT);
+                                       sc.ForwardSetState(SCE_C_DEFAULT);
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_UUID) {
-                       if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == ')') {
-                               cc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_UUID) {
+                       if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
+                               sc.SetState(SCE_C_DEFAULT);
                        }
                }
 
                        }
                }
 
-               if (cc.state == SCE_C_DEFAULT) {
-                       if (cc.Match('@', '\"')) {
-                               cc.SetState(SCE_C_VERBATIM);
-                               cc.Forward();
-                       } else if (IsADigit(cc.ch) || (cc.ch == '.' && IsADigit(cc.chNext))) {
+               // Determine if a new state should be entered.
+               if (sc.state == SCE_C_DEFAULT) {
+                       if (sc.Match('@', '\"')) {
+                               sc.SetState(SCE_C_VERBATIM);
+                               sc.Forward();
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
                                if (lastWordWasUUID) {
                                if (lastWordWasUUID) {
-                                       cc.SetState(SCE_C_UUID);
+                                       sc.SetState(SCE_C_UUID);
                                        lastWordWasUUID = false;
                                } else {
                                        lastWordWasUUID = false;
                                } else {
-                                       cc.SetState(SCE_C_NUMBER);
+                                       sc.SetState(SCE_C_NUMBER);
                                }
                                }
-                       } else if (IsAWordStart(cc.ch) || (cc.ch == '@')) {
+                       } else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
                                if (lastWordWasUUID) {
                                if (lastWordWasUUID) {
-                                       cc.SetState(SCE_C_UUID);
+                                       sc.SetState(SCE_C_UUID);
                                        lastWordWasUUID = false;
                                } else {
                                        lastWordWasUUID = false;
                                } else {
-                                       cc.SetState(SCE_C_IDENTIFIER);
+                                       sc.SetState(SCE_C_IDENTIFIER);
                                }
                                }
-                       } else if (cc.Match('/', '*')) {
-                               if (cc.Match("/**") || cc.Match("/*!")) // Support of Qt/Doxygen doc. style
-                                       cc.SetState(SCE_C_COMMENTDOC);
-                               else
-                                       cc.SetState(SCE_C_COMMENT);
-                               cc.Forward();   // Eat the * so it isn't used for the end of the comment
-                       } else if (cc.Match('/', '/')) {
-                               if (cc.Match("///") || cc.Match("//!")) // Support of Qt/Doxygen doc. style
-                                       cc.SetState(SCE_C_COMMENTLINEDOC);
+                       } else if (sc.Match('/', '*')) {
+                               if (sc.Match("/**") || sc.Match("/*!")) {       // Support of Qt/Doxygen doc. style
+                                       noDocChars = 0;
+                                       sc.SetState(SCE_C_COMMENTDOC);
+                               } else {
+                                       sc.SetState(SCE_C_COMMENT);
+                               }
+                               sc.Forward();   // Eat the * so it isn't used for the end of the comment
+                       } else if (sc.Match('/', '/')) {
+                               if (sc.Match("///") || sc.Match("//!")) // Support of Qt/Doxygen doc. style
+                                       sc.SetState(SCE_C_COMMENTLINEDOC);
                                else
                                else
-                                       cc.SetState(SCE_C_COMMENTLINE);
-                       } else if (cc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
-                               cc.SetState(SCE_C_REGEX);
-                       } else if (cc.ch == '\"') {
-                               cc.SetState(SCE_C_STRING);
-                       } else if (cc.ch == '\'') {
-                               cc.SetState(SCE_C_CHARACTER);
-                       } else if (cc.ch == '#' && visibleChars == 0) {
+                                       sc.SetState(SCE_C_COMMENTLINE);
+                       } else if (sc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
+                               sc.SetState(SCE_C_REGEX);
+                       } else if (sc.ch == '\"') {
+                               sc.SetState(SCE_C_STRING);
+                       } else if (sc.ch == '\'') {
+                               sc.SetState(SCE_C_CHARACTER);
+                       } else if (sc.ch == '#' && visibleChars == 0) {
                                // Preprocessor commands are alone on their line
                                // Preprocessor commands are alone on their line
-                               cc.SetState(SCE_C_PREPROCESSOR);
+                               sc.SetState(SCE_C_PREPROCESSOR);
                                // Skip whitespace between # and preprocessor word
                                do {
                                // Skip whitespace between # and preprocessor word
                                do {
-                                       cc.Forward();
-                               } while (IsASpace(cc.ch) && cc.More());
-                       } else if (isoperator(static_cast<char>(cc.ch))) {
-                               cc.SetState(SCE_C_OPERATOR);
+                                       sc.Forward();
+                               } while ((sc.ch == ' ') && (sc.ch == '\t') && sc.More());
+                               if (sc.atLineEnd) {
+                                       sc.SetState(SCE_C_DEFAULT);
+                               }
+                       } else if (isoperator(static_cast<char>(sc.ch))) {
+                               sc.SetState(SCE_C_OPERATOR);
                        }
                }
                        }
                }
-               if (cc.atEOL) {
+               
+               if (sc.atLineEnd) {
                        // Reset states to begining of colourise so no surprises 
                        // if different sets of lines lexed.
                        chPrevNonWhite = ' ';
                        visibleChars = 0;
                        lastWordWasUUID = false;
                }
                        // Reset states to begining of colourise so no surprises 
                        // if different sets of lines lexed.
                        chPrevNonWhite = ' ';
                        visibleChars = 0;
                        lastWordWasUUID = false;
                }
-               if (!IsASpace(cc.ch)) {
-                       chPrevNonWhite = cc.ch;
+               if (!IsASpace(sc.ch)) {
+                       chPrevNonWhite = sc.ch;
                        visibleChars++;
                }
        }
                        visibleChars++;
                }
        }
-       cc.Complete();
+       sc.Complete();
 }
 
 static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
 }
 
 static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
diff --git a/contrib/src/stc/scintilla/src/LexCrontab.cxx b/contrib/src/stc/scintilla/src/LexCrontab.cxx
new file mode 100644 (file)
index 0000000..94a172c
--- /dev/null
@@ -0,0 +1,204 @@
+// Scintilla source code edit control
+/** @file LexCrontab.cxx
+ ** Lexer to use with extended crontab files used by a powerful
+ ** Windows scheduler/event monitor/automation manager nnCron.
+ ** (http://nemtsev.virtualave.net/)
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList
+*keywordLists[], Accessor &styler)
+{
+       int state = SCE_NNCRONTAB_DEFAULT;
+       char chNext = styler[startPos];
+       int lengthDoc = startPos + length;
+       // create a buffer large enough to take the largest chunk...
+       char *buffer = new char[length];
+       int bufferCount = 0;
+       // used when highliting environment variables inside quoted string:
+       bool insideString = false;
+
+       // this assumes that we have 3 keyword list in conf.properties
+       WordList &section = *keywordLists[0];
+       WordList &keyword = *keywordLists[1];
+       WordList &modifier = *keywordLists[2];
+
+       // go through all provided text segment
+       // using the hand-written state machine shown below
+       styler.StartAt(startPos);
+       styler.StartSegment(startPos);
+       for (int i = startPos; i < lengthDoc; i++) {
+               char ch = chNext;
+               chNext = styler.SafeGetCharAt(i + 1);
+
+               if (styler.IsLeadByte(ch)) {
+                       chNext = styler.SafeGetCharAt(i + 2);
+                       i++;
+                       continue;
+               }
+               switch(state) {
+                       case SCE_NNCRONTAB_DEFAULT:
+                               if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') {
+                                       // whitespace is simply ignored here...
+                                       styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT);
+                                       break;
+                               } else if( ch == '#' && styler.SafeGetCharAt(i+1) == '(') {
+                                       // signals the start of a task...
+                                       state = SCE_NNCRONTAB_TASK;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               }
+                                 else if( ch == '\\' && styler.SafeGetCharAt(i+1) == ' ') {
+                                       // signals the start of an extended comment...
+                                       state = SCE_NNCRONTAB_COMMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               } else if( ch == '#' ) {
+                                       // signals the start of a plain comment...
+                                       state = SCE_NNCRONTAB_COMMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               } else if( ch == ')' && styler.SafeGetCharAt(i+1) == '#') {
+                                       // signals the end of a task...
+                                       state = SCE_NNCRONTAB_TASK;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               } else if( ch == '"') {
+                                       state = SCE_NNCRONTAB_STRING;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_STRING);
+                               } else if( ch == '%') {
+                                       // signals environment variables
+                                       state = SCE_NNCRONTAB_ENVIRONMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT);
+                               } else if( ch == '*' ) {
+                                       // signals an asterisk
+                                       // no state jump necessary for this simple case...
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ASTERISK);
+                               } else if( isalpha(ch) || ch == '<' ) {
+                                       // signals the start of an identifier
+                                       bufferCount = 0;
+                                       buffer[bufferCount++] = ch;
+                                       state = SCE_NNCRONTAB_IDENTIFIER;
+                               } else if( isdigit(ch) ) {
+                                       // signals the start of a number
+                                       bufferCount = 0;
+                                       buffer[bufferCount++] = ch;
+                                       state = SCE_NNCRONTAB_NUMBER;
+                               } else {
+                                       // style it the default style..
+                                       styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_COMMENT:
+                               // if we find a newline here,
+                               // we simply go to default state
+                               // else continue to work on it...
+                               if( ch == '\n' || ch == '\r' ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               } else {
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_TASK:
+                               // if we find a newline here,
+                               // we simply go to default state
+                               // else continue to work on it...
+                               if( ch == '\n' || ch == '\r' ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               } else {
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_STRING:
+                               if( ch == '%' ) {
+                                       state = SCE_NNCRONTAB_ENVIRONMENT;
+                                       insideString = true;
+                                       styler.ColourTo(i-1,SCE_NNCRONTAB_STRING);
+                                       break;
+                               }
+                               // if we find the end of a string char, we simply go to default state
+                               // else we're still dealing with an string...
+                               if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') ||
+                                       (ch == '\n') || (ch == '\r') ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               }
+                               styler.ColourTo(i,SCE_NNCRONTAB_STRING);
+                               break;
+
+                       case SCE_NNCRONTAB_ENVIRONMENT:
+                               // if we find the end of a string char, we simply go to default state
+                               // else we're still dealing with an string...
+                               if( ch == '%' && insideString ) {
+                                       state = SCE_NNCRONTAB_STRING;
+                                       insideString = false;
+                                       break;
+                               }
+                               if( (ch == '%' && styler.SafeGetCharAt(i-1)!='\\')
+                                       || (ch == '\n') || (ch == '\r') ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT);
+                                       break;
+                               }
+                               styler.ColourTo(i+1,SCE_NNCRONTAB_ENVIRONMENT);
+                               break;
+
+                       case SCE_NNCRONTAB_IDENTIFIER:
+                               // stay  in CONF_IDENTIFIER state until we find a non-alphanumeric
+                               if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') ||
+                                       (ch == '$') || (ch == '.') || (ch == '<') || (ch == '>') ) {
+                                       buffer[bufferCount++] = ch;
+                               } else {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       buffer[bufferCount] = '\0';
+
+                                       // check if the buffer contains a keyword,
+                                       // and highlight it if it is a keyword...
+                                       if(section.InList(buffer)) {
+                                               styler.ColourTo(i,SCE_NNCRONTAB_SECTION );
+                                       } else if(keyword.InList(buffer)) {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_KEYWORD );
+                                       } // else if(strchr(buffer,'/') || strchr(buffer,'.')) {
+                                       //      styler.ColourTo(i-1,SCE_NNCRONTAB_EXTENSION);
+                                       // }
+                                         else if(modifier.InList(buffer)) {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_MODIFIER );
+                                         }     else {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_DEFAULT);
+                                       }
+                                       // push back the faulty character
+                                       chNext = styler[i--];
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_NUMBER:
+                               // stay  in CONF_NUMBER state until we find a non-numeric
+                               if( isdigit(ch) /* || ch == '.' */ ) {
+                                       buffer[bufferCount++] = ch;
+                               } else {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       buffer[bufferCount] = '\0';
+                                       // Colourize here... (normal number)
+                                       styler.ColourTo(i-1,SCE_NNCRONTAB_NUMBER);
+                                       // push back a character
+                                       chNext = styler[i--];
+                               }
+                               break;
+               }
+       }
+}
+
+LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");
index 1296fb24506c7787775d2776b5c4201dfedbd6da..64709432088517d56d133a79cd244c1596a4ac69 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
@@ -31,23 +32,6 @@ inline bool isEiffelOperator(unsigned int ch) {
                ch == '!' || ch == '@' || ch == '?';
 }
 
                ch == '!' || ch == '@' || ch == '?';
 }
 
-static void getRangeLowered(unsigned int start,
-               unsigned int end,
-               Accessor &styler,
-               char *s,
-               unsigned int len) {
-       unsigned int i = 0;
-       while ((i < end - start + 1) && (i < len-1)) {
-               s[i] = static_cast<char>(tolower(styler[start + i]));
-               i++;
-       }
-       s[i] = '\0';
-}
-
-inline bool IsASpace(unsigned int ch) {
-    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
-}
-
 inline bool IsAWordChar(unsigned int  ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 inline bool IsAWordChar(unsigned int  ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
@@ -56,81 +40,6 @@ inline bool IsAWordStart(unsigned int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
-inline bool IsADigit(unsigned int ch) {
-       return (ch >= '0') && (ch <= '9');
-}
-
-// All languages handled so far can treat all characters >= 0x80 as one class
-// which just continues the current token or starts an identifier if in default.
-// DBCS treated specially as the second character can be < 0x80 and hence 
-// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
-class xColouriseContext {
-       Accessor &styler;
-       int lengthDoc;
-       int currentPos;
-       xColouriseContext& operator=(const xColouriseContext&) {
-               return *this;
-       }
-public:
-       int state;
-       unsigned int chPrev;
-       unsigned int ch;
-       unsigned int chNext;
-
-       xColouriseContext(unsigned int startPos, int length,
-                        int initStyle, Accessor &styler_) : 
-               styler(styler_),
-               lengthDoc(startPos + length),
-               currentPos(startPos), 
-               state(initStyle), 
-               chPrev(0),
-               ch(0), 
-               chNext(0) {
-               styler.StartAt(startPos);
-               styler.StartSegment(startPos);
-               int pos = currentPos;
-               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               if (styler.IsLeadByte(static_cast<char>(ch))) {
-                       pos++;
-                       ch = ch << 8;
-                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               }
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
-               }
-       }
-       void Complete() {
-               styler.ColourTo(currentPos - 1, state);
-       }
-       bool More() {
-               return currentPos <= lengthDoc;
-       }
-       void Forward() {
-               chPrev = ch;
-               currentPos++;
-               if (ch >= 0x100)
-                       currentPos++;
-               ch = chNext;
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
-               }
-       }
-       void ChangeState(int state_) {
-               state = state_;
-       }
-       void SetState(int state_) {
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void GetCurrentLowered(char *s, int len) {
-               getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-       }
-};
-
 static void ColouriseEiffelDoc(unsigned int startPos,
                             int length,
                             int initStyle,
 static void ColouriseEiffelDoc(unsigned int startPos,
                             int length,
                             int initStyle,
@@ -139,68 +48,68 @@ static void ColouriseEiffelDoc(unsigned int startPos,
 
        WordList &keywords = *keywordlists[0];
 
 
        WordList &keywords = *keywordlists[0];
 
-       xColouriseContext lc(startPos, length, initStyle, styler);
+       StyleContext sc(startPos, length, initStyle, styler);
 
 
-       for (; lc.More(); lc.Forward()) {
+       for (; sc.More(); sc.Forward()) {
 
 
-               if (lc.state == SCE_EIFFEL_STRINGEOL) {
-                       if (lc.ch != '\r' && lc.ch != '\n') {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               if (sc.state == SCE_EIFFEL_STRINGEOL) {
+                       if (sc.ch != '\r' && sc.ch != '\n') {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_OPERATOR) {
-                       lc.SetState(SCE_EIFFEL_DEFAULT);
-               } else if (lc.state == SCE_EIFFEL_WORD) {
-                       if (!IsAWordChar(lc.ch)) {
+               } else if (sc.state == SCE_EIFFEL_OPERATOR) {
+                       sc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_WORD) {
+                       if (!IsAWordChar(sc.ch)) {
                                char s[100];
                                char s[100];
-                               lc.GetCurrentLowered(s, sizeof(s));
+                               sc.GetCurrentLowered(s, sizeof(s));
                                if (!keywords.InList(s)) {
                                if (!keywords.InList(s)) {
-                                       lc.ChangeState(SCE_EIFFEL_IDENTIFIER);
+                                       sc.ChangeState(SCE_EIFFEL_IDENTIFIER);
                                }
                                }
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_NUMBER) {
-                       if (!IsAWordChar(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_COMMENTLINE) {
-                       if (lc.ch == '\r' || lc.ch == '\n') {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_COMMENTLINE) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_STRING) {
-                       if (lc.ch == '%') {
-                               lc.Forward();
-                       } else if (lc.ch == '\"') {
-                               lc.Forward();
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_STRING) {
+                       if (sc.ch == '%') {
+                               sc.Forward();
+                       } else if (sc.ch == '\"') {
+                               sc.Forward();
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_CHARACTER) {
-                       if (lc.ch == '\r' || lc.ch == '\n') {
-                               lc.SetState(SCE_EIFFEL_STRINGEOL);
-                       } else if (lc.ch == '%') {
-                               lc.Forward();
-                       } else if (lc.ch == '\'') {
-                               lc.Forward();
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_CHARACTER) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_EIFFEL_STRINGEOL);
+                       } else if (sc.ch == '%') {
+                               sc.Forward();
+                       } else if (sc.ch == '\'') {
+                               sc.Forward();
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                }
 
                        }
                }
 
-               if (lc.state == SCE_EIFFEL_DEFAULT) {
-                       if (lc.ch == '-' && lc.chNext == '-') {
-                               lc.SetState(SCE_EIFFEL_COMMENTLINE);
-                       } else if (lc.ch == '\"') {
-                               lc.SetState(SCE_EIFFEL_STRING);
-                       } else if (lc.ch == '\'') {
-                               lc.SetState(SCE_EIFFEL_CHARACTER);
-                       } else if (IsADigit(lc.ch) || (lc.ch == '.')) {
-                               lc.SetState(SCE_EIFFEL_NUMBER);
-                       } else if (IsAWordStart(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_WORD);
-                       } else if (isEiffelOperator(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_OPERATOR);
+               if (sc.state == SCE_EIFFEL_DEFAULT) {
+                       if (sc.ch == '-' && sc.chNext == '-') {
+                               sc.SetState(SCE_EIFFEL_COMMENTLINE);
+                       } else if (sc.ch == '\"') {
+                               sc.SetState(SCE_EIFFEL_STRING);
+                       } else if (sc.ch == '\'') {
+                               sc.SetState(SCE_EIFFEL_CHARACTER);
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.')) {
+                               sc.SetState(SCE_EIFFEL_NUMBER);
+                       } else if (IsAWordStart(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_WORD);
+                       } else if (isEiffelOperator(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_OPERATOR);
                        }
                }
        }
                        }
                }
        }
-       lc.Complete();
+       sc.Complete();
 }
 
 static bool IsEiffelComment(Accessor &styler, int pos, int len) {
 }
 
 static bool IsEiffelComment(Accessor &styler, int pos, int len) {
index c28a43279544eaa2d76ac4a27927d51a4ccc9c34..3a03096f8ae42c02133aefca468166db43db8f3d 100644 (file)
@@ -1,7 +1,7 @@
 // Scintilla source code edit control
 /** @file LexHTML.cxx
  ** Lexer for HTML.
 // Scintilla source code edit control
 /** @file LexHTML.cxx
  ** Lexer for HTML.
- **/
+ **/ 
 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
 #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
 
 #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
 #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
 
-enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML };
+enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
 enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
 
 static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
        char s[30 + 1];
 enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
 
 static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
        char s[30 + 1];
-       s[0] = '\0';
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = static_cast<char>(tolower(styler[start + i]));
                s[i] = static_cast<char>(tolower(styler[start + i]));
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
        if (strstr(s, "src"))   // External script
                return eScriptNone;
        //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
        if (strstr(s, "src"))   // External script
                return eScriptNone;
@@ -55,11 +55,11 @@ static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigne
 static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) {
        int iResult = 0;
        char s[30 + 1];
 static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) {
        int iResult = 0;
        char s[30 + 1];
-       s[0] = '\0';
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = static_cast<char>(tolower(styler[start + i]));
                s[i] = static_cast<char>(tolower(styler[start + i]));
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        if (0 == strncmp(s, "php", 3)) {
                iResult = 3;
        }
        if (0 == strncmp(s, "php", 3)) {
                iResult = 3;
        }
@@ -68,22 +68,21 @@ static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, u
 }
 
 static int ScriptOfState(int state) {
 }
 
 static int ScriptOfState(int state) {
-       int scriptLanguage;
-
        if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
        if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
-               scriptLanguage = eScriptPython;
+               return eScriptPython;
        } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
        } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
-               scriptLanguage = eScriptVBS;
+               return eScriptVBS;
        } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
        } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
-               scriptLanguage = eScriptJS;
+               return eScriptJS;
        } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
        } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
-               scriptLanguage = eScriptPHP;
+               return eScriptPHP;
+       } else if ((state >= SCE_H_SGML_DEFAULT) && (state <= SCE_H_SGML_BLOCK_DEFAULT)) {
+               return eScriptSGML;
+       } else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
+               return eScriptSGMLblock;
        } else {
        } else {
-               //              scriptLanguage = defaultScript;
-               scriptLanguage = eScriptNone;
+               return eScriptNone;
        }
        }
-
-       return scriptLanguage;
 }
 
 static int statePrintForState(int state, int inScriptType) {
 }
 
 static int statePrintForState(int state, int inScriptType) {
@@ -174,11 +173,11 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
                chAttr = SCE_H_NUMBER;
        } else {
                char s[30 + 1];
                chAttr = SCE_H_NUMBER;
        } else {
                char s[30 + 1];
-               s[0] = '\0';
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = static_cast<char>(tolower(styler[start + i]));
                        s[i] = static_cast<char>(tolower(styler[start + i]));
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_H_ATTRIBUTE;
        }
                if (keywords.InList(s))
                        chAttr = SCE_H_ATTRIBUTE;
        }
@@ -195,18 +194,14 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
        unsigned int i = 0;
        for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
                char ch = styler[cPos];
        unsigned int i = 0;
        for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
                char ch = styler[cPos];
-               if (ch != '<')
+               if ((ch != '<') && (ch != '/'))
                        s[i++] = static_cast<char>(tolower(ch));
        }
        s[i] = '\0';
        bool isScript = false;
        char chAttr = SCE_H_TAGUNKNOWN;
                        s[i++] = static_cast<char>(tolower(ch));
        }
        s[i] = '\0';
        bool isScript = false;
        char chAttr = SCE_H_TAGUNKNOWN;
-       if (s[0] == '!' && s[1] == '-' && s[2] == '-') {        //Comment
-               chAttr = SCE_H_COMMENT;
-       } else if (strcmp(s, "![cdata[") == 0) {        // In lower case because already converted
-               chAttr = SCE_H_CDATA;
-       } else if (s[0] == '!') {
-               chAttr = SCE_H_SGML;
+       if (s[0] == '!') {
+               chAttr = SCE_H_SGML_DEFAULT;
        } else if (s[0] == '/') {       // Closing tag
                if (keywords.InList(s + 1))
                        chAttr = SCE_H_TAG;
        } else if (s[0] == '/') {       // Closing tag
                if (keywords.InList(s + 1))
                        chAttr = SCE_H_TAG;
@@ -231,10 +226,11 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
                chAttr = SCE_HJ_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HJ_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = styler[start + i];
                        s[i] = styler[start + i];
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_HJ_KEYWORD;
        }
                if (keywords.InList(s))
                        chAttr = SCE_HJ_KEYWORD;
        }
@@ -248,10 +244,11 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
                chAttr = SCE_HB_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HB_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = static_cast<char>(tolower(styler[start + i]));
                        s[i] = static_cast<char>(tolower(styler[start + i]));
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s)) {
                        chAttr = SCE_HB_WORD;
                        if (strcmp(s, "rem") == 0)
                if (keywords.InList(s)) {
                        chAttr = SCE_HB_WORD;
                        if (strcmp(s, "rem") == 0)
@@ -268,10 +265,11 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
 static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
        bool wordIsNumber = isdigit(styler[start]);
        char s[30 + 1];
 static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
        bool wordIsNumber = isdigit(styler[start]);
        char s[30 + 1];
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = styler[start + i];
                s[i] = styler[start + i];
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        char chAttr = SCE_HP_IDENTIFIER;
        if (0 == strcmp(prevWord, "class"))
                chAttr = SCE_HP_CLASSNAME;
        char chAttr = SCE_HP_IDENTIFIER;
        if (0 == strcmp(prevWord, "class"))
                chAttr = SCE_HP_CLASSNAME;
@@ -294,16 +292,37 @@ static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &ke
                chAttr = SCE_HPHP_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HPHP_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = styler[start + i];
                        s[i] = styler[start + i];
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_HPHP_WORD;
        }
        styler.ColourTo(end, chAttr);
 }
 
                if (keywords.InList(s))
                        chAttr = SCE_HPHP_WORD;
        }
        styler.ColourTo(end, chAttr);
 }
 
+static bool isWordHSGML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
+       char s[30 + 1];
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
+               s[i] = styler[start + i];
+       }
+       s[i] = '\0';
+       return keywords.InList(s);
+}
+
+static bool isWordCdata(unsigned int start, unsigned int end, Accessor &styler) {
+       char s[30 + 1];
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
+               s[i] = styler[start + i];
+       }
+       s[i] = '\0';
+       return (0 == strcmp(s, "[CDATA["));
+}
+
 // Return the first state to reach when entering a scripting language
 static int StateForScript(int scriptLanguage) {
        int Result;
 // Return the first state to reach when entering a scripting language
 static int StateForScript(int scriptLanguage) {
        int Result;
@@ -320,6 +339,9 @@ static int StateForScript(int scriptLanguage) {
        case eScriptXML:
                Result = SCE_H_TAGUNKNOWN;
                break;
        case eScriptXML:
                Result = SCE_H_TAGUNKNOWN;
                break;
+       case eScriptSGML:
+               Result = SCE_H_SGML_DEFAULT;
+               break;
        default :
                Result = SCE_HJ_START;
                break;
        default :
                Result = SCE_HJ_START;
                break;
@@ -331,6 +353,10 @@ inline bool ishtmlwordchar(char ch) {
        return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
 }
 
        return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
 }
 
+inline bool issgmlwordchar(char ch) {
+       return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
+}
+
 static bool InTagState(int state) {
        return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN ||
               state == SCE_H_SCRIPT ||
 static bool InTagState(int state) {
        return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN ||
               state == SCE_H_SCRIPT ||
@@ -339,6 +365,10 @@ static bool InTagState(int state) {
               state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
 }
 
               state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
 }
 
+static bool IsCommentState(const int state) {
+       return state == SCE_H_COMMENT || state == SCE_H_SGML_COMMENT;
+}
+
 static bool isLineEnd(char ch) {
        return ch == '\r' || ch == '\n';
 }
 static bool isLineEnd(char ch) {
        return ch == '\r' || ch == '\n';
 }
@@ -348,23 +378,23 @@ static bool isOKBeforeRE(char ch) {
 }
 
 static bool isPHPStringState(int state) {
 }
 
 static bool isPHPStringState(int state) {
-       return 
-               (state == SCE_HPHP_HSTRING) ||
-               (state == SCE_HPHP_SIMPLESTRING) ||
-               (state == SCE_HPHP_HSTRING_VARIABLE);
+       return
+           (state == SCE_HPHP_HSTRING) ||
+           (state == SCE_HPHP_SIMPLESTRING) ||
+           (state == SCE_HPHP_HSTRING_VARIABLE);
 }
 
 static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
 }
 
 static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
-
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
        WordList &keywords3 = *keywordlists[2];
        WordList &keywords4 = *keywordlists[3];
        WordList &keywords5 = *keywordlists[4];
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
        WordList &keywords3 = *keywordlists[2];
        WordList &keywords4 = *keywordlists[3];
        WordList &keywords5 = *keywordlists[4];
+       WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
 
        // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
 
        // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
-       styler.StartAt(startPos, 127);
+       styler.StartAt(startPos, STYLE_MAX);
        char prevWord[200];
        prevWord[0] = '\0';
        int StateToPrint = initStyle;
        char prevWord[200];
        prevWord[0] = '\0';
        int StateToPrint = initStyle;
@@ -374,49 +404,51 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
        if (InTagState(state)) {
                while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
                        startPos--;
        if (InTagState(state)) {
                while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
                        startPos--;
-            length++;
+                       length++;
                }
                state = SCE_H_DEFAULT;
        }
                }
                state = SCE_H_DEFAULT;
        }
-       styler.StartAt(startPos, 127);
+       styler.StartAt(startPos, STYLE_MAX);
 
 
-       int lineState = eScriptVBS;
        int lineCurrent = styler.GetLine(startPos);
        int lineCurrent = styler.GetLine(startPos);
-       if (lineCurrent > 0)
+       int lineState;
+       if (lineCurrent > 0) {
                lineState = styler.GetLineState(lineCurrent);
                lineState = styler.GetLineState(lineCurrent);
-       int inScriptType  = (lineState >> 0) & 0x03; // 2 bits of scripting type
-       bool tagOpened    = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
-       bool tagClosing   = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
-       int defaultScript = (lineState >> 4) & 0x0F; // 4 bits of script name
-       int beforePreProc = (lineState >> 8) & 0xFF; // 8 bits of state
+       } else {
+               // Default client and ASP scripting language is JavaScript
+               lineState = eScriptJS << 8;
+               lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
+       }
+       int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
+       bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
+       bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
+       int aspScript = (lineState >> 4) & 0x0F; // 4 bits of script name
+       int clientScript = (lineState >> 8) & 0x0F; // 4 bits of script name
+       int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
 
        int scriptLanguage = ScriptOfState(state);
 
 
        int scriptLanguage = ScriptOfState(state);
 
-       bool fold = styler.GetPropertyInt("fold");
-       bool foldHTML = styler.GetPropertyInt("fold.html",0);
-       bool foldCompact = styler.GetPropertyInt("fold.compact",1);
-
-       fold = foldHTML && fold;
+       const bool foldHTML = styler.GetPropertyInt("fold.html", 0);
+       const bool fold = foldHTML && styler.GetPropertyInt("fold");
+       const bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
 
        int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
        int levelCurrent = levelPrev;
 
        int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
        int levelCurrent = levelPrev;
-       int visibleChars;
-
-       visibleChars = 0;
+       int visibleChars = 0;
 
        char chPrev = ' ';
        char ch = ' ';
        char chPrevNonWhite = ' ';
        styler.StartSegment(startPos);
 
        char chPrev = ' ';
        char ch = ' ';
        char chPrevNonWhite = ' ';
        styler.StartSegment(startPos);
-       int lengthDoc = startPos + length;
+       const int lengthDoc = startPos + length;
        for (int i = startPos; i < lengthDoc; i++) {
        for (int i = startPos; i < lengthDoc; i++) {
-               char chPrev2 = chPrev;
+               const char chPrev2 = chPrev;
                chPrev = ch;
                if (ch != ' ' && ch != '\t')
                        chPrevNonWhite = ch;
                ch = styler[i];
                char chNext = styler.SafeGetCharAt(i + 1);
                chPrev = ch;
                if (ch != ' ' && ch != '\t')
                        chPrevNonWhite = ch;
                ch = styler[i];
                char chNext = styler.SafeGetCharAt(i + 1);
-               char chNext2 = styler.SafeGetCharAt(i + 2);
+               const char chNext2 = styler.SafeGetCharAt(i + 2);
 
                // Handle DBCS codepages
                if (styler.IsLeadByte(ch)) {
 
                // Handle DBCS codepages
                if (styler.IsLeadByte(ch)) {
@@ -451,18 +483,21 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                        } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
                                                // check if the number of tabs is lower than the level
                                                int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8;
                                        } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
                                                // check if the number of tabs is lower than the level
                                                int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8;
-                                               for (int j = 0;Findlevel > 0;j++) {
+                                               for (int j = 0; Findlevel > 0; j++) {
                                                        char chTmp = styler.SafeGetCharAt(i + j + 1);
                                                        if (chTmp == '\t') {
                                                                Findlevel -= 8;
                                                        char chTmp = styler.SafeGetCharAt(i + j + 1);
                                                        if (chTmp == '\t') {
                                                                Findlevel -= 8;
-                                                       }       else if (chTmp == ' ') {
+                                                       } else if (chTmp == ' ') {
                                                                Findlevel--;
                                                                Findlevel--;
-                                                       }       else break;
+                                                       } else {
+                                                               break;
+                                                       }
                                                }
 
                                                if (Findlevel > 0) {
                                                        levelCurrent -= Findlevel / 8;
                                                }
 
                                                if (Findlevel > 0) {
                                                        levelCurrent -= Findlevel / 8;
-                                                       if (Findlevel % 8) levelCurrent--;
+                                                       if (Findlevel % 8)
+                                                               levelCurrent--;
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -487,11 +522,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        }
                        lineCurrent++;
                        styler.SetLineState(lineCurrent,
                        }
                        lineCurrent++;
                        styler.SetLineState(lineCurrent,
-                                           ((inScriptType  & 0x03) << 0) |
-                                                               ((tagOpened     & 0x01) << 2) |
-                                                               ((tagClosing    & 0x01) << 3) |
-                                           ((defaultScript & 0x0F) << 4) |
-                                           ((beforePreProc & 0xFF) << 8));
+                                           ((inScriptType & 0x03) << 0) |
+                                           ((tagOpened & 0x01) << 2) |
+                                           ((tagClosing & 0x01) << 3) |
+                                           ((aspScript & 0x0F) << 4) |
+                                           ((clientScript & 0x0F) << 8) |
+                                           ((beforePreProc & 0xFF) << 12));
                }
 
                // generic end of script processing
                }
 
                // generic end of script processing
@@ -503,9 +539,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        case SCE_H_SINGLESTRING:
                        case SCE_HJ_COMMENT:
                        case SCE_HJ_COMMENTDOC:
                        case SCE_H_SINGLESTRING:
                        case SCE_HJ_COMMENT:
                        case SCE_HJ_COMMENTDOC:
-                       // SCE_HJ_COMMENTLINE removed as this is a common thing done to hide
-                       // the end of script marker from some JS interpreters.
-                       //case SCE_HJ_COMMENTLINE:
+                               // SCE_HJ_COMMENTLINE removed as this is a common thing done to hide
+                               // the end of script marker from some JS interpreters.
+                               //case SCE_HJ_COMMENTLINE:
                        case SCE_HJ_DOUBLESTRING:
                        case SCE_HJ_SINGLESTRING:
                        case SCE_HB_STRING:
                        case SCE_HJ_DOUBLESTRING:
                        case SCE_HJ_SINGLESTRING:
                        case SCE_HB_STRING:
@@ -514,29 +550,31 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        case SCE_HP_TRIPLEDOUBLE:
                                break;
                        default :
                        case SCE_HP_TRIPLEDOUBLE:
                                break;
                        default :
-                               // maybe we should check here if it's a tag and if it's SCRIPT
+                               // closing tag of the script (it's a closing HTML tag anyway)
                                styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_H_TAGUNKNOWN;
                                inScriptType = eHtml;
                                scriptLanguage = eScriptNone;
                                styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_H_TAGUNKNOWN;
                                inScriptType = eHtml;
                                scriptLanguage = eScriptNone;
+                               clientScript = eScriptJS;
                                i += 2;
                                i += 2;
-                               // unfold closing script
-                               levelCurrent--;
+                               visibleChars += 2;
+                               tagClosing = true;
                                continue;
                        }
                }
 
                /////////////////////////////////////
                // handle the start of PHP pre-processor = Non-HTML
                                continue;
                        }
                }
 
                /////////////////////////////////////
                // handle the start of PHP pre-processor = Non-HTML
-               else if ((state != SCE_H_ASPAT) && 
-                               !isPHPStringState(state) && 
-                               (state != SCE_HPHP_COMMENT) && 
-                               (ch == '<') && 
-                               (chNext == '?')) {
+               else if ((state != SCE_H_ASPAT) &&
+                        !isPHPStringState(state) &&
+                        (state != SCE_HPHP_COMMENT) &&
+                        (ch == '<') &&
+                        (chNext == '?')) {
                        styler.ColourTo(i - 1, StateToPrint);
                        beforePreProc = state;
                        scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
                        i++;
                        styler.ColourTo(i - 1, StateToPrint);
                        beforePreProc = state;
                        scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
                        i++;
+                       visibleChars++;
                        i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 10);
                        if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLSTART);
                        i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 10);
                        if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLSTART);
@@ -567,6 +605,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
                        if (chNext2 == '@') {
                                i += 2; // place as if it was the second next char treated
 
                        if (chNext2 == '@') {
                                i += 2; // place as if it was the second next char treated
+                               visibleChars += 2;
                                state = SCE_H_ASPAT;
                        } else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
                                styler.ColourTo(i + 3, SCE_H_ASP);
                                state = SCE_H_ASPAT;
                        } else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
                                styler.ColourTo(i + 3, SCE_H_ASP);
@@ -576,11 +615,13 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        } else {
                                if (chNext2 == '=') {
                                        i += 2; // place as if it was the second next char treated
                        } else {
                                if (chNext2 == '=') {
                                        i += 2; // place as if it was the second next char treated
+                                       visibleChars += 2;
                                } else {
                                        i++; // place as if it was the next char treated
                                } else {
                                        i++; // place as if it was the next char treated
+                                       visibleChars++;
                                }
 
                                }
 
-                               state = StateForScript(defaultScript);
+                               state = StateForScript(aspScript);
                        }
                        scriptLanguage = eScriptVBS;
                        styler.ColourTo(i, SCE_H_ASP);
                        }
                        scriptLanguage = eScriptVBS;
                        styler.ColourTo(i, SCE_H_ASP);
@@ -591,17 +632,42 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        continue;
                }
 
                        continue;
                }
 
+               /////////////////////////////////////
+               // handle the start of SGML language (DTD)
+               else if (((scriptLanguage == eScriptNone) || (scriptLanguage == eScriptXML)) &&
+                        (chPrev == '<') &&
+                        (ch == '!') &&
+                        (StateToPrint != SCE_H_CDATA) && (!IsCommentState(StateToPrint))) {
+                       beforePreProc = state;
+                       styler.ColourTo(i - 2, StateToPrint);
+                       if ((chNext == '-') && (chNext2 == '-')) {
+                               state = SCE_H_COMMENT; // wait for a pending command
+                       }
+                       else if (isWordCdata(i + 1, i + 7, styler)) {
+                               state = SCE_H_CDATA;
+                       } else {
+                               styler.ColourTo(i, SCE_H_SGML_DEFAULT); // <! is default
+                               scriptLanguage = eScriptSGML;
+                               state = SCE_H_SGML_COMMAND; // wait for a pending command
+                       }
+                       // fold whole tag (-- when closing the tag)
+
+                       levelCurrent++;
+                       continue;
+               }
+
                // handle the end of a pre-processor = Non-HTML
                // handle the end of a pre-processor = Non-HTML
-               else if (
-                       ((inScriptType == eNonHtmlPreProc)
-                               || (inScriptType == eNonHtmlScriptPreProc)) && (
-                               ((scriptLanguage == eScriptPHP) && (ch == '?') && !isPHPStringState(state) && (state != SCE_HPHP_COMMENT)) || 
-                               ((scriptLanguage != eScriptNone) && !isStringState(state) &&
-                                (ch == '%'))
-                       ) && (chNext == '>')) {
+               else if ((
+                            ((inScriptType == eNonHtmlPreProc)
+                             || (inScriptType == eNonHtmlScriptPreProc)) && (
+                                ((scriptLanguage == eScriptPHP) && (ch == '?') && !isPHPStringState(state) && (state != SCE_HPHP_COMMENT)) ||
+                                ((scriptLanguage != eScriptNone) && !isStringState(state) &&
+                                 (ch == '%'))
+                            ) && (chNext == '>')) ||
+                        ((scriptLanguage == eScriptSGML) && (ch == '>') && (state != SCE_H_SGML_COMMENT))) {
                        if (state == SCE_H_ASPAT) {
                        if (state == SCE_H_ASPAT) {
-                               defaultScript = segIsScriptingIndicator(styler,
-                                       styler.GetStartSegment(), i - 1, defaultScript);
+                               aspScript = segIsScriptingIndicator(styler,
+                                                                   styler.GetStartSegment(), i - 1, aspScript);
                        }
                        // Bounce out of any ASP mode
                        switch (state) {
                        }
                        // Bounce out of any ASP mode
                        switch (state) {
@@ -624,11 +690,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                styler.ColourTo(i - 1, StateToPrint);
                                break;
                        }
                                styler.ColourTo(i - 1, StateToPrint);
                                break;
                        }
-                       i++;
+                       if (scriptLanguage != eScriptSGML) {
+                               i++;
+                               visibleChars++;
+                       }
                        if (ch == '%')
                                styler.ColourTo(i, SCE_H_ASP);
                        else if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLEND);
                        if (ch == '%')
                                styler.ColourTo(i, SCE_H_ASP);
                        else if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLEND);
+                       else if (scriptLanguage == eScriptSGML)
+                               styler.ColourTo(i, SCE_H_SGML_DEFAULT);
                        else
                                styler.ColourTo(i, SCE_H_QUESTION);
                        state = beforePreProc;
                        else
                                styler.ColourTo(i, SCE_H_QUESTION);
                        state = beforePreProc;
@@ -648,47 +719,156 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (ch == '<') {
                                // in HTML, fold on tag open and unfold on tag close
                                tagOpened = true;
                        if (ch == '<') {
                                // in HTML, fold on tag open and unfold on tag close
                                tagOpened = true;
-                               if (chNext == '/') {
-                                       tagClosing = true;
-                               } else {
-                                       tagClosing = false;
-                               }
-
+                               tagClosing = (chNext == '/');
                                styler.ColourTo(i - 1, StateToPrint);
                                styler.ColourTo(i - 1, StateToPrint);
-                               if (chNext == '!' && chNext2 == '-' && styler.SafeGetCharAt(i + 3) == '-') {
-                                       // should be better
-                                       i += 3;
-                                       levelCurrent++;
-                                       state = SCE_H_COMMENT;
-                               } else
+                               if (chNext != '!')
                                        state = SCE_H_TAGUNKNOWN;
                        } else if (ch == '&') {
                                styler.ColourTo(i - 1, SCE_H_DEFAULT);
                                state = SCE_H_ENTITY;
                        }
                        break;
                                        state = SCE_H_TAGUNKNOWN;
                        } else if (ch == '&') {
                                styler.ColourTo(i - 1, SCE_H_DEFAULT);
                                state = SCE_H_ENTITY;
                        }
                        break;
-               case SCE_H_COMMENT:
-                       if ((ch == '>') && (chPrev == '-') && (chPrev2 == '-')) {
-                               // unfold HTML comment
-                               levelCurrent--;
+               case SCE_H_SGML_DEFAULT:
+                       if (scriptLanguage == eScriptSGMLblock)
+                               StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
+
+                       if (ch == '\"') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_DOUBLESTRING;
+                       } else if (ch == '\'') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_SIMPLESTRING;
+                       } else if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       } else if (isalpha(ch) && (chPrev == '%')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_ENTITY;
+                       } else if (ch == '#') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_SPECIAL;
+                       } else if (ch == '[') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               scriptLanguage = eScriptSGMLblock;
+                       } else if (ch == ']') {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i, StateToPrint);
+                                       scriptLanguage = eScriptSGML;
+                               } else {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_ERROR);
+                               }
+                       } else if (scriptLanguage == eScriptSGMLblock) {
+                               if ((ch == '!') && (chPrev == '<')) {
+                                       styler.ColourTo(i - 2, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_DEFAULT);
+                                       state = SCE_H_SGML_COMMAND;
+                               } else if (ch == '>') {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_DEFAULT);
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_COMMAND:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       } else if (!issgmlwordchar(ch)) {
+                               if (isWordHSGML(styler.GetStartSegment(), i - 1, keywords6, styler)) {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       state = SCE_H_SGML_1ST_PARAM;
+                               } else {
+                                       state = SCE_H_SGML_ERROR;
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_1ST_PARAM:
+                       // wait for the beginning of the word
+                       if ((ch == '-') && (chPrev == '-')) {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i - 2, SCE_H_SGML_BLOCK_DEFAULT);
+                               } else {
+                                       styler.ColourTo(i - 2, SCE_H_SGML_DEFAULT);
+                               }
+                               state = SCE_H_SGML_1ST_PARAM_COMMENT;
+                       } else if (issgmlwordchar(ch)) {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i - 1, SCE_H_SGML_BLOCK_DEFAULT);
+                               } else {
+                                       styler.ColourTo(i - 1, SCE_H_SGML_DEFAULT);
+                               }
+                               // find the length of the word
+                               int size = 1;
+                               while (ishtmlwordchar(styler.SafeGetCharAt(i + size)))
+                                       size++;
+                               styler.ColourTo(i + size - 1, StateToPrint);
+                               i += size - 1;
+                               visibleChars += size - 1;
+                               ch = styler.SafeGetCharAt(i);
+                               state = SCE_H_SGML_DEFAULT;
+                               continue;
+                       }
+                       break;
+               case SCE_H_SGML_ERROR:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       }
+               case SCE_H_SGML_DOUBLESTRING:
+                       if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
                                styler.ColourTo(i, StateToPrint);
-                               state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               state = SCE_H_SGML_DEFAULT;
+                       }
+                       break;
+               case SCE_H_SGML_SIMPLESTRING:
+                       if (ch == '\'') {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
+                       }
+                       break;
+               case SCE_H_SGML_COMMENT:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
                        }
                        break;
                case SCE_H_CDATA:
                        }
                        break;
                case SCE_H_CDATA:
-                       if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) {
+                       if ((chPrev2 == ']') && (chPrev == ']') && (ch == '>')) {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               levelCurrent--;
                        }
                        break;
                        }
                        break;
-               case SCE_H_SGML:
-                       if (ch == '>') {
-                               levelCurrent--;
+               case SCE_H_COMMENT:
+                       if ((chPrev2 == '-') && (chPrev == '-') && (ch == '>')) {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               levelCurrent--;
+                       }
+                       break;
+               case SCE_H_SGML_1ST_PARAM_COMMENT:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i, SCE_H_SGML_COMMENT);
+                               state = SCE_H_SGML_1ST_PARAM;
+                       }
+                       break;
+               case SCE_H_SGML_SPECIAL:
+                       if (!isupper(ch)) {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               if (isalnum(ch)) {
+                                       state = SCE_H_SGML_ERROR;
+                               } else {
+                                       state = SCE_H_SGML_DEFAULT;
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_ENTITY:
+                       if (ch == ';') {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
+                       } else if (!isalnum(ch) && ch != '-' && ch != '.') {
+                               styler.ColourTo(i, SCE_H_SGML_ERROR);
+                               state = SCE_H_SGML_DEFAULT;
                        }
                        break;
                case SCE_H_ENTITY:
                        }
                        break;
                case SCE_H_ENTITY:
@@ -705,9 +885,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
                                int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
                                if (eClass == SCE_H_SCRIPT) {
                        if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
                                int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
                                if (eClass == SCE_H_SCRIPT) {
-                                       inScriptType = eNonHtmlScript;
-                                       scriptLanguage = defaultScript;
-                                       eClass = SCE_H_TAG;
+                                       if (!tagClosing) {
+                                               inScriptType = eNonHtmlScript;
+                                               scriptLanguage = clientScript;
+                                               eClass = SCE_H_TAG;
+                                       } else {
+                                               scriptLanguage = eScriptNone;
+                                               eClass = SCE_H_TAG;
+                                       }
                                }
                                if (ch == '>') {
                                        styler.ColourTo(i, eClass);
                                }
                                if (ch == '>') {
                                        styler.ColourTo(i, eClass);
@@ -717,28 +902,27 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                                state = SCE_H_DEFAULT;
                                        }
                                        tagOpened = false;
                                                state = SCE_H_DEFAULT;
                                        }
                                        tagOpened = false;
-                                       if (tagClosing)
+                                       if (tagClosing) {
                                                levelCurrent--;
                                                levelCurrent--;
-                                       else
+                                       } else {
                                                levelCurrent++;
                                                levelCurrent++;
+                                       }
                                        tagClosing = false;
                                        tagClosing = false;
-                           } else if (ch == '/' && chNext == '>') {
+                               } else if (ch == '/' && chNext == '>') {
                                        if (eClass == SCE_H_TAGUNKNOWN) {
                                        if (eClass == SCE_H_TAGUNKNOWN) {
-                                           styler.ColourTo(i + 1, SCE_H_TAGUNKNOWN);
+                                               styler.ColourTo(i + 1, SCE_H_TAGUNKNOWN);
                                        } else {
                                        } else {
-                                           styler.ColourTo(i - 1, StateToPrint);
-                                           styler.ColourTo(i + 1, SCE_H_TAGEND);
+                                               styler.ColourTo(i - 1, StateToPrint);
+                                               styler.ColourTo(i + 1, SCE_H_TAGEND);
                                        }
                                        }
-                                   i++;
-                                   ch = chNext;
-                                   state = SCE_H_DEFAULT;
+                                       i++;
+                                       ch = chNext;
+                                       state = SCE_H_DEFAULT;
                                        tagOpened = false;
                                } else {
                                        if (eClass != SCE_H_TAGUNKNOWN) {
                                        tagOpened = false;
                                } else {
                                        if (eClass != SCE_H_TAGUNKNOWN) {
-                                               if (eClass == SCE_H_CDATA) {
-                                                       state = SCE_H_CDATA;
-                                               } else if (eClass == SCE_H_SGML) {
-                                                       state = SCE_H_SGML;
+                                               if (eClass == SCE_H_SGML_DEFAULT) {
+                                                       state = SCE_H_SGML_DEFAULT;
                                                } else {
                                                        state = SCE_H_OTHER;
                                                }
                                                } else {
                                                        state = SCE_H_OTHER;
                                                }
@@ -750,7 +934,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
                                if (inScriptType == eNonHtmlScript) {
                                        int scriptLanguagePrev = scriptLanguage;
                        if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
                                if (inScriptType == eNonHtmlScript) {
                                        int scriptLanguagePrev = scriptLanguage;
-                                       scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
+                                       clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
+                                       scriptLanguage = clientScript;
                                        if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
                                                inScriptType = eHtml;
                                }
                                        if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
                                                inScriptType = eHtml;
                                }
@@ -1217,18 +1402,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                case SCE_HPHP_NUMBER:
                        if (!isdigit(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
                case SCE_HPHP_NUMBER:
                        if (!isdigit(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
-                               if (isoperator(ch)) 
-                                       state =SCE_HPHP_OPERATOR;
-                               else 
+                               if (isoperator(ch))
+                                       state = SCE_HPHP_OPERATOR;
+                               else
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                case SCE_HPHP_VARIABLE:
                        if (!iswordstart(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                case SCE_HPHP_VARIABLE:
                        if (!iswordstart(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
-                               if (isoperator(ch)) 
-                                       state =SCE_HPHP_OPERATOR;
-                               else 
+                               if (isoperator(ch))
+                                       state = SCE_HPHP_OPERATOR;
+                               else
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
@@ -1249,7 +1434,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                // skip the next char
                                i++;
                        } else if (ch == '$') {
                                // skip the next char
                                i++;
                        } else if (ch == '$') {
-                               styler.ColourTo(i-1, StateToPrint);
+                               styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_HPHP_HSTRING_VARIABLE;
                        } else if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_HPHP_HSTRING_VARIABLE;
                        } else if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
@@ -1267,13 +1452,13 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        break;
                case SCE_HPHP_HSTRING_VARIABLE:
                        if (!iswordstart(ch)) {
                        break;
                case SCE_HPHP_HSTRING_VARIABLE:
                        if (!iswordstart(ch)) {
-                               styler.ColourTo(i-1, StateToPrint);
+                               styler.ColourTo(i - 1, StateToPrint);
                                i--; // strange but it works
                                state = SCE_HPHP_HSTRING;
                        }
                        break;
                case SCE_HPHP_OPERATOR:
                                i--; // strange but it works
                                state = SCE_HPHP_HSTRING;
                        }
                        break;
                case SCE_HPHP_OPERATOR:
-               case SCE_HPHP_DEFAULT:
+               case SCE_HPHP_DEFAULT:
                        styler.ColourTo(i - 1, StateToPrint);
                        if (isdigit(ch)) {
                                state = SCE_HPHP_NUMBER;
                        styler.ColourTo(i - 1, StateToPrint);
                        if (isdigit(ch)) {
                                state = SCE_HPHP_NUMBER;
@@ -1304,6 +1489,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
                // Some of the above terminated their lexeme but since the same character starts
                // the same class again, only reenter if non empty segment.
 
                // Some of the above terminated their lexeme but since the same character starts
                // the same class again, only reenter if non empty segment.
+
                bool nonEmptySegment = i >= static_cast<int>(styler.GetStartSegment());
                if (state == SCE_HB_DEFAULT) {    // One of the above succeeded
                        if ((ch == '\"') && (nonEmptySegment)) {
                bool nonEmptySegment = i >= static_cast<int>(styler.GetStartSegment());
                if (state == SCE_HB_DEFAULT) {    // One of the above succeeded
                        if ((ch == '\"') && (nonEmptySegment)) {
@@ -1335,7 +1521,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                state = SCE_HJ_COMMENTLINE;
                        } else if ((ch == '\"') && (nonEmptySegment)) {
                                state = SCE_HJ_DOUBLESTRING;
                                state = SCE_HJ_COMMENTLINE;
                        } else if ((ch == '\"') && (nonEmptySegment)) {
                                state = SCE_HJ_DOUBLESTRING;
-                       } else if ((ch == '\'')  && (nonEmptySegment)) {
+                       } else if ((ch == '\'') && (nonEmptySegment)) {
                                state = SCE_HJ_SINGLESTRING;
                        } else if (iswordstart(ch)) {
                                state = SCE_HJ_WORD;
                                state = SCE_HJ_SINGLESTRING;
                        } else if (iswordstart(ch)) {
                                state = SCE_HJ_WORD;
@@ -1357,4 +1543,3 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
 LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
 LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
 
 LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
 LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
-
index 6669694d1d6451d9c0c1d56ef6b636359ffb0b52..221859035e353cca2f3e6377be2c48fadf5bc8c2 100644 (file)
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
-/* Returns true if the "as" word that begins at start follows an import statement */
-static bool IsImportAs(unsigned int start, Accessor &styler) {
-       unsigned int i;
-       unsigned int j;
-       char s[10];
-
-       /* Find any import before start but after any statement terminator or quote */
-       i = start;
-       while (i > 0) {
-               char ch = styler[i - 1];
-
-               if (ch == '\n' || ch == '\r' || ch == ';' || ch == '\'' || ch == '"' || ch == '`')
-                       break;
-               if (ch == 't' && i > 5) {
-                       for (j = 0; j < 6; j++)
-                               s[j] = styler[(i - 6) + j];
-                       s[j] = '\0';
-                       if (strcmp(s, "import") == 0)
-                               return true;
-               }
-               i--;
-       }
-
-        return false;
-}
-
-static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
-       char s[100];
-       bool wordIsNumber = isdigit(styler[start]);
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
-               s[i] = styler[start + i];
-               s[i + 1] = '\0';
-       }
-       char chAttr = SCE_P_IDENTIFIER;
-       if (0 == strcmp(prevWord, "class"))
-               chAttr = SCE_P_CLASSNAME;
-       else if (0 == strcmp(prevWord, "def"))
-               chAttr = SCE_P_DEFNAME;
-       else if (wordIsNumber)
-               chAttr = SCE_P_NUMBER;
-       else if (keywords.InList(s))
-               chAttr = SCE_P_WORD;
-       else if (strcmp(s, "as") == 0 && IsImportAs(start, styler))
-               chAttr = SCE_P_WORD;
-       // make sure that dot-qualifiers inside the word are lexed correct
-       else for (unsigned int i = 0; i < end - start + 1; i++) {
-               if (styler[start + i] == '.') {
-                       styler.ColourTo(start + i - 1, chAttr);
-                       styler.ColourTo(start + i, SCE_P_OPERATOR);
-               }
-       }
-       styler.ColourTo(end, chAttr);
-       strcpy(prevWord, s);
-}
+enum kwType { kwOther, kwClass, kwDef, kwImport };
 
 static bool IsPyComment(Accessor &styler, int pos, int len) {
        return len>0 && styler[pos]=='#';
 }
 
 
 static bool IsPyComment(Accessor &styler, int pos, int len) {
        return len>0 && styler[pos]=='#';
 }
 
-static bool IsPyStringStart(char ch, char chNext, char chNext2) {
+static bool IsPyStringStart(int ch, int chNext, int chNext2) {
        if (ch == '\'' || ch == '"')
                return true;
        if (ch == 'u' || ch == 'U') {
        if (ch == '\'' || ch == '"')
                return true;
        if (ch == 'u' || ch == 'U') {
@@ -93,10 +41,6 @@ static bool IsPyStringStart(char ch, char chNext, char chNext2) {
        return false;
 }
 
        return false;
 }
 
-static bool IsPyWordStart(char ch, char chNext, char chNext2) {
-       return (iswordchar(ch) && !IsPyStringStart(ch, chNext, chNext2));
-}
-
 /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
 static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        char ch = styler.SafeGetCharAt(i);
 /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
 static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        char ch = styler.SafeGetCharAt(i);
@@ -139,10 +83,18 @@ static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        }
 }
 
        }
 }
 
+inline bool IsAWordChar(int  ch) {
+       return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+inline bool IsAWordStart(int ch) {
+       return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
 static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                                                   WordList *keywordlists[], Accessor &styler) {
 
 static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                                                   WordList *keywordlists[], Accessor &styler) {
 
-       int lengthDoc = startPos + length;
+       int endPos = startPos + length;
 
        // Backtrack to previous line in case need to fix its tab whinging
        int lineCurrent = styler.GetLine(startPos);
 
        // Backtrack to previous line in case need to fix its tab whinging
        int lineCurrent = styler.GetLine(startPos);
@@ -156,32 +108,27 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                }
        }
 
                }
        }
 
-       // Python uses a different mask because bad indentation is marked by oring with 32
-       styler.StartAt(startPos, 127);
-
        WordList &keywords = *keywordlists[0];
 
        WordList &keywords = *keywordlists[0];
 
-       int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
-       char prevWord[200];
-       prevWord[0] = '\0';
-       if (length == 0)
-               return ;
+       const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
 
 
-       int state = initStyle & 31;
+       initStyle = initStyle & 31;
+       if (initStyle == SCE_P_STRINGEOL) {
+               initStyle = SCE_P_DEFAULT;
+       }
 
 
-       int nextIndex = 0;
-       char chPrev = ' ';
-       char chPrev2 = ' ';
-       char chNext = styler[startPos];
-       styler.StartSegment(startPos);
-       bool atStartLine = true;
+       kwType kwLast = kwOther;
        int spaceFlags = 0;
        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
        int spaceFlags = 0;
        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-       for (int i = startPos; i < lengthDoc; i++) {
+       
+       // Python uses a different mask because bad indentation is marked by oring with 32
+       StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f);
+       
+       for (; sc.More(); sc.Forward()) {
 
 
-               if (atStartLine) {
-                       char chBad = static_cast<char>(64);
-                       char chGood = static_cast<char>(0);
+               if (sc.atLineStart) {
+                       const char chBad = static_cast<char>(64);
+                       const char chGood = static_cast<char>(0);
                        char chFlags = chGood;
                        if (whingeLevel == 1) {
                                chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
                        char chFlags = chGood;
                        if (whingeLevel == 1) {
                                chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
@@ -192,132 +139,117 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                        } else if (whingeLevel == 4) {
                                chFlags = (spaceFlags & wsTab) ? chBad : chGood;
                        }
                        } else if (whingeLevel == 4) {
                                chFlags = (spaceFlags & wsTab) ? chBad : chGood;
                        }
-                       styler.SetFlags(chFlags, static_cast<char>(state));
-                       atStartLine = false;
+                       styler.SetFlags(chFlags, static_cast<char>(sc.state));
                }
 
                }
 
-               char ch = chNext;
-               chNext = styler.SafeGetCharAt(i + 1);
-               char chNext2 = styler.SafeGetCharAt(i + 2);
-
-               if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
-                       if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
+               if (sc.atLineEnd) {
+                       if ((sc.state == SCE_P_DEFAULT) || 
+                               (sc.state == SCE_P_TRIPLE) || 
+                               (sc.state == SCE_P_TRIPLEDOUBLE)) {
                                // Perform colourisation of white space and triple quoted strings at end of each line to allow
                                // tab marking to work inside white space and triple quoted strings
                                // Perform colourisation of white space and triple quoted strings at end of each line to allow
                                // tab marking to work inside white space and triple quoted strings
-                               styler.ColourTo(i, state);
+                               sc.ForwardSetState(sc.state);
                        }
                        lineCurrent++;
                        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
                        }
                        lineCurrent++;
                        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-                       atStartLine = true;
-               }
-
-               if (styler.IsLeadByte(ch)) {
-                       chNext = styler.SafeGetCharAt(i + 2);
-                       chPrev = ' ';
-                       chPrev2 = ' ';
-                       i += 1;
-                       continue;
+                       if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
+                               sc.ChangeState(SCE_P_STRINGEOL);
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
                }
 
                }
 
-               if (state == SCE_P_STRINGEOL) {
-                       if (ch != '\r' && ch != '\n') {
-                               styler.ColourTo(i - 1, state);
-                               state = SCE_P_DEFAULT;
+               // Check for a state end
+               if (sc.state == SCE_P_OPERATOR) {
+                       kwLast = kwOther;
+                       sc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_P_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_P_DEFAULT);
                        }
                        }
-               }
-               if (state == SCE_P_DEFAULT) {
-                       if (IsPyWordStart(ch, chNext, chNext2)) {
-                               styler.ColourTo(i - 1, state);
-                               state = SCE_P_WORD;
-                       } else if (ch == '#') {
-                               styler.ColourTo(i - 1, state);
-                               state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
-                       } else if (IsPyStringStart(ch, chNext, chNext2)) {
-                               styler.ColourTo(i - 1, state);
-                               state = GetPyStringState(styler, i, &nextIndex);
-                               if (nextIndex != i + 1) {
-                                       i = nextIndex - 1;
-                                       ch = ' ';
-                                       chPrev = ' ';
-                                       chNext = styler.SafeGetCharAt(i + 1);
+               } else if (sc.state == SCE_P_WORD) {
+                       if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
+                               char s[100];
+                               sc.GetCurrent(s, sizeof(s));
+                               int style = SCE_P_IDENTIFIER;
+                               if ((kwLast == kwImport) && (strcmp(s, "as") == 0)) {
+                                       style = SCE_P_WORD;
+                               } else if (keywords.InList(s)) {
+                                       style = SCE_P_WORD;
+                               } else if (kwLast == kwClass) {
+                                       style = SCE_P_CLASSNAME;
+                               } else if (kwLast == kwDef) {
+                                       style = SCE_P_DEFNAME;
                                }
                                }
-                       } else if (isoperator(ch)) {
-                               styler.ColourTo(i - 1, state);
-                               styler.ColourTo(i, SCE_P_OPERATOR);
-                       }
-               } else if (state == SCE_P_WORD) {
-                       if (!iswordchar(ch)) {
-                               ClassifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
-                               state = SCE_P_DEFAULT;
-                               if (ch == '#') {
-                                       state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
-                               } else if (IsPyStringStart(ch, chNext, chNext2)) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = GetPyStringState(styler, i, &nextIndex);
-                                       if (nextIndex != i + 1) {
-                                               i = nextIndex - 1;
-                                               ch = ' ';
-                                               chPrev = ' ';
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (isoperator(ch)) {
-                                       styler.ColourTo(i, SCE_P_OPERATOR);
+                               sc.ChangeState(style);
+                               sc.SetState(SCE_P_DEFAULT);
+                               if (style == SCE_P_WORD) {
+                                       if (0 == strcmp(s, "class"))
+                                               kwLast = kwClass;
+                                       else if (0 == strcmp(s, "def"))
+                                               kwLast = kwDef;
+                                       else if (0 == strcmp(s, "import"))
+                                               kwLast = kwImport;
+                                       else
+                                               kwLast = kwOther;
+                               } else if (style == SCE_P_CLASSNAME) {
+                                               kwLast = kwOther;
+                               } else if (style == SCE_P_DEFNAME) {
+                                               kwLast = kwOther;
                                }
                        }
                                }
                        }
-               } else {
-                       if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
-                               if (ch == '\r' || ch == '\n') {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_STRING) {
-                               if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_STRINGEOL;
-                               } else if (ch == '\\') {
-                                       if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
-                                               i++;
-                                               ch = chNext;
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (ch == '\"') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_CHARACTER) {
-                               if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_STRINGEOL;
-                               } else if (ch == '\\') {
-                                       if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
-                                               i++;
-                                               ch = chNext;
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (ch == '\'') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_TRIPLE) {
-                               if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
+               } else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_P_DEFAULT);
+                       }
+               } else if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
+                       if (sc.ch == '\\') {
+                               if ((sc.chNext == '\r') && (sc.GetRelative(2) == '\n')) {
+                                       sc.Forward();
                                }
                                }
-                       } else if (state == SCE_P_TRIPLEDOUBLE) {
-                               if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
+                               sc.Forward();
+                       } else if ((sc.state == SCE_P_STRING) && (sc.ch == '\"')) {
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       } else if ((sc.state == SCE_P_CHARACTER) && (sc.ch == '\'')) {
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               } else if (sc.state == SCE_P_TRIPLE) {
+                       if (sc.ch == '\\') {
+                               sc.Forward();
+                       } else if (sc.Match("\'\'\'")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               } else if (sc.state == SCE_P_TRIPLEDOUBLE) {
+                       if (sc.ch == '\\') {
+                               sc.Forward();
+                       } else if (sc.Match("\"\"\"")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               }
+
+               // Check for a new state starting character
+               if (sc.state == SCE_P_DEFAULT) {
+                       if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
+                               sc.SetState(SCE_P_OPERATOR);
+                       } else if (sc.ch == '#') {
+                               sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+                               sc.SetState(SCE_P_NUMBER);
+                       } else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
+                               int nextIndex = 0;
+                               sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
+                               while (nextIndex > (sc.currentPos+1)) {
+                                       sc.Forward();
                                }
                                }
+                       } else if (IsAWordStart(sc.ch)) {
+                               sc.SetState(SCE_P_WORD);
                        }
                }
                        }
                }
-               chPrev2 = chPrev;
-               chPrev = ch;
-       }
-       if (state == SCE_P_WORD) {
-               ClassifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
-       } else {
-               styler.ColourTo(lengthDoc, state);
        }
        }
+       sc.Complete();
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
@@ -338,14 +270,15 @@ static bool IsQuoteLine(int line, Accessor &styler) {
        return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
 }
 
        return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
 }
 
+
 static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
                                        WordList *[], Accessor &styler) {
 static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
                                        WordList *[], Accessor &styler) {
-       int maxPos = startPos + length;
-       int maxLines = styler.GetLine(maxPos-1);
-                                               
-       bool foldComment = styler.GetPropertyInt("fold.comment.python");
-       bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
-
+       const int maxPos = startPos + length;
+       const int maxLines = styler.GetLine(maxPos-1);             // Requested last line
+       const int docLines = styler.GetLine(styler.Length() - 1);  // Available last line
+       const bool foldComment = styler.GetPropertyInt("fold.comment.python");
+       const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
+       
        // Backtrack to previous non-blank line so we can determine indent level
        // for any white space lines (needed esp. within triple quoted strings)
        // and so we can fix any preceding fold level (which is why we go back
        // Backtrack to previous non-blank line so we can determine indent level
        // for any white space lines (needed esp. within triple quoted strings)
        // and so we can fix any preceding fold level (which is why we go back
@@ -363,8 +296,8 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
        }
        int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
        
        }
        int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
        
+       // Set up initial loop state
        startPos = styler.LineStart(lineCurrent);
        startPos = styler.LineStart(lineCurrent);
-       // Set up initial state
        int prev_state = SCE_P_DEFAULT & 31;
        if (lineCurrent >= 1)
                prev_state = styler.StyleAt(startPos-1) & 31;
        int prev_state = SCE_P_DEFAULT & 31;
        if (lineCurrent >= 1)
                prev_state = styler.StyleAt(startPos-1) & 31;
@@ -374,21 +307,27 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
 
        // Process all characters to end of requested range or end of any triple quote
                prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
 
        // Process all characters to end of requested range or end of any triple quote
-       // or comment that hangs over the end of the range
-       while ((lineCurrent <= maxLines) || prevQuote || prevComment) {
+       // or comment that hangs over the end of the range.  Cap processing in all cases
+       // to end of document (in case of unclosed quote or comment at end).
+       while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote || prevComment)) {
 
                // Gather info
                int lev = indentCurrent;
                int lineNext = lineCurrent + 1;
 
                // Gather info
                int lev = indentCurrent;
                int lineNext = lineCurrent + 1;
-               int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
-               int indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
-               int quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
-               int quote_start = (quote && !prevQuote);
-               int quote_continue = (quote && prevQuote);
-               int comment = foldComment && IsCommentLine(lineCurrent, styler);
-               int comment_start = (comment && !prevComment && 
+               int indentNext = indentCurrent;
+               int quote = false;
+               if (lineNext <= docLines) {
+                       // Information about next line is only available if not at end of document
+                       indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
+                       int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
+                       quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+               }
+               const int quote_start = (quote && !prevQuote);
+               const int quote_continue = (quote && prevQuote);
+               const int comment = foldComment && IsCommentLine(lineCurrent, styler);
+               const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
                        IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
                        IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
-               int comment_continue = (comment && prevComment);
+               const int comment_continue = (comment && prevComment);
                if ((!quote || !prevQuote) && !comment)
                        indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
                if (quote)
                if ((!quote || !prevQuote) && !comment)
                        indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
                if (quote)
@@ -411,22 +350,35 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                }
 
                // Skip past any blank lines for next indent level info; we skip also comments
                }
 
                // Skip past any blank lines for next indent level info; we skip also comments
-               // starting in column 0 which effectively folds them into surrounding code
-               // rather than screwing up folding.  Then set indent level on the lines
-               // we skipped to be same as maximum of current and next indent.  This approach
-               // does a reasonable job of collapsing white space into surrounding code
-               // without getting confused by white space at the start of an indented level.
+               // starting in column 0 which effectively folds them into surrounding code rather
+               // than screwing up folding.
+               const int saveIndentNext = indentNext;
                while (!quote &&
                while (!quote &&
-                      ((indentNext & SC_FOLDLEVELWHITEFLAG) || styler[styler.LineStart(lineNext)] == '#') &&
-                      (lineNext < maxLines)) {
-                       int level = Platform::Maximum(indentCurrent, indentNext);
-                       if (indentNext & SC_FOLDLEVELWHITEFLAG)
-                               level = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
-                       styler.SetLevel(lineNext, level);
+                      (lineNext < docLines) &&
+                      ((indentNext & SC_FOLDLEVELWHITEFLAG) || 
+                       (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
+
                        lineNext++;
                        indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
                }
 
                        lineNext++;
                        indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
                }
 
+               // Next compute max indent level of current line and next non-blank line.
+               // This is the level to which we set all the intervening blank or comment lines.
+               const int skip_level = Platform::Maximum(indentCurrentLevel,
+                                                  indentNext & SC_FOLDLEVELNUMBERMASK);
+               
+               // Now set all the indent levels on the lines we skipped
+               int skipLine = lineCurrent + 1;
+               int skipIndentNext = saveIndentNext;
+               while (skipLine < lineNext) {
+                       int skipLineLevel = skip_level;
+                       if (skipIndentNext & SC_FOLDLEVELWHITEFLAG)
+                               skipLineLevel = SC_FOLDLEVELWHITEFLAG | skipLineLevel;
+                       styler.SetLevel(skipLine, skipLineLevel);
+                       skipLine++;
+                       skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL);
+               }
+               
                // Set fold header on non-quote/non-comment line
                if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
                        if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
                // Set fold header on non-quote/non-comment line
                if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
                        if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
@@ -443,8 +395,9 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                lineCurrent = lineNext;
        }
 
                lineCurrent = lineNext;
        }
 
-       // Make sure last line indent level is set too
-       styler.SetLevel(lineCurrent, indentCurrent);
+       // NOTE: Cannot set level of last line here because indentCurrent doesn't have
+       // header flag set; the loop above is crafted to take care of this case!
+       //styler.SetLevel(lineCurrent, indentCurrent);
 }
 
 LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc);
 }
 
 LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc);
index dc1468d8324ced046063c8eecea21b95ec0ac412..a7c5b124fc6d12c8922e839ce0af761da8db7b54 100644 (file)
@@ -40,7 +40,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
        surface->FillRectangle(rcH, fore);
 }
 
        surface->FillRectangle(rcH, fore);
 }
 
-void LineMarker::Draw(Surface *surface, PRectangle &rcWhole) {
+void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter) {
        // Restrict most shapes a bit
        PRectangle rc = rcWhole;
        rc.top++;
        // Restrict most shapes a bit
        PRectangle rc = rcWhole;
        rc.top++;
@@ -230,6 +230,15 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole) {
                surface->MoveTo(centreX, rcWhole.top);
                surface->LineTo(centreX, centreY - blobSize);
                
                surface->MoveTo(centreX, rcWhole.top);
                surface->LineTo(centreX, centreY - blobSize);
                
+       } else if (markType >= SC_MARK_CHARACTER) {
+               char character[1];
+               character[0] = static_cast<char>(markType - SC_MARK_CHARACTER);
+               int width = surface->WidthText(fontForCharacter, character, 1);
+               rc.left += (rc.Width() - width) / 2;
+               rc.right = rc.left + width;
+               surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2, 
+                       character, 1, fore.allocated, back.allocated);
+
        } else { // SC_MARK_SHORTARROW
                Point pts[] = {
                        Point(centreX, centreY + dimOn2),
        } else { // SC_MARK_SHORTARROW
                Point pts[] = {
                        Point(centreX, centreY + dimOn2),
index ee0f36c256611437b649a254d80b8d947de8b4f9..b9dd15d06246e865d22bb1c2b4fe3ad75d577b6a 100644 (file)
@@ -20,7 +20,7 @@ public:
                fore = Colour(0,0,0);
                back = Colour(0xff,0xff,0xff);
        }
                fore = Colour(0,0,0);
                back = Colour(0xff,0xff,0xff);
        }
-       void Draw(Surface *surface, PRectangle &rc);
+       void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
 };
 
 #endif
 };
 
 #endif
index 07534db1ef020406ab7185bfc8161defe90d273b..ac5b73d0267e2f474f577890a018cb41ed5fadae 100644 (file)
@@ -30,9 +30,8 @@
  * Modification history:
  *
  * $Log$
  * Modification history:
  *
  * $Log$
- * Revision 1.1  2001/09/01 03:05:24  RD
- * Upgraded to version 1.39 of Scintilla, and upated wxStyledTextCtrl
- * accordingly.
+ * Revision 1.2  2001/10/18 01:24:58  RD
+ * Updated to version 1.40 of Scintilla
  *
  * Revision 1.6  2001/04/29 13:32:10  nyamatongwe
  * Addition of new target methods - versions of ReplaceTarget that take counted
  *
  * Revision 1.6  2001/04/29 13:32:10  nyamatongwe
  * Addition of new target methods - versions of ReplaceTarget that take counted
index 707f59b9f440978ee0ea10dc1dd321d8bf22e40e..75a8ffffa42cf11503dae6f0d46073318e40a421 100644 (file)
@@ -35,6 +35,7 @@
 #include "ScintillaBase.h"
 
 ScintillaBase::ScintillaBase() {
 #include "ScintillaBase.h"
 
 ScintillaBase::ScintillaBase() {
+       displayPopupMenu = true;
        listType = 0;
 #ifdef SCI_LEXER
        lexLanguage = SCLEX_CONTAINER;
        listType = 0;
 #ifdef SCI_LEXER
        lexLanguage = SCLEX_CONTAINER;
@@ -514,6 +515,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
                InvalidateStyleRedraw();
                break;
 
                InvalidateStyleRedraw();
                break;
 
+       case SCI_USEPOPUP:
+               displayPopupMenu = wParam;
+               break;
+
 #ifdef SCI_LEXER
        case SCI_SETLEXER:
                SetLexer(wParam);
 #ifdef SCI_LEXER
        case SCI_SETLEXER:
                SetLexer(wParam);
index d5b1e8ba0ccae8b98666326d2711112cef0917d5..ca4695355fac0eb7261fed7a64c3fb9f700ae74f 100644 (file)
@@ -30,6 +30,7 @@ protected:
                idcmdSelectAll=16
        };
 
                idcmdSelectAll=16
        };
 
+       bool displayPopupMenu;
        Menu popup;
        AutoComplete ac;
 
        Menu popup;
        AutoComplete ac;
 
@@ -42,7 +43,7 @@ protected:
        int lexLanguage;
        LexerModule *lexCurrent;
        PropSet props;
        int lexLanguage;
        LexerModule *lexCurrent;
        PropSet props;
-       enum {numWordLists=5};
+       enum {numWordLists=6};
        WordList *keyWordLists[numWordLists+1];
        void SetLexer(uptr_t wParam);
        void SetLexerLanguage(const char *languageName);
        WordList *keyWordLists[numWordLists+1];
        void SetLexer(uptr_t wParam);
        void SetLexerLanguage(const char *languageName);
diff --git a/contrib/src/stc/scintilla/src/StyleContext.cxx b/contrib/src/stc/scintilla/src/StyleContext.cxx
new file mode 100644 (file)
index 0000000..bdae281
--- /dev/null
@@ -0,0 +1,51 @@
+// Scintilla source code edit control
+/** @file StyleContext.cxx
+ ** Lexer infrastructure.
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// This file is in the public domain.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+
+static void getRange(unsigned int start,
+               unsigned int end,
+               Accessor &styler,
+               char *s,
+               unsigned int len) {
+       unsigned int i = 0;
+       while ((i < end - start + 1) && (i < len-1)) {
+               s[i] = styler[start + i];
+               i++;
+       }
+       s[i] = '\0';
+}
+
+void StyleContext::GetCurrent(char *s, int len) {
+       getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
+}
+
+static void getRangeLowered(unsigned int start,
+               unsigned int end,
+               Accessor &styler,
+               char *s,
+               unsigned int len) {
+       unsigned int i = 0;
+       while ((i < end - start + 1) && (i < len-1)) {
+               s[i] = static_cast<char>(tolower(styler[start + i]));
+               i++;
+       }
+       s[i] = '\0';
+}
+
+void StyleContext::GetCurrentLowered(char *s, int len) {
+       getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
+}
diff --git a/contrib/src/stc/scintilla/src/StyleContext.h b/contrib/src/stc/scintilla/src/StyleContext.h
new file mode 100644 (file)
index 0000000..5bc6371
--- /dev/null
@@ -0,0 +1,127 @@
+// Scintilla source code edit control
+/** @file StyleContext.cxx
+ ** Lexer infrastructure.
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// This file is in the public domain.
+
+// All languages handled so far can treat all characters >= 0x80 as one class
+// which just continues the current token or starts an identifier if in default.
+// DBCS treated specially as the second character can be < 0x80 and hence 
+// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
+class StyleContext {
+       Accessor &styler;
+       int endPos;
+       StyleContext& operator=(const StyleContext&) {
+               return *this;
+       }
+public:
+       int currentPos;
+       bool atLineStart;
+       bool atLineEnd;
+       int state;
+       int chPrev;
+       int ch;
+       int chNext;
+
+       StyleContext(unsigned int startPos, int length,
+                        int initStyle, Accessor &styler_, char chMask=31) : 
+               styler(styler_),
+               endPos(startPos + length),
+               currentPos(startPos), 
+               atLineStart(true),
+               atLineEnd(false),
+               state(initStyle), 
+               chPrev(0),
+               ch(0), 
+               chNext(0) {
+               styler.StartAt(startPos, chMask);
+               styler.StartSegment(startPos);
+               int pos = currentPos;
+               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
+               if (styler.IsLeadByte(static_cast<char>(ch))) {
+                       pos++;
+                       ch = ch << 8;
+                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
+               }
+               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
+               if (styler.IsLeadByte(static_cast<char>(chNext))) {
+                       chNext = chNext << 8;
+                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
+               }
+               atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
+       }
+       void Complete() {
+               styler.ColourTo(currentPos - 1, state);
+       }
+       bool More() {
+               return currentPos <= endPos;
+       }
+       void Forward() {
+               atLineStart = atLineEnd;
+               // A lot of this is repeated from the constructor - TODO: merge code
+               chPrev = ch;
+               currentPos++;
+               if (ch >= 0x100)
+                       currentPos++;
+               ch = chNext;
+               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
+               if (styler.IsLeadByte(static_cast<char>(chNext))) {
+                       chNext = chNext << 8;
+                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+               }
+               // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+               // Avoid triggering two times on Dos/Win
+               // End of line
+               atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
+       }
+       void ChangeState(int state_) {
+               state = state_;
+       }
+       void SetState(int state_) {
+               styler.ColourTo(currentPos - 1, state);
+               state = state_;
+       }
+       void ForwardSetState(int state_) {
+               Forward();
+               styler.ColourTo(currentPos - 1, state);
+               state = state_;
+       }
+       int LengthCurrent() {
+               return currentPos - styler.GetStartSegment();
+       }
+       int GetRelative(int n) {
+               return styler.SafeGetCharAt(currentPos+n);
+       }
+       bool Match(char ch0) {
+               return ch == ch0;
+       }
+       bool Match(char ch0, char ch1) {
+               return (ch == ch0) && (chNext == ch1);
+       }
+       bool Match(const char *s) {
+               if (ch != *s)
+                       return false;
+               s++;
+               if (chNext != *s)
+                       return false;
+               s++;
+               for (int n=2; *s; n++) {
+                       if (*s != styler.SafeGetCharAt(currentPos+n))
+                               return false;
+                       s++;
+               }
+               return true;
+       }
+       // Non-inline
+       void GetCurrent(char *s, int len);
+       void GetCurrentLowered(char *s, int len);
+};
+
+inline bool IsASpace(unsigned int ch) {
+    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
+}
+
+inline bool IsADigit(unsigned int ch) {
+       return (ch >= '0') && (ch <= '9');
+}
index bd6184cf6a33dbb5e7dc11a47f9851cafa7cfc3e..99645adb29333632c863296d4ad08458720271c7 100644 (file)
@@ -32,6 +32,7 @@ int wxForceScintillaLexers(void)
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
+  extern LexerModule lmNncrontab;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
@@ -48,6 +49,7 @@ int wxForceScintillaLexers(void)
      && &lmAVE
      && &lmConf
      && &lmCPP
      && &lmAVE
      && &lmConf
      && &lmCPP
+     && &lmNncrontab
      && &lmEiffel
      && &lmHTML
      && &lmLISP
      && &lmEiffel
      && &lmHTML
      && &lmLISP
@@ -1202,6 +1204,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Replace the target text with the argument text.
 }
 
 // Replace the target text with the argument text.
+// Text is counted so it can contain nulls.
 // Returns the length of the replacement text.
 
                        int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
 // Returns the length of the replacement text.
 
                        int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
@@ -1210,6 +1213,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Replace the target text with the argument text after \d processing.
 }
 
 // Replace the target text with the argument text after \d processing.
+// Text is counted so it can contain nulls.
 // Looks for \d where d is between 1 and 9 and replaces these with the strings
 // matched in the last search operation which were surrounded by \( and \).
 // Returns the length of the replacement text including any change
 // Looks for \d where d is between 1 and 9 and replaces these with the strings
 // matched in the last search operation which were surrounded by \( and \).
 // Returns the length of the replacement text including any change
@@ -1221,7 +1225,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Search for a counted string in the target and set the target to the found
 }
 
 // Search for a counted string in the target and set the target to the found
-// range.
+// range. Text is counted so it can contain nulls.
 // Returns length of range or -1 for failure in which case target is not moved.
 
                        int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
 // Returns length of range or -1 for failure in which case target is not moved.
 
                        int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
index 979bca8794bd0db9ab6ebbd9b1591cd9b71726db..3a415e1f85c3c913358b61e831bfd2bf8e6bc56c 100644 (file)
@@ -32,6 +32,7 @@ int wxForceScintillaLexers(void)
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
+  extern LexerModule lmNncrontab;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
@@ -48,6 +49,7 @@ int wxForceScintillaLexers(void)
      && &lmAVE
      && &lmConf
      && &lmCPP
      && &lmAVE
      && &lmConf
      && &lmCPP
+     && &lmNncrontab
      && &lmEiffel
      && &lmHTML
      && &lmLISP
      && &lmEiffel
      && &lmHTML
      && &lmLISP
index 46dcb91225c191eb964e916697dad8e7c4ae28d9..99553d810b9e2afab6fbbdd7681c88acd4e42904 100644 (file)
@@ -72,6 +72,7 @@
 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
 #define wxSTC_MARK_CIRCLEMINUS 20
 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
 #define wxSTC_MARK_CIRCLEMINUS 20
 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
+#define wxSTC_MARK_CHARACTER 10000
 
 // Markers used for outlining column
 #define wxSTC_MARKNUM_FOLDEREND 25
 
 // Markers used for outlining column
 #define wxSTC_MARKNUM_FOLDEREND 25
 #define wxSTC_MARKNUM_FOLDEROPEN 31
 #define wxSTC_MARGIN_SYMBOL 0
 #define wxSTC_MARGIN_NUMBER 1
 #define wxSTC_MARKNUM_FOLDEROPEN 31
 #define wxSTC_MARGIN_SYMBOL 0
 #define wxSTC_MARGIN_NUMBER 1
+
+// Styles in range 32..37 are predefined for parts of the UI and are not used as normal styles.
+// Styles 38 and 39 are for future use.
 #define wxSTC_STYLE_DEFAULT 32
 #define wxSTC_STYLE_LINENUMBER 33
 #define wxSTC_STYLE_BRACELIGHT 34
 #define wxSTC_STYLE_BRACEBAD 35
 #define wxSTC_STYLE_CONTROLCHAR 36
 #define wxSTC_STYLE_INDENTGUIDE 37
 #define wxSTC_STYLE_DEFAULT 32
 #define wxSTC_STYLE_LINENUMBER 33
 #define wxSTC_STYLE_BRACELIGHT 34
 #define wxSTC_STYLE_BRACEBAD 35
 #define wxSTC_STYLE_CONTROLCHAR 36
 #define wxSTC_STYLE_INDENTGUIDE 37
+#define wxSTC_STYLE_LASTPREDEFINED 39
 #define wxSTC_STYLE_MAX 127
 
 // Character set identifiers are used in StyleSetCharacterSet.
 #define wxSTC_STYLE_MAX 127
 
 // Character set identifiers are used in StyleSetCharacterSet.
 #define wxSTC_LEX_EIFFEL 23
 #define wxSTC_LEX_EIFFELKW 24
 #define wxSTC_LEX_TCL 25
 #define wxSTC_LEX_EIFFEL 23
 #define wxSTC_LEX_EIFFELKW 24
 #define wxSTC_LEX_TCL 25
+#define wxSTC_LEX_NNCRONTAB 26
 
 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 // value assigned in sequence from SCLEX_AUTOMATIC+1.
 
 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 // value assigned in sequence from SCLEX_AUTOMATIC+1.
 #define wxSTC_C_REGEX 14
 #define wxSTC_C_COMMENTLINEDOC 15
 #define wxSTC_C_WORD2 16
 #define wxSTC_C_REGEX 14
 #define wxSTC_C_COMMENTLINEDOC 15
 #define wxSTC_C_WORD2 16
+#define wxSTC_C_COMMENTDOCKEYWORD 17
+#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
 
 // Lexical states for SCLEX_HTML, SCLEX_XML
 #define wxSTC_H_DEFAULT 0
 
 // Lexical states for SCLEX_HTML, SCLEX_XML
 #define wxSTC_H_DEFAULT 0
 #define wxSTC_H_XCCOMMENT 20
 
 // SGML
 #define wxSTC_H_XCCOMMENT 20
 
 // SGML
-#define wxSTC_H_SGML 21
+#define wxSTC_H_SGML_DEFAULT 21
+#define wxSTC_H_SGML_COMMAND 22
+#define wxSTC_H_SGML_1ST_PARAM 23
+#define wxSTC_H_SGML_DOUBLESTRING 24
+#define wxSTC_H_SGML_SIMPLESTRING 25
+#define wxSTC_H_SGML_ERROR 26
+#define wxSTC_H_SGML_SPECIAL 27
+#define wxSTC_H_SGML_ENTITY 28
+#define wxSTC_H_SGML_COMMENT 29
+#define wxSTC_H_SGML_1ST_PARAM_COMMENT 30
+#define wxSTC_H_SGML_BLOCK_DEFAULT 31
 
 // Embedded Javascript
 #define wxSTC_HJ_START 40
 
 // Embedded Javascript
 #define wxSTC_HJ_START 40
 #define wxSTC_EIFFEL_IDENTIFIER 7
 #define wxSTC_EIFFEL_STRINGEOL 8
 
 #define wxSTC_EIFFEL_IDENTIFIER 7
 #define wxSTC_EIFFEL_STRINGEOL 8
 
+// Lexical states for the SCLEX_NNCRONTAB (nnCron crontab Lexer)
+#define wxSTC_NNCRONTAB_DEFAULT 0
+#define wxSTC_NNCRONTAB_COMMENT 1
+#define wxSTC_NNCRONTAB_TASK 2
+#define wxSTC_NNCRONTAB_SECTION 3
+#define wxSTC_NNCRONTAB_KEYWORD 4
+#define wxSTC_NNCRONTAB_MODIFIER 5
+#define wxSTC_NNCRONTAB_ASTERISK 6
+#define wxSTC_NNCRONTAB_NUMBER 7
+#define wxSTC_NNCRONTAB_STRING 8
+#define wxSTC_NNCRONTAB_ENVIRONMENT 9
+#define wxSTC_NNCRONTAB_IDENTIFIER 10
+
 // END of generated section
 //----------------------------------------------------------------------
 // Others
 // END of generated section
 //----------------------------------------------------------------------
 // Others
@@ -1223,10 +1254,12 @@ public:
     int GetTargetEnd();
 
     // Replace the target text with the argument text.
     int GetTargetEnd();
 
     // Replace the target text with the argument text.
+    // Text is counted so it can contain nulls.
     // Returns the length of the replacement text.
     int ReplaceTarget(const wxString& text);
 
     // Replace the target text with the argument text after \d processing.
     // Returns the length of the replacement text.
     int ReplaceTarget(const wxString& text);
 
     // Replace the target text with the argument text after \d processing.
+    // Text is counted so it can contain nulls.
     // Looks for \d where d is between 1 and 9 and replaces these with the strings
     // matched in the last search operation which were surrounded by \( and \).
     // Returns the length of the replacement text including any change
     // Looks for \d where d is between 1 and 9 and replaces these with the strings
     // matched in the last search operation which were surrounded by \( and \).
     // Returns the length of the replacement text including any change
@@ -1234,7 +1267,7 @@ public:
     int ReplaceTargetRE(const wxString& text);
 
     // Search for a counted string in the target and set the target to the found
     int ReplaceTargetRE(const wxString& text);
 
     // Search for a counted string in the target and set the target to the found
-    // range.
+    // range. Text is counted so it can contain nulls.
     // Returns length of range or -1 for failure in which case target is not moved.
     int SearchInTarget(const wxString& text);
 
     // Returns length of range or -1 for failure in which case target is not moved.
     int SearchInTarget(const wxString& text);
 
index 3deb9ba6ba53535539a8e3444a2686457b39f7ba..d6fdd6bc607d3e77741978701866d636add20e80 100644 (file)
@@ -37,6 +37,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
        LexAda.o                \
        LexCPP.o                \
        LexConf.o               \
        LexAda.o                \
        LexCPP.o                \
        LexConf.o               \
+       LexCrontab.o            \
        LexEiffel.o             \
        LexHTML.o               \
        LexLisp.o               \
        LexEiffel.o             \
        LexHTML.o               \
        LexLisp.o               \
@@ -53,6 +54,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
        RESearch.o              \
         ScintillaBase.o                \
         Style.o                        \
        RESearch.o              \
         ScintillaBase.o                \
         Style.o                        \
+       StyleContext.o          \
        UniConversion.o         \
         ViewStyle.o            \
        WindowAccessor.o        \
        UniConversion.o         \
         ViewStyle.o            \
        WindowAccessor.o        \
index 0e7390741484ce8e61b0d2123c91f9db2edc4a95..35a85e67ae30b7596152c2a1caa7a39d26b1c547 100644 (file)
@@ -531,24 +531,20 @@ ListBox::~ListBox() {
 
 void ListBox::Create(Window &parent, int ctrlID) {
     id = new wxSTCListBox(parent.id, ctrlID);
 
 void ListBox::Create(Window &parent, int ctrlID) {
     id = new wxSTCListBox(parent.id, ctrlID);
-//    id = new wxListBox(parent.id, ctrlID,  wxDefaultPosition, wxDefaultSize,
-//                       0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER);
 }
 
 void ListBox::SetVisibleRows(int rows) {
        desiredVisibleRows = rows;
 }
 
 void ListBox::SetVisibleRows(int rows) {
        desiredVisibleRows = rows;
-        printf("SetVisibleRows: %d\n", rows);
 }
 
 PRectangle ListBox::GetDesiredRect() {
     wxSize sz = ((wxListBox*)id)->GetBestSize();
 }
 
 PRectangle ListBox::GetDesiredRect() {
     wxSize sz = ((wxListBox*)id)->GetBestSize();
-    printf("GetDesiredRect: %d, %d\n", sz.x, sz.y);
     PRectangle rc;
     rc.top = 0;
     rc.left = 0;
     if (sz.x > 400)
         sz.x = 400;
     PRectangle rc;
     rc.top = 0;
     rc.left = 0;
     if (sz.x > 400)
         sz.x = 400;
-    if (sz.y > 150)
+    if (sz.y > 150)  // TODO:  Use desiredVisibleRows??
         sz.y = 150;
     rc.right = sz.x;
     rc.bottom = sz.y;
         sz.y = 150;
     rc.right = sz.x;
     rc.bottom = sz.y;
@@ -592,13 +588,7 @@ int ListBox::GetSelection() {
 }
 
 int ListBox::Find(const char *prefix) {
 }
 
 int ListBox::Find(const char *prefix) {
-    if (prefix) {
-        for (int x=0; x < ((wxListBox*)id)->GetCount(); x++) {
-            wxString text = ((wxListBox*)id)->GetString(x);
-            if (text.StartsWith(prefix))
-                return x;
-        }
-    }
+    // No longer used
     return -1;
 }
 
     return -1;
 }
 
index 103ce927962f45cb8b23b8421579be49116221ea..d5f2648dd163791a3b8e33dac2b215a5ead9448f 100644 (file)
@@ -122,9 +122,10 @@ void ScintillaWX::Finalise() {
 
 void ScintillaWX::StartDrag() {
     wxDropSource        source(wMain.GetID());
 
 void ScintillaWX::StartDrag() {
     wxDropSource        source(wMain.GetID());
-    wxTextDataObject    data(dragChars);
+    wxTextDataObject    data(wxString(drag.s, drag.len));
     wxDragResult        result;
 
     wxDragResult        result;
 
+    dropWentOutside = true;
     source.SetData(data);
     result = source.DoDragDrop(TRUE);
     if (result == wxDragMove && dropWentOutside)
     source.SetData(data);
     result = source.DoDragDrop(TRUE);
     if (result == wxDragMove && dropWentOutside)
@@ -217,9 +218,10 @@ void ScintillaWX::NotifyParent(SCNotification scn) {
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
-        char* text = CopySelectionRange();
+        SelectionText st;
+        CopySelectionRange(&st);
         wxTheClipboard->Open();
         wxTheClipboard->Open();
-        wxTheClipboard->SetData(new wxTextDataObject(text));
+        wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len)));
         wxTheClipboard->Close();
     }
 }
         wxTheClipboard->Close();
     }
 }
@@ -494,14 +496,15 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
 
 
 wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
 
 
 wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
-    return def;
+    dragResult = def;
+    return dragResult;
 }
 
 
 wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
     SetDragPosition(PositionFromLocation(Point(x, y)));
     dragResult = def;
 }
 
 
 wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
     SetDragPosition(PositionFromLocation(Point(x, y)));
     dragResult = def;
-    return def;
+    return dragResult;
 }
 
 
 }
 
 
index 492b4e26dfeadca9546bc022a6645ae7737b4fc8..7a74f314afdf214f63d43e95dd14e40c672ee1f1 100644 (file)
@@ -22,36 +22,45 @@ STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
 
 OBJECTS = \
 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
 
 OBJECTS = \
-    AutoComplete.obj        \
-    CallTip.obj             \
-    CellBuffer.obj          \
-    ContractionState.obj    \
-    Document.obj            \
-    DocumentAccessor.obj    \
-    Editor.obj              \
-    Indicator.obj           \
-    KeyMap.obj              \
-    KeyWords.obj            \
-    LexCPP.obj              \
-    LexHTML.obj             \
-    LexLua.obj              \
-    LexOthers.obj           \
-    LexPerl.obj             \
-    LexPython.obj           \
-    LexSQL.obj              \
-    LexVB.obj               \
-    LineMarker.obj          \
-    PosRegExp.obj           \
-    PropSet.obj             \
-    ScintillaBase.obj       \
-    Style.obj               \
-    UniConversion.obj       \
-    ViewStyle.obj           \
-    WindowAccessor.obj      \
-                            \
-    PlatWX.obj              \
-    ScintillaWX.obj         \
-    stc.obj                 \
+        AutoComplete.obj       \
+        CallTip.obj            \
+        CellBuffer.obj         \
+        ContractionState.obj   \
+        Document.obj           \
+       DocumentAccessor.obj    \
+        Editor.obj             \
+        Indicator.obj          \
+        KeyMap.obj             \
+        KeyWords.obj           \
+       LexAVE.obj              \
+       LexAda.obj              \
+       LexCPP.obj              \
+       LexConf.obj             \
+       LexCrontab.obj          \
+       LexEiffel.obj           \
+       LexHTML.obj             \
+       LexLisp.obj             \
+       LexLua.obj              \
+       LexOthers.obj           \
+       LexPascal.obj           \
+       LexPerl.obj             \
+       LexPython.obj           \
+       LexRuby.obj             \
+       LexSQL.obj              \
+       LexVB.obj               \
+        LineMarker.obj         \
+        PropSet.obj            \
+       RESearch.obj            \
+        ScintillaBase.obj      \
+        Style.obj              \
+       StyleContext.obj        \
+       UniConversion.obj       \
+        ViewStyle.obj          \
+       WindowAccessor.obj      \
+                               \
+       PlatWX.obj              \
+       ScintillaWX.obj         \
+       stc.obj                 \
 
 
 !include $(WXDIR)\src\makelib.b32
 
 
 !include $(WXDIR)\src\makelib.b32
index ea3cbd9c0ccf58b36bf12e6f6031683020c7d87b..cf708ed801b8ddbb1a51f0b2cadb7cf4492fa72b 100644 (file)
@@ -10,32 +10,42 @@ S=$(SCINTILLA)/src
 EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
 
 OBJECTS = \
 EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
 
 OBJECTS = \
-       $(S)/AutoComplete.$(OBJSUFF) \
-       $(S)/CallTip.$(OBJSUFF) \
-       $(S)/CellBuffer.$(OBJSUFF) \
-       $(S)/ContractionState.$(OBJSUFF)\
-       $(S)/Document.$(OBJSUFF) \
-       $(S)/Editor.$(OBJSUFF) \
-       $(S)/Indicator.$(OBJSUFF) \
-       $(S)/KeyMap.$(OBJSUFF) \
-       $(S)/KeyWords.$(OBJSUFF) \
-       $(S)/LineMarker.$(OBJSUFF) \
-       $(S)/PropSet.$(OBJSUFF) \
-       $(S)/ScintillaBase.$(OBJSUFF) \
-       $(S)/Style.$(OBJSUFF) \
-       $(S)/ViewStyle.$(OBJSUFF) \
-       $(S)/LexCPP.$(OBJSUFF)  \
-       $(S)/LexHTML.$(OBJSUFF) \
-       $(S)/LexLua.$(OBJSUFF) \
-       $(S)/LexOthers.$(OBJSUFF) \
-       $(S)/LexPerl.$(OBJSUFF) \
-       $(S)/LexPython.$(OBJSUFF) \
-       $(S)/LexSQL.$(OBJSUFF)  \
-       $(S)/LexVB.$(OBJSUFF)   \
-       $(S)/DocumentAccessor.$(OBJSUFF)\
+        $(S)/AutoComplete.$(OBJSUFF)   \
+        $(S)/CallTip.$(OBJSUFF)                \
+        $(S)/CellBuffer.$(OBJSUFF)     \
+        $(S)/ContractionState.$(OBJSUFF) \
+        $(S)/Document.$(OBJSUFF)       \
+       $(S)/DocumentAccessor.$(OBJSUFF) \
+        $(S)/Editor.$(OBJSUFF)         \
+        $(S)/Indicator.$(OBJSUFF)      \
+        $(S)/KeyMap.$(OBJSUFF)         \
+        $(S)/KeyWords.$(OBJSUFF)       \
+       $(S)/LexAVE.$(OBJSUFF)          \
+       $(S)/LexAda.$(OBJSUFF)          \
+       $(S)/LexCPP.$(OBJSUFF)          \
+       $(S)/LexConf.$(OBJSUFF)         \
+       $(S)/LexCrontab.$(OBJSUFF)      \
+       $(S)/LexEiffel.$(OBJSUFF)       \
+       $(S)/LexHTML.$(OBJSUFF)         \
+       $(S)/LexLisp.$(OBJSUFF)         \
+       $(S)/LexLua.$(OBJSUFF)          \
+       $(S)/LexOthers.$(OBJSUFF)       \
+       $(S)/LexPascal.$(OBJSUFF)       \
+       $(S)/LexPerl.$(OBJSUFF)         \
+       $(S)/LexPython.$(OBJSUFF)       \
+       $(S)/LexRuby.$(OBJSUFF)         \
+       $(S)/LexSQL.$(OBJSUFF)          \
+       $(S)/LexVB.$(OBJSUFF)           \
+        $(S)/LineMarker.$(OBJSUFF)     \
+        $(S)/PropSet.$(OBJSUFF)                \
+       $(S)/RESearch.$(OBJSUFF)        \
+        $(S)/ScintillaBase.$(OBJSUFF)  \
+        $(S)/Style.$(OBJSUFF)          \
+       $(S)/StyleContext.$(OBJSUFF)    \
        $(S)/UniConversion.$(OBJSUFF)   \
        $(S)/UniConversion.$(OBJSUFF)   \
+        $(S)/ViewStyle.$(OBJSUFF)      \
        $(S)/WindowAccessor.$(OBJSUFF)  \
        $(S)/WindowAccessor.$(OBJSUFF)  \
-       $(S)/PosRegExp.$(OBJSUFF) \
+       \
        PlatWX.$(OBJSUFF) \
        ScintillaWX.$(OBJSUFF) \
        stc.$(OBJSUFF)
        PlatWX.$(OBJSUFF) \
        ScintillaWX.$(OBJSUFF) \
        stc.$(OBJSUFF)
index fa0f4a7e77471f6ed7f70d5ee1bd2fe7d436377c..9c6d478b878317c07aa30aa96e4abf57ae82b343 100644 (file)
@@ -15,40 +15,41 @@ NOPCH=1
 !include $(WXDIR)\src\makevc.env
 
 OBJECTS = \
 !include $(WXDIR)\src\makevc.env
 
 OBJECTS = \
-       $(D)\AutoComplete.obj   \
-       $(D)\CallTip.obj        \
-       $(D)\CellBuffer.obj     \
-       $(D)\ContractionState.obj\
-       $(D)\Document.obj       \
-       $(D)\DocumentAccessor.obj\
-       $(D)\Editor.obj         \
-       $(D)\Indicator.obj      \
-       $(D)\KeyMap.obj         \
-       $(D)\KeyWords.obj       \
-       $(D)\LineMarker.obj     \
-       $(D)\PropSet.obj        \
-       $(D)\RESearch.obj       \
-       $(D)\ScintillaBase.obj  \
-       $(D)\Style.obj          \
-       $(D)\UniConversion.obj  \
-       $(D)\ViewStyle.obj      \
-       $(D)\WindowAccessor.obj \
-                               \
-       $(D)\LexAda.obj         \
-       $(D)\LexAVE.obj         \
-       $(D)\LexConf.obj        \
-       $(D)\LexCPP.obj         \
-       $(D)\LexEiffel.obj      \
-       $(D)\LexHTML.obj        \
-       $(D)\LexLisp.obj        \
-       $(D)\LexLua.obj         \
-       $(D)\LexOthers.obj      \
-       $(D)\LexPascal.obj      \
-       $(D)\LexPerl.obj        \
-       $(D)\LexPython.obj      \
-       $(D)\LexRuby.obj        \
-       $(D)\LexSQL.obj         \
-       $(D)\LexVB.obj          \
+        $(D)\AutoComplete.obj          \
+        $(D)\CallTip.obj               \
+        $(D)\CellBuffer.obj            \
+        $(D)\ContractionState.obj      \
+        $(D)\Document.obj              \
+       $(D)\DocumentAccessor.obj       \
+        $(D)\Editor.obj                        \
+        $(D)\Indicator.obj             \
+        $(D)\KeyMap.obj                        \
+        $(D)\KeyWords.obj              \
+       $(D)\LexAVE.obj                 \
+       $(D)\LexAda.obj                 \
+       $(D)\LexCPP.obj                 \
+       $(D)\LexConf.obj                \
+       $(D)\LexCrontab.obj             \
+       $(D)\LexEiffel.obj              \
+       $(D)\LexHTML.obj                \
+       $(D)\LexLisp.obj                \
+       $(D)\LexLua.obj                 \
+       $(D)\LexOthers.obj              \
+       $(D)\LexPascal.obj              \
+       $(D)\LexPerl.obj                \
+       $(D)\LexPython.obj              \
+       $(D)\LexRuby.obj                \
+       $(D)\LexSQL.obj                 \
+       $(D)\LexVB.obj                  \
+        $(D)\LineMarker.obj            \
+        $(D)\PropSet.obj               \
+       $(D)\RESearch.obj               \
+        $(D)\ScintillaBase.obj         \
+        $(D)\Style.obj                 \
+       $(D)\StyleContext.obj           \
+       $(D)\UniConversion.obj          \
+        $(D)\ViewStyle.obj             \
+       $(D)\WindowAccessor.obj         \
                                \
        $(D)\PlatWX.obj         \
        $(D)\ScintillaWX.obj    \
                                \
        $(D)\PlatWX.obj         \
        $(D)\ScintillaWX.obj    \
index 598da70f58b7750830d6a3857bfd8e80903418f9..98c4018245daeece4d84dea59b1f5d5876cd94d5 100644 (file)
@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
 distribution.  All other code needed to implement Scintilla on top of
 wxWindows is located in the directory above this one.
 
 distribution.  All other code needed to implement Scintilla on top of
 wxWindows is located in the directory above this one.
 
-The current version of the Scintilla code is 1.39
+The current version of the Scintilla code is 1.40
 
 
index 591bd06aa1a4a6a8bbd4765d3da8aa34af146cc3..680cb1513855d47b6221908c7f717ba3cca2a7b5 100644 (file)
@@ -40,6 +40,7 @@
 #define SCLEX_EIFFEL 23
 #define SCLEX_EIFFELKW 24
 #define SCLEX_TCL 25
 #define SCLEX_EIFFEL 23
 #define SCLEX_EIFFELKW 24
 #define SCLEX_TCL 25
+#define SCLEX_NNCRONTAB 26
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -72,6 +73,8 @@
 #define SCE_C_REGEX 14
 #define SCE_C_COMMENTLINEDOC 15
 #define SCE_C_WORD2 16
 #define SCE_C_REGEX 14
 #define SCE_C_COMMENTLINEDOC 15
 #define SCE_C_WORD2 16
+#define SCE_C_COMMENTDOCKEYWORD 17
+#define SCE_C_COMMENTDOCKEYWORDERROR 18
 #define SCE_H_DEFAULT 0
 #define SCE_H_TAG 1
 #define SCE_H_TAGUNKNOWN 2
 #define SCE_H_DEFAULT 0
 #define SCE_H_TAG 1
 #define SCE_H_TAGUNKNOWN 2
 #define SCE_H_QUESTION 18
 #define SCE_H_VALUE 19
 #define SCE_H_XCCOMMENT 20
 #define SCE_H_QUESTION 18
 #define SCE_H_VALUE 19
 #define SCE_H_XCCOMMENT 20
-#define SCE_H_SGML 21
+#define SCE_H_SGML_DEFAULT 21
+#define SCE_H_SGML_COMMAND 22
+#define SCE_H_SGML_1ST_PARAM 23
+#define SCE_H_SGML_DOUBLESTRING 24
+#define SCE_H_SGML_SIMPLESTRING 25
+#define SCE_H_SGML_ERROR 26
+#define SCE_H_SGML_SPECIAL 27
+#define SCE_H_SGML_ENTITY 28
+#define SCE_H_SGML_COMMENT 29
+#define SCE_H_SGML_1ST_PARAM_COMMENT 30
+#define SCE_H_SGML_BLOCK_DEFAULT 31
 #define SCE_HJ_START 40
 #define SCE_HJ_DEFAULT 41
 #define SCE_HJ_COMMENT 42
 #define SCE_HJ_START 40
 #define SCE_HJ_DEFAULT 41
 #define SCE_HJ_COMMENT 42
 #define SCE_EIFFEL_OPERATOR 6
 #define SCE_EIFFEL_IDENTIFIER 7
 #define SCE_EIFFEL_STRINGEOL 8
 #define SCE_EIFFEL_OPERATOR 6
 #define SCE_EIFFEL_IDENTIFIER 7
 #define SCE_EIFFEL_STRINGEOL 8
+#define SCE_NNCRONTAB_DEFAULT 0
+#define SCE_NNCRONTAB_COMMENT 1
+#define SCE_NNCRONTAB_TASK 2
+#define SCE_NNCRONTAB_SECTION 3
+#define SCE_NNCRONTAB_KEYWORD 4
+#define SCE_NNCRONTAB_MODIFIER 5
+#define SCE_NNCRONTAB_ASTERISK 6
+#define SCE_NNCRONTAB_NUMBER 7
+#define SCE_NNCRONTAB_STRING 8
+#define SCE_NNCRONTAB_ENVIRONMENT 9
+#define SCE_NNCRONTAB_IDENTIFIER 10
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #endif
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #endif
index 0185d3e5be6cac69c7b19f8e888bba79cc4235b0..abe1581a49c018373e9c7c1a148e0e942193aba0 100644 (file)
@@ -11,9 +11,6 @@
 #ifndef SCINTILLA_H
 #define SCINTILLA_H
 
 #ifndef SCINTILLA_H
 #define SCINTILLA_H
 
-// Compile-time configuration options
-#define MACRO_SUPPORT 1  // Comment out to remove macro hooks
-
 #if PLAT_WIN
 #ifdef STATIC_BUILD
 void Scintilla_RegisterClasses(HINSTANCE hInstance);
 #if PLAT_WIN
 #ifdef STATIC_BUILD
 void Scintilla_RegisterClasses(HINSTANCE hInstance);
@@ -102,6 +99,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SC_MARK_CIRCLEPLUSCONNECTED 19
 #define SC_MARK_CIRCLEMINUS 20
 #define SC_MARK_CIRCLEMINUSCONNECTED 21
 #define SC_MARK_CIRCLEPLUSCONNECTED 19
 #define SC_MARK_CIRCLEMINUS 20
 #define SC_MARK_CIRCLEMINUSCONNECTED 21
+#define SC_MARK_CHARACTER 10000
 #define SC_MARKNUM_FOLDEREND 25
 #define SC_MARKNUM_FOLDEROPENMID 26
 #define SC_MARKNUM_FOLDERMIDTAIL 27
 #define SC_MARKNUM_FOLDEREND 25
 #define SC_MARKNUM_FOLDEROPENMID 26
 #define SC_MARKNUM_FOLDERMIDTAIL 27
@@ -134,6 +132,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define STYLE_BRACEBAD 35
 #define STYLE_CONTROLCHAR 36
 #define STYLE_INDENTGUIDE 37
 #define STYLE_BRACEBAD 35
 #define STYLE_CONTROLCHAR 36
 #define STYLE_INDENTGUIDE 37
+#define STYLE_LASTPREDEFINED 39
 #define STYLE_MAX 127
 #define SC_CHARSET_ANSI 0
 #define SC_CHARSET_DEFAULT 1
 #define STYLE_MAX 127
 #define SC_CHARSET_ANSI 0
 #define SC_CHARSET_DEFAULT 1
@@ -507,12 +506,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCN_DWELLEND 2017
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 #define SCN_DWELLEND 2017
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
-// Optional module for macro recording
-#ifdef MACRO_SUPPORT
-typedef void (tMacroRecorder)(unsigned int iMessage, unsigned long wParam, 
-       long lParam, void *userData);
-#endif
-
 // These structures are defined to be exactly the same shape as the Win32
 // CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
 // So older code that treats Scintilla as a RichEdit will work.
 // These structures are defined to be exactly the same shape as the Win32
 // CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
 // So older code that treats Scintilla as a RichEdit will work.
@@ -566,11 +559,9 @@ struct SCNotification {
        const char *text;       // SCN_MODIFIED
        int length;             // SCN_MODIFIED
        int linesAdded; // SCN_MODIFIED
        const char *text;       // SCN_MODIFIED
        int length;             // SCN_MODIFIED
        int linesAdded; // SCN_MODIFIED
-#ifdef MACRO_SUPPORT
        int message;    // SCN_MACRORECORD
        uptr_t wParam;  // SCN_MACRORECORD
        int message;    // SCN_MACRORECORD
        uptr_t wParam;  // SCN_MACRORECORD
-       sptr_t lParam;          // SCN_MACRORECORD
-#endif
+       sptr_t lParam;  // SCN_MACRORECORD
        int line;               // SCN_MODIFIED
        int foldLevelNow;       // SCN_MODIFIED
        int foldLevelPrev;      // SCN_MODIFIED
        int line;               // SCN_MODIFIED
        int foldLevelNow;       // SCN_MODIFIED
        int foldLevelPrev;      // SCN_MODIFIED
index 90360076fa5f48bd032cd19ed705ef3b50ca48b2..7724efdb00180d95b9e04c16859135aaee82fd7c 100644 (file)
@@ -229,6 +229,8 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
 val SC_MARK_CIRCLEMINUS=20
 val SC_MARK_CIRCLEMINUSCONNECTED=21
 
 val SC_MARK_CIRCLEMINUS=20
 val SC_MARK_CIRCLEMINUSCONNECTED=21
 
+val SC_MARK_CHARACTER=10000
+
 # Markers used for outlining column
 val SC_MARKNUM_FOLDEREND=25
 val SC_MARKNUM_FOLDEROPENMID=26
 # Markers used for outlining column
 val SC_MARKNUM_FOLDEREND=25
 val SC_MARKNUM_FOLDEROPENMID=26
@@ -292,12 +294,15 @@ set void SetMarginSensitiveN=2246(int margin, bool sensitive)
 # Retrieve the mouse click sensitivity of a margin.
 get bool GetMarginSensitiveN=2247(int margin,)
 
 # Retrieve the mouse click sensitivity of a margin.
 get bool GetMarginSensitiveN=2247(int margin,)
 
+# Styles in range 32..37 are predefined for parts of the UI and are not used as normal styles.
+# Styles 38 and 39 are for future use.
 val STYLE_DEFAULT=32
 val STYLE_LINENUMBER=33
 val STYLE_BRACELIGHT=34
 val STYLE_BRACEBAD=35
 val STYLE_CONTROLCHAR=36
 val STYLE_INDENTGUIDE=37
 val STYLE_DEFAULT=32
 val STYLE_LINENUMBER=33
 val STYLE_BRACELIGHT=34
 val STYLE_BRACEBAD=35
 val STYLE_CONTROLCHAR=36
 val STYLE_INDENTGUIDE=37
+val STYLE_LASTPREDEFINED=39
 val STYLE_MAX=127
 
 # Character set identifiers are used in StyleSetCharacterSet.
 val STYLE_MAX=127
 
 # Character set identifiers are used in StyleSetCharacterSet.
@@ -759,10 +764,12 @@ set void SetTargetEnd=2192(position pos,)
 get position GetTargetEnd=2193(,)
 
 # Replace the target text with the argument text.
 get position GetTargetEnd=2193(,)
 
 # Replace the target text with the argument text.
+# Text is counted so it can contain nulls.
 # Returns the length of the replacement text.
 fun int ReplaceTarget=2194(int length, string text)
 
 # Replace the target text with the argument text after \d processing.
 # Returns the length of the replacement text.
 fun int ReplaceTarget=2194(int length, string text)
 
 # Replace the target text with the argument text after \d processing.
+# Text is counted so it can contain nulls.
 # Looks for \d where d is between 1 and 9 and replaces these with the strings
 # matched in the last search operation which were surrounded by \( and \).
 # Returns the length of the replacement text including any change
 # Looks for \d where d is between 1 and 9 and replaces these with the strings
 # matched in the last search operation which were surrounded by \( and \).
 # Returns the length of the replacement text including any change
@@ -770,7 +777,7 @@ fun int ReplaceTarget=2194(int length, string text)
 fun int ReplaceTargetRE=2195(int length, string text)
 
 # Search for a counted string in the target and set the target to the found
 fun int ReplaceTargetRE=2195(int length, string text)
 
 # Search for a counted string in the target and set the target to the found
-# range.
+# range. Text is counted so it can contain nulls.
 # Returns length of range or -1 for failure in which case target is not moved.
 fun int SearchInTarget=2197(int length, string text)
 
 # Returns length of range or -1 for failure in which case target is not moved.
 fun int SearchInTarget=2197(int length, string text)
 
@@ -1265,6 +1272,7 @@ val SCLEX_RUBY=22
 val SCLEX_EIFFEL=23
 val SCLEX_EIFFELKW=24
 val SCLEX_TCL=25
 val SCLEX_EIFFEL=23
 val SCLEX_EIFFELKW=24
 val SCLEX_TCL=25
+val SCLEX_NNCRONTAB=26
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
 val SCLEX_AUTOMATIC=1000
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
 val SCLEX_AUTOMATIC=1000
@@ -1301,6 +1309,8 @@ val SCE_C_VERBATIM=13
 val SCE_C_REGEX=14
 val SCE_C_COMMENTLINEDOC=15
 val SCE_C_WORD2=16
 val SCE_C_REGEX=14
 val SCE_C_COMMENTLINEDOC=15
 val SCE_C_WORD2=16
+val SCE_C_COMMENTDOCKEYWORD=17
+val SCE_C_COMMENTDOCKEYWORDERROR=18
 # Lexical states for SCLEX_HTML, SCLEX_XML
 val SCE_H_DEFAULT=0
 val SCE_H_TAG=1
 # Lexical states for SCLEX_HTML, SCLEX_XML
 val SCE_H_DEFAULT=0
 val SCE_H_TAG=1
@@ -1327,7 +1337,17 @@ val SCE_H_VALUE=19
 # X-Code
 val SCE_H_XCCOMMENT=20
 # SGML
 # X-Code
 val SCE_H_XCCOMMENT=20
 # SGML
-val SCE_H_SGML=21
+val SCE_H_SGML_DEFAULT=21
+val SCE_H_SGML_COMMAND=22
+val SCE_H_SGML_1ST_PARAM=23
+val SCE_H_SGML_DOUBLESTRING=24
+val SCE_H_SGML_SIMPLESTRING=25
+val SCE_H_SGML_ERROR=26
+val SCE_H_SGML_SPECIAL=27
+val SCE_H_SGML_ENTITY=28
+val SCE_H_SGML_COMMENT=29
+val SCE_H_SGML_1ST_PARAM_COMMENT=30
+val SCE_H_SGML_BLOCK_DEFAULT=31
 # Embedded Javascript
 val SCE_HJ_START=40
 val SCE_HJ_DEFAULT=41
 # Embedded Javascript
 val SCE_HJ_START=40
 val SCE_HJ_DEFAULT=41
@@ -1547,6 +1567,18 @@ val SCE_EIFFEL_CHARACTER=5
 val SCE_EIFFEL_OPERATOR=6
 val SCE_EIFFEL_IDENTIFIER=7
 val SCE_EIFFEL_STRINGEOL=8
 val SCE_EIFFEL_OPERATOR=6
 val SCE_EIFFEL_IDENTIFIER=7
 val SCE_EIFFEL_STRINGEOL=8
+# Lexical states for the SCLEX_NNCRONTAB (nnCron crontab Lexer)
+val SCE_NNCRONTAB_DEFAULT=0
+val SCE_NNCRONTAB_COMMENT=1
+val SCE_NNCRONTAB_TASK=2
+val SCE_NNCRONTAB_SECTION=3
+val SCE_NNCRONTAB_KEYWORD=4
+val SCE_NNCRONTAB_MODIFIER=5
+val SCE_NNCRONTAB_ASTERISK=6
+val SCE_NNCRONTAB_NUMBER=7
+val SCE_NNCRONTAB_STRING=8
+val SCE_NNCRONTAB_ENVIRONMENT=9
+val SCE_NNCRONTAB_IDENTIFIER=10
 
 # Events
 
 
 # Events
 
@@ -1574,171 +1606,3 @@ evt void DwellStart=2016(int position)
 evt void DwellEnd=2017(int position)
 
 cat Deprecated
 evt void DwellEnd=2017(int position)
 
 cat Deprecated
-
-val SCFIND_DOWN=1
-
-################################################
-# From WinDefs.h
-
-# ***** DEPRECATED from here to end of file ******
-
-# Will a paste succeed?
-fun bool EM_CanPaste=1074(,)
-
-# Are there any undoable actions in the undo history.
-fun bool EM_CanUndo=198(,)
-
-# Find the position and line from a point within the window.
-fun int EM_CharFromPos=215(,point pt)
-
-# Delete the undo history.
-fun void EM_EmptyUndoBuffer=205(,)
-
-# Retrieve the selection range.
-fun void EM_ExGetSel=1076(,charrangeresult cr)
-
-# Retrieve the line number of a position in the document.
-get int EM_ExLineFromChar=1078(,position pos)
-
-# Select a range of text.
-fun void EM_ExSetSel=1079(,charrange cr)
-
-# Find some text in the document.
-fun position EM_FindText=1080(int flags, findtext ft)
-
-# Find some text in the document. Returns range of found text in ft argument.
-fun position EM_FindTextEx=1103(int flags, findtextex ft)
-
-# On Windows will draw the document into a display context such as a printer.
-fun void EM_FormatRange=1081(bool draw, formatrange fr)
-
-# Retrieve the line at the top of the display.
-get int EM_GetFirstVisibleLine=206(,)
-
-# Retrieve the contents of a line.
-# Returns the length of the line.
-fun int EM_GetLine=196(int line, countedstring text)
-
-# Returns the number of lines in the document. There is always at least one.
-fun int EM_GetLineCount=186(,)
-
-# Returns the size in pixels of left and right margins packed into one integer.
-# The left margin is in the low half and the right margin in the high half.
-fun int EM_GetMargins=212(,)
-
-# Is the document different from when it was last saved?
-get bool EM_GetModify=184(,)
-
-# Get the area used to display the document.
-fun void EM_GetRect=178(,rectangle r)
-
-# Return the selection packed into one integer with the start of the selection
-# in the low half and the end in the high half.
-fun int EM_GetSel=176(,)
-
-# Retrieve the selected text.
-# Return the length of the text.
-fun int EM_GetSelText=1086(,stringresult text)
-
-# Retrieve a range of text.
-# Return the length of the text.
-fun int EM_GetTextRange=1099(, textrange tr)
-
-# Draw the selection in normal style or with selection highlighted.
-fun void EM_HideSelection=1087(bool normal,)
-
-# Retrieve the line of a position.
-fun int EM_LineFromChar=201(position pos,)
-
-# Retrieve the position at the start of a line.
-fun position EM_LineIndex=187(int line,)
-
-# Retrieve the number of characters on a line not including end of line characters.
-fun int EM_LineLength=193(int line,)
-
-# Scroll horizontally and vertically.
-fun void EM_LineScroll=182(int columns, int lines)
-
-# Retrieve the point in the window where a position is displayed.
-fun void EM_PosFromChar=214(pointresult pt, position pos)
-
-# Replace the selected text with the argument text.
-fun void EM_ReplaceSel=194(, string text)
-
-# Ensure the caret is visible.
-fun void EM_ScrollCaret=183(,)
-
-# Returns SEL_EMPTY if selection contains no characters, otherwise SEL_TEXT.
-fun void EM_SelectionType=1090(,)
-
-# Set the width of the left and right margins
-fun void EM_SetMargins=211(int flags, int values)
-
-# Set to read only or read write.
-set void EM_SetReadOnly=207(bool readOnly,)
-
-# Select the range of text from start to end.
-fun void EM_SetSel=177(position start, position end)
-
-# Undo one action in the undo history.
-fun void EM_Undo=199(,)
-
-# Null operation.
-fun void WM_Null=0(,)
-
-# Clear the selection.
-fun void WM_Clear=771(,)
-
-fun void WM_Command=273(,)
-
-# Copy the selection to the clipboard.
-fun void WM_Copy=769(,)
-
-# Cut the selection to the clipboard.
-fun void WM_Cut=768(,)
-
-# Retrieve all the text in the document.
-# Returns number of characters retrieved.
-fun int WM_GetText=13(int length, stringresult text)
-
-# Retrieve the number of characters in the document.
-fun int WM_GetTextLength=14(,)
-
-# Notification back to container
-fun void WM_Notify=78(int id, int stuff)
-
-# Paste the contents of the clipboard into the document replacing the selection.
-fun void WM_Paste=770(,)
-
-# Replace the contents of the document with the argument text.
-fun void WM_SetText=12(, string text)
-
-# Undo one action in the undo history.
-fun void WM_Undo=772(,)
-
-# Notification codes
-val EN_CHANGE=768
-val EN_KILLFOCUS=512
-val EN_SETFOCUS=256
-
-# Flags for setting margins.
-val EC_LEFTMARGIN=1
-val EC_RIGHTMARGIN=2
-val EC_USEFONTINFO=0xffff
-
-# Selection type.
-val SEL_EMPTY=0
-val SEL_TEXT=1
-
-# Find replace mask constants
-val FR_MATCHCASE=0x4
-val FR_WHOLEWORD=0x2
-val FR_DOWN=0x1
-
-# Key modifier flag.
-val SHIFT_PRESSED=1
-val LEFT_CTRL_PRESSED=2
-val LEFT_ALT_PRESSED=4
-
-#events
-evt void EN_Change=768(void)
index f6c2fc3542c343af2c1cd05622063e6c6da084d3..6e22f58f8b6b3b19427950d43a7bd2a2cf036582 100644 (file)
 
 #if PLAT_GTK
 
 
 #if PLAT_GTK
 
-#ifndef SCINTILLA_H
-#ifdef _MSC_VER
-#pragma message(__FILE__ "(1) : warning : Scintilla.h should be included before ScintillaWidget.h")
-#pragma message("This will be required in the next version of Scintilla")
-#else
-#warning Scintilla.h should be included before ScintillaWidget.h
-#warning This will be required in the next version of Scintilla
-#endif
-#include "Scintilla.h"
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/stc/scintilla/include/WinDefs.h b/src/stc/scintilla/include/WinDefs.h
deleted file mode 100644 (file)
index b3421c0..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-// Scintilla source code edit control
-/** @file WinDefs.h
- ** The subset of definitions from Windows needed by Scintilla for GTK+.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef WINDEFS_H
-#define WINDEFS_H
-
-/* Running GTK version on win32 */
-#if PLAT_GTK_WIN32
-#include "Windows.h"
-#include "Richedit.h"
-
-/* Name conflicts */
-#undef DrawText
-#undef FindText
-#else
-
-#define WORD short
-#define WPARAM unsigned long
-#define LPARAM long
-#define LRESULT long
-#define DWORD long
-
-#define UINT unsigned int
-#define LPSTR char *
-#define LONG long
-
-//#if 0
-/* RTF control */
-#define EM_CANPASTE    (1074)
-#define EM_CANUNDO     (198)
-#define EM_CHARFROMPOS (215)
-#define EM_EMPTYUNDOBUFFER     (205)
-#define EM_EXGETSEL    (1076)
-#define EM_EXLINEFROMCHAR      (1078)
-#define EM_EXSETSEL    (1079)
-#define EM_FINDTEXT    (1080)
-#define EM_FINDTEXTEX  (1103)
-#define EM_FORMATRANGE (1081)
-#define EM_GETFIRSTVISIBLELINE (206)
-#define EM_GETLINE     (196)
-#define EM_GETLINECOUNT        (186)
-#define EM_GETMARGINS  (212)
-#define EM_GETMODIFY   (184)
-#define EM_GETRECT     (178)
-#define EM_GETSEL      (176)
-#define EM_GETSELTEXT  (1086)
-#define EM_GETTEXTRANGE        (1099)
-#define EM_HIDESELECTION       (1087)
-#define EM_LINEFROMCHAR        (201)
-#define EM_LINEINDEX   (187)
-#define EM_LINELENGTH  (193)
-#define EM_LINESCROLL  (182)
-#define EM_POSFROMCHAR (214)
-#define EM_REPLACESEL  (194)
-#define EM_SCROLLCARET (183)
-#define EM_SELECTIONTYPE       (1090)
-#define EM_SETMARGINS  (211)
-#define EM_SETREADONLY (207)
-#define EM_SETSEL      (177)
-#define EM_UNDO        (199)
-
-#define WM_NULL                (0)
-#define WM_CLEAR       (771)
-#define WM_COPY        (769)
-#define WM_CUT (768)
-#define WM_GETTEXT     (13)
-#define WM_GETTEXTLENGTH       (14)
-#define WM_PASTE       (770)
-#define WM_SETTEXT     (12)
-#define WM_UNDO        (772)
-
-#define EN_CHANGE      (768)
-#define EN_KILLFOCUS (512)
-#define EN_SETFOCUS (256)
-
-#define EC_LEFTMARGIN 1
-#define EC_RIGHTMARGIN 2
-#define EC_USEFONTINFO 0xffff
-
-//#endif
-
-#if 0
-#if PLAT_GTK
-#define VK_DOWN GDK_Down
-#define VK_UP GDK_Up
-#define VK_LEFT GDK_Left
-#define VK_RIGHT GDK_Right
-#define VK_HOME GDK_Home
-#define VK_END GDK_End
-#define VK_PRIOR GDK_Page_Up
-#define VK_NEXT GDK_Page_Down
-#define VK_DELETE GDK_Delete
-#define VK_INSERT GDK_Insert
-#define VK_ESCAPE GDK_Escape
-#define VK_BACK GDK_BackSpace
-#define VK_TAB GDK_Tab
-#define VK_RETURN GDK_Return
-#define VK_ADD GDK_KP_Add
-#define VK_SUBTRACT GDK_KP_Subtract
-#define VK_DIVIDE GDK_KP_Divide
-#endif
-
-#if PLAT_WX
-#define VK_DOWN         WXK_DOWN
-#define VK_UP           WXK_UP
-#define VK_LEFT         WXK_LEFT
-#define VK_RIGHT        WXK_RIGHT
-#define VK_HOME         WXK_HOME
-#define VK_END          WXK_END
-#define VK_PRIOR        WXK_PRIOR
-#define VK_NEXT         WXK_NEXT
-#define VK_DELETE       WXK_DELETE
-#define VK_INSERT       WXK_INSERT
-#define VK_ESCAPE       WXK_ESCAPE
-#define VK_BACK         WXK_BACK
-#define VK_TAB          WXK_TAB
-#define VK_RETURN       WXK_RETURN
-#define VK_ADD          WXK_ADD
-#define VK_SUBTRACT     WXK_SUBTRACT
-//TODO:
-#define VK_DIVIDE      WXK_DIVIDE
-#endif
-
-#define SHIFT_PRESSED 1
-#define LEFT_CTRL_PRESSED 2
-#define LEFT_ALT_PRESSED 4
-
-// Are these needed any more
-#define LPSTR char *
-#define LONG long
-#define LPDWORD (long *)
-
-/* SELCHANGE structure */
-#define SEL_EMPTY      (0)
-#define SEL_TEXT       (1)
-#define SEL_OBJECT     (2)
-#define SEL_MULTICHAR  (4)
-#define SEL_MULTIOBJECT        (8)
-
-struct RECT {
-       LONG left;
-       LONG top;
-       LONG right;
-       LONG bottom;
-};
-
-/* FINDREPLACE structure */
-
-#define FR_MATCHCASE   (0x4)
-#define FR_WHOLEWORD   (0x2)
-#define FR_DOWN                (0x1)
-
-#endif
-
-#if 0
-struct CHARRANGE {
-       LONG cpMin;
-       LONG cpMax;
-};
-
-struct TEXTRANGE {
-       CHARRANGE chrg;
-       LPSTR lpstrText;
-};
-
-struct FINDTEXTEX {
-       CHARRANGE chrg;
-       LPSTR lpstrText;
-       CHARRANGE chrgText;
-};
-
-struct NMHDR {
-       WindowID hwndFrom;
-       UINT idFrom;
-       UINT code;
-};
-
-struct FORMATRANGE {
-       SurfaceID hdc;
-       SurfaceID hdcTarget;
-       RECT rc;
-       RECT rcPage;
-       CHARRANGE chrg;
-};
-#endif
-
-//#define MAKELONG(a, b) ((a) | ((b) << 16))
-//#define LOWORD(x) (x & 0xffff)
-//#define HIWORD(x) (x >> 16)
-
-#endif /* !_MSC_VER */
-
-#endif
index 10403242b9378ffc64a181c3de46197a753fddbd..abbb87d5dc9cce22a177a954c75fd6018311a433 100644 (file)
@@ -357,8 +357,10 @@ void Document::ModifiedAt(int pos) {
 
 // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 void Document::DeleteChars(int pos, int len) {
 
 // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 void Document::DeleteChars(int pos, int len) {
+       if (len == 0)
+               return;
        if ((pos + len) > Length())
        if ((pos + len) > Length())
-               return ;
+               return;
        if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
                enteredReadOnlyCount++;
                NotifyModifyAttempt();
        if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
                enteredReadOnlyCount++;
                NotifyModifyAttempt();
index 5b72ac579d28886b60c18035c20d7f1ddd955c85..2171924f0fd5eea90a496b6d8b5a139b573c0ba0 100644 (file)
 
 #include "Scintilla.h"
 
 
 #include "Scintilla.h"
 
-#if PLAT_WX || PLAT_GTK
-#include "WinDefs.h"
-#endif 
-
 #include "ContractionState.h"
 #include "SVector.h"
 #include "CellBuffer.h"
 #include "ContractionState.h"
 #include "SVector.h"
 #include "CellBuffer.h"
@@ -58,7 +54,6 @@ Editor::Editor() {
        dwelling = false;
        ptMouseLast.x = 0;
        ptMouseLast.y = 0;
        dwelling = false;
        ptMouseLast.x = 0;
        ptMouseLast.y = 0;
-       firstExpose = true;
        inDragDrop = false;
        dropWentOutside = false;
        posDrag = invalidPosition;
        inDragDrop = false;
        dropWentOutside = false;
        posDrag = invalidPosition;
@@ -69,9 +64,6 @@ Editor::Editor() {
        lineAnchor = 0;
        originalAnchorPos = 0;
 
        lineAnchor = 0;
        originalAnchorPos = 0;
 
-       dragChars = 0;
-       lenDrag = 0;
-       dragIsRectangle = false;
        selType = selStream;
        xStartSelect = 0;
        xEndSelect = 0;
        selType = selStream;
        xStartSelect = 0;
        xEndSelect = 0;
@@ -85,9 +77,6 @@ Editor::Editor() {
 
        searchAnchor = 0;
 
 
        searchAnchor = 0;
 
-       ucWheelScrollLines = 0;
-       cWheelDelta = 0;   //wheel delta from roll
-
        xOffset = 0;
        xCaretMargin = 50;
        horizontalScrollBarVisible = true;
        xOffset = 0;
        xCaretMargin = 50;
        horizontalScrollBarVisible = true;
@@ -114,15 +103,11 @@ Editor::Editor() {
 
        modEventMask = SC_MODEVENTMASKALL;
 
 
        modEventMask = SC_MODEVENTMASKALL;
 
-       displayPopupMenu = true;
-
        pdoc = new Document();
        pdoc ->AddRef();
        pdoc->AddWatcher(this, 0);
 
        pdoc = new Document();
        pdoc ->AddRef();
        pdoc->AddWatcher(this, 0);
 
-#ifdef MACRO_SUPPORT
-       recordingMacro = 0;
-#endif 
+       recordingMacro = false;
        foldFlags = 0;
 }
 
        foldFlags = 0;
 }
 
@@ -131,10 +116,6 @@ Editor::~Editor() {
        pdoc->Release();
        pdoc = 0;
        DropGraphics();
        pdoc->Release();
        pdoc = 0;
        DropGraphics();
-
-       delete []dragChars;
-       dragChars = 0;
-       lenDrag = 0;
 }
 
 void Editor::Finalise() {
 }
 
 void Editor::Finalise() {
@@ -874,7 +855,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
                                if (marks) {
                                        for (int markBit = 0; (markBit < 32) && marks; markBit++) {
                                                if (marks & 1) {
                                if (marks) {
                                        for (int markBit = 0; (markBit < 32) && marks; markBit++) {
                                                if (marks & 1) {
-                                                       vs.markers[markBit].Draw(surface, rcMarker);
+                                                       vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font);
                                                }
                                                marks >>= 1;
                                        }
                                                }
                                                marks >>= 1;
                                        }
@@ -1917,14 +1898,12 @@ void Editor::NotifyChar(int ch) {
        scn.nmhdr.code = SCN_CHARADDED;
        scn.ch = ch;
        NotifyParent(scn);
        scn.nmhdr.code = SCN_CHARADDED;
        scn.ch = ch;
        NotifyParent(scn);
-#ifdef MACRO_SUPPORT
        if (recordingMacro) {
                char txt[2];
                txt[0] = static_cast<char>(ch);
                txt[1] = '\0';
                NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<long>(txt));
        }
        if (recordingMacro) {
                char txt[2];
                txt[0] = static_cast<char>(ch);
                txt[1] = '\0';
                NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<long>(txt));
        }
-#endif 
 }
 
 void Editor::NotifySavePoint(bool isSavePoint) {
 }
 
 void Editor::NotifySavePoint(bool isSavePoint) {
@@ -2150,7 +2129,6 @@ void Editor::NotifyDeleted(Document *, void *) {
        /* Do nothing */
 }
 
        /* Do nothing */
 }
 
-#ifdef MACRO_SUPPORT
 void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam) {
 
        // Enumerates all macroable messages
 void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam) {
 
        // Enumerates all macroable messages
@@ -2159,10 +2137,6 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
        case SCI_COPY:
        case SCI_PASTE:
        case SCI_CLEAR:
        case SCI_COPY:
        case SCI_PASTE:
        case SCI_CLEAR:
-       case WM_CUT:
-       case WM_COPY:
-       case WM_PASTE:
-       case WM_CLEAR:
        case SCI_REPLACESEL:
        case SCI_ADDTEXT:
        case SCI_INSERTTEXT:
        case SCI_REPLACESEL:
        case SCI_ADDTEXT:
        case SCI_INSERTTEXT:
@@ -2236,7 +2210,6 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
        scn.lParam = lParam;
        NotifyParent(scn);
 }
        scn.lParam = lParam;
        NotifyParent(scn);
 }
-#endif 
 
 // Force scroll and keep position relative to top of window
 void Editor::PageMove(int direction, bool extend) {
 
 // Force scroll and keep position relative to top of window
 void Editor::PageMove(int direction, bool extend) {
@@ -2674,7 +2647,6 @@ void Editor::Indent(bool forwards) {
  * @return The position of the found text, -1 if not found.
  */
 long Editor::FindText(
  * @return The position of the found text, -1 if not found.
  */
 long Editor::FindText(
-    unsigned int iMessage,     ///< Can be @c EM_FINDTEXT or @c EM_FINDTEXTEX or @c SCI_FINDTEXT.
     unsigned long wParam,      ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
     ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP.
     long lParam) {                     ///< @c TextToFind structure: The text to search for in the given range.
     unsigned long wParam,      ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
     ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP.
     long lParam) {                     ///< @c TextToFind structure: The text to search for in the given range.
@@ -2688,10 +2660,8 @@ long Editor::FindText(
                                 wParam & SCFIND_REGEXP,
                                 &lengthFound);
        if (pos != -1) {
                                 wParam & SCFIND_REGEXP,
                                 &lengthFound);
        if (pos != -1) {
-               if (iMessage != EM_FINDTEXT) {
-                       ft->chrgText.cpMin = pos;
-                       ft->chrgText.cpMax = pos + lengthFound;
-               }
+               ft->chrgText.cpMin = pos;
+               ft->chrgText.cpMax = pos + lengthFound;
        }
        return pos;
 }
        }
        return pos;
 }
@@ -2800,33 +2770,23 @@ char *Editor::CopyRange(int start, int end) {
        return text;
 }
 
        return text;
 }
 
-int Editor::SelectionRangeLength() {
+void Editor::CopySelectionRange(SelectionText *ss) {
+       char *text = 0;
+       int size = 0;
        if (selType == selRectangle) {
                int lineStart = pdoc->LineFromPosition(SelectionStart());
                int lineEnd = pdoc->LineFromPosition(SelectionEnd());
        if (selType == selRectangle) {
                int lineStart = pdoc->LineFromPosition(SelectionStart());
                int lineEnd = pdoc->LineFromPosition(SelectionEnd());
-               int totalSize = 0;
-               for (int line = lineStart; line <= lineEnd; line++) {
-                       totalSize += SelectionEnd(line) - SelectionStart(line) + 1;
+               int line;
+               for (line = lineStart; line <= lineEnd; line++) {
+                       size += SelectionEnd(line) - SelectionStart(line) + 1;
                        if (pdoc->eolMode == SC_EOL_CRLF)
                        if (pdoc->eolMode == SC_EOL_CRLF)
-                               totalSize++;
+                               size++;
                }
                }
-               return totalSize;
-       } else {
-               return SelectionEnd() - SelectionStart();
-       }
-}
-
-char *Editor::CopySelectionRange() {
-       if (selType == selRectangle) {
-               char *text = 0;
-               int lineStart = pdoc->LineFromPosition(SelectionStart());
-               int lineEnd = pdoc->LineFromPosition(SelectionEnd());
-               int totalSize = SelectionRangeLength();
-               if (totalSize > 0) {
-                       text = new char[totalSize + 1];
+               if (size > 0) {
+                       text = new char[size + 1];
                        if (text) {
                                int j = 0;
                        if (text) {
                                int j = 0;
-                               for (int line = lineStart; line <= lineEnd; line++) {
+                               for (line = lineStart; line <= lineEnd; line++) {
                                        for (int i = SelectionStart(line);i < SelectionEnd(line);i++) {
                                                text[j++] = pdoc->CharAt(i);
                                        }
                                        for (int i = SelectionStart(line);i < SelectionEnd(line);i++) {
                                                text[j++] = pdoc->CharAt(i);
                                        }
@@ -2835,24 +2795,14 @@ char *Editor::CopySelectionRange() {
                                        if (pdoc->eolMode != SC_EOL_CR)
                                                text[j++] = '\n';
                                }
                                        if (pdoc->eolMode != SC_EOL_CR)
                                                text[j++] = '\n';
                                }
-                               text[totalSize] = '\0';
+                               text[size] = '\0';
                        }
                }
                        }
                }
-               return text;
        } else {
        } else {
-               return CopyRange(SelectionStart(), SelectionEnd());
-       }
-}
-
-void Editor::CopySelectionIntoDrag() {
-       delete []dragChars;
-       dragChars = 0;
-       lenDrag = SelectionRangeLength();
-       dragChars = CopySelectionRange();
-       dragIsRectangle = selType == selRectangle;
-       if (!dragChars) {
-               lenDrag = 0;
+               size = SelectionEnd() - SelectionStart();
+               text = CopyRange(SelectionStart(), SelectionEnd());
        }
        }
+       ss->Set(text, size, selType == selRectangle);
 }
 
 void Editor::SetDragPosition(int newPos) {
 }
 
 void Editor::SetDragPosition(int newPos) {
@@ -2882,8 +2832,6 @@ void Editor::StartDrag() {
        //DisplayCursor(Window::cursorArrow);
 }
 
        //DisplayCursor(Window::cursorArrow);
 }
 
-
-
 void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
        //Platform::DebugPrintf("DropAt %d\n", inDragDrop);
        if (inDragDrop)
 void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
        //Platform::DebugPrintf("DropAt %d\n", inDragDrop);
        if (inDragDrop)
@@ -3115,7 +3063,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
                        if (inDragDrop) {
                                SetMouseCapture(false);
                                SetDragPosition(newPos);
                        if (inDragDrop) {
                                SetMouseCapture(false);
                                SetDragPosition(newPos);
-                               CopySelectionIntoDrag();
+                               CopySelectionRange(&drag);
                                StartDrag();
                        } else {
                                xStartSelect = pt.x - vs.fixedColumnWidth + xOffset;
                                StartDrag();
                        } else {
                                xStartSelect = pt.x - vs.fixedColumnWidth + xOffset;
@@ -3220,25 +3168,23 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
                        int selStart = SelectionStart();
                        int selEnd = SelectionEnd();
                        if (selStart < selEnd) {
                        int selStart = SelectionStart();
                        int selEnd = SelectionEnd();
                        if (selStart < selEnd) {
-                               if (dragChars && lenDrag) {
+                               if (drag.len) {
                                        if (ctrl) {
                                        if (ctrl) {
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else if (newPos < selStart) {
                                        } else if (newPos < selStart) {
-                                               pdoc->DeleteChars(selStart, lenDrag);
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->DeleteChars(selStart, drag.len);
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else if (newPos > selEnd) {
                                        } else if (newPos > selEnd) {
-                                               pdoc->DeleteChars(selStart, lenDrag);
-                                               newPos -= lenDrag;
-                                               pdoc->InsertString(newPos, dragChars, lenDrag);
-                                               SetSelection(newPos, newPos + lenDrag);
+                                               pdoc->DeleteChars(selStart, drag.len);
+                                               newPos -= drag.len;
+                                               pdoc->InsertString(newPos, drag.s, drag.len);
+                                               SetSelection(newPos, newPos + drag.len);
                                        } else {
                                                SetEmptySelection(newPos);
                                        }
                                        } else {
                                                SetEmptySelection(newPos);
                                        }
-                                       delete []dragChars;
-                                       dragChars = 0;
-                                       lenDrag = 0;
+                                       drag.Set(0, 0);
                                }
                                selectionType = selChar;
                        }
                                }
                                selectionType = selChar;
                        }
@@ -3545,14 +3491,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
        // Optional macro recording hook
        //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
        // Optional macro recording hook
-#ifdef MACRO_SUPPORT
        if (recordingMacro)
                NotifyMacroRecord(iMessage, wParam, lParam);
        if (recordingMacro)
                NotifyMacroRecord(iMessage, wParam, lParam);
-#endif 
 
        switch (iMessage) {
 
 
        switch (iMessage) {
 
-       case WM_GETTEXT:
        case SCI_GETTEXT:
                {
                        if (lParam == 0)
        case SCI_GETTEXT:
                {
                        if (lParam == 0)
@@ -3565,7 +3508,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return iChar;
                }
 
                        return iChar;
                }
 
-       case WM_SETTEXT:
        case SCI_SETTEXT:
                {
                        if (lParam == 0)
        case SCI_SETTEXT:
                {
                        if (lParam == 0)
@@ -3576,130 +3518,45 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return TRUE;
                }
 
                        return TRUE;
                }
 
-       case WM_GETTEXTLENGTH:
        case SCI_GETTEXTLENGTH:
                return pdoc->Length();
 
        case SCI_GETTEXTLENGTH:
                return pdoc->Length();
 
-       case WM_CUT:
        case SCI_CUT:
                Cut();
                SetLastXChosen();
                break;
 
        case SCI_CUT:
                Cut();
                SetLastXChosen();
                break;
 
-       case WM_COPY:
        case SCI_COPY:
                Copy();
                break;
 
        case SCI_COPY:
                Copy();
                break;
 
-       case WM_PASTE:
        case SCI_PASTE:
                Paste();
                SetLastXChosen();
                EnsureCaretVisible();
                break;
 
        case SCI_PASTE:
                Paste();
                SetLastXChosen();
                EnsureCaretVisible();
                break;
 
-       case WM_CLEAR:
        case SCI_CLEAR:
                Clear();
                SetLastXChosen();
                break;
 
        case SCI_CLEAR:
                Clear();
                SetLastXChosen();
                break;
 
-       case WM_UNDO:
        case SCI_UNDO:
                Undo();
                SetLastXChosen();
                break;
 
        case SCI_UNDO:
                Undo();
                SetLastXChosen();
                break;
 
-               // Edit control messages
-
-               // Not supported (no-ops):
-               //              EM_GETWORDBREAKPROC
-               //              EM_GETWORDBREAKPROCEX
-               //              EM_SETWORDBREAKPROC
-               //              EM_SETWORDBREAKPROCEX
-               //              EM_GETWORDWRAPMODE
-               //              EM_SETWORDWRAPMODE
-               //              EM_LIMITTEXT
-               //              EM_EXLIMITTEXT
-               //              EM_SETRECT
-               //              EM_SETRECTNP
-               //              EM_FMTLINES
-               //              EM_GETHANDLE
-               //              EM_SETHANDLE
-               //              EM_GETPASSWORDCHAR
-               //              EM_SETPASSWORDCHAR
-               //              EM_SETTABSTOPS
-               //              EM_FINDWORDBREAK
-               //              EM_GETCHARFORMAT
-               //              EM_SETCHARFORMAT
-               //              EM_GETOLEINTERFACE
-               //              EM_SETOLEINTERFACE
-               //              EM_SETOLECALLBACK
-               //              EM_GETPARAFORMAT
-               //              EM_SETPARAFORMAT
-               //              EM_PASTESPECIAL
-               //              EM_REQUESTRESIZE
-               //              EM_GETBKGNDCOLOR
-               //              EM_SETBKGNDCOLOR
-               //              EM_STREAMIN
-               //              EM_STREAMOUT
-               //              EM_GETIMECOLOR
-               //              EM_SETIMECOLOR
-               //              EM_GETIMEOPTIONS
-               //              EM_SETIMEOPTIONS
-               //              EM_GETOPTIONS
-               //              EM_SETOPTIONS
-               //              EM_GETPUNCTUATION
-               //              EM_SETPUNCTUATION
-               //              EM_GETTHUMB
-               //              EM_SETTARGETDEVICE
-
-               // Not supported but should be:
-               //              EM_GETEVENTMASK
-               //              EM_SETEVENTMASK
-               //              For printing:
-               //                      EM_DISPLAYBAND
-
-       case EM_CANUNDO:
        case SCI_CANUNDO:
                return pdoc->CanUndo() ? TRUE : FALSE;
 
        case SCI_CANUNDO:
                return pdoc->CanUndo() ? TRUE : FALSE;
 
-       case EM_UNDO:
-               Undo();
-               SetLastXChosen();
-               break;
-
-       case EM_EMPTYUNDOBUFFER:
        case SCI_EMPTYUNDOBUFFER:
                pdoc->DeleteUndoHistory();
                return 0;
 
        case SCI_EMPTYUNDOBUFFER:
                pdoc->DeleteUndoHistory();
                return 0;
 
-       case EM_GETFIRSTVISIBLELINE:
        case SCI_GETFIRSTVISIBLELINE:
                return topLine;
 
        case SCI_GETFIRSTVISIBLELINE:
                return topLine;
 
-       case EM_GETLINE: {
-                       if (lParam == 0) {
-                               return 0;
-                       }
-                       char *ptr = reinterpret_cast<char *>(lParam);
-                       short *pBufSize = reinterpret_cast<short *>(lParam);
-                       short bufSize = *pBufSize;
-                       ptr[0] = '\0';  // If no characters copied, have to put a NUL into buffer
-                       if (static_cast<int>(wParam) > pdoc->LinesTotal()) {
-                               return 0;
-                       }
-                       int lineStart = pdoc->LineStart(wParam);
-                       int lineEnd = pdoc->LineStart(wParam + 1);
-                       // The first word of the buffer is the size, in TCHARs, of the buffer
-                       int iPlace = 0;
-                       for (int iChar = lineStart; iChar < lineEnd && iPlace < bufSize; iChar++) {
-                               ptr[iPlace++] = pdoc->CharAt(iChar);
-                       }
-                       return iPlace;
-               }
-
-       case SCI_GETLINE: {     // Simpler than EM_GETLINE, but with risk of overwriting the end of the buffer
+       case SCI_GETLINE: {     // Risk of overwriting the end of the buffer
                        if (lParam == 0) {
                                return 0;
                        }
                        if (lParam == 0) {
                                return 0;
                        }
@@ -3713,42 +3570,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return iPlace;
                }
 
                        return iPlace;
                }
 
-       case EM_GETLINECOUNT:
        case SCI_GETLINECOUNT:
                if (pdoc->LinesTotal() == 0)
                        return 1;
                else
                        return pdoc->LinesTotal();
 
        case SCI_GETLINECOUNT:
                if (pdoc->LinesTotal() == 0)
                        return 1;
                else
                        return pdoc->LinesTotal();
 
-       case EM_GETMODIFY:
        case SCI_GETMODIFY:
                return !pdoc->IsSavePoint();
 
        case SCI_GETMODIFY:
                return !pdoc->IsSavePoint();
 
-       case EM_GETRECT:
-               if (lParam == 0)
-                       return 0;
-               *(reinterpret_cast<PRectangle *>(lParam)) = GetClientRectangle();
-               break;
-
-       case EM_GETSEL:
-               if (wParam)
-                       *reinterpret_cast<int *>(wParam) = SelectionStart();
-               if (lParam)
-                       *reinterpret_cast<int *>(lParam) = SelectionEnd();
-               return Platform::LongFromTwoShorts(
-                          static_cast<short>(SelectionStart()),
-                          static_cast<short>(SelectionEnd()));
-
-       case EM_EXGETSEL: {
-                       if (lParam == 0)
-                               return 0;
-                       CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
-                       pCR->cpMin = SelectionStart();
-                       pCR->cpMax = SelectionEnd();
-               }
-               break;
-
-       case EM_SETSEL:
        case SCI_SETSEL: {
                        int nStart = static_cast<int>(wParam);
                        int nEnd = static_cast<int>(lParam);
        case SCI_SETSEL: {
                        int nStart = static_cast<int>(wParam);
                        int nEnd = static_cast<int>(lParam);
@@ -3762,55 +3592,28 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                }
                break;
 
                }
                break;
 
-       case EM_EXSETSEL: {
-                       if (lParam == 0)
-                               return 0;
-                       CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
-                       selType = selStream;
-                       if (pCR->cpMax == -1) {
-                               SetSelection(pCR->cpMin, pdoc->Length());
-                       } else {
-                               SetSelection(pCR->cpMin, pCR->cpMax);
-                       }
-                       EnsureCaretVisible();
-                       return pdoc->LineFromPosition(SelectionStart());
-               }
-
-       case EM_GETSELTEXT:
        case SCI_GETSELTEXT: {
                        if (lParam == 0)
                                return 0;
        case SCI_GETSELTEXT: {
                        if (lParam == 0)
                                return 0;
+                       SelectionText selectedText;
+                       CopySelectionRange(&selectedText);
                        char *ptr = reinterpret_cast<char *>(lParam);
                        char *ptr = reinterpret_cast<char *>(lParam);
-                       int selSize = SelectionRangeLength();
-                       char *text = CopySelectionRange();
                        int iChar = 0;
                        int iChar = 0;
-                       if (text) {
-                               for (; iChar < selSize; iChar++)
-                                       ptr[iChar] = text[iChar];
+                       if (selectedText.len) {
+                               for (; iChar < selectedText.len; iChar++)
+                                       ptr[iChar] = selectedText.s[iChar];
                                ptr[iChar] = '\0';
                                ptr[iChar] = '\0';
-                               delete []text;
                        } else {
                                ptr[0] = '\0';
                        }
                        return iChar;
                }
 
                        } else {
                                ptr[0] = '\0';
                        }
                        return iChar;
                }
 
-       case EM_LINEFROMCHAR:
-               if (static_cast<int>(wParam) < 0)
-                       wParam = SelectionStart();
-               return pdoc->LineFromPosition(wParam);
-
-       case EM_EXLINEFROMCHAR:
-               if (static_cast<int>(lParam) < 0)
-                       lParam = SelectionStart();      // Not specified, but probably OK
-               return pdoc->LineFromPosition(lParam);
-
        case SCI_LINEFROMPOSITION:
                if (static_cast<int>(wParam) < 0)
                        return 0;
                return pdoc->LineFromPosition(wParam);
 
        case SCI_LINEFROMPOSITION:
                if (static_cast<int>(wParam) < 0)
                        return 0;
                return pdoc->LineFromPosition(wParam);
 
-       case EM_LINEINDEX:
        case SCI_POSITIONFROMLINE:
                if (static_cast<int>(wParam) < 0)
                        wParam = pdoc->LineFromPosition(SelectionStart());
        case SCI_POSITIONFROMLINE:
                if (static_cast<int>(wParam) < 0)
                        wParam = pdoc->LineFromPosition(SelectionStart());
@@ -3822,28 +3625,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                //      return -1;
                return pdoc->LineStart(wParam);
 
                //      return -1;
                return pdoc->LineStart(wParam);
 
-       case EM_LINELENGTH: {
-                       if (static_cast<int>(wParam) < 0)       // Who use this anyway?
-                               return 0;       // Should be... Too complex to describe here, see MS specs!
-                       if (static_cast<int>(wParam) > pdoc->Length())  // Useful test, anyway...
-                               return 0;
-                       int line = pdoc->LineFromPosition(wParam);
-                       int charsOnLine = 0;
-                       for (int pos = pdoc->LineStart(line); pos < pdoc->LineStart(line + 1); pos++) {
-                               if ((pdoc->CharAt(pos) != '\r') && (pdoc->CharAt(pos) != '\n'))
-                                       charsOnLine++;
-                       }
-                       return charsOnLine;
-               }
-
-               // Replacement of the old Scintilla interpretation of EM_LINELENGTH
+       // Replacement of the old Scintilla interpretation of EM_LINELENGTH
        case SCI_LINELENGTH:
                if ((static_cast<int>(wParam) < 0) ||
                        (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
                        return 0;
                return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam);
 
        case SCI_LINELENGTH:
                if ((static_cast<int>(wParam) < 0) ||
                        (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
                        return 0;
                return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam);
 
-       case EM_REPLACESEL:
        case SCI_REPLACESEL: {
                        if (lParam == 0)
                                return 0;
        case SCI_REPLACESEL: {
                        if (lParam == 0)
                                return 0;
@@ -3890,18 +3678,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETSEARCHFLAGS:
                return searchFlags;
 
        case SCI_GETSEARCHFLAGS:
                return searchFlags;
 
-       case EM_LINESCROLL:
        case SCI_LINESCROLL:
                ScrollTo(topLine + lParam);
                HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
                return TRUE;
 
        case SCI_LINESCROLL:
                ScrollTo(topLine + lParam);
                HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
                return TRUE;
 
-       case EM_SCROLLCARET:
        case SCI_SCROLLCARET:
                EnsureCaretVisible();
                break;
 
        case SCI_SCROLLCARET:
                EnsureCaretVisible();
                break;
 
-       case EM_SETREADONLY:
        case SCI_SETREADONLY:
                pdoc->SetReadOnly(wParam);
                return TRUE;
        case SCI_SETREADONLY:
                pdoc->SetReadOnly(wParam);
                return TRUE;
@@ -3909,33 +3694,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETREADONLY:
                return pdoc->IsReadOnly();
 
        case SCI_GETREADONLY:
                return pdoc->IsReadOnly();
 
-       case EM_CANPASTE:
        case SCI_CANPASTE:
                return CanPaste();
 
        case SCI_CANPASTE:
                return CanPaste();
 
-       case EM_CHARFROMPOS: {
-                       if (lParam == 0)
-                               return 0;
-                       Point *ppt = reinterpret_cast<Point *>(lParam);
-                       int pos = PositionFromLocation(*ppt);
-                       int line = pdoc->LineFromPosition(pos);
-                       return Platform::LongFromTwoShorts(
-                                  static_cast<short>(pos), static_cast < short > (line));
-               }
-
-       case EM_POSFROMCHAR: {
-                       // The MS specs for this have changed 3 times: using the RichEdit 3 version
-                       if (wParam == 0)
-                               return 0;
-                       Point *ppt = reinterpret_cast<Point *>(wParam);
-                       if (lParam < 0) {
-                               *ppt = Point(0, 0);
-                       } else {
-                               *ppt = LocationFromPosition(lParam);
-                       }
-                       return 0;
-               }
-
        case SCI_POINTXFROMPOSITION:
                if (lParam < 0) {
                        return 0;
        case SCI_POINTXFROMPOSITION:
                if (lParam < 0) {
                        return 0;
@@ -3952,14 +3713,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return pt.y;
                }
 
                        return pt.y;
                }
 
-       case EM_FINDTEXT:
-               return FindText(iMessage, wParam, lParam);
-
-       case EM_FINDTEXTEX:
        case SCI_FINDTEXT:
        case SCI_FINDTEXT:
-               return FindText(iMessage, wParam, lParam);
+               return FindText(wParam, lParam);
 
 
-       case EM_GETTEXTRANGE:
        case SCI_GETTEXTRANGE: {
                        if (lParam == 0)
                                return 0;
        case SCI_GETTEXTRANGE: {
                        if (lParam == 0)
                                return 0;
@@ -3974,53 +3730,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
                        return len;     // Not including NUL
                }
 
                        return len;     // Not including NUL
                }
 
-
-
-       case EM_SELECTIONTYPE:
-#ifdef SEL_EMPTY
-               if (currentPos == anchor)
-                       return SEL_EMPTY;
-               else
-                       return SEL_TEXT;
-#else 
-               return 0;
-#endif 
-
-       case EM_HIDESELECTION:
+       case SCI_HIDESELECTION:
                hideSelection = wParam;
                Redraw();
                break;
 
                hideSelection = wParam;
                Redraw();
                break;
 
-       case EM_FORMATRANGE:
        case SCI_FORMATRANGE:
                return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
 
        case SCI_FORMATRANGE:
                return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
 
-       case EM_GETMARGINS:
-               return Platform::LongFromTwoShorts(static_cast<short>(vs.leftMarginWidth),
-                                                  static_cast<short>(vs.rightMarginWidth));
-
        case SCI_GETMARGINLEFT:
                return vs.leftMarginWidth;
 
        case SCI_GETMARGINRIGHT:
                return vs.rightMarginWidth;
 
        case SCI_GETMARGINLEFT:
                return vs.leftMarginWidth;
 
        case SCI_GETMARGINRIGHT:
                return vs.rightMarginWidth;
 
-       case EM_SETMARGINS:
-#ifdef EC_LEFTMARGIN
-               if (wParam & EC_LEFTMARGIN) {
-                       vs.leftMarginWidth = Platform::LowShortFromLong(lParam);
-               }
-               if (wParam & EC_RIGHTMARGIN) {
-                       vs.rightMarginWidth = Platform::HighShortFromLong(lParam);
-               }
-               if (wParam == EC_USEFONTINFO) {
-                       vs.leftMarginWidth = vs.aveCharWidth / 2;
-                       vs.rightMarginWidth = vs.aveCharWidth / 2;
-               }
-               InvalidateStyleRedraw();
-#endif 
-               break;
-
        case SCI_SETMARGINLEFT:
                vs.leftMarginWidth = lParam;
                InvalidateStyleRedraw();
        case SCI_SETMARGINLEFT:
                vs.leftMarginWidth = lParam;
                InvalidateStyleRedraw();
@@ -4667,10 +4390,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_LINESONSCREEN:
                return LinesOnScreen();
 
        case SCI_LINESONSCREEN:
                return LinesOnScreen();
 
-       case SCI_USEPOPUP:
-               displayPopupMenu = wParam;
-               break;
-
        case SCI_SETSELFORE:
                vs.selforeset = wParam;
                vs.selforeground.desired = Colour(lParam);
        case SCI_SETSELFORE:
                vs.selforeset = wParam;
                vs.selforeground.desired = Colour(lParam);
@@ -4711,7 +4430,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
        case SCI_CLEARCMDKEY:
                kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
 
        case SCI_CLEARCMDKEY:
                kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
-                                 Platform::HighShortFromLong(wParam), WM_NULL);
+                                 Platform::HighShortFromLong(wParam), SCI_NULL);
                break;
 
        case SCI_CLEARALLCMDKEYS:
                break;
 
        case SCI_CLEARALLCMDKEYS:
@@ -4915,15 +4634,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
        case SCI_GETCURSOR:
                return cursorMode;
 
        case SCI_GETCURSOR:
                return cursorMode;
 
-#ifdef MACRO_SUPPORT
        case SCI_STARTRECORD:
        case SCI_STARTRECORD:
-               recordingMacro = 1;
+               recordingMacro = true;
                return 0;
 
        case SCI_STOPRECORD:
                return 0;
 
        case SCI_STOPRECORD:
-               recordingMacro = 0;
+               recordingMacro = false;
                return 0;
                return 0;
-#endif 
 
        case SCI_MOVECARETINSIDEVIEW:
                MoveCaretInsideView();
 
        case SCI_MOVECARETINSIDEVIEW:
                MoveCaretInsideView();
index d42f5ad14a133b0d53b1f31f12a7cc05b5cfe9a2..a51fd86f91682853dc507729b28b8843e38a9010 100644 (file)
@@ -50,6 +50,26 @@ public:
        int positions[maxLineLength+1];
 };
 
        int positions[maxLineLength+1];
 };
 
+class SelectionText {
+public:
+       char *s;
+       int len;
+       bool rectangular;
+       SelectionText() : s(0), len(0), rectangular(false) {}
+       ~SelectionText() {
+               Set(0, 0);
+       }
+       void Set(char *s_, int len_, bool rectangular_=false) {
+               delete []s;
+               s = s_;
+               if (s)
+                       len = len_;
+               else
+                       len = 0;
+               rectangular = rectangular_;
+       }
+};
+
 /**
  */
 class Editor : public DocWatcher {
 /**
  */
 class Editor : public DocWatcher {
@@ -68,6 +88,7 @@ protected:    // ScintillaBase subclass needs access to much of Editor
        bool stylesValid;       
        ViewStyle vs;
        Palette palette;
        bool stylesValid;       
        ViewStyle vs;
        Palette palette;
+
        int printMagnification;
        int printColourMode;
        int cursorMode;
        int printMagnification;
        int printColourMode;
        int cursorMode;
@@ -91,9 +112,6 @@ protected:   // ScintillaBase subclass needs access to much of Editor
        Surface pixmapSelPattern;
        Surface pixmapIndentGuide;
        Surface pixmapIndentGuideHighlight;
        Surface pixmapSelPattern;
        Surface pixmapIndentGuide;
        Surface pixmapIndentGuideHighlight;
-       // Intellimouse support - currently only implemented for Windows
-       unsigned int ucWheelScrollLines;
-       int cWheelDelta; ///< Wheel delta from roll
 
        KeyMap kmap;
 
 
        KeyMap kmap;
 
@@ -109,7 +127,6 @@ protected:  // ScintillaBase subclass needs access to much of Editor
        bool dwelling;
        enum { selChar, selWord, selLine } selectionType;
        Point ptMouseLast;
        bool dwelling;
        enum { selChar, selWord, selLine } selectionType;
        Point ptMouseLast;
-       bool firstExpose;
        bool inDragDrop;
        bool dropWentOutside;
        int posDrag;
        bool inDragDrop;
        bool dropWentOutside;
        int posDrag;
@@ -138,9 +155,7 @@ protected:  // ScintillaBase subclass needs access to much of Editor
        
        int modEventMask;
        
        
        int modEventMask;
        
-       char *dragChars;
-       int lenDrag;
-       bool dragIsRectangle;
+       SelectionText drag;
        enum { selStream, selRectangle, selRectangleFixed } selType;
        int xStartSelect;
        int xEndSelect;
        enum { selStream, selRectangle, selRectangleFixed } selType;
        int xStartSelect;
        int xEndSelect;
@@ -154,11 +169,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
        
        int searchAnchor;
 
        
        int searchAnchor;
 
-       int displayPopupMenu;
-
-#ifdef MACRO_SUPPORT
-       int recordingMacro;
-#endif
+       bool recordingMacro;
 
        int foldFlags;
        ContractionState cs;
 
        int foldFlags;
        ContractionState cs;
@@ -270,11 +281,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
        void NotifyModified(Document *document, DocModification mh, void *userData);
        void NotifyDeleted(Document *document, void *userData);
        void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
        void NotifyModified(Document *document, DocModification mh, void *userData);
        void NotifyDeleted(Document *document, void *userData);
        void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
-
-       
-#ifdef MACRO_SUPPORT
        void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
        void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
-#endif
 
        void PageMove(int direction, bool extend=false);
        void ChangeCaseOfSelection(bool makeUpperCase);
 
        void PageMove(int direction, bool extend=false);
        void ChangeCaseOfSelection(bool makeUpperCase);
@@ -289,16 +296,14 @@ protected:        // ScintillaBase subclass needs access to much of Editor
 
        void Indent(bool forwards);
 
 
        void Indent(bool forwards);
 
-       long FindText(unsigned int iMessage, unsigned long wParam, long lParam);
+       long FindText(unsigned long wParam, long lParam);
        void SearchAnchor();
        long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
        long SearchInTarget(const char *text, int length);
        void GoToLine(int lineNo);
 
        char *CopyRange(int start, int end);
        void SearchAnchor();
        long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
        long SearchInTarget(const char *text, int length);
        void GoToLine(int lineNo);
 
        char *CopyRange(int start, int end);
-       int SelectionRangeLength();
-       char *CopySelectionRange();
-       void CopySelectionIntoDrag();
+       void CopySelectionRange(SelectionText *ss);
        void SetDragPosition(int newPos);
        void DisplayCursor(Window::Cursor c);
        virtual void StartDrag();
        void SetDragPosition(int newPos);
        void DisplayCursor(Window::Cursor c);
        virtual void StartDrag();
index 0728580fdfeb69c50b434c377f58726b7ed659ca..756037a9a4cf1b1ae7006721791a56e9a4550bd0 100644 (file)
@@ -108,22 +108,26 @@ LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
 int wxForceScintillaLexers(void) {
   extern LexerModule lmAda;
   extern LexerModule lmAVE;
 int wxForceScintillaLexers(void) {
   extern LexerModule lmAda;
   extern LexerModule lmAVE;
+  extern LexerModule lmBatch;
   extern LexerModule lmConf;
   extern LexerModule lmConf;
-  extern LexerModule lmDiff;
-  extern LexerModule lmLatex;
-  extern LexerModule lmPascal;
   extern LexerModule lmCPP;
   extern LexerModule lmCPP;
-  extern LexerModule lmHTML;
-  extern LexerModule lmXML;
-  extern LexerModule lmProps;
+  extern LexerModule lmDiff;
+  extern LexerModule lmEiffel;
+  extern LexerModule lmEiffelkw;
   extern LexerModule lmErrorList;
   extern LexerModule lmErrorList;
+  extern LexerModule lmHTML;
+  extern LexerModule lmLatex;
+  extern LexerModule lmLISP;
+  extern LexerModule lmLua;
   extern LexerModule lmMake;
   extern LexerModule lmMake;
-  extern LexerModule lmBatch;
+  extern LexerModule lmPascal;
   extern LexerModule lmPerl;
   extern LexerModule lmPerl;
+  extern LexerModule lmProps;  
   extern LexerModule lmPython;
   extern LexerModule lmPython;
+  extern LexerModule lmRuby;
   extern LexerModule lmSQL;
   extern LexerModule lmVB;
   extern LexerModule lmSQL;
   extern LexerModule lmVB;
-  extern LexerModule lmRuby;
+  extern LexerModule lmXML;
 
   if (
       &lmAda
 
   if (
       &lmAda
@@ -143,7 +147,12 @@ int wxForceScintillaLexers(void) {
       && &lmPython
       && &lmSQL
       && &lmVB
       && &lmPython
       && &lmSQL
       && &lmVB
-      && &lmRuby      
+      && &lmRuby
+      && &lmEiffel
+      && &lmEiffelkw
+      && &lmLISP
+      && &lmLua
+      && &lmNull
       )
     {
       return 1;
       )
     {
       return 1;
index 19aa329bafdc2cf76f762de6be183260f54e8d54..b0471b8e527ec7f9bef18d4944cf73149353efd0 100644 (file)
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
-static bool IsOKBeforeRE(int ch) {
+static bool IsOKBeforeRE(const int ch) {
        return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
        return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
-static void getRange(unsigned int start,
-               unsigned int end,
-               Accessor &styler,
-               char *s,
-               unsigned int len) {
-       unsigned int i = 0;
-       while ((i < end - start + 1) && (i < len-1)) {
-               s[i] = styler[start + i];
-               i++;
-       }
-       s[i] = '\0';
-}
-
-inline bool IsASpace(int ch) {
-    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
-}
-
-inline bool IsAWordChar(int  ch) {
+inline bool IsAWordChar(const int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 
-inline bool IsAWordStart(int ch) {
+inline bool IsAWordStart(const int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
-inline bool IsADigit(int ch) {
-       return (ch >= '0') && (ch <= '9');
+inline bool IsADoxygenChar(const int ch) {
+       return (islower(ch) || ch == '$' || ch == '@' ||
+                   ch == '\\' || ch == '&' || ch == '<' ||
+                       ch == '>' || ch == '#' || ch == '{' ||
+                       ch == '}' || ch == '[' || ch == ']');
 }
 
 }
 
-// All languages handled so far can treat all characters >= 0x80 as one class
-// which just continues the current token or starts an identifier if in default.
-// DBCS treated specially as the second character can be < 0x80 and hence 
-// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
-class ColouriseContext {
-       Accessor &styler;
-       int lengthDoc;
-       int currentPos;
-       ColouriseContext& operator=(const ColouriseContext&) {
-               return *this;
-       }
-public:
-       bool atEOL;
-       int state;
-       int chPrev;
-       int ch;
-       int chNext;
+inline bool IsStateComment(const int state) {
+       return ((state == SCE_C_COMMENT) ||
+                     (state == SCE_C_COMMENTLINE) ||
+                     (state == SCE_C_COMMENTDOC) ||
+                     (state == SCE_C_COMMENTDOCKEYWORD) ||
+                     (state == SCE_C_COMMENTDOCKEYWORDERROR));
+}
 
 
-       ColouriseContext(unsigned int startPos, int length,
-                        int initStyle, Accessor &styler_) : 
-               styler(styler_),
-               lengthDoc(startPos + length),
-               currentPos(startPos), 
-               atEOL(false),
-               state(initStyle), 
-               chPrev(0),
-               ch(0), 
-               chNext(0) {
-               styler.StartAt(startPos);
-               styler.StartSegment(startPos);
-               int pos = currentPos;
-               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               if (styler.IsLeadByte(static_cast<char>(ch))) {
-                       pos++;
-                       ch = ch << 8;
-                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               }
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
-               }
-               atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-       }
-       void Complete() {
-               styler.ColourTo(currentPos - 1, state);
-       }
-       bool More() {
-               return currentPos <= lengthDoc;
-       }
-       void Forward() {
-               // A lot of this is repeated from the constructor - TODO: merge code
-               chPrev = ch;
-               currentPos++;
-               if (ch >= 0x100)
-                       currentPos++;
-               ch = chNext;
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
-               }
-               // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
-               // Avoid triggering two times on Dos/Win
-               // End of line
-               atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-       }
-       void ChangeState(int state_) {
-               state = state_;
-       }
-       void SetState(int state_) {
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void ForwardSetState(int state_) {
-               Forward();
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void GetCurrent(char *s, int len) {
-               getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-       }
-       int LengthCurrent() {
-               return currentPos - styler.GetStartSegment();
-       }
-       bool Match(char ch0) {
-               return ch == ch0;
-       }
-       bool Match(char ch0, char ch1) {
-               return (ch == ch0) && (chNext == ch1);
-       }
-       bool Match(const char *s) {
-               if (ch != *s)
-                       return false;
-               s++;
-               if (chNext != *s)
-                       return false;
-               s++;
-               for (int n=2; *s; n++) {
-                       if (*s != styler.SafeGetCharAt(currentPos+n))
-                               return false;
-                       s++;
-               }
-               return true;
-       }
-};
+inline bool IsStateString(const int state) {
+       return ((state == SCE_C_STRING) || (state == SCE_C_VERBATIM));
+}
 
 static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler) {
 
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
 
 static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler) {
 
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
+       WordList &keywords3 = *keywordlists[2];
 
        bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
 
 
        bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
 
-       if (initStyle == SCE_C_STRINGEOL)       // Does not leak onto next line
+       // Do not leak onto next line
+       if (initStyle == SCE_C_STRINGEOL)
                initStyle = SCE_C_DEFAULT;
 
        int chPrevNonWhite = ' ';
        int visibleChars = 0;
                initStyle = SCE_C_DEFAULT;
 
        int chPrevNonWhite = ' ';
        int visibleChars = 0;
+       int noDocChars = 0;
        bool lastWordWasUUID = false;
 
        bool lastWordWasUUID = false;
 
-       ColouriseContext cc(startPos, length, initStyle, styler);
-
-       for (; cc.More(); cc.Forward()) {
+       StyleContext sc(startPos, length, initStyle, styler);
 
 
-               if (cc.state == SCE_C_STRINGEOL) {
-                       if (cc.atEOL) {
-                               cc.SetState(SCE_C_DEFAULT);
+       for (; sc.More(); sc.Forward()) {
+       
+               // Handle line continuation generically.
+               if (sc.ch == '\\') {
+                       if (sc.Match("\\\n")) {
+                               sc.Forward();
+                               sc.Forward();
+                               continue;
                        }
                        }
-               } else if (cc.state == SCE_C_OPERATOR) {
-                       cc.SetState(SCE_C_DEFAULT);
-               } else if (cc.state == SCE_C_NUMBER) {
-                       if (!IsAWordChar(cc.ch)) {
-                               cc.SetState(SCE_C_DEFAULT);
+                       if (sc.Match("\\\r\n")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.Forward();
+                               continue;
                        }
                        }
-               } else if (cc.state == SCE_C_IDENTIFIER) {
-                       if (!IsAWordChar(cc.ch) || (cc.ch == '.')) {
+               }
+
+               // Determine if the current state should terminate.
+               if (sc.state == SCE_C_OPERATOR) {
+                       sc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_C_DEFAULT);
+                       }
+               } else if (sc.state == SCE_C_IDENTIFIER) {
+                       if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
                                char s[100];
                                char s[100];
-                               cc.GetCurrent(s, sizeof(s));
+                               sc.GetCurrent(s, sizeof(s));
                                if (keywords.InList(s)) {
                                        lastWordWasUUID = strcmp(s, "uuid") == 0;
                                if (keywords.InList(s)) {
                                        lastWordWasUUID = strcmp(s, "uuid") == 0;
-                                       cc.ChangeState(SCE_C_WORD);
+                                       sc.ChangeState(SCE_C_WORD);
                                } else if (keywords2.InList(s)) {
                                } else if (keywords2.InList(s)) {
-                                       cc.ChangeState(SCE_C_WORD2);
+                                       sc.ChangeState(SCE_C_WORD2);
                                }
                                }
-                               cc.SetState(SCE_C_DEFAULT);
+                               sc.SetState(SCE_C_DEFAULT);
                        }
                        }
-               } if (cc.state == SCE_C_PREPROCESSOR) {
+               } else if (sc.state == SCE_C_PREPROCESSOR) {
                        if (stylingWithinPreprocessor) {
                        if (stylingWithinPreprocessor) {
-                               if (IsASpace(cc.ch)) {
-                                       cc.SetState(SCE_C_DEFAULT);
+                               if (IsASpace(sc.ch)) {
+                                       sc.SetState(SCE_C_DEFAULT);
                                }
                        } else {
                                }
                        } else {
-                               if (cc.atEOL && (cc.chPrev != '\\')) {
-                                       cc.SetState(SCE_C_DEFAULT);
+                               if (sc.atLineEnd) {
+                                       sc.SetState(SCE_C_DEFAULT);
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_COMMENT) {
-                       if (cc.Match('*', '/')) {
-                               cc.Forward();
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENT) {
+                       if (sc.Match('*', '/')) {
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       }
+               } else if (sc.state == SCE_C_COMMENTDOC) {
+                       if (sc.Match('*', '/')) {
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) {
+                               sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+                       } else if (sc.atLineEnd) {
+                               noDocChars = 0;
+                       } else if (!isspace(sc.ch) && (sc.ch != '*')) {
+                               noDocChars++;
                        }
                        }
-               } else if (cc.state == SCE_C_COMMENTDOC) {
-                       if (cc.Match('*', '/')) {
-                               cc.Forward();
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
+                       if (sc.atLineEnd) {
+                               sc.SetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
                        }
                        }
-               } else if (cc.state == SCE_C_COMMENTLINE || cc.state == SCE_C_COMMENTLINEDOC) {
-                       if (cc.ch == '\r' || cc.ch == '\n') {
-                               cc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_COMMENTDOCKEYWORD) {
+                       if (sc.Match('*', '/')) {
+                               sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (!IsADoxygenChar(sc.ch)) {
+                               char s[100];
+                               sc.GetCurrent(s, sizeof(s));
+                               if (!isspace(sc.ch) || !keywords3.InList(s+1)) {
+                                       sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+                               }
+                               sc.SetState(SCE_C_COMMENTDOC);
                        }
                        }
-               } else if (cc.state == SCE_C_STRING) {
-                       if (cc.ch == '\\') {
-                               if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_STRING) {
+                       if (sc.ch == '\\') {
+                               if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                                       sc.Forward();
                                }
                                }
-                       } else if (cc.ch == '\"') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
-                       } else if ((cc.atEOL) && (cc.chPrev != '\\')) {
-                               cc.ChangeState(SCE_C_STRINGEOL);
+                       } else if (sc.ch == '\"') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.atLineEnd) {
+                               sc.ChangeState(SCE_C_STRINGEOL);
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
                        }
                        }
-               } else if (cc.state == SCE_C_CHARACTER) {
-                       if ((cc.ch == '\r' || cc.ch == '\n') && (cc.chPrev != '\\')) {
-                               cc.ChangeState(SCE_C_STRINGEOL);
-                       } else if (cc.ch == '\\') {
-                               if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_CHARACTER) {
+                       if (sc.atLineEnd) {
+                               sc.ChangeState(SCE_C_STRINGEOL);
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                               visibleChars = 0;
+                       } else if (sc.ch == '\\') {
+                               if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                                       sc.Forward();
                                }
                                }
-                       } else if (cc.ch == '\'') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.ch == '\'') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
                        }
                        }
-               } else if (cc.state == SCE_C_REGEX) {
-                       if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == '/') {
-                               cc.ForwardSetState(SCE_C_DEFAULT);
-                       } else if (cc.ch == '\\') {
+               } else if (sc.state == SCE_C_REGEX) {
+                       if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == '/') {
+                               sc.ForwardSetState(SCE_C_DEFAULT);
+                       } else if (sc.ch == '\\') {
                                // Gobble up the quoted character
                                // Gobble up the quoted character
-                               if (cc.chNext == '\\' || cc.chNext == '/') {
-                                       cc.Forward();
+                               if (sc.chNext == '\\' || sc.chNext == '/') {
+                                       sc.Forward();
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_VERBATIM) {
-                       if (cc.ch == '\"') {
-                               if (cc.chNext == '\"') {
-                                       cc.Forward();
+               } else if (sc.state == SCE_C_VERBATIM) {
+                       if (sc.ch == '\"') {
+                               if (sc.chNext == '\"') {
+                                       sc.Forward();
                                } else {
                                } else {
-                                       cc.ForwardSetState(SCE_C_DEFAULT);
+                                       sc.ForwardSetState(SCE_C_DEFAULT);
                                }
                        }
                                }
                        }
-               } else if (cc.state == SCE_C_UUID) {
-                       if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == ')') {
-                               cc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_C_UUID) {
+                       if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
+                               sc.SetState(SCE_C_DEFAULT);
                        }
                }
 
                        }
                }
 
-               if (cc.state == SCE_C_DEFAULT) {
-                       if (cc.Match('@', '\"')) {
-                               cc.SetState(SCE_C_VERBATIM);
-                               cc.Forward();
-                       } else if (IsADigit(cc.ch) || (cc.ch == '.' && IsADigit(cc.chNext))) {
+               // Determine if a new state should be entered.
+               if (sc.state == SCE_C_DEFAULT) {
+                       if (sc.Match('@', '\"')) {
+                               sc.SetState(SCE_C_VERBATIM);
+                               sc.Forward();
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
                                if (lastWordWasUUID) {
                                if (lastWordWasUUID) {
-                                       cc.SetState(SCE_C_UUID);
+                                       sc.SetState(SCE_C_UUID);
                                        lastWordWasUUID = false;
                                } else {
                                        lastWordWasUUID = false;
                                } else {
-                                       cc.SetState(SCE_C_NUMBER);
+                                       sc.SetState(SCE_C_NUMBER);
                                }
                                }
-                       } else if (IsAWordStart(cc.ch) || (cc.ch == '@')) {
+                       } else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
                                if (lastWordWasUUID) {
                                if (lastWordWasUUID) {
-                                       cc.SetState(SCE_C_UUID);
+                                       sc.SetState(SCE_C_UUID);
                                        lastWordWasUUID = false;
                                } else {
                                        lastWordWasUUID = false;
                                } else {
-                                       cc.SetState(SCE_C_IDENTIFIER);
+                                       sc.SetState(SCE_C_IDENTIFIER);
                                }
                                }
-                       } else if (cc.Match('/', '*')) {
-                               if (cc.Match("/**") || cc.Match("/*!")) // Support of Qt/Doxygen doc. style
-                                       cc.SetState(SCE_C_COMMENTDOC);
-                               else
-                                       cc.SetState(SCE_C_COMMENT);
-                               cc.Forward();   // Eat the * so it isn't used for the end of the comment
-                       } else if (cc.Match('/', '/')) {
-                               if (cc.Match("///") || cc.Match("//!")) // Support of Qt/Doxygen doc. style
-                                       cc.SetState(SCE_C_COMMENTLINEDOC);
+                       } else if (sc.Match('/', '*')) {
+                               if (sc.Match("/**") || sc.Match("/*!")) {       // Support of Qt/Doxygen doc. style
+                                       noDocChars = 0;
+                                       sc.SetState(SCE_C_COMMENTDOC);
+                               } else {
+                                       sc.SetState(SCE_C_COMMENT);
+                               }
+                               sc.Forward();   // Eat the * so it isn't used for the end of the comment
+                       } else if (sc.Match('/', '/')) {
+                               if (sc.Match("///") || sc.Match("//!")) // Support of Qt/Doxygen doc. style
+                                       sc.SetState(SCE_C_COMMENTLINEDOC);
                                else
                                else
-                                       cc.SetState(SCE_C_COMMENTLINE);
-                       } else if (cc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
-                               cc.SetState(SCE_C_REGEX);
-                       } else if (cc.ch == '\"') {
-                               cc.SetState(SCE_C_STRING);
-                       } else if (cc.ch == '\'') {
-                               cc.SetState(SCE_C_CHARACTER);
-                       } else if (cc.ch == '#' && visibleChars == 0) {
+                                       sc.SetState(SCE_C_COMMENTLINE);
+                       } else if (sc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
+                               sc.SetState(SCE_C_REGEX);
+                       } else if (sc.ch == '\"') {
+                               sc.SetState(SCE_C_STRING);
+                       } else if (sc.ch == '\'') {
+                               sc.SetState(SCE_C_CHARACTER);
+                       } else if (sc.ch == '#' && visibleChars == 0) {
                                // Preprocessor commands are alone on their line
                                // Preprocessor commands are alone on their line
-                               cc.SetState(SCE_C_PREPROCESSOR);
+                               sc.SetState(SCE_C_PREPROCESSOR);
                                // Skip whitespace between # and preprocessor word
                                do {
                                // Skip whitespace between # and preprocessor word
                                do {
-                                       cc.Forward();
-                               } while (IsASpace(cc.ch) && cc.More());
-                       } else if (isoperator(static_cast<char>(cc.ch))) {
-                               cc.SetState(SCE_C_OPERATOR);
+                                       sc.Forward();
+                               } while ((sc.ch == ' ') && (sc.ch == '\t') && sc.More());
+                               if (sc.atLineEnd) {
+                                       sc.SetState(SCE_C_DEFAULT);
+                               }
+                       } else if (isoperator(static_cast<char>(sc.ch))) {
+                               sc.SetState(SCE_C_OPERATOR);
                        }
                }
                        }
                }
-               if (cc.atEOL) {
+               
+               if (sc.atLineEnd) {
                        // Reset states to begining of colourise so no surprises 
                        // if different sets of lines lexed.
                        chPrevNonWhite = ' ';
                        visibleChars = 0;
                        lastWordWasUUID = false;
                }
                        // Reset states to begining of colourise so no surprises 
                        // if different sets of lines lexed.
                        chPrevNonWhite = ' ';
                        visibleChars = 0;
                        lastWordWasUUID = false;
                }
-               if (!IsASpace(cc.ch)) {
-                       chPrevNonWhite = cc.ch;
+               if (!IsASpace(sc.ch)) {
+                       chPrevNonWhite = sc.ch;
                        visibleChars++;
                }
        }
                        visibleChars++;
                }
        }
-       cc.Complete();
+       sc.Complete();
 }
 
 static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
 }
 
 static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
diff --git a/src/stc/scintilla/src/LexCrontab.cxx b/src/stc/scintilla/src/LexCrontab.cxx
new file mode 100644 (file)
index 0000000..94a172c
--- /dev/null
@@ -0,0 +1,204 @@
+// Scintilla source code edit control
+/** @file LexCrontab.cxx
+ ** Lexer to use with extended crontab files used by a powerful
+ ** Windows scheduler/event monitor/automation manager nnCron.
+ ** (http://nemtsev.virtualave.net/)
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList
+*keywordLists[], Accessor &styler)
+{
+       int state = SCE_NNCRONTAB_DEFAULT;
+       char chNext = styler[startPos];
+       int lengthDoc = startPos + length;
+       // create a buffer large enough to take the largest chunk...
+       char *buffer = new char[length];
+       int bufferCount = 0;
+       // used when highliting environment variables inside quoted string:
+       bool insideString = false;
+
+       // this assumes that we have 3 keyword list in conf.properties
+       WordList &section = *keywordLists[0];
+       WordList &keyword = *keywordLists[1];
+       WordList &modifier = *keywordLists[2];
+
+       // go through all provided text segment
+       // using the hand-written state machine shown below
+       styler.StartAt(startPos);
+       styler.StartSegment(startPos);
+       for (int i = startPos; i < lengthDoc; i++) {
+               char ch = chNext;
+               chNext = styler.SafeGetCharAt(i + 1);
+
+               if (styler.IsLeadByte(ch)) {
+                       chNext = styler.SafeGetCharAt(i + 2);
+                       i++;
+                       continue;
+               }
+               switch(state) {
+                       case SCE_NNCRONTAB_DEFAULT:
+                               if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') {
+                                       // whitespace is simply ignored here...
+                                       styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT);
+                                       break;
+                               } else if( ch == '#' && styler.SafeGetCharAt(i+1) == '(') {
+                                       // signals the start of a task...
+                                       state = SCE_NNCRONTAB_TASK;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               }
+                                 else if( ch == '\\' && styler.SafeGetCharAt(i+1) == ' ') {
+                                       // signals the start of an extended comment...
+                                       state = SCE_NNCRONTAB_COMMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               } else if( ch == '#' ) {
+                                       // signals the start of a plain comment...
+                                       state = SCE_NNCRONTAB_COMMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               } else if( ch == ')' && styler.SafeGetCharAt(i+1) == '#') {
+                                       // signals the end of a task...
+                                       state = SCE_NNCRONTAB_TASK;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               } else if( ch == '"') {
+                                       state = SCE_NNCRONTAB_STRING;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_STRING);
+                               } else if( ch == '%') {
+                                       // signals environment variables
+                                       state = SCE_NNCRONTAB_ENVIRONMENT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT);
+                               } else if( ch == '*' ) {
+                                       // signals an asterisk
+                                       // no state jump necessary for this simple case...
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ASTERISK);
+                               } else if( isalpha(ch) || ch == '<' ) {
+                                       // signals the start of an identifier
+                                       bufferCount = 0;
+                                       buffer[bufferCount++] = ch;
+                                       state = SCE_NNCRONTAB_IDENTIFIER;
+                               } else if( isdigit(ch) ) {
+                                       // signals the start of a number
+                                       bufferCount = 0;
+                                       buffer[bufferCount++] = ch;
+                                       state = SCE_NNCRONTAB_NUMBER;
+                               } else {
+                                       // style it the default style..
+                                       styler.ColourTo(i,SCE_NNCRONTAB_DEFAULT);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_COMMENT:
+                               // if we find a newline here,
+                               // we simply go to default state
+                               // else continue to work on it...
+                               if( ch == '\n' || ch == '\r' ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               } else {
+                                       styler.ColourTo(i,SCE_NNCRONTAB_COMMENT);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_TASK:
+                               // if we find a newline here,
+                               // we simply go to default state
+                               // else continue to work on it...
+                               if( ch == '\n' || ch == '\r' ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               } else {
+                                       styler.ColourTo(i,SCE_NNCRONTAB_TASK);
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_STRING:
+                               if( ch == '%' ) {
+                                       state = SCE_NNCRONTAB_ENVIRONMENT;
+                                       insideString = true;
+                                       styler.ColourTo(i-1,SCE_NNCRONTAB_STRING);
+                                       break;
+                               }
+                               // if we find the end of a string char, we simply go to default state
+                               // else we're still dealing with an string...
+                               if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') ||
+                                       (ch == '\n') || (ch == '\r') ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                               }
+                               styler.ColourTo(i,SCE_NNCRONTAB_STRING);
+                               break;
+
+                       case SCE_NNCRONTAB_ENVIRONMENT:
+                               // if we find the end of a string char, we simply go to default state
+                               // else we're still dealing with an string...
+                               if( ch == '%' && insideString ) {
+                                       state = SCE_NNCRONTAB_STRING;
+                                       insideString = false;
+                                       break;
+                               }
+                               if( (ch == '%' && styler.SafeGetCharAt(i-1)!='\\')
+                                       || (ch == '\n') || (ch == '\r') ) {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       styler.ColourTo(i,SCE_NNCRONTAB_ENVIRONMENT);
+                                       break;
+                               }
+                               styler.ColourTo(i+1,SCE_NNCRONTAB_ENVIRONMENT);
+                               break;
+
+                       case SCE_NNCRONTAB_IDENTIFIER:
+                               // stay  in CONF_IDENTIFIER state until we find a non-alphanumeric
+                               if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') ||
+                                       (ch == '$') || (ch == '.') || (ch == '<') || (ch == '>') ) {
+                                       buffer[bufferCount++] = ch;
+                               } else {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       buffer[bufferCount] = '\0';
+
+                                       // check if the buffer contains a keyword,
+                                       // and highlight it if it is a keyword...
+                                       if(section.InList(buffer)) {
+                                               styler.ColourTo(i,SCE_NNCRONTAB_SECTION );
+                                       } else if(keyword.InList(buffer)) {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_KEYWORD );
+                                       } // else if(strchr(buffer,'/') || strchr(buffer,'.')) {
+                                       //      styler.ColourTo(i-1,SCE_NNCRONTAB_EXTENSION);
+                                       // }
+                                         else if(modifier.InList(buffer)) {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_MODIFIER );
+                                         }     else {
+                                               styler.ColourTo(i-1,SCE_NNCRONTAB_DEFAULT);
+                                       }
+                                       // push back the faulty character
+                                       chNext = styler[i--];
+                               }
+                               break;
+
+                       case SCE_NNCRONTAB_NUMBER:
+                               // stay  in CONF_NUMBER state until we find a non-numeric
+                               if( isdigit(ch) /* || ch == '.' */ ) {
+                                       buffer[bufferCount++] = ch;
+                               } else {
+                                       state = SCE_NNCRONTAB_DEFAULT;
+                                       buffer[bufferCount] = '\0';
+                                       // Colourize here... (normal number)
+                                       styler.ColourTo(i-1,SCE_NNCRONTAB_NUMBER);
+                                       // push back a character
+                                       chNext = styler[i--];
+                               }
+                               break;
+               }
+       }
+}
+
+LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");
index 1296fb24506c7787775d2776b5c4201dfedbd6da..64709432088517d56d133a79cd244c1596a4ac69 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
@@ -31,23 +32,6 @@ inline bool isEiffelOperator(unsigned int ch) {
                ch == '!' || ch == '@' || ch == '?';
 }
 
                ch == '!' || ch == '@' || ch == '?';
 }
 
-static void getRangeLowered(unsigned int start,
-               unsigned int end,
-               Accessor &styler,
-               char *s,
-               unsigned int len) {
-       unsigned int i = 0;
-       while ((i < end - start + 1) && (i < len-1)) {
-               s[i] = static_cast<char>(tolower(styler[start + i]));
-               i++;
-       }
-       s[i] = '\0';
-}
-
-inline bool IsASpace(unsigned int ch) {
-    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
-}
-
 inline bool IsAWordChar(unsigned int  ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
 inline bool IsAWordChar(unsigned int  ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
 }
@@ -56,81 +40,6 @@ inline bool IsAWordStart(unsigned int ch) {
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
        return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
-inline bool IsADigit(unsigned int ch) {
-       return (ch >= '0') && (ch <= '9');
-}
-
-// All languages handled so far can treat all characters >= 0x80 as one class
-// which just continues the current token or starts an identifier if in default.
-// DBCS treated specially as the second character can be < 0x80 and hence 
-// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
-class xColouriseContext {
-       Accessor &styler;
-       int lengthDoc;
-       int currentPos;
-       xColouriseContext& operator=(const xColouriseContext&) {
-               return *this;
-       }
-public:
-       int state;
-       unsigned int chPrev;
-       unsigned int ch;
-       unsigned int chNext;
-
-       xColouriseContext(unsigned int startPos, int length,
-                        int initStyle, Accessor &styler_) : 
-               styler(styler_),
-               lengthDoc(startPos + length),
-               currentPos(startPos), 
-               state(initStyle), 
-               chPrev(0),
-               ch(0), 
-               chNext(0) {
-               styler.StartAt(startPos);
-               styler.StartSegment(startPos);
-               int pos = currentPos;
-               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               if (styler.IsLeadByte(static_cast<char>(ch))) {
-                       pos++;
-                       ch = ch << 8;
-                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
-               }
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
-               }
-       }
-       void Complete() {
-               styler.ColourTo(currentPos - 1, state);
-       }
-       bool More() {
-               return currentPos <= lengthDoc;
-       }
-       void Forward() {
-               chPrev = ch;
-               currentPos++;
-               if (ch >= 0x100)
-                       currentPos++;
-               ch = chNext;
-               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
-               if (styler.IsLeadByte(static_cast<char>(chNext))) {
-                       chNext = chNext << 8;
-                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
-               }
-       }
-       void ChangeState(int state_) {
-               state = state_;
-       }
-       void SetState(int state_) {
-               styler.ColourTo(currentPos - 1, state);
-               state = state_;
-       }
-       void GetCurrentLowered(char *s, int len) {
-               getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-       }
-};
-
 static void ColouriseEiffelDoc(unsigned int startPos,
                             int length,
                             int initStyle,
 static void ColouriseEiffelDoc(unsigned int startPos,
                             int length,
                             int initStyle,
@@ -139,68 +48,68 @@ static void ColouriseEiffelDoc(unsigned int startPos,
 
        WordList &keywords = *keywordlists[0];
 
 
        WordList &keywords = *keywordlists[0];
 
-       xColouriseContext lc(startPos, length, initStyle, styler);
+       StyleContext sc(startPos, length, initStyle, styler);
 
 
-       for (; lc.More(); lc.Forward()) {
+       for (; sc.More(); sc.Forward()) {
 
 
-               if (lc.state == SCE_EIFFEL_STRINGEOL) {
-                       if (lc.ch != '\r' && lc.ch != '\n') {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               if (sc.state == SCE_EIFFEL_STRINGEOL) {
+                       if (sc.ch != '\r' && sc.ch != '\n') {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_OPERATOR) {
-                       lc.SetState(SCE_EIFFEL_DEFAULT);
-               } else if (lc.state == SCE_EIFFEL_WORD) {
-                       if (!IsAWordChar(lc.ch)) {
+               } else if (sc.state == SCE_EIFFEL_OPERATOR) {
+                       sc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_WORD) {
+                       if (!IsAWordChar(sc.ch)) {
                                char s[100];
                                char s[100];
-                               lc.GetCurrentLowered(s, sizeof(s));
+                               sc.GetCurrentLowered(s, sizeof(s));
                                if (!keywords.InList(s)) {
                                if (!keywords.InList(s)) {
-                                       lc.ChangeState(SCE_EIFFEL_IDENTIFIER);
+                                       sc.ChangeState(SCE_EIFFEL_IDENTIFIER);
                                }
                                }
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_NUMBER) {
-                       if (!IsAWordChar(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_COMMENTLINE) {
-                       if (lc.ch == '\r' || lc.ch == '\n') {
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_COMMENTLINE) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_STRING) {
-                       if (lc.ch == '%') {
-                               lc.Forward();
-                       } else if (lc.ch == '\"') {
-                               lc.Forward();
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_STRING) {
+                       if (sc.ch == '%') {
+                               sc.Forward();
+                       } else if (sc.ch == '\"') {
+                               sc.Forward();
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                        }
-               } else if (lc.state == SCE_EIFFEL_CHARACTER) {
-                       if (lc.ch == '\r' || lc.ch == '\n') {
-                               lc.SetState(SCE_EIFFEL_STRINGEOL);
-                       } else if (lc.ch == '%') {
-                               lc.Forward();
-                       } else if (lc.ch == '\'') {
-                               lc.Forward();
-                               lc.SetState(SCE_EIFFEL_DEFAULT);
+               } else if (sc.state == SCE_EIFFEL_CHARACTER) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_EIFFEL_STRINGEOL);
+                       } else if (sc.ch == '%') {
+                               sc.Forward();
+                       } else if (sc.ch == '\'') {
+                               sc.Forward();
+                               sc.SetState(SCE_EIFFEL_DEFAULT);
                        }
                }
 
                        }
                }
 
-               if (lc.state == SCE_EIFFEL_DEFAULT) {
-                       if (lc.ch == '-' && lc.chNext == '-') {
-                               lc.SetState(SCE_EIFFEL_COMMENTLINE);
-                       } else if (lc.ch == '\"') {
-                               lc.SetState(SCE_EIFFEL_STRING);
-                       } else if (lc.ch == '\'') {
-                               lc.SetState(SCE_EIFFEL_CHARACTER);
-                       } else if (IsADigit(lc.ch) || (lc.ch == '.')) {
-                               lc.SetState(SCE_EIFFEL_NUMBER);
-                       } else if (IsAWordStart(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_WORD);
-                       } else if (isEiffelOperator(lc.ch)) {
-                               lc.SetState(SCE_EIFFEL_OPERATOR);
+               if (sc.state == SCE_EIFFEL_DEFAULT) {
+                       if (sc.ch == '-' && sc.chNext == '-') {
+                               sc.SetState(SCE_EIFFEL_COMMENTLINE);
+                       } else if (sc.ch == '\"') {
+                               sc.SetState(SCE_EIFFEL_STRING);
+                       } else if (sc.ch == '\'') {
+                               sc.SetState(SCE_EIFFEL_CHARACTER);
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.')) {
+                               sc.SetState(SCE_EIFFEL_NUMBER);
+                       } else if (IsAWordStart(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_WORD);
+                       } else if (isEiffelOperator(sc.ch)) {
+                               sc.SetState(SCE_EIFFEL_OPERATOR);
                        }
                }
        }
                        }
                }
        }
-       lc.Complete();
+       sc.Complete();
 }
 
 static bool IsEiffelComment(Accessor &styler, int pos, int len) {
 }
 
 static bool IsEiffelComment(Accessor &styler, int pos, int len) {
index c28a43279544eaa2d76ac4a27927d51a4ccc9c34..3a03096f8ae42c02133aefca468166db43db8f3d 100644 (file)
@@ -1,7 +1,7 @@
 // Scintilla source code edit control
 /** @file LexHTML.cxx
  ** Lexer for HTML.
 // Scintilla source code edit control
 /** @file LexHTML.cxx
  ** Lexer for HTML.
- **/
+ **/ 
 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
 #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
 
 #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
 #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
 
-enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML };
+enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
 enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
 
 static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
        char s[30 + 1];
 enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
 
 static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
        char s[30 + 1];
-       s[0] = '\0';
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = static_cast<char>(tolower(styler[start + i]));
                s[i] = static_cast<char>(tolower(styler[start + i]));
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
        if (strstr(s, "src"))   // External script
                return eScriptNone;
        //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
        if (strstr(s, "src"))   // External script
                return eScriptNone;
@@ -55,11 +55,11 @@ static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigne
 static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) {
        int iResult = 0;
        char s[30 + 1];
 static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) {
        int iResult = 0;
        char s[30 + 1];
-       s[0] = '\0';
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = static_cast<char>(tolower(styler[start + i]));
                s[i] = static_cast<char>(tolower(styler[start + i]));
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        if (0 == strncmp(s, "php", 3)) {
                iResult = 3;
        }
        if (0 == strncmp(s, "php", 3)) {
                iResult = 3;
        }
@@ -68,22 +68,21 @@ static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, u
 }
 
 static int ScriptOfState(int state) {
 }
 
 static int ScriptOfState(int state) {
-       int scriptLanguage;
-
        if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
        if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
-               scriptLanguage = eScriptPython;
+               return eScriptPython;
        } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
        } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
-               scriptLanguage = eScriptVBS;
+               return eScriptVBS;
        } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
        } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
-               scriptLanguage = eScriptJS;
+               return eScriptJS;
        } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
        } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
-               scriptLanguage = eScriptPHP;
+               return eScriptPHP;
+       } else if ((state >= SCE_H_SGML_DEFAULT) && (state <= SCE_H_SGML_BLOCK_DEFAULT)) {
+               return eScriptSGML;
+       } else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
+               return eScriptSGMLblock;
        } else {
        } else {
-               //              scriptLanguage = defaultScript;
-               scriptLanguage = eScriptNone;
+               return eScriptNone;
        }
        }
-
-       return scriptLanguage;
 }
 
 static int statePrintForState(int state, int inScriptType) {
 }
 
 static int statePrintForState(int state, int inScriptType) {
@@ -174,11 +173,11 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
                chAttr = SCE_H_NUMBER;
        } else {
                char s[30 + 1];
                chAttr = SCE_H_NUMBER;
        } else {
                char s[30 + 1];
-               s[0] = '\0';
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = static_cast<char>(tolower(styler[start + i]));
                        s[i] = static_cast<char>(tolower(styler[start + i]));
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_H_ATTRIBUTE;
        }
                if (keywords.InList(s))
                        chAttr = SCE_H_ATTRIBUTE;
        }
@@ -195,18 +194,14 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
        unsigned int i = 0;
        for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
                char ch = styler[cPos];
        unsigned int i = 0;
        for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
                char ch = styler[cPos];
-               if (ch != '<')
+               if ((ch != '<') && (ch != '/'))
                        s[i++] = static_cast<char>(tolower(ch));
        }
        s[i] = '\0';
        bool isScript = false;
        char chAttr = SCE_H_TAGUNKNOWN;
                        s[i++] = static_cast<char>(tolower(ch));
        }
        s[i] = '\0';
        bool isScript = false;
        char chAttr = SCE_H_TAGUNKNOWN;
-       if (s[0] == '!' && s[1] == '-' && s[2] == '-') {        //Comment
-               chAttr = SCE_H_COMMENT;
-       } else if (strcmp(s, "![cdata[") == 0) {        // In lower case because already converted
-               chAttr = SCE_H_CDATA;
-       } else if (s[0] == '!') {
-               chAttr = SCE_H_SGML;
+       if (s[0] == '!') {
+               chAttr = SCE_H_SGML_DEFAULT;
        } else if (s[0] == '/') {       // Closing tag
                if (keywords.InList(s + 1))
                        chAttr = SCE_H_TAG;
        } else if (s[0] == '/') {       // Closing tag
                if (keywords.InList(s + 1))
                        chAttr = SCE_H_TAG;
@@ -231,10 +226,11 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
                chAttr = SCE_HJ_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HJ_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = styler[start + i];
                        s[i] = styler[start + i];
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_HJ_KEYWORD;
        }
                if (keywords.InList(s))
                        chAttr = SCE_HJ_KEYWORD;
        }
@@ -248,10 +244,11 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
                chAttr = SCE_HB_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HB_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = static_cast<char>(tolower(styler[start + i]));
                        s[i] = static_cast<char>(tolower(styler[start + i]));
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s)) {
                        chAttr = SCE_HB_WORD;
                        if (strcmp(s, "rem") == 0)
                if (keywords.InList(s)) {
                        chAttr = SCE_HB_WORD;
                        if (strcmp(s, "rem") == 0)
@@ -268,10 +265,11 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
 static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
        bool wordIsNumber = isdigit(styler[start]);
        char s[30 + 1];
 static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
        bool wordIsNumber = isdigit(styler[start]);
        char s[30 + 1];
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
                s[i] = styler[start + i];
                s[i] = styler[start + i];
-               s[i + 1] = '\0';
        }
        }
+       s[i] = '\0';
        char chAttr = SCE_HP_IDENTIFIER;
        if (0 == strcmp(prevWord, "class"))
                chAttr = SCE_HP_CLASSNAME;
        char chAttr = SCE_HP_IDENTIFIER;
        if (0 == strcmp(prevWord, "class"))
                chAttr = SCE_HP_CLASSNAME;
@@ -294,16 +292,37 @@ static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &ke
                chAttr = SCE_HPHP_NUMBER;
        else {
                char s[30 + 1];
                chAttr = SCE_HPHP_NUMBER;
        else {
                char s[30 + 1];
-               for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+               unsigned int i = 0;
+               for (; i < end - start + 1 && i < 30; i++) {
                        s[i] = styler[start + i];
                        s[i] = styler[start + i];
-                       s[i + 1] = '\0';
                }
                }
+               s[i] = '\0';
                if (keywords.InList(s))
                        chAttr = SCE_HPHP_WORD;
        }
        styler.ColourTo(end, chAttr);
 }
 
                if (keywords.InList(s))
                        chAttr = SCE_HPHP_WORD;
        }
        styler.ColourTo(end, chAttr);
 }
 
+static bool isWordHSGML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
+       char s[30 + 1];
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
+               s[i] = styler[start + i];
+       }
+       s[i] = '\0';
+       return keywords.InList(s);
+}
+
+static bool isWordCdata(unsigned int start, unsigned int end, Accessor &styler) {
+       char s[30 + 1];
+       unsigned int i = 0;
+       for (; i < end - start + 1 && i < 30; i++) {
+               s[i] = styler[start + i];
+       }
+       s[i] = '\0';
+       return (0 == strcmp(s, "[CDATA["));
+}
+
 // Return the first state to reach when entering a scripting language
 static int StateForScript(int scriptLanguage) {
        int Result;
 // Return the first state to reach when entering a scripting language
 static int StateForScript(int scriptLanguage) {
        int Result;
@@ -320,6 +339,9 @@ static int StateForScript(int scriptLanguage) {
        case eScriptXML:
                Result = SCE_H_TAGUNKNOWN;
                break;
        case eScriptXML:
                Result = SCE_H_TAGUNKNOWN;
                break;
+       case eScriptSGML:
+               Result = SCE_H_SGML_DEFAULT;
+               break;
        default :
                Result = SCE_HJ_START;
                break;
        default :
                Result = SCE_HJ_START;
                break;
@@ -331,6 +353,10 @@ inline bool ishtmlwordchar(char ch) {
        return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
 }
 
        return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
 }
 
+inline bool issgmlwordchar(char ch) {
+       return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
+}
+
 static bool InTagState(int state) {
        return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN ||
               state == SCE_H_SCRIPT ||
 static bool InTagState(int state) {
        return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN ||
               state == SCE_H_SCRIPT ||
@@ -339,6 +365,10 @@ static bool InTagState(int state) {
               state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
 }
 
               state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
 }
 
+static bool IsCommentState(const int state) {
+       return state == SCE_H_COMMENT || state == SCE_H_SGML_COMMENT;
+}
+
 static bool isLineEnd(char ch) {
        return ch == '\r' || ch == '\n';
 }
 static bool isLineEnd(char ch) {
        return ch == '\r' || ch == '\n';
 }
@@ -348,23 +378,23 @@ static bool isOKBeforeRE(char ch) {
 }
 
 static bool isPHPStringState(int state) {
 }
 
 static bool isPHPStringState(int state) {
-       return 
-               (state == SCE_HPHP_HSTRING) ||
-               (state == SCE_HPHP_SIMPLESTRING) ||
-               (state == SCE_HPHP_HSTRING_VARIABLE);
+       return
+           (state == SCE_HPHP_HSTRING) ||
+           (state == SCE_HPHP_SIMPLESTRING) ||
+           (state == SCE_HPHP_HSTRING_VARIABLE);
 }
 
 static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
 }
 
 static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
-
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
        WordList &keywords3 = *keywordlists[2];
        WordList &keywords4 = *keywordlists[3];
        WordList &keywords5 = *keywordlists[4];
        WordList &keywords = *keywordlists[0];
        WordList &keywords2 = *keywordlists[1];
        WordList &keywords3 = *keywordlists[2];
        WordList &keywords4 = *keywordlists[3];
        WordList &keywords5 = *keywordlists[4];
+       WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
 
        // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
 
        // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
-       styler.StartAt(startPos, 127);
+       styler.StartAt(startPos, STYLE_MAX);
        char prevWord[200];
        prevWord[0] = '\0';
        int StateToPrint = initStyle;
        char prevWord[200];
        prevWord[0] = '\0';
        int StateToPrint = initStyle;
@@ -374,49 +404,51 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
        if (InTagState(state)) {
                while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
                        startPos--;
        if (InTagState(state)) {
                while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
                        startPos--;
-            length++;
+                       length++;
                }
                state = SCE_H_DEFAULT;
        }
                }
                state = SCE_H_DEFAULT;
        }
-       styler.StartAt(startPos, 127);
+       styler.StartAt(startPos, STYLE_MAX);
 
 
-       int lineState = eScriptVBS;
        int lineCurrent = styler.GetLine(startPos);
        int lineCurrent = styler.GetLine(startPos);
-       if (lineCurrent > 0)
+       int lineState;
+       if (lineCurrent > 0) {
                lineState = styler.GetLineState(lineCurrent);
                lineState = styler.GetLineState(lineCurrent);
-       int inScriptType  = (lineState >> 0) & 0x03; // 2 bits of scripting type
-       bool tagOpened    = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
-       bool tagClosing   = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
-       int defaultScript = (lineState >> 4) & 0x0F; // 4 bits of script name
-       int beforePreProc = (lineState >> 8) & 0xFF; // 8 bits of state
+       } else {
+               // Default client and ASP scripting language is JavaScript
+               lineState = eScriptJS << 8;
+               lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
+       }
+       int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
+       bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
+       bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
+       int aspScript = (lineState >> 4) & 0x0F; // 4 bits of script name
+       int clientScript = (lineState >> 8) & 0x0F; // 4 bits of script name
+       int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
 
        int scriptLanguage = ScriptOfState(state);
 
 
        int scriptLanguage = ScriptOfState(state);
 
-       bool fold = styler.GetPropertyInt("fold");
-       bool foldHTML = styler.GetPropertyInt("fold.html",0);
-       bool foldCompact = styler.GetPropertyInt("fold.compact",1);
-
-       fold = foldHTML && fold;
+       const bool foldHTML = styler.GetPropertyInt("fold.html", 0);
+       const bool fold = foldHTML && styler.GetPropertyInt("fold");
+       const bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
 
        int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
        int levelCurrent = levelPrev;
 
        int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
        int levelCurrent = levelPrev;
-       int visibleChars;
-
-       visibleChars = 0;
+       int visibleChars = 0;
 
        char chPrev = ' ';
        char ch = ' ';
        char chPrevNonWhite = ' ';
        styler.StartSegment(startPos);
 
        char chPrev = ' ';
        char ch = ' ';
        char chPrevNonWhite = ' ';
        styler.StartSegment(startPos);
-       int lengthDoc = startPos + length;
+       const int lengthDoc = startPos + length;
        for (int i = startPos; i < lengthDoc; i++) {
        for (int i = startPos; i < lengthDoc; i++) {
-               char chPrev2 = chPrev;
+               const char chPrev2 = chPrev;
                chPrev = ch;
                if (ch != ' ' && ch != '\t')
                        chPrevNonWhite = ch;
                ch = styler[i];
                char chNext = styler.SafeGetCharAt(i + 1);
                chPrev = ch;
                if (ch != ' ' && ch != '\t')
                        chPrevNonWhite = ch;
                ch = styler[i];
                char chNext = styler.SafeGetCharAt(i + 1);
-               char chNext2 = styler.SafeGetCharAt(i + 2);
+               const char chNext2 = styler.SafeGetCharAt(i + 2);
 
                // Handle DBCS codepages
                if (styler.IsLeadByte(ch)) {
 
                // Handle DBCS codepages
                if (styler.IsLeadByte(ch)) {
@@ -451,18 +483,21 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                        } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
                                                // check if the number of tabs is lower than the level
                                                int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8;
                                        } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
                                                // check if the number of tabs is lower than the level
                                                int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8;
-                                               for (int j = 0;Findlevel > 0;j++) {
+                                               for (int j = 0; Findlevel > 0; j++) {
                                                        char chTmp = styler.SafeGetCharAt(i + j + 1);
                                                        if (chTmp == '\t') {
                                                                Findlevel -= 8;
                                                        char chTmp = styler.SafeGetCharAt(i + j + 1);
                                                        if (chTmp == '\t') {
                                                                Findlevel -= 8;
-                                                       }       else if (chTmp == ' ') {
+                                                       } else if (chTmp == ' ') {
                                                                Findlevel--;
                                                                Findlevel--;
-                                                       }       else break;
+                                                       } else {
+                                                               break;
+                                                       }
                                                }
 
                                                if (Findlevel > 0) {
                                                        levelCurrent -= Findlevel / 8;
                                                }
 
                                                if (Findlevel > 0) {
                                                        levelCurrent -= Findlevel / 8;
-                                                       if (Findlevel % 8) levelCurrent--;
+                                                       if (Findlevel % 8)
+                                                               levelCurrent--;
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -487,11 +522,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        }
                        lineCurrent++;
                        styler.SetLineState(lineCurrent,
                        }
                        lineCurrent++;
                        styler.SetLineState(lineCurrent,
-                                           ((inScriptType  & 0x03) << 0) |
-                                                               ((tagOpened     & 0x01) << 2) |
-                                                               ((tagClosing    & 0x01) << 3) |
-                                           ((defaultScript & 0x0F) << 4) |
-                                           ((beforePreProc & 0xFF) << 8));
+                                           ((inScriptType & 0x03) << 0) |
+                                           ((tagOpened & 0x01) << 2) |
+                                           ((tagClosing & 0x01) << 3) |
+                                           ((aspScript & 0x0F) << 4) |
+                                           ((clientScript & 0x0F) << 8) |
+                                           ((beforePreProc & 0xFF) << 12));
                }
 
                // generic end of script processing
                }
 
                // generic end of script processing
@@ -503,9 +539,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        case SCE_H_SINGLESTRING:
                        case SCE_HJ_COMMENT:
                        case SCE_HJ_COMMENTDOC:
                        case SCE_H_SINGLESTRING:
                        case SCE_HJ_COMMENT:
                        case SCE_HJ_COMMENTDOC:
-                       // SCE_HJ_COMMENTLINE removed as this is a common thing done to hide
-                       // the end of script marker from some JS interpreters.
-                       //case SCE_HJ_COMMENTLINE:
+                               // SCE_HJ_COMMENTLINE removed as this is a common thing done to hide
+                               // the end of script marker from some JS interpreters.
+                               //case SCE_HJ_COMMENTLINE:
                        case SCE_HJ_DOUBLESTRING:
                        case SCE_HJ_SINGLESTRING:
                        case SCE_HB_STRING:
                        case SCE_HJ_DOUBLESTRING:
                        case SCE_HJ_SINGLESTRING:
                        case SCE_HB_STRING:
@@ -514,29 +550,31 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        case SCE_HP_TRIPLEDOUBLE:
                                break;
                        default :
                        case SCE_HP_TRIPLEDOUBLE:
                                break;
                        default :
-                               // maybe we should check here if it's a tag and if it's SCRIPT
+                               // closing tag of the script (it's a closing HTML tag anyway)
                                styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_H_TAGUNKNOWN;
                                inScriptType = eHtml;
                                scriptLanguage = eScriptNone;
                                styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_H_TAGUNKNOWN;
                                inScriptType = eHtml;
                                scriptLanguage = eScriptNone;
+                               clientScript = eScriptJS;
                                i += 2;
                                i += 2;
-                               // unfold closing script
-                               levelCurrent--;
+                               visibleChars += 2;
+                               tagClosing = true;
                                continue;
                        }
                }
 
                /////////////////////////////////////
                // handle the start of PHP pre-processor = Non-HTML
                                continue;
                        }
                }
 
                /////////////////////////////////////
                // handle the start of PHP pre-processor = Non-HTML
-               else if ((state != SCE_H_ASPAT) && 
-                               !isPHPStringState(state) && 
-                               (state != SCE_HPHP_COMMENT) && 
-                               (ch == '<') && 
-                               (chNext == '?')) {
+               else if ((state != SCE_H_ASPAT) &&
+                        !isPHPStringState(state) &&
+                        (state != SCE_HPHP_COMMENT) &&
+                        (ch == '<') &&
+                        (chNext == '?')) {
                        styler.ColourTo(i - 1, StateToPrint);
                        beforePreProc = state;
                        scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
                        i++;
                        styler.ColourTo(i - 1, StateToPrint);
                        beforePreProc = state;
                        scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
                        i++;
+                       visibleChars++;
                        i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 10);
                        if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLSTART);
                        i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 10);
                        if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLSTART);
@@ -567,6 +605,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
                        if (chNext2 == '@') {
                                i += 2; // place as if it was the second next char treated
 
                        if (chNext2 == '@') {
                                i += 2; // place as if it was the second next char treated
+                               visibleChars += 2;
                                state = SCE_H_ASPAT;
                        } else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
                                styler.ColourTo(i + 3, SCE_H_ASP);
                                state = SCE_H_ASPAT;
                        } else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
                                styler.ColourTo(i + 3, SCE_H_ASP);
@@ -576,11 +615,13 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        } else {
                                if (chNext2 == '=') {
                                        i += 2; // place as if it was the second next char treated
                        } else {
                                if (chNext2 == '=') {
                                        i += 2; // place as if it was the second next char treated
+                                       visibleChars += 2;
                                } else {
                                        i++; // place as if it was the next char treated
                                } else {
                                        i++; // place as if it was the next char treated
+                                       visibleChars++;
                                }
 
                                }
 
-                               state = StateForScript(defaultScript);
+                               state = StateForScript(aspScript);
                        }
                        scriptLanguage = eScriptVBS;
                        styler.ColourTo(i, SCE_H_ASP);
                        }
                        scriptLanguage = eScriptVBS;
                        styler.ColourTo(i, SCE_H_ASP);
@@ -591,17 +632,42 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        continue;
                }
 
                        continue;
                }
 
+               /////////////////////////////////////
+               // handle the start of SGML language (DTD)
+               else if (((scriptLanguage == eScriptNone) || (scriptLanguage == eScriptXML)) &&
+                        (chPrev == '<') &&
+                        (ch == '!') &&
+                        (StateToPrint != SCE_H_CDATA) && (!IsCommentState(StateToPrint))) {
+                       beforePreProc = state;
+                       styler.ColourTo(i - 2, StateToPrint);
+                       if ((chNext == '-') && (chNext2 == '-')) {
+                               state = SCE_H_COMMENT; // wait for a pending command
+                       }
+                       else if (isWordCdata(i + 1, i + 7, styler)) {
+                               state = SCE_H_CDATA;
+                       } else {
+                               styler.ColourTo(i, SCE_H_SGML_DEFAULT); // <! is default
+                               scriptLanguage = eScriptSGML;
+                               state = SCE_H_SGML_COMMAND; // wait for a pending command
+                       }
+                       // fold whole tag (-- when closing the tag)
+
+                       levelCurrent++;
+                       continue;
+               }
+
                // handle the end of a pre-processor = Non-HTML
                // handle the end of a pre-processor = Non-HTML
-               else if (
-                       ((inScriptType == eNonHtmlPreProc)
-                               || (inScriptType == eNonHtmlScriptPreProc)) && (
-                               ((scriptLanguage == eScriptPHP) && (ch == '?') && !isPHPStringState(state) && (state != SCE_HPHP_COMMENT)) || 
-                               ((scriptLanguage != eScriptNone) && !isStringState(state) &&
-                                (ch == '%'))
-                       ) && (chNext == '>')) {
+               else if ((
+                            ((inScriptType == eNonHtmlPreProc)
+                             || (inScriptType == eNonHtmlScriptPreProc)) && (
+                                ((scriptLanguage == eScriptPHP) && (ch == '?') && !isPHPStringState(state) && (state != SCE_HPHP_COMMENT)) ||
+                                ((scriptLanguage != eScriptNone) && !isStringState(state) &&
+                                 (ch == '%'))
+                            ) && (chNext == '>')) ||
+                        ((scriptLanguage == eScriptSGML) && (ch == '>') && (state != SCE_H_SGML_COMMENT))) {
                        if (state == SCE_H_ASPAT) {
                        if (state == SCE_H_ASPAT) {
-                               defaultScript = segIsScriptingIndicator(styler,
-                                       styler.GetStartSegment(), i - 1, defaultScript);
+                               aspScript = segIsScriptingIndicator(styler,
+                                                                   styler.GetStartSegment(), i - 1, aspScript);
                        }
                        // Bounce out of any ASP mode
                        switch (state) {
                        }
                        // Bounce out of any ASP mode
                        switch (state) {
@@ -624,11 +690,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                styler.ColourTo(i - 1, StateToPrint);
                                break;
                        }
                                styler.ColourTo(i - 1, StateToPrint);
                                break;
                        }
-                       i++;
+                       if (scriptLanguage != eScriptSGML) {
+                               i++;
+                               visibleChars++;
+                       }
                        if (ch == '%')
                                styler.ColourTo(i, SCE_H_ASP);
                        else if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLEND);
                        if (ch == '%')
                                styler.ColourTo(i, SCE_H_ASP);
                        else if (scriptLanguage == eScriptXML)
                                styler.ColourTo(i, SCE_H_XMLEND);
+                       else if (scriptLanguage == eScriptSGML)
+                               styler.ColourTo(i, SCE_H_SGML_DEFAULT);
                        else
                                styler.ColourTo(i, SCE_H_QUESTION);
                        state = beforePreProc;
                        else
                                styler.ColourTo(i, SCE_H_QUESTION);
                        state = beforePreProc;
@@ -648,47 +719,156 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (ch == '<') {
                                // in HTML, fold on tag open and unfold on tag close
                                tagOpened = true;
                        if (ch == '<') {
                                // in HTML, fold on tag open and unfold on tag close
                                tagOpened = true;
-                               if (chNext == '/') {
-                                       tagClosing = true;
-                               } else {
-                                       tagClosing = false;
-                               }
-
+                               tagClosing = (chNext == '/');
                                styler.ColourTo(i - 1, StateToPrint);
                                styler.ColourTo(i - 1, StateToPrint);
-                               if (chNext == '!' && chNext2 == '-' && styler.SafeGetCharAt(i + 3) == '-') {
-                                       // should be better
-                                       i += 3;
-                                       levelCurrent++;
-                                       state = SCE_H_COMMENT;
-                               } else
+                               if (chNext != '!')
                                        state = SCE_H_TAGUNKNOWN;
                        } else if (ch == '&') {
                                styler.ColourTo(i - 1, SCE_H_DEFAULT);
                                state = SCE_H_ENTITY;
                        }
                        break;
                                        state = SCE_H_TAGUNKNOWN;
                        } else if (ch == '&') {
                                styler.ColourTo(i - 1, SCE_H_DEFAULT);
                                state = SCE_H_ENTITY;
                        }
                        break;
-               case SCE_H_COMMENT:
-                       if ((ch == '>') && (chPrev == '-') && (chPrev2 == '-')) {
-                               // unfold HTML comment
-                               levelCurrent--;
+               case SCE_H_SGML_DEFAULT:
+                       if (scriptLanguage == eScriptSGMLblock)
+                               StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
+
+                       if (ch == '\"') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_DOUBLESTRING;
+                       } else if (ch == '\'') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_SIMPLESTRING;
+                       } else if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       } else if (isalpha(ch) && (chPrev == '%')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_ENTITY;
+                       } else if (ch == '#') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               state = SCE_H_SGML_SPECIAL;
+                       } else if (ch == '[') {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               scriptLanguage = eScriptSGMLblock;
+                       } else if (ch == ']') {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i, StateToPrint);
+                                       scriptLanguage = eScriptSGML;
+                               } else {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_ERROR);
+                               }
+                       } else if (scriptLanguage == eScriptSGMLblock) {
+                               if ((ch == '!') && (chPrev == '<')) {
+                                       styler.ColourTo(i - 2, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_DEFAULT);
+                                       state = SCE_H_SGML_COMMAND;
+                               } else if (ch == '>') {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       styler.ColourTo(i, SCE_H_SGML_DEFAULT);
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_COMMAND:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       } else if (!issgmlwordchar(ch)) {
+                               if (isWordHSGML(styler.GetStartSegment(), i - 1, keywords6, styler)) {
+                                       styler.ColourTo(i - 1, StateToPrint);
+                                       state = SCE_H_SGML_1ST_PARAM;
+                               } else {
+                                       state = SCE_H_SGML_ERROR;
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_1ST_PARAM:
+                       // wait for the beginning of the word
+                       if ((ch == '-') && (chPrev == '-')) {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i - 2, SCE_H_SGML_BLOCK_DEFAULT);
+                               } else {
+                                       styler.ColourTo(i - 2, SCE_H_SGML_DEFAULT);
+                               }
+                               state = SCE_H_SGML_1ST_PARAM_COMMENT;
+                       } else if (issgmlwordchar(ch)) {
+                               if (scriptLanguage == eScriptSGMLblock) {
+                                       styler.ColourTo(i - 1, SCE_H_SGML_BLOCK_DEFAULT);
+                               } else {
+                                       styler.ColourTo(i - 1, SCE_H_SGML_DEFAULT);
+                               }
+                               // find the length of the word
+                               int size = 1;
+                               while (ishtmlwordchar(styler.SafeGetCharAt(i + size)))
+                                       size++;
+                               styler.ColourTo(i + size - 1, StateToPrint);
+                               i += size - 1;
+                               visibleChars += size - 1;
+                               ch = styler.SafeGetCharAt(i);
+                               state = SCE_H_SGML_DEFAULT;
+                               continue;
+                       }
+                       break;
+               case SCE_H_SGML_ERROR:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i - 2, StateToPrint);
+                               state = SCE_H_SGML_COMMENT;
+                       }
+               case SCE_H_SGML_DOUBLESTRING:
+                       if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
                                styler.ColourTo(i, StateToPrint);
-                               state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               state = SCE_H_SGML_DEFAULT;
+                       }
+                       break;
+               case SCE_H_SGML_SIMPLESTRING:
+                       if (ch == '\'') {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
+                       }
+                       break;
+               case SCE_H_SGML_COMMENT:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
                        }
                        break;
                case SCE_H_CDATA:
                        }
                        break;
                case SCE_H_CDATA:
-                       if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) {
+                       if ((chPrev2 == ']') && (chPrev == ']') && (ch == '>')) {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               levelCurrent--;
                        }
                        break;
                        }
                        break;
-               case SCE_H_SGML:
-                       if (ch == '>') {
-                               levelCurrent--;
+               case SCE_H_COMMENT:
+                       if ((chPrev2 == '-') && (chPrev == '-') && (ch == '>')) {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_H_DEFAULT;
-                               tagOpened = false;
+                               levelCurrent--;
+                       }
+                       break;
+               case SCE_H_SGML_1ST_PARAM_COMMENT:
+                       if ((ch == '-') && (chPrev == '-')) {
+                               styler.ColourTo(i, SCE_H_SGML_COMMENT);
+                               state = SCE_H_SGML_1ST_PARAM;
+                       }
+                       break;
+               case SCE_H_SGML_SPECIAL:
+                       if (!isupper(ch)) {
+                               styler.ColourTo(i - 1, StateToPrint);
+                               if (isalnum(ch)) {
+                                       state = SCE_H_SGML_ERROR;
+                               } else {
+                                       state = SCE_H_SGML_DEFAULT;
+                               }
+                       }
+                       break;
+               case SCE_H_SGML_ENTITY:
+                       if (ch == ';') {
+                               styler.ColourTo(i, StateToPrint);
+                               state = SCE_H_SGML_DEFAULT;
+                       } else if (!isalnum(ch) && ch != '-' && ch != '.') {
+                               styler.ColourTo(i, SCE_H_SGML_ERROR);
+                               state = SCE_H_SGML_DEFAULT;
                        }
                        break;
                case SCE_H_ENTITY:
                        }
                        break;
                case SCE_H_ENTITY:
@@ -705,9 +885,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
                                int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
                                if (eClass == SCE_H_SCRIPT) {
                        if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
                                int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
                                if (eClass == SCE_H_SCRIPT) {
-                                       inScriptType = eNonHtmlScript;
-                                       scriptLanguage = defaultScript;
-                                       eClass = SCE_H_TAG;
+                                       if (!tagClosing) {
+                                               inScriptType = eNonHtmlScript;
+                                               scriptLanguage = clientScript;
+                                               eClass = SCE_H_TAG;
+                                       } else {
+                                               scriptLanguage = eScriptNone;
+                                               eClass = SCE_H_TAG;
+                                       }
                                }
                                if (ch == '>') {
                                        styler.ColourTo(i, eClass);
                                }
                                if (ch == '>') {
                                        styler.ColourTo(i, eClass);
@@ -717,28 +902,27 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                                state = SCE_H_DEFAULT;
                                        }
                                        tagOpened = false;
                                                state = SCE_H_DEFAULT;
                                        }
                                        tagOpened = false;
-                                       if (tagClosing)
+                                       if (tagClosing) {
                                                levelCurrent--;
                                                levelCurrent--;
-                                       else
+                                       } else {
                                                levelCurrent++;
                                                levelCurrent++;
+                                       }
                                        tagClosing = false;
                                        tagClosing = false;
-                           } else if (ch == '/' && chNext == '>') {
+                               } else if (ch == '/' && chNext == '>') {
                                        if (eClass == SCE_H_TAGUNKNOWN) {
                                        if (eClass == SCE_H_TAGUNKNOWN) {
-                                           styler.ColourTo(i + 1, SCE_H_TAGUNKNOWN);
+                                               styler.ColourTo(i + 1, SCE_H_TAGUNKNOWN);
                                        } else {
                                        } else {
-                                           styler.ColourTo(i - 1, StateToPrint);
-                                           styler.ColourTo(i + 1, SCE_H_TAGEND);
+                                               styler.ColourTo(i - 1, StateToPrint);
+                                               styler.ColourTo(i + 1, SCE_H_TAGEND);
                                        }
                                        }
-                                   i++;
-                                   ch = chNext;
-                                   state = SCE_H_DEFAULT;
+                                       i++;
+                                       ch = chNext;
+                                       state = SCE_H_DEFAULT;
                                        tagOpened = false;
                                } else {
                                        if (eClass != SCE_H_TAGUNKNOWN) {
                                        tagOpened = false;
                                } else {
                                        if (eClass != SCE_H_TAGUNKNOWN) {
-                                               if (eClass == SCE_H_CDATA) {
-                                                       state = SCE_H_CDATA;
-                                               } else if (eClass == SCE_H_SGML) {
-                                                       state = SCE_H_SGML;
+                                               if (eClass == SCE_H_SGML_DEFAULT) {
+                                                       state = SCE_H_SGML_DEFAULT;
                                                } else {
                                                        state = SCE_H_OTHER;
                                                }
                                                } else {
                                                        state = SCE_H_OTHER;
                                                }
@@ -750,7 +934,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
                                if (inScriptType == eNonHtmlScript) {
                                        int scriptLanguagePrev = scriptLanguage;
                        if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
                                if (inScriptType == eNonHtmlScript) {
                                        int scriptLanguagePrev = scriptLanguage;
-                                       scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
+                                       clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
+                                       scriptLanguage = clientScript;
                                        if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
                                                inScriptType = eHtml;
                                }
                                        if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
                                                inScriptType = eHtml;
                                }
@@ -1217,18 +1402,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                case SCE_HPHP_NUMBER:
                        if (!isdigit(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
                case SCE_HPHP_NUMBER:
                        if (!isdigit(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
-                               if (isoperator(ch)) 
-                                       state =SCE_HPHP_OPERATOR;
-                               else 
+                               if (isoperator(ch))
+                                       state = SCE_HPHP_OPERATOR;
+                               else
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                case SCE_HPHP_VARIABLE:
                        if (!iswordstart(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                case SCE_HPHP_VARIABLE:
                        if (!iswordstart(ch)) {
                                styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
-                               if (isoperator(ch)) 
-                                       state =SCE_HPHP_OPERATOR;
-                               else 
+                               if (isoperator(ch))
+                                       state = SCE_HPHP_OPERATOR;
+                               else
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
                                        state = SCE_HPHP_DEFAULT;
                        }
                        break;
@@ -1249,7 +1434,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                // skip the next char
                                i++;
                        } else if (ch == '$') {
                                // skip the next char
                                i++;
                        } else if (ch == '$') {
-                               styler.ColourTo(i-1, StateToPrint);
+                               styler.ColourTo(i - 1, StateToPrint);
                                state = SCE_HPHP_HSTRING_VARIABLE;
                        } else if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
                                state = SCE_HPHP_HSTRING_VARIABLE;
                        } else if (ch == '\"') {
                                styler.ColourTo(i, StateToPrint);
@@ -1267,13 +1452,13 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                        break;
                case SCE_HPHP_HSTRING_VARIABLE:
                        if (!iswordstart(ch)) {
                        break;
                case SCE_HPHP_HSTRING_VARIABLE:
                        if (!iswordstart(ch)) {
-                               styler.ColourTo(i-1, StateToPrint);
+                               styler.ColourTo(i - 1, StateToPrint);
                                i--; // strange but it works
                                state = SCE_HPHP_HSTRING;
                        }
                        break;
                case SCE_HPHP_OPERATOR:
                                i--; // strange but it works
                                state = SCE_HPHP_HSTRING;
                        }
                        break;
                case SCE_HPHP_OPERATOR:
-               case SCE_HPHP_DEFAULT:
+               case SCE_HPHP_DEFAULT:
                        styler.ColourTo(i - 1, StateToPrint);
                        if (isdigit(ch)) {
                                state = SCE_HPHP_NUMBER;
                        styler.ColourTo(i - 1, StateToPrint);
                        if (isdigit(ch)) {
                                state = SCE_HPHP_NUMBER;
@@ -1304,6 +1489,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
                // Some of the above terminated their lexeme but since the same character starts
                // the same class again, only reenter if non empty segment.
 
                // Some of the above terminated their lexeme but since the same character starts
                // the same class again, only reenter if non empty segment.
+
                bool nonEmptySegment = i >= static_cast<int>(styler.GetStartSegment());
                if (state == SCE_HB_DEFAULT) {    // One of the above succeeded
                        if ((ch == '\"') && (nonEmptySegment)) {
                bool nonEmptySegment = i >= static_cast<int>(styler.GetStartSegment());
                if (state == SCE_HB_DEFAULT) {    // One of the above succeeded
                        if ((ch == '\"') && (nonEmptySegment)) {
@@ -1335,7 +1521,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
                                state = SCE_HJ_COMMENTLINE;
                        } else if ((ch == '\"') && (nonEmptySegment)) {
                                state = SCE_HJ_DOUBLESTRING;
                                state = SCE_HJ_COMMENTLINE;
                        } else if ((ch == '\"') && (nonEmptySegment)) {
                                state = SCE_HJ_DOUBLESTRING;
-                       } else if ((ch == '\'')  && (nonEmptySegment)) {
+                       } else if ((ch == '\'') && (nonEmptySegment)) {
                                state = SCE_HJ_SINGLESTRING;
                        } else if (iswordstart(ch)) {
                                state = SCE_HJ_WORD;
                                state = SCE_HJ_SINGLESTRING;
                        } else if (iswordstart(ch)) {
                                state = SCE_HJ_WORD;
@@ -1357,4 +1543,3 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
 LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
 LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
 
 LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
 LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
-
index 6669694d1d6451d9c0c1d56ef6b636359ffb0b52..221859035e353cca2f3e6377be2c48fadf5bc8c2 100644 (file)
 
 #include "PropSet.h"
 #include "Accessor.h"
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
 
-/* Returns true if the "as" word that begins at start follows an import statement */
-static bool IsImportAs(unsigned int start, Accessor &styler) {
-       unsigned int i;
-       unsigned int j;
-       char s[10];
-
-       /* Find any import before start but after any statement terminator or quote */
-       i = start;
-       while (i > 0) {
-               char ch = styler[i - 1];
-
-               if (ch == '\n' || ch == '\r' || ch == ';' || ch == '\'' || ch == '"' || ch == '`')
-                       break;
-               if (ch == 't' && i > 5) {
-                       for (j = 0; j < 6; j++)
-                               s[j] = styler[(i - 6) + j];
-                       s[j] = '\0';
-                       if (strcmp(s, "import") == 0)
-                               return true;
-               }
-               i--;
-       }
-
-        return false;
-}
-
-static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
-       char s[100];
-       bool wordIsNumber = isdigit(styler[start]);
-       for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
-               s[i] = styler[start + i];
-               s[i + 1] = '\0';
-       }
-       char chAttr = SCE_P_IDENTIFIER;
-       if (0 == strcmp(prevWord, "class"))
-               chAttr = SCE_P_CLASSNAME;
-       else if (0 == strcmp(prevWord, "def"))
-               chAttr = SCE_P_DEFNAME;
-       else if (wordIsNumber)
-               chAttr = SCE_P_NUMBER;
-       else if (keywords.InList(s))
-               chAttr = SCE_P_WORD;
-       else if (strcmp(s, "as") == 0 && IsImportAs(start, styler))
-               chAttr = SCE_P_WORD;
-       // make sure that dot-qualifiers inside the word are lexed correct
-       else for (unsigned int i = 0; i < end - start + 1; i++) {
-               if (styler[start + i] == '.') {
-                       styler.ColourTo(start + i - 1, chAttr);
-                       styler.ColourTo(start + i, SCE_P_OPERATOR);
-               }
-       }
-       styler.ColourTo(end, chAttr);
-       strcpy(prevWord, s);
-}
+enum kwType { kwOther, kwClass, kwDef, kwImport };
 
 static bool IsPyComment(Accessor &styler, int pos, int len) {
        return len>0 && styler[pos]=='#';
 }
 
 
 static bool IsPyComment(Accessor &styler, int pos, int len) {
        return len>0 && styler[pos]=='#';
 }
 
-static bool IsPyStringStart(char ch, char chNext, char chNext2) {
+static bool IsPyStringStart(int ch, int chNext, int chNext2) {
        if (ch == '\'' || ch == '"')
                return true;
        if (ch == 'u' || ch == 'U') {
        if (ch == '\'' || ch == '"')
                return true;
        if (ch == 'u' || ch == 'U') {
@@ -93,10 +41,6 @@ static bool IsPyStringStart(char ch, char chNext, char chNext2) {
        return false;
 }
 
        return false;
 }
 
-static bool IsPyWordStart(char ch, char chNext, char chNext2) {
-       return (iswordchar(ch) && !IsPyStringStart(ch, chNext, chNext2));
-}
-
 /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
 static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        char ch = styler.SafeGetCharAt(i);
 /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
 static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        char ch = styler.SafeGetCharAt(i);
@@ -139,10 +83,18 @@ static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
        }
 }
 
        }
 }
 
+inline bool IsAWordChar(int  ch) {
+       return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+inline bool IsAWordStart(int ch) {
+       return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
 static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                                                   WordList *keywordlists[], Accessor &styler) {
 
 static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                                                   WordList *keywordlists[], Accessor &styler) {
 
-       int lengthDoc = startPos + length;
+       int endPos = startPos + length;
 
        // Backtrack to previous line in case need to fix its tab whinging
        int lineCurrent = styler.GetLine(startPos);
 
        // Backtrack to previous line in case need to fix its tab whinging
        int lineCurrent = styler.GetLine(startPos);
@@ -156,32 +108,27 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                }
        }
 
                }
        }
 
-       // Python uses a different mask because bad indentation is marked by oring with 32
-       styler.StartAt(startPos, 127);
-
        WordList &keywords = *keywordlists[0];
 
        WordList &keywords = *keywordlists[0];
 
-       int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
-       char prevWord[200];
-       prevWord[0] = '\0';
-       if (length == 0)
-               return ;
+       const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
 
 
-       int state = initStyle & 31;
+       initStyle = initStyle & 31;
+       if (initStyle == SCE_P_STRINGEOL) {
+               initStyle = SCE_P_DEFAULT;
+       }
 
 
-       int nextIndex = 0;
-       char chPrev = ' ';
-       char chPrev2 = ' ';
-       char chNext = styler[startPos];
-       styler.StartSegment(startPos);
-       bool atStartLine = true;
+       kwType kwLast = kwOther;
        int spaceFlags = 0;
        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
        int spaceFlags = 0;
        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-       for (int i = startPos; i < lengthDoc; i++) {
+       
+       // Python uses a different mask because bad indentation is marked by oring with 32
+       StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f);
+       
+       for (; sc.More(); sc.Forward()) {
 
 
-               if (atStartLine) {
-                       char chBad = static_cast<char>(64);
-                       char chGood = static_cast<char>(0);
+               if (sc.atLineStart) {
+                       const char chBad = static_cast<char>(64);
+                       const char chGood = static_cast<char>(0);
                        char chFlags = chGood;
                        if (whingeLevel == 1) {
                                chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
                        char chFlags = chGood;
                        if (whingeLevel == 1) {
                                chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
@@ -192,132 +139,117 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
                        } else if (whingeLevel == 4) {
                                chFlags = (spaceFlags & wsTab) ? chBad : chGood;
                        }
                        } else if (whingeLevel == 4) {
                                chFlags = (spaceFlags & wsTab) ? chBad : chGood;
                        }
-                       styler.SetFlags(chFlags, static_cast<char>(state));
-                       atStartLine = false;
+                       styler.SetFlags(chFlags, static_cast<char>(sc.state));
                }
 
                }
 
-               char ch = chNext;
-               chNext = styler.SafeGetCharAt(i + 1);
-               char chNext2 = styler.SafeGetCharAt(i + 2);
-
-               if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
-                       if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
+               if (sc.atLineEnd) {
+                       if ((sc.state == SCE_P_DEFAULT) || 
+                               (sc.state == SCE_P_TRIPLE) || 
+                               (sc.state == SCE_P_TRIPLEDOUBLE)) {
                                // Perform colourisation of white space and triple quoted strings at end of each line to allow
                                // tab marking to work inside white space and triple quoted strings
                                // Perform colourisation of white space and triple quoted strings at end of each line to allow
                                // tab marking to work inside white space and triple quoted strings
-                               styler.ColourTo(i, state);
+                               sc.ForwardSetState(sc.state);
                        }
                        lineCurrent++;
                        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
                        }
                        lineCurrent++;
                        styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-                       atStartLine = true;
-               }
-
-               if (styler.IsLeadByte(ch)) {
-                       chNext = styler.SafeGetCharAt(i + 2);
-                       chPrev = ' ';
-                       chPrev2 = ' ';
-                       i += 1;
-                       continue;
+                       if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
+                               sc.ChangeState(SCE_P_STRINGEOL);
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
                }
 
                }
 
-               if (state == SCE_P_STRINGEOL) {
-                       if (ch != '\r' && ch != '\n') {
-                               styler.ColourTo(i - 1, state);
-                               state = SCE_P_DEFAULT;
+               // Check for a state end
+               if (sc.state == SCE_P_OPERATOR) {
+                       kwLast = kwOther;
+                       sc.SetState(SCE_C_DEFAULT);
+               } else if (sc.state == SCE_P_NUMBER) {
+                       if (!IsAWordChar(sc.ch)) {
+                               sc.SetState(SCE_P_DEFAULT);
                        }
                        }
-               }
-               if (state == SCE_P_DEFAULT) {
-                       if (IsPyWordStart(ch, chNext, chNext2)) {
-                               styler.ColourTo(i - 1, state);
-                               state = SCE_P_WORD;
-                       } else if (ch == '#') {
-                               styler.ColourTo(i - 1, state);
-                               state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
-                       } else if (IsPyStringStart(ch, chNext, chNext2)) {
-                               styler.ColourTo(i - 1, state);
-                               state = GetPyStringState(styler, i, &nextIndex);
-                               if (nextIndex != i + 1) {
-                                       i = nextIndex - 1;
-                                       ch = ' ';
-                                       chPrev = ' ';
-                                       chNext = styler.SafeGetCharAt(i + 1);
+               } else if (sc.state == SCE_P_WORD) {
+                       if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
+                               char s[100];
+                               sc.GetCurrent(s, sizeof(s));
+                               int style = SCE_P_IDENTIFIER;
+                               if ((kwLast == kwImport) && (strcmp(s, "as") == 0)) {
+                                       style = SCE_P_WORD;
+                               } else if (keywords.InList(s)) {
+                                       style = SCE_P_WORD;
+                               } else if (kwLast == kwClass) {
+                                       style = SCE_P_CLASSNAME;
+                               } else if (kwLast == kwDef) {
+                                       style = SCE_P_DEFNAME;
                                }
                                }
-                       } else if (isoperator(ch)) {
-                               styler.ColourTo(i - 1, state);
-                               styler.ColourTo(i, SCE_P_OPERATOR);
-                       }
-               } else if (state == SCE_P_WORD) {
-                       if (!iswordchar(ch)) {
-                               ClassifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
-                               state = SCE_P_DEFAULT;
-                               if (ch == '#') {
-                                       state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
-                               } else if (IsPyStringStart(ch, chNext, chNext2)) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = GetPyStringState(styler, i, &nextIndex);
-                                       if (nextIndex != i + 1) {
-                                               i = nextIndex - 1;
-                                               ch = ' ';
-                                               chPrev = ' ';
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (isoperator(ch)) {
-                                       styler.ColourTo(i, SCE_P_OPERATOR);
+                               sc.ChangeState(style);
+                               sc.SetState(SCE_P_DEFAULT);
+                               if (style == SCE_P_WORD) {
+                                       if (0 == strcmp(s, "class"))
+                                               kwLast = kwClass;
+                                       else if (0 == strcmp(s, "def"))
+                                               kwLast = kwDef;
+                                       else if (0 == strcmp(s, "import"))
+                                               kwLast = kwImport;
+                                       else
+                                               kwLast = kwOther;
+                               } else if (style == SCE_P_CLASSNAME) {
+                                               kwLast = kwOther;
+                               } else if (style == SCE_P_DEFNAME) {
+                                               kwLast = kwOther;
                                }
                        }
                                }
                        }
-               } else {
-                       if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
-                               if (ch == '\r' || ch == '\n') {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_STRING) {
-                               if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_STRINGEOL;
-                               } else if (ch == '\\') {
-                                       if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
-                                               i++;
-                                               ch = chNext;
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (ch == '\"') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_CHARACTER) {
-                               if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
-                                       styler.ColourTo(i - 1, state);
-                                       state = SCE_P_STRINGEOL;
-                               } else if (ch == '\\') {
-                                       if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
-                                               i++;
-                                               ch = chNext;
-                                               chNext = styler.SafeGetCharAt(i + 1);
-                                       }
-                               } else if (ch == '\'') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
-                               }
-                       } else if (state == SCE_P_TRIPLE) {
-                               if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
+               } else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
+                       if (sc.ch == '\r' || sc.ch == '\n') {
+                               sc.SetState(SCE_P_DEFAULT);
+                       }
+               } else if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
+                       if (sc.ch == '\\') {
+                               if ((sc.chNext == '\r') && (sc.GetRelative(2) == '\n')) {
+                                       sc.Forward();
                                }
                                }
-                       } else if (state == SCE_P_TRIPLEDOUBLE) {
-                               if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
-                                       styler.ColourTo(i, state);
-                                       state = SCE_P_DEFAULT;
+                               sc.Forward();
+                       } else if ((sc.state == SCE_P_STRING) && (sc.ch == '\"')) {
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       } else if ((sc.state == SCE_P_CHARACTER) && (sc.ch == '\'')) {
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               } else if (sc.state == SCE_P_TRIPLE) {
+                       if (sc.ch == '\\') {
+                               sc.Forward();
+                       } else if (sc.Match("\'\'\'")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               } else if (sc.state == SCE_P_TRIPLEDOUBLE) {
+                       if (sc.ch == '\\') {
+                               sc.Forward();
+                       } else if (sc.Match("\"\"\"")) {
+                               sc.Forward();
+                               sc.Forward();
+                               sc.ForwardSetState(SCE_P_DEFAULT);
+                       }
+               }
+
+               // Check for a new state starting character
+               if (sc.state == SCE_P_DEFAULT) {
+                       if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
+                               sc.SetState(SCE_P_OPERATOR);
+                       } else if (sc.ch == '#') {
+                               sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
+                       } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+                               sc.SetState(SCE_P_NUMBER);
+                       } else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
+                               int nextIndex = 0;
+                               sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
+                               while (nextIndex > (sc.currentPos+1)) {
+                                       sc.Forward();
                                }
                                }
+                       } else if (IsAWordStart(sc.ch)) {
+                               sc.SetState(SCE_P_WORD);
                        }
                }
                        }
                }
-               chPrev2 = chPrev;
-               chPrev = ch;
-       }
-       if (state == SCE_P_WORD) {
-               ClassifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
-       } else {
-               styler.ColourTo(lengthDoc, state);
        }
        }
+       sc.Complete();
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
@@ -338,14 +270,15 @@ static bool IsQuoteLine(int line, Accessor &styler) {
        return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
 }
 
        return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
 }
 
+
 static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
                                        WordList *[], Accessor &styler) {
 static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
                                        WordList *[], Accessor &styler) {
-       int maxPos = startPos + length;
-       int maxLines = styler.GetLine(maxPos-1);
-                                               
-       bool foldComment = styler.GetPropertyInt("fold.comment.python");
-       bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
-
+       const int maxPos = startPos + length;
+       const int maxLines = styler.GetLine(maxPos-1);             // Requested last line
+       const int docLines = styler.GetLine(styler.Length() - 1);  // Available last line
+       const bool foldComment = styler.GetPropertyInt("fold.comment.python");
+       const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
+       
        // Backtrack to previous non-blank line so we can determine indent level
        // for any white space lines (needed esp. within triple quoted strings)
        // and so we can fix any preceding fold level (which is why we go back
        // Backtrack to previous non-blank line so we can determine indent level
        // for any white space lines (needed esp. within triple quoted strings)
        // and so we can fix any preceding fold level (which is why we go back
@@ -363,8 +296,8 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
        }
        int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
        
        }
        int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
        
+       // Set up initial loop state
        startPos = styler.LineStart(lineCurrent);
        startPos = styler.LineStart(lineCurrent);
-       // Set up initial state
        int prev_state = SCE_P_DEFAULT & 31;
        if (lineCurrent >= 1)
                prev_state = styler.StyleAt(startPos-1) & 31;
        int prev_state = SCE_P_DEFAULT & 31;
        if (lineCurrent >= 1)
                prev_state = styler.StyleAt(startPos-1) & 31;
@@ -374,21 +307,27 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
 
        // Process all characters to end of requested range or end of any triple quote
                prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
 
        // Process all characters to end of requested range or end of any triple quote
-       // or comment that hangs over the end of the range
-       while ((lineCurrent <= maxLines) || prevQuote || prevComment) {
+       // or comment that hangs over the end of the range.  Cap processing in all cases
+       // to end of document (in case of unclosed quote or comment at end).
+       while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote || prevComment)) {
 
                // Gather info
                int lev = indentCurrent;
                int lineNext = lineCurrent + 1;
 
                // Gather info
                int lev = indentCurrent;
                int lineNext = lineCurrent + 1;
-               int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
-               int indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
-               int quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
-               int quote_start = (quote && !prevQuote);
-               int quote_continue = (quote && prevQuote);
-               int comment = foldComment && IsCommentLine(lineCurrent, styler);
-               int comment_start = (comment && !prevComment && 
+               int indentNext = indentCurrent;
+               int quote = false;
+               if (lineNext <= docLines) {
+                       // Information about next line is only available if not at end of document
+                       indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
+                       int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
+                       quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+               }
+               const int quote_start = (quote && !prevQuote);
+               const int quote_continue = (quote && prevQuote);
+               const int comment = foldComment && IsCommentLine(lineCurrent, styler);
+               const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
                        IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
                        IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
-               int comment_continue = (comment && prevComment);
+               const int comment_continue = (comment && prevComment);
                if ((!quote || !prevQuote) && !comment)
                        indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
                if (quote)
                if ((!quote || !prevQuote) && !comment)
                        indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
                if (quote)
@@ -411,22 +350,35 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                }
 
                // Skip past any blank lines for next indent level info; we skip also comments
                }
 
                // Skip past any blank lines for next indent level info; we skip also comments
-               // starting in column 0 which effectively folds them into surrounding code
-               // rather than screwing up folding.  Then set indent level on the lines
-               // we skipped to be same as maximum of current and next indent.  This approach
-               // does a reasonable job of collapsing white space into surrounding code
-               // without getting confused by white space at the start of an indented level.
+               // starting in column 0 which effectively folds them into surrounding code rather
+               // than screwing up folding.
+               const int saveIndentNext = indentNext;
                while (!quote &&
                while (!quote &&
-                      ((indentNext & SC_FOLDLEVELWHITEFLAG) || styler[styler.LineStart(lineNext)] == '#') &&
-                      (lineNext < maxLines)) {
-                       int level = Platform::Maximum(indentCurrent, indentNext);
-                       if (indentNext & SC_FOLDLEVELWHITEFLAG)
-                               level = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
-                       styler.SetLevel(lineNext, level);
+                      (lineNext < docLines) &&
+                      ((indentNext & SC_FOLDLEVELWHITEFLAG) || 
+                       (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
+
                        lineNext++;
                        indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
                }
 
                        lineNext++;
                        indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
                }
 
+               // Next compute max indent level of current line and next non-blank line.
+               // This is the level to which we set all the intervening blank or comment lines.
+               const int skip_level = Platform::Maximum(indentCurrentLevel,
+                                                  indentNext & SC_FOLDLEVELNUMBERMASK);
+               
+               // Now set all the indent levels on the lines we skipped
+               int skipLine = lineCurrent + 1;
+               int skipIndentNext = saveIndentNext;
+               while (skipLine < lineNext) {
+                       int skipLineLevel = skip_level;
+                       if (skipIndentNext & SC_FOLDLEVELWHITEFLAG)
+                               skipLineLevel = SC_FOLDLEVELWHITEFLAG | skipLineLevel;
+                       styler.SetLevel(skipLine, skipLineLevel);
+                       skipLine++;
+                       skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL);
+               }
+               
                // Set fold header on non-quote/non-comment line
                if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
                        if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
                // Set fold header on non-quote/non-comment line
                if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
                        if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
@@ -443,8 +395,9 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
                lineCurrent = lineNext;
        }
 
                lineCurrent = lineNext;
        }
 
-       // Make sure last line indent level is set too
-       styler.SetLevel(lineCurrent, indentCurrent);
+       // NOTE: Cannot set level of last line here because indentCurrent doesn't have
+       // header flag set; the loop above is crafted to take care of this case!
+       //styler.SetLevel(lineCurrent, indentCurrent);
 }
 
 LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc);
 }
 
 LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc);
index dc1468d8324ced046063c8eecea21b95ec0ac412..a7c5b124fc6d12c8922e839ce0af761da8db7b54 100644 (file)
@@ -40,7 +40,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
        surface->FillRectangle(rcH, fore);
 }
 
        surface->FillRectangle(rcH, fore);
 }
 
-void LineMarker::Draw(Surface *surface, PRectangle &rcWhole) {
+void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter) {
        // Restrict most shapes a bit
        PRectangle rc = rcWhole;
        rc.top++;
        // Restrict most shapes a bit
        PRectangle rc = rcWhole;
        rc.top++;
@@ -230,6 +230,15 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole) {
                surface->MoveTo(centreX, rcWhole.top);
                surface->LineTo(centreX, centreY - blobSize);
                
                surface->MoveTo(centreX, rcWhole.top);
                surface->LineTo(centreX, centreY - blobSize);
                
+       } else if (markType >= SC_MARK_CHARACTER) {
+               char character[1];
+               character[0] = static_cast<char>(markType - SC_MARK_CHARACTER);
+               int width = surface->WidthText(fontForCharacter, character, 1);
+               rc.left += (rc.Width() - width) / 2;
+               rc.right = rc.left + width;
+               surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2, 
+                       character, 1, fore.allocated, back.allocated);
+
        } else { // SC_MARK_SHORTARROW
                Point pts[] = {
                        Point(centreX, centreY + dimOn2),
        } else { // SC_MARK_SHORTARROW
                Point pts[] = {
                        Point(centreX, centreY + dimOn2),
index ee0f36c256611437b649a254d80b8d947de8b4f9..b9dd15d06246e865d22bb1c2b4fe3ad75d577b6a 100644 (file)
@@ -20,7 +20,7 @@ public:
                fore = Colour(0,0,0);
                back = Colour(0xff,0xff,0xff);
        }
                fore = Colour(0,0,0);
                back = Colour(0xff,0xff,0xff);
        }
-       void Draw(Surface *surface, PRectangle &rc);
+       void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
 };
 
 #endif
 };
 
 #endif
index 07534db1ef020406ab7185bfc8161defe90d273b..ac5b73d0267e2f474f577890a018cb41ed5fadae 100644 (file)
@@ -30,9 +30,8 @@
  * Modification history:
  *
  * $Log$
  * Modification history:
  *
  * $Log$
- * Revision 1.1  2001/09/01 03:05:24  RD
- * Upgraded to version 1.39 of Scintilla, and upated wxStyledTextCtrl
- * accordingly.
+ * Revision 1.2  2001/10/18 01:24:58  RD
+ * Updated to version 1.40 of Scintilla
  *
  * Revision 1.6  2001/04/29 13:32:10  nyamatongwe
  * Addition of new target methods - versions of ReplaceTarget that take counted
  *
  * Revision 1.6  2001/04/29 13:32:10  nyamatongwe
  * Addition of new target methods - versions of ReplaceTarget that take counted
index 707f59b9f440978ee0ea10dc1dd321d8bf22e40e..75a8ffffa42cf11503dae6f0d46073318e40a421 100644 (file)
@@ -35,6 +35,7 @@
 #include "ScintillaBase.h"
 
 ScintillaBase::ScintillaBase() {
 #include "ScintillaBase.h"
 
 ScintillaBase::ScintillaBase() {
+       displayPopupMenu = true;
        listType = 0;
 #ifdef SCI_LEXER
        lexLanguage = SCLEX_CONTAINER;
        listType = 0;
 #ifdef SCI_LEXER
        lexLanguage = SCLEX_CONTAINER;
@@ -514,6 +515,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
                InvalidateStyleRedraw();
                break;
 
                InvalidateStyleRedraw();
                break;
 
+       case SCI_USEPOPUP:
+               displayPopupMenu = wParam;
+               break;
+
 #ifdef SCI_LEXER
        case SCI_SETLEXER:
                SetLexer(wParam);
 #ifdef SCI_LEXER
        case SCI_SETLEXER:
                SetLexer(wParam);
index d5b1e8ba0ccae8b98666326d2711112cef0917d5..ca4695355fac0eb7261fed7a64c3fb9f700ae74f 100644 (file)
@@ -30,6 +30,7 @@ protected:
                idcmdSelectAll=16
        };
 
                idcmdSelectAll=16
        };
 
+       bool displayPopupMenu;
        Menu popup;
        AutoComplete ac;
 
        Menu popup;
        AutoComplete ac;
 
@@ -42,7 +43,7 @@ protected:
        int lexLanguage;
        LexerModule *lexCurrent;
        PropSet props;
        int lexLanguage;
        LexerModule *lexCurrent;
        PropSet props;
-       enum {numWordLists=5};
+       enum {numWordLists=6};
        WordList *keyWordLists[numWordLists+1];
        void SetLexer(uptr_t wParam);
        void SetLexerLanguage(const char *languageName);
        WordList *keyWordLists[numWordLists+1];
        void SetLexer(uptr_t wParam);
        void SetLexerLanguage(const char *languageName);
diff --git a/src/stc/scintilla/src/StyleContext.cxx b/src/stc/scintilla/src/StyleContext.cxx
new file mode 100644 (file)
index 0000000..bdae281
--- /dev/null
@@ -0,0 +1,51 @@
+// Scintilla source code edit control
+/** @file StyleContext.cxx
+ ** Lexer infrastructure.
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// This file is in the public domain.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+
+static void getRange(unsigned int start,
+               unsigned int end,
+               Accessor &styler,
+               char *s,
+               unsigned int len) {
+       unsigned int i = 0;
+       while ((i < end - start + 1) && (i < len-1)) {
+               s[i] = styler[start + i];
+               i++;
+       }
+       s[i] = '\0';
+}
+
+void StyleContext::GetCurrent(char *s, int len) {
+       getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
+}
+
+static void getRangeLowered(unsigned int start,
+               unsigned int end,
+               Accessor &styler,
+               char *s,
+               unsigned int len) {
+       unsigned int i = 0;
+       while ((i < end - start + 1) && (i < len-1)) {
+               s[i] = static_cast<char>(tolower(styler[start + i]));
+               i++;
+       }
+       s[i] = '\0';
+}
+
+void StyleContext::GetCurrentLowered(char *s, int len) {
+       getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
+}
diff --git a/src/stc/scintilla/src/StyleContext.h b/src/stc/scintilla/src/StyleContext.h
new file mode 100644 (file)
index 0000000..5bc6371
--- /dev/null
@@ -0,0 +1,127 @@
+// Scintilla source code edit control
+/** @file StyleContext.cxx
+ ** Lexer infrastructure.
+ **/
+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// This file is in the public domain.
+
+// All languages handled so far can treat all characters >= 0x80 as one class
+// which just continues the current token or starts an identifier if in default.
+// DBCS treated specially as the second character can be < 0x80 and hence 
+// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
+class StyleContext {
+       Accessor &styler;
+       int endPos;
+       StyleContext& operator=(const StyleContext&) {
+               return *this;
+       }
+public:
+       int currentPos;
+       bool atLineStart;
+       bool atLineEnd;
+       int state;
+       int chPrev;
+       int ch;
+       int chNext;
+
+       StyleContext(unsigned int startPos, int length,
+                        int initStyle, Accessor &styler_, char chMask=31) : 
+               styler(styler_),
+               endPos(startPos + length),
+               currentPos(startPos), 
+               atLineStart(true),
+               atLineEnd(false),
+               state(initStyle), 
+               chPrev(0),
+               ch(0), 
+               chNext(0) {
+               styler.StartAt(startPos, chMask);
+               styler.StartSegment(startPos);
+               int pos = currentPos;
+               ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
+               if (styler.IsLeadByte(static_cast<char>(ch))) {
+                       pos++;
+                       ch = ch << 8;
+                       ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
+               }
+               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
+               if (styler.IsLeadByte(static_cast<char>(chNext))) {
+                       chNext = chNext << 8;
+                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
+               }
+               atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
+       }
+       void Complete() {
+               styler.ColourTo(currentPos - 1, state);
+       }
+       bool More() {
+               return currentPos <= endPos;
+       }
+       void Forward() {
+               atLineStart = atLineEnd;
+               // A lot of this is repeated from the constructor - TODO: merge code
+               chPrev = ch;
+               currentPos++;
+               if (ch >= 0x100)
+                       currentPos++;
+               ch = chNext;
+               chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
+               if (styler.IsLeadByte(static_cast<char>(chNext))) {
+                       chNext = chNext << 8;
+                       chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+               }
+               // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+               // Avoid triggering two times on Dos/Win
+               // End of line
+               atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
+       }
+       void ChangeState(int state_) {
+               state = state_;
+       }
+       void SetState(int state_) {
+               styler.ColourTo(currentPos - 1, state);
+               state = state_;
+       }
+       void ForwardSetState(int state_) {
+               Forward();
+               styler.ColourTo(currentPos - 1, state);
+               state = state_;
+       }
+       int LengthCurrent() {
+               return currentPos - styler.GetStartSegment();
+       }
+       int GetRelative(int n) {
+               return styler.SafeGetCharAt(currentPos+n);
+       }
+       bool Match(char ch0) {
+               return ch == ch0;
+       }
+       bool Match(char ch0, char ch1) {
+               return (ch == ch0) && (chNext == ch1);
+       }
+       bool Match(const char *s) {
+               if (ch != *s)
+                       return false;
+               s++;
+               if (chNext != *s)
+                       return false;
+               s++;
+               for (int n=2; *s; n++) {
+                       if (*s != styler.SafeGetCharAt(currentPos+n))
+                               return false;
+                       s++;
+               }
+               return true;
+       }
+       // Non-inline
+       void GetCurrent(char *s, int len);
+       void GetCurrentLowered(char *s, int len);
+};
+
+inline bool IsASpace(unsigned int ch) {
+    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
+}
+
+inline bool IsADigit(unsigned int ch) {
+       return (ch >= '0') && (ch <= '9');
+}
index bd6184cf6a33dbb5e7dc11a47f9851cafa7cfc3e..99645adb29333632c863296d4ad08458720271c7 100644 (file)
@@ -32,6 +32,7 @@ int wxForceScintillaLexers(void)
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
+  extern LexerModule lmNncrontab;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
@@ -48,6 +49,7 @@ int wxForceScintillaLexers(void)
      && &lmAVE
      && &lmConf
      && &lmCPP
      && &lmAVE
      && &lmConf
      && &lmCPP
+     && &lmNncrontab
      && &lmEiffel
      && &lmHTML
      && &lmLISP
      && &lmEiffel
      && &lmHTML
      && &lmLISP
@@ -1202,6 +1204,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Replace the target text with the argument text.
 }
 
 // Replace the target text with the argument text.
+// Text is counted so it can contain nulls.
 // Returns the length of the replacement text.
 
                        int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
 // Returns the length of the replacement text.
 
                        int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
@@ -1210,6 +1213,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Replace the target text with the argument text after \d processing.
 }
 
 // Replace the target text with the argument text after \d processing.
+// Text is counted so it can contain nulls.
 // Looks for \d where d is between 1 and 9 and replaces these with the strings
 // matched in the last search operation which were surrounded by \( and \).
 // Returns the length of the replacement text including any change
 // Looks for \d where d is between 1 and 9 and replaces these with the strings
 // matched in the last search operation which were surrounded by \( and \).
 // Returns the length of the replacement text including any change
@@ -1221,7 +1225,7 @@ int wxStyledTextCtrl::GetTargetEnd() {
 }
 
 // Search for a counted string in the target and set the target to the found
 }
 
 // Search for a counted string in the target and set the target to the found
-// range.
+// range. Text is counted so it can contain nulls.
 // Returns length of range or -1 for failure in which case target is not moved.
 
                        int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
 // Returns length of range or -1 for failure in which case target is not moved.
 
                        int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
index 979bca8794bd0db9ab6ebbd9b1591cd9b71726db..3a415e1f85c3c913358b61e831bfd2bf8e6bc56c 100644 (file)
@@ -32,6 +32,7 @@ int wxForceScintillaLexers(void)
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
   extern LexerModule lmAVE;
   extern LexerModule lmConf;
   extern LexerModule lmCPP;
+  extern LexerModule lmNncrontab;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
   extern LexerModule lmEiffel;
   extern LexerModule lmHTML;
   extern LexerModule lmLISP;
@@ -48,6 +49,7 @@ int wxForceScintillaLexers(void)
      && &lmAVE
      && &lmConf
      && &lmCPP
      && &lmAVE
      && &lmConf
      && &lmCPP
+     && &lmNncrontab
      && &lmEiffel
      && &lmHTML
      && &lmLISP
      && &lmEiffel
      && &lmHTML
      && &lmLISP