From 8e54aaedb5329a49ffd9c5d50071f9c8cdd5c59e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 6 Feb 2004 00:03:13 +0000 Subject: [PATCH] Updated Scintilla to version 1.58 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/build/stc/stc.bkl | 26 +- contrib/include/wx/stc/stc.h | 251 ++++- contrib/src/stc/Makefile.in | 164 ++- contrib/src/stc/PlatWX.cpp | 4 - contrib/src/stc/ScintillaWX.cpp | 39 +- contrib/src/stc/ScintillaWX.h | 4 +- contrib/src/stc/gen_iface.py | 25 +- contrib/src/stc/scintilla/README.txt | 2 +- contrib/src/stc/scintilla/include/Platform.h | 2 +- contrib/src/stc/scintilla/include/PropSet.h | 2 +- contrib/src/stc/scintilla/include/SciLexer.h | 124 ++- contrib/src/stc/scintilla/include/Scintilla.h | 29 + .../src/stc/scintilla/include/Scintilla.iface | 274 ++++- contrib/src/stc/scintilla/src/CallTip.cxx | 8 +- .../stc/scintilla/src/ContractionState.cxx | 1 + contrib/src/stc/scintilla/src/Document.cxx | 135 ++- contrib/src/stc/scintilla/src/Document.h | 11 +- contrib/src/stc/scintilla/src/Editor.cxx | 934 +++++++++++++----- contrib/src/stc/scintilla/src/Editor.h | 46 +- .../src/stc/scintilla/src/ExternalLexer.cxx | 3 +- contrib/src/stc/scintilla/src/Indicator.cxx | 8 +- contrib/src/stc/scintilla/src/Indicator.h | 2 +- contrib/src/stc/scintilla/src/KeyMap.cxx | 44 +- contrib/src/stc/scintilla/src/KeyWords.cxx | 10 + contrib/src/stc/scintilla/src/LexAsm.cxx | 103 +- contrib/src/stc/scintilla/src/LexCLW.cxx | 441 +++++++++ contrib/src/stc/scintilla/src/LexErlang.cxx | 522 ++++++++++ contrib/src/stc/scintilla/src/LexForth.cxx | 348 +++++++ contrib/src/stc/scintilla/src/LexFortran.cxx | 356 +++++-- contrib/src/stc/scintilla/src/LexLua.cxx | 27 +- contrib/src/stc/scintilla/src/LexMPT.cxx | 182 ++++ contrib/src/stc/scintilla/src/LexMatlab.cxx | 76 +- contrib/src/stc/scintilla/src/LexMetapost.cxx | 320 ++++++ contrib/src/stc/scintilla/src/LexOthers.cxx | 6 + contrib/src/stc/scintilla/src/LexPB.cxx | 228 +++++ contrib/src/stc/scintilla/src/LexPOV.cxx | 17 +- contrib/src/stc/scintilla/src/LexPerl.cxx | 448 ++++++--- contrib/src/stc/scintilla/src/LexRuby.cxx | 5 + contrib/src/stc/scintilla/src/LexSQL.cxx | 19 +- contrib/src/stc/scintilla/src/LexScriptol.cxx | 429 ++++---- contrib/src/stc/scintilla/src/LexTeX.cxx | 288 ++++++ contrib/src/stc/scintilla/src/LexVB.cxx | 73 +- contrib/src/stc/scintilla/src/LexYAML.cxx | 305 ++++++ contrib/src/stc/scintilla/src/PropSet.cxx | 58 +- contrib/src/stc/scintilla/src/RESearch.cxx | 150 +-- .../src/stc/scintilla/src/ScintillaBase.cxx | 19 +- contrib/src/stc/scintilla/src/ScintillaBase.h | 1 + contrib/src/stc/scintilla/src/ViewStyle.cxx | 2 + contrib/src/stc/scintilla/src/ViewStyle.h | 1 + contrib/src/stc/scintilla/src/XPM.cxx | 38 +- contrib/src/stc/scintilla/src/XPM.h | 23 +- contrib/src/stc/stc.cpp | 66 +- contrib/src/stc/stc.cpp.in | 5 + contrib/src/stc/stc.h.in | 3 +- include/wx/stc/stc.h | 251 ++++- src/stc/Makefile.in | 164 ++- src/stc/PlatWX.cpp | 4 - src/stc/ScintillaWX.cpp | 39 +- src/stc/ScintillaWX.h | 4 +- src/stc/gen_iface.py | 25 +- src/stc/scintilla/README.txt | 2 +- src/stc/scintilla/include/Platform.h | 2 +- src/stc/scintilla/include/PropSet.h | 2 +- src/stc/scintilla/include/SciLexer.h | 124 ++- src/stc/scintilla/include/Scintilla.h | 29 + src/stc/scintilla/include/Scintilla.iface | 274 ++++- src/stc/scintilla/src/CallTip.cxx | 8 +- src/stc/scintilla/src/ContractionState.cxx | 1 + src/stc/scintilla/src/Document.cxx | 135 ++- src/stc/scintilla/src/Document.h | 11 +- src/stc/scintilla/src/Editor.cxx | 934 +++++++++++++----- src/stc/scintilla/src/Editor.h | 46 +- src/stc/scintilla/src/ExternalLexer.cxx | 3 +- src/stc/scintilla/src/Indicator.cxx | 8 +- src/stc/scintilla/src/Indicator.h | 2 +- src/stc/scintilla/src/KeyMap.cxx | 44 +- src/stc/scintilla/src/KeyWords.cxx | 10 + src/stc/scintilla/src/LexAsm.cxx | 103 +- src/stc/scintilla/src/LexCLW.cxx | 441 +++++++++ src/stc/scintilla/src/LexErlang.cxx | 522 ++++++++++ src/stc/scintilla/src/LexForth.cxx | 348 +++++++ src/stc/scintilla/src/LexFortran.cxx | 356 +++++-- src/stc/scintilla/src/LexLua.cxx | 27 +- src/stc/scintilla/src/LexMPT.cxx | 182 ++++ src/stc/scintilla/src/LexMatlab.cxx | 76 +- src/stc/scintilla/src/LexMetapost.cxx | 320 ++++++ src/stc/scintilla/src/LexOthers.cxx | 6 + src/stc/scintilla/src/LexPB.cxx | 228 +++++ src/stc/scintilla/src/LexPOV.cxx | 17 +- src/stc/scintilla/src/LexPerl.cxx | 448 ++++++--- src/stc/scintilla/src/LexRuby.cxx | 5 + src/stc/scintilla/src/LexSQL.cxx | 19 +- src/stc/scintilla/src/LexScriptol.cxx | 429 ++++---- src/stc/scintilla/src/LexTeX.cxx | 288 ++++++ src/stc/scintilla/src/LexVB.cxx | 73 +- src/stc/scintilla/src/LexYAML.cxx | 305 ++++++ src/stc/scintilla/src/PropSet.cxx | 58 +- src/stc/scintilla/src/RESearch.cxx | 150 +-- src/stc/scintilla/src/ScintillaBase.cxx | 19 +- src/stc/scintilla/src/ScintillaBase.h | 1 + src/stc/scintilla/src/ViewStyle.cxx | 2 + src/stc/scintilla/src/ViewStyle.h | 1 + src/stc/scintilla/src/XPM.cxx | 38 +- src/stc/scintilla/src/XPM.h | 23 +- src/stc/stc.cpp | 66 +- src/stc/stc.cpp.in | 5 + src/stc/stc.h.in | 3 +- 107 files changed, 10979 insertions(+), 2409 deletions(-) create mode 100644 contrib/src/stc/scintilla/src/LexCLW.cxx create mode 100644 contrib/src/stc/scintilla/src/LexErlang.cxx create mode 100644 contrib/src/stc/scintilla/src/LexForth.cxx create mode 100644 contrib/src/stc/scintilla/src/LexMPT.cxx create mode 100644 contrib/src/stc/scintilla/src/LexMetapost.cxx create mode 100644 contrib/src/stc/scintilla/src/LexPB.cxx create mode 100644 contrib/src/stc/scintilla/src/LexTeX.cxx create mode 100644 contrib/src/stc/scintilla/src/LexYAML.cxx create mode 100644 src/stc/scintilla/src/LexCLW.cxx create mode 100644 src/stc/scintilla/src/LexErlang.cxx create mode 100644 src/stc/scintilla/src/LexForth.cxx create mode 100644 src/stc/scintilla/src/LexMPT.cxx create mode 100644 src/stc/scintilla/src/LexMetapost.cxx create mode 100644 src/stc/scintilla/src/LexPB.cxx create mode 100644 src/stc/scintilla/src/LexTeX.cxx create mode 100644 src/stc/scintilla/src/LexYAML.cxx diff --git a/contrib/build/stc/stc.bkl b/contrib/build/stc/stc.bkl index 3d3d35d04e..7dd9548dee 100644 --- a/contrib/build/stc/stc.bkl +++ b/contrib/build/stc/stc.bkl @@ -16,48 +16,56 @@ scintilla/src/CallTip.cxx scintilla/src/CellBuffer.cxx scintilla/src/ContractionState.cxx - scintilla/src/Document.cxx scintilla/src/DocumentAccessor.cxx + scintilla/src/Document.cxx scintilla/src/Editor.cxx scintilla/src/ExternalLexer.cxx scintilla/src/Indicator.cxx scintilla/src/KeyMap.cxx scintilla/src/KeyWords.cxx - scintilla/src/LexAVE.cxx scintilla/src/LexAda.cxx scintilla/src/LexAsm.cxx + scintilla/src/LexAVE.cxx scintilla/src/LexBaan.cxx scintilla/src/LexBullant.cxx - scintilla/src/LexCPP.cxx - scintilla/src/LexCSS.cxx + scintilla/src/LexCLW.cxx scintilla/src/LexConf.cxx + scintilla/src/LexCPP.cxx scintilla/src/LexCrontab.cxx + scintilla/src/LexCSS.cxx scintilla/src/LexEiffel.cxx + scintilla/src/LexErlang.cxx scintilla/src/LexEScript.cxx + scintilla/src/LexForth.cxx scintilla/src/LexFortran.cxx scintilla/src/LexHTML.cxx scintilla/src/LexLisp.cxx scintilla/src/LexLout.cxx scintilla/src/LexLua.cxx - scintilla/src/LexMMIXAL.cxx scintilla/src/LexMatlab.cxx + scintilla/src/LexMetapost.cxx + scintilla/src/LexMMIXAL.cxx + scintilla/src/LexMPT.cxx scintilla/src/LexNsis.cxx scintilla/src/LexOthers.cxx - scintilla/src/LexPOV.cxx - scintilla/src/LexPS.cxx scintilla/src/LexPascal.cxx + scintilla/src/LexPB.cxx scintilla/src/LexPerl.cxx + scintilla/src/LexPOV.cxx + scintilla/src/LexPS.cxx scintilla/src/LexPython.cxx scintilla/src/LexRuby.cxx - scintilla/src/LexSQL.cxx scintilla/src/LexScriptol.cxx + scintilla/src/LexSQL.cxx + scintilla/src/LexTeX.cxx scintilla/src/LexVB.cxx + scintilla/src/LexYAML.cxx scintilla/src/LineMarker.cxx scintilla/src/PropSet.cxx scintilla/src/RESearch.cxx scintilla/src/ScintillaBase.cxx - scintilla/src/Style.cxx scintilla/src/StyleContext.cxx + scintilla/src/Style.cxx scintilla/src/UniConversion.cxx scintilla/src/ViewStyle.cxx scintilla/src/WindowAccessor.cxx diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index f70374ee2f..207fd19dc0 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -57,7 +57,7 @@ #define wxSTC_INVALID_POSITION -1 -// Define start of Scintilla messages to be greater than all edit (EM_*) messages +// Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages // as many EM_ messages can be used although that use is deprecated. #define wxSTC_START 2000 #define wxSTC_OPTIONAL_START 3000 @@ -162,6 +162,7 @@ #define wxSTC_INDIC_DIAGONAL 3 #define wxSTC_INDIC_STRIKE 4 #define wxSTC_INDIC_HIDDEN 5 +#define wxSTC_INDIC_BOX 6 #define wxSTC_INDIC0_MASK 0x20 #define wxSTC_INDIC1_MASK 0x40 #define wxSTC_INDIC2_MASK 0x80 @@ -243,6 +244,11 @@ // where most code reside, and the lines after the caret, eg. the body of a function. #define wxSTC_CARET_EVEN 0x08 +// Selection modes +#define wxSTC_SEL_STREAM 0 +#define wxSTC_SEL_RECTANGLE 1 +#define wxSTC_SEL_LINES 2 + // Maximum value of keywordSet parameter of SetKeyWords. #define wxSTC_KEYWORDSET_MAX 8 @@ -333,6 +339,16 @@ #define wxSTC_LEX_PS 42 #define wxSTC_LEX_NSIS 43 #define wxSTC_LEX_MMIXAL 44 +#define wxSTC_LEX_CLW 45 +#define wxSTC_LEX_CLWNOCASE 46 +#define wxSTC_LEX_LOT 47 +#define wxSTC_LEX_YAML 48 +#define wxSTC_LEX_TEX 49 +#define wxSTC_LEX_METAPOST 50 +#define wxSTC_LEX_POWERBASIC 51 +#define wxSTC_LEX_FORTH 52 +#define wxSTC_LEX_ERLANG 53 +#define wxSTC_LEX_OCTAVE 54 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a // value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -542,7 +558,7 @@ #define wxSTC_PL_STRING_QR 29 #define wxSTC_PL_STRING_QW 30 -// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT +// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC #define wxSTC_B_DEFAULT 0 #define wxSTC_B_COMMENT 1 #define wxSTC_B_NUMBER 2 @@ -552,6 +568,10 @@ #define wxSTC_B_OPERATOR 6 #define wxSTC_B_IDENTIFIER 7 #define wxSTC_B_DATE 8 +#define wxSTC_B_STRINGEOL 9 +#define wxSTC_B_KEYWORD2 10 +#define wxSTC_B_KEYWORD3 11 +#define wxSTC_B_KEYWORD4 12 // Lexical states for SCLEX_PROPERTIES #define wxSTC_PROPS_DEFAULT 0 @@ -607,6 +627,8 @@ #define wxSTC_ERR_PHP 14 #define wxSTC_ERR_ELF 15 #define wxSTC_ERR_IFC 16 +#define wxSTC_ERR_IFORT 17 +#define wxSTC_ERR_ABSF 18 // Lexical states for SCLEX_BATCH #define wxSTC_BAT_DEFAULT 0 @@ -726,37 +748,50 @@ #define wxSTC_NNCRONTAB_ENVIRONMENT 9 #define wxSTC_NNCRONTAB_IDENTIFIER 10 +// Lexical states for SCLEX_FORTH (Forth Lexer) +#define wxSTC_FORTH_DEFAULT 0 +#define wxSTC_FORTH_COMMENT 1 +#define wxSTC_FORTH_COMMENT_ML 2 +#define wxSTC_FORTH_IDENTIFIER 3 +#define wxSTC_FORTH_CONTROL 4 +#define wxSTC_FORTH_KEYWORD 5 +#define wxSTC_FORTH_DEFWORD 6 +#define wxSTC_FORTH_PREWORD1 7 +#define wxSTC_FORTH_PREWORD2 8 +#define wxSTC_FORTH_NUMBER 9 +#define wxSTC_FORTH_STRING 10 +#define wxSTC_FORTH_LOCALE 11 + // Lexical states for SCLEX_MATLAB #define wxSTC_MATLAB_DEFAULT 0 #define wxSTC_MATLAB_COMMENT 1 #define wxSTC_MATLAB_COMMAND 2 #define wxSTC_MATLAB_NUMBER 3 #define wxSTC_MATLAB_KEYWORD 4 + +// single quoted string #define wxSTC_MATLAB_STRING 5 #define wxSTC_MATLAB_OPERATOR 6 #define wxSTC_MATLAB_IDENTIFIER 7 +#define wxSTC_MATLAB_DOUBLEQUOTESTRING 8 // Lexical states for SCLEX_SCRIPTOL #define wxSTC_SCRIPTOL_DEFAULT 0 -#define wxSTC_SCRIPTOL_COMMENT 1 +#define wxSTC_SCRIPTOL_WHITE 1 #define wxSTC_SCRIPTOL_COMMENTLINE 2 -#define wxSTC_SCRIPTOL_COMMENTDOC 3 -#define wxSTC_SCRIPTOL_NUMBER 4 -#define wxSTC_SCRIPTOL_WORD 5 -#define wxSTC_SCRIPTOL_STRING 6 -#define wxSTC_SCRIPTOL_CHARACTER 7 -#define wxSTC_SCRIPTOL_UUID 8 -#define wxSTC_SCRIPTOL_PREPROCESSOR 9 -#define wxSTC_SCRIPTOL_OPERATOR 10 -#define wxSTC_SCRIPTOL_IDENTIFIER 11 -#define wxSTC_SCRIPTOL_STRINGEOL 12 -#define wxSTC_SCRIPTOL_VERBATIM 13 -#define wxSTC_SCRIPTOL_REGEX 14 -#define wxSTC_SCRIPTOL_COMMENTLINEDOC 15 -#define wxSTC_SCRIPTOL_WORD2 16 -#define wxSTC_SCRIPTOL_COMMENTDOCKEYWORD 17 -#define wxSTC_SCRIPTOL_COMMENTDOCKEYWORDERROR 18 -#define wxSTC_SCRIPTOL_COMMENTBASIC 19 +#define wxSTC_SCRIPTOL_PERSISTENT 3 +#define wxSTC_SCRIPTOL_CSTYLE 4 +#define wxSTC_SCRIPTOL_COMMENTBLOCK 5 +#define wxSTC_SCRIPTOL_NUMBER 6 +#define wxSTC_SCRIPTOL_STRING 7 +#define wxSTC_SCRIPTOL_CHARACTER 8 +#define wxSTC_SCRIPTOL_STRINGEOL 9 +#define wxSTC_SCRIPTOL_KEYWORD 10 +#define wxSTC_SCRIPTOL_OPERATOR 11 +#define wxSTC_SCRIPTOL_IDENTIFIER 12 +#define wxSTC_SCRIPTOL_TRIPLE 13 +#define wxSTC_SCRIPTOL_CLASSNAME 14 +#define wxSTC_SCRIPTOL_PREPROCESSOR 15 // Lexical states for SCLEX_ASM #define wxSTC_ASM_DEFAULT 0 @@ -770,6 +805,10 @@ #define wxSTC_ASM_REGISTER 8 #define wxSTC_ASM_DIRECTIVE 9 #define wxSTC_ASM_DIRECTIVEOPERAND 10 +#define wxSTC_ASM_COMMENTBLOCK 11 +#define wxSTC_ASM_CHARACTER 12 +#define wxSTC_ASM_STRINGEOL 13 +#define wxSTC_ASM_EXTINSTRUCTION 14 // Lexical states for SCLEX_FORTRAN #define wxSTC_F_DEFAULT 0 @@ -905,6 +944,75 @@ #define wxSTC_MMIXAL_SYMBOL 16 #define wxSTC_MMIXAL_INCLUDE 17 +// Lexical states for SCLEX_CLW +#define wxSTC_CLW_DEFAULT 0 +#define wxSTC_CLW_LABEL 1 +#define wxSTC_CLW_COMMENT 2 +#define wxSTC_CLW_STRING 3 +#define wxSTC_CLW_USER_IDENTIFIER 4 +#define wxSTC_CLW_INTEGER_CONSTANT 5 +#define wxSTC_CLW_REAL_CONSTANT 6 +#define wxSTC_CLW_PICTURE_STRING 7 +#define wxSTC_CLW_KEYWORD 8 +#define wxSTC_CLW_COMPILER_DIRECTIVE 9 +#define wxSTC_CLW_BUILTIN_PROCEDURES_FUNCTION 10 +#define wxSTC_CLW_STRUCTURE_DATA_TYPE 11 +#define wxSTC_CLW_ATTRIBUTE 12 +#define wxSTC_CLW_STANDARD_EQUATE 13 +#define wxSTC_CLW_ERROR 14 + +// Lexical states for SCLEX_LOT +#define wxSTC_LOT_DEFAULT 0 +#define wxSTC_LOT_HEADER 1 +#define wxSTC_LOT_BREAK 2 +#define wxSTC_LOT_SET 3 +#define wxSTC_LOT_PASS 4 +#define wxSTC_LOT_FAIL 5 +#define wxSTC_LOT_ABORT 6 + +// Lexical states for SCLEX_YAML +#define wxSTC_YAML_DEFAULT 0 +#define wxSTC_YAML_COMMENT 1 +#define wxSTC_YAML_IDENTIFIER 2 +#define wxSTC_YAML_KEYWORD 3 +#define wxSTC_YAML_NUMBER 4 +#define wxSTC_YAML_REFERENCE 5 +#define wxSTC_YAML_DOCUMENT 6 +#define wxSTC_YAML_TEXT 7 +#define wxSTC_YAML_ERROR 8 + +// Lexical states for SCLEX_TEX +#define wxSTC_TEX_DEFAULT 0 +#define wxSTC_TEX_SPECIAL 1 +#define wxSTC_TEX_GROUP 2 +#define wxSTC_TEX_SYMBOL 3 +#define wxSTC_TEX_COMMAND 4 +#define wxSTC_TEX_TEXT 5 +#define wxSTC_METAPOST_DEFAULT 0 +#define wxSTC_METAPOST_SPECIAL 1 +#define wxSTC_METAPOST_GROUP 2 +#define wxSTC_METAPOST_SYMBOL 3 +#define wxSTC_METAPOST_COMMAND 4 +#define wxSTC_METAPOST_TEXT 5 +#define wxSTC_METAPOST_EXTRA 6 + +// Lexical states for SCLEX_ERLANG +#define wxSTC_ERLANG_DEFAULT 0 +#define wxSTC_ERLANG_COMMENT 1 +#define wxSTC_ERLANG_VARIABLE 2 +#define wxSTC_ERLANG_NUMBER 3 +#define wxSTC_ERLANG_KEYWORD 4 +#define wxSTC_ERLANG_STRING 5 +#define wxSTC_ERLANG_OPERATOR 6 +#define wxSTC_ERLANG_ATOM 7 +#define wxSTC_ERLANG_FUNCTION_NAME 8 +#define wxSTC_ERLANG_CHARACTER 9 +#define wxSTC_ERLANG_MACRO 10 +#define wxSTC_ERLANG_RECORD 11 +#define wxSTC_ERLANG_SEPARATOR 12 +#define wxSTC_ERLANG_NODE_NAME 13 +#define wxSTC_ERLANG_UNKNOWN 31 + //----------------------------------------- // Commands that can be bound to keystrokes @@ -1090,7 +1198,7 @@ // except they behave differently when word-wrap is enabled: // They go first to the start / end of the display line, like (Home|LineEnd)Display // The difference is that, the cursor is already at the point, it goes on to the start -// or end of the document line, as appropriate for (Home|LineEnd|VCHome)Extend. +// or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. #define wxSTC_CMD_HOMEWRAP 2349 #define wxSTC_CMD_HOMEWRAPEXTEND 2450 #define wxSTC_CMD_LINEENDWRAP 2451 @@ -1118,12 +1226,65 @@ // Delete forwards from the current position to the end of the line. #define wxSTC_CMD_DELLINERIGHT 2396 -// Move caret between paragraphs (delimited by empty lines) +// Move caret between paragraphs (delimited by empty lines). #define wxSTC_CMD_PARADOWN 2413 #define wxSTC_CMD_PARADOWNEXTEND 2414 #define wxSTC_CMD_PARAUP 2415 #define wxSTC_CMD_PARAUPEXTEND 2416 +// Move caret down one line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEDOWNRECTEXTEND 2426 + +// Move caret up one line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEUPRECTEXTEND 2427 + +// Move caret left one character, extending rectangular selection to new caret position. +#define wxSTC_CMD_CHARLEFTRECTEXTEND 2428 + +// Move caret right one character, extending rectangular selection to new caret position. +#define wxSTC_CMD_CHARRIGHTRECTEXTEND 2429 + +// Move caret to first position on line, extending rectangular selection to new caret position. +#define wxSTC_CMD_HOMERECTEXTEND 2430 + +// Move caret to before first visible character on line. +// If already there move to first character on line. +// In either case, extend rectangular selection to new caret position. +#define wxSTC_CMD_VCHOMERECTEXTEND 2431 + +// Move caret to last position on line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEENDRECTEXTEND 2432 + +// Move caret one page up, extending rectangular selection to new caret position. +#define wxSTC_CMD_PAGEUPRECTEXTEND 2433 + +// Move caret one page down, extending rectangular selection to new caret position. +#define wxSTC_CMD_PAGEDOWNRECTEXTEND 2434 + +// Move caret to top of page, or one page up if already at top of page. +#define wxSTC_CMD_STUTTEREDPAGEUP 2435 + +// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. +#define wxSTC_CMD_STUTTEREDPAGEUPEXTEND 2436 + +// Move caret to bottom of page, or one page down if already at bottom of page. +#define wxSTC_CMD_STUTTEREDPAGEDOWN 2437 + +// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. +#define wxSTC_CMD_STUTTEREDPAGEDOWNEXTEND 2438 + +// Move caret left one word, position cursor at end of word. +#define wxSTC_CMD_WORDLEFTEND 2439 + +// Move caret left one word, position cursor at end of word, extending selection to new caret position. +#define wxSTC_CMD_WORDLEFTENDEXTEND 2440 + +// Move caret right one word, position cursor at end of word. +#define wxSTC_CMD_WORDRIGHTEND 2441 + +// Move caret right one word, position cursor at end of word, extending selection to new caret position. +#define wxSTC_CMD_WORDRIGHTENDEXTEND 2442 + // END of generated section //---------------------------------------------------------------------- @@ -1410,7 +1571,7 @@ public: // When key+modifier combination km is pressed perform msg. void CmdKeyAssign(int key, int modifiers, int cmd); - // When key+modifier combination km do nothing. + // When key+modifier combination km is pressed do nothing. void CmdKeyClear(int key, int modifiers); // Drop all key mappings. @@ -1429,6 +1590,7 @@ public: void SetCaretPeriod(int periodMilliseconds); // Set the set of characters making up words for when moving or selecting by word. + // First sets deaults like SetCharsDefault. void SetWordChars(const wxString& characters); // Start a sequence of actions that is undone and redone as a unit. @@ -1663,7 +1825,7 @@ public: int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect); @@ -1781,12 +1943,12 @@ public: int GetTargetEnd(); // Replace the target text with the argument text. - // Text is counted so it can contain nulls. + // Text is counted so it can contain NULs. // 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. + // Text is counted so it can contain NULs. // 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 @@ -1794,7 +1956,7 @@ public: int ReplaceTargetRE(const wxString& text); // Search for a counted string in the target and set the target to the found - // range. Text is counted so it can contain nulls. + // range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int SearchInTarget(const wxString& text); @@ -1919,7 +2081,7 @@ public: int GetScrollWidth(); // Measure the pixel width of some text in a particular style. - // Nul terminated text argument. + // NUL terminated text argument. // Does not handle tab or control characters. int TextWidth(int style, const wxString& text); @@ -2135,7 +2297,7 @@ public: void SetXOffset(int newOffset); int GetXOffset(); - // Set the last x chosen value to be the caret x position + // Set the last x chosen value to be the caret x position. void ChooseCaretX(); // Set the way the caret is kept visible when going sideway. @@ -2149,7 +2311,7 @@ public: // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). void SetPrintWrapMode(int mode); - // Is printing line wrapped. + // Is printing line wrapped? int GetPrintWrapMode(); // Set a fore colour for active hotspots. @@ -2161,6 +2323,9 @@ public: // Enable / Disable underlining active hotspots. void SetHotspotActiveUnderline(bool underline); + // Limit hotspots to single line so hotspots on two lines don't merge. + void SetHotspotSingleLine(bool singleLine); + // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int PositionBefore(int pos); @@ -2175,6 +2340,29 @@ public: // Copy argument text to the clipboard. void CopyText(int length, const wxString& text); + // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or + // by lines (SC_SEL_LINES). + void SetSelectionMode(int mode); + + // Get the mode of the current selection. + int GetSelectionMode(); + + // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). + int GetLineSelStartPosition(int line); + + // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). + int GetLineSelEndPosition(int line); + + // Set the set of characters making up whitespace for when moving or selecting by word. + // Should be called after SetWordChars. + void SetWhitespaceChars(const wxString& characters); + + // Reset the set of characters for whitespace and word characters to the defaults. + void SetCharsDefault(); + + // Get currently selected item position in the auto-completion list + int AutoCompGetCurrent(); + // Start notifying the container of all key presses and commands. void StartRecord(); @@ -2321,7 +2509,8 @@ private: void OnEraseBackground(wxEraseEvent& evt); void OnMenu(wxCommandEvent& evt); void OnListBox(wxCommandEvent& evt); - + void OnIdle(wxIdleEvent& evt); + // Turn notifications from Scintilla into events void NotifyChange(); diff --git a/contrib/src/stc/Makefile.in b/contrib/src/stc/Makefile.in index 6c645a2e24..2979989fef 100644 --- a/contrib/src/stc/Makefile.in +++ b/contrib/src/stc/Makefile.in @@ -57,48 +57,56 @@ STCDLL_OBJECTS = \ stcdll_CallTip.o \ stcdll_CellBuffer.o \ stcdll_ContractionState.o \ - stcdll_Document.o \ stcdll_DocumentAccessor.o \ + stcdll_Document.o \ stcdll_Editor.o \ stcdll_ExternalLexer.o \ stcdll_Indicator.o \ stcdll_KeyMap.o \ stcdll_KeyWords.o \ - stcdll_LexAVE.o \ stcdll_LexAda.o \ stcdll_LexAsm.o \ + stcdll_LexAVE.o \ stcdll_LexBaan.o \ stcdll_LexBullant.o \ - stcdll_LexCPP.o \ - stcdll_LexCSS.o \ + stcdll_LexCLW.o \ stcdll_LexConf.o \ + stcdll_LexCPP.o \ stcdll_LexCrontab.o \ + stcdll_LexCSS.o \ stcdll_LexEiffel.o \ + stcdll_LexErlang.o \ stcdll_LexEScript.o \ + stcdll_LexForth.o \ stcdll_LexFortran.o \ stcdll_LexHTML.o \ stcdll_LexLisp.o \ stcdll_LexLout.o \ stcdll_LexLua.o \ - stcdll_LexMMIXAL.o \ stcdll_LexMatlab.o \ + stcdll_LexMetapost.o \ + stcdll_LexMMIXAL.o \ + stcdll_LexMPT.o \ stcdll_LexNsis.o \ stcdll_LexOthers.o \ - stcdll_LexPOV.o \ - stcdll_LexPS.o \ stcdll_LexPascal.o \ + stcdll_LexPB.o \ stcdll_LexPerl.o \ + stcdll_LexPOV.o \ + stcdll_LexPS.o \ stcdll_LexPython.o \ stcdll_LexRuby.o \ - stcdll_LexSQL.o \ stcdll_LexScriptol.o \ + stcdll_LexSQL.o \ + stcdll_LexTeX.o \ stcdll_LexVB.o \ + stcdll_LexYAML.o \ stcdll_LineMarker.o \ stcdll_PropSet.o \ stcdll_RESearch.o \ stcdll_ScintillaBase.o \ - stcdll_Style.o \ stcdll_StyleContext.o \ + stcdll_Style.o \ stcdll_UniConversion.o \ stcdll_ViewStyle.o \ stcdll_WindowAccessor.o \ @@ -115,48 +123,56 @@ STCLIB_OBJECTS = \ stclib_CallTip.o \ stclib_CellBuffer.o \ stclib_ContractionState.o \ - stclib_Document.o \ stclib_DocumentAccessor.o \ + stclib_Document.o \ stclib_Editor.o \ stclib_ExternalLexer.o \ stclib_Indicator.o \ stclib_KeyMap.o \ stclib_KeyWords.o \ - stclib_LexAVE.o \ stclib_LexAda.o \ stclib_LexAsm.o \ + stclib_LexAVE.o \ stclib_LexBaan.o \ stclib_LexBullant.o \ - stclib_LexCPP.o \ - stclib_LexCSS.o \ + stclib_LexCLW.o \ stclib_LexConf.o \ + stclib_LexCPP.o \ stclib_LexCrontab.o \ + stclib_LexCSS.o \ stclib_LexEiffel.o \ + stclib_LexErlang.o \ stclib_LexEScript.o \ + stclib_LexForth.o \ stclib_LexFortran.o \ stclib_LexHTML.o \ stclib_LexLisp.o \ stclib_LexLout.o \ stclib_LexLua.o \ - stclib_LexMMIXAL.o \ stclib_LexMatlab.o \ + stclib_LexMetapost.o \ + stclib_LexMMIXAL.o \ + stclib_LexMPT.o \ stclib_LexNsis.o \ stclib_LexOthers.o \ - stclib_LexPOV.o \ - stclib_LexPS.o \ stclib_LexPascal.o \ + stclib_LexPB.o \ stclib_LexPerl.o \ + stclib_LexPOV.o \ + stclib_LexPS.o \ stclib_LexPython.o \ stclib_LexRuby.o \ - stclib_LexSQL.o \ stclib_LexScriptol.o \ + stclib_LexSQL.o \ + stclib_LexTeX.o \ stclib_LexVB.o \ + stclib_LexYAML.o \ stclib_LineMarker.o \ stclib_PropSet.o \ stclib_RESearch.o \ stclib_ScintillaBase.o \ - stclib_Style.o \ stclib_StyleContext.o \ + stclib_Style.o \ stclib_UniConversion.o \ stclib_ViewStyle.o \ stclib_WindowAccessor.o \ @@ -332,10 +348,10 @@ stcdll_CellBuffer.o: $(srcdir)/scintilla/src/CellBuffer.cxx stcdll_ContractionState.o: $(srcdir)/scintilla/src/ContractionState.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_Document.o: $(srcdir)/scintilla/src/Document.cxx +stcdll_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx +stcdll_Document.o: $(srcdir)/scintilla/src/Document.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_Editor.o: $(srcdir)/scintilla/src/Editor.cxx @@ -353,39 +369,48 @@ stcdll_KeyMap.o: $(srcdir)/scintilla/src/KeyMap.cxx stcdll_KeyWords.o: $(srcdir)/scintilla/src/KeyWords.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx - $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< - stcdll_LexAda.o: $(srcdir)/scintilla/src/LexAda.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexAsm.o: $(srcdir)/scintilla/src/LexAsm.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexBaan.o: $(srcdir)/scintilla/src/LexBaan.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexBullant.o: $(srcdir)/scintilla/src/LexBullant.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx +stcdll_LexCLW.o: $(srcdir)/scintilla/src/LexCLW.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx +stcdll_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx +stcdll_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexCrontab.o: $(srcdir)/scintilla/src/LexCrontab.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexEiffel.o: $(srcdir)/scintilla/src/LexEiffel.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexErlang.o: $(srcdir)/scintilla/src/LexErlang.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexEScript.o: $(srcdir)/scintilla/src/LexEScript.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexForth.o: $(srcdir)/scintilla/src/LexForth.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexFortran.o: $(srcdir)/scintilla/src/LexFortran.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< @@ -401,10 +426,16 @@ stcdll_LexLout.o: $(srcdir)/scintilla/src/LexLout.cxx stcdll_LexLua.o: $(srcdir)/scintilla/src/LexLua.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + +stcdll_LexMetapost.o: $(srcdir)/scintilla/src/LexMetapost.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexMMIXAL.o: $(srcdir)/scintilla/src/LexMMIXAL.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx +stcdll_LexMPT.o: $(srcdir)/scintilla/src/LexMPT.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx @@ -413,16 +444,19 @@ stcdll_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx stcdll_LexOthers.o: $(srcdir)/scintilla/src/LexOthers.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx +stcdll_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx +stcdll_LexPB.o: $(srcdir)/scintilla/src/LexPB.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx +stcdll_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx +stcdll_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + +stcdll_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx @@ -431,15 +465,21 @@ stcdll_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx stcdll_LexRuby.o: $(srcdir)/scintilla/src/LexRuby.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexSQL.o: $(srcdir)/scintilla/src/LexSQL.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx +stcdll_LexTeX.o: $(srcdir)/scintilla/src/LexTeX.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< @@ -452,10 +492,10 @@ stcdll_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stcdll_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_Style.o: $(srcdir)/scintilla/src/Style.cxx +stcdll_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx +stcdll_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_UniConversion.o: $(srcdir)/scintilla/src/UniConversion.cxx @@ -491,10 +531,10 @@ stclib_CellBuffer.o: $(srcdir)/scintilla/src/CellBuffer.cxx stclib_ContractionState.o: $(srcdir)/scintilla/src/ContractionState.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_Document.o: $(srcdir)/scintilla/src/Document.cxx +stclib_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx +stclib_Document.o: $(srcdir)/scintilla/src/Document.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_Editor.o: $(srcdir)/scintilla/src/Editor.cxx @@ -512,39 +552,48 @@ stclib_KeyMap.o: $(srcdir)/scintilla/src/KeyMap.cxx stclib_KeyWords.o: $(srcdir)/scintilla/src/KeyWords.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx - $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< - stclib_LexAda.o: $(srcdir)/scintilla/src/LexAda.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexAsm.o: $(srcdir)/scintilla/src/LexAsm.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexBaan.o: $(srcdir)/scintilla/src/LexBaan.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexBullant.o: $(srcdir)/scintilla/src/LexBullant.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx +stclib_LexCLW.o: $(srcdir)/scintilla/src/LexCLW.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx +stclib_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx +stclib_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexCrontab.o: $(srcdir)/scintilla/src/LexCrontab.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexEiffel.o: $(srcdir)/scintilla/src/LexEiffel.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexErlang.o: $(srcdir)/scintilla/src/LexErlang.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexEScript.o: $(srcdir)/scintilla/src/LexEScript.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexForth.o: $(srcdir)/scintilla/src/LexForth.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexFortran.o: $(srcdir)/scintilla/src/LexFortran.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< @@ -560,10 +609,16 @@ stclib_LexLout.o: $(srcdir)/scintilla/src/LexLout.cxx stclib_LexLua.o: $(srcdir)/scintilla/src/LexLua.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + +stclib_LexMetapost.o: $(srcdir)/scintilla/src/LexMetapost.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexMMIXAL.o: $(srcdir)/scintilla/src/LexMMIXAL.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx +stclib_LexMPT.o: $(srcdir)/scintilla/src/LexMPT.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx @@ -572,16 +627,19 @@ stclib_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx stclib_LexOthers.o: $(srcdir)/scintilla/src/LexOthers.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx +stclib_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx +stclib_LexPB.o: $(srcdir)/scintilla/src/LexPB.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx +stclib_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx +stclib_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + +stclib_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx @@ -590,15 +648,21 @@ stclib_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx stclib_LexRuby.o: $(srcdir)/scintilla/src/LexRuby.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexSQL.o: $(srcdir)/scintilla/src/LexSQL.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx +stclib_LexTeX.o: $(srcdir)/scintilla/src/LexTeX.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< @@ -611,10 +675,10 @@ stclib_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stclib_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_Style.o: $(srcdir)/scintilla/src/Style.cxx +stclib_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx +stclib_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_UniConversion.o: $(srcdir)/scintilla/src/UniConversion.cxx diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index ceb50296a6..56205b99a4 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -855,7 +855,6 @@ public: virtual int GetSelection(); virtual int Find(const char *prefix); virtual void GetValue(int n, char *value, int len); - virtual void Sort(); virtual void RegisterImage(int type, const char *xpm_data); virtual void ClearRegisteredImages(); virtual void SetDoubleClickAction(CallBackAction, void *); @@ -1008,9 +1007,6 @@ void ListBoxImpl::GetValue(int n, char *value, int len) { value[len-1] = '\0'; } -void ListBoxImpl::Sort() { -} - void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1); diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index 26e966cf36..eaa1600208 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -146,7 +146,6 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { ScintillaWX::~ScintillaWX() { - SetTicking(false); } //---------------------------------------------------------------------- @@ -165,6 +164,8 @@ void ScintillaWX::Initialise() { void ScintillaWX::Finalise() { ScintillaBase::Finalise(); + SetTicking(false); + SetIdle(false); } @@ -199,6 +200,19 @@ void ScintillaWX::StartDrag() { } +bool ScintillaWX::SetIdle(bool on) { + if (idler.state != on) { + // connect or disconnect the EVT_IDLE handler + if (on) + stc->Connect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle); + else + stc->Disconnect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle); + idler.state = on; + } + return idler.state; +} + + void ScintillaWX::SetTicking(bool on) { wxSTCTimer* steTimer; if (timer.ticking != on) { @@ -219,11 +233,13 @@ void ScintillaWX::SetTicking(bool on) { void ScintillaWX::SetMouseCapture(bool on) { - if (on && !capturedMouse) - stc->CaptureMouse(); - else if (!on && capturedMouse && stc->HasCapture()) - stc->ReleaseMouse(); - capturedMouse = on; + if (mouseDownCaptures) { + if (on && !capturedMouse) + stc->CaptureMouse(); + else if (!on && capturedMouse && stc->HasCapture()) + stc->ReleaseMouse(); + capturedMouse = on; + } } @@ -652,7 +668,7 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { // Set the current position to the mouse click point and // then paste in the PRIMARY selection, if any. wxGTK only. int newPos = PositionFromLocation(pt); - MovePositionTo(newPos, 0, 1); + MovePositionTo(newPos, noSel, true); pdoc->BeginUndoAction(); wxTextDataObject data; @@ -775,6 +791,15 @@ void ScintillaWX::DoOnListBox() { AutoCompleteCompleted(); } + +void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { + + if ( Idle() ) + evt.RequestMore(); + else + SetIdle(false); +} + //---------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP diff --git a/contrib/src/stc/ScintillaWX.h b/contrib/src/stc/ScintillaWX.h index 799e58ed5a..1316c6661d 100644 --- a/contrib/src/stc/ScintillaWX.h +++ b/contrib/src/stc/ScintillaWX.h @@ -99,6 +99,7 @@ public: virtual void Initialise(); virtual void Finalise(); virtual void StartDrag(); + virtual bool SetIdle(bool on); virtual void SetTicking(bool on); virtual void SetMouseCapture(bool on); virtual bool HaveMouseCapture(); @@ -142,7 +143,8 @@ public: void DoAddChar(int key); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed); void DoTick() { Tick(); } - + void DoOnIdle(wxIdleEvent& evt); + #if wxUSE_DRAG_AND_DROP bool DoDropText(long x, long y, const wxString& data); wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); diff --git a/contrib/src/stc/gen_iface.py b/contrib/src/stc/gen_iface.py index aa9432d377..070d4cbe90 100644 --- a/contrib/src/stc/gen_iface.py +++ b/contrib/src/stc/gen_iface.py @@ -44,6 +44,7 @@ cmdValues = [ (2300, 2349), (2395, 2396), 2404, (2413, 2416), + (2426, 2442), (2450, 2454), ] @@ -275,6 +276,7 @@ methodOverrideMap = { 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0), 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0), 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0), + 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0), 'RegisterImage' : (0, @@ -330,14 +332,14 @@ methodOverrideMap = { int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect);''', ''' int %s(bool doDraw, int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; @@ -615,8 +617,23 @@ methodOverrideMap = { 'ParaDownExtend' : (None, 0, 0, 0), 'ParaUp' : (None, 0, 0, 0), 'ParaUpExtend' : (None, 0, 0, 0), - - + 'LineDownRectExtend' : (None, 0, 0, 0), + 'LineUpRectExtend' : (None, 0, 0, 0), + 'CharLeftRectExtend' : (None, 0, 0, 0), + 'CharRightRectExtend' : (None, 0, 0, 0), + 'HomeRectExtend' : (None, 0, 0, 0), + 'VCHomeRectExtend' : (None, 0, 0, 0), + 'LineEndRectExtend' : (None, 0, 0, 0), + 'PageUpRectExtend' : (None, 0, 0, 0), + 'PageDownRectExtend' : (None, 0, 0, 0), + 'StutteredPageUp' : (None, 0, 0, 0), + 'StutteredPageUpExtend' : (None, 0, 0, 0), + 'StutteredPageDown' : (None, 0, 0, 0), + 'StutteredPageDownExtend' : (None, 0, 0, 0), + 'WordLeftEnd' : (None, 0, 0, 0), + 'WordLeftEndExtend' : (None, 0, 0, 0), + 'WordRightEnd' : (None, 0, 0, 0), + 'WordRightEndExtend' : (None, 0, 0, 0), '' : ('', 0, 0, 0), diff --git a/contrib/src/stc/scintilla/README.txt b/contrib/src/stc/scintilla/README.txt index 1960be5d3d..f8ebdb02a6 100644 --- a/contrib/src/stc/scintilla/README.txt +++ b/contrib/src/stc/scintilla/README.txt @@ -3,4 +3,4 @@ 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. -The current version of the Scintilla code is 1.54 +The current version of the Scintilla code is 1.58 diff --git a/contrib/src/stc/scintilla/include/Platform.h b/contrib/src/stc/scintilla/include/Platform.h index 4f7ba2357c..8764024168 100644 --- a/contrib/src/stc/scintilla/include/Platform.h +++ b/contrib/src/stc/scintilla/include/Platform.h @@ -58,6 +58,7 @@ typedef void *WindowID; typedef void *MenuID; typedef void *TickerID; typedef void *Function; +typedef void *IdlerID; /** * A geometric point class. @@ -408,7 +409,6 @@ public: virtual int GetSelection()=0; virtual int Find(const char *prefix)=0; virtual void GetValue(int n, char *value, int len)=0; - virtual void Sort()=0; virtual void RegisterImage(int type, const char *xpm_data)=0; virtual void ClearRegisteredImages()=0; virtual void SetDoubleClickAction(CallBackAction, void *)=0; diff --git a/contrib/src/stc/scintilla/include/PropSet.h b/contrib/src/stc/scintilla/include/PropSet.h index 20ac5f774a..62cd5da3a9 100644 --- a/contrib/src/stc/scintilla/include/PropSet.h +++ b/contrib/src/stc/scintilla/include/PropSet.h @@ -81,7 +81,7 @@ public: void SetFromAllocated(); bool InList(const char *s); const char *GetNearestWord(const char *wordStart, int searchLen = -1, - bool ignoreCase = false, SString wordCharacters=""); + bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1); char *GetNearestWords(const char *wordStart, int searchLen=-1, bool ignoreCase=false, char otherSeparator='\0'); }; diff --git a/contrib/src/stc/scintilla/include/SciLexer.h b/contrib/src/stc/scintilla/include/SciLexer.h index 34867542f9..44d5dcdcda 100644 --- a/contrib/src/stc/scintilla/include/SciLexer.h +++ b/contrib/src/stc/scintilla/include/SciLexer.h @@ -59,6 +59,16 @@ #define SCLEX_PS 42 #define SCLEX_NSIS 43 #define SCLEX_MMIXAL 44 +#define SCLEX_CLW 45 +#define SCLEX_CLWNOCASE 46 +#define SCLEX_LOT 47 +#define SCLEX_YAML 48 +#define SCLEX_TEX 49 +#define SCLEX_METAPOST 50 +#define SCLEX_POWERBASIC 51 +#define SCLEX_FORTH 52 +#define SCLEX_ERLANG 53 +#define SCLEX_OCTAVE 54 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -243,6 +253,10 @@ #define SCE_B_OPERATOR 6 #define SCE_B_IDENTIFIER 7 #define SCE_B_DATE 8 +#define SCE_B_STRINGEOL 9 +#define SCE_B_KEYWORD2 10 +#define SCE_B_KEYWORD3 11 +#define SCE_B_KEYWORD4 12 #define SCE_PROPS_DEFAULT 0 #define SCE_PROPS_COMMENT 1 #define SCE_PROPS_SECTION 2 @@ -290,6 +304,8 @@ #define SCE_ERR_PHP 14 #define SCE_ERR_ELF 15 #define SCE_ERR_IFC 16 +#define SCE_ERR_IFORT 17 +#define SCE_ERR_ABSF 18 #define SCE_BAT_DEFAULT 0 #define SCE_BAT_COMMENT 1 #define SCE_BAT_WORD 2 @@ -388,6 +404,18 @@ #define SCE_NNCRONTAB_STRING 8 #define SCE_NNCRONTAB_ENVIRONMENT 9 #define SCE_NNCRONTAB_IDENTIFIER 10 +#define SCE_FORTH_DEFAULT 0 +#define SCE_FORTH_COMMENT 1 +#define SCE_FORTH_COMMENT_ML 2 +#define SCE_FORTH_IDENTIFIER 3 +#define SCE_FORTH_CONTROL 4 +#define SCE_FORTH_KEYWORD 5 +#define SCE_FORTH_DEFWORD 6 +#define SCE_FORTH_PREWORD1 7 +#define SCE_FORTH_PREWORD2 8 +#define SCE_FORTH_NUMBER 9 +#define SCE_FORTH_STRING 10 +#define SCE_FORTH_LOCALE 11 #define SCE_MATLAB_DEFAULT 0 #define SCE_MATLAB_COMMENT 1 #define SCE_MATLAB_COMMAND 2 @@ -396,26 +424,23 @@ #define SCE_MATLAB_STRING 5 #define SCE_MATLAB_OPERATOR 6 #define SCE_MATLAB_IDENTIFIER 7 +#define SCE_MATLAB_DOUBLEQUOTESTRING 8 #define SCE_SCRIPTOL_DEFAULT 0 -#define SCE_SCRIPTOL_COMMENT 1 +#define SCE_SCRIPTOL_WHITE 1 #define SCE_SCRIPTOL_COMMENTLINE 2 -#define SCE_SCRIPTOL_COMMENTDOC 3 -#define SCE_SCRIPTOL_NUMBER 4 -#define SCE_SCRIPTOL_WORD 5 -#define SCE_SCRIPTOL_STRING 6 -#define SCE_SCRIPTOL_CHARACTER 7 -#define SCE_SCRIPTOL_UUID 8 -#define SCE_SCRIPTOL_PREPROCESSOR 9 -#define SCE_SCRIPTOL_OPERATOR 10 -#define SCE_SCRIPTOL_IDENTIFIER 11 -#define SCE_SCRIPTOL_STRINGEOL 12 -#define SCE_SCRIPTOL_VERBATIM 13 -#define SCE_SCRIPTOL_REGEX 14 -#define SCE_SCRIPTOL_COMMENTLINEDOC 15 -#define SCE_SCRIPTOL_WORD2 16 -#define SCE_SCRIPTOL_COMMENTDOCKEYWORD 17 -#define SCE_SCRIPTOL_COMMENTDOCKEYWORDERROR 18 -#define SCE_SCRIPTOL_COMMENTBASIC 19 +#define SCE_SCRIPTOL_PERSISTENT 3 +#define SCE_SCRIPTOL_CSTYLE 4 +#define SCE_SCRIPTOL_COMMENTBLOCK 5 +#define SCE_SCRIPTOL_NUMBER 6 +#define SCE_SCRIPTOL_STRING 7 +#define SCE_SCRIPTOL_CHARACTER 8 +#define SCE_SCRIPTOL_STRINGEOL 9 +#define SCE_SCRIPTOL_KEYWORD 10 +#define SCE_SCRIPTOL_OPERATOR 11 +#define SCE_SCRIPTOL_IDENTIFIER 12 +#define SCE_SCRIPTOL_TRIPLE 13 +#define SCE_SCRIPTOL_CLASSNAME 14 +#define SCE_SCRIPTOL_PREPROCESSOR 15 #define SCE_ASM_DEFAULT 0 #define SCE_ASM_COMMENT 1 #define SCE_ASM_NUMBER 2 @@ -427,6 +452,10 @@ #define SCE_ASM_REGISTER 8 #define SCE_ASM_DIRECTIVE 9 #define SCE_ASM_DIRECTIVEOPERAND 10 +#define SCE_ASM_COMMENTBLOCK 11 +#define SCE_ASM_CHARACTER 12 +#define SCE_ASM_STRINGEOL 13 +#define SCE_ASM_EXTINSTRUCTION 14 #define SCE_F_DEFAULT 0 #define SCE_F_COMMENT 1 #define SCE_F_NUMBER 2 @@ -545,6 +574,65 @@ #define SCE_MMIXAL_OPERATOR 15 #define SCE_MMIXAL_SYMBOL 16 #define SCE_MMIXAL_INCLUDE 17 +#define SCE_CLW_DEFAULT 0 +#define SCE_CLW_LABEL 1 +#define SCE_CLW_COMMENT 2 +#define SCE_CLW_STRING 3 +#define SCE_CLW_USER_IDENTIFIER 4 +#define SCE_CLW_INTEGER_CONSTANT 5 +#define SCE_CLW_REAL_CONSTANT 6 +#define SCE_CLW_PICTURE_STRING 7 +#define SCE_CLW_KEYWORD 8 +#define SCE_CLW_COMPILER_DIRECTIVE 9 +#define SCE_CLW_BUILTIN_PROCEDURES_FUNCTION 10 +#define SCE_CLW_STRUCTURE_DATA_TYPE 11 +#define SCE_CLW_ATTRIBUTE 12 +#define SCE_CLW_STANDARD_EQUATE 13 +#define SCE_CLW_ERROR 14 +#define SCE_LOT_DEFAULT 0 +#define SCE_LOT_HEADER 1 +#define SCE_LOT_BREAK 2 +#define SCE_LOT_SET 3 +#define SCE_LOT_PASS 4 +#define SCE_LOT_FAIL 5 +#define SCE_LOT_ABORT 6 +#define SCE_YAML_DEFAULT 0 +#define SCE_YAML_COMMENT 1 +#define SCE_YAML_IDENTIFIER 2 +#define SCE_YAML_KEYWORD 3 +#define SCE_YAML_NUMBER 4 +#define SCE_YAML_REFERENCE 5 +#define SCE_YAML_DOCUMENT 6 +#define SCE_YAML_TEXT 7 +#define SCE_YAML_ERROR 8 +#define SCE_TEX_DEFAULT 0 +#define SCE_TEX_SPECIAL 1 +#define SCE_TEX_GROUP 2 +#define SCE_TEX_SYMBOL 3 +#define SCE_TEX_COMMAND 4 +#define SCE_TEX_TEXT 5 +#define SCE_METAPOST_DEFAULT 0 +#define SCE_METAPOST_SPECIAL 1 +#define SCE_METAPOST_GROUP 2 +#define SCE_METAPOST_SYMBOL 3 +#define SCE_METAPOST_COMMAND 4 +#define SCE_METAPOST_TEXT 5 +#define SCE_METAPOST_EXTRA 6 +#define SCE_ERLANG_DEFAULT 0 +#define SCE_ERLANG_COMMENT 1 +#define SCE_ERLANG_VARIABLE 2 +#define SCE_ERLANG_NUMBER 3 +#define SCE_ERLANG_KEYWORD 4 +#define SCE_ERLANG_STRING 5 +#define SCE_ERLANG_OPERATOR 6 +#define SCE_ERLANG_ATOM 7 +#define SCE_ERLANG_FUNCTION_NAME 8 +#define SCE_ERLANG_CHARACTER 9 +#define SCE_ERLANG_MACRO 10 +#define SCE_ERLANG_RECORD 11 +#define SCE_ERLANG_SEPARATOR 12 +#define SCE_ERLANG_NODE_NAME 13 +#define SCE_ERLANG_UNKNOWN 31 //--Autogenerated -- end of section automatically generated from Scintilla.iface #endif diff --git a/contrib/src/stc/scintilla/include/Scintilla.h b/contrib/src/stc/scintilla/include/Scintilla.h index 34893c8938..68c5427b61 100644 --- a/contrib/src/stc/scintilla/include/Scintilla.h +++ b/contrib/src/stc/scintilla/include/Scintilla.h @@ -205,6 +205,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_DIAGONAL 3 #define INDIC_STRIKE 4 #define INDIC_HIDDEN 5 +#define INDIC_BOX 6 #define INDIC0_MASK 0x20 #define INDIC1_MASK 0x40 #define INDIC2_MASK 0x80 @@ -533,6 +534,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETHOTSPOTACTIVEFORE 2410 #define SCI_SETHOTSPOTACTIVEBACK 2411 #define SCI_SETHOTSPOTACTIVEUNDERLINE 2412 +#define SCI_SETHOTSPOTSINGLELINE 2421 #define SCI_PARADOWN 2413 #define SCI_PARADOWNEXTEND 2414 #define SCI_PARAUP 2415 @@ -541,6 +543,33 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_POSITIONAFTER 2418 #define SCI_COPYRANGE 2419 #define SCI_COPYTEXT 2420 +#define SC_SEL_STREAM 0 +#define SC_SEL_RECTANGLE 1 +#define SC_SEL_LINES 2 +#define SCI_SETSELECTIONMODE 2422 +#define SCI_GETSELECTIONMODE 2423 +#define SCI_GETLINESELSTARTPOSITION 2424 +#define SCI_GETLINESELENDPOSITION 2425 +#define SCI_LINEDOWNRECTEXTEND 2426 +#define SCI_LINEUPRECTEXTEND 2427 +#define SCI_CHARLEFTRECTEXTEND 2428 +#define SCI_CHARRIGHTRECTEXTEND 2429 +#define SCI_HOMERECTEXTEND 2430 +#define SCI_VCHOMERECTEXTEND 2431 +#define SCI_LINEENDRECTEXTEND 2432 +#define SCI_PAGEUPRECTEXTEND 2433 +#define SCI_PAGEDOWNRECTEXTEND 2434 +#define SCI_STUTTEREDPAGEUP 2435 +#define SCI_STUTTEREDPAGEUPEXTEND 2436 +#define SCI_STUTTEREDPAGEDOWN 2437 +#define SCI_STUTTEREDPAGEDOWNEXTEND 2438 +#define SCI_WORDLEFTEND 2439 +#define SCI_WORDLEFTENDEXTEND 2440 +#define SCI_WORDRIGHTEND 2441 +#define SCI_WORDRIGHTENDEXTEND 2442 +#define SCI_SETWHITESPACECHARS 2443 +#define SCI_SETCHARSDEFAULT 2444 +#define SCI_AUTOCGETCURRENT 2445 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/contrib/src/stc/scintilla/include/Scintilla.iface b/contrib/src/stc/scintilla/include/Scintilla.iface index 9ca4ad539a..06ff4e5800 100644 --- a/contrib/src/stc/scintilla/include/Scintilla.iface +++ b/contrib/src/stc/scintilla/include/Scintilla.iface @@ -2,7 +2,7 @@ ## This file defines the interface to Scintilla -## Copyright 2000-2002 by Neil Hodgson +## Copyright 2000-2003 by Neil Hodgson ## The License.txt file describes the conditions under which this software may be distributed. ## A line starting with ## is a pure comment and should be stripped by readers. @@ -26,7 +26,8 @@ ## A property may be subscripted, in which case the first parameter is the subscript. ## fun, get, and set features have a strict syntax: ## [=,) -## param is [=] +## where stands for white space. +## param may be empty (null value) or is [=] ## Additional white space is allowed between elements. ## The syntax for evt is [=[,]*]) ## Feature names that contain an underscore are defined by Windows, so in these @@ -80,7 +81,7 @@ cat Basics ################################################ ## For Scintilla.h val INVALID_POSITION=-1 -# Define start of Scintilla messages to be greater than all edit (EM_*) messages +# Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages # as many EM_ messages can be used although that use is deprecated. val SCI_START=2000 val SCI_OPTIONAL_START=3000 @@ -131,7 +132,7 @@ fun void SelectAll=2013(,) fun void SetSavePoint=2014(,) # Retrieve a buffer of cells. -# Returns the number of bytes in the buffer not including terminating nulls. +# Returns the number of bytes in the buffer not including terminating NULs. fun int GetStyledText=2015(, textrange tr) # Are there any redoable actions in the undo history? @@ -159,11 +160,11 @@ get int GetViewWS=2020(,) set void SetViewWS=2021(int viewWS,) # Find the position from a point within the window. -fun int PositionFromPoint=2022(int x, int y) +fun position PositionFromPoint=2022(int x, int y) # Find the position from a point within the window but return # INVALID_POSITION if not close to text. -fun int PositionFromPointClose=2023(int x, int y) +fun position PositionFromPointClose=2023(int x, int y) # Set caret to start of a line and ensure it is visible. fun void GotoLine=2024(int line,) @@ -427,7 +428,7 @@ set void SetCaretFore=2069(colour fore,) # When key+modifier combination km is pressed perform msg. fun void AssignCmdKey=2070(keymod km, int msg) -# When key+modifier combination km do nothing. +# When key+modifier combination km is pressed do nothing. fun void ClearCmdKey=2071(keymod km,) # Drop all key mappings. @@ -446,6 +447,7 @@ get int GetCaretPeriod=2075(,) set void SetCaretPeriod=2076(int periodMilliseconds,) # Set the set of characters making up words for when moving or selecting by word. +# First sets deaults like SetCharsDefault. set void SetWordChars=2077(, string characters) # Start a sequence of actions that is undone and redone as a unit. @@ -463,6 +465,7 @@ val INDIC_TT=2 val INDIC_DIAGONAL=3 val INDIC_STRIKE=4 val INDIC_HIDDEN=5 +val INDIC_BOX=6 val INDIC0_MASK=0x20 val INDIC1_MASK=0x40 val INDIC2_MASK=0x80 @@ -711,7 +714,7 @@ val SCFIND_POSIX=0x00400000 fun position FindText=2150(int flags, findtext ft) # On Windows, will draw the document into a display context such as a printer. -fun void FormatRange=2151(bool draw, formatrange fr) +fun position FormatRange=2151(bool draw, formatrange fr) # Retrieve the display line at the top of the display. get int GetFirstVisibleLine=2152(,) @@ -743,7 +746,7 @@ fun void SetSel=2160(position start, position end) # Retrieve the selected text. # Return the length of the text. -fun int GetSelText=2161(,stringresult text) +fun int GetSelText=2161(, stringresult text) # Retrieve a range of text. # Return the length of the text. @@ -762,7 +765,7 @@ fun int PointYFromPosition=2165(, position pos) fun int LineFromPosition=2166(position pos,) # Retrieve the position at the start of a line. -fun int PositionFromLine=2167(int line,) +fun position PositionFromLine=2167(int line,) # Scroll horizontally and vertically. fun void LineScroll=2168(int columns, int lines) @@ -847,12 +850,12 @@ set void SetTargetEnd=2192(position pos,) get position GetTargetEnd=2193(,) # Replace the target text with the argument text. -# Text is counted so it can contain nulls. +# Text is counted so it can contain NULs. # 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. +# Text is counted so it can contain NULs. # 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 @@ -860,7 +863,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 -# range. Text is counted so it can contain nulls. +# range. Text is counted so it can contain NULs. # Returns length of range or -1 for failure in which case target is not moved. fun int SearchInTarget=2197(int length, string text) @@ -1015,7 +1018,7 @@ set void SetScrollWidth=2274(int pixelWidth,) get int GetScrollWidth=2275(,) # Measure the pixel width of some text in a particular style. -# Nul terminated text argument. +# NUL terminated text argument. # Does not handle tab or control characters. fun int TextWidth=2276(int style, string text) @@ -1223,7 +1226,7 @@ fun void LineEndDisplayExtend=2348(,) # except they behave differently when word-wrap is enabled: # They go first to the start / end of the display line, like (Home|LineEnd)Display # The difference is that, the cursor is already at the point, it goes on to the start -# or end of the document line, as appropriate for (Home|LineEnd|VCHome)Extend. +# or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. fun void HomeWrap=2349(,) fun void HomeWrapExtend=2450(,) @@ -1260,7 +1263,7 @@ set void SetViewEOL=2356(bool visible,) get int GetDocPointer=2357(,) # Change the document object used. -set void SetDocPointer=2358(,int pointer) +set void SetDocPointer=2358(, int pointer) # Set which document modification events are sent to the container. set void SetModEventMask=2359(int mask,) @@ -1385,7 +1388,7 @@ fun void DelLineRight=2396(,) set void SetXOffset=2397(int newOffset,) get int GetXOffset=2398(,) -# Set the last x chosen value to be the caret x position +# Set the last x chosen value to be the caret x position. fun void ChooseCaretX=2399(,) # Set the focus to this Scintilla widget. @@ -1427,7 +1430,7 @@ fun void SetYCaretPolicy=2403(int caretPolicy, int caretSlop) # Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). set void SetPrintWrapMode=2406(int mode,) -# Is printing line wrapped. +# Is printing line wrapped? get int GetPrintWrapMode=2407(,) # Set a fore colour for active hotspots. @@ -1439,7 +1442,10 @@ set void SetHotspotActiveBack=2411(bool useSetting, colour back) # Enable / Disable underlining active hotspots. set void SetHotspotActiveUnderline=2412(bool underline,) -# Move caret between paragraphs (delimited by empty lines) +# Limit hotspots to single line so hotspots on two lines don't merge. +set void SetHotspotSingleLine=2421(bool singleLine,) + +# Move caret between paragraphs (delimited by empty lines). fun void ParaDown=2413(,) fun void ParaDownExtend=2414(,) fun void ParaUp=2415(,) @@ -1459,6 +1465,91 @@ fun void CopyRange=2419(position start, position end) # Copy argument text to the clipboard. fun void CopyText=2420(int length, string text) +# Selection modes +enu SelectionMode=SC_SEL_ +val SC_SEL_STREAM=0 +val SC_SEL_RECTANGLE=1 +val SC_SEL_LINES=2 + +# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +# by lines (SC_SEL_LINES). +set void SetSelectionMode=2422(int mode,) + +# Get the mode of the current selection. +get int GetSelectionMode=2423(,) + +# Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelStartPosition=2424(int line,) + +# Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelEndPosition=2425(int line,) + +## RectExtended rectangular selection moves +# Move caret down one line, extending rectangular selection to new caret position. +fun void LineDownRectExtend=2426(,) + +# Move caret up one line, extending rectangular selection to new caret position. +fun void LineUpRectExtend=2427(,) + +# Move caret left one character, extending rectangular selection to new caret position. +fun void CharLeftRectExtend=2428(,) + +# Move caret right one character, extending rectangular selection to new caret position. +fun void CharRightRectExtend=2429(,) + +# Move caret to first position on line, extending rectangular selection to new caret position. +fun void HomeRectExtend=2430(,) + +# Move caret to before first visible character on line. +# If already there move to first character on line. +# In either case, extend rectangular selection to new caret position. +fun void VCHomeRectExtend=2431(,) + +# Move caret to last position on line, extending rectangular selection to new caret position. +fun void LineEndRectExtend=2432(,) + +# Move caret one page up, extending rectangular selection to new caret position. +fun void PageUpRectExtend=2433(,) + +# Move caret one page down, extending rectangular selection to new caret position. +fun void PageDownRectExtend=2434(,) + + +# Move caret to top of page, or one page up if already at top of page. +fun void StutteredPageUp=2435(,) + +# Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. +fun void StutteredPageUpExtend=2436(,) + +# Move caret to bottom of page, or one page down if already at bottom of page. +fun void StutteredPageDown=2437(,) + +# Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. +fun void StutteredPageDownExtend=2438(,) + + +# Move caret left one word, position cursor at end of word. +fun void WordLeftEnd=2439(,) + +# Move caret left one word, position cursor at end of word, extending selection to new caret position. +fun void WordLeftEndExtend=2440(,) + +# Move caret right one word, position cursor at end of word. +fun void WordRightEnd=2441(,) + +# Move caret right one word, position cursor at end of word, extending selection to new caret position. +fun void WordRightEndExtend=2442(,) + +# Set the set of characters making up whitespace for when moving or selecting by word. +# Should be called after SetWordChars. +set void SetWhitespaceChars=2443(, string characters) + +# Reset the set of characters for whitespace and word characters to the defaults. +fun void SetCharsDefault=2444(,) + +# Get currently selected item position in the auto-completion list +fun int AutoCGetCurrent=2445(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) @@ -1486,7 +1577,7 @@ set void SetKeyWords=4005(int keywordSet, string keyWords) # Set the lexing language of the document based on string name. set void SetLexerLanguage=4006(, string language) -# Load a lexer library (dll / so) +# Load a lexer library (dll / so). fun void LoadLexerLibrary=4007(, string path) # Notifications @@ -1591,6 +1682,16 @@ val SCLEX_ESCRIPT=41 val SCLEX_PS=42 val SCLEX_NSIS=43 val SCLEX_MMIXAL=44 +val SCLEX_CLW=45 +val SCLEX_CLWNOCASE=46 +val SCLEX_LOT=47 +val SCLEX_YAML=48 +val SCLEX_TEX=49 +val SCLEX_METAPOST=50 +val SCLEX_POWERBASIC=51 +val SCLEX_FORTH=52 +val SCLEX_ERLANG=53 +val SCLEX_OCTAVE=54 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -1796,9 +1897,10 @@ val SCE_PL_STRING_QQ=27 val SCE_PL_STRING_QX=28 val SCE_PL_STRING_QR=29 val SCE_PL_STRING_QW=30 -# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT +# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC lex VB=SCLEX_VB SCE_B_ lex VBScript=SCLEX_VBSCRIPT SCE_B_ +lex PowerBasic=SCLEX_POWERBASIC SCE_B_ val SCE_B_DEFAULT=0 val SCE_B_COMMENT=1 val SCE_B_NUMBER=2 @@ -1808,6 +1910,10 @@ val SCE_B_PREPROCESSOR=5 val SCE_B_OPERATOR=6 val SCE_B_IDENTIFIER=7 val SCE_B_DATE=8 +val SCE_B_STRINGEOL=9 +val SCE_B_KEYWORD2=10 +val SCE_B_KEYWORD3=11 +val SCE_B_KEYWORD4=12 # Lexical states for SCLEX_PROPERTIES lex Properties=SCLEX_PROPERTIES SCE_PROPS_ val SCE_PROPS_DEFAULT=0 @@ -1863,6 +1969,8 @@ val SCE_ERR_DIFF_MESSAGE=13 val SCE_ERR_PHP=14 val SCE_ERR_ELF=15 val SCE_ERR_IFC=16 +val SCE_ERR_IFORT=17 +val SCE_ERR_ABSF=18 # Lexical states for SCLEX_BATCH lex Batch=SCLEX_BATCH SCE_BAT_ val SCE_BAT_DEFAULT=0 @@ -1982,6 +2090,20 @@ val SCE_NNCRONTAB_NUMBER=7 val SCE_NNCRONTAB_STRING=8 val SCE_NNCRONTAB_ENVIRONMENT=9 val SCE_NNCRONTAB_IDENTIFIER=10 +# Lexical states for SCLEX_FORTH (Forth Lexer) +lex Forth=SCLEX_FORTH SCE_FORTH_ +val SCE_FORTH_DEFAULT=0 +val SCE_FORTH_COMMENT=1 +val SCE_FORTH_COMMENT_ML=2 +val SCE_FORTH_IDENTIFIER=3 +val SCE_FORTH_CONTROL=4 +val SCE_FORTH_KEYWORD=5 +val SCE_FORTH_DEFWORD=6 +val SCE_FORTH_PREWORD1=7 +val SCE_FORTH_PREWORD2=8 +val SCE_FORTH_NUMBER=9 +val SCE_FORTH_STRING=10 +val SCE_FORTH_LOCALE=11 # Lexical states for SCLEX_MATLAB lex MatLab=SCLEX_MATLAB SCE_MATLAB_ val SCE_MATLAB_DEFAULT=0 @@ -1989,31 +2111,29 @@ val SCE_MATLAB_COMMENT=1 val SCE_MATLAB_COMMAND=2 val SCE_MATLAB_NUMBER=3 val SCE_MATLAB_KEYWORD=4 +# single quoted string val SCE_MATLAB_STRING=5 val SCE_MATLAB_OPERATOR=6 val SCE_MATLAB_IDENTIFIER=7 +val SCE_MATLAB_DOUBLEQUOTESTRING=8 # Lexical states for SCLEX_SCRIPTOL lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_ val SCE_SCRIPTOL_DEFAULT=0 -val SCE_SCRIPTOL_COMMENT=1 +val SCE_SCRIPTOL_WHITE=1 val SCE_SCRIPTOL_COMMENTLINE=2 -val SCE_SCRIPTOL_COMMENTDOC=3 -val SCE_SCRIPTOL_NUMBER=4 -val SCE_SCRIPTOL_WORD=5 -val SCE_SCRIPTOL_STRING=6 -val SCE_SCRIPTOL_CHARACTER=7 -val SCE_SCRIPTOL_UUID=8 -val SCE_SCRIPTOL_PREPROCESSOR=9 -val SCE_SCRIPTOL_OPERATOR=10 -val SCE_SCRIPTOL_IDENTIFIER=11 -val SCE_SCRIPTOL_STRINGEOL=12 -val SCE_SCRIPTOL_VERBATIM=13 -val SCE_SCRIPTOL_REGEX=14 -val SCE_SCRIPTOL_COMMENTLINEDOC=15 -val SCE_SCRIPTOL_WORD2=16 -val SCE_SCRIPTOL_COMMENTDOCKEYWORD=17 -val SCE_SCRIPTOL_COMMENTDOCKEYWORDERROR=18 -val SCE_SCRIPTOL_COMMENTBASIC=19 +val SCE_SCRIPTOL_PERSISTENT=3 +val SCE_SCRIPTOL_CSTYLE=4 +val SCE_SCRIPTOL_COMMENTBLOCK=5 +val SCE_SCRIPTOL_NUMBER=6 +val SCE_SCRIPTOL_STRING=7 +val SCE_SCRIPTOL_CHARACTER=8 +val SCE_SCRIPTOL_STRINGEOL=9 +val SCE_SCRIPTOL_KEYWORD=10 +val SCE_SCRIPTOL_OPERATOR=11 +val SCE_SCRIPTOL_IDENTIFIER=12 +val SCE_SCRIPTOL_TRIPLE=13 +val SCE_SCRIPTOL_CLASSNAME=14 +val SCE_SCRIPTOL_PREPROCESSOR=15 # Lexical states for SCLEX_ASM lex Asm=SCLEX_ASM SCE_ASM_ val SCE_ASM_DEFAULT=0 @@ -2027,6 +2147,10 @@ val SCE_ASM_MATHINSTRUCTION=7 val SCE_ASM_REGISTER=8 val SCE_ASM_DIRECTIVE=9 val SCE_ASM_DIRECTIVEOPERAND=10 +val SCE_ASM_COMMENTBLOCK=11 +val SCE_ASM_CHARACTER=12 +val SCE_ASM_STRINGEOL=13 +val SCE_ASM_EXTINSTRUCTION=14 # Lexical states for SCLEX_FORTRAN lex Fortran=SCLEX_FORTRAN SCE_F_ lex F77=SCLEX_F77 SCE_F_ @@ -2162,6 +2286,78 @@ val SCE_MMIXAL_HEX=14 val SCE_MMIXAL_OPERATOR=15 val SCE_MMIXAL_SYMBOL=16 val SCE_MMIXAL_INCLUDE=17 +# Lexical states for SCLEX_CLW +lex Clarion=SCLEX_CLW SCE_CLW_ +val SCE_CLW_DEFAULT=0 +val SCE_CLW_LABEL=1 +val SCE_CLW_COMMENT=2 +val SCE_CLW_STRING=3 +val SCE_CLW_USER_IDENTIFIER=4 +val SCE_CLW_INTEGER_CONSTANT=5 +val SCE_CLW_REAL_CONSTANT=6 +val SCE_CLW_PICTURE_STRING=7 +val SCE_CLW_KEYWORD=8 +val SCE_CLW_COMPILER_DIRECTIVE=9 +val SCE_CLW_BUILTIN_PROCEDURES_FUNCTION=10 +val SCE_CLW_STRUCTURE_DATA_TYPE=11 +val SCE_CLW_ATTRIBUTE=12 +val SCE_CLW_STANDARD_EQUATE=13 +val SCE_CLW_ERROR=14 +# Lexical states for SCLEX_LOT +lex LOT=SCLEX_LOT SCE_LOT_ +val SCE_LOT_DEFAULT=0 +val SCE_LOT_HEADER=1 +val SCE_LOT_BREAK=2 +val SCE_LOT_SET=3 +val SCE_LOT_PASS=4 +val SCE_LOT_FAIL=5 +val SCE_LOT_ABORT=6 +# Lexical states for SCLEX_YAML +lex YAML=SCLEX_YAML SCE_YAML_ +val SCE_YAML_DEFAULT=0 +val SCE_YAML_COMMENT=1 +val SCE_YAML_IDENTIFIER=2 +val SCE_YAML_KEYWORD=3 +val SCE_YAML_NUMBER=4 +val SCE_YAML_REFERENCE=5 +val SCE_YAML_DOCUMENT=6 +val SCE_YAML_TEXT=7 +val SCE_YAML_ERROR=8 +# Lexical states for SCLEX_TEX +lex TeX=SCLEX_TEX SCE_TEX_ +val SCE_TEX_DEFAULT=0 +val SCE_TEX_SPECIAL=1 +val SCE_TEX_GROUP=2 +val SCE_TEX_SYMBOL=3 +val SCE_TEX_COMMAND=4 +val SCE_TEX_TEXT=5 +lex Metapost=SCLEX_METAPOST SCE_METAPOST_ +val SCE_METAPOST_DEFAULT=0 +val SCE_METAPOST_SPECIAL=1 +val SCE_METAPOST_GROUP=2 +val SCE_METAPOST_SYMBOL=3 +val SCE_METAPOST_COMMAND=4 +val SCE_METAPOST_TEXT=5 +val SCE_METAPOST_EXTRA=6 +# Lexical states for SCLEX_ERLANG +lex Erlang=SCLEX_ERLANG SCE_ERLANG_ +val SCE_ERLANG_DEFAULT=0 +val SCE_ERLANG_COMMENT=1 +val SCE_ERLANG_VARIABLE=2 +val SCE_ERLANG_NUMBER=3 +val SCE_ERLANG_KEYWORD=4 +val SCE_ERLANG_STRING=5 +val SCE_ERLANG_OPERATOR=6 +val SCE_ERLANG_ATOM=7 +val SCE_ERLANG_FUNCTION_NAME=8 +val SCE_ERLANG_CHARACTER=9 +val SCE_ERLANG_MACRO=10 +val SCE_ERLANG_RECORD=11 +val SCE_ERLANG_SEPARATOR=12 +val SCE_ERLANG_NODE_NAME=13 +val SCE_ERLANG_UNKNOWN=31 +# Lexical states for SCLEX_OCTAVE are identical to MatLab +lex Octave=SCLEX_OCTAVE SCE_MATLAB_ # Events diff --git a/contrib/src/stc/scintilla/src/CallTip.cxx b/contrib/src/stc/scintilla/src/CallTip.cxx index 314f9bfa71..2f299afffd 100644 --- a/contrib/src/stc/scintilla/src/CallTip.cxx +++ b/contrib/src/stc/scintilla/src/CallTip.cxx @@ -48,6 +48,10 @@ void CallTip::RefreshColourPalette(Palette &pal, bool want) { pal.WantFind(colourLight, want); } +static bool IsArrowCharacter(char ch) { + return (ch >= 0) && (ch <= '\002'); +} + void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw) { @@ -56,7 +60,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int maxEnd = 0; int ends[10]; for (int i=0;i 0) ends[maxEnd++] = i; ends[maxEnd++] = i+1; @@ -68,7 +72,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, for (int seg = 0; seg startSeg) { - if (s[startSeg] <= '\002') { + if (IsArrowCharacter(s[startSeg])) { xEnd = x + widthArrow; offsetMain = xEnd; if (draw) { diff --git a/contrib/src/stc/scintilla/src/ContractionState.cxx b/contrib/src/stc/scintilla/src/ContractionState.cxx index 5b36b2cadf..8833b07bc0 100644 --- a/contrib/src/stc/scintilla/src/ContractionState.cxx +++ b/contrib/src/stc/scintilla/src/ContractionState.cxx @@ -175,6 +175,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) { if (i != 0) // Line zero is always visible lines[i].visible = lines[i + lineCount].visible; lines[i].expanded = lines[i + lineCount].expanded; + lines[i].height = lines[i + lineCount].height; } linesInDoc -= lineCount; linesInDisplay += deltaDisplayed; diff --git a/contrib/src/stc/scintilla/src/Document.cxx b/contrib/src/stc/scintilla/src/Document.cxx index 487262f8ad..fb28144dd7 100644 --- a/contrib/src/stc/scintilla/src/Document.cxx +++ b/contrib/src/stc/scintilla/src/Document.cxx @@ -50,7 +50,7 @@ Document::Document() { stylingBits = 5; stylingBitsMask = 0x1F; stylingMask = 0; - SetWordChars(0); + SetDefaultCharClasses(); endStyled = 0; styleClock = 0; enteredCount = 0; @@ -761,7 +761,7 @@ int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) pos++; } - return pos; + return MovePositionOutsideChar(pos, delta); } /** @@ -791,6 +791,40 @@ int Document::NextWordStart(int pos, int delta) { return pos; } +/** + * Find the end of the next word in either a forward (delta >= 0) or backwards direction + * (delta < 0). + * This is looking for a transition between character classes although there is also some + * additional movement to transit white space. + * Used by cursor movement by word commands. + */ +int Document::NextWordEnd(int pos, int delta) { + if (delta < 0) { + if (pos > 0) { + charClassification ccStart = WordCharClass(cb.CharAt(pos-1)); + if (ccStart != ccSpace) { + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccStart) { + pos--; + } + } + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccSpace) { + pos--; + } + } + } else { + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccSpace) { + pos++; + } + if (pos < Length()) { + charClassification ccStart = WordCharClass(cb.CharAt(pos)); + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccStart) { + pos++; + } + } + } + return pos; +} + /** * Check that the character at the given position is a word or punctuation character and that * the previous character is of a different character class. @@ -1012,7 +1046,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, } } pos += increment; - if (dbcsCodePage) { + if (dbcsCodePage && (pos >= 0)) { // Ensure trying to match from start of character pos = MovePositionOutsideChar(pos, increment, false); } @@ -1032,10 +1066,24 @@ const char *Document::SubstituteByPosition(const char *text, int *length) { return 0; unsigned int lenResult = 0; for (int i = 0; i < *length; i++) { - if ((text[i] == '\\') && (text[i + 1] >= '1' && text[i + 1] <= '9')) { - unsigned int patNum = text[i + 1] - '0'; - lenResult += pre->eopat[patNum] - pre->bopat[patNum]; - i++; + if (text[i] == '\\') { + if (text[i + 1] >= '1' && text[i + 1] <= '9') { + unsigned int patNum = text[i + 1] - '0'; + lenResult += pre->eopat[patNum] - pre->bopat[patNum]; + i++; + } else { + switch (text[i + 1]) { + case 'a': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + i++; + } + lenResult++; + } } else { lenResult++; } @@ -1045,13 +1093,43 @@ const char *Document::SubstituteByPosition(const char *text, int *length) { return 0; char *o = substituted; for (int j = 0; j < *length; j++) { - if ((text[j] == '\\') && (text[j + 1] >= '1' && text[j + 1] <= '9')) { - unsigned int patNum = text[j + 1] - '0'; - unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; - if (pre->pat[patNum]) // Will be null if try for a match that did not occur - memcpy(o, pre->pat[patNum], len); - o += len; - j++; + if (text[j] == '\\') { + if (text[j + 1] >= '1' && text[j + 1] <= '9') { + unsigned int patNum = text[j + 1] - '0'; + unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; + if (pre->pat[patNum]) // Will be null if try for a match that did not occur + memcpy(o, pre->pat[patNum], len); + o += len; + j++; + } else { + j++; + switch (text[j]) { + case 'a': + *o++ = '\a'; + break; + case 'b': + *o++ = '\b'; + break; + case 'f': + *o++ = '\f'; + break; + case 'n': + *o++ = '\n'; + break; + case 'r': + *o++ = '\r'; + break; + case 't': + *o++ = '\t'; + break; + case 'v': + *o++ = '\v'; + break; + default: + *o++ = '\\'; + j--; + } + } } else { *o++ = text[j]; } @@ -1085,26 +1163,27 @@ void Document::ChangeCase(Range r, bool makeUpperCase) { } } -void Document::SetWordChars(unsigned char *chars) { - int ch; - for (ch = 0; ch < 256; ch++) { +void Document::SetDefaultCharClasses() { + // Initialize all char classes to default values + for (int ch = 0; ch < 256; ch++) { if (ch == '\r' || ch == '\n') charClass[ch] = ccNewLine; else if (ch < 0x20 || ch == ' ') charClass[ch] = ccSpace; + else if (ch >= 0x80 || isalnum(ch) || ch == '_') + charClass[ch] = ccWord; else charClass[ch] = ccPunctuation; } +} + +void Document::SetCharClasses(unsigned char *chars, charClassification newCharClass) { + // Apply the newCharClass to the specifed chars if (chars) { while (*chars) { - charClass[*chars] = ccWord; + charClass[*chars] = newCharClass; chars++; } - } else { - for (ch = 0; ch < 256; ch++) { - if (ch >= 0x80 || isalnum(ch) || ch == '_') - charClass[ch] = ccWord; - } } } @@ -1335,14 +1414,18 @@ int Document::WordPartRight(int pos) { return pos; } -int Document::ExtendStyleRange(int pos, int delta) { +bool IsLineEndChar(char c) { + return (c == '\n' || c == '\r'); +} + +int Document::ExtendStyleRange(int pos, int delta, bool singleLine) { int sStart = cb.StyleAt(pos); if (delta < 0) { - while (pos > 0 && (cb.StyleAt(pos) == sStart)) + while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos--; pos++; } else { - while (pos < (Length()) && (cb.StyleAt(pos) == sStart)) + while (pos < (Length()) && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos++; } return pos; diff --git a/contrib/src/stc/scintilla/src/Document.h b/contrib/src/stc/scintilla/src/Document.h index bcdbe00ca5..dc9e38e21d 100644 --- a/contrib/src/stc/scintilla/src/Document.h +++ b/contrib/src/stc/scintilla/src/Document.h @@ -87,11 +87,12 @@ public: userData = 0; } }; + + enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; private: int refCount; CellBuffer cb; - enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; charClassification charClass[256]; char stylingMask; int endStyled; @@ -190,6 +191,7 @@ public: void Indent(bool forwards); int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false); int NextWordStart(int pos, int delta); + int NextWordEnd(int pos, int delta); int Length() { return cb.Length(); } long FindText(int minPos, int maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length); @@ -198,8 +200,9 @@ public: int LinesTotal(); void ChangeCase(Range r, bool makeUpperCase); - - void SetWordChars(unsigned char *chars); + + void SetDefaultCharClasses(); + void SetCharClasses(unsigned char *chars, charClassification newCharClass); void SetStylingBits(int bits); void StartStyling(int position, char mask); bool SetStyleFor(int length, char style); @@ -220,7 +223,7 @@ public: bool IsWordPartSeparator(char ch); int WordPartLeft(int pos); int WordPartRight(int pos); - int ExtendStyleRange(int pos, int delta); + int ExtendStyleRange(int pos, int delta, bool singleLine = false); int ParaUp(int pos); int ParaDown(int pos); diff --git a/contrib/src/stc/scintilla/src/Editor.cxx b/contrib/src/stc/scintilla/src/Editor.cxx index df260ed512..f0f10e25a3 100644 --- a/contrib/src/stc/scintilla/src/Editor.cxx +++ b/contrib/src/stc/scintilla/src/Editor.cxx @@ -35,6 +35,9 @@ active(false), on(false), period(500) {} Timer::Timer() : ticking(false), ticksToWait(0), tickerID(0) {} +Idler::Idler() : +state(false), idlerID(0) {} + LineLayout::LineLayout(int maxLineLength_) : lineStarts(0), lenLineStarts(0), @@ -53,6 +56,8 @@ LineLayout::LineLayout(int maxLineLength_) : styles(0), indicators(0), positions(0), + hsStart(0), + hsEnd(0), widthLine(wrapWidthInfinite), lines(1) { Resize(maxLineLength_); @@ -316,6 +321,7 @@ Editor::Editor() { originalAnchorPos = 0; selType = selStream; + moveExtendsSelection = false; xStartSelect = 0; xEndSelect = 0; primarySelection = true; @@ -373,6 +379,8 @@ Editor::Editor() { wrapState = eWrapNone; wrapWidth = LineLayout::wrapWidthInfinite; docLineLastWrapped = -1; + docLastLineToWrap = -1; + backgroundWrapEnabled = true; hsStart = -1; hsEnd = -1; @@ -393,6 +401,7 @@ Editor::~Editor() { } void Editor::Finalise() { + SetIdle(false); CancelModes(); } @@ -408,6 +417,10 @@ void Editor::InvalidateStyleData() { palette.Release(); DropGraphics(); llc.Invalidate(LineLayout::llInvalid); + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); + } } void Editor::InvalidateStyleRedraw() { @@ -495,7 +508,9 @@ const char *ControlCharacterString(unsigned char ch) { } } -// Convenience class to ensure LineLayout objects are always disposed. +/** + * Convenience class to ensure LineLayout objects are always disposed. + */ class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; @@ -518,6 +533,84 @@ public: } }; +/** + * Allows to iterate through the lines of a selection. + * Althought it can be called for a stream selection, in most cases + * it is inefficient and it should be used only for + * a rectangular or a line selection. + */ +class SelectionLineIterator { +private: + Editor *ed; + int line; ///< Current line within the iteration. + bool forward; ///< True if iterating by increasing line number, false otherwise. + int selStart, selEnd; ///< Positions of the start and end of the selection relative to the start of the document. + int minX, maxX; ///< Left and right of selection rectangle. + +public: + int lineStart, lineEnd; ///< Line numbers, first and last lines of the selection. + int startPos, endPos; ///< Positions of the beginning and end of the selection on the current line. + + void Reset() { + if (forward) { + line = lineStart; + } else { + line = lineEnd; + } + } + + SelectionLineIterator(Editor *ed_, bool forward_ = true) : line(0), startPos(0), endPos(0) { + ed = ed_; + forward = forward_; + selStart = ed->SelectionStart(); + selEnd = ed->SelectionEnd(); + lineStart = ed->pdoc->LineFromPosition(selStart); + lineEnd = ed->pdoc->LineFromPosition(selEnd); + // Left of rectangle + minX = Platform::Minimum(ed->xStartSelect, ed->xEndSelect); + // Right of rectangle + maxX = Platform::Maximum(ed->xStartSelect, ed->xEndSelect); + Reset(); + } + ~SelectionLineIterator() {} + + void SetAt(int line) { + if (line < lineStart || line > lineEnd) { + startPos = endPos = INVALID_POSITION; + } else { + if (ed->selType == ed->selRectangle) { + // Measure line and return character closest to minX + startPos = ed->PositionFromLineX(line, minX); + // Measure line and return character closest to maxX + endPos = ed->PositionFromLineX(line, maxX); + } else if (ed->selType == ed->selLines) { + startPos = ed->pdoc->LineStart(line); + endPos = ed->pdoc->LineStart(line + 1); + } else { // Stream selection, here only for completion + if (line == lineStart) { + startPos = selStart; + } else { + startPos = ed->pdoc->LineStart(line); + } + if (line == lineEnd) { + endPos = selEnd; + } else { + endPos = ed->pdoc->LineStart(line + 1); + } + } + } + } + bool Iterate() { + SetAt(line); + if (forward) { + line++; + } else { + line--; + } + return startPos != INVALID_POSITION; + } +}; + Point Editor::LocationFromPosition(int pos) { Point pt; RefreshStyleData(); @@ -681,8 +774,10 @@ int Editor::PositionFromLineX(int lineDoc, int x) { return retVal; } -// If painting then abandon the painting because a wider redraw is needed. -// Return true if calling code should stop drawing +/** + * If painting then abandon the painting because a wider redraw is needed. + * @return true if calling code should stop drawing. + */ bool Editor::AbandonPaint() { if ((paintState == painting) && !paintingAllText) { paintState = paintAbandoned; @@ -765,63 +860,44 @@ bool Editor::SelectionEmpty() { return anchor == currentPos; } -int Editor::SelectionStart(int line) { - if ((line == -1) || (selType == selStream)) { - return Platform::Minimum(currentPos, anchor); - } else { // selType == selRectangle - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); - int lineStart = pdoc->LineFromPosition(selStart); - int lineEnd = pdoc->LineFromPosition(selEnd); - if (line < lineStart || line > lineEnd) { - return -1; - } else { - int minX = Platform::Minimum(xStartSelect, xEndSelect); - return PositionFromLineX(line, minX); - } - } +int Editor::SelectionStart() { + return Platform::Minimum(currentPos, anchor); } -int Editor::SelectionEnd(int line) { - if ((line == -1) || (selType == selStream)) { - return Platform::Maximum(currentPos, anchor); - } else { // selType == selRectangle - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); - int lineStart = pdoc->LineFromPosition(selStart); - int lineEnd = pdoc->LineFromPosition(selEnd); - if (line < lineStart || line > lineEnd) { - return -1; - } else { - int maxX = Platform::Maximum(xStartSelect, xEndSelect); - // measure line and return character closest to minx - return PositionFromLineX(line, maxX); - } - } +int Editor::SelectionEnd() { + return Platform::Maximum(currentPos, anchor); +} + +void Editor::InvalidateSelection(int currentPos_, int anchor_) { + int firstAffected = anchor; + if (firstAffected > currentPos) + firstAffected = currentPos; + if (firstAffected > anchor_) + firstAffected = anchor_; + if (firstAffected > currentPos_) + firstAffected = currentPos_; + int lastAffected = anchor; + if (lastAffected < currentPos) + lastAffected = currentPos; + if (lastAffected < anchor_) + lastAffected = anchor_; + if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted + lastAffected = (currentPos_ + 1); + needUpdateUI = true; + InvalidateRange(firstAffected, lastAffected); } void Editor::SetSelection(int currentPos_, int anchor_) { currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_); anchor_ = pdoc->ClampPositionIntoDocument(anchor_); if ((currentPos != currentPos_) || (anchor != anchor_)) { - int firstAffected = anchor; - if (firstAffected > currentPos) - firstAffected = currentPos; - if (firstAffected > anchor_) - firstAffected = anchor_; - if (firstAffected > currentPos_) - firstAffected = currentPos_; - int lastAffected = anchor; - if (lastAffected < currentPos) - lastAffected = currentPos; - if (lastAffected < anchor_) - lastAffected = anchor_; - if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted - lastAffected = (currentPos_ + 1); + InvalidateSelection(currentPos_, anchor_); currentPos = currentPos_; anchor = anchor_; - needUpdateUI = true; - InvalidateRange(firstAffected, lastAffected); + } + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); } ClaimSelection(); } @@ -829,25 +905,19 @@ void Editor::SetSelection(int currentPos_, int anchor_) { void Editor::SetSelection(int currentPos_) { currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_); if (currentPos != currentPos_) { - int firstAffected = anchor; - if (firstAffected > currentPos) - firstAffected = currentPos; - if (firstAffected > currentPos_) - firstAffected = currentPos_; - int lastAffected = anchor; - if (lastAffected < currentPos) - lastAffected = currentPos; - if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted - lastAffected = (currentPos_ + 1); + InvalidateSelection(currentPos_, currentPos_); currentPos = currentPos_; - needUpdateUI = true; - InvalidateRange(firstAffected, lastAffected); + } + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); } ClaimSelection(); } void Editor::SetEmptySelection(int currentPos_) { selType = selStream; + moveExtendsSelection = false; SetSelection(currentPos_, currentPos_); } @@ -867,13 +937,27 @@ bool Editor::RangeContainsProtected(int start, int end) const { return false; } -bool Editor::SelectionContainsProtected() const { - // TODO: make support rectangular selection - return RangeContainsProtected(anchor, currentPos); +bool Editor::SelectionContainsProtected() { + // DONE, but untested...: make support rectangular selection + bool scp = false; + if (selType == selStream) { + scp = RangeContainsProtected(anchor, currentPos); + } else { + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + if (RangeContainsProtected(lineIterator.startPos, lineIterator.endPos)) { + scp = true; + break; + } + } + } + return scp; } +/** + * Asks document to find a good position and then moves out of any invisible positions. + */ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { - // Asks document to find a good position and then moves out of any invisible positions pos = pdoc->MovePositionOutsideChar(pos, moveDir, checkLineEnd); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; @@ -894,18 +978,22 @@ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { return pos; } -int Editor::MovePositionTo(int newPos, bool extend, bool ensureVisible) { +int Editor::MovePositionTo(int newPos, selTypes sel, bool ensureVisible) { int delta = newPos - currentPos; newPos = pdoc->ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); - if (extend) { + if (sel != noSel) { + selType = sel; + } + if (sel != noSel || moveExtendsSelection) { SetSelection(newPos); } else { SetEmptySelection(newPos); } ShowCaretAtCurrentPosition(); - if (ensureVisible) + if (ensureVisible) { EnsureCaretVisible(); + } NotifyMove(newPos); return 0; } @@ -929,7 +1017,10 @@ int Editor::MovePositionSoVisible(int pos, int moveDir) { } } -// Choose the x position that the caret will try to stick to as it is moves up and down +/** + * Choose the x position that the caret will try to stick to + * as it moves up and down. + */ void Editor::SetLastXChosen() { Point pt = LocationFromPosition(currentPos); lastXChosen = pt.x; @@ -976,12 +1067,12 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { if (pt.y < rcClient.top) { MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top)), - false, ensureVisible); + noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)), - false, ensureVisible); + noSel, ensureVisible); } } @@ -1032,7 +1123,7 @@ This way, we favour the displaying of useful information: the begining of lines, where most code reside, and the lines after the caret, eg. the body of a function. | | | | | -slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of +slop | strict | jumps | even | Caret can go to the margin | When reaching limitÝ(caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right @@ -1298,18 +1389,57 @@ void Editor::InvalidateCaret() { InvalidateRange(currentPos, currentPos + 1); } -void Editor::NeedWrapping(int docLineStartWrapping) { +void Editor::NeedWrapping(int docLineStartWrapping, int docLineEndWrapping) { + bool noWrap = (docLastLineToWrap == docLineLastWrapped); if (docLineLastWrapped > (docLineStartWrapping - 1)) { docLineLastWrapped = docLineStartWrapping - 1; if (docLineLastWrapped < -1) docLineLastWrapped = -1; llc.Invalidate(LineLayout::llPositions); } + if (noWrap) { + docLastLineToWrap = docLineEndWrapping; + } else if (docLastLineToWrap < docLineEndWrapping) { + docLastLineToWrap = docLineEndWrapping + 1; + } + if (docLastLineToWrap < -1) + docLastLineToWrap = -1; + if (docLastLineToWrap >= pdoc->LinesTotal()) + docLastLineToWrap = pdoc->LinesTotal()-1; + // Wrap lines during idle. + if (backgroundWrapEnabled && docLastLineToWrap != docLineLastWrapped ) { + SetIdle(true); + } } // Check if wrapping needed and perform any needed wrapping. +// fullwrap: if true, all lines which need wrapping will be done, +// in this single call. +// priorityWrapLineStart: If greater than zero, all lines starting from +// here to 100 lines past will be wrapped (even if there are +// more lines under wrapping process in idle). +// If it is neither fullwrap, nor priorityWrap, then 100 lines will be +// wrapped, if there are any wrapping going on in idle. (Generally this +// condition is called only from idler). // Return true if wrapping occurred. -bool Editor::WrapLines() { +bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { + // If there are any pending wraps, do them during idle if possible. + if (wrapState != eWrapNone) { + if (docLineLastWrapped < docLastLineToWrap) { + if (!(backgroundWrapEnabled && SetIdle(true))) { + // Background wrapping is disabled, or idle processing + // not supported. A full wrap is required. + fullWrap = true; + } + } + if (!fullWrap && priorityWrapLineStart >= 0 && + // .. and if the paint window is outside pending wraps + (((priorityWrapLineStart + 100) < docLineLastWrapped) || + (priorityWrapLineStart > docLastLineToWrap))) { + // No priority wrap pending + return false; + } + } int goodTopLine = topLine; bool wrapOccurred = false; if (docLineLastWrapped < pdoc->LinesTotal()) { @@ -1332,21 +1462,47 @@ bool Editor::WrapLines() { wrapWidth = rcTextArea.Width(); // Ensure all of the document is styled. pdoc->EnsureStyledTo(pdoc->Length()); + RefreshStyleData(); AutoSurface surface(this); if (surface) { - int lastLineToWrap = pdoc->LinesTotal(); - while (docLineLastWrapped <= lastLineToWrap) { - docLineLastWrapped++; - AutoLineLayout ll(llc, RetrieveLineLayout(docLineLastWrapped)); + bool priorityWrap = false; + int lastLineToWrap = docLastLineToWrap; + int firstLineToWrap = docLineLastWrapped; + if (!fullWrap) { + if (priorityWrapLineStart >= 0) { + // This is a priority wrap. + firstLineToWrap = priorityWrapLineStart; + lastLineToWrap = firstLineToWrap + 100; + priorityWrap = true; + } else { + // This is idle wrap. + lastLineToWrap = docLineLastWrapped + 100; + } + if (lastLineToWrap >= docLastLineToWrap) + lastLineToWrap = docLastLineToWrap; + } // else do a fullWrap. + + // printf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, firstLineToWrap, lastLineToWrap); + // printf("Pending wraps: %d to %d\n", docLineLastWrapped, docLastLineToWrap); + while (firstLineToWrap < lastLineToWrap) { + firstLineToWrap++; + if (!priorityWrap) + docLineLastWrapped++; + AutoLineLayout ll(llc, RetrieveLineLayout(firstLineToWrap)); int linesWrapped = 1; if (ll) { - LayoutLine(docLineLastWrapped, surface, vs, ll, wrapWidth); + LayoutLine(firstLineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } - if (cs.SetHeight(docLineLastWrapped, linesWrapped)) { + if (cs.SetHeight(firstLineToWrap, linesWrapped)) { wrapOccurred = true; } } + // If wrapping is done, bring it to resting position + if (docLineLastWrapped > docLastLineToWrap) { + docLineLastWrapped = -1; + docLastLineToWrap = -1; + } } goodTopLine = cs.DisplayFromDoc(lineDocTop); if (subLineTop < cs.GetHeight(lineDocTop)) @@ -1666,6 +1822,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; + PLATFORM_ASSERT(line < pdoc->LinesTotal()); int posLineStart = pdoc->LineStart(line); int posLineEnd = pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport @@ -1684,13 +1841,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou int numCharsInLine = 0; // See if chars, styles, indicators, are all the same bool allSame = true; - char styleByte; - int styleMask = pdoc->stylingBitsMask; + const int styleMask = pdoc->stylingBitsMask; // Check base line layout for (int charInDoc = posLineStart; allSame && (charInDoc < posLineEnd); charInDoc++) { char chDoc = pdoc->CharAt(charInDoc); - styleByte = pdoc->StyleAt(charInDoc); - if (vstyle.viewEOL || (!IsEOLChar(chDoc != '\r'))) { + if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { + char styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && (ll->styles[numCharsInLine] == static_cast(styleByte & styleMask)); allSame = allSame && @@ -1884,7 +2040,7 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun (i >= ll->edgeColumn) && !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour.allocated; - if (inHotspot) + if (inHotspot && vsDraw.hotspotBackgroundSet) return vsDraw.hotspotBackground.allocated; if (overrideBackground) return background; @@ -2220,20 +2376,26 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis for (int indica = 0; indica <= INDIC_MAX; indica++) indStart[indica] = 0; - for (int indicPos = 0; indicPos < ll->numCharsInLine; indicPos++) { - if (ll->indicators[indicPos] != ll->indicators[indicPos + 1]) { + for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { + if ((indicPos == lineEnd) || (ll->indicators[indicPos] != ll->indicators[indicPos + 1])) { int mask = 1 << pdoc->stylingBits; for (int indicnum = 0; mask < 0x100; indicnum++) { - if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) { + if ((indicPos == lineEnd)) { + indStart[indicnum] = ll->positions[indicPos]; + } else if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) { indStart[indicnum] = ll->positions[indicPos + 1]; } - if (!(ll->indicators[indicPos + 1] & mask) && (ll->indicators[indicPos] & mask)) { + if ((ll->indicators[indicPos] & mask) && + ((indicPos == lineEnd) || !(ll->indicators[indicPos + 1] & mask))) { + int endIndicator = indicPos; + if (endIndicator >= lineEnd) + endIndicator = lineEnd-1; PRectangle rcIndic( - indStart[indicnum] + xStart, - rcLine.top + vsDraw.maxAscent, - ll->positions[indicPos + 1] + xStart, - rcLine.top + vsDraw.maxAscent + 3); - vsDraw.indicators[indicnum].Draw(surface, rcIndic); + indStart[indicnum] + xStart - subLineStart, + rcLine.top + vsDraw.maxAscent, + ll->positions[endIndicator + 1] + xStart - subLineStart, + rcLine.top + vsDraw.maxAscent + 3); + vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); } mask = mask << 1; } @@ -2358,11 +2520,15 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { needUpdateUI = false; } - PaintSelMargin(surfaceWindow, rcArea); - - if (WrapLines()) { - // The wrapping process has changed the height of some lines so abandon this - // paint for a complete repaint. + // Call priority lines wrap on a window of lines which are likely + // to rendered with the following paint (that is wrap the visible + // lines first). + int startLineToWrap = cs.DocFromDisplay(topLine) - 5; + if (startLineToWrap < 0) + startLineToWrap = -1; + if (WrapLines(false, startLineToWrap)) { + // The wrapping process has changed the height of some lines so + // abandon this paint for a complete repaint. if (AbandonPaint()) { return; } @@ -2370,6 +2536,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } PLATFORM_ASSERT(pixmapSelPattern->Initialised()); + PaintSelMargin(surfaceWindow, rcArea); + PRectangle rcRightMargin = rcClient; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; if (rcArea.Intersects(rcRightMargin)) { @@ -2423,6 +2591,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //ElapsedTime etWhole; int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times AutoLineLayout ll(llc, 0); + SelectionLineIterator lineIterator(this); while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) { int lineDoc = cs.DocFromDisplay(visibleLine); @@ -2442,8 +2611,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //durLayout += et.Duration(true); if (ll) { - ll->selStart = SelectionStart(lineDoc); - ll->selEnd = SelectionEnd(lineDoc); + if (selType == selStream) { + ll->selStart = SelectionStart(); + ll->selEnd = SelectionEnd(); + } else { + lineIterator.SetAt(lineDoc); + ll->selStart = lineIterator.startPos; + ll->selEnd = lineIterator.endPos; + } ll->containsCaret = lineDoc == lineCaret; if (hideSelection) { ll->selStart = -1; @@ -2466,7 +2641,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); //durPaint += et.Duration(true); - // Restore the precvious styles for the brace highlights in case layout is in cache. + // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, braces); bool expanded = cs.GetExpanded(lineDoc); @@ -2917,31 +3092,28 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { void Editor::ClearSelection() { if (!SelectionContainsProtected()) { - if (selType == selRectangle) { + int startPos = SelectionStart(); + if (selType == selStream) { + unsigned int chars = SelectionEnd() - startPos; + if (0 != chars) { + pdoc->BeginUndoAction(); + pdoc->DeleteChars(startPos, chars); + pdoc->EndUndoAction(); + } + } else { pdoc->BeginUndoAction(); - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - int startPos = SelectionStart(); - for (int line = lineEnd; line >= lineStart; line--) { - startPos = SelectionStart(line); - unsigned int chars = SelectionEnd(line) - startPos; + SelectionLineIterator lineIterator(this, false); + while (lineIterator.Iterate()) { + startPos = lineIterator.startPos; + unsigned int chars = lineIterator.endPos - startPos; if (0 != chars) { pdoc->DeleteChars(startPos, chars); } } - SetEmptySelection(startPos); pdoc->EndUndoAction(); selType = selStream; - } else { - int startPos = SelectionStart(); - unsigned int chars = SelectionEnd() - startPos; - SetEmptySelection(startPos); - if (0 != chars) { - pdoc->BeginUndoAction(); - pdoc->DeleteChars(startPos, chars); - pdoc->EndUndoAction(); - } } + SetEmptySelection(startPos); } } @@ -3234,20 +3406,18 @@ void Editor::CheckModificationForWrap(DocModification mh) { llc.Invalidate(LineLayout::llCheckTextAndStyle); if (wrapState != eWrapNone) { int lineDoc = pdoc->LineFromPosition(mh.position); - if (mh.linesAdded == 0) { + if (mh.linesAdded <= 0) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); if (cs.GetHeight(lineDoc) != ll->lines) { - NeedWrapping(lineDoc - 1); + NeedWrapping(lineDoc - 1, lineDoc + 1); Redraw(); } - } else { - NeedWrapping(lineDoc); } } else { - NeedWrapping(lineDoc); + NeedWrapping(lineDoc, lineDoc + 1 + mh.linesAdded); } } } @@ -3281,7 +3451,6 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } - CheckModificationForWrap(mh); if (mh.modificationType & SC_MOD_CHANGESTYLE) { if (paintState == notPainting) { if (mh.position < pdoc->LineStart(topLine)) { @@ -3322,6 +3491,9 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { } else { cs.DeleteLines(lineOfPos, -mh.linesAdded); } + } + CheckModificationForWrap(mh); + if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine) { int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); @@ -3420,6 +3592,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: + case SCI_WORDLEFTEND: + case SCI_WORDLEFTENDEXTEND: + case SCI_WORDRIGHTEND: + case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: @@ -3432,6 +3608,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: + case SCI_STUTTEREDPAGEUP: + case SCI_STUTTEREDPAGEUPEXTEND: + case SCI_STUTTEREDPAGEDOWN: + case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: @@ -3464,10 +3644,20 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: - break; - - // Filter out all others like display changes. Also, newlines are redundant - // with char insert messages. + case SCI_SETSELECTIONMODE: + case SCI_LINEDOWNRECTEXTEND: + case SCI_LINEUPRECTEXTEND: + case SCI_CHARLEFTRECTEXTEND: + case SCI_CHARRIGHTRECTEXTEND: + case SCI_HOMERECTEXTEND: + case SCI_VCHOMERECTEXTEND: + case SCI_LINEENDRECTEXTEND: + case SCI_PAGEUPRECTEXTEND: + case SCI_PAGEDOWNRECTEXTEND: + break; + + // Filter out all others like display changes. Also, newlines are redundant + // with char insert messages. case SCI_NEWLINE: default: // printf("Filtered out %ld of macro recording\n", iMessage); @@ -3483,20 +3673,44 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long NotifyParent(scn); } -// Force scroll and keep position relative to top of window -void Editor::PageMove(int direction, bool extend) { - Point pt = LocationFromPosition(currentPos); - int topLineNew = Platform::Clamp( +/** + * Force scroll and keep position relative to top of window. + * + * If stuttered = true and not already at first/last row, move to first/last row of window. + * If stuttered = true and already at first/last row, scroll as normal. + */ +void Editor::PageMove(int direction, selTypes sel, bool stuttered) { + int topLineNew, newPos; + + // I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem? + int currentLine = pdoc->LineFromPosition(currentPos); + int topStutterLine = topLine + caretYSlop; + int bottomStutterLine = topLine + LinesToScroll() - caretYSlop; + + if (stuttered && (direction < 0 && currentLine > topStutterLine)) { + topLineNew = topLine; + newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * caretYSlop)); + + } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { + topLineNew = topLine; + newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * (LinesToScroll() - caretYSlop))); + + } else { + Point pt = LocationFromPosition(currentPos); + + topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); - int newPos = PositionFromLocation( + newPos = PositionFromLocation( Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll()))); + } + if (topLineNew != topLine) { SetTopLine(topLineNew); - MovePositionTo(newPos, extend); + MovePositionTo(newPos, sel); Redraw(); SetVerticalScrollPos(); } else { - MovePositionTo(newPos, extend); + MovePositionTo(newPos, sel); } } @@ -3504,21 +3718,19 @@ void Editor::ChangeCaseOfSelection(bool makeUpperCase) { pdoc->BeginUndoAction(); int startCurrent = currentPos; int startAnchor = anchor; - if (selType == selRectangle) { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - for (int line = lineEnd; line >= lineStart; line--) { + if (selType == selStream) { + pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), + makeUpperCase); + SetSelection(startCurrent, startAnchor); + } else { + SelectionLineIterator lineIterator(this, false); + while (lineIterator.Iterate()) { pdoc->ChangeCase( - Range(SelectionStart(line), SelectionEnd(line)), + Range(lineIterator.startPos, lineIterator.endPos), makeUpperCase); } // Would be nicer to keep the rectangular selection but this is complex - selType = selStream; - SetSelection(startCurrent, startCurrent); - } else { - pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), - makeUpperCase); - SetSelection(startCurrent, startAnchor); + SetEmptySelection(startCurrent); } pdoc->EndUndoAction(); } @@ -3566,7 +3778,9 @@ void Editor::LineDuplicate() { delete []thisLine; } -void Editor::CancelModes() {} +void Editor::CancelModes() { + moveExtendsSelection = false; +} void Editor::NewLine() { ClearSelection(); @@ -3587,7 +3801,7 @@ void Editor::NewLine() { EnsureCaretVisible(); } -void Editor::CursorUpOrDown(int direction, bool extend) { +void Editor::CursorUpOrDown(int direction, selTypes sel) { Point pt = LocationFromPosition(currentPos); int posNew = PositionFromLocation( Point(lastXChosen, pt.y + direction * vs.lineHeight)); @@ -3602,7 +3816,7 @@ void Editor::CursorUpOrDown(int direction, bool extend) { ptNew = LocationFromPosition(posNew); } } - MovePositionTo(posNew, extend); + MovePositionTo(posNew, sel); } int Editor::StartEndDisplayLine(int pos, bool start) { @@ -3643,13 +3857,16 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: - CursorUpOrDown(1, true); + CursorUpOrDown(1, selStream); + break; + case SCI_LINEDOWNRECTEXTEND: + CursorUpOrDown(1, selRectangle); break; case SCI_PARADOWN: MovePositionTo(pdoc->ParaDown(currentPos)); break; case SCI_PARADOWNEXTEND: - MovePositionTo(pdoc->ParaDown(currentPos), true); + MovePositionTo(pdoc->ParaDown(currentPos), selStream); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); @@ -3659,20 +3876,23 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: - CursorUpOrDown(-1, true); + CursorUpOrDown(-1, selStream); + break; + case SCI_LINEUPRECTEXTEND: + CursorUpOrDown(-1, selRectangle); break; case SCI_PARAUP: MovePositionTo(pdoc->ParaUp(currentPos)); break; case SCI_PARAUPEXTEND: - MovePositionTo(pdoc->ParaUp(currentPos), true); + MovePositionTo(pdoc->ParaUp(currentPos), selStream); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); break; case SCI_CHARLEFT: - if (SelectionEmpty()) { + if (SelectionEmpty() || moveExtendsSelection) { MovePositionTo(MovePositionSoVisible(currentPos - 1, -1)); } else { MovePositionTo(SelectionStart()); @@ -3680,11 +3900,15 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_CHARLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), true); + MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selStream); + SetLastXChosen(); + break; + case SCI_CHARLEFTRECTEXTEND: + MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selRectangle); SetLastXChosen(); break; case SCI_CHARRIGHT: - if (SelectionEmpty()) { + if (SelectionEmpty() || moveExtendsSelection) { MovePositionTo(MovePositionSoVisible(currentPos + 1, 1)); } else { MovePositionTo(SelectionEnd()); @@ -3692,7 +3916,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_CHARRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), true); + MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selStream); + SetLastXChosen(); + break; + case SCI_CHARRIGHTRECTEXTEND: + MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selRectangle); SetLastXChosen(); break; case SCI_WORDLEFT: @@ -3700,7 +3928,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1), true); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1), selStream); SetLastXChosen(); break; case SCI_WORDRIGHT: @@ -3708,15 +3936,37 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1), true); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1), selStream); + SetLastXChosen(); + break; + + case SCI_WORDLEFTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1)); + SetLastXChosen(); + break; + case SCI_WORDLEFTENDEXTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1), selStream); + SetLastXChosen(); + break; + case SCI_WORDRIGHTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1)); SetLastXChosen(); break; + case SCI_WORDRIGHTENDEXTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1), selStream); + SetLastXChosen(); + break; + case SCI_HOME: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos))); SetLastXChosen(); break; case SCI_HOMEEXTEND: - MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), true); + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selStream); + SetLastXChosen(); + break; + case SCI_HOMERECTEXTEND: + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selRectangle); SetLastXChosen(); break; case SCI_LINEEND: @@ -3724,7 +3974,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_LINEENDEXTEND: - MovePositionTo(pdoc->LineEndPosition(currentPos), true); + MovePositionTo(pdoc->LineEndPosition(currentPos), selStream); + SetLastXChosen(); + break; + case SCI_LINEENDRECTEXTEND: + MovePositionTo(pdoc->LineEndPosition(currentPos), selRectangle); SetLastXChosen(); break; case SCI_HOMEWRAP: { @@ -3739,7 +3993,7 @@ int Editor::KeyCommand(unsigned int iMessage) { int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); if (currentPos <= homePos) homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos)); - MovePositionTo(homePos, true); + MovePositionTo(homePos, selStream); SetLastXChosen(); } break; @@ -3755,7 +4009,7 @@ int Editor::KeyCommand(unsigned int iMessage) { int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1); if (currentPos >= endPos) endPos = pdoc->LineEndPosition(currentPos); - MovePositionTo(endPos, true); + MovePositionTo(endPos, selStream); SetLastXChosen(); } break; @@ -3764,7 +4018,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTSTARTEXTEND: - MovePositionTo(0, true); + MovePositionTo(0, selStream); SetLastXChosen(); break; case SCI_DOCUMENTEND: @@ -3772,20 +4026,38 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTENDEXTEND: - MovePositionTo(pdoc->Length(), true); + MovePositionTo(pdoc->Length(), selStream); SetLastXChosen(); break; + case SCI_STUTTEREDPAGEUP: + PageMove(-1, noSel, true); + break; + case SCI_STUTTEREDPAGEUPEXTEND: + PageMove(-1, selStream, true); + break; + case SCI_STUTTEREDPAGEDOWN: + PageMove(1, noSel, true); + break; + case SCI_STUTTEREDPAGEDOWNEXTEND: + PageMove(1, selStream, true); + break; case SCI_PAGEUP: PageMove(-1); break; case SCI_PAGEUPEXTEND: - PageMove(-1, true); + PageMove(-1, selStream); + break; + case SCI_PAGEUPRECTEXTEND: + PageMove(-1, selRectangle); break; case SCI_PAGEDOWN: PageMove(1); break; case SCI_PAGEDOWNEXTEND: - PageMove(1, true); + PageMove(1, selStream); + break; + case SCI_PAGEDOWNRECTEXTEND: + PageMove(1, selRectangle); break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; @@ -3828,7 +4100,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_VCHOMEEXTEND: - MovePositionTo(pdoc->VCHomePosition(currentPos), true); + MovePositionTo(pdoc->VCHomePosition(currentPos), selStream); + SetLastXChosen(); + break; + case SCI_VCHOMERECTEXTEND: + MovePositionTo(pdoc->VCHomePosition(currentPos), selRectangle); SetLastXChosen(); break; case SCI_VCHOMEWRAP: { @@ -3847,7 +4123,7 @@ int Editor::KeyCommand(unsigned int iMessage) { if ((viewLineStart < currentPos) && (viewLineStart > homePos)) homePos = viewLineStart; - MovePositionTo(homePos, true); + MovePositionTo(homePos, selStream); SetLastXChosen(); } break; @@ -3930,7 +4206,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDPARTLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1), true); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1), selStream); SetLastXChosen(); break; case SCI_WORDPARTRIGHT: @@ -3938,7 +4214,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDPARTRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), true); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), selStream); SetLastXChosen(); break; case SCI_HOMEDISPLAY: @@ -3948,7 +4224,7 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1), true); + StartEndDisplayLine(currentPos, true), -1), selStream); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: @@ -3958,7 +4234,7 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1), true); + StartEndDisplayLine(currentPos, false), 1), selStream); SetLastXChosen(); break; } @@ -4073,9 +4349,9 @@ void Editor::Indent(bool forwards) { * @return The position of the found text, -1 if not found. */ long Editor::FindText( - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, - ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. - sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. + sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. TextToFind *ft = reinterpret_cast(lParam); int lengthFound = istrlen(ft->lpstrText); @@ -4114,9 +4390,9 @@ void Editor::SearchAnchor() { * @return The position of the found text, -1 if not found. */ long Editor::SearchText( - unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, - ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. + unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< The text to search for. const char *txt = reinterpret_cast(lParam); @@ -4205,36 +4481,45 @@ void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) { } void Editor::CopySelectionRange(SelectionText *ss) { - if (selType == selRectangle) { + if (selType == selStream) { + CopySelectionFromRange(ss, SelectionStart(), SelectionEnd()); + } else { char *text = 0; int size = 0; - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - int line; - for (line = lineStart; line <= lineEnd; line++) { - size += SelectionEnd(line) - SelectionStart(line) + 1; - if (pdoc->eolMode == SC_EOL_CRLF) + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + size += lineIterator.endPos - lineIterator.startPos; + if (selType != selLines) { size++; + if (pdoc->eolMode == SC_EOL_CRLF) { + size++; + } + } } if (size > 0) { text = new char[size + 1]; if (text) { int j = 0; - for (line = lineStart; line <= lineEnd; line++) { - for (int i = SelectionStart(line);i < SelectionEnd(line);i++) { + lineIterator.Reset(); + while (lineIterator.Iterate()) { + for (int i = lineIterator.startPos; + i < lineIterator.endPos; + i++) { text[j++] = pdoc->CharAt(i); } - if (pdoc->eolMode != SC_EOL_LF) - text[j++] = '\r'; - if (pdoc->eolMode != SC_EOL_CR) - text[j++] = '\n'; + if (selType != selLines) { + if (pdoc->eolMode != SC_EOL_LF) { + text[j++] = '\r'; + } + if (pdoc->eolMode != SC_EOL_CR) { + text[j++] = '\n'; + } + } } text[size] = '\0'; } } - ss->Set(text, size + 1, true); - } else { - CopySelectionFromRange(ss, SelectionStart(), SelectionEnd()); + ss->Set(text, size + 1, selType == selRectangle); } } @@ -4300,17 +4585,14 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul int positionAfterDeletion = position; if (inDragDrop && moving) { // Remove dragged out text - if (rectangular) { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - for (int line = lineStart; line <= lineEnd; line++) { - int startPos = SelectionStart(line); - int endPos = SelectionEnd(line); - if (position >= startPos) { - if (position > endPos) { - positionAfterDeletion -= endPos - startPos; + if (rectangular || selType == selLines) { + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + if (position >= lineIterator.startPos) { + if (position > lineIterator.endPos) { + positionAfterDeletion -= lineIterator.endPos - lineIterator.startPos; } else { - positionAfterDeletion -= position - startPos; + positionAfterDeletion -= position - lineIterator.startPos; } } } @@ -4327,7 +4609,7 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul PasteRectangular(position, value, istrlen(value)); pdoc->EndUndoAction(); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position - SetSelection(position, position); + SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, currentPos - position); if (pdoc->InsertString(position, value)) { @@ -4336,53 +4618,65 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul pdoc->EndUndoAction(); } } else if (inDragDrop) { - SetSelection(position, position); + SetEmptySelection(position); } } -static int BeforeInOrAfter(int val, int minim, int maxim) { - if (val < minim) +/** + * @return -1 if given position is before the selection, + * 1 if position is after the selection, + * 0 if position is inside the selection, + */ +int Editor::PositionInSelection(int pos) { + pos = MovePositionOutsideChar(pos, currentPos - pos); + if (pos < SelectionStart()) { return -1; - else if (val > maxim) + } + if (pos > SelectionEnd()) { return 1; - else + } + if (selType == selStream) { return 0; -} - -int Editor::PositionInSelection(int pos) { - pos = MovePositionOutsideChar(pos, currentPos - pos); - if (selType == selRectangle) { - if (pos < SelectionStart()) + } else { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(pdoc->LineFromPosition(pos)); + if (pos < lineIterator.startPos) { return -1; - if (pos > SelectionEnd()) + } else if (pos > lineIterator.endPos) { return 1; - int linePos = pdoc->LineFromPosition(pos); - return BeforeInOrAfter(pos, SelectionStart(linePos), SelectionEnd(linePos)); - } else { - if (currentPos > anchor) { - return BeforeInOrAfter(pos, anchor, currentPos); - } else if (currentPos < anchor) { - return BeforeInOrAfter(pos, currentPos, anchor); + } else { + return 0; } } - return 1; } bool Editor::PointInSelection(Point pt) { - // TODO: fix up for rectangular selection int pos = PositionFromLocation(pt); if (0 == PositionInSelection(pos)) { - if (pos == SelectionStart()) { + // Probably inside, but we must make a finer test + int selStart, selEnd; + if (selType == selStream) { + selStart = SelectionStart(); + selEnd = SelectionEnd(); + } else { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(pdoc->LineFromPosition(pos)); + selStart = lineIterator.startPos; + selEnd = lineIterator.endPos; + } + if (pos == selStart) { // see if just before selection Point locStart = LocationFromPosition(pos); - if (pt.x < locStart.x) + if (pt.x < locStart.x) { return false; + } } - if (pos == SelectionEnd()) { + if (pos == selEnd) { // see if just after selection Point locEnd = LocationFromPosition(pos); - if (pt.x > locEnd.x) + if (pt.x > locEnd.x) { return false; + } } return true; } @@ -4430,6 +4724,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b int newPos = PositionFromLocation(pt); newPos = MovePositionOutsideChar(newPos, currentPos - newPos); inDragDrop = false; + moveExtendsSelection = false; bool processed = NotifyMarginClick(pt, shift, ctrl, alt); if (processed) @@ -4475,7 +4770,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift); - if (PositionIsHotspot(newPos)) + if (PointIsHotspot(newPos)) NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt); } } else { // Single click @@ -4507,7 +4802,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b SetMouseCapture(true); selectionType = selLine; } else { - if (PositionIsHotspot(newPos)) { + if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newPos, shift, ctrl, alt); } if (!shift) { @@ -4519,13 +4814,13 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b CopySelectionRange(&drag); StartDrag(); } else { - xStartSelect = pt.x - vs.fixedColumnWidth + xOffset; - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; SetDragPosition(invalidPosition); SetMouseCapture(true); - if (!shift) + if (!shift) { SetEmptySelection(newPos); + } selType = alt ? selRectangle : selStream; + xStartSelect = xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; selectionType = selChar; originalAnchorPos = currentPos; } @@ -4537,11 +4832,13 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } bool Editor::PositionIsHotspot(int position) { - return vs.styles[pdoc->StyleAt(position)].hotspot; + return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; } bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocation(pt); + int pos = PositionFromLocationClose(pt); + if (pos == INVALID_POSITION) + return false; return PositionIsHotspot(pos); } @@ -4552,8 +4849,8 @@ void Editor::SetHotSpotRange(Point *pt) { // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. - int hsStart_ = pdoc->ExtendStyleRange(pos, -1); - int hsEnd_ = pdoc->ExtendStyleRange(pos, 1); + int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); + int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... if (hsStart_ != hsStart || hsEnd_ != hsEnd) { @@ -4598,7 +4895,6 @@ void Editor::ButtonMove(Point pt) { autoScrollTimer.ticksToWait = autoScrollDelay; // Adjust selection - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; int movePos = PositionFromLocation(pt); movePos = MovePositionOutsideChar(movePos, currentPos - movePos); if (posDrag >= 0) { @@ -4608,7 +4904,17 @@ void Editor::ButtonMove(Point pt) { SetSelection(movePos); } else if (selectionType == selWord) { // Continue selecting by word - if (movePos >= originalAnchorPos) { // Moved forward + if (movePos == originalAnchorPos) { // Didn't move + // No need to do anything. Previously this case was lumped + // in with "Moved forward", but that can be harmful in this + // case: a handler for the NotifyDoubleClick re-adjusts + // the selection for a fancier definition of "word" (for + // example, in Perl it is useful to include the leading + // '$', '%' or '@' on variables for word selection). In this + // the ButtonMove() called via Tick() for auto-scrolling + // could result in the fancier word selection adjustment + // being unmade. + } else if (movePos > originalAnchorPos) { // Moved forward SetSelection(pdoc->ExtendWordSelect(movePos, 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward @@ -4621,6 +4927,9 @@ void Editor::ButtonMove(Point pt) { LineSelection(lineMove, lineAnchor); } } + // While dragging to make rectangular selection, we don't want the current + // position to jump to the end of smaller or empty lines. + xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; // Autoscroll PRectangle rcClient = GetClientRectangle(); @@ -4659,7 +4968,6 @@ void Editor::ButtonMove(Point pt) { SetHotSpotRange(NULL); } } - } void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { @@ -4671,7 +4979,6 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; ptMouseLast = pt; SetMouseCapture(false); int newPos = PositionFromLocation(pt); @@ -4708,6 +5015,9 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { SetSelection(newPos); } } + // Now we rely on the current pos to compute rectangular selection + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x; @@ -4745,6 +5055,30 @@ void Editor::Tick() { } } +bool Editor::Idle() { + + bool idleDone; + + bool wrappingDone = (wrapState == eWrapNone) || (!backgroundWrapEnabled); + + if (!wrappingDone) { + // Wrap lines during idle. + WrapLines(false, -1); + // No more wrapping + if (docLineLastWrapped == docLastLineToWrap) + wrappingDone = true; + } + + // Add more idle things to do here, but make sure idleDone is + // set correctly before the function returns. returning + // false will stop calling this idle funtion until SetIdle() is + // called again. + + idleDone = wrappingDone; // && thatDone && theOtherThingDone... + + return !idleDone; +} + void Editor::SetFocusState(bool focusState) { hasFocus = focusState; NotifyFocus(hasFocus); @@ -4898,6 +5232,7 @@ void Editor::SetDocPointer(Document *document) { pdoc->AddRef(); // Ensure all positions within document + selType = selStream; currentPos = 0; anchor = 0; targetStart = 0; @@ -4914,7 +5249,9 @@ void Editor::SetDocPointer(Document *document) { SetScrollBars(); } -// Recursively expand a fold, making lines visible except where they have an unexpanded parent +/** + * Recursively expand a fold, making lines visible except where they have an unexpanded parent. + */ void Editor::Expand(int &line, bool doExpand) { int lineMaxSubord = pdoc->GetLastChild(line); line++; @@ -4953,12 +5290,14 @@ void Editor::ToggleContraction(int line) { } } -// Recurse up from this line to find any folds that prevent this line from being visible -// and unfold them all-> +/** + * Recurse up from this line to find any folds that prevent this line from being visible + * and unfold them all. + */ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { // In case in need of wrapping to ensure DisplayFromDoc works. - WrapLines(); + WrapLines(true, -1); if (!cs.GetVisible(lineDoc)) { int lineParent = pdoc->GetFoldParent(lineDoc); @@ -5157,7 +5496,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (selectedText.len) { for (; iChar < selectedText.len; iChar++) ptr[iChar] = selectedText.s[iChar]; - ptr[iChar] = '\0'; } else { ptr[0] = '\0'; } @@ -5307,6 +5645,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); + PLATFORM_ASSERT(cpMax <= pdoc->Length()); int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); // Spec says copied text is terminated with a NUL @@ -5360,7 +5699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; int insertPos = wParam; - if (static_cast(wParam) == -1) + if (static_cast(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); char *sz = CharPtrFromSPtr(lParam); @@ -5406,12 +5745,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETWORDCHARS: { + pdoc->SetDefaultCharClasses(); if (lParam == 0) return 0; - pdoc->SetWordChars(reinterpret_cast(lParam)); + pdoc->SetCharClasses(reinterpret_cast(lParam), Document::ccWord); } break; + case SCI_SETWHITESPACECHARS: { + if (lParam == 0) + return 0; + pdoc->SetCharClasses(reinterpret_cast(lParam), Document::ccSpace); + } + break; + + case SCI_SETCHARSDEFAULT: + pdoc->SetDefaultCharClasses(); + break; + case SCI_GETLENGTH: return pdoc->Length(); @@ -5468,7 +5819,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return printWrapState; case SCI_GETSTYLEAT: - if (static_cast(wParam) >= pdoc->Length()) + if (static_cast(wParam) >= pdoc->Length()) return 0; else return pdoc->StyleAt(wParam); @@ -5843,8 +6194,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINWIDTHN: if (ValidMargin(wParam)) { - vs.ms[wParam].width = lParam; - InvalidateStyleRedraw(); + // Short-circuit if the width is unchanged, to avoid unnecessary redraw. + if (vs.ms[wParam].width != lParam) { + vs.ms[wParam].width = lParam; + InvalidateStyleRedraw(); + } } break; @@ -6192,6 +6546,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: + case SCI_WORDLEFTEND: + case SCI_WORDLEFTENDEXTEND: + case SCI_WORDRIGHTEND: + case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: @@ -6204,6 +6562,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: + + case SCI_STUTTEREDPAGEUP: + case SCI_STUTTEREDPAGEUPEXTEND: + case SCI_STUTTEREDPAGEDOWN: + case SCI_STUTTEREDPAGEDOWNEXTEND: + case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: @@ -6243,6 +6607,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: + case SCI_LINEDOWNRECTEXTEND: + case SCI_LINEUPRECTEXTEND: + case SCI_CHARLEFTRECTEXTEND: + case SCI_CHARRIGHTRECTEXTEND: + case SCI_HOMERECTEXTEND: + case SCI_VCHOMERECTEXTEND: + case SCI_LINEENDRECTEXTEND: + case SCI_PAGEUPRECTEXTEND: + case SCI_PAGEDOWNRECTEXTEND: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: @@ -6336,7 +6709,49 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_SELECTIONISRECTANGLE: - return (selType == selRectangle) ? 1 : 0; + return selType == selRectangle ? 1 : 0; + + case SCI_SETSELECTIONMODE: { + switch (wParam) { + case SC_SEL_STREAM: + moveExtendsSelection = !moveExtendsSelection || (selType != selStream); + selType = selStream; + break; + case SC_SEL_RECTANGLE: + moveExtendsSelection = !moveExtendsSelection || (selType != selRectangle); + selType = selRectangle; + break; + case SC_SEL_LINES: + moveExtendsSelection = !moveExtendsSelection || (selType != selLines); + selType = selLines; + break; + default: + moveExtendsSelection = !moveExtendsSelection || (selType != selStream); + selType = selStream; + } + InvalidateSelection(currentPos, anchor); + } + case SCI_GETSELECTIONMODE: + switch (selType) { + case selStream: + return SC_SEL_STREAM; + case selRectangle: + return SC_SEL_RECTANGLE; + case selLines: + return SC_SEL_LINES; + default: // ?! + return SC_SEL_STREAM; + } + case SCI_GETLINESELSTARTPOSITION: { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(wParam); + return lineIterator.startPos; + } + case SCI_GETLINESELENDPOSITION: { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(wParam); + return lineIterator.endPos; + } case SCI_SETOVERTYPE: inOverstrike = wParam != 0; @@ -6422,6 +6837,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_SETHOTSPOTSINGLELINE: + vs.hotspotSingleLine = wParam != 0; + InvalidateStyleRedraw(); + break; + default: return DefWndProc(iMessage, wParam, lParam); } diff --git a/contrib/src/stc/scintilla/src/Editor.h b/contrib/src/stc/scintilla/src/Editor.h index bd4669192f..08c56f7a41 100644 --- a/contrib/src/stc/scintilla/src/Editor.h +++ b/contrib/src/stc/scintilla/src/Editor.h @@ -31,6 +31,16 @@ public: Timer(); }; +/** + */ +class Idler { +public: + bool state; + IdlerID idlerID; + + Idler(); +}; + /** */ class LineLayout { @@ -115,6 +125,10 @@ public: void Dispose(LineLayout *ll); }; +/** + * Hold a piece of text selected for copying or dragging. + * The text is expected to hold a terminating '\0'. + */ class SelectionText { public: char *s; @@ -208,6 +222,8 @@ protected: // ScintillaBase subclass needs access to much of Editor Timer autoScrollTimer; enum { autoScrollDelay = 200 }; + Idler idler; + Point lastClick; unsigned int lastClickTime; int dwellDelay; @@ -244,9 +260,11 @@ protected: // ScintillaBase subclass needs access to much of Editor int modEventMask; SelectionText drag; - enum { selStream, selRectangle, selRectangleFixed } selType; - int xStartSelect; - int xEndSelect; + enum selTypes { noSel, selStream, selRectangle, selLines }; + selTypes selType; + bool moveExtendsSelection; + int xStartSelect; ///< x position of start of rectangular selection + int xEndSelect; ///< x position of end of rectangular selection bool primarySelection; int caretXPolicy; @@ -271,8 +289,10 @@ protected: // ScintillaBase subclass needs access to much of Editor // Wrapping support enum { eWrapNone, eWrapWord } wrapState; + bool backgroundWrapEnabled; int wrapWidth; int docLineLastWrapped; + int docLastLineToWrap; Document *pdoc; @@ -310,15 +330,16 @@ protected: // ScintillaBase subclass needs access to much of Editor int CurrentPosition(); bool SelectionEmpty(); - int SelectionStart(int line=-1); - int SelectionEnd(int line=-1); + int SelectionStart(); + int SelectionEnd(); + void InvalidateSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_); void SetEmptySelection(int currentPos_); bool RangeContainsProtected(int start, int end) const; - bool SelectionContainsProtected() const; + bool SelectionContainsProtected(); int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); - int MovePositionTo(int newPos, bool extend=false, bool ensureVisible=true); + int MovePositionTo(int newPos, selTypes sel=noSel, bool ensureVisible=true); int MovePositionSoVisible(int pos, int moveDir); void SetLastXChosen(); @@ -332,8 +353,8 @@ protected: // ScintillaBase subclass needs access to much of Editor void DropCaret(); void InvalidateCaret(); - void NeedWrapping(int docLineStartWrapping=0); - bool WrapLines(); + void NeedWrapping(int docLineStartWrapping = 0, int docLineEndWrapping = 0x7ffffff); + bool WrapLines(bool fullWrap, int priorityWrapLineStart); void LinesJoin(); void LinesSplit(int pixelWidth); @@ -406,13 +427,13 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyStyleNeeded(Document *doc, void *userData, int endPos); void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - void PageMove(int direction, bool extend=false); + void PageMove(int direction, selTypes sel=noSel, bool stuttered = false); void ChangeCaseOfSelection(bool makeUpperCase); void LineTranspose(); void LineDuplicate(); virtual void CancelModes(); void NewLine(); - void CursorUpOrDown(int direction, bool extend=false); + void CursorUpOrDown(int direction, selTypes sel=noSel); int StartEndDisplayLine(int pos, bool start); virtual int KeyCommand(unsigned int iMessage); virtual int KeyDefault(int /* key */, int /*modifiers*/); @@ -451,7 +472,9 @@ protected: // ScintillaBase subclass needs access to much of Editor void ButtonUp(Point pt, unsigned int curTime, bool ctrl); void Tick(); + bool Idle(); virtual void SetTicking(bool on) = 0; + virtual bool SetIdle(bool) { return false; } virtual void SetMouseCapture(bool on) = 0; virtual bool HaveMouseCapture() = 0; void SetFocusState(bool focusState); @@ -484,6 +507,7 @@ public: // Public so scintilla_set_id can use it. int ctrlID; friend class AutoSurface; + friend class SelectionLineIterator; }; /** diff --git a/contrib/src/stc/scintilla/src/ExternalLexer.cxx b/contrib/src/stc/scintilla/src/ExternalLexer.cxx index 88be76f249..752118b770 100644 --- a/contrib/src/stc/scintilla/src/ExternalLexer.cxx +++ b/contrib/src/stc/scintilla/src/ExternalLexer.cxx @@ -232,8 +232,9 @@ void LexerManager::Clear() { if (NULL != first) { LexerLibrary *cur = first; - LexerLibrary *next = first->next; + LexerLibrary *next; while (cur) { + next = cur->next; delete cur; cur = next; } diff --git a/contrib/src/stc/scintilla/src/Indicator.cxx b/contrib/src/stc/scintilla/src/Indicator.cxx index 1e386b68e3..a42abb2037 100644 --- a/contrib/src/stc/scintilla/src/Indicator.cxx +++ b/contrib/src/stc/scintilla/src/Indicator.cxx @@ -10,7 +10,7 @@ #include "Scintilla.h" #include "Indicator.h" -void Indicator::Draw(Surface *surface, PRectangle &rc) { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { surface->PenColour(fore.allocated); int ymid = (rc.bottom + rc.top) / 2; if (style == INDIC_SQUIGGLE) { @@ -57,6 +57,12 @@ void Indicator::Draw(Surface *surface, PRectangle &rc) { surface->LineTo(rc.right, rc.top - 4); } else if (style == INDIC_HIDDEN) { // Draw nothing + } else if (style == INDIC_BOX) { + surface->MoveTo(rc.left, ymid+1); + surface->LineTo(rc.right, ymid+1); + surface->LineTo(rc.right, rcLine.top+1); + surface->LineTo(rc.left, rcLine.top+1); + surface->LineTo(rc.left, ymid+1); } else { // Either INDIC_PLAIN or unknown surface->MoveTo(rc.left, ymid); surface->LineTo(rc.right, ymid); diff --git a/contrib/src/stc/scintilla/src/Indicator.h b/contrib/src/stc/scintilla/src/Indicator.h index 56e9420bcc..716db1051f 100644 --- a/contrib/src/stc/scintilla/src/Indicator.h +++ b/contrib/src/stc/scintilla/src/Indicator.h @@ -16,7 +16,7 @@ public: ColourPair fore; Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) { } - void Draw(Surface *surface, PRectangle &rc); + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine); }; #endif diff --git a/contrib/src/stc/scintilla/src/KeyMap.cxx b/contrib/src/stc/scintilla/src/KeyMap.cxx index f15842af68..950916bd08 100644 --- a/contrib/src/stc/scintilla/src/KeyMap.cxx +++ b/contrib/src/stc/scintilla/src/KeyMap.cxx @@ -2,7 +2,7 @@ /** @file KeyMap.cxx ** Defines a mapping between keystrokes and commands. **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include "Platform.h" @@ -15,7 +15,7 @@ KeyMap::KeyMap() : kmap(0), len(0), alloc(0) { for (int i = 0; MapDefault[i].key; i++) { AssignCmdKey(MapDefault[i].key, MapDefault[i].modifiers, - MapDefault[i].msg); + MapDefault[i].msg); } } @@ -35,7 +35,7 @@ void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) { KeyToCommand *ktcNew = new KeyToCommand[alloc + 5]; if (!ktcNew) return; - for (int k=0;k +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -22,24 +24,25 @@ #include "SciLexer.h" - static inline bool IsAWordChar(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch =='\\'); + return (ch < 0x80) && (isalnum(ch) || ch == '.' || + ch == '_' || ch == '?'); } static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' || + ch == '%' || ch == '@' || ch == '$' || ch == '?'); } -inline bool isAsmOperator(char ch) { +static inline bool IsAsmOperator(char ch) { if (isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || - ch == '(' || ch == ')' || ch == '=' || - ch == '[' || ch == ']' || ch == '<' || - ch == '>' || ch == ',' || - ch == '.' || ch == '%' || ch == ':') + ch == '(' || ch == ')' || ch == '=' || ch == '^' || + ch == '[' || ch == ']' || ch == '<' || ch == '&' || + ch == '>' || ch == ',' || ch == '|' || ch == '~' || + ch == '%' || ch == ':') return true; return false; } @@ -52,48 +55,63 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo WordList ®isters = *keywordlists[2]; WordList &directive = *keywordlists[3]; WordList &directiveOperand = *keywordlists[4]; + WordList &extInstruction = *keywordlists[5]; + + // Do not leak onto next line + if (initStyle == SCE_ASM_STRINGEOL) + initStyle = SCE_ASM_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { + + // Prevent SCE_ASM_STRINGEOL from leaking back to previous line + if (sc.atLineStart && (sc.state == SCE_ASM_STRING)) { + sc.SetState(SCE_ASM_STRING); + } else if (sc.atLineStart && (sc.state == SCE_ASM_CHARACTER)) { + sc.SetState(SCE_ASM_CHARACTER); + } + // Handle line continuation generically. if (sc.ch == '\\') { - if (sc.Match("\\\n")) { - sc.Forward(); - continue; - } - if (sc.Match("\\\r\n")) { - sc.Forward(); + if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); + } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_ASM_OPERATOR) { - sc.SetState(SCE_ASM_DEFAULT); + if (!IsAsmOperator(static_cast(sc.ch))) { + sc.SetState(SCE_ASM_DEFAULT); + } }else if (sc.state == SCE_ASM_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_IDENTIFIER) { if (!IsAWordChar(sc.ch) ) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - - if (cpuInstruction.InList(s)) { - sc.ChangeState(SCE_ASM_CPUINSTRUCTION); - } else if (mathInstruction.InList(s)) { - sc.ChangeState(SCE_ASM_MATHINSTRUCTION); - } else if (registers.InList(s)) { - sc.ChangeState(SCE_ASM_REGISTER); - } else if (directive.InList(s)) { - sc.ChangeState(SCE_ASM_DIRECTIVE); - } else if (directiveOperand.InList(s)) { - sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); - } - sc.SetState(SCE_ASM_DEFAULT); + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + + if (cpuInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_CPUINSTRUCTION); + } else if (mathInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_MATHINSTRUCTION); + } else if (registers.InList(s)) { + sc.ChangeState(SCE_ASM_REGISTER); + } else if (directive.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVE); + } else if (directiveOperand.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); + } else if (extInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_EXTINSTRUCTION); + } + sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_COMMENT ) { @@ -108,20 +126,36 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_ASM_DEFAULT); } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_CHARACTER) { + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); sc.ForwardSetState(SCE_ASM_DEFAULT); } } // Determine if a new state should be entered. - else if (sc.state == SCE_ASM_DEFAULT) { + if (sc.state == SCE_ASM_DEFAULT) { if (sc.ch == ';'){ sc.SetState(SCE_ASM_COMMENT); } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { sc.SetState(SCE_ASM_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_ASM_IDENTIFIER); - } else if (sc.Match('\"')) { + } else if (sc.ch == '\"') { sc.SetState(SCE_ASM_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_ASM_CHARACTER); + } else if (IsAsmOperator(static_cast(sc.ch))) { + sc.SetState(SCE_ASM_OPERATOR); } } @@ -135,6 +169,7 @@ static const char * const asmWordListDesc[] = { "Registers", "Directives", "Directive operands", + "Extended instructions", 0 }; diff --git a/contrib/src/stc/scintilla/src/LexCLW.cxx b/contrib/src/stc/scintilla/src/LexCLW.cxx new file mode 100644 index 0000000000..e5240776cc --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexCLW.cxx @@ -0,0 +1,441 @@ +// Scintilla source code edit control +/** @file LexClw.cxx + ** Lexer for Clarion. + **/ +// Copyright 2003 by Ron Schofield +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static char MakeUpperCase(char ch) { + if (ch < 'a' || ch > 'z') + return ch; + else + return static_cast(ch - 'a' + 'A'); +} + +static void MakeUpperCaseString(char *s) { + while (*s) { + *s = MakeUpperCase(*s); + s++; + } +} + +// Is a label start character +inline bool IsALabelStart(const int iChar) { + return(isalpha(iChar) || iChar == '_'); +} + +// Is a label character +inline bool IsALabelCharacter(const int iChar) { + return(isalnum(iChar) || iChar == '_' || iChar == ':'); +} + +// Is the character is a ! and the the next character is not a ! +inline bool IsACommentStart(StyleContext &scDoc) { + return(scDoc.ch == '!' && scDoc.chNext != '!'); +} + +// Is the character a Clarion hex character (ABCDEF) +inline bool IsAHexCharacter(const int iChar, bool bCaseSensitive) { + // Case insensitive. + if (!bCaseSensitive) { + if (strchr("ABCDEFabcdef", iChar) != NULL) { + return(true); + } + } + // Case sensitive + else { + if (strchr("ABCDEF", iChar) != NULL) { + return(true); + } + } + return(false); +} + +// Is the character a Clarion base character (B=Binary, O=Octal, H=Hex) +inline bool IsANumericBaseCharacter(const int iChar, bool bCaseSensitive) { + // Case insensitive. + if (!bCaseSensitive) { + // If character is a numeric base character + if (strchr("BOHboh", iChar) != NULL) { + return(true); + } + } + // Case sensitive + else { + // If character is a numeric base character + if (strchr("BOH", iChar) != NULL) { + return(true); + } + } + return(false); +} + +// Set the correct numeric constant state +inline bool SetNumericConstantState(StyleContext &scDoc) { + int iPoints = 0; // Point counter + char cNumericString[100]; // Numeric string buffer + + // Buffer the current numberic string + scDoc.GetCurrent(cNumericString, sizeof(cNumericString)); + // Loop through the string until end of string (NULL termination) + for (int iIndex = 0; cNumericString[iIndex] != '\0'; iIndex++) { + // Depending on the character + switch (cNumericString[iIndex]) { + // Is a . (point) + case '.' : + // Increment point counter + iPoints++; + break; + default : + break; + } + } + // If points found (can be more than one for improper formatted number + if (iPoints > 0) { + return(true); + } + // Else no points found + else { + return(false); + } +} + +// Clarion Language Colouring Procedure +static void ColouriseClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { + + int iParenthesesLevel=0; // Parenthese Level + + WordList &wlClarionKeywords = *wlKeywords[0]; // Clarion Keywords + WordList &wlCompilerDirectives = *wlKeywords[1]; // Compiler Directives + WordList &wlBuiltInProcsFuncs = *wlKeywords[2]; // Builtin Procedures and Functions + WordList &wlStructsDataTypes = *wlKeywords[3]; // Structures and Data Types + WordList &wlAttributes = *wlKeywords[4]; // Procedure Attributes + WordList &wlStandardEquates = *wlKeywords[5]; // Standard Equates + WordList &wlReservedWords = *wlKeywords[6]; // Clarion Reserved Keywords + + StyleContext scDoc(uiStartPos, iLength, iInitStyle, accStyler); + + // lex source code + for (; scDoc.More(); scDoc.Forward()) + { + // + // Determine if the current state should terminate. + // + + // Label State Handling + if (scDoc.state == SCE_CLW_LABEL) { + // If the character is not a valid label + if (!IsALabelCharacter(scDoc.ch)) { + // If the character is a . (dot syntax) + if (scDoc.ch == '.') { + // Uncolour the . (dot) to default state, move forward one character, + // and change back to the label state. + scDoc.SetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + scDoc.SetState(SCE_CLW_LABEL); + } + // Else terminate the label state + else { + char cLabel[100]; // Label buffer + // Buffer the current label string + scDoc.GetCurrent(cLabel,sizeof(cLabel)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cLabel); + } + // If label string is in the Clarion reserved keyword list + if (wlReservedWords.InList(cLabel)){ + // change to error state + scDoc.ChangeState(SCE_CLW_ERROR); + } + // Else if label string is in the compiler directive keyword list + else if (wlCompilerDirectives.InList(cLabel)) { + // change the state to compiler directive state + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + } + // Terminate the label state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + } + // Keyword State Handling + else if (scDoc.state == SCE_CLW_KEYWORD) { + // If character is : (colon) + if (scDoc.ch == ':') { + char cEquate[100]; // Equate buffer + // Move forward to include : (colon) in buffer + scDoc.Forward(); + // Buffer the equate string + scDoc.GetCurrent(cEquate,sizeof(cEquate)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cEquate); + } + // If statement string is in the equate list + if (wlStandardEquates.InList(cEquate)) { + // Change to equate state + scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE); + } + } + // If the character is not a valid label character + else if (!IsALabelCharacter(scDoc.ch)) { + char cStatement[100]; // Statement buffer + // Buffer the statement string + scDoc.GetCurrent(cStatement,sizeof(cStatement)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cStatement); + } + // If statement string is in the Clarion keyword list + if (wlClarionKeywords.InList(cStatement)) { + // Set to the Clarion keyword state + scDoc.ChangeState(SCE_CLW_KEYWORD); + } + // Else if statement string is in the compiler directive keyword list + else if (wlCompilerDirectives.InList(cStatement)) { + // Set to the compiler directive state + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + } + // Else if statement string is in the builtin procedures and functions keyword list + else if (wlBuiltInProcsFuncs.InList(cStatement)) { + // Set to the builtin procedures and functions state + scDoc.ChangeState(SCE_CLW_BUILTIN_PROCEDURES_FUNCTION); + } + // Else if statement string is in the tructures and data types keyword list + else if (wlStructsDataTypes.InList(cStatement)) { + // Set to the structures and data types state + scDoc.ChangeState(SCE_CLW_STRUCTURE_DATA_TYPE); + } + // Else if statement string is in the procedure attribute keyword list + else if (wlAttributes.InList(cStatement)) { + // Set to the procedure attribute state + scDoc.ChangeState(SCE_CLW_ATTRIBUTE); + } + // Else if statement string is in the standard equate keyword list + else if (wlStandardEquates.InList(cStatement)) { + // Set to the standard equate state + scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE); + } + // Terminate the keyword state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + // String State Handling + else if (scDoc.state == SCE_CLW_STRING) { + // If the character is an ' (single quote) + if (scDoc.ch == '\'') { + // Set the state to default and move forward colouring + // the ' (single quote) as default state + // terminating the string state + scDoc.SetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + } + // If the next character is an ' (single quote) + if (scDoc.chNext == '\'') { + // Move forward one character and set to default state + // colouring the next ' (single quote) as default state + // terminating the string state + scDoc.ForwardSetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + } + } + // Picture String State Handling + else if (scDoc.state == SCE_CLW_PICTURE_STRING) { + // If the character is an ( (open parenthese) + if (scDoc.ch == '(') { + // Increment the parenthese level + iParenthesesLevel++; + } + // Else if the character is a ) (close parenthese) + else if (scDoc.ch == ')') { + // If the parenthese level is set to zero + // parentheses matched + if (!iParenthesesLevel) { + scDoc.SetState(SCE_CLW_DEFAULT); + } + // Else parenthese level is greater than zero + // still looking for matching parentheses + else { + // Decrement the parenthese level + iParenthesesLevel--; + } + } + } + // Standard Equate State Handling + else if (scDoc.state == SCE_CLW_STANDARD_EQUATE) { + if (!isalnum(scDoc.ch)) { + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + // Integer Constant State Handling + else if (scDoc.state == SCE_CLW_INTEGER_CONSTANT) { + // If the character is not a digit (0-9) + // or character is not a hexidecimal character (A-F) + // or character is not a . (point) + // or character is not a numberic base character (B,O,H) + if (!(isdigit(scDoc.ch) + || IsAHexCharacter(scDoc.ch, bCaseSensitive) + || scDoc.ch == '.' + || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) { + // If the number was a real + if (SetNumericConstantState(scDoc)) { + // Colour the matched string to the real constant state + scDoc.ChangeState(SCE_CLW_REAL_CONSTANT); + } + // Else the number was an integer + else { + // Colour the matched string to an integer constant state + scDoc.ChangeState(SCE_CLW_INTEGER_CONSTANT); + } + // Terminate the integer constant state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + + // + // Determine if a new state should be entered. + // + + // Beginning of Line Handling + if (scDoc.atLineStart) { + // If column 1 character is a label start character + if (IsALabelStart(scDoc.ch)) { + // Set the state to label + scDoc.SetState(SCE_CLW_LABEL); + } + // else if character is a space or tab + else if (IsASpace(scDoc.ch)){ + // Set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + // else if the start of a comment or is an * (asterisk) + else if (IsACommentStart(scDoc) || scDoc.ch == '*' ) { + // then set the state to comment. + scDoc.SetState(SCE_CLW_COMMENT); + } + // else the character is a ? (question mark) + else if (scDoc.ch == '?') { + // Change to the compiler directive state, move forward, + // colouring the ? (question mark), change back to default state. + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + scDoc.Forward(); + scDoc.SetState(SCE_CLW_DEFAULT); + } + // else an invalid character in column 1 + else { + // Set to error state + scDoc.SetState(SCE_CLW_ERROR); + } + } + // End of Line Handling + else if (scDoc.atLineEnd) { + // Reset to the default state at the end of each line. + scDoc.SetState(SCE_CLW_DEFAULT); + } + // Default Handling + else { + // If in default state + if (scDoc.state == SCE_CLW_DEFAULT) { + // If is a letter could be a possible statement + if (isalpha(scDoc.ch)) { + // Set the state to Clarion Keyword and verify later + scDoc.SetState(SCE_CLW_KEYWORD); + } + // else is a number + else if (isdigit(scDoc.ch)) { + // Set the state to Integer Constant and verify later + scDoc.SetState(SCE_CLW_INTEGER_CONSTANT); + } + // else if the start of a comment or a | (line continuation) + else if (IsACommentStart(scDoc) || scDoc.ch == '|') { + // then set the state to comment. + scDoc.SetState(SCE_CLW_COMMENT); + } + // else if the character is a ' (single quote) + else if (scDoc.ch == '\'') { + // If the character is also a ' (single quote) + // Embedded Apostrophe + if (scDoc.chNext == '\'') { + // Move forward colouring it as default state + scDoc.ForwardSetState(SCE_CLW_DEFAULT); + } + else { + // move to the next character and then set the state to comment. + scDoc.ForwardSetState(SCE_CLW_STRING); + } + } + // else the character is an @ (apersand) + else if (scDoc.ch == '@') { + // Case insensitive. + if (!bCaseSensitive) { + // If character is a valid picture token character + if (strchr("DEKNPSTdeknpst", scDoc.chNext) != NULL) { + // Set to the picture string state + scDoc.SetState(SCE_CLW_PICTURE_STRING); + } + } + // Case sensitive + else { + // If character is a valid picture token character + if (strchr("DEKNPST", scDoc.chNext) != NULL) { + // Set the picture string state + scDoc.SetState(SCE_CLW_PICTURE_STRING); + } + } + } + } + } + } + // lexing complete + scDoc.Complete(); +} + +// Clarion Language Case Sensitive Colouring Procedure +static void ColouriseClwDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true); +} + +// Clarion Language Case Insensitive Colouring Procedure +static void ColouriseClwDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false); +} + +// Clarion Language Folding Procedure +#ifdef FOLDING_IMPLEMENTED +static void FoldClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + +} +#endif + +// Word List Descriptions +static const char * const rgWordListDescriptions[] = { + "Clarion Keywords", + "Compiler Directives", + "Built-in Procedures and Functions", + "Structure and Data Types", + "Attributes", + "Standard Equates", + "Reserved Words", + 0, +}; + +// Case Sensitive Clarion Language Lexer +LexerModule lmClw(SCLEX_CLW, ColouriseClwDocSensitive, "clw", NULL, rgWordListDescriptions); + +// Case Insensitive Clarion Language Lexer +LexerModule lmClwNoCase(SCLEX_CLWNOCASE, ColouriseClwDocInsensitive, "clwnocase", NULL, rgWordListDescriptions); diff --git a/contrib/src/stc/scintilla/src/LexErlang.cxx b/contrib/src/stc/scintilla/src/LexErlang.cxx new file mode 100644 index 0000000000..9444eb9501 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexErlang.cxx @@ -0,0 +1,522 @@ +// Scintilla source code edit control +/** @file LexErlang.cxx + ** Lexer for Erlang. + ** Written by Peter-Henry Mander, based on Matlab lexer by José Fonseca + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +/* + TODO: + o _Param should be a new lexical type +*/ + +static int is_radix(int radix, int ch) { + int digit; + if ( 16 < radix || 2 > radix ) { + return 0; + } + if ( isdigit(ch) ) { + digit = ch - '0'; + } else if ( isxdigit(ch) ) { + digit = toupper(ch) - 'A' + 10; + } else { + return 0; + } + if ( digit < radix ) { + return 1; + } else { + return 0; + } +} + +typedef enum { + STATE_NULL, + ATOM_UNQUOTED, + ATOM_QUOTED, + ATOM_FUN_NAME, + NODE_NAME_UNQUOTED, + NODE_NAME_QUOTED, + MACRO_START, + MACRO_UNQUOTED, + MACRO_QUOTED, + RECORD_START, + RECORD_UNQUOTED, + RECORD_QUOTED, + NUMERAL_START, + NUMERAL_SIGNED, + NUMERAL_RADIX_LITERAL, + NUMERAL_SPECULATIVE_MANTISSA, + NUMERAL_FLOAT_MANTISSA, + NUMERAL_FLOAT_EXPONENT, + NUMERAL_FLOAT_SIGNED_EXPONENT, + PARSE_ERROR +} atom_parse_state_t; + +static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + + styler.StartAt(startPos); + + StyleContext sc(startPos, length, initStyle, styler); + atom_parse_state_t parse_state = STATE_NULL; + int radix_digits = 0; + int exponent_digits = 0; + for (; sc.More(); sc.Forward()) { + if ( STATE_NULL != parse_state ) { + switch (parse_state) { + case STATE_NULL: + sc.SetState(SCE_ERLANG_DEFAULT); + break; + case ATOM_UNQUOTED: + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_UNQUOTED; + } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { + char s[100]; + sc.GetCurrent(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(SCE_ERLANG_KEYWORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + if ( '/' == sc.ch ) { + parse_state = ATOM_FUN_NAME; + } else { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } + } + break; + case ATOM_QUOTED: + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_QUOTED; + } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case ATOM_FUN_NAME: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_FUNCTION_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NODE_NAME_QUOTED: + if ( '@' == sc.ch ) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NODE_NAME_UNQUOTED: + if ( '@' == sc.ch ) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_START: + if ( '\'' == sc.ch ) { + parse_state = RECORD_QUOTED; + } else if (isalpha(sc.ch) && islower(sc.ch)) { + parse_state = RECORD_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_QUOTED: + if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_UNQUOTED: + if ( !isalpha(sc.ch) && '_' != sc.ch ) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_START: + if ( '\'' == sc.ch ) { + parse_state = MACRO_QUOTED; + } else if (isalpha(sc.ch)) { + parse_state = MACRO_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_UNQUOTED: + if ( !isalpha(sc.ch) && '_' != sc.ch ) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_QUOTED: + if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_START: + if ( isdigit(sc.ch) ) { + radix_digits *= 10; + radix_digits += sc.ch - '0'; // Assuming ASCII here! + } else if ( '#' == sc.ch ) { + if ( 2 > radix_digits || 16 < radix_digits) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_RADIX_LITERAL; + } + } else if ( '.' == sc.ch && isdigit(sc.chNext)) { + radix_digits = 0; + parse_state = NUMERAL_FLOAT_MANTISSA; + } else if ( 'e' == sc.ch || 'E' == sc.ch ) { + exponent_digits = 0; + parse_state = NUMERAL_FLOAT_EXPONENT; + } else { + radix_digits = 0; + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_RADIX_LITERAL: + if ( !is_radix(radix_digits,sc.ch) ) { + radix_digits = 0; + if ( !isalnum(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_FLOAT_MANTISSA: + if ( 'e' == sc.ch || 'E' == sc.ch ) { + exponent_digits = 0; + parse_state = NUMERAL_FLOAT_EXPONENT; + } else if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_FLOAT_EXPONENT: + if ( '-' == sc.ch || '+' == sc.ch ) { + parse_state = NUMERAL_FLOAT_SIGNED_EXPONENT; + } else if ( !isdigit(sc.ch) ) { + if ( 0 < exponent_digits ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + break; + case NUMERAL_FLOAT_SIGNED_EXPONENT: + if ( !isdigit(sc.ch) ) { + if ( 0 < exponent_digits ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + break; + case NUMERAL_SIGNED: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( '.' == sc.ch ) { + parse_state = NUMERAL_FLOAT_MANTISSA; + } + break; + case NUMERAL_SPECULATIVE_MANTISSA: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_OPERATOR); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_FLOAT_MANTISSA; + } + break; + case PARSE_ERROR: + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + break; + } + } else if (sc.state == SCE_ERLANG_OPERATOR) { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_VARIABLE) { + if (!isalnum(sc.ch) && sc.ch != '_') { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_STRING) { + if (sc.ch == '\"' && sc.chPrev != '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_COMMENT ) { + if (sc.atLineEnd) { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_CHARACTER ) { + if ( sc.chPrev == '\\' ) { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if ( sc.ch != '\\' ) { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } + + if (sc.state == SCE_ERLANG_DEFAULT) { + if (sc.ch == '%') { + sc.SetState(SCE_ERLANG_COMMENT); + } else if (sc.ch == '\"') { + sc.SetState(SCE_ERLANG_STRING); + } else if (sc.ch == '#') { + parse_state = RECORD_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch == '?') { + parse_state = MACRO_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch == '$') { + sc.SetState(SCE_ERLANG_CHARACTER); + } else if (sc.ch == '\'') { + parse_state = ATOM_QUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if ( isdigit(sc.ch) ) { + parse_state = NUMERAL_START; + radix_digits = sc.ch - '0'; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if ( '.' == sc.ch ) { + parse_state = NUMERAL_SPECULATIVE_MANTISSA; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isalpha(sc.ch) && isupper(sc.ch)) { + sc.SetState(SCE_ERLANG_VARIABLE); + } else if (isalpha(sc.ch)) { + parse_state = ATOM_UNQUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isoperator(static_cast(sc.ch)) || sc.ch == '\\') { + sc.SetState(SCE_ERLANG_OPERATOR); + } + } + } + sc.Complete(); +} + +static int ClassifyFoldPointErlang( + Accessor &styler, + int styleNext, + int keyword_start +) { + int lev = 0; + if ( styler.Match(keyword_start,"case") + || ( + styler.Match(keyword_start,"fun") + && SCE_ERLANG_FUNCTION_NAME != styleNext) + || styler.Match(keyword_start,"if") + || styler.Match(keyword_start,"query") + || styler.Match(keyword_start,"receive") + ) { + ++lev; + } else if ( styler.Match(keyword_start,"end") ) { + --lev; + } + return lev; +} + + +static void FoldErlangDoc( + unsigned int startPos, int length, int initStyle, + WordList** /*keywordlists*/, Accessor &styler +) { + unsigned int endPos = startPos + length; + //~ int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; + int levelCurrent = levelPrev; + char chNext = styler.SafeGetCharAt(startPos); + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int keyword_start = 0; + + bool fold_keywords = true; + bool fold_comments = true; + bool fold_braces = true; + bool fold_function_clauses = false; + bool fold_clauses = false; + + //int clause_level = 0; + + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + if ( (stylePrev != SCE_ERLANG_KEYWORD) && (style == SCE_ERLANG_KEYWORD) ) { + keyword_start = i; + } + if ( fold_keywords ) { + if ( (stylePrev == SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_ATOM) + ) { + levelCurrent += ClassifyFoldPointErlang(styler,styleNext,keyword_start); + } + } + + if ( fold_comments ) { + if (style == SCE_ERLANG_COMMENT) { + if ((ch == '%') && (chNext == '{')) { + levelCurrent++; + } else if ((ch == '%') && (chNext == '}')) { + levelCurrent--; + } + } + } + + if ( fold_function_clauses ) { + if ( (SC_FOLDLEVELBASE == levelCurrent) /*&& (style == SCE_ERLANG_OPERATOR)*/ ) { + if ( (ch == '-') && (chNext == '>')) { + //~ fprintf(stderr,"levelCurrent=%d\n", levelCurrent); + //++clause_level; + //~ if ( 0 < clause_level ) + ++levelCurrent; + } + } + //~ if ( (stylePrev != SCE_ERLANG_RECORD) + //~ && (style != SCE_ERLANG_NUMBER) + //~ && (style != SCE_ERLANG_STRING) + //~ && (style != SCE_ERLANG_COMMENT) + //~ ) { + if ( (SC_FOLDLEVELBASE+1 == levelCurrent) && (ch == '.') ) { + //--clause_level; + //~ if ( 0 == clause_level ) + --levelCurrent; + } + //~ } + } + + if ( fold_clauses ) { + if ( (0 < levelCurrent) && (style == SCE_ERLANG_OPERATOR) ) { + if ((ch == '-') && (chNext == '>')) { + levelCurrent++; + } + if ( (ch == ';') ) { + levelCurrent--; + } + } + if ( (stylePrev != SCE_ERLANG_RECORD) + && (style != SCE_ERLANG_NUMBER) + && (style != SCE_ERLANG_STRING) + && (style != SCE_ERLANG_COMMENT) + ) { + if ( (ch == '.') ) { + levelCurrent--; + } + } + if ( (stylePrev == SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_ATOM) + && ( + styler.Match(keyword_start,"end") // 'end' counted twice if fold_keywords too + || styler.Match(keyword_start,"after") ) + ) { + levelCurrent--; + } + } + + if ( fold_braces ) { + if (style == SCE_ERLANG_OPERATOR) { + if ( (ch == '{') || (ch == '(') || (ch == '[') ) { + levelCurrent++; + } else if ( (ch == '}') || (ch == ')') || (ch == ']') ) { + levelCurrent--; + } + } + } + + if (atEOL) { + int lev = levelPrev; + //~ if (visibleChars == 0 && foldCompact) + //~ lev |= SC_FOLDLEVELWHITEFLAG; + //~ if ((levelCurrent > levelPrev) && (visibleChars > 0)) + if ((levelCurrent > levelPrev)) { + lev |= SC_FOLDLEVELHEADERFLAG; + } + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelPrev = levelCurrent; + //~ visibleChars = 0; + } + //~ if (!isspacechar(ch)) + //~ visibleChars++; + + } + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} + +static const char * const erlangWordListDesc[] = { + "Keywords", + 0 +}; + +LexerModule lmErlang( + SCLEX_ERLANG, + ColouriseErlangDoc, + "erlang", + FoldErlangDoc, + erlangWordListDesc); + diff --git a/contrib/src/stc/scintilla/src/LexForth.cxx b/contrib/src/stc/scintilla/src/LexForth.cxx new file mode 100644 index 0000000000..3f128156d6 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexForth.cxx @@ -0,0 +1,348 @@ +// 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.eserv.ru/) + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +bool is_whitespace(int ch){ + return ch == '\n' || ch == '\r' || ch == '\t' || ch == ' '; +} + +bool is_blank(int ch){ + return ch == '\t' || ch == ' '; +} +//#define FORTH_DEBUG +#ifdef FORTH_DEBUG +static FILE *f_debug; +#define log(x) fputs(f_debug,x); +#else +#define log(x) +#endif + +#define STATE_LOCALE +#define BL ' ' + +static Accessor *st; +static int cur_pos,pos1,pos2,pos0,lengthDoc; +char *buffer; + +char getChar(bool is_bl){ + char ch=st->SafeGetCharAt(cur_pos); + if(is_bl) if(is_whitespace(ch)) ch=BL; + return ch; +} + +char getCharBL(){ + char ch=st->SafeGetCharAt(cur_pos); + return ch; +} +bool is_eol(char ch){ + return ch=='\n' || ch=='\r'; +} + +int parse(char ch, bool skip_eol){ +// pos1 - start pos of word +// pos2 - pos after of word +// pos0 - start pos + char c=0; + int len; + bool is_bl=ch==BL; + pos0=pos1=pos2=cur_pos; + for(;cur_pos9 && base>10) digit-=7; + if(digit<0) return false; + if(digit>=base) return false; + } + return true; +} + +bool is_number(char *s){ + if(strncmp(s,"0x",2)==0) return _is_number(s+2,16); + return _is_number(s,10); +} + +static void ColouriseForthDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +{ + st=&styler; + cur_pos=startPos; + lengthDoc = startPos + length; + buffer = new char[length]; + +#ifdef FORTH_DEBUG + f_debug=fopen("c:\\sci.log","at"); +#endif + + WordList &control = *keywordLists[0]; + WordList &keyword = *keywordLists[1]; + WordList &defword = *keywordLists[2]; + WordList &preword1 = *keywordLists[3]; + WordList &preword2 = *keywordLists[4]; + WordList &strings = *keywordLists[5]; + + // go through all provided text segment + // using the hand-written state machine shown below + styler.StartAt(startPos); + styler.StartSegment(startPos); + while(parse(BL,true)!=0){ + if(pos0!=pos1){ + styler.ColourTo(pos0,SCE_FORTH_DEFAULT); + styler.ColourTo(pos1-1,SCE_FORTH_DEFAULT); + } + if(strcmp("\\",buffer)==0){ + styler.ColourTo(pos1,SCE_FORTH_COMMENT); + parse(1,false); + styler.ColourTo(pos2,SCE_FORTH_COMMENT); + }else if(strcmp("(",buffer)==0){ + styler.ColourTo(pos1,SCE_FORTH_COMMENT); + parse(')',true); + if(cur_pos // The License.txt file describes the conditions under which this software may be distributed. - +/***************************************/ #include #include #include #include #include - +/***************************************/ #include "Platform.h" - #include "PropSet.h" #include "Accessor.h" #include "StyleContext.h" #include "KeyWords.h" #include "Scintilla.h" #include "SciLexer.h" - +/***********************************************/ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%'); } - +/**********************************************/ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch)); } - +/***************************************/ inline bool IsABlank(unsigned int ch) { return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ; } -static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler, bool isFixFormat) { - +/***************************************/ +inline bool IsALineEnd(char ch) { + return ((ch == '\n') || (ch == '\r')) ; +} +/***************************************/ +unsigned int GetContinuedPos(unsigned int pos, Accessor &styler) { + while (!IsALineEnd(styler.SafeGetCharAt(pos++))) continue; + if (styler.SafeGetCharAt(pos) == '\n') pos++; + while (IsABlank(styler.SafeGetCharAt(pos++))) continue; + char chCur = styler.SafeGetCharAt(pos); + if (chCur == '&') { + while (IsABlank(styler.SafeGetCharAt(++pos))) continue; + return pos; + } else { + return pos; + } +} +/***************************************/ +static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, bool isFixFormat) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; - - int posLineStart = 0, prevState = 0; + /***************************************/ + int posLineStart = 0, numNonBlank = 0, prevState = 0; int endPos = startPos + length; - - // backtrack to the beginning of the document, this may be slow for big documents. - // initStyle = SCE_F_DEFAULT; - // StyleContext sc(0, startPos+length, initStyle, styler); - + /***************************************/ // backtrack to the nearest keyword while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_F_WORD)) { startPos--; @@ -53,22 +65,47 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle startPos = styler.LineStart(styler.GetLine(startPos)); initStyle = styler.StyleAt(startPos - 1); StyleContext sc(startPos, endPos-startPos, initStyle, styler); - + /***************************************/ for (; sc.More(); sc.Forward()) { - - // remember the position of the line + // remember the start position of the line if (sc.atLineStart) { posLineStart = sc.currentPos; + numNonBlank = 0; sc.SetState(SCE_F_DEFAULT); } - + if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; + /***********************************************/ + // Handle the fix format generically + int toLineStart = sc.currentPos - posLineStart; + if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) { + if (toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') { + sc.SetState(SCE_F_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart > 72) { + sc.SetState(SCE_F_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart < 5) { + if (IsADigit(sc.ch)) + sc.SetState(SCE_F_LABEL); + else + sc.SetState(SCE_F_DEFAULT); + } else if (toLineStart == 5) { + if (!IsASpace(sc.ch) && sc.ch != '0') { + sc.SetState(SCE_F_CONTINUATION); + sc.ForwardSetState(prevState); + } else + sc.SetState(SCE_F_DEFAULT); + } + continue; + } + /***************************************/ // Handle line continuation generically. - if (sc.ch == '&') { + if (!isFixFormat && sc.ch == '&') { char chTemp = ' '; int j = 1; while (IsABlank(chTemp) && j<132) { chTemp = static_cast(sc.GetRelative(j)); - j ++; + j++; } if (chTemp == '!') { sc.SetState(SCE_F_CONTINUATION); @@ -76,24 +113,21 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } else if (chTemp == '\r' || chTemp == '\n') { int currentState = sc.state; sc.SetState(SCE_F_CONTINUATION); - if (currentState == SCE_F_STRING1 || currentState == SCE_F_STRING2) { - sc.ForwardSetState(SCE_F_DEFAULT); - while (IsASpace(sc.ch) && sc.More()) sc.Forward(); - if (sc.ch == '&') { - sc.SetState(SCE_F_CONTINUATION); - sc.Forward(); - } - sc.SetState(currentState); + sc.ForwardSetState(SCE_F_DEFAULT); + while (IsASpace(sc.ch) && sc.More()) sc.Forward(); + if (sc.ch == '&') { + sc.SetState(SCE_F_CONTINUATION); + sc.Forward(); } + sc.SetState(currentState); } - continue; } - + /***************************************/ // Determine if the current state should terminate. if (sc.state == SCE_F_OPERATOR) { sc.SetState(SCE_F_DEFAULT); } else if (sc.state == SCE_F_NUMBER) { - if (!IsAWordChar(sc.ch)) { + if (!(IsAWordChar(sc.ch) || sc.ch=='\'' || sc.ch=='\"' || sc.ch=='.')) { sc.SetState(SCE_F_DEFAULT); } } else if (sc.state == SCE_F_IDENTIFIER) { @@ -109,7 +143,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } sc.SetState(SCE_F_DEFAULT); } - } else if (sc.state == SCE_F_COMMENT) { + } else if (sc.state == SCE_F_COMMENT || sc.state == SCE_F_PREPROCESSOR) { if (sc.ch == '\r' || sc.ch == '\n') { sc.SetState(SCE_F_DEFAULT); } @@ -123,24 +157,14 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle prevState = SCE_F_DEFAULT; } } else if (sc.atLineEnd) { - if (isFixFormat) { - sc.ForwardSetState(SCE_F_DEFAULT); - posLineStart = sc.currentPos; - } else { - sc.ChangeState(SCE_F_STRINGEOL); - sc.ForwardSetState(SCE_F_DEFAULT); - } + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); } } else if (sc.state == SCE_F_STRING2) { prevState = sc.state; if (sc.atLineEnd) { - if (isFixFormat) { - sc.ForwardSetState(SCE_F_DEFAULT); - posLineStart = sc.currentPos; - } else { - sc.ChangeState(SCE_F_STRINGEOL); - sc.ForwardSetState(SCE_F_DEFAULT); - } + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); } else if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); @@ -156,33 +180,36 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } else if (sc.state == SCE_F_CONTINUATION) { sc.SetState(SCE_F_DEFAULT); } else if (sc.state == SCE_F_LABEL) { - if (sc.currentPos >= static_cast(posLineStart+5)) { + if (!IsADigit(sc.ch)) { sc.SetState(SCE_F_DEFAULT); + } else { + if (isFixFormat && sc.currentPos-posLineStart > 4) + sc.SetState(SCE_F_DEFAULT); + else if (numNonBlank > 5) + sc.SetState(SCE_F_DEFAULT); } } - + /***************************************/ // Determine if a new state should be entered. if (sc.state == SCE_F_DEFAULT) { - int toLineStart = sc.currentPos - posLineStart; - if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) { - if (sc.atLineStart && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') { - sc.SetState(SCE_F_COMMENT); - } else if (toLineStart > 72) { + if (sc.ch == '!') { + if (sc.chNext == '$') { + sc.SetState(SCE_F_PREPROCESSOR); + } else { sc.SetState(SCE_F_COMMENT); - } else if (toLineStart < 5 && !IsASpace(sc.ch)) { - sc.SetState(SCE_F_LABEL); - } else if (toLineStart == 5 && (!IsASpace(sc.ch) && sc.ch != '0')) { - sc.SetState(SCE_F_CONTINUATION); - sc.ForwardSetState(prevState); } + } else if ((!isFixFormat) && IsADigit(sc.ch) && numNonBlank == 1) { + sc.SetState(SCE_F_LABEL); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_F_NUMBER); + } else if ((tolower(sc.ch) == 'b' || tolower(sc.ch) == 'o' || + tolower(sc.ch) == 'z') && (sc.chNext == '\"' || sc.chNext == '\'')) { + sc.SetState(SCE_F_NUMBER); + sc.Forward(); } else if (sc.ch == '.' && isalpha(sc.chNext)) { sc.SetState(SCE_F_OPERATOR2); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_F_IDENTIFIER); - } else if (sc.ch == '!') { - sc.SetState(SCE_F_COMMENT); } else if (sc.ch == '\"') { sc.SetState(SCE_F_STRING2); } else if (sc.ch == '\'') { @@ -194,37 +221,46 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } sc.Complete(); } - -// The folding depends on the mercy of the programer. -static int classifyFoldPointFortran(const char* s, const char* prevWord) { +/***************************************/ +// To determine the folding level depending on keywords +static int classifyFoldPointFortran(const char* s, const char* prevWord, const char chNextNonBlank) { int lev = 0; - if (strcmp(prevWord, "end") == 0) return lev; if ((strcmp(prevWord, "else") == 0 && strcmp(s, "if") == 0) || strcmp(s, "elseif") == 0) return -1; if (strcmp(s, "associate") == 0 || strcmp(s, "block") == 0 || strcmp(s, "blockdata") == 0 || strcmp(s, "select") == 0 || strcmp(s, "do") == 0 || strcmp(s, "enum") ==0 - || strcmp(s, "forall") == 0 || strcmp(s, "function") == 0 - || strcmp(s, "interface") == 0 || strcmp(s, "module") == 0 - || strcmp(s, "program") == 0 || strcmp(s, "subroutine") == 0 - || strcmp(s, "then") == 0 || strcmp(s, "where") == 0) { - lev = 1; - } else if (strcmp(s, "end") == 0 || strcmp(s, "continue") == 0 - || strcmp(s, "endassociate") == 0 || strcmp(s, "endblock") == 0 - || strcmp(s, "endblockdata") == 0 || strcmp(s, "endselect") == 0 - || strcmp(s, "enddo") == 0 || strcmp(s, "endenum") ==0 - || strcmp(s, "endif") == 0 - || strcmp(s, "endforall") == 0 || strcmp(s, "endfunction") == 0 - || strcmp(s, "endinterface") == 0 || strcmp(s, "endmodule") == 0 - || strcmp(s, "endprogram") == 0 || strcmp(s, "endsubroutine") == 0 - || strcmp(s, "endwhere") == 0 || strcmp(s, "procedure") == 0 ) { - lev = -1; + || strcmp(s, "function") == 0 || strcmp(s, "interface") == 0 + || strcmp(s, "module") == 0 || strcmp(s, "program") == 0 + || strcmp(s, "subroutine") == 0 || strcmp(s, "then") == 0 + || (strcmp(s, "type") == 0 && chNextNonBlank != '(') ){ + if (strcmp(prevWord, "end") == 0) + lev = 0; + else + lev = 1; + } else if (strcmp(s, "end") == 0 && chNextNonBlank != '=' + || strcmp(s, "endassociate") == 0 || strcmp(s, "endblock") == 0 + || strcmp(s, "endblockdata") == 0 || strcmp(s, "endselect") == 0 + || strcmp(s, "enddo") == 0 || strcmp(s, "endenum") ==0 + || strcmp(s, "endif") == 0 || strcmp(s, "endforall") == 0 + || strcmp(s, "endfunction") == 0 || strcmp(s, "endinterface") == 0 + || strcmp(s, "endmodule") == 0 || strcmp(s, "endprogram") == 0 + || strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0 + || strcmp(s, "endwhere") == 0 + || strcmp(s, "procedure") == 0 ) { // Take care of the module procedure statement + lev = -1; + } else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if + lev = 0; } return lev; } -static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { - //~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0; +// Folding the code +static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, + Accessor &styler, bool isFixFormat) { + // + // bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. + // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; @@ -232,37 +268,133 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, Wor int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; + char chNextNonBlank; int styleNext = styler.StyleAt(startPos); int style = initStyle; - + /***************************************/ int lastStart = 0; - char prevWord[32] = ""; - + char prevWord[32] = "", Label[6] = ""; + // Variables for do label folding. + static int doLabels[100], posLabel=-1; + /***************************************/ for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); + chNextNonBlank = chNext; + unsigned int j=i+1; + while(IsABlank(chNextNonBlank) && j(tolower(styler[lastStart + j])); + unsigned int k; + for(k=0; (k<31 ) && (k(tolower(styler[lastStart+k])); + } + s[k] = '\0'; + // Handle the forall and where statement and structure. + if (strcmp(s, "forall") == 0 || strcmp(s, "where") == 0) { + if (strcmp(prevWord, "end") != 0) { + j = i + 1; + char chBrace = '(', chSeek = ')', ch1 = styler.SafeGetCharAt(j); + // Find the position of the first ( + while (ch1 != chBrace && j -1) { + levelCurrent--; + posLabel--; + } + } } if (atEOL) { int lev = levelPrev; @@ -278,33 +410,41 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, Wor visibleChars = 0; strcpy(prevWord, ""); } - - if (!isspacechar(ch)) - visibleChars++; + /***************************************/ + if (!isspacechar(ch)) visibleChars++; } - + /***************************************/ // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } - +/***************************************/ static const char * const FortranWordLists[] = { "Primary keywords and identifiers", "Intrinsic functions", "Extended and user defined functions", 0, }; - +/***************************************/ static void ColouriseFortranDocFreeFormat(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, false); } - +/***************************************/ static void ColouriseFortranDocFixFormat(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, true); } - - -LexerModule lmFortran(SCLEX_FORTRAN, ColouriseFortranDocFreeFormat, "fortran", FoldFortranDoc, FortranWordLists); -LexerModule lmF77(SCLEX_F77, ColouriseFortranDocFixFormat, "f77", FoldFortranDoc, FortranWordLists); +/***************************************/ +static void FoldFortranDocFreeFormat(unsigned int startPos, int length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, false); +} +/***************************************/ +static void FoldFortranDocFixFormat(unsigned int startPos, int length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, true); +} +/***************************************/ +LexerModule lmFortran(SCLEX_FORTRAN, ColouriseFortranDocFreeFormat, "fortran", FoldFortranDocFreeFormat, FortranWordLists); +LexerModule lmF77(SCLEX_F77, ColouriseFortranDocFixFormat, "f77", FoldFortranDocFixFormat, FortranWordLists); diff --git a/contrib/src/stc/scintilla/src/LexLua.cxx b/contrib/src/stc/scintilla/src/LexLua.cxx index 18612c9ee3..3781eed83a 100644 --- a/contrib/src/stc/scintilla/src/LexLua.cxx +++ b/contrib/src/stc/scintilla/src/LexLua.cxx @@ -27,21 +27,31 @@ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); } -inline bool IsAWordStart(const int ch) { +static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -inline bool isLuaOperator(char ch) { - if (isalnum(ch)) +static inline bool IsANumberChar(const int ch) { + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. + return (ch < 0x80) && + (isdigit(ch) || toupper(ch) == 'E' || + ch == '.' || ch == '-' || ch == '+'); +} + +static inline bool IsLuaOperator(int ch) { + if (ch >= 0x80 || isalnum(ch)) { return false; + } // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '{' || ch == '}' || ch == '~' || ch == '[' || ch == ']' || ch == ';' || ch == '<' || ch == '>' || ch == ',' || - ch == '.' || ch == '^' || ch == '%' || ch == ':') + ch == '.' || ch == '^' || ch == '%' || ch == ':') { return true; + } return false; } @@ -124,11 +134,8 @@ static void ColouriseLuaDoc( sc.SetState(SCE_LUA_DEFAULT); } else if (sc.state == SCE_LUA_NUMBER) { // We stop the number definition on non-numerical non-dot non-eE non-sign char - if (!(isdigit(sc.ch) || sc.ch == '.' || - toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) { - // Not exactly following number definition (several dots are seen as OK, etc.) - // but probably enough in most cases. - sc.SetState(SCE_LUA_DEFAULT); + if (!IsANumberChar(sc.ch)) { + sc.SetState(SCE_LUA_DEFAULT); } } else if (sc.state == SCE_LUA_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { @@ -233,7 +240,7 @@ static void ColouriseLuaDoc( sc.Forward(); } else if (sc.atLineStart && sc.Match('$')) { sc.SetState(SCE_LUA_PREPROCESSOR); // Obsolete since Lua 4.0, but still in old code - } else if (isLuaOperator(static_cast(sc.ch))) { + } else if (IsLuaOperator(static_cast(sc.ch))) { sc.SetState(SCE_LUA_OPERATOR); } } diff --git a/contrib/src/stc/scintilla/src/LexMPT.cxx b/contrib/src/stc/scintilla/src/LexMPT.cxx new file mode 100644 index 0000000000..1058b9b496 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexMPT.cxx @@ -0,0 +1,182 @@ +// Scintilla source code edit control +/** @file LexMPT.cxx + ** Lexer for MPT specific files. Based on LexOthers.cxx + ** LOT = the text log file created by the MPT application while running a test program + ** Other MPT specific files to be added later. + **/ +// Copyright 2003 by Marius Gheorghe +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "SString.h" + +static int GetLotLineState(SString &line) { + if (line.length()) { + // Most of the time the first non-blank character in line determines that line's type + // Now finds the first non-blank character + unsigned i; // Declares counter here to make it persistent after the for loop + for (i = 0; i < line.length(); ++i) { + if (!isspace(line[i])) + break; + } + + // Checks if it was a blank line + if (i == line.length()) + return SCE_LOT_DEFAULT; + + switch (line[i]) { + case '*': // Fail measurement + return SCE_LOT_FAIL; + + case '+': // Header + case '|': // Header + return SCE_LOT_HEADER; + + case ':': // Set test limits + return SCE_LOT_SET; + + case '-': // Section break + return SCE_LOT_BREAK; + + default: // Any other line + // Checks for message at the end of lot file + if (line.contains("PASSED")) { + return SCE_LOT_PASS; + } + else if (line.contains("FAILED")) { + return SCE_LOT_FAIL; + } + else if (line.contains("ABORTED")) { + return SCE_LOT_ABORT; + } + else { + return i ? SCE_LOT_PASS : SCE_LOT_DEFAULT; + } + } + } + else { + return SCE_LOT_DEFAULT; + } +} + +static void ColourizeLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { + styler.StartAt(startPos); + styler.StartSegment(startPos); + bool atLineStart = true;// Arms the 'at line start' flag + char chNext = styler.SafeGetCharAt(startPos); + SString line(""); + line.setsizegrowth(256); // Lot lines are less than 256 chars long most of the time. This should avoid reallocations + + // Styles LOT document + unsigned int i; // Declared here because it's used after the for loop + for (i = startPos; i < startPos + length; ++i) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + line += ch; + atLineStart = false; + + // LOT files are only used on the Win32 platform, thus EOL == CR+LF + // Searches for the end of line + if (ch == '\r' && chNext == '\n') { + line += chNext; // Gets the '\n' + ++i; // Advances past the '\n' + chNext = styler.SafeGetCharAt(i + 1); // Gets character of next line + styler.ColourTo(i, GetLotLineState(line)); + line = ""; + atLineStart = true; // Arms flag for next line + } + } + + // Last line may not have a line ending + if (!atLineStart) { + styler.ColourTo(i - 1, GetLotLineState(line)); + } +} + +// Folds an MPT LOT file: the blocks that can be folded are: +// sections (headed by a set line) +// passes (contiguous pass results within a section) +// fails (contiguous fail results within a section) +static void FoldLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { + bool foldCompact = styler.GetPropertyInt("fold.compact", 0) != 0; + unsigned int endPos = startPos + length; + int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + + char chNext = styler.SafeGetCharAt(startPos); + int style = SCE_LOT_DEFAULT; + int styleNext = styler.StyleAt(startPos); + int lev = SC_FOLDLEVELBASE; + + // Gets style of previous line if not at the beginning of the document + if (startPos > 1) + style = styler.StyleAt(startPos - 2); + + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if (ch == '\r' && chNext == '\n') { + // TO DO: + // Should really get the state of the previous line from the styler + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 2); + + switch (style) { +/* + case SCE_LOT_SET: + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + break; +*/ + case SCE_LOT_FAIL: +/* + if (stylePrev != SCE_LOT_FAIL) + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else + lev = SC_FOLDLEVELBASE + 1; +*/ + lev = SC_FOLDLEVELBASE; + break; + + default: + if (lineCurrent == 0 || stylePrev == SCE_LOT_FAIL) + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else + lev = SC_FOLDLEVELBASE + 1; + + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + break; + } + + if (lev != styler.LevelAt(lineCurrent)) + styler.SetLevel(lineCurrent, lev); + + lineCurrent++; + visibleChars = 0; + } + + if (!isspacechar(ch)) + visibleChars++; + } + + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, lev | flagsNext); +} + +static const char * const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmLot(SCLEX_LOT, ColourizeLotDoc, "lot", FoldLotDoc, emptyWordListDesc); diff --git a/contrib/src/stc/scintilla/src/LexMatlab.cxx b/contrib/src/stc/scintilla/src/LexMatlab.cxx index 5f4dff3b8e..249fa67ce2 100644 --- a/contrib/src/stc/scintilla/src/LexMatlab.cxx +++ b/contrib/src/stc/scintilla/src/LexMatlab.cxx @@ -2,6 +2,10 @@ /** @file LexMatlab.cxx ** Lexer for Matlab. ** Written by José Fonseca + ** + ** Changes by Christoph Dalitz 2003/12/04: + ** - added support for Octave + ** - Strings can now be included both in single or double quotes **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -21,8 +25,21 @@ #include "Scintilla.h" #include "SciLexer.h" + +static bool IsMatlabCommentChar(int c) { + return (c == '%') ; +} + +static bool IsOctaveCommentChar(int c) { + return (c == '%' || c == '#') ; +} + static bool IsMatlabComment(Accessor &styler, int pos, int len) { - return len > 0 && (styler[pos] == '%' || styler[pos] == '!') ; + return len > 0 && IsMatlabCommentChar(styler[pos]) ; +} + +static bool IsOctaveComment(Accessor &styler, int pos, int len) { + return len > 0 && IsOctaveCommentChar(styler[pos]) ; } static inline bool IsAWordChar(const int ch) { @@ -33,8 +50,10 @@ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) { +static void ColouriseMatlabOctaveDoc( + unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, + bool (*IsCommentChar)(int)) { WordList &keywords = *keywordlists[0]; @@ -81,9 +100,11 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, transpose = true; } } else if (sc.state == SCE_MATLAB_STRING) { - // Matlab doubles quotes to preserve them, so just end this string - // state now as a following quote will start again - if (sc.ch == '\'') { + if (sc.ch == '\'' && sc.chPrev != '\\') { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + } + } else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) { + if (sc.ch == '"' && sc.chPrev != '\\') { sc.ForwardSetState(SCE_MATLAB_DEFAULT); } } else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) { @@ -94,7 +115,7 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, } if (sc.state == SCE_MATLAB_DEFAULT) { - if (sc.ch == '%') { + if (IsCommentChar(sc.ch)) { sc.SetState(SCE_MATLAB_COMMENT); } else if (sc.ch == '!') { sc.SetState(SCE_MATLAB_COMMAND); @@ -104,6 +125,8 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, } else { sc.SetState(SCE_MATLAB_STRING); } + } else if (sc.ch == '"') { + sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING); } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { sc.SetState(SCE_MATLAB_NUMBER); } else if (isalpha(sc.ch)) { @@ -123,8 +146,20 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldMatlabDoc(unsigned int startPos, int length, int, - WordList *[], Accessor &styler) { +static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar); +} + +static void ColouriseOctaveDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar); +} + +static void FoldMatlabOctaveDoc(unsigned int startPos, int length, int, + WordList *[], Accessor &styler, + bool (*IsComment)(Accessor&,int,int)) { + int endPos = startPos + length; // Backtrack to previous line in case need to fix its fold status @@ -136,7 +171,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } } int spaceFlags = 0; - int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsMatlabComment); + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsComment); char chNext = styler[startPos]; for (int i = startPos; i < endPos; i++) { char ch = chNext; @@ -144,7 +179,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) { int lev = indentCurrent; - int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsMatlabComment); + int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsComment); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { // Only non whitespace lines can be headers if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { @@ -152,7 +187,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { // Line after is blank so check the next - maybe should continue further? int spaceFlags2 = 0; - int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsMatlabComment); + int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsComment); if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } @@ -165,9 +200,26 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } } +static void FoldMatlabDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment); +} + +static void FoldOctaveDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment); +} + static const char * const matlabWordListDesc[] = { "Keywords", 0 }; +static const char * const octaveWordListDesc[] = { + "Keywords", + 0 +}; + LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc, matlabWordListDesc); + +LexerModule lmOctave(SCLEX_OCTAVE, ColouriseOctaveDoc, "octave", FoldOctaveDoc, octaveWordListDesc); diff --git a/contrib/src/stc/scintilla/src/LexMetapost.cxx b/contrib/src/stc/scintilla/src/LexMetapost.cxx new file mode 100644 index 0000000000..b7d482c0f1 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexMetapost.cxx @@ -0,0 +1,320 @@ +// Scintilla source code edit control + +// File: LexMetapost.cxx - general context conformant metapost coloring scheme +// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com +// Version: September 28, 2003 + +// Copyright: 1998-2003 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// This lexer is derived from the one written for the texwork environment (1999++) which in +// turn is inspired on texedit (1991++) which finds its roots in wdt (1986). + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "StyleContext.h" + +// val SCE_METAPOST_DEFAULT = 0 +// val SCE_METAPOST_SPECIAL = 1 +// val SCE_METAPOST_GROUP = 2 +// val SCE_METAPOST_SYMBOL = 3 +// val SCE_METAPOST_COMMAND = 4 +// val SCE_METAPOST_TEXT = 5 + +// Definitions in SciTEGlobal.properties: +// +// Metapost Highlighting +// +// # Default +// style.metapost.0=fore:#7F7F00 +// # Special +// style.metapost.1=fore:#007F7F +// # Group +// style.metapost.2=fore:#880000 +// # Symbol +// style.metapost.3=fore:#7F7F00 +// # Command +// style.metapost.4=fore:#008800 +// # Text +// style.metapost.5=fore:#000000 + +// lexer.tex.comment.process=0 + +// Auxiliary functions: + +static inline bool endOfLine(Accessor &styler, unsigned int i) { + return + (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')) ; +} + +static inline bool isMETAPOSTcomment(int ch) { + return + (ch == '%') ; +} + +static inline bool isMETAPOSTone(int ch) { + return + (ch == '[') || (ch == ']') || (ch == '(') || (ch == ')') || + (ch == ':') || (ch == '=') || (ch == '<') || (ch == '>') || + (ch == '{') || (ch == '}') || (ch == '\'') || (ch == '\"') ; +} + +static inline bool isMETAPOSTtwo(int ch) { + return + (ch == ';') || (ch == '$') || (ch == '@') || (ch == '#'); +} + +static inline bool isMETAPOSTthree(int ch) { + return + (ch == '.') || (ch == '-') || (ch == '+') || (ch == '/') || + (ch == '*') || (ch == ',') || (ch == '|') || (ch == '`') || + (ch == '!') || (ch == '?') || (ch == '^') || (ch == '&') || + (ch == '%') ; +} + +static inline bool isMETAPOSTidentifier(int ch) { + return + ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || + (ch == '_') ; +} + +static inline bool isMETAPOSTnumber(int ch) { + return + (ch >= '0') && (ch <= '9') ; +} + +static inline bool isMETAPOSTstring(int ch) { + return + (ch == '\"') ; +} + +static inline bool isMETAPOSTcolon(int ch) { + return + (ch == ':') ; +} + +static inline bool isMETAPOSTequal(int ch) { + return + (ch == '=') ; +} + +static int CheckMETAPOSTInterface( + unsigned int startPos, + int length, + Accessor &styler, + int defaultInterface) { + + char lineBuffer[1024] ; + unsigned int linePos = 0 ; + + // some day we can make something lexer.metapost.mapping=(none,0)(metapost,1)(mp,1)(metafun,2)... + + if (styler.SafeGetCharAt(0) == '%') { + for (unsigned int i = 0; i < startPos + length; i++) { + lineBuffer[linePos++] = styler.SafeGetCharAt(i) ; + if (endOfLine(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + lineBuffer[linePos] = '\0'; + if (strstr(lineBuffer, "interface=none")) { + return 0 ; + } else if (strstr(lineBuffer, "interface=metapost") || strstr(lineBuffer, "interface=mp")) { + return 1 ; + } else if (strstr(lineBuffer, "interface=metafun")) { + return 2 ; + } else if (styler.SafeGetCharAt(1) == 'D' && strstr(lineBuffer, "%D \\module")) { + // better would be to limit the search to just one line + return 2 ; + } else { + return defaultInterface ; + } + } + } + } + + return defaultInterface ; +} + +static void ColouriseMETAPOSTDoc( + unsigned int startPos, + int length, + int, + WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos) ; + styler.StartSegment(startPos) ; + + bool processComment = styler.GetPropertyInt("lexer.metapost.comment.process", 0) == 1 ; + int defaultInterface = styler.GetPropertyInt("lexer.metapost.interface.default", 1) ; + + int currentInterface = CheckMETAPOSTInterface(startPos,length,styler,defaultInterface) ; + + // 0 no keyword highlighting + // 1 metapost keyword hightlighting + // 2+ metafun keyword hightlighting + + int extraInterface = 0 ; + + if (currentInterface != 0) { + extraInterface = currentInterface ; + } + + WordList &keywords = *keywordlists[0] ; + WordList &keywords2 = *keywordlists[extraInterface-1] ; + + StyleContext sc(startPos, length, SCE_METAPOST_TEXT, styler) ; + + char key[100] ; + + bool inTeX = false ; + bool inComment = false ; + bool inString = false ; + bool inClause = false ; + + bool going = sc.More() ; // needed because of a fuzzy end of file state + + for (; going; sc.Forward()) { + + if (! sc.More()) { going = false ; } // we need to go one behind the end of text + + if (inClause) { + sc.SetState(SCE_METAPOST_TEXT) ; + inClause = false ; + } + + if (inComment) { + if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; // not correct but we want to stimulate one-lines + } + } else if (inString) { + if (isMETAPOSTstring(sc.ch)) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + sc.ForwardSetState(SCE_METAPOST_TEXT) ; + inString = false ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; // not correct but we want to stimulate one-lines + } + } else { + if ((! isMETAPOSTidentifier(sc.ch)) && (sc.LengthCurrent() > 0)) { + if (sc.state == SCE_METAPOST_COMMAND) { + sc.GetCurrent(key, sizeof(key)) ; + if ((strcmp(key,"btex") == 0) || (strcmp(key,"verbatimtex") == 0)) { + sc.ChangeState(SCE_METAPOST_GROUP) ; + inTeX = true ; + } else if (inTeX) { + if (strcmp(key,"etex") == 0) { + sc.ChangeState(SCE_METAPOST_GROUP) ; + inTeX = false ; + } else { + sc.ChangeState(SCE_METAPOST_TEXT) ; + } + } else { + if (keywords && keywords.InList(key)) { + sc.ChangeState(SCE_METAPOST_COMMAND) ; + } else if (keywords2 && keywords2.InList(key)) { + sc.ChangeState(SCE_METAPOST_EXTRA) ; + } else { + sc.ChangeState(SCE_METAPOST_TEXT) ; + } + } + } + } + if (isMETAPOSTcomment(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SYMBOL) ; + sc.ForwardSetState(SCE_METAPOST_DEFAULT) ; + inComment = ! processComment ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTstring(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + if (! isMETAPOSTstring(sc.chNext)) { + sc.ForwardSetState(SCE_METAPOST_TEXT) ; + } + inString = true ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTcolon(sc.ch)) { + if (! inTeX) { + if (! isMETAPOSTequal(sc.chNext)) { + sc.SetState(SCE_METAPOST_COMMAND) ; + inClause = true ; + } else { + sc.SetState(SCE_METAPOST_SPECIAL) ; + } + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTone(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTtwo(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_GROUP) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTthree(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SYMBOL) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTidentifier(sc.ch)) { + if (sc.state != SCE_METAPOST_COMMAND) { + sc.SetState(SCE_METAPOST_TEXT) ; + sc.ChangeState(SCE_METAPOST_COMMAND) ; + } + } else if (isMETAPOSTnumber(sc.ch)) { + // rather redundant since for the moment we don't handle numbers + sc.SetState(SCE_METAPOST_TEXT) ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } + + } + + sc.Complete(); + +} + +// Hooks info the system: + +static const char * const metapostWordListDesc[] = { + "MetaPost", + "MetaFun", + 0 +} ; + +LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", 0, metapostWordListDesc); diff --git a/contrib/src/stc/scintilla/src/LexOthers.cxx b/contrib/src/stc/scintilla/src/LexOthers.cxx index 31ac415ad4..819dd31290 100644 --- a/contrib/src/stc/scintilla/src/LexOthers.cxx +++ b/contrib/src/stc/scintilla/src/LexOthers.cxx @@ -427,6 +427,12 @@ static void ColouriseErrorListLine( styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION); } else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') { styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE); + } else if (strstart(lineBuffer, "cf90-")) { + // Absoft Pro Fortran 90/95 v8.2 error and/or warning message + styler.ColourTo(endPos, SCE_ERR_ABSF); + } else if (strstart(lineBuffer, "fortcom:")) { + // Intel Fortran Compiler v8.0 error/warning message + styler.ColourTo(endPos, SCE_ERR_IFORT); } else if (lineBuffer[0] == '-') { styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION); } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) { diff --git a/contrib/src/stc/scintilla/src/LexPB.cxx b/contrib/src/stc/scintilla/src/LexPB.cxx new file mode 100644 index 0000000000..d35944ecf7 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexPB.cxx @@ -0,0 +1,228 @@ +// Scintilla source code edit control +/** @file LexPB.cxx + ** Lexer for PowerBasic by Roland Walter, roland@rowalt.de + ** Last update: 17.10.2003 (toggling of subs/functions now until next sub/functin - this gives better results) + **/ +// +// Necessary changes in Scintilla project: +// - In SciLexer.h and Scintilla.iface: +// +// #define SCLEX_PB 51 //ID for PowerBasic lexer +// (...) +// #define SCE_B_DEFAULT 0 //in both VB and PB lexer +// #define SCE_B_COMMENT 1 //in both VB and PB lexer +// #define SCE_B_NUMBER 2 //in both VB and PB lexer +// #define SCE_B_KEYWORD 3 //in both VB and PB lexer +// #define SCE_B_STRING 4 //in both VB and PB lexer +// #define SCE_B_PREPROCESSOR 5 //VB lexer only, unsupported by PB lexer +// #define SCE_B_OPERATOR 6 //in both VB and PB lexer +// #define SCE_B_IDENTIFIER 7 //in both VB and PB lexer +// #define SCE_B_DATE 8 //VB lexer only, unsupported by PB lexer + +// - Statement added to KeyWords.cxx: 'LINK_LEXER(lmPB);' +// - Statement added to scintilla_vc6.mak: '$(DIR_O)\LexPB.obj: ...\src\LexPB.cxx $(LEX_HEADERS)' +// +// Copyright for Scintilla: 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static inline bool IsTypeCharacter(const int ch) { + return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$'; +} + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); +} + +static inline bool IsAWordStart(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_'); +} + +bool MatchUpperCase(Accessor &styler, int pos, const char *s) //Same as styler.Match() but uppercase comparison (a-z,A-Z and space only) +{ + char ch; + for (int i=0; *s; i++) + { + ch=styler.SafeGetCharAt(pos+i); + if (ch > 0x60) ch -= '\x20'; + if (*s != ch) return false; + s++; + } + return true; +} + +static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[], + Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + + styler.StartAt(startPos); + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + if (sc.state == SCE_B_OPERATOR) + { + sc.SetState(SCE_B_DEFAULT); + } + else if (sc.state == SCE_B_KEYWORD) + { + if (!IsAWordChar(sc.ch)) + { + if (!IsTypeCharacter(sc.ch)) + { + if (sc.ch == ']') {sc.Forward();} + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) + { + if (strcmp(s, "rem") == 0) + { + sc.ChangeState(SCE_B_COMMENT); + if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);} + } + else + { + sc.SetState(SCE_B_DEFAULT); + } + } + else + { + sc.ChangeState(SCE_B_IDENTIFIER); + sc.SetState(SCE_B_DEFAULT); + } + } + } + } + else if (sc.state == SCE_B_NUMBER) + { + if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);} + } + else if (sc.state == SCE_B_STRING) + { + // PB doubles quotes to preserve them, so just end this string + // state now as a following quote will start again + if (sc.ch == '\"') + { + if (tolower(sc.chNext) == 'c') {sc.Forward();} + sc.ForwardSetState(SCE_B_DEFAULT); + } + } + else if (sc.state == SCE_B_COMMENT) + { + if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);} + } + + if (sc.state == SCE_B_DEFAULT) + { + if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);} + else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);} + else if (sc.ch == '#') + { int n = 1; + int chSeek = ' '; + while ((n < 100) && (chSeek == ' ' || chSeek == '\t')) + { + chSeek = sc.GetRelative(n); + n++; + } + sc.SetState(SCE_B_OPERATOR); + } + else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);} + else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);} + else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);} + else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);} + else if (IsAWordStart(sc.ch) || (sc.ch == '[')) {sc.SetState(SCE_B_KEYWORD);} + else if (isoperator(static_cast(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);} + } + + } + sc.Complete(); +} + +static void FoldPBDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +{ + // No folding enabled, no reason to continue... + if( styler.GetPropertyInt("fold") == 0 ) + return; + + unsigned int endPos = startPos + length; + int lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + + bool atEOL=1; + for (unsigned int i = startPos; i < endPos; i++) + { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if( atEOL ) //Begin of a new line (The Sub/Function/Macro keywords may occur at begin of line only) + { + if( MatchUpperCase(styler,i,"FUNCTION") ) //else if( + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"CALLBACK FUNCTION") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"STATIC FUNCTION") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"SUB") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"STATIC SUB") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + //else if( MatchUpperCase(styler,i,"MACRO") ) //ToDo: What's with single-line macros? + } + + atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if( atEOL ) + { + lineCurrent++; + levelCurrent = levelNext; + } + } + + if (levelNext == SC_FOLDLEVELBASE) + { + int levelUse = levelCurrent; + int lev = levelUse | levelNext << 16; + styler.SetLevel(lineCurrent, lev); + } +} + +static const char * const pbWordListDesc[] = { + "Keywords", + 0 +}; + +LexerModule lmPB(SCLEX_POWERBASIC, ColourisePBDoc, "powerbasic", FoldPBDoc, pbWordListDesc); diff --git a/contrib/src/stc/scintilla/src/LexPOV.cxx b/contrib/src/stc/scintilla/src/LexPOV.cxx index 33ba6a490f..0c1a21ab48 100644 --- a/contrib/src/stc/scintilla/src/LexPOV.cxx +++ b/contrib/src/stc/scintilla/src/LexPOV.cxx @@ -33,10 +33,18 @@ static inline bool IsAWordChar(const int ch) { return ch < 0x80 && (isalnum(ch) || ch == '_'); } -inline bool IsAWordStart(const int ch) { +static inline bool IsAWordStart(const int ch) { return ch < 0x80 && isalpha(ch); } +static inline bool IsANumberChar(const int ch) { + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. + return (ch < 0x80) && + (isdigit(ch) || toupper(ch) == 'E' || + ch == '.' || ch == '-' || ch == '+'); +} + static void ColourisePovDoc( unsigned int startPos, int length, @@ -91,11 +99,8 @@ static void ColourisePovDoc( sc.SetState(SCE_POV_DEFAULT); } else if (sc.state == SCE_POV_NUMBER) { // We stop the number definition on non-numerical non-dot non-eE non-sign char - if (!(isdigit(sc.ch) || sc.ch == '.' || - toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) { - // Not exactly following number definition (several dots are seen as OK, etc.) - // but probably enough in most cases. - sc.SetState(SCE_POV_DEFAULT); + if (!IsANumberChar(sc.ch)) { + sc.SetState(SCE_POV_DEFAULT); } } else if (sc.state == SCE_POV_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { diff --git a/contrib/src/stc/scintilla/src/LexPerl.cxx b/contrib/src/stc/scintilla/src/LexPerl.cxx index 211c3b8751..16a068778e 100644 --- a/contrib/src/stc/scintilla/src/LexPerl.cxx +++ b/contrib/src/stc/scintilla/src/LexPerl.cxx @@ -2,7 +2,8 @@ /** @file LexPerl.cxx ** Lexer for subset of Perl. **/ -// Copyright 1998-2001 by Neil Hodgson +// Lexical analysis fixes by Kein-Hong Man 20031020 +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -19,6 +20,14 @@ #include "Scintilla.h" #include "SciLexer.h" +#define PERLNUM_DECIMAL 1 +#define PERLNUM_NON_DEC 2 +#define PERLNUM_FLOAT 3 +#define PERLNUM_VECTOR 4 +#define PERLNUM_V_VECTOR 5 + +#define HERE_DELIM_MAX 256 + static inline bool isEOLChar(char ch) { return (ch == '\r') || (ch == '\n'); } @@ -31,9 +40,6 @@ static bool isSingleCharOp(char ch) { } static inline bool isPerlOperator(char ch) { - if (isalnum(ch)) - return false; - // '.' left out as it is used to make up numbers if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' || ch == '(' || ch == ')' || ch == '-' || ch == '+' || ch == '=' || ch == '|' || ch == '{' || ch == '}' || @@ -46,18 +52,13 @@ static inline bool isPerlOperator(char ch) { static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { char s[100]; - bool wordIsNumber = isdigit(styler[start]) || (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_PL_IDENTIFIER; - if (wordIsNumber) - chAttr = SCE_PL_NUMBER; - else { - if (keywords.InList(s)) - chAttr = SCE_PL_WORD; - } + if (keywords.InList(s)) + chAttr = SCE_PL_WORD; styler.ColourTo(end, chAttr); return chAttr; } @@ -67,6 +68,23 @@ static inline bool isEndVar(char ch) { ch != '_' && ch != '\''; } +static inline bool isNonQuote(char ch) { + return isalnum(ch) || ch == '_'; +} + +static inline char actualNumStyle(int numberStyle) { + switch (numberStyle) { + case PERLNUM_VECTOR: + case PERLNUM_V_VECTOR: + return SCE_PL_STRING; + case PERLNUM_DECIMAL: + case PERLNUM_NON_DEC: + case PERLNUM_FLOAT: + default: + return SCE_PL_NUMBER; + } +} + static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) { if ((pos + static_cast(strlen(val))) >= lengthDoc) { return false; @@ -109,12 +127,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, char Quote; // the char after '<<' bool Quoted; // true if Quote in ('\'','"','`') int DelimiterLength; // strlen(Delimiter) - char Delimiter[256]; // the Delimiter, 256: sizeof PL_tokenbuf + char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf HereDocCls() { State = 0; DelimiterLength = 0; + Delimiter = new char[HERE_DELIM_MAX]; Delimiter[0] = '\0'; } + ~HereDocCls() { + delete []Delimiter; + } }; HereDocCls HereDoc; // TODO: FIFO for stacked here-docs @@ -141,14 +163,17 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, }; QuoteCls Quote; - char sooked[100]; - int sookedpos = 0; - bool preferRE = true; - sooked[sookedpos] = '\0'; int state = initStyle; + char numState = PERLNUM_DECIMAL; + int dotCount = 0; unsigned int lengthDoc = startPos + length; + //int sookedpos = 0; // these have no apparent use, see POD state + //char sooked[100]; + //sooked[sookedpos] = '\0'; - // If in a long distance lexical state, seek to the beginning to find quote characters + // If in a long distance lexical state, seek to the beginning to find quote characters + // Perl strings can be multi-line with embedded newlines, so backtrack. + // Perl numbers have additional state during lexing, so backtrack too. if (state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX) { while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_PL_HERE_DELIM)) { startPos--; @@ -163,6 +188,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, || state == SCE_PL_STRING_QW || state == SCE_PL_REGEX || state == SCE_PL_REGSUBST + || state == SCE_PL_STRING + || state == SCE_PL_BACKTICKS + || state == SCE_PL_CHARACTER + || state == SCE_PL_NUMBER ) { while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) { startPos--; @@ -179,6 +208,9 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; + // if the current character is not consumed due to the completion of an + // earlier style, lexing can be restarted via a simple goto + restartLexer: chNext = styler.SafeGetCharAt(i + 1); char chNext2 = styler.SafeGetCharAt(i + 2); @@ -189,32 +221,36 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, continue; } if ((chPrev == '\r' && ch == '\n')) { // skip on DOS/Windows + styler.ColourTo(i, state); chPrev = ch; continue; } if (HereDoc.State == 1 && isEOLChar(ch)) { // Begin of here-doc (the line after the here-doc delimiter): + // Lexically, the here-doc starts from the next line after the >>, but the + // first line of here-doc seem to follow the style of the last EOL sequence HereDoc.State = 2; - styler.ColourTo(i - 1, state); if (HereDoc.Quoted) { if (state == SCE_PL_HERE_DELIM) { // Missing quote at end of string! We are stricter than perl. + // Colour here-doc anyway while marking this bit as an error. state = SCE_PL_ERROR; - } else { - switch (HereDoc.Quote) { - case '\'': - state = SCE_PL_HERE_Q ; - break; - case '"': - state = SCE_PL_HERE_QQ; - break; - case '`': - state = SCE_PL_HERE_QX; - break; - } + } + styler.ColourTo(i - 1, state); + switch (HereDoc.Quote) { + case '\'': + state = SCE_PL_HERE_Q ; + break; + case '"': + state = SCE_PL_HERE_QQ; + break; + case '`': + state = SCE_PL_HERE_QX; + break; } } else { + styler.ColourTo(i - 1, state); switch (HereDoc.Quote) { case '\\': state = SCE_PL_HERE_Q ; @@ -226,26 +262,37 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } if (state == SCE_PL_DEFAULT) { - if (iswordstart(ch)) { - styler.ColourTo(i - 1, state); - if (ch == 's' && !isalnum(chNext)) { + if (isdigit(ch) || (isdigit(chNext) && + (ch == '.' || ch == 'v'))) { + state = SCE_PL_NUMBER; + numState = PERLNUM_DECIMAL; + dotCount = 0; + if (ch == '0') { // hex,bin,octal + if (chNext == 'x' || chNext == 'b' || isdigit(chNext)) { + numState = PERLNUM_NON_DEC; + } + } else if (ch == 'v') { // vector + numState = PERLNUM_V_VECTOR; + } + } else if (iswordstart(ch)) { + if (ch == 's' && !isNonQuote(chNext)) { state = SCE_PL_REGSUBST; Quote.New(2); - } else if (ch == 'm' && !isalnum(chNext)) { + } else if (ch == 'm' && !isNonQuote(chNext)) { state = SCE_PL_REGEX; Quote.New(1); - } else if (ch == 'q' && !isalnum(chNext)) { + } else if (ch == 'q' && !isNonQuote(chNext)) { state = SCE_PL_STRING_Q; Quote.New(1); - } else if (ch == 'y' && !isalnum(chNext)) { + } else if (ch == 'y' && !isNonQuote(chNext)) { state = SCE_PL_REGSUBST; Quote.New(2); - } else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) { + } else if (ch == 't' && chNext == 'r' && !isNonQuote(chNext2)) { state = SCE_PL_REGSUBST; Quote.New(2); i++; chNext = chNext2; - } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) { + } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isNonQuote(chNext2)) { if (chNext == 'q') state = SCE_PL_STRING_QQ; else if (chNext == 'x') state = SCE_PL_STRING_QX; else if (chNext == 'r') state = SCE_PL_STRING_QR; @@ -253,9 +300,12 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, i++; chNext = chNext2; Quote.New(1); + } else if (ch == 'x' && (chNext == '=' || // repetition + (chNext != '_' && !isalnum(chNext)) || + (isdigit(chPrev) && isdigit(chNext)))) { + styler.ColourTo(i, SCE_PL_OPERATOR); } else { state = SCE_PL_WORD; - preferRE = false; if ((!iswordchar(chNext) && chNext != '\'') || (chNext == '.' && chNext2 == '.')) { // We need that if length of word == 1! @@ -265,10 +315,8 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } } } else if (ch == '#') { - styler.ColourTo(i - 1, state); state = SCE_PL_COMMENTLINE; } else if (ch == '\"') { - styler.ColourTo(i - 1, state); state = SCE_PL_STRING; Quote.New(1); Quote.Open(ch); @@ -277,31 +325,32 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, // Archaic call styler.ColourTo(i, state); } else { - styler.ColourTo(i - 1, state); state = SCE_PL_CHARACTER; Quote.New(1); Quote.Open(ch); } } else if (ch == '`') { - styler.ColourTo(i - 1, state); state = SCE_PL_BACKTICKS; Quote.New(1); Quote.Open(ch); } else if (ch == '$') { - preferRE = false; - styler.ColourTo(i - 1, state); if ((chNext == '{') || isspacechar(chNext)) { styler.ColourTo(i, SCE_PL_SCALAR); } else { state = SCE_PL_SCALAR; - i++; - ch = chNext; - chNext = chNext2; + if (chNext == '`' && chNext2 == '`') { + i += 2; + ch = styler.SafeGetCharAt(i); + chNext = styler.SafeGetCharAt(i + 1); + } else { + i++; + ch = chNext; + chNext = chNext2; + } } } else if (ch == '@') { - preferRE = false; - styler.ColourTo(i - 1, state); - if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { + if (isalpha(chNext) || chNext == '#' || chNext == '$' + || chNext == '_' || chNext == '+') { state = SCE_PL_ARRAY; } else if (chNext != '{' && chNext != '[') { styler.ColourTo(i, SCE_PL_ARRAY); @@ -311,8 +360,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, styler.ColourTo(i, SCE_PL_ARRAY); } } else if (ch == '%') { - preferRE = false; - styler.ColourTo(i - 1, state); if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { state = SCE_PL_HASH; } else if (chNext == '{') { @@ -321,56 +368,189 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, styler.ColourTo(i, SCE_PL_OPERATOR); } } else if (ch == '*') { - styler.ColourTo(i - 1, state); - state = SCE_PL_SYMBOLTABLE; - } else if (ch == '/' && preferRE) { - styler.ColourTo(i - 1, state); - state = SCE_PL_REGEX; - Quote.New(1); - Quote.Open(ch); + if (isalpha(chNext) || chNext == '_' || chNext == '{') { + state = SCE_PL_SYMBOLTABLE; + } else { + if (chNext == '*') { // exponentiation + i++; + ch = chNext; + chNext = chNext2; + } + styler.ColourTo(i, SCE_PL_OPERATOR); + } + } else if (ch == '/') { + // Explicit backward peeking to set a consistent preferRE for + // any slash found, so no longer need to track preferRE state. + // Find first previous significant lexed element and interpret. + bool preferRE = false; + unsigned int bk = (i > 0)? i - 1: 0; + char bkch; + styler.Flush(); + while ((bk > 0) && (styler.StyleAt(bk) == SCE_PL_DEFAULT || + styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) { + bk--; + } + if (bk == 0) { + preferRE = true; + } else { + int bkstyle = styler.StyleAt(bk); + switch(bkstyle) { + case SCE_PL_OPERATOR: + preferRE = true; + bkch = styler.SafeGetCharAt(bk); + if (bkch == ')' || bkch == ']') { + preferRE = false; + } else if (bkch == '}') { + // backtrack further, count balanced brace pairs + // if a brace pair found, see if it's a variable + int braceCount = 1; + while (--bk > 0) { + bkstyle = styler.StyleAt(bk); + if (bkstyle == SCE_PL_OPERATOR) { + bkch = styler.SafeGetCharAt(bk); + if (bkch == '}') { + braceCount++; + } else if (bkch == '{') { + if (--braceCount == 0) + break; + } + } + } + if (bk == 0) { + // at beginning, true + } else if (braceCount == 0) { + // balanced { found, check for variable + bkstyle = styler.StyleAt(bk - 1); + if (bkstyle == SCE_PL_SCALAR + || bkstyle == SCE_PL_ARRAY + || bkstyle == SCE_PL_HASH + || bkstyle == SCE_PL_SYMBOLTABLE) { + preferRE = false; + } + } + } + break; + // other styles uses the default, preferRE=false + case SCE_PL_IDENTIFIER: + case SCE_PL_POD: + case SCE_PL_WORD: + case SCE_PL_HERE_Q: + case SCE_PL_HERE_QQ: + case SCE_PL_HERE_QX: + preferRE = true; + break; + } + } + if (preferRE) { + state = SCE_PL_REGEX; + Quote.New(1); + Quote.Open(ch); + } else { + styler.ColourTo(i, SCE_PL_OPERATOR); + } } else if (ch == '<' && chNext == '<') { - styler.ColourTo(i - 1, state); state = SCE_PL_HERE_DELIM; HereDoc.State = 0; - } else if (ch == '=' + } else if (ch == '=' // POD && isalpha(chNext) && (isEOLChar(chPrev))) { - styler.ColourTo(i - 1, state); state = SCE_PL_POD; - sookedpos = 0; - sooked[sookedpos] = '\0'; - } else if (ch == '-' + //sookedpos = 0; + //sooked[sookedpos] = '\0'; + } else if (ch == '-' // file test operators && isSingleCharOp(chNext) && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) { - styler.ColourTo(i - 1, state); styler.ColourTo(i + 1, SCE_PL_WORD); state = SCE_PL_DEFAULT; - preferRE = false; - i += 2; - ch = chNext2; - chNext = chNext2 = styler.SafeGetCharAt(i + 1); + i++; + ch = chNext; + chNext = chNext2; } else if (isPerlOperator(ch)) { - if (ch == ')' || ch == ']') - preferRE = false; - else - preferRE = true; - styler.ColourTo(i - 1, state); + if (ch == '.' && chNext == '.') { // .. and ... + i++; + if (chNext2 == '.') { i++; } + state = SCE_PL_DEFAULT; + ch = styler.SafeGetCharAt(i); + chNext = styler.SafeGetCharAt(i + 1); + } styler.ColourTo(i, SCE_PL_OPERATOR); + } else { + // keep colouring defaults to make restart easier + styler.ColourTo(i, SCE_PL_DEFAULT); + } + } else if (state == SCE_PL_NUMBER) { + if (ch == '.') { + if (chNext == '.') { + // double dot is always an operator + goto numAtEnd; + } else if (numState == PERLNUM_NON_DEC || numState == PERLNUM_FLOAT) { + // non-decimal number or float exponent, consume next dot + styler.ColourTo(i - 1, SCE_PL_NUMBER); + styler.ColourTo(i, SCE_PL_OPERATOR); + state = SCE_PL_DEFAULT; + } else { // decimal or vectors allows dots + dotCount++; + if (numState == PERLNUM_DECIMAL) { + if (dotCount > 1) { + if (isdigit(chNext)) { // really a vector + numState = PERLNUM_VECTOR; + } else // number then dot + goto numAtEnd; + } + } else { // vectors + if (!isdigit(chNext)) // vector then dot + goto numAtEnd; + } + } + } else if (ch == '_' && numState == PERLNUM_DECIMAL) { + if (!isdigit(chNext)) { + goto numAtEnd; + } + } else if (isalnum(ch)) { + if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) { + if (isalpha(ch)) { + if (dotCount == 0) { // change to word + state = SCE_PL_WORD; + } else { // vector then word + goto numAtEnd; + } + } + } else if (numState == PERLNUM_DECIMAL) { + if (ch == 'E' || ch == 'e') { // exponent + numState = PERLNUM_FLOAT; + if (chNext == '+' || chNext == '-') { + i++; + ch = chNext; + chNext = chNext2; + } + } else if (!isdigit(ch)) { // number then word + goto numAtEnd; + } + } else if (numState == PERLNUM_FLOAT) { + if (!isdigit(ch)) { // float then word + goto numAtEnd; + } + } else {// (numState == PERLNUM_NON_DEC) + // allow alphanum for bin,hex,oct for now + } + } else { + // complete current number or vector + numAtEnd: + styler.ColourTo(i - 1, actualNumStyle(numState)); + state = SCE_PL_DEFAULT; + goto restartLexer; } } else if (state == SCE_PL_WORD) { if ((!iswordchar(chNext) && chNext != '\'') || (chNext == '.' && chNext2 == '.')) { // ".." is always an operator if preceded by a SCE_PL_WORD. // Archaic Perl has quotes inside names - if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) { - styler.ColourTo(i, SCE_PL_DATASECTION); - state = SCE_PL_DATASECTION; - } else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) { + if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__") + || isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) { styler.ColourTo(i, SCE_PL_DATASECTION); state = SCE_PL_DATASECTION; } else { - if (classifyWordPerl(styler.GetStartSegment(), i, keywords, styler) == SCE_PL_WORD) - preferRE = true; + classifyWordPerl(styler.GetStartSegment(), i, keywords, styler); state = SCE_PL_DEFAULT; ch = ' '; } @@ -380,6 +560,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, if (isEOLChar(ch)) { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; + goto restartLexer; + } else if (isEOLChar(chNext)) { + styler.ColourTo(i, state); + state = SCE_PL_DEFAULT; } } else if (state == SCE_PL_HERE_DELIM) { // @@ -398,9 +582,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, // There must be no space between the << and the identifier. // (If you put a space it will be treated as a null identifier, // which is valid, and matches the first empty line.) + // (This is deprecated, -w warns of this syntax) // The terminating string must appear by itself (unquoted and with no // surrounding whitespace) on the terminating line. // + // From Bash info: + // --------------- + // Specifier format is: <<[-]WORD + // Optional '-' is for removal of leading tabs from here-doc. + // Whitespace acceptable after <<[-] operator. + // if (HereDoc.State == 0) { // '<<' encountered HereDoc.State = 1; HereDoc.Quote = chNext; @@ -412,15 +603,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, ch = chNext; chNext = chNext2; HereDoc.Quoted = true; - } else if (chNext == '\\') { // ref? - i++; - ch = chNext; - chNext = chNext2; - } else if (isalnum(chNext) || chNext == '_') { // an unquoted here-doc delimiter - } - else if (isspacechar(chNext)) { // deprecated here-doc delimiter || TODO: left shift operator - } - else { // TODO: ??? + } else if (isalpha(chNext) || chNext == '_') { + // an unquoted here-doc delimiter, no special handling + } else if (isspacechar(chNext) || isdigit(chNext) || chNext == '\\' + || chNext == '=' || chNext == '$' || chNext == '@') { + // left shift << or <<= operator cases + styler.ColourTo(i, SCE_PL_OPERATOR); + state = SCE_PL_DEFAULT; + HereDoc.State = 0; + } else { + // symbols terminates; deprecated zero-length delimiter } } else if (HereDoc.State == 1) { // collect the delimiter @@ -428,9 +620,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, if (ch == HereDoc.Quote) { // closing quote => end of delimiter styler.ColourTo(i, state); state = SCE_PL_DEFAULT; - i++; - ch = chNext; - chNext = chNext2; } else { if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote i++; @@ -447,24 +636,27 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } else { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; + goto restartLexer; } } - if (HereDoc.DelimiterLength >= static_cast(sizeof(HereDoc.Delimiter)) - 1) { + if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { styler.ColourTo(i - 1, state); state = SCE_PL_ERROR; + goto restartLexer; } } } else if (HereDoc.State == 2) { // state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX if (isEOLChar(chPrev) && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) { i += HereDoc.DelimiterLength; - chNext = styler.SafeGetCharAt(i); - if (isEOLChar(chNext)) { + chPrev = styler.SafeGetCharAt(i - 1); + ch = styler.SafeGetCharAt(i); + if (isEOLChar(ch)) { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; HereDoc.State = 0; + goto restartLexer; } - ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } } else if (state == SCE_PL_POD) { @@ -474,33 +666,30 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, i += 4; state = SCE_PL_DEFAULT; ch = styler.SafeGetCharAt(i); - chNext = styler.SafeGetCharAt(i + 1); + //chNext = styler.SafeGetCharAt(i + 1); + goto restartLexer; } } - } else if (state == SCE_PL_SCALAR) { - if (isEndVar(ch)) { - if (i == (styler.GetStartSegment() + 1)) { + } else if (state == SCE_PL_SCALAR // variable names + || state == SCE_PL_ARRAY + || state == SCE_PL_HASH + || state == SCE_PL_SYMBOLTABLE) { + if (ch == ':' && chNext == ':') { // skip :: + i++; + ch = chNext; + chNext = chNext2; + } + else if (isEndVar(ch)) { + if ((state == SCE_PL_SCALAR || state == SCE_PL_ARRAY) + && i == (styler.GetStartSegment() + 1)) { // Special variable: $(, $_ etc. styler.ColourTo(i, state); + state = SCE_PL_DEFAULT; } else { styler.ColourTo(i - 1, state); + state = SCE_PL_DEFAULT; + goto restartLexer; } - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_ARRAY) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_HASH) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_SYMBOLTABLE) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; } } else if (state == SCE_PL_REGEX || state == SCE_PL_STRING_QR @@ -627,29 +816,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, Quote.Count++; } } - - if (state == SCE_PL_DEFAULT) { // One of the above succeeded - if (ch == '#') { - state = SCE_PL_COMMENTLINE; - } else if (ch == '\"') { - state = SCE_PL_STRING; - Quote.New(1); - Quote.Open(ch); - } else if (ch == '\'') { - state = SCE_PL_CHARACTER; - Quote.New(1); - Quote.Open(ch); - } else if (iswordstart(ch)) { - state = SCE_PL_WORD; - preferRE = false; - } else if (isPerlOperator(ch)) { - if (ch == ')' || ch == ']') - preferRE = false; - else - preferRE = true; - styler.ColourTo(i, SCE_PL_OPERATOR); - } - } } if (state == SCE_PL_ERROR) { break; diff --git a/contrib/src/stc/scintilla/src/LexRuby.cxx b/contrib/src/stc/scintilla/src/LexRuby.cxx index 43a874968d..692a47adef 100644 --- a/contrib/src/stc/scintilla/src/LexRuby.cxx +++ b/contrib/src/stc/scintilla/src/LexRuby.cxx @@ -96,6 +96,11 @@ static int GetRbStringState(Accessor &styler, int i, int *nextIndex) { return SCE_P_DEFAULT; } + if (i>0 && styler.SafeGetCharAt(i-1) == '$') { + *nextIndex = i + 1; + return SCE_P_DEFAULT; + } + if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) { *nextIndex = i + 3; diff --git a/contrib/src/stc/scintilla/src/LexSQL.cxx b/contrib/src/stc/scintilla/src/LexSQL.cxx index 3f65b12097..144176855e 100644 --- a/contrib/src/stc/scintilla/src/LexSQL.cxx +++ b/contrib/src/stc/scintilla/src/LexSQL.cxx @@ -88,7 +88,10 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, } else if (ch == '-' && chNext == '-') { styler.ColourTo(i - 1, state); state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + styler.ColourTo(i - 1, state); + state = SCE_C_CHARACTER; + } else if (ch == '"') { styler.ColourTo(i - 1, state); state = SCE_C_STRING; } else if (isoperator(ch)) { @@ -103,7 +106,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_C_COMMENT; } else if (ch == '-' && chNext == '-') { state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (ch == '"') { state = SCE_C_STRING; } else if (isoperator(ch)) { styler.ColourTo(i, SCE_C_OPERATOR); @@ -123,7 +128,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, styler.ColourTo(i - 1, state); state = SCE_C_DEFAULT; } - } else if (state == SCE_C_STRING) { + } else if (state == SCE_C_CHARACTER) { if (ch == '\'') { if ( chNext == '\'' ) { i++; @@ -134,7 +139,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, } ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - } else if (ch == '"') { + } + } else if (state == SCE_C_STRING) { + if (ch == '"') { if (chNext == '"') { i++; } else { @@ -151,7 +158,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_C_COMMENT; } else if (ch == '-' && chNext == '-') { state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (ch == '"') { state = SCE_C_STRING; } else if (iswordstart(ch)) { state = SCE_C_WORD; diff --git a/contrib/src/stc/scintilla/src/LexScriptol.cxx b/contrib/src/stc/scintilla/src/LexScriptol.cxx index fda10e316c..faaa2d46df 100644 --- a/contrib/src/stc/scintilla/src/LexScriptol.cxx +++ b/contrib/src/stc/scintilla/src/LexScriptol.cxx @@ -19,32 +19,31 @@ static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) { - char s[100]; - bool wordIsNumber = isdigit(styler[start]) != 0; - 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 (wordIsNumber) chAttr = SCE_P_NUMBER; - else if (keywords.InList(s)) chAttr = SCE_P_WORD; + char s[100]; + bool wordIsNumber = isdigit(styler[start]) != 0; + for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) + { + s[i] = styler[start + i]; + s[i + 1] = '\0'; + } + char chAttr = SCE_SCRIPTOL_IDENTIFIER; + if (0 == strcmp(prevWord, "class")) chAttr = SCE_SCRIPTOL_CLASSNAME; + else if (wordIsNumber) chAttr = SCE_SCRIPTOL_NUMBER; + else if (keywords.InList(s)) chAttr = SCE_SCRIPTOL_KEYWORD; else for (unsigned int i = 0; i < end - start + 1; i++) // test dotted idents { - if (styler[start + 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); + styler.ColourTo(start + i - 1, chAttr); + styler.ColourTo(start + i, SCE_SCRIPTOL_OPERATOR); + } + } + styler.ColourTo(end, chAttr); + strcpy(prevWord, s); } static bool IsSolComment(Accessor &styler, int pos, int len) { -// return len > 0 && styler[pos]=='`'; char c; if(len > 0) { @@ -63,60 +62,62 @@ static bool IsSolComment(Accessor &styler, int pos, int len) return false; } -static bool IsSolStringStart(char ch, char /*chNext*/) +static bool IsSolStringStart(char ch) { if (ch == '\'' || ch == '"') return true; - //chNext = chNext; // for future use - - return false; + return false; } -static bool IsSolWordStart(char ch, char chNext) +static bool IsSolWordStart(char ch) { - return (iswordchar(ch) && !IsSolStringStart(ch, chNext)); + return (iswordchar(ch) && !IsSolStringStart(ch)); } -/* 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 GetSolStringState(Accessor &styler, int i, int *nextIndex) { char ch = styler.SafeGetCharAt(i); char chNext = styler.SafeGetCharAt(i + 1); - if (ch != '"' && ch != '\'') { - *nextIndex = i + 1; - return SCE_P_DEFAULT; + if (ch != '\"' && ch != '\'') + { + *nextIndex = i + 1; + return SCE_SCRIPTOL_DEFAULT; } - + // ch is either single or double quotes in string + // code below seem non-sense but is here for future extensions if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) - { - *nextIndex = i + 3; - if (ch == '"') return SCE_P_TRIPLEDOUBLE; - else return SCE_P_TRIPLE; + { + *nextIndex = i + 3; + if(ch == '\"') return SCE_SCRIPTOL_TRIPLE; + if(ch == '\'') return SCE_SCRIPTOL_TRIPLE; + return SCE_SCRIPTOL_STRING; } - else - { - *nextIndex = i + 1; - if (ch == '"') return SCE_P_STRING; - else return SCE_P_CHARACTER; + else + { + *nextIndex = i + 1; + if (ch == '"') return SCE_SCRIPTOL_STRING; + else return SCE_SCRIPTOL_STRING; } } + static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) + WordList *keywordlists[], Accessor &styler) { int lengthDoc = startPos + length; + char stringType = '\"'; - // Backtrack to previous line in case need to fix its tab whinging if (startPos > 0) - { - int lineCurrent = styler.GetLine(startPos); - if (lineCurrent > 0) { - startPos = styler.LineStart(lineCurrent-1); - if (startPos == 0) initStyle = SCE_P_DEFAULT; - else initStyle = styler.StyleAt(startPos-1); - } + int lineCurrent = styler.GetLine(startPos); + if (lineCurrent > 0) + { + startPos = styler.LineStart(lineCurrent-1); + if (startPos == 0) initStyle = SCE_SCRIPTOL_DEFAULT; + else initStyle = styler.StyleAt(startPos-1); + } } styler.StartAt(startPos, 127); @@ -126,241 +127,216 @@ static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); char prevWord[200]; prevWord[0] = '\0'; - if (length == 0) return ; + if (length == 0) return; int state = initStyle & 31; int nextIndex = 0; - char chPrev = ' '; - //char chPrev2 = ' '; - char chNext = styler[startPos]; + char chPrev = ' '; + char chPrev2 = ' '; + char chNext = styler[startPos]; styler.StartSegment(startPos); bool atStartLine = true; int spaceFlags = 0; for (int i = startPos; i < lengthDoc; i++) - { + { - if (atStartLine) - { + if (atStartLine) + { char chBad = static_cast(64); char chGood = static_cast(0); char chFlags = chGood; if (whingeLevel == 1) { - chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; + chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; } else if (whingeLevel == 2) { - chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; + chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; } else if (whingeLevel == 3) { - chFlags = (spaceFlags & wsSpace) ? chBad : chGood; + chFlags = (spaceFlags & wsSpace) ? chBad : chGood; } else if (whingeLevel == 4) { - chFlags = (spaceFlags & wsTab) ? chBad : chGood; + chFlags = (spaceFlags & wsTab) ? chBad : chGood; } styler.SetFlags(chFlags, static_cast(state)); atStartLine = false; } - char ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); - if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) - { - if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) - { - styler.ColourTo(i, state); - } - atStartLine = true; - } + if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) + { + if ((state == SCE_SCRIPTOL_DEFAULT) || + (state == SCE_SCRIPTOL_TRIPLE) || + (state == SCE_SCRIPTOL_COMMENTBLOCK)) + { + styler.ColourTo(i, state); + } + atStartLine = true; + } - if (styler.IsLeadByte(ch)) - { - chNext = styler.SafeGetCharAt(i + 2); - chPrev = ' '; - //chPrev2 = ' '; - i += 1; - continue; - } + if (styler.IsLeadByte(ch)) + { + chNext = styler.SafeGetCharAt(i + 2); + chPrev = ' '; + chPrev2 = ' '; + i += 1; + continue; + } - if (state == SCE_P_STRINGEOL) - { - if (ch != '\r' && ch != '\n') + if (state == SCE_SCRIPTOL_STRINGEOL) + { + if (ch != '\r' && ch != '\n') { - styler.ColourTo(i - 1, state); - state = SCE_P_DEFAULT; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_DEFAULT; } - } + } - if (state == SCE_P_DEFAULT) - { - if (IsSolWordStart(ch, chNext)) + if (state == SCE_SCRIPTOL_DEFAULT) + { + if (IsSolWordStart(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_P_WORD; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_KEYWORD; } else if (ch == '`') { - styler.ColourTo(i - 1, state); - state = SCE_P_COMMENTLINE; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_COMMENTLINE; } else if (ch == '/') { - styler.ColourTo(i - 1, state); - if(chNext == '/') state = SCE_P_COMMENTLINE; - if(chNext == '*') state = SCE_P_COMMENTBLOCK; + styler.ColourTo(i - 1, state); + if(chNext == '/') state = SCE_SCRIPTOL_CSTYLE; + if(chNext == '*') state = SCE_SCRIPTOL_COMMENTBLOCK; } - else if (ch == '=' && chNext == 'b') - { - // =begin indicates the start of a comment (doc) block - if(styler.SafeGetCharAt(i + 2) == 'e' && styler.SafeGetCharAt(i + 3) == 'g' && styler.SafeGetCharAt(i + 4) == 'i' && styler.SafeGetCharAt(i + 5) == 'n') - { - styler.ColourTo(i - 1, state); - state = SCE_P_TRIPLEDOUBLE; //SCE_C_COMMENT; - } - } - else if (IsSolStringStart(ch, chNext)) + else if (IsSolStringStart(ch)) { styler.ColourTo(i - 1, state); state = GetSolStringState(styler, i, &nextIndex); + if(state == SCE_SCRIPTOL_STRING) + { + stringType = ch; + } if (nextIndex != i + 1) { - i = nextIndex - 1; - ch = ' '; - //chPrev = ' '; - chNext = styler.SafeGetCharAt(i + 1); + i = nextIndex - 1; + ch = ' '; + chPrev = ' '; + chNext = styler.SafeGetCharAt(i + 1); } - } + } else if (isoperator(ch)) { - styler.ColourTo(i - 1, state); - styler.ColourTo(i, SCE_P_OPERATOR); - } + styler.ColourTo(i - 1, state); + styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR); + } } - else if (state == SCE_P_WORD) + else if (state == SCE_SCRIPTOL_KEYWORD) { if (!iswordchar(ch)) { ClassifyWordSol(styler.GetStartSegment(), i - 1, keywords, styler, prevWord); - state = SCE_P_DEFAULT; + state = SCE_SCRIPTOL_DEFAULT; if (ch == '`') { - state = chNext == '`' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE; + state = chNext == '`' ? SCE_SCRIPTOL_PERSISTENT : SCE_SCRIPTOL_COMMENTLINE; } - else if (IsSolStringStart(ch, chNext)) + else if (IsSolStringStart(ch)) { styler.ColourTo(i - 1, state); state = GetSolStringState(styler, i, &nextIndex); - if (nextIndex != i + 1) + if (nextIndex != i + 1) { - i = nextIndex - 1; - ch = ' '; - //chPrev = ' '; - chNext = styler.SafeGetCharAt(i + 1); - } + i = nextIndex - 1; + ch = ' '; + chPrev = ' '; + chNext = styler.SafeGetCharAt(i + 1); + } } else if (isoperator(ch)) { - styler.ColourTo(i, SCE_P_OPERATOR); + styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR); } } } else { - if (state == SCE_P_COMMENTLINE) + if (state == SCE_SCRIPTOL_COMMENTLINE || + state == SCE_SCRIPTOL_PERSISTENT || + state == SCE_SCRIPTOL_CSTYLE) { - if (ch == '\r' || ch == '\n') + if (ch == '\r' || ch == '\n') { - styler.ColourTo(i - 1, state); - state = SCE_P_DEFAULT; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_DEFAULT; } } - else if(state == SCE_P_COMMENTBLOCK) + else if(state == SCE_SCRIPTOL_COMMENTBLOCK) { - if(ch == '*' && chNext == '/') state = SCE_P_DEFAULT; + if(chPrev == '*' && ch == '/') + { + styler.ColourTo(i, state); + state = SCE_SCRIPTOL_DEFAULT; + } } - else if (state == SCE_P_STRING) + else if ((state == SCE_SCRIPTOL_STRING) || + (state == SCE_SCRIPTOL_CHARACTER)) { - if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) + if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) { - styler.ColourTo(i - 1, state); - state = SCE_P_STRINGEOL; - } + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_STRINGEOL; + } else if (ch == '\\') { if (chNext == '\"' || chNext == '\'' || chNext == '\\') { - i++; - ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); + 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 == '\'') + else if ((ch == '\"') || (ch == '\'')) { - styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } - } - /* - else if (state == SCE_P_TRIPLE) + // must match the entered quote type + if(ch == stringType) + { + styler.ColourTo(i, state); + state = SCE_SCRIPTOL_DEFAULT; + } + } + } + else if (state == SCE_SCRIPTOL_TRIPLE) { - if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') + if ((ch == '\'' && chPrev == '\'' && chPrev2 == '\'') || + (ch == '\"' && chPrev == '\"' && chPrev2 == '\"')) { styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } - } - else if (state == SCE_P_TRIPLEDOUBLE) - { - // =end terminates the comment block - if (ch == 'd' && chPrev == 'n' && chPrev2 == 'e') - { - if (styler.SafeGetCharAt(i - 3) == '=') - { - styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } + state = SCE_SCRIPTOL_DEFAULT; } - } - */ - } - //chPrev2 = chPrev; - chPrev = ch; + } + + } + chPrev2 = chPrev; + chPrev = ch; } - if (state == SCE_P_WORD) - { - ClassifyWordSol(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord); + if (state == SCE_SCRIPTOL_KEYWORD) + { + ClassifyWordSol(styler.GetStartSegment(), + lengthDoc-1, keywords, styler, prevWord); } - else - { - styler.ColourTo(lengthDoc-1, state); + else + { + styler.ColourTo(lengthDoc-1, state); } } @@ -369,57 +345,58 @@ static void FoldSolDoc(unsigned int startPos, int length, int initStyle, { int lengthDoc = startPos + length; - // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); - if (startPos > 0) { - if (lineCurrent > 0) + if (startPos > 0) { - lineCurrent--; - startPos = styler.LineStart(lineCurrent); - if (startPos == 0) - initStyle = SCE_P_DEFAULT; - else - initStyle = styler.StyleAt(startPos-1); - } + if (lineCurrent > 0) + { + lineCurrent--; + startPos = styler.LineStart(lineCurrent); + if (startPos == 0) + initStyle = SCE_SCRIPTOL_DEFAULT; + else + initStyle = styler.StyleAt(startPos-1); + } } int state = initStyle & 31; int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsSolComment); - if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) - indentCurrent |= SC_FOLDLEVELWHITEFLAG; + if ((state == SCE_SCRIPTOL_TRIPLE)) + indentCurrent |= SC_FOLDLEVELWHITEFLAG; char chNext = styler[startPos]; for (int i = startPos; i < lengthDoc; i++) - { + { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i) & 31; if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) - { - int lev = indentCurrent; - int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsSolComment); - if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE)) - indentNext |= SC_FOLDLEVELWHITEFLAG; - if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) - { - // Only non whitespace lines can be headers - if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) - { - lev |= SC_FOLDLEVELHEADERFLAG; - } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { - // Line after is blank so check the next - maybe should continue further? - int spaceFlags2 = 0; - int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsSolComment); - if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) + int lev = indentCurrent; + int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsSolComment); + if (style == SCE_SCRIPTOL_TRIPLE) + indentNext |= SC_FOLDLEVELWHITEFLAG; + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { - lev |= SC_FOLDLEVELHEADERFLAG; - } - } - } - indentCurrent = indentNext; - styler.SetLevel(lineCurrent, lev); - lineCurrent++; + // Only non whitespace lines can be headers + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) + { + lev |= SC_FOLDLEVELHEADERFLAG; + } + else if (indentNext & SC_FOLDLEVELWHITEFLAG) + { + // Line after is blank so check the next - maybe should continue further? + int spaceFlags2 = 0; + int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsSolComment); + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) + { + lev |= SC_FOLDLEVELHEADERFLAG; + } + } + } + indentCurrent = indentNext; + styler.SetLevel(lineCurrent, lev); + lineCurrent++; } } } diff --git a/contrib/src/stc/scintilla/src/LexTeX.cxx b/contrib/src/stc/scintilla/src/LexTeX.cxx new file mode 100644 index 0000000000..a5b0946701 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexTeX.cxx @@ -0,0 +1,288 @@ +// Scintilla source code edit control + +// File: LexTeX.cxx - general context conformant tex coloring scheme +// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com +// Version: September 28, 2003 + +// Copyright: 1998-2003 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// This lexer is derived from the one written for the texwork environment (1999++) which in +// turn is inspired on texedit (1991++) which finds its roots in wdt (1986). + +// If you run into strange boundary cases, just tell me and I'll look into it. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "StyleContext.h" + +// val SCE_TEX_DEFAULT = 0 +// val SCE_TEX_SPECIAL = 1 +// val SCE_TEX_GROUP = 2 +// val SCE_TEX_SYMBOL = 3 +// val SCE_TEX_COMMAND = 4 +// val SCE_TEX_TEXT = 5 + +// Definitions in SciTEGlobal.properties: +// +// TeX Highlighting +// +// # Default +// style.tex.0=fore:#7F7F00 +// # Special +// style.tex.1=fore:#007F7F +// # Group +// style.tex.2=fore:#880000 +// # Symbol +// style.tex.3=fore:#7F7F00 +// # Command +// style.tex.4=fore:#008800 +// # Text +// style.tex.5=fore:#000000 + +// lexer.tex.interface.default=0 +// lexer.tex.comment.process=0 + +// todo: lexer.tex.auto.if + +// Auxiliary functions: + +static inline bool endOfLine(Accessor &styler, unsigned int i) { + return + (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')) ; +} + +static inline bool isTeXzero(int ch) { + return + (ch == '%') ; +} + +static inline bool isTeXone(int ch) { + return + (ch == '[') || (ch == ']') || (ch == '=') || (ch == '#') || + (ch == '(') || (ch == ')') || (ch == '<') || (ch == '>') || + (ch == '"') ; +} + +static inline bool isTeXtwo(int ch) { + return + (ch == '{') || (ch == '}') || (ch == '$') ; +} + +static inline bool isTeXthree(int ch) { + return + (ch == '~') || (ch == '^') || (ch == '_') || (ch == '&') || + (ch == '-') || (ch == '+') || (ch == '\"') || (ch == '`') || + (ch == '/') || (ch == '|') || (ch == '%') ; +} + +static inline bool isTeXfour(int ch) { + return + (ch == '\\') ; +} + +static inline bool isTeXfive(int ch) { + return + ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || + (ch == '@') || (ch == '!') || (ch == '?') ; +} + +static inline bool isTeXsix(int ch) { + return + (ch == ' ') ; +} + +static inline bool isTeXseven(int ch) { + return + (ch == '^') ; +} + +// Interface determination + +static int CheckTeXInterface( + unsigned int startPos, + int length, + Accessor &styler, + int defaultInterface) { + + char lineBuffer[1024] ; + unsigned int linePos = 0 ; + + // some day we can make something lexer.tex.mapping=(all,0)(nl,1)(en,2)... + + if (styler.SafeGetCharAt(0) == '%') { + for (unsigned int i = 0; i < startPos + length; i++) { + lineBuffer[linePos++] = styler.SafeGetCharAt(i) ; + if (endOfLine(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + lineBuffer[linePos] = '\0'; + if (strstr(lineBuffer, "interface=all")) { + return 0 ; + } else if (strstr(lineBuffer, "interface=tex")) { + return 1 ; + } else if (strstr(lineBuffer, "interface=nl")) { + return 2 ; + } else if (strstr(lineBuffer, "interface=en")) { + return 3 ; + } else if (strstr(lineBuffer, "interface=de")) { + return 4 ; + } else if (strstr(lineBuffer, "interface=cz")) { + return 5 ; + } else if (strstr(lineBuffer, "interface=it")) { + return 6 ; + } else if (strstr(lineBuffer, "interface=ro")) { + return 7 ; + } else if (strstr(lineBuffer, "interface=latex")) { + // we will move latex cum suis up to 91+ when more keyword lists are supported + return 8 ; + } else if (styler.SafeGetCharAt(1) == 'D' && strstr(lineBuffer, "%D \\module")) { + // better would be to limit the search to just one line + return 3 ; + } else { + return defaultInterface ; + } + } + } + } + + return defaultInterface ; +} + +static void ColouriseTeXDoc( + unsigned int startPos, + int length, + int, + WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos) ; + styler.StartSegment(startPos) ; + + bool processComment = styler.GetPropertyInt("lexer.tex.comment.process", 0) == 1 ; + bool useKeywords = styler.GetPropertyInt("lexer.tex.use.keywords", 1) == 1 ; + bool autoIf = styler.GetPropertyInt("lexer.tex.auto.if", 1) == 1 ; + int defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ; + + char key[100] ; + int k ; + bool newifDone = false ; + bool inComment = false ; + + int currentInterface = CheckTeXInterface(startPos,length,styler,defaultInterface) ; + + if (currentInterface == 0) { + useKeywords = false ; + currentInterface = 1 ; + } + + WordList &keywords = *keywordlists[currentInterface-1] ; + + StyleContext sc(startPos, length, SCE_TEX_TEXT, styler); + + bool going = sc.More() ; // needed because of a fuzzy end of file state + + for (; going; sc.Forward()) { + + if (! sc.More()) { going = false ; } // we need to go one behind the end of text + + if (inComment) { + if (sc.atLineEnd) { + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + inComment = false ; + } + } else { + if (! isTeXfive(sc.ch)) { + if (sc.state == SCE_TEX_COMMAND) { + if (sc.LengthCurrent() == 1) { // \ + if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { + sc.Forward(2) ; // \^^ and \^^ + } + sc.ForwardSetState(SCE_TEX_TEXT) ; + } else { + sc.GetCurrent(key, sizeof(key)-1) ; + k = strlen(key) ; + memmove(key,key+1,k) ; // shift left over escape token + key[k] = '\0' ; + k-- ; + if (! keywords || ! useKeywords) { + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = false ; + } else if (k == 1) { //\ + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = false ; + } else if (keywords.InList(key)) { + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = autoIf && (strcmp(key,"newif") == 0) ; + } else if (autoIf && ! newifDone && (key[0] == 'i') && (key[1] == 'f') && keywords.InList("if")) { + sc.SetState(SCE_TEX_COMMAND) ; + } else { + sc.ChangeState(SCE_TEX_TEXT) ; + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + } + } + } + if (isTeXzero(sc.ch)) { + sc.SetState(SCE_TEX_SYMBOL) ; + sc.ForwardSetState(SCE_TEX_DEFAULT) ; + inComment = ! processComment ; + newifDone = false ; + } else if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { + sc.SetState(SCE_TEX_TEXT) ; + sc.ForwardSetState(SCE_TEX_TEXT) ; + } else if (isTeXone(sc.ch)) { + sc.SetState(SCE_TEX_SPECIAL) ; + newifDone = false ; + } else if (isTeXtwo(sc.ch)) { + sc.SetState(SCE_TEX_GROUP) ; + newifDone = false ; + } else if (isTeXthree(sc.ch)) { + sc.SetState(SCE_TEX_SYMBOL) ; + newifDone = false ; + } else if (isTeXfour(sc.ch)) { + sc.SetState(SCE_TEX_COMMAND) ; + } else if (isTeXsix(sc.ch)) { + sc.SetState(SCE_TEX_TEXT) ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + inComment = false ; + } else { + sc.SetState(SCE_TEX_TEXT) ; + } + } else if (sc.state != SCE_TEX_COMMAND) { + sc.SetState(SCE_TEX_TEXT) ; + } + } + } + sc.ChangeState(SCE_TEX_TEXT) ; + sc.Complete(); + +} + + +// Hooks into the system: + +static const char * const texWordListDesc[] = { + "TeX, eTeX, pdfTeX, Omega" + "ConTeXt Dutch", + "ConTeXt English", + "ConTeXt German", + "ConTeXt Czech", + "ConTeXt Italian", + "ConTeXt Romanian", + 0, +} ; + +LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", 0, texWordListDesc); diff --git a/contrib/src/stc/scintilla/src/LexVB.cxx b/contrib/src/stc/scintilla/src/LexVB.cxx index 72fdb9c3cf..93bdedbd89 100644 --- a/contrib/src/stc/scintilla/src/LexVB.cxx +++ b/contrib/src/stc/scintilla/src/LexVB.cxx @@ -2,7 +2,7 @@ /** @file LexVB.cxx ** Lexer for Visual Basic and VBScript. **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -24,16 +24,19 @@ static bool IsVBComment(Accessor &styler, int pos, int len) { return len>0 && styler[pos]=='\''; } -static inline bool IsTypeCharacter(const int ch) { +static inline bool IsTypeCharacter(int ch) { return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$'; } -static inline bool IsAWordChar(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); +// Extended to accept accented characters +static inline bool IsAWordChar(int ch) { + return ch >= 0x80 || + (isalnum(ch) || ch == '.' || ch == '_'); } -static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_'); +static inline bool IsAWordStart(int ch) { + return ch >= 0x80 || + (isalnum(ch) || ch == '_'); } static inline bool IsADateCharacter(const int ch) { @@ -45,6 +48,9 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) { WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; + WordList &keywords4 = *keywordlists[3]; styler.StartAt(startPos); @@ -56,26 +62,37 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, if (sc.state == SCE_B_OPERATOR) { sc.SetState(SCE_B_DEFAULT); - } else if (sc.state == SCE_B_KEYWORD) { + } else if (sc.state == SCE_B_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { - if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) { - if (sc.ch == ']') - sc.Forward(); - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); + // In Basic (except VBScript), a variable name or a function name + // can end with a special character indicating the type of the value + // held or returned. + bool skipType = false; + if (!vbScriptSyntax && IsTypeCharacter(sc.ch)) { + sc.Forward(); // Skip it + skipType = true; + } + if (sc.ch == ']') { + sc.Forward(); + } + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (skipType) { + s[strlen(s) - 1] = '\0'; + } + if (strcmp(s, "rem") == 0) { + sc.ChangeState(SCE_B_COMMENT); + } else { if (keywords.InList(s)) { - if (strcmp(s, "rem") == 0) { - sc.ChangeState(SCE_B_COMMENT); - if (sc.atLineEnd) { - sc.SetState(SCE_B_DEFAULT); - } - } else { - sc.SetState(SCE_B_DEFAULT); - } - } else { - sc.ChangeState(SCE_B_IDENTIFIER); - sc.SetState(SCE_B_DEFAULT); - } + sc.ChangeState(SCE_B_KEYWORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD2); + } else if (keywords3.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD3); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD4); + } // Else, it is really an identifier... + sc.SetState(SCE_B_DEFAULT); } } } else if (sc.state == SCE_B_NUMBER) { @@ -90,6 +107,9 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, sc.Forward(); } sc.ForwardSetState(SCE_B_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_B_STRINGEOL); + sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_COMMENT) { if (sc.atLineEnd) { @@ -132,7 +152,7 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_B_NUMBER); } else if (IsAWordStart(sc.ch) || (sc.ch == '[')) { - sc.SetState(SCE_B_KEYWORD); + sc.SetState(SCE_B_IDENTIFIER); } else if (isoperator(static_cast(sc.ch)) || (sc.ch == '\\')) { sc.SetState(SCE_B_OPERATOR); } @@ -202,6 +222,9 @@ static void ColouriseVBScriptDoc(unsigned int startPos, int length, int initStyl static const char * const vbWordListDesc[] = { "Keywords", + "user1", + "user2", + "user3", 0 }; diff --git a/contrib/src/stc/scintilla/src/LexYAML.cxx b/contrib/src/stc/scintilla/src/LexYAML.cxx new file mode 100644 index 0000000000..e3053f8140 --- /dev/null +++ b/contrib/src/stc/scintilla/src/LexYAML.cxx @@ -0,0 +1,305 @@ +// Scintilla source code edit control +/** @file LexYAML.cxx + ** Lexer for YAML. + **/ +// Copyright 2003- by Sean O'Dell +// Release under the same license as Scintilla/SciTE. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static const char * const yamlWordListDesc[] = { + "Keywords", + 0 +}; + +static inline bool AtEOL(Accessor &styler, unsigned int i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +static unsigned int SpaceCount(char* lineBuffer) { + if (lineBuffer == NULL) + return 0; + + char* headBuffer = lineBuffer; + + while (*headBuffer == ' ') + headBuffer++; + + return headBuffer - lineBuffer; +} + +#define YAML_STATE_BITSIZE 16 +#define YAML_STATE_MASK (0xFFFF0000) +#define YAML_STATE_DOCUMENT (1 << YAML_STATE_BITSIZE) +#define YAML_STATE_VALUE (2 << YAML_STATE_BITSIZE) +#define YAML_STATE_COMMENT (3 << YAML_STATE_BITSIZE) +#define YAML_STATE_TEXT_PARENT (4 << YAML_STATE_BITSIZE) +#define YAML_STATE_TEXT (5 << YAML_STATE_BITSIZE) + +static void ColouriseYAMLLine( + char *lineBuffer, + unsigned int currentLine, + unsigned int lengthLine, + unsigned int startLine, + unsigned int endPos, + WordList &keywords, + Accessor &styler) { + + unsigned int i = 0; + bool bInQuotes = false; + unsigned int indentAmount = SpaceCount(lineBuffer); + + if (currentLine > 0) { + int parentLineState = styler.GetLineState(currentLine - 1); + + if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) { + unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK); + if (indentAmount > parentIndentAmount) { + styler.SetLineState(currentLine, YAML_STATE_TEXT | parentIndentAmount); + styler.ColourTo(endPos, SCE_YAML_TEXT); + return; + } + } + } + styler.SetLineState(currentLine, 0); + if (strncmp(lineBuffer, "---", 3) == 0) { // Document marker + styler.SetLineState(currentLine, YAML_STATE_DOCUMENT); + styler.ColourTo(endPos, SCE_YAML_DOCUMENT); + return; + } + // Skip initial spaces + while ((i < lengthLine) && lineBuffer[i] == ' ') { // YAML always uses space, never TABS or anything else + i++; + } + if (lineBuffer[i] == '\t') { // if we skipped all spaces, and we are NOT inside a text block, this is wrong + styler.ColourTo(endPos, SCE_YAML_ERROR); + return; + } + if (lineBuffer[i] == '#') { // Comment + styler.SetLineState(currentLine, YAML_STATE_COMMENT); + styler.ColourTo(endPos, SCE_YAML_COMMENT); + return; + } + while (i < lengthLine) { + if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') { + bInQuotes = !bInQuotes; + } else if (lineBuffer[i] == ':' && !bInQuotes) { + styler.ColourTo(startLine + i, SCE_YAML_IDENTIFIER); + // Non-folding scalar + i++; + while ((i < lengthLine) && isspacechar(lineBuffer[i])) + i++; + unsigned int endValue = lengthLine - 1; + while ((endValue >= i) && isspacechar(lineBuffer[endValue])) + endValue--; + lineBuffer[endValue + 1] = '\0'; + if (lineBuffer[i] == '|' || lineBuffer[i] == '>') { + i++; + if (lineBuffer[i] == '+' || lineBuffer[i] == '-') + i++; + while ((i < lengthLine) && isspacechar(lineBuffer[i])) + i++; + if (lineBuffer[i] == '\0') { + styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount); + styler.ColourTo(endPos, SCE_YAML_DEFAULT); + return; + } else if (lineBuffer[i] == '#') { + styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount); + styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT); + styler.ColourTo(endPos, SCE_YAML_COMMENT); + return; + } else { + styler.ColourTo(endPos, SCE_YAML_ERROR); + return; + } + } + styler.SetLineState(currentLine, YAML_STATE_VALUE); + if (lineBuffer[i] == '&' || lineBuffer[i] == '*') { + styler.ColourTo(endPos, SCE_YAML_REFERENCE); + return; + } + if (keywords.InList(&lineBuffer[i])) { // Convertible value (true/false, etc.) + styler.ColourTo(endPos, SCE_YAML_KEYWORD); + return; + } else { + unsigned int i2 = i; + while ((i < lengthLine) && lineBuffer[i]) { + if (!isdigit(lineBuffer[i]) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') { + styler.ColourTo(endPos, SCE_YAML_DEFAULT); + return; + } + i++; + } + if (i > i2) { + styler.ColourTo(endPos, SCE_YAML_NUMBER); + return; + } + } + break; // shouldn't get here, but just in case, the rest of the line is coloured the default + } + i++; + } + styler.ColourTo(endPos, SCE_YAML_DEFAULT); +} + +static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { + char lineBuffer[1024]; + styler.StartAt(startPos); + styler.StartSegment(startPos); + unsigned int linePos = 0; + unsigned int startLine = startPos; + unsigned int endPos = startPos + length; + unsigned int maxPos = styler.Length(); + unsigned int lineCurrent = styler.GetLine(startPos); + + for (unsigned int i = startPos; i < maxPos && i < endPos; i++) { + lineBuffer[linePos++] = styler[i]; + if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + // End of line (or of line buffer) met, colourise it + lineBuffer[linePos] = '\0'; + ColouriseYAMLLine(lineBuffer, lineCurrent, linePos, startLine, i, *keywordLists[0], styler); + linePos = 0; + startLine = i + 1; + lineCurrent++; + } + } + if (linePos > 0) { // Last line does not have ending characters + ColouriseYAMLLine(lineBuffer, lineCurrent, linePos, startLine, startPos + length - 1, *keywordLists[0], styler); + } +} + +static bool IsCommentLine(int line, Accessor &styler) { + int pos = styler.LineStart(line); + if (styler[pos] == '#') + return true; + return false; +} + +static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unused*/, + WordList *[], Accessor &styler) { + 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.yaml") != 0; + + // Backtrack to previous non-blank line so we can determine indent level + // for any white space lines + // and so we can fix any preceding fold level (which is why we go back + // at least one line in all cases) + int spaceFlags = 0; + int lineCurrent = styler.GetLine(startPos); + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + while (lineCurrent > 0) { + lineCurrent--; + indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) && + (!IsCommentLine(lineCurrent, styler))) + break; + } + int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + + // Set up initial loop state + int prevComment = 0; + if (lineCurrent >= 1) + prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler); + + // Process all characters to end of requested range + // or comment that hangs over the end of the range. Cap processing in all cases + // to end of document (in case of unclosed comment at end). + while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) { + + // Gather info + int lev = indentCurrent; + int lineNext = lineCurrent + 1; + int indentNext = indentCurrent; + if (lineNext <= docLines) { + // Information about next line is only available if not at end of document + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + const int comment = foldComment && IsCommentLine(lineCurrent, styler); + const int comment_start = (comment && !prevComment && (lineNext <= docLines) && + IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE)); + const int comment_continue = (comment && prevComment); + if (!comment) + indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + if (indentNext & SC_FOLDLEVELWHITEFLAG) + indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel; + + if (comment_start) { + // Place fold point at start of a block of comments + lev |= SC_FOLDLEVELHEADERFLAG; + } else if (comment_continue) { + // Add level to rest of lines in the block + lev = lev + 1; + } + + // Skip past any blank lines for next indent level info; we skip also + // comments (all comments, not just those starting in column 0) + // which effectively folds them into surrounding code rather + // than screwing up folding. + + while ((lineNext < docLines) && + ((indentNext & SC_FOLDLEVELWHITEFLAG) || + (lineNext <= docLines && IsCommentLine(lineNext, styler)))) { + + lineNext++; + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + + const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK; + const int levelBeforeComments = Platform::Maximum(indentCurrentLevel,levelAfterComments); + + // Now set all the indent levels on the lines we skipped + // Do this from end to start. Once we encounter one line + // which is indented more than the line after the end of + // the comment-block, use the level of the block before + + int skipLine = lineNext; + int skipLevel = levelAfterComments; + + while (--skipLine > lineCurrent) { + int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL); + + if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments) + skipLevel = levelBeforeComments; + + int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG; + + styler.SetLevel(skipLine, skipLevel | whiteFlag); + } + + // Set fold header on non-comment line + if (!comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) { + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) + lev |= SC_FOLDLEVELHEADERFLAG; + } + + // Keep track of block comment state of previous line + prevComment = comment_start || comment_continue; + + // Set fold level for this line and move to next line + styler.SetLevel(lineCurrent, lev); + indentCurrent = indentNext; + lineCurrent = lineNext; + } + + // 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 lmYAML(SCLEX_YAML, ColouriseYAMLDoc, "yaml", FoldYAMLDoc, yamlWordListDesc); diff --git a/contrib/src/stc/scintilla/src/PropSet.cxx b/contrib/src/stc/scintilla/src/PropSet.cxx index 021a657273..658d5046a4 100644 --- a/contrib/src/stc/scintilla/src/PropSet.cxx +++ b/contrib/src/stc/scintilla/src/PropSet.cxx @@ -562,7 +562,7 @@ bool WordList::InList(const char *s) { * The length of the word to compare is passed too. * Letter case can be ignored or preserved (default). */ -const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) { +const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */, int wordIndex /*= -1 */) { int start = 0; // lower bound of the api array block to search int end = len - 1; // upper bound of the api array block to search int pivot; // index of api array element just being compared @@ -580,8 +580,33 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 pivot = (start + end) >> 1; word = wordsNoCase[pivot]; cond = CompareNCaseInsensitive(wordStart, word, searchLen); - if (!cond && (!wordCharacters.contains(word[searchLen]))) + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found a word in a binary fashion. Now checks if a specific index was requested + if (wordIndex < 0) return word; // result must not be freed with free() + + // Finds first word in a series of equal words + int first = pivot; + end = pivot - 1; + while (start <= end) { + pivot = (start + end) >> 1; + word = wordsNoCase[pivot]; + cond = CompareNCaseInsensitive(wordStart, word, searchLen); + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found another word + first = pivot; + end = pivot - 1; + } + else if (cond > 0) + start = pivot + 1; + else if (cond <= 0) + break; + } + + // Gets the word at the requested index + word = wordsNoCase[first + wordIndex]; + return word; + } else if (cond > 0) start = pivot + 1; else if (cond <= 0) @@ -592,8 +617,33 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 pivot = (start + end) >> 1; word = words[pivot]; cond = strncmp(wordStart, word, searchLen); - if (!cond && (!wordCharacters.contains(word[searchLen]))) - return word; // result must not be freed with free() + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found a word in a binary fashion. Now checks if a specific index was requested + if (wordIndex < 0) + return word; // result must not be freed with free() + + // Finds first word in a series of equal words + int first = pivot; + end = pivot - 1; + while (start <= end) { + pivot = (start + end) >> 1; + word = words[pivot]; + cond = strncmp(wordStart, word, searchLen); + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found another word + first = pivot; + end = pivot - 1; + } + else if (cond > 0) + start = pivot + 1; + else if (cond <= 0) + break; + } + + // Gets the word at the requested index + word = words[first + wordIndex]; + return word; + } else if (cond > 0) start = pivot + 1; else if (cond <= 0) diff --git a/contrib/src/stc/scintilla/src/RESearch.cxx b/contrib/src/stc/scintilla/src/RESearch.cxx index 3ca61bb9ce..b7ea71bfb9 100644 --- a/contrib/src/stc/scintilla/src/RESearch.cxx +++ b/contrib/src/stc/scintilla/src/RESearch.cxx @@ -10,11 +10,11 @@ * Dept. of Computer Science * York University * - * Original code available from http://www.cs.yorku.ca/~oz/ + * Original code available from http://www.cs.yorku.ca/~oz/ * Translation to C++ by Neil Hodgson neilh@scintilla.org * Removed all use of register. * Converted to modern function prototypes. - * Put all global/static variables into an object so this code can be + * Put all global/static variables into an object so this code can be * used from multiple threads etc. * * These routines are the PUBLIC DOMAIN equivalents of regex @@ -27,74 +27,8 @@ * see Henry Spencer's regexp routines, or GNU Emacs pattern * matching module. * - * Modification history: - * - * $Log$ - * Revision 1.8 2003/09/18 05:05:38 RD - * Updated to Scintilla 1.54 - * Applied most of patch #806092 - * Added new wxSTC sample from Otto Wyss - * - * Revision 1.9 2003/03/21 10:36:08 nyamatongwe - * Detect patterns too long in regular expression search. - * - * Revision 1.8 2003/03/04 10:53:59 nyamatongwe - * Patch from Jakub to optionally implement more POSIX compatible regular - * expressions. \(..\) changes to (..) - * Fixes problem where find previous would not find earlier matches on same - * line. - * - * Revision 1.8 2003/03/03 20:12:56 vrana - * Added posix syntax. - * - * Revision 1.7 2002/09/28 00:33:28 nyamatongwe - * Fixed problem with character ranges caused by expansion to 8 bits. - * - * Revision 1.6 2001/04/29 13:32:10 nyamatongwe - * Addition of new target methods - versions of ReplaceTarget that take counted - * strings to allow for nulls, SearchInTarget and Get/SetSearchFlags to use a - * series of calls rather than a structure. - * Handling of \000 in search and replace. - * Handling of /escapes within character ranges of regular expressions. - * Some handling of bare ^ and $ regular expressions. - * - * Revision 1.5 2001/04/20 07:36:09 nyamatongwe - * Removed DEBUG code that failed to compile on GTK+. - * - * Revision 1.4 2001/04/13 03:52:13 nyamatongwe - * Added URL to find original code to comments. - * - * Revision 1.3 2001/04/06 12:24:21 nyamatongwe - * Made regular expression searching work on a line by line basis, made ^ and - * $ work, made [set] work, and added a case insensitive option. - * - * Revision 1.2 2001/04/05 01:58:04 nyamatongwe - * Replace target functionality to make find and replace operations faster - * by diminishing screen updates and allow for \d patterns in the replacement - * text. - * - * Revision 1.1 2001/04/04 12:52:44 nyamatongwe - * Moved to public domain regular expresion implementation. - * - * Revision 1.4 1991/10/17 03:56:42 oz - * miscellaneous changes, small cleanups etc. - * - * Revision 1.3 1989/04/01 14:18:09 oz - * Change all references to a dfa: this is actually an nfa. - * - * Revision 1.2 88/08/28 15:36:04 oz - * Use a complement bitmap to represent NCL. - * This removes the need to have seperate - * code in the PMatch case block - it is - * just CCL code now. - * - * Use the actual CCL code in the CLO - * section of PMatch. No need for a recursive - * PMatch call. - * - * Use a bitmap table to set char bits in an - * 8-bit chunk. - * + * Modification history removed. + * * Interfaces: * RESearch::Compile: compile a regular expression into a NFA. * @@ -124,7 +58,7 @@ * void re_fail(msg, op) * char *msg; * char op; - * + * * Regular Expressions: * * [1] char matches itself, unless it is a special @@ -134,20 +68,20 @@ * * [3] \ matches the character following it, except * when followed by a left or right round bracket, - * a digit 1 to 9 or a left or right angle bracket. + * a digit 1 to 9 or a left or right angle bracket. * (see [7], [8] and [9]) - * It is used as an escape character for all + * It is used as an escape character for all * other meta-characters, and itself. When used * in a set ([4]), it is treated as an ordinary * character. * * [4] [set] matches one of the characters in the set. * If the first character in the set is "^", - * it matches a character NOT in the set, i.e. - * complements the set. A shorthand S-E is - * used to specify a set of characters S upto - * E, inclusive. The special characters "]" and - * "-" have no special meaning if they appear + * it matches a character NOT in the set, i.e. + * complements the set. A shorthand S-E is + * used to specify a set of characters S upto + * E, inclusive. The special characters "]" and + * "-" have no special meaning if they appear * as the first chars in the set. * examples: match: * @@ -212,8 +146,8 @@ * Notes: * * This implementation uses a bit-set representation for character - * classes for speed and compactness. Each character is represented - * by one bit in a 128-bit block. Thus, CCL always takes a + * classes for speed and compactness. Each character is represented + * by one bit in a 128-bit block. Thus, CCL always takes a * constant 16 bytes in the internal nfa, and RESearch::Execute does a single * bit comparison to locate the character in the set. * @@ -223,7 +157,7 @@ * compile: CHR f CHR o CLO CHR o END CLO ANY END END * matches: fo foo fooo foobar fobar foxx ... * - * pattern: fo[ob]a[rz] + * pattern: fo[ob]a[rz] * compile: CHR f CHR o CCL bitset CHR a CCL bitset END * matches: fobar fooar fobaz fooaz * @@ -263,7 +197,7 @@ * The following defines are not meant to be changeable. * They are for readability only. */ -#define BLKIND 0170 +#define BLKIND 0370 #define BITIND 07 #define ASCIIB 0177 @@ -271,7 +205,7 @@ const char bitarr[] = {1,2,4,8,16,32,64,'\200'}; #define badpat(x) (*nfa = END, x) - + RESearch::RESearch() { Init(); } @@ -361,7 +295,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b int n; char mask; /* xor mask -CCL/NCL */ int c1, c2; - + if (!pat || !length) if (sta) return 0; @@ -403,7 +337,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b i++; if (*++p == '^') { - mask = '\377'; + mask = '\377'; i++; p++; } else @@ -447,7 +381,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b for (n = 0; n < BITBLK; bittab[n++] = (char) 0) *mp++ = static_cast(mask ^ bittab[n]); - + break; case '*': /* match 0 or more.. */ @@ -592,7 +526,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b * RESearch::Execute: * execute nfa to find a match. * - * special cases: (nfa[0]) + * special cases: (nfa[0]) * BOL * Match only once, starting from the * beginning. @@ -617,7 +551,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { bol = lp; failure = 0; - + Clear(); switch(*ap) { @@ -658,7 +592,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { return 1; } -/* +/* * PMatch: internal routine for the hard part * * This code is partly snarfed from an early grep written by @@ -684,7 +618,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { * * At the end of a successful match, bopat[n] and eopat[n] * are set to the beginning and end of subpatterns matched - * by tagged expressions (n = 1 to 9). + * by tagged expressions (n = 1 to 9). * */ @@ -695,23 +629,23 @@ extern void re_fail(char *,char); * and EOW. the reason for not using ctype macros is that we can * let the user add into our own table. see RESearch::ModifyWord. This table * is not in the bitset form, since we may wish to extend it in the - * future for other character classifications. + * future for other character classifications. * * TRUE for 0-9 A-Z a-z _ */ static char chrtyp[MAXCHR] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; @@ -833,10 +767,10 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { * the compact bitset representation for the default table] */ -static char deftab[16] = { - 0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207', - '\376', '\377', '\377', 007 -}; +static char deftab[16] = { + 0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207', + '\376', '\377', '\377', 007 +}; void RESearch::ModifyWord(char *s) { int i; @@ -883,7 +817,7 @@ int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) { pin = c - '0'; break; } - + default: *dst++ = c; continue; diff --git a/contrib/src/stc/scintilla/src/ScintillaBase.cxx b/contrib/src/stc/scintilla/src/ScintillaBase.cxx index 039539ad3c..e42b5dc65e 100644 --- a/contrib/src/stc/scintilla/src/ScintillaBase.cxx +++ b/contrib/src/stc/scintilla/src/ScintillaBase.cxx @@ -198,16 +198,18 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { if (ac.chooseSingle && (listType == 0)) { if (list && !strchr(list, ac.GetSeparator())) { + const char *typeSep = strchr(list, ac.GetTypesep()); + size_t lenInsert = (typeSep) ? (typeSep-list) : strlen(list); if (ac.ignoreCase) { SetEmptySelection(currentPos - lenEntered); pdoc->DeleteChars(currentPos, lenEntered); SetEmptySelection(currentPos); - pdoc->InsertString(currentPos, list); - SetEmptySelection(currentPos + static_cast(strlen(list))); + pdoc->InsertString(currentPos, list, lenInsert); + SetEmptySelection(currentPos + lenInsert); } else { SetEmptySelection(currentPos); - pdoc->InsertString(currentPos, list + lenEntered); - SetEmptySelection(currentPos + static_cast(strlen(list + lenEntered))); + pdoc->InsertString(currentPos, list + lenEntered, lenInsert - lenEntered); + SetEmptySelection(currentPos + lenInsert - lenEntered); } return; } @@ -345,6 +347,10 @@ void ScintillaBase::AutoCompleteCompleted() { pdoc->EndUndoAction(); } +int ScintillaBase::AutoCompleteGetCurrent() { + return ac.lb->GetSelection(); +} + void ScintillaBase::CallTipShow(Point pt, const char *defn) { AutoCompleteCancel(); pt.y += vs.lineHeight; @@ -497,6 +503,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara ac.Select(reinterpret_cast(lParam)); break; + case SCI_AUTOCGETCURRENT: + return AutoCompleteGetCurrent(); + case SCI_AUTOCSETCANCELATSTART: ac.cancelAtStartPos = wParam != 0; break; @@ -557,7 +566,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.GetTypesep(); case SCI_CALLTIPSHOW: - CallTipShow(LocationFromPosition(wParam), + CallTipShow(LocationFromPosition(wParam), reinterpret_cast(lParam)); break; diff --git a/contrib/src/stc/scintilla/src/ScintillaBase.h b/contrib/src/stc/scintilla/src/ScintillaBase.h index bb09e3f5b3..6ea23ab5a3 100644 --- a/contrib/src/stc/scintilla/src/ScintillaBase.h +++ b/contrib/src/stc/scintilla/src/ScintillaBase.h @@ -65,6 +65,7 @@ protected: void AutoCompleteStart(int lenEntered, const char *list); void AutoCompleteCancel(); void AutoCompleteMove(int delta); + int AutoCompleteGetCurrent(); void AutoCompleteCharacterAdded(char ch); void AutoCompleteCharacterDeleted(); void AutoCompleteCompleted(); diff --git a/contrib/src/stc/scintilla/src/ViewStyle.cxx b/contrib/src/stc/scintilla/src/ViewStyle.cxx index eb8e54f2f8..e2a65e09e4 100644 --- a/contrib/src/stc/scintilla/src/ViewStyle.cxx +++ b/contrib/src/stc/scintilla/src/ViewStyle.cxx @@ -84,6 +84,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { hotspotBackgroundSet = source.hotspotBackgroundSet; hotspotBackground.desired = source.hotspotBackground.desired; hotspotUnderline = source.hotspotUnderline; + hotspotSingleLine = source.hotspotSingleLine; whitespaceForegroundSet = source.whitespaceForegroundSet; whitespaceForeground.desired = source.whitespaceForeground.desired; @@ -164,6 +165,7 @@ void ViewStyle::Init() { hotspotBackgroundSet = false; hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff); hotspotUnderline = true; + hotspotSingleLine = true; leftMarginWidth = 1; rightMarginWidth = 1; diff --git a/contrib/src/stc/scintilla/src/ViewStyle.h b/contrib/src/stc/scintilla/src/ViewStyle.h index ff38efef2e..5f27cc08cb 100644 --- a/contrib/src/stc/scintilla/src/ViewStyle.h +++ b/contrib/src/stc/scintilla/src/ViewStyle.h @@ -68,6 +68,7 @@ public: bool hotspotBackgroundSet; ColourPair hotspotBackground; bool hotspotUnderline; + bool hotspotSingleLine; /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin enum { margins=3 }; int leftMarginWidth; ///< Spacing margin on left of text diff --git a/contrib/src/stc/scintilla/src/XPM.cxx b/contrib/src/stc/scintilla/src/XPM.cxx index c3f66c2e40..e693736a21 100644 --- a/contrib/src/stc/scintilla/src/XPM.cxx +++ b/contrib/src/stc/scintilla/src/XPM.cxx @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file XPM.cxx - ** Define a class that holds data in the X Pixmap (XPM) format, + ** Define a class that holds data in the X Pixmap (XPM) format. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -33,7 +33,7 @@ static size_t MeasureLength(const char *s) { ColourAllocated XPM::ColourFromCode(int ch) { return colourCodeTable[ch]->allocated; #ifdef SLOW - for (int i=0;iGetId() == id) { set[i]->Init(textForm); return; } } - // No present, so add to end + // Not present, so add to end XPM *pxpm = new XPM(textForm); if (pxpm) { pxpm->SetId(id); pxpm->CopyDesiredColours(); if (len == maximum) { - int lenNew = len + 100; - XPM **setNew = new XPM *[lenNew]; - for (int i=0; iGetId() == id) { return set[i]; } @@ -276,7 +276,7 @@ XPM *XPMSet::Get(int id) { int XPMSet::GetHeight() { if (height < 0) { - for (int i=0; iGetHeight()) { height = set[i]->GetHeight(); } @@ -287,7 +287,7 @@ int XPMSet::GetHeight() { int XPMSet::GetWidth() { if (width < 0) { - for (int i=0; iGetWidth()) { width = set[i]->GetWidth(); } diff --git a/contrib/src/stc/scintilla/src/XPM.h b/contrib/src/stc/scintilla/src/XPM.h index 948e557a92..4d3da28d36 100644 --- a/contrib/src/stc/scintilla/src/XPM.h +++ b/contrib/src/stc/scintilla/src/XPM.h @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file XPM.h - ** Define a class that holds data in the X Pixmap (XPM) format, + ** Define a class that holds data in the X Pixmap (XPM) format. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -31,11 +31,11 @@ public: void Init(const char *textForm); void Init(const char * const *linesForm); void Clear(); - // Similar to same named method in ViewStyle: + /// Similar to same named method in ViewStyle: void RefreshColourPalette(Palette &pal, bool want); - // No palette used, so just copy the desired colours to the allocated colours: + /// No palette used, so just copy the desired colours to the allocated colours void CopyDesiredColours(); - // Decompose image into runs and use FillRectangle for each run: + /// Decompose image into runs and use FillRectangle for each run void Draw(Surface *surface, PRectangle &rc); char **InLinesForm() { return lines; } void SetId(int id_) { id = id_; } @@ -49,18 +49,23 @@ public: * A collection of pixmaps indexed by integer id. */ class XPMSet { - XPM **set; - int len; - int maximum; - int height; - int width; + XPM **set; ///< The stored XPMs. + int len; ///< Current number of XPMs. + int maximum; ///< Current maximum number of XPMs, increased by steps if reached. + int height; ///< Memorize largest height of the set. + int width; ///< Memorize largest width of the set. public: XPMSet(); ~XPMSet(); + /// Remove all XPMs. void Clear(); + /// Add a XPM. void Add(int id, const char *textForm); + /// Get XPM by id. XPM *Get(int id); + /// Give the largest height of the set. int GetHeight(); + /// Give the largest width of the set. int GetWidth(); }; diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 8d03e9c92d..2f5ea9eae1 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -154,7 +154,7 @@ void wxStyledTextCtrl::Create(wxWindow *parent, style |= wxVSCROLL | wxHSCROLL; #endif wxControl::Create(parent, id, pos, size, - style | wxWANTS_CHARS | wxCLIP_CHILDREN, + style | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name); #ifdef LINK_LEXERS @@ -619,7 +619,7 @@ void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { SendMsg(2070, MAKELONG(key, modifiers), cmd); } -// When key+modifier combination km do nothing. +// When key+modifier combination km is pressed do nothing. void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { SendMsg(2071, MAKELONG(key, modifiers)); } @@ -650,6 +650,7 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { } // Set the set of characters making up words for when moving or selecting by word. +// First sets deaults like SetCharsDefault. void wxStyledTextCtrl::SetWordChars(const wxString& characters) { SendMsg(2077, 0, (long)(const char*)wx2stc(characters)); } @@ -1049,7 +1050,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; @@ -1305,7 +1306,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // Returns the length of the replacement text. int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { @@ -1314,7 +1315,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text after \d processing. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // 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 @@ -1326,7 +1327,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Search for a counted string in the target and set the target to the found -// range. Text is counted so it can contain nulls. +// range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int wxStyledTextCtrl::SearchInTarget(const wxString& text) { @@ -1533,7 +1534,7 @@ int wxStyledTextCtrl::GetScrollWidth() { } // Measure the pixel width of some text in a particular style. -// Nul terminated text argument. +// NUL terminated text argument. // Does not handle tab or control characters. int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { return SendMsg(2276, style, (long)(const char*)wx2stc(text)); @@ -1884,7 +1885,7 @@ int wxStyledTextCtrl::GetXOffset() { return SendMsg(2398, 0, 0); } -// Set the last x chosen value to be the caret x position +// Set the last x chosen value to be the caret x position. void wxStyledTextCtrl::ChooseCaretX() { SendMsg(2399, 0, 0); } @@ -1906,7 +1907,7 @@ void wxStyledTextCtrl::SetPrintWrapMode(int mode) { SendMsg(2406, mode, 0); } -// Is printing line wrapped. +// Is printing line wrapped? int wxStyledTextCtrl::GetPrintWrapMode() { return SendMsg(2407, 0, 0); } @@ -1926,6 +1927,11 @@ void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) { SendMsg(2412, underline, 0); } +// Limit hotspots to single line so hotspots on two lines don't merge. +void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) { + SendMsg(2421, singleLine, 0); +} + // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int wxStyledTextCtrl::PositionBefore(int pos) { @@ -1948,6 +1954,43 @@ void wxStyledTextCtrl::CopyText(int length, const wxString& text) { SendMsg(2420, length, (long)(const char*)wx2stc(text)); } +// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +// by lines (SC_SEL_LINES). +void wxStyledTextCtrl::SetSelectionMode(int mode) { + SendMsg(2422, mode, 0); +} + +// Get the mode of the current selection. +int wxStyledTextCtrl::GetSelectionMode() { + return SendMsg(2423, 0, 0); +} + +// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelStartPosition(int line) { + return SendMsg(2424, line, 0); +} + +// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelEndPosition(int line) { + return SendMsg(2425, line, 0); +} + +// Set the set of characters making up whitespace for when moving or selecting by word. +// Should be called after SetWordChars. +void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) { + SendMsg(2443, 0, (long)(const char*)wx2stc(characters)); +} + +// Reset the set of characters for whitespace and word characters to the defaults. +void wxStyledTextCtrl::SetCharsDefault() { + SendMsg(2444, 0, 0); +} + +// Get currently selected item position in the auto-completion list +int wxStyledTextCtrl::AutoCompGetCurrent() { + return SendMsg(2445, 0, 0); +} + // Start notifying the container of all key presses and commands. void wxStyledTextCtrl::StartRecord() { SendMsg(3001, 0, 0); @@ -2336,6 +2379,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index b10b081bb7..f8fb2d1cc6 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -541,6 +541,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events diff --git a/contrib/src/stc/stc.h.in b/contrib/src/stc/stc.h.in index 0f9b62df2a..04c205e341 100644 --- a/contrib/src/stc/stc.h.in +++ b/contrib/src/stc/stc.h.in @@ -237,7 +237,8 @@ private: void OnEraseBackground(wxEraseEvent& evt); void OnMenu(wxCommandEvent& evt); void OnListBox(wxCommandEvent& evt); - + void OnIdle(wxIdleEvent& evt); + // Turn notifications from Scintilla into events void NotifyChange(); diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index f70374ee2f..207fd19dc0 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -57,7 +57,7 @@ #define wxSTC_INVALID_POSITION -1 -// Define start of Scintilla messages to be greater than all edit (EM_*) messages +// Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages // as many EM_ messages can be used although that use is deprecated. #define wxSTC_START 2000 #define wxSTC_OPTIONAL_START 3000 @@ -162,6 +162,7 @@ #define wxSTC_INDIC_DIAGONAL 3 #define wxSTC_INDIC_STRIKE 4 #define wxSTC_INDIC_HIDDEN 5 +#define wxSTC_INDIC_BOX 6 #define wxSTC_INDIC0_MASK 0x20 #define wxSTC_INDIC1_MASK 0x40 #define wxSTC_INDIC2_MASK 0x80 @@ -243,6 +244,11 @@ // where most code reside, and the lines after the caret, eg. the body of a function. #define wxSTC_CARET_EVEN 0x08 +// Selection modes +#define wxSTC_SEL_STREAM 0 +#define wxSTC_SEL_RECTANGLE 1 +#define wxSTC_SEL_LINES 2 + // Maximum value of keywordSet parameter of SetKeyWords. #define wxSTC_KEYWORDSET_MAX 8 @@ -333,6 +339,16 @@ #define wxSTC_LEX_PS 42 #define wxSTC_LEX_NSIS 43 #define wxSTC_LEX_MMIXAL 44 +#define wxSTC_LEX_CLW 45 +#define wxSTC_LEX_CLWNOCASE 46 +#define wxSTC_LEX_LOT 47 +#define wxSTC_LEX_YAML 48 +#define wxSTC_LEX_TEX 49 +#define wxSTC_LEX_METAPOST 50 +#define wxSTC_LEX_POWERBASIC 51 +#define wxSTC_LEX_FORTH 52 +#define wxSTC_LEX_ERLANG 53 +#define wxSTC_LEX_OCTAVE 54 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a // value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -542,7 +558,7 @@ #define wxSTC_PL_STRING_QR 29 #define wxSTC_PL_STRING_QW 30 -// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT +// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC #define wxSTC_B_DEFAULT 0 #define wxSTC_B_COMMENT 1 #define wxSTC_B_NUMBER 2 @@ -552,6 +568,10 @@ #define wxSTC_B_OPERATOR 6 #define wxSTC_B_IDENTIFIER 7 #define wxSTC_B_DATE 8 +#define wxSTC_B_STRINGEOL 9 +#define wxSTC_B_KEYWORD2 10 +#define wxSTC_B_KEYWORD3 11 +#define wxSTC_B_KEYWORD4 12 // Lexical states for SCLEX_PROPERTIES #define wxSTC_PROPS_DEFAULT 0 @@ -607,6 +627,8 @@ #define wxSTC_ERR_PHP 14 #define wxSTC_ERR_ELF 15 #define wxSTC_ERR_IFC 16 +#define wxSTC_ERR_IFORT 17 +#define wxSTC_ERR_ABSF 18 // Lexical states for SCLEX_BATCH #define wxSTC_BAT_DEFAULT 0 @@ -726,37 +748,50 @@ #define wxSTC_NNCRONTAB_ENVIRONMENT 9 #define wxSTC_NNCRONTAB_IDENTIFIER 10 +// Lexical states for SCLEX_FORTH (Forth Lexer) +#define wxSTC_FORTH_DEFAULT 0 +#define wxSTC_FORTH_COMMENT 1 +#define wxSTC_FORTH_COMMENT_ML 2 +#define wxSTC_FORTH_IDENTIFIER 3 +#define wxSTC_FORTH_CONTROL 4 +#define wxSTC_FORTH_KEYWORD 5 +#define wxSTC_FORTH_DEFWORD 6 +#define wxSTC_FORTH_PREWORD1 7 +#define wxSTC_FORTH_PREWORD2 8 +#define wxSTC_FORTH_NUMBER 9 +#define wxSTC_FORTH_STRING 10 +#define wxSTC_FORTH_LOCALE 11 + // Lexical states for SCLEX_MATLAB #define wxSTC_MATLAB_DEFAULT 0 #define wxSTC_MATLAB_COMMENT 1 #define wxSTC_MATLAB_COMMAND 2 #define wxSTC_MATLAB_NUMBER 3 #define wxSTC_MATLAB_KEYWORD 4 + +// single quoted string #define wxSTC_MATLAB_STRING 5 #define wxSTC_MATLAB_OPERATOR 6 #define wxSTC_MATLAB_IDENTIFIER 7 +#define wxSTC_MATLAB_DOUBLEQUOTESTRING 8 // Lexical states for SCLEX_SCRIPTOL #define wxSTC_SCRIPTOL_DEFAULT 0 -#define wxSTC_SCRIPTOL_COMMENT 1 +#define wxSTC_SCRIPTOL_WHITE 1 #define wxSTC_SCRIPTOL_COMMENTLINE 2 -#define wxSTC_SCRIPTOL_COMMENTDOC 3 -#define wxSTC_SCRIPTOL_NUMBER 4 -#define wxSTC_SCRIPTOL_WORD 5 -#define wxSTC_SCRIPTOL_STRING 6 -#define wxSTC_SCRIPTOL_CHARACTER 7 -#define wxSTC_SCRIPTOL_UUID 8 -#define wxSTC_SCRIPTOL_PREPROCESSOR 9 -#define wxSTC_SCRIPTOL_OPERATOR 10 -#define wxSTC_SCRIPTOL_IDENTIFIER 11 -#define wxSTC_SCRIPTOL_STRINGEOL 12 -#define wxSTC_SCRIPTOL_VERBATIM 13 -#define wxSTC_SCRIPTOL_REGEX 14 -#define wxSTC_SCRIPTOL_COMMENTLINEDOC 15 -#define wxSTC_SCRIPTOL_WORD2 16 -#define wxSTC_SCRIPTOL_COMMENTDOCKEYWORD 17 -#define wxSTC_SCRIPTOL_COMMENTDOCKEYWORDERROR 18 -#define wxSTC_SCRIPTOL_COMMENTBASIC 19 +#define wxSTC_SCRIPTOL_PERSISTENT 3 +#define wxSTC_SCRIPTOL_CSTYLE 4 +#define wxSTC_SCRIPTOL_COMMENTBLOCK 5 +#define wxSTC_SCRIPTOL_NUMBER 6 +#define wxSTC_SCRIPTOL_STRING 7 +#define wxSTC_SCRIPTOL_CHARACTER 8 +#define wxSTC_SCRIPTOL_STRINGEOL 9 +#define wxSTC_SCRIPTOL_KEYWORD 10 +#define wxSTC_SCRIPTOL_OPERATOR 11 +#define wxSTC_SCRIPTOL_IDENTIFIER 12 +#define wxSTC_SCRIPTOL_TRIPLE 13 +#define wxSTC_SCRIPTOL_CLASSNAME 14 +#define wxSTC_SCRIPTOL_PREPROCESSOR 15 // Lexical states for SCLEX_ASM #define wxSTC_ASM_DEFAULT 0 @@ -770,6 +805,10 @@ #define wxSTC_ASM_REGISTER 8 #define wxSTC_ASM_DIRECTIVE 9 #define wxSTC_ASM_DIRECTIVEOPERAND 10 +#define wxSTC_ASM_COMMENTBLOCK 11 +#define wxSTC_ASM_CHARACTER 12 +#define wxSTC_ASM_STRINGEOL 13 +#define wxSTC_ASM_EXTINSTRUCTION 14 // Lexical states for SCLEX_FORTRAN #define wxSTC_F_DEFAULT 0 @@ -905,6 +944,75 @@ #define wxSTC_MMIXAL_SYMBOL 16 #define wxSTC_MMIXAL_INCLUDE 17 +// Lexical states for SCLEX_CLW +#define wxSTC_CLW_DEFAULT 0 +#define wxSTC_CLW_LABEL 1 +#define wxSTC_CLW_COMMENT 2 +#define wxSTC_CLW_STRING 3 +#define wxSTC_CLW_USER_IDENTIFIER 4 +#define wxSTC_CLW_INTEGER_CONSTANT 5 +#define wxSTC_CLW_REAL_CONSTANT 6 +#define wxSTC_CLW_PICTURE_STRING 7 +#define wxSTC_CLW_KEYWORD 8 +#define wxSTC_CLW_COMPILER_DIRECTIVE 9 +#define wxSTC_CLW_BUILTIN_PROCEDURES_FUNCTION 10 +#define wxSTC_CLW_STRUCTURE_DATA_TYPE 11 +#define wxSTC_CLW_ATTRIBUTE 12 +#define wxSTC_CLW_STANDARD_EQUATE 13 +#define wxSTC_CLW_ERROR 14 + +// Lexical states for SCLEX_LOT +#define wxSTC_LOT_DEFAULT 0 +#define wxSTC_LOT_HEADER 1 +#define wxSTC_LOT_BREAK 2 +#define wxSTC_LOT_SET 3 +#define wxSTC_LOT_PASS 4 +#define wxSTC_LOT_FAIL 5 +#define wxSTC_LOT_ABORT 6 + +// Lexical states for SCLEX_YAML +#define wxSTC_YAML_DEFAULT 0 +#define wxSTC_YAML_COMMENT 1 +#define wxSTC_YAML_IDENTIFIER 2 +#define wxSTC_YAML_KEYWORD 3 +#define wxSTC_YAML_NUMBER 4 +#define wxSTC_YAML_REFERENCE 5 +#define wxSTC_YAML_DOCUMENT 6 +#define wxSTC_YAML_TEXT 7 +#define wxSTC_YAML_ERROR 8 + +// Lexical states for SCLEX_TEX +#define wxSTC_TEX_DEFAULT 0 +#define wxSTC_TEX_SPECIAL 1 +#define wxSTC_TEX_GROUP 2 +#define wxSTC_TEX_SYMBOL 3 +#define wxSTC_TEX_COMMAND 4 +#define wxSTC_TEX_TEXT 5 +#define wxSTC_METAPOST_DEFAULT 0 +#define wxSTC_METAPOST_SPECIAL 1 +#define wxSTC_METAPOST_GROUP 2 +#define wxSTC_METAPOST_SYMBOL 3 +#define wxSTC_METAPOST_COMMAND 4 +#define wxSTC_METAPOST_TEXT 5 +#define wxSTC_METAPOST_EXTRA 6 + +// Lexical states for SCLEX_ERLANG +#define wxSTC_ERLANG_DEFAULT 0 +#define wxSTC_ERLANG_COMMENT 1 +#define wxSTC_ERLANG_VARIABLE 2 +#define wxSTC_ERLANG_NUMBER 3 +#define wxSTC_ERLANG_KEYWORD 4 +#define wxSTC_ERLANG_STRING 5 +#define wxSTC_ERLANG_OPERATOR 6 +#define wxSTC_ERLANG_ATOM 7 +#define wxSTC_ERLANG_FUNCTION_NAME 8 +#define wxSTC_ERLANG_CHARACTER 9 +#define wxSTC_ERLANG_MACRO 10 +#define wxSTC_ERLANG_RECORD 11 +#define wxSTC_ERLANG_SEPARATOR 12 +#define wxSTC_ERLANG_NODE_NAME 13 +#define wxSTC_ERLANG_UNKNOWN 31 + //----------------------------------------- // Commands that can be bound to keystrokes @@ -1090,7 +1198,7 @@ // except they behave differently when word-wrap is enabled: // They go first to the start / end of the display line, like (Home|LineEnd)Display // The difference is that, the cursor is already at the point, it goes on to the start -// or end of the document line, as appropriate for (Home|LineEnd|VCHome)Extend. +// or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. #define wxSTC_CMD_HOMEWRAP 2349 #define wxSTC_CMD_HOMEWRAPEXTEND 2450 #define wxSTC_CMD_LINEENDWRAP 2451 @@ -1118,12 +1226,65 @@ // Delete forwards from the current position to the end of the line. #define wxSTC_CMD_DELLINERIGHT 2396 -// Move caret between paragraphs (delimited by empty lines) +// Move caret between paragraphs (delimited by empty lines). #define wxSTC_CMD_PARADOWN 2413 #define wxSTC_CMD_PARADOWNEXTEND 2414 #define wxSTC_CMD_PARAUP 2415 #define wxSTC_CMD_PARAUPEXTEND 2416 +// Move caret down one line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEDOWNRECTEXTEND 2426 + +// Move caret up one line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEUPRECTEXTEND 2427 + +// Move caret left one character, extending rectangular selection to new caret position. +#define wxSTC_CMD_CHARLEFTRECTEXTEND 2428 + +// Move caret right one character, extending rectangular selection to new caret position. +#define wxSTC_CMD_CHARRIGHTRECTEXTEND 2429 + +// Move caret to first position on line, extending rectangular selection to new caret position. +#define wxSTC_CMD_HOMERECTEXTEND 2430 + +// Move caret to before first visible character on line. +// If already there move to first character on line. +// In either case, extend rectangular selection to new caret position. +#define wxSTC_CMD_VCHOMERECTEXTEND 2431 + +// Move caret to last position on line, extending rectangular selection to new caret position. +#define wxSTC_CMD_LINEENDRECTEXTEND 2432 + +// Move caret one page up, extending rectangular selection to new caret position. +#define wxSTC_CMD_PAGEUPRECTEXTEND 2433 + +// Move caret one page down, extending rectangular selection to new caret position. +#define wxSTC_CMD_PAGEDOWNRECTEXTEND 2434 + +// Move caret to top of page, or one page up if already at top of page. +#define wxSTC_CMD_STUTTEREDPAGEUP 2435 + +// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. +#define wxSTC_CMD_STUTTEREDPAGEUPEXTEND 2436 + +// Move caret to bottom of page, or one page down if already at bottom of page. +#define wxSTC_CMD_STUTTEREDPAGEDOWN 2437 + +// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. +#define wxSTC_CMD_STUTTEREDPAGEDOWNEXTEND 2438 + +// Move caret left one word, position cursor at end of word. +#define wxSTC_CMD_WORDLEFTEND 2439 + +// Move caret left one word, position cursor at end of word, extending selection to new caret position. +#define wxSTC_CMD_WORDLEFTENDEXTEND 2440 + +// Move caret right one word, position cursor at end of word. +#define wxSTC_CMD_WORDRIGHTEND 2441 + +// Move caret right one word, position cursor at end of word, extending selection to new caret position. +#define wxSTC_CMD_WORDRIGHTENDEXTEND 2442 + // END of generated section //---------------------------------------------------------------------- @@ -1410,7 +1571,7 @@ public: // When key+modifier combination km is pressed perform msg. void CmdKeyAssign(int key, int modifiers, int cmd); - // When key+modifier combination km do nothing. + // When key+modifier combination km is pressed do nothing. void CmdKeyClear(int key, int modifiers); // Drop all key mappings. @@ -1429,6 +1590,7 @@ public: void SetCaretPeriod(int periodMilliseconds); // Set the set of characters making up words for when moving or selecting by word. + // First sets deaults like SetCharsDefault. void SetWordChars(const wxString& characters); // Start a sequence of actions that is undone and redone as a unit. @@ -1663,7 +1825,7 @@ public: int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect); @@ -1781,12 +1943,12 @@ public: int GetTargetEnd(); // Replace the target text with the argument text. - // Text is counted so it can contain nulls. + // Text is counted so it can contain NULs. // 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. + // Text is counted so it can contain NULs. // 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 @@ -1794,7 +1956,7 @@ public: int ReplaceTargetRE(const wxString& text); // Search for a counted string in the target and set the target to the found - // range. Text is counted so it can contain nulls. + // range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int SearchInTarget(const wxString& text); @@ -1919,7 +2081,7 @@ public: int GetScrollWidth(); // Measure the pixel width of some text in a particular style. - // Nul terminated text argument. + // NUL terminated text argument. // Does not handle tab or control characters. int TextWidth(int style, const wxString& text); @@ -2135,7 +2297,7 @@ public: void SetXOffset(int newOffset); int GetXOffset(); - // Set the last x chosen value to be the caret x position + // Set the last x chosen value to be the caret x position. void ChooseCaretX(); // Set the way the caret is kept visible when going sideway. @@ -2149,7 +2311,7 @@ public: // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). void SetPrintWrapMode(int mode); - // Is printing line wrapped. + // Is printing line wrapped? int GetPrintWrapMode(); // Set a fore colour for active hotspots. @@ -2161,6 +2323,9 @@ public: // Enable / Disable underlining active hotspots. void SetHotspotActiveUnderline(bool underline); + // Limit hotspots to single line so hotspots on two lines don't merge. + void SetHotspotSingleLine(bool singleLine); + // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int PositionBefore(int pos); @@ -2175,6 +2340,29 @@ public: // Copy argument text to the clipboard. void CopyText(int length, const wxString& text); + // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or + // by lines (SC_SEL_LINES). + void SetSelectionMode(int mode); + + // Get the mode of the current selection. + int GetSelectionMode(); + + // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). + int GetLineSelStartPosition(int line); + + // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). + int GetLineSelEndPosition(int line); + + // Set the set of characters making up whitespace for when moving or selecting by word. + // Should be called after SetWordChars. + void SetWhitespaceChars(const wxString& characters); + + // Reset the set of characters for whitespace and word characters to the defaults. + void SetCharsDefault(); + + // Get currently selected item position in the auto-completion list + int AutoCompGetCurrent(); + // Start notifying the container of all key presses and commands. void StartRecord(); @@ -2321,7 +2509,8 @@ private: void OnEraseBackground(wxEraseEvent& evt); void OnMenu(wxCommandEvent& evt); void OnListBox(wxCommandEvent& evt); - + void OnIdle(wxIdleEvent& evt); + // Turn notifications from Scintilla into events void NotifyChange(); diff --git a/src/stc/Makefile.in b/src/stc/Makefile.in index 6c645a2e24..2979989fef 100644 --- a/src/stc/Makefile.in +++ b/src/stc/Makefile.in @@ -57,48 +57,56 @@ STCDLL_OBJECTS = \ stcdll_CallTip.o \ stcdll_CellBuffer.o \ stcdll_ContractionState.o \ - stcdll_Document.o \ stcdll_DocumentAccessor.o \ + stcdll_Document.o \ stcdll_Editor.o \ stcdll_ExternalLexer.o \ stcdll_Indicator.o \ stcdll_KeyMap.o \ stcdll_KeyWords.o \ - stcdll_LexAVE.o \ stcdll_LexAda.o \ stcdll_LexAsm.o \ + stcdll_LexAVE.o \ stcdll_LexBaan.o \ stcdll_LexBullant.o \ - stcdll_LexCPP.o \ - stcdll_LexCSS.o \ + stcdll_LexCLW.o \ stcdll_LexConf.o \ + stcdll_LexCPP.o \ stcdll_LexCrontab.o \ + stcdll_LexCSS.o \ stcdll_LexEiffel.o \ + stcdll_LexErlang.o \ stcdll_LexEScript.o \ + stcdll_LexForth.o \ stcdll_LexFortran.o \ stcdll_LexHTML.o \ stcdll_LexLisp.o \ stcdll_LexLout.o \ stcdll_LexLua.o \ - stcdll_LexMMIXAL.o \ stcdll_LexMatlab.o \ + stcdll_LexMetapost.o \ + stcdll_LexMMIXAL.o \ + stcdll_LexMPT.o \ stcdll_LexNsis.o \ stcdll_LexOthers.o \ - stcdll_LexPOV.o \ - stcdll_LexPS.o \ stcdll_LexPascal.o \ + stcdll_LexPB.o \ stcdll_LexPerl.o \ + stcdll_LexPOV.o \ + stcdll_LexPS.o \ stcdll_LexPython.o \ stcdll_LexRuby.o \ - stcdll_LexSQL.o \ stcdll_LexScriptol.o \ + stcdll_LexSQL.o \ + stcdll_LexTeX.o \ stcdll_LexVB.o \ + stcdll_LexYAML.o \ stcdll_LineMarker.o \ stcdll_PropSet.o \ stcdll_RESearch.o \ stcdll_ScintillaBase.o \ - stcdll_Style.o \ stcdll_StyleContext.o \ + stcdll_Style.o \ stcdll_UniConversion.o \ stcdll_ViewStyle.o \ stcdll_WindowAccessor.o \ @@ -115,48 +123,56 @@ STCLIB_OBJECTS = \ stclib_CallTip.o \ stclib_CellBuffer.o \ stclib_ContractionState.o \ - stclib_Document.o \ stclib_DocumentAccessor.o \ + stclib_Document.o \ stclib_Editor.o \ stclib_ExternalLexer.o \ stclib_Indicator.o \ stclib_KeyMap.o \ stclib_KeyWords.o \ - stclib_LexAVE.o \ stclib_LexAda.o \ stclib_LexAsm.o \ + stclib_LexAVE.o \ stclib_LexBaan.o \ stclib_LexBullant.o \ - stclib_LexCPP.o \ - stclib_LexCSS.o \ + stclib_LexCLW.o \ stclib_LexConf.o \ + stclib_LexCPP.o \ stclib_LexCrontab.o \ + stclib_LexCSS.o \ stclib_LexEiffel.o \ + stclib_LexErlang.o \ stclib_LexEScript.o \ + stclib_LexForth.o \ stclib_LexFortran.o \ stclib_LexHTML.o \ stclib_LexLisp.o \ stclib_LexLout.o \ stclib_LexLua.o \ - stclib_LexMMIXAL.o \ stclib_LexMatlab.o \ + stclib_LexMetapost.o \ + stclib_LexMMIXAL.o \ + stclib_LexMPT.o \ stclib_LexNsis.o \ stclib_LexOthers.o \ - stclib_LexPOV.o \ - stclib_LexPS.o \ stclib_LexPascal.o \ + stclib_LexPB.o \ stclib_LexPerl.o \ + stclib_LexPOV.o \ + stclib_LexPS.o \ stclib_LexPython.o \ stclib_LexRuby.o \ - stclib_LexSQL.o \ stclib_LexScriptol.o \ + stclib_LexSQL.o \ + stclib_LexTeX.o \ stclib_LexVB.o \ + stclib_LexYAML.o \ stclib_LineMarker.o \ stclib_PropSet.o \ stclib_RESearch.o \ stclib_ScintillaBase.o \ - stclib_Style.o \ stclib_StyleContext.o \ + stclib_Style.o \ stclib_UniConversion.o \ stclib_ViewStyle.o \ stclib_WindowAccessor.o \ @@ -332,10 +348,10 @@ stcdll_CellBuffer.o: $(srcdir)/scintilla/src/CellBuffer.cxx stcdll_ContractionState.o: $(srcdir)/scintilla/src/ContractionState.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_Document.o: $(srcdir)/scintilla/src/Document.cxx +stcdll_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx +stcdll_Document.o: $(srcdir)/scintilla/src/Document.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_Editor.o: $(srcdir)/scintilla/src/Editor.cxx @@ -353,39 +369,48 @@ stcdll_KeyMap.o: $(srcdir)/scintilla/src/KeyMap.cxx stcdll_KeyWords.o: $(srcdir)/scintilla/src/KeyWords.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx - $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< - stcdll_LexAda.o: $(srcdir)/scintilla/src/LexAda.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexAsm.o: $(srcdir)/scintilla/src/LexAsm.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexBaan.o: $(srcdir)/scintilla/src/LexBaan.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexBullant.o: $(srcdir)/scintilla/src/LexBullant.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx +stcdll_LexCLW.o: $(srcdir)/scintilla/src/LexCLW.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx +stcdll_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx +stcdll_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexCrontab.o: $(srcdir)/scintilla/src/LexCrontab.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexEiffel.o: $(srcdir)/scintilla/src/LexEiffel.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexErlang.o: $(srcdir)/scintilla/src/LexErlang.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexEScript.o: $(srcdir)/scintilla/src/LexEScript.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexForth.o: $(srcdir)/scintilla/src/LexForth.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexFortran.o: $(srcdir)/scintilla/src/LexFortran.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< @@ -401,10 +426,16 @@ stcdll_LexLout.o: $(srcdir)/scintilla/src/LexLout.cxx stcdll_LexLua.o: $(srcdir)/scintilla/src/LexLua.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + +stcdll_LexMetapost.o: $(srcdir)/scintilla/src/LexMetapost.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexMMIXAL.o: $(srcdir)/scintilla/src/LexMMIXAL.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx +stcdll_LexMPT.o: $(srcdir)/scintilla/src/LexMPT.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx @@ -413,16 +444,19 @@ stcdll_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx stcdll_LexOthers.o: $(srcdir)/scintilla/src/LexOthers.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx +stcdll_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx +stcdll_LexPB.o: $(srcdir)/scintilla/src/LexPB.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx +stcdll_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx +stcdll_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + +stcdll_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx @@ -431,15 +465,21 @@ stcdll_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx stcdll_LexRuby.o: $(srcdir)/scintilla/src/LexRuby.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LexSQL.o: $(srcdir)/scintilla/src/LexSQL.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx +stcdll_LexTeX.o: $(srcdir)/scintilla/src/LexTeX.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< +stcdll_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< + stcdll_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< @@ -452,10 +492,10 @@ stcdll_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stcdll_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_Style.o: $(srcdir)/scintilla/src/Style.cxx +stcdll_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< -stcdll_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx +stcdll_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $< stcdll_UniConversion.o: $(srcdir)/scintilla/src/UniConversion.cxx @@ -491,10 +531,10 @@ stclib_CellBuffer.o: $(srcdir)/scintilla/src/CellBuffer.cxx stclib_ContractionState.o: $(srcdir)/scintilla/src/ContractionState.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_Document.o: $(srcdir)/scintilla/src/Document.cxx +stclib_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_DocumentAccessor.o: $(srcdir)/scintilla/src/DocumentAccessor.cxx +stclib_Document.o: $(srcdir)/scintilla/src/Document.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_Editor.o: $(srcdir)/scintilla/src/Editor.cxx @@ -512,39 +552,48 @@ stclib_KeyMap.o: $(srcdir)/scintilla/src/KeyMap.cxx stclib_KeyWords.o: $(srcdir)/scintilla/src/KeyWords.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx - $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< - stclib_LexAda.o: $(srcdir)/scintilla/src/LexAda.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexAsm.o: $(srcdir)/scintilla/src/LexAsm.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexAVE.o: $(srcdir)/scintilla/src/LexAVE.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexBaan.o: $(srcdir)/scintilla/src/LexBaan.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexBullant.o: $(srcdir)/scintilla/src/LexBullant.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx +stclib_LexCLW.o: $(srcdir)/scintilla/src/LexCLW.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx +stclib_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexConf.o: $(srcdir)/scintilla/src/LexConf.cxx +stclib_LexCPP.o: $(srcdir)/scintilla/src/LexCPP.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexCrontab.o: $(srcdir)/scintilla/src/LexCrontab.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexCSS.o: $(srcdir)/scintilla/src/LexCSS.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexEiffel.o: $(srcdir)/scintilla/src/LexEiffel.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexErlang.o: $(srcdir)/scintilla/src/LexErlang.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexEScript.o: $(srcdir)/scintilla/src/LexEScript.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexForth.o: $(srcdir)/scintilla/src/LexForth.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexFortran.o: $(srcdir)/scintilla/src/LexFortran.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< @@ -560,10 +609,16 @@ stclib_LexLout.o: $(srcdir)/scintilla/src/LexLout.cxx stclib_LexLua.o: $(srcdir)/scintilla/src/LexLua.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + +stclib_LexMetapost.o: $(srcdir)/scintilla/src/LexMetapost.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexMMIXAL.o: $(srcdir)/scintilla/src/LexMMIXAL.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexMatlab.o: $(srcdir)/scintilla/src/LexMatlab.cxx +stclib_LexMPT.o: $(srcdir)/scintilla/src/LexMPT.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx @@ -572,16 +627,19 @@ stclib_LexNsis.o: $(srcdir)/scintilla/src/LexNsis.cxx stclib_LexOthers.o: $(srcdir)/scintilla/src/LexOthers.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx +stclib_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx +stclib_LexPB.o: $(srcdir)/scintilla/src/LexPB.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPascal.o: $(srcdir)/scintilla/src/LexPascal.cxx +stclib_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexPerl.o: $(srcdir)/scintilla/src/LexPerl.cxx +stclib_LexPOV.o: $(srcdir)/scintilla/src/LexPOV.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + +stclib_LexPS.o: $(srcdir)/scintilla/src/LexPS.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx @@ -590,15 +648,21 @@ stclib_LexPython.o: $(srcdir)/scintilla/src/LexPython.cxx stclib_LexRuby.o: $(srcdir)/scintilla/src/LexRuby.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LexSQL.o: $(srcdir)/scintilla/src/LexSQL.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_LexScriptol.o: $(srcdir)/scintilla/src/LexScriptol.cxx +stclib_LexTeX.o: $(srcdir)/scintilla/src/LexTeX.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_LexVB.o: $(srcdir)/scintilla/src/LexVB.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< +stclib_LexYAML.o: $(srcdir)/scintilla/src/LexYAML.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< + stclib_LineMarker.o: $(srcdir)/scintilla/src/LineMarker.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< @@ -611,10 +675,10 @@ stclib_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stclib_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_Style.o: $(srcdir)/scintilla/src/Style.cxx +stclib_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< -stclib_StyleContext.o: $(srcdir)/scintilla/src/StyleContext.cxx +stclib_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $< stclib_UniConversion.o: $(srcdir)/scintilla/src/UniConversion.cxx diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index ceb50296a6..56205b99a4 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -855,7 +855,6 @@ public: virtual int GetSelection(); virtual int Find(const char *prefix); virtual void GetValue(int n, char *value, int len); - virtual void Sort(); virtual void RegisterImage(int type, const char *xpm_data); virtual void ClearRegisteredImages(); virtual void SetDoubleClickAction(CallBackAction, void *); @@ -1008,9 +1007,6 @@ void ListBoxImpl::GetValue(int n, char *value, int len) { value[len-1] = '\0'; } -void ListBoxImpl::Sort() { -} - void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1); diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 26e966cf36..eaa1600208 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -146,7 +146,6 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { ScintillaWX::~ScintillaWX() { - SetTicking(false); } //---------------------------------------------------------------------- @@ -165,6 +164,8 @@ void ScintillaWX::Initialise() { void ScintillaWX::Finalise() { ScintillaBase::Finalise(); + SetTicking(false); + SetIdle(false); } @@ -199,6 +200,19 @@ void ScintillaWX::StartDrag() { } +bool ScintillaWX::SetIdle(bool on) { + if (idler.state != on) { + // connect or disconnect the EVT_IDLE handler + if (on) + stc->Connect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle); + else + stc->Disconnect(-1, wxEVT_IDLE, (wxObjectEventFunction)&wxStyledTextCtrl::OnIdle); + idler.state = on; + } + return idler.state; +} + + void ScintillaWX::SetTicking(bool on) { wxSTCTimer* steTimer; if (timer.ticking != on) { @@ -219,11 +233,13 @@ void ScintillaWX::SetTicking(bool on) { void ScintillaWX::SetMouseCapture(bool on) { - if (on && !capturedMouse) - stc->CaptureMouse(); - else if (!on && capturedMouse && stc->HasCapture()) - stc->ReleaseMouse(); - capturedMouse = on; + if (mouseDownCaptures) { + if (on && !capturedMouse) + stc->CaptureMouse(); + else if (!on && capturedMouse && stc->HasCapture()) + stc->ReleaseMouse(); + capturedMouse = on; + } } @@ -652,7 +668,7 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { // Set the current position to the mouse click point and // then paste in the PRIMARY selection, if any. wxGTK only. int newPos = PositionFromLocation(pt); - MovePositionTo(newPos, 0, 1); + MovePositionTo(newPos, noSel, true); pdoc->BeginUndoAction(); wxTextDataObject data; @@ -775,6 +791,15 @@ void ScintillaWX::DoOnListBox() { AutoCompleteCompleted(); } + +void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { + + if ( Idle() ) + evt.RequestMore(); + else + SetIdle(false); +} + //---------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index 799e58ed5a..1316c6661d 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -99,6 +99,7 @@ public: virtual void Initialise(); virtual void Finalise(); virtual void StartDrag(); + virtual bool SetIdle(bool on); virtual void SetTicking(bool on); virtual void SetMouseCapture(bool on); virtual bool HaveMouseCapture(); @@ -142,7 +143,8 @@ public: void DoAddChar(int key); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed); void DoTick() { Tick(); } - + void DoOnIdle(wxIdleEvent& evt); + #if wxUSE_DRAG_AND_DROP bool DoDropText(long x, long y, const wxString& data); wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index aa9432d377..070d4cbe90 100644 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -44,6 +44,7 @@ cmdValues = [ (2300, 2349), (2395, 2396), 2404, (2413, 2416), + (2426, 2442), (2450, 2454), ] @@ -275,6 +276,7 @@ methodOverrideMap = { 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0), 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0), 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0), + 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0), 'RegisterImage' : (0, @@ -330,14 +332,14 @@ methodOverrideMap = { int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect);''', ''' int %s(bool doDraw, int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; @@ -615,8 +617,23 @@ methodOverrideMap = { 'ParaDownExtend' : (None, 0, 0, 0), 'ParaUp' : (None, 0, 0, 0), 'ParaUpExtend' : (None, 0, 0, 0), - - + 'LineDownRectExtend' : (None, 0, 0, 0), + 'LineUpRectExtend' : (None, 0, 0, 0), + 'CharLeftRectExtend' : (None, 0, 0, 0), + 'CharRightRectExtend' : (None, 0, 0, 0), + 'HomeRectExtend' : (None, 0, 0, 0), + 'VCHomeRectExtend' : (None, 0, 0, 0), + 'LineEndRectExtend' : (None, 0, 0, 0), + 'PageUpRectExtend' : (None, 0, 0, 0), + 'PageDownRectExtend' : (None, 0, 0, 0), + 'StutteredPageUp' : (None, 0, 0, 0), + 'StutteredPageUpExtend' : (None, 0, 0, 0), + 'StutteredPageDown' : (None, 0, 0, 0), + 'StutteredPageDownExtend' : (None, 0, 0, 0), + 'WordLeftEnd' : (None, 0, 0, 0), + 'WordLeftEndExtend' : (None, 0, 0, 0), + 'WordRightEnd' : (None, 0, 0, 0), + 'WordRightEndExtend' : (None, 0, 0, 0), '' : ('', 0, 0, 0), diff --git a/src/stc/scintilla/README.txt b/src/stc/scintilla/README.txt index 1960be5d3d..f8ebdb02a6 100644 --- a/src/stc/scintilla/README.txt +++ b/src/stc/scintilla/README.txt @@ -3,4 +3,4 @@ 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. -The current version of the Scintilla code is 1.54 +The current version of the Scintilla code is 1.58 diff --git a/src/stc/scintilla/include/Platform.h b/src/stc/scintilla/include/Platform.h index 4f7ba2357c..8764024168 100644 --- a/src/stc/scintilla/include/Platform.h +++ b/src/stc/scintilla/include/Platform.h @@ -58,6 +58,7 @@ typedef void *WindowID; typedef void *MenuID; typedef void *TickerID; typedef void *Function; +typedef void *IdlerID; /** * A geometric point class. @@ -408,7 +409,6 @@ public: virtual int GetSelection()=0; virtual int Find(const char *prefix)=0; virtual void GetValue(int n, char *value, int len)=0; - virtual void Sort()=0; virtual void RegisterImage(int type, const char *xpm_data)=0; virtual void ClearRegisteredImages()=0; virtual void SetDoubleClickAction(CallBackAction, void *)=0; diff --git a/src/stc/scintilla/include/PropSet.h b/src/stc/scintilla/include/PropSet.h index 20ac5f774a..62cd5da3a9 100644 --- a/src/stc/scintilla/include/PropSet.h +++ b/src/stc/scintilla/include/PropSet.h @@ -81,7 +81,7 @@ public: void SetFromAllocated(); bool InList(const char *s); const char *GetNearestWord(const char *wordStart, int searchLen = -1, - bool ignoreCase = false, SString wordCharacters=""); + bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1); char *GetNearestWords(const char *wordStart, int searchLen=-1, bool ignoreCase=false, char otherSeparator='\0'); }; diff --git a/src/stc/scintilla/include/SciLexer.h b/src/stc/scintilla/include/SciLexer.h index 34867542f9..44d5dcdcda 100644 --- a/src/stc/scintilla/include/SciLexer.h +++ b/src/stc/scintilla/include/SciLexer.h @@ -59,6 +59,16 @@ #define SCLEX_PS 42 #define SCLEX_NSIS 43 #define SCLEX_MMIXAL 44 +#define SCLEX_CLW 45 +#define SCLEX_CLWNOCASE 46 +#define SCLEX_LOT 47 +#define SCLEX_YAML 48 +#define SCLEX_TEX 49 +#define SCLEX_METAPOST 50 +#define SCLEX_POWERBASIC 51 +#define SCLEX_FORTH 52 +#define SCLEX_ERLANG 53 +#define SCLEX_OCTAVE 54 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -243,6 +253,10 @@ #define SCE_B_OPERATOR 6 #define SCE_B_IDENTIFIER 7 #define SCE_B_DATE 8 +#define SCE_B_STRINGEOL 9 +#define SCE_B_KEYWORD2 10 +#define SCE_B_KEYWORD3 11 +#define SCE_B_KEYWORD4 12 #define SCE_PROPS_DEFAULT 0 #define SCE_PROPS_COMMENT 1 #define SCE_PROPS_SECTION 2 @@ -290,6 +304,8 @@ #define SCE_ERR_PHP 14 #define SCE_ERR_ELF 15 #define SCE_ERR_IFC 16 +#define SCE_ERR_IFORT 17 +#define SCE_ERR_ABSF 18 #define SCE_BAT_DEFAULT 0 #define SCE_BAT_COMMENT 1 #define SCE_BAT_WORD 2 @@ -388,6 +404,18 @@ #define SCE_NNCRONTAB_STRING 8 #define SCE_NNCRONTAB_ENVIRONMENT 9 #define SCE_NNCRONTAB_IDENTIFIER 10 +#define SCE_FORTH_DEFAULT 0 +#define SCE_FORTH_COMMENT 1 +#define SCE_FORTH_COMMENT_ML 2 +#define SCE_FORTH_IDENTIFIER 3 +#define SCE_FORTH_CONTROL 4 +#define SCE_FORTH_KEYWORD 5 +#define SCE_FORTH_DEFWORD 6 +#define SCE_FORTH_PREWORD1 7 +#define SCE_FORTH_PREWORD2 8 +#define SCE_FORTH_NUMBER 9 +#define SCE_FORTH_STRING 10 +#define SCE_FORTH_LOCALE 11 #define SCE_MATLAB_DEFAULT 0 #define SCE_MATLAB_COMMENT 1 #define SCE_MATLAB_COMMAND 2 @@ -396,26 +424,23 @@ #define SCE_MATLAB_STRING 5 #define SCE_MATLAB_OPERATOR 6 #define SCE_MATLAB_IDENTIFIER 7 +#define SCE_MATLAB_DOUBLEQUOTESTRING 8 #define SCE_SCRIPTOL_DEFAULT 0 -#define SCE_SCRIPTOL_COMMENT 1 +#define SCE_SCRIPTOL_WHITE 1 #define SCE_SCRIPTOL_COMMENTLINE 2 -#define SCE_SCRIPTOL_COMMENTDOC 3 -#define SCE_SCRIPTOL_NUMBER 4 -#define SCE_SCRIPTOL_WORD 5 -#define SCE_SCRIPTOL_STRING 6 -#define SCE_SCRIPTOL_CHARACTER 7 -#define SCE_SCRIPTOL_UUID 8 -#define SCE_SCRIPTOL_PREPROCESSOR 9 -#define SCE_SCRIPTOL_OPERATOR 10 -#define SCE_SCRIPTOL_IDENTIFIER 11 -#define SCE_SCRIPTOL_STRINGEOL 12 -#define SCE_SCRIPTOL_VERBATIM 13 -#define SCE_SCRIPTOL_REGEX 14 -#define SCE_SCRIPTOL_COMMENTLINEDOC 15 -#define SCE_SCRIPTOL_WORD2 16 -#define SCE_SCRIPTOL_COMMENTDOCKEYWORD 17 -#define SCE_SCRIPTOL_COMMENTDOCKEYWORDERROR 18 -#define SCE_SCRIPTOL_COMMENTBASIC 19 +#define SCE_SCRIPTOL_PERSISTENT 3 +#define SCE_SCRIPTOL_CSTYLE 4 +#define SCE_SCRIPTOL_COMMENTBLOCK 5 +#define SCE_SCRIPTOL_NUMBER 6 +#define SCE_SCRIPTOL_STRING 7 +#define SCE_SCRIPTOL_CHARACTER 8 +#define SCE_SCRIPTOL_STRINGEOL 9 +#define SCE_SCRIPTOL_KEYWORD 10 +#define SCE_SCRIPTOL_OPERATOR 11 +#define SCE_SCRIPTOL_IDENTIFIER 12 +#define SCE_SCRIPTOL_TRIPLE 13 +#define SCE_SCRIPTOL_CLASSNAME 14 +#define SCE_SCRIPTOL_PREPROCESSOR 15 #define SCE_ASM_DEFAULT 0 #define SCE_ASM_COMMENT 1 #define SCE_ASM_NUMBER 2 @@ -427,6 +452,10 @@ #define SCE_ASM_REGISTER 8 #define SCE_ASM_DIRECTIVE 9 #define SCE_ASM_DIRECTIVEOPERAND 10 +#define SCE_ASM_COMMENTBLOCK 11 +#define SCE_ASM_CHARACTER 12 +#define SCE_ASM_STRINGEOL 13 +#define SCE_ASM_EXTINSTRUCTION 14 #define SCE_F_DEFAULT 0 #define SCE_F_COMMENT 1 #define SCE_F_NUMBER 2 @@ -545,6 +574,65 @@ #define SCE_MMIXAL_OPERATOR 15 #define SCE_MMIXAL_SYMBOL 16 #define SCE_MMIXAL_INCLUDE 17 +#define SCE_CLW_DEFAULT 0 +#define SCE_CLW_LABEL 1 +#define SCE_CLW_COMMENT 2 +#define SCE_CLW_STRING 3 +#define SCE_CLW_USER_IDENTIFIER 4 +#define SCE_CLW_INTEGER_CONSTANT 5 +#define SCE_CLW_REAL_CONSTANT 6 +#define SCE_CLW_PICTURE_STRING 7 +#define SCE_CLW_KEYWORD 8 +#define SCE_CLW_COMPILER_DIRECTIVE 9 +#define SCE_CLW_BUILTIN_PROCEDURES_FUNCTION 10 +#define SCE_CLW_STRUCTURE_DATA_TYPE 11 +#define SCE_CLW_ATTRIBUTE 12 +#define SCE_CLW_STANDARD_EQUATE 13 +#define SCE_CLW_ERROR 14 +#define SCE_LOT_DEFAULT 0 +#define SCE_LOT_HEADER 1 +#define SCE_LOT_BREAK 2 +#define SCE_LOT_SET 3 +#define SCE_LOT_PASS 4 +#define SCE_LOT_FAIL 5 +#define SCE_LOT_ABORT 6 +#define SCE_YAML_DEFAULT 0 +#define SCE_YAML_COMMENT 1 +#define SCE_YAML_IDENTIFIER 2 +#define SCE_YAML_KEYWORD 3 +#define SCE_YAML_NUMBER 4 +#define SCE_YAML_REFERENCE 5 +#define SCE_YAML_DOCUMENT 6 +#define SCE_YAML_TEXT 7 +#define SCE_YAML_ERROR 8 +#define SCE_TEX_DEFAULT 0 +#define SCE_TEX_SPECIAL 1 +#define SCE_TEX_GROUP 2 +#define SCE_TEX_SYMBOL 3 +#define SCE_TEX_COMMAND 4 +#define SCE_TEX_TEXT 5 +#define SCE_METAPOST_DEFAULT 0 +#define SCE_METAPOST_SPECIAL 1 +#define SCE_METAPOST_GROUP 2 +#define SCE_METAPOST_SYMBOL 3 +#define SCE_METAPOST_COMMAND 4 +#define SCE_METAPOST_TEXT 5 +#define SCE_METAPOST_EXTRA 6 +#define SCE_ERLANG_DEFAULT 0 +#define SCE_ERLANG_COMMENT 1 +#define SCE_ERLANG_VARIABLE 2 +#define SCE_ERLANG_NUMBER 3 +#define SCE_ERLANG_KEYWORD 4 +#define SCE_ERLANG_STRING 5 +#define SCE_ERLANG_OPERATOR 6 +#define SCE_ERLANG_ATOM 7 +#define SCE_ERLANG_FUNCTION_NAME 8 +#define SCE_ERLANG_CHARACTER 9 +#define SCE_ERLANG_MACRO 10 +#define SCE_ERLANG_RECORD 11 +#define SCE_ERLANG_SEPARATOR 12 +#define SCE_ERLANG_NODE_NAME 13 +#define SCE_ERLANG_UNKNOWN 31 //--Autogenerated -- end of section automatically generated from Scintilla.iface #endif diff --git a/src/stc/scintilla/include/Scintilla.h b/src/stc/scintilla/include/Scintilla.h index 34893c8938..68c5427b61 100644 --- a/src/stc/scintilla/include/Scintilla.h +++ b/src/stc/scintilla/include/Scintilla.h @@ -205,6 +205,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_DIAGONAL 3 #define INDIC_STRIKE 4 #define INDIC_HIDDEN 5 +#define INDIC_BOX 6 #define INDIC0_MASK 0x20 #define INDIC1_MASK 0x40 #define INDIC2_MASK 0x80 @@ -533,6 +534,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETHOTSPOTACTIVEFORE 2410 #define SCI_SETHOTSPOTACTIVEBACK 2411 #define SCI_SETHOTSPOTACTIVEUNDERLINE 2412 +#define SCI_SETHOTSPOTSINGLELINE 2421 #define SCI_PARADOWN 2413 #define SCI_PARADOWNEXTEND 2414 #define SCI_PARAUP 2415 @@ -541,6 +543,33 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_POSITIONAFTER 2418 #define SCI_COPYRANGE 2419 #define SCI_COPYTEXT 2420 +#define SC_SEL_STREAM 0 +#define SC_SEL_RECTANGLE 1 +#define SC_SEL_LINES 2 +#define SCI_SETSELECTIONMODE 2422 +#define SCI_GETSELECTIONMODE 2423 +#define SCI_GETLINESELSTARTPOSITION 2424 +#define SCI_GETLINESELENDPOSITION 2425 +#define SCI_LINEDOWNRECTEXTEND 2426 +#define SCI_LINEUPRECTEXTEND 2427 +#define SCI_CHARLEFTRECTEXTEND 2428 +#define SCI_CHARRIGHTRECTEXTEND 2429 +#define SCI_HOMERECTEXTEND 2430 +#define SCI_VCHOMERECTEXTEND 2431 +#define SCI_LINEENDRECTEXTEND 2432 +#define SCI_PAGEUPRECTEXTEND 2433 +#define SCI_PAGEDOWNRECTEXTEND 2434 +#define SCI_STUTTEREDPAGEUP 2435 +#define SCI_STUTTEREDPAGEUPEXTEND 2436 +#define SCI_STUTTEREDPAGEDOWN 2437 +#define SCI_STUTTEREDPAGEDOWNEXTEND 2438 +#define SCI_WORDLEFTEND 2439 +#define SCI_WORDLEFTENDEXTEND 2440 +#define SCI_WORDRIGHTEND 2441 +#define SCI_WORDRIGHTENDEXTEND 2442 +#define SCI_SETWHITESPACECHARS 2443 +#define SCI_SETCHARSDEFAULT 2444 +#define SCI_AUTOCGETCURRENT 2445 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/src/stc/scintilla/include/Scintilla.iface b/src/stc/scintilla/include/Scintilla.iface index 9ca4ad539a..06ff4e5800 100644 --- a/src/stc/scintilla/include/Scintilla.iface +++ b/src/stc/scintilla/include/Scintilla.iface @@ -2,7 +2,7 @@ ## This file defines the interface to Scintilla -## Copyright 2000-2002 by Neil Hodgson +## Copyright 2000-2003 by Neil Hodgson ## The License.txt file describes the conditions under which this software may be distributed. ## A line starting with ## is a pure comment and should be stripped by readers. @@ -26,7 +26,8 @@ ## A property may be subscripted, in which case the first parameter is the subscript. ## fun, get, and set features have a strict syntax: ## [=,) -## param is [=] +## where stands for white space. +## param may be empty (null value) or is [=] ## Additional white space is allowed between elements. ## The syntax for evt is [=[,]*]) ## Feature names that contain an underscore are defined by Windows, so in these @@ -80,7 +81,7 @@ cat Basics ################################################ ## For Scintilla.h val INVALID_POSITION=-1 -# Define start of Scintilla messages to be greater than all edit (EM_*) messages +# Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages # as many EM_ messages can be used although that use is deprecated. val SCI_START=2000 val SCI_OPTIONAL_START=3000 @@ -131,7 +132,7 @@ fun void SelectAll=2013(,) fun void SetSavePoint=2014(,) # Retrieve a buffer of cells. -# Returns the number of bytes in the buffer not including terminating nulls. +# Returns the number of bytes in the buffer not including terminating NULs. fun int GetStyledText=2015(, textrange tr) # Are there any redoable actions in the undo history? @@ -159,11 +160,11 @@ get int GetViewWS=2020(,) set void SetViewWS=2021(int viewWS,) # Find the position from a point within the window. -fun int PositionFromPoint=2022(int x, int y) +fun position PositionFromPoint=2022(int x, int y) # Find the position from a point within the window but return # INVALID_POSITION if not close to text. -fun int PositionFromPointClose=2023(int x, int y) +fun position PositionFromPointClose=2023(int x, int y) # Set caret to start of a line and ensure it is visible. fun void GotoLine=2024(int line,) @@ -427,7 +428,7 @@ set void SetCaretFore=2069(colour fore,) # When key+modifier combination km is pressed perform msg. fun void AssignCmdKey=2070(keymod km, int msg) -# When key+modifier combination km do nothing. +# When key+modifier combination km is pressed do nothing. fun void ClearCmdKey=2071(keymod km,) # Drop all key mappings. @@ -446,6 +447,7 @@ get int GetCaretPeriod=2075(,) set void SetCaretPeriod=2076(int periodMilliseconds,) # Set the set of characters making up words for when moving or selecting by word. +# First sets deaults like SetCharsDefault. set void SetWordChars=2077(, string characters) # Start a sequence of actions that is undone and redone as a unit. @@ -463,6 +465,7 @@ val INDIC_TT=2 val INDIC_DIAGONAL=3 val INDIC_STRIKE=4 val INDIC_HIDDEN=5 +val INDIC_BOX=6 val INDIC0_MASK=0x20 val INDIC1_MASK=0x40 val INDIC2_MASK=0x80 @@ -711,7 +714,7 @@ val SCFIND_POSIX=0x00400000 fun position FindText=2150(int flags, findtext ft) # On Windows, will draw the document into a display context such as a printer. -fun void FormatRange=2151(bool draw, formatrange fr) +fun position FormatRange=2151(bool draw, formatrange fr) # Retrieve the display line at the top of the display. get int GetFirstVisibleLine=2152(,) @@ -743,7 +746,7 @@ fun void SetSel=2160(position start, position end) # Retrieve the selected text. # Return the length of the text. -fun int GetSelText=2161(,stringresult text) +fun int GetSelText=2161(, stringresult text) # Retrieve a range of text. # Return the length of the text. @@ -762,7 +765,7 @@ fun int PointYFromPosition=2165(, position pos) fun int LineFromPosition=2166(position pos,) # Retrieve the position at the start of a line. -fun int PositionFromLine=2167(int line,) +fun position PositionFromLine=2167(int line,) # Scroll horizontally and vertically. fun void LineScroll=2168(int columns, int lines) @@ -847,12 +850,12 @@ set void SetTargetEnd=2192(position pos,) get position GetTargetEnd=2193(,) # Replace the target text with the argument text. -# Text is counted so it can contain nulls. +# Text is counted so it can contain NULs. # 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. +# Text is counted so it can contain NULs. # 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 @@ -860,7 +863,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 -# range. Text is counted so it can contain nulls. +# range. Text is counted so it can contain NULs. # Returns length of range or -1 for failure in which case target is not moved. fun int SearchInTarget=2197(int length, string text) @@ -1015,7 +1018,7 @@ set void SetScrollWidth=2274(int pixelWidth,) get int GetScrollWidth=2275(,) # Measure the pixel width of some text in a particular style. -# Nul terminated text argument. +# NUL terminated text argument. # Does not handle tab or control characters. fun int TextWidth=2276(int style, string text) @@ -1223,7 +1226,7 @@ fun void LineEndDisplayExtend=2348(,) # except they behave differently when word-wrap is enabled: # They go first to the start / end of the display line, like (Home|LineEnd)Display # The difference is that, the cursor is already at the point, it goes on to the start -# or end of the document line, as appropriate for (Home|LineEnd|VCHome)Extend. +# or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. fun void HomeWrap=2349(,) fun void HomeWrapExtend=2450(,) @@ -1260,7 +1263,7 @@ set void SetViewEOL=2356(bool visible,) get int GetDocPointer=2357(,) # Change the document object used. -set void SetDocPointer=2358(,int pointer) +set void SetDocPointer=2358(, int pointer) # Set which document modification events are sent to the container. set void SetModEventMask=2359(int mask,) @@ -1385,7 +1388,7 @@ fun void DelLineRight=2396(,) set void SetXOffset=2397(int newOffset,) get int GetXOffset=2398(,) -# Set the last x chosen value to be the caret x position +# Set the last x chosen value to be the caret x position. fun void ChooseCaretX=2399(,) # Set the focus to this Scintilla widget. @@ -1427,7 +1430,7 @@ fun void SetYCaretPolicy=2403(int caretPolicy, int caretSlop) # Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). set void SetPrintWrapMode=2406(int mode,) -# Is printing line wrapped. +# Is printing line wrapped? get int GetPrintWrapMode=2407(,) # Set a fore colour for active hotspots. @@ -1439,7 +1442,10 @@ set void SetHotspotActiveBack=2411(bool useSetting, colour back) # Enable / Disable underlining active hotspots. set void SetHotspotActiveUnderline=2412(bool underline,) -# Move caret between paragraphs (delimited by empty lines) +# Limit hotspots to single line so hotspots on two lines don't merge. +set void SetHotspotSingleLine=2421(bool singleLine,) + +# Move caret between paragraphs (delimited by empty lines). fun void ParaDown=2413(,) fun void ParaDownExtend=2414(,) fun void ParaUp=2415(,) @@ -1459,6 +1465,91 @@ fun void CopyRange=2419(position start, position end) # Copy argument text to the clipboard. fun void CopyText=2420(int length, string text) +# Selection modes +enu SelectionMode=SC_SEL_ +val SC_SEL_STREAM=0 +val SC_SEL_RECTANGLE=1 +val SC_SEL_LINES=2 + +# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +# by lines (SC_SEL_LINES). +set void SetSelectionMode=2422(int mode,) + +# Get the mode of the current selection. +get int GetSelectionMode=2423(,) + +# Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelStartPosition=2424(int line,) + +# Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelEndPosition=2425(int line,) + +## RectExtended rectangular selection moves +# Move caret down one line, extending rectangular selection to new caret position. +fun void LineDownRectExtend=2426(,) + +# Move caret up one line, extending rectangular selection to new caret position. +fun void LineUpRectExtend=2427(,) + +# Move caret left one character, extending rectangular selection to new caret position. +fun void CharLeftRectExtend=2428(,) + +# Move caret right one character, extending rectangular selection to new caret position. +fun void CharRightRectExtend=2429(,) + +# Move caret to first position on line, extending rectangular selection to new caret position. +fun void HomeRectExtend=2430(,) + +# Move caret to before first visible character on line. +# If already there move to first character on line. +# In either case, extend rectangular selection to new caret position. +fun void VCHomeRectExtend=2431(,) + +# Move caret to last position on line, extending rectangular selection to new caret position. +fun void LineEndRectExtend=2432(,) + +# Move caret one page up, extending rectangular selection to new caret position. +fun void PageUpRectExtend=2433(,) + +# Move caret one page down, extending rectangular selection to new caret position. +fun void PageDownRectExtend=2434(,) + + +# Move caret to top of page, or one page up if already at top of page. +fun void StutteredPageUp=2435(,) + +# Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. +fun void StutteredPageUpExtend=2436(,) + +# Move caret to bottom of page, or one page down if already at bottom of page. +fun void StutteredPageDown=2437(,) + +# Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. +fun void StutteredPageDownExtend=2438(,) + + +# Move caret left one word, position cursor at end of word. +fun void WordLeftEnd=2439(,) + +# Move caret left one word, position cursor at end of word, extending selection to new caret position. +fun void WordLeftEndExtend=2440(,) + +# Move caret right one word, position cursor at end of word. +fun void WordRightEnd=2441(,) + +# Move caret right one word, position cursor at end of word, extending selection to new caret position. +fun void WordRightEndExtend=2442(,) + +# Set the set of characters making up whitespace for when moving or selecting by word. +# Should be called after SetWordChars. +set void SetWhitespaceChars=2443(, string characters) + +# Reset the set of characters for whitespace and word characters to the defaults. +fun void SetCharsDefault=2444(,) + +# Get currently selected item position in the auto-completion list +fun int AutoCGetCurrent=2445(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) @@ -1486,7 +1577,7 @@ set void SetKeyWords=4005(int keywordSet, string keyWords) # Set the lexing language of the document based on string name. set void SetLexerLanguage=4006(, string language) -# Load a lexer library (dll / so) +# Load a lexer library (dll / so). fun void LoadLexerLibrary=4007(, string path) # Notifications @@ -1591,6 +1682,16 @@ val SCLEX_ESCRIPT=41 val SCLEX_PS=42 val SCLEX_NSIS=43 val SCLEX_MMIXAL=44 +val SCLEX_CLW=45 +val SCLEX_CLWNOCASE=46 +val SCLEX_LOT=47 +val SCLEX_YAML=48 +val SCLEX_TEX=49 +val SCLEX_METAPOST=50 +val SCLEX_POWERBASIC=51 +val SCLEX_FORTH=52 +val SCLEX_ERLANG=53 +val SCLEX_OCTAVE=54 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -1796,9 +1897,10 @@ val SCE_PL_STRING_QQ=27 val SCE_PL_STRING_QX=28 val SCE_PL_STRING_QR=29 val SCE_PL_STRING_QW=30 -# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT +# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC lex VB=SCLEX_VB SCE_B_ lex VBScript=SCLEX_VBSCRIPT SCE_B_ +lex PowerBasic=SCLEX_POWERBASIC SCE_B_ val SCE_B_DEFAULT=0 val SCE_B_COMMENT=1 val SCE_B_NUMBER=2 @@ -1808,6 +1910,10 @@ val SCE_B_PREPROCESSOR=5 val SCE_B_OPERATOR=6 val SCE_B_IDENTIFIER=7 val SCE_B_DATE=8 +val SCE_B_STRINGEOL=9 +val SCE_B_KEYWORD2=10 +val SCE_B_KEYWORD3=11 +val SCE_B_KEYWORD4=12 # Lexical states for SCLEX_PROPERTIES lex Properties=SCLEX_PROPERTIES SCE_PROPS_ val SCE_PROPS_DEFAULT=0 @@ -1863,6 +1969,8 @@ val SCE_ERR_DIFF_MESSAGE=13 val SCE_ERR_PHP=14 val SCE_ERR_ELF=15 val SCE_ERR_IFC=16 +val SCE_ERR_IFORT=17 +val SCE_ERR_ABSF=18 # Lexical states for SCLEX_BATCH lex Batch=SCLEX_BATCH SCE_BAT_ val SCE_BAT_DEFAULT=0 @@ -1982,6 +2090,20 @@ val SCE_NNCRONTAB_NUMBER=7 val SCE_NNCRONTAB_STRING=8 val SCE_NNCRONTAB_ENVIRONMENT=9 val SCE_NNCRONTAB_IDENTIFIER=10 +# Lexical states for SCLEX_FORTH (Forth Lexer) +lex Forth=SCLEX_FORTH SCE_FORTH_ +val SCE_FORTH_DEFAULT=0 +val SCE_FORTH_COMMENT=1 +val SCE_FORTH_COMMENT_ML=2 +val SCE_FORTH_IDENTIFIER=3 +val SCE_FORTH_CONTROL=4 +val SCE_FORTH_KEYWORD=5 +val SCE_FORTH_DEFWORD=6 +val SCE_FORTH_PREWORD1=7 +val SCE_FORTH_PREWORD2=8 +val SCE_FORTH_NUMBER=9 +val SCE_FORTH_STRING=10 +val SCE_FORTH_LOCALE=11 # Lexical states for SCLEX_MATLAB lex MatLab=SCLEX_MATLAB SCE_MATLAB_ val SCE_MATLAB_DEFAULT=0 @@ -1989,31 +2111,29 @@ val SCE_MATLAB_COMMENT=1 val SCE_MATLAB_COMMAND=2 val SCE_MATLAB_NUMBER=3 val SCE_MATLAB_KEYWORD=4 +# single quoted string val SCE_MATLAB_STRING=5 val SCE_MATLAB_OPERATOR=6 val SCE_MATLAB_IDENTIFIER=7 +val SCE_MATLAB_DOUBLEQUOTESTRING=8 # Lexical states for SCLEX_SCRIPTOL lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_ val SCE_SCRIPTOL_DEFAULT=0 -val SCE_SCRIPTOL_COMMENT=1 +val SCE_SCRIPTOL_WHITE=1 val SCE_SCRIPTOL_COMMENTLINE=2 -val SCE_SCRIPTOL_COMMENTDOC=3 -val SCE_SCRIPTOL_NUMBER=4 -val SCE_SCRIPTOL_WORD=5 -val SCE_SCRIPTOL_STRING=6 -val SCE_SCRIPTOL_CHARACTER=7 -val SCE_SCRIPTOL_UUID=8 -val SCE_SCRIPTOL_PREPROCESSOR=9 -val SCE_SCRIPTOL_OPERATOR=10 -val SCE_SCRIPTOL_IDENTIFIER=11 -val SCE_SCRIPTOL_STRINGEOL=12 -val SCE_SCRIPTOL_VERBATIM=13 -val SCE_SCRIPTOL_REGEX=14 -val SCE_SCRIPTOL_COMMENTLINEDOC=15 -val SCE_SCRIPTOL_WORD2=16 -val SCE_SCRIPTOL_COMMENTDOCKEYWORD=17 -val SCE_SCRIPTOL_COMMENTDOCKEYWORDERROR=18 -val SCE_SCRIPTOL_COMMENTBASIC=19 +val SCE_SCRIPTOL_PERSISTENT=3 +val SCE_SCRIPTOL_CSTYLE=4 +val SCE_SCRIPTOL_COMMENTBLOCK=5 +val SCE_SCRIPTOL_NUMBER=6 +val SCE_SCRIPTOL_STRING=7 +val SCE_SCRIPTOL_CHARACTER=8 +val SCE_SCRIPTOL_STRINGEOL=9 +val SCE_SCRIPTOL_KEYWORD=10 +val SCE_SCRIPTOL_OPERATOR=11 +val SCE_SCRIPTOL_IDENTIFIER=12 +val SCE_SCRIPTOL_TRIPLE=13 +val SCE_SCRIPTOL_CLASSNAME=14 +val SCE_SCRIPTOL_PREPROCESSOR=15 # Lexical states for SCLEX_ASM lex Asm=SCLEX_ASM SCE_ASM_ val SCE_ASM_DEFAULT=0 @@ -2027,6 +2147,10 @@ val SCE_ASM_MATHINSTRUCTION=7 val SCE_ASM_REGISTER=8 val SCE_ASM_DIRECTIVE=9 val SCE_ASM_DIRECTIVEOPERAND=10 +val SCE_ASM_COMMENTBLOCK=11 +val SCE_ASM_CHARACTER=12 +val SCE_ASM_STRINGEOL=13 +val SCE_ASM_EXTINSTRUCTION=14 # Lexical states for SCLEX_FORTRAN lex Fortran=SCLEX_FORTRAN SCE_F_ lex F77=SCLEX_F77 SCE_F_ @@ -2162,6 +2286,78 @@ val SCE_MMIXAL_HEX=14 val SCE_MMIXAL_OPERATOR=15 val SCE_MMIXAL_SYMBOL=16 val SCE_MMIXAL_INCLUDE=17 +# Lexical states for SCLEX_CLW +lex Clarion=SCLEX_CLW SCE_CLW_ +val SCE_CLW_DEFAULT=0 +val SCE_CLW_LABEL=1 +val SCE_CLW_COMMENT=2 +val SCE_CLW_STRING=3 +val SCE_CLW_USER_IDENTIFIER=4 +val SCE_CLW_INTEGER_CONSTANT=5 +val SCE_CLW_REAL_CONSTANT=6 +val SCE_CLW_PICTURE_STRING=7 +val SCE_CLW_KEYWORD=8 +val SCE_CLW_COMPILER_DIRECTIVE=9 +val SCE_CLW_BUILTIN_PROCEDURES_FUNCTION=10 +val SCE_CLW_STRUCTURE_DATA_TYPE=11 +val SCE_CLW_ATTRIBUTE=12 +val SCE_CLW_STANDARD_EQUATE=13 +val SCE_CLW_ERROR=14 +# Lexical states for SCLEX_LOT +lex LOT=SCLEX_LOT SCE_LOT_ +val SCE_LOT_DEFAULT=0 +val SCE_LOT_HEADER=1 +val SCE_LOT_BREAK=2 +val SCE_LOT_SET=3 +val SCE_LOT_PASS=4 +val SCE_LOT_FAIL=5 +val SCE_LOT_ABORT=6 +# Lexical states for SCLEX_YAML +lex YAML=SCLEX_YAML SCE_YAML_ +val SCE_YAML_DEFAULT=0 +val SCE_YAML_COMMENT=1 +val SCE_YAML_IDENTIFIER=2 +val SCE_YAML_KEYWORD=3 +val SCE_YAML_NUMBER=4 +val SCE_YAML_REFERENCE=5 +val SCE_YAML_DOCUMENT=6 +val SCE_YAML_TEXT=7 +val SCE_YAML_ERROR=8 +# Lexical states for SCLEX_TEX +lex TeX=SCLEX_TEX SCE_TEX_ +val SCE_TEX_DEFAULT=0 +val SCE_TEX_SPECIAL=1 +val SCE_TEX_GROUP=2 +val SCE_TEX_SYMBOL=3 +val SCE_TEX_COMMAND=4 +val SCE_TEX_TEXT=5 +lex Metapost=SCLEX_METAPOST SCE_METAPOST_ +val SCE_METAPOST_DEFAULT=0 +val SCE_METAPOST_SPECIAL=1 +val SCE_METAPOST_GROUP=2 +val SCE_METAPOST_SYMBOL=3 +val SCE_METAPOST_COMMAND=4 +val SCE_METAPOST_TEXT=5 +val SCE_METAPOST_EXTRA=6 +# Lexical states for SCLEX_ERLANG +lex Erlang=SCLEX_ERLANG SCE_ERLANG_ +val SCE_ERLANG_DEFAULT=0 +val SCE_ERLANG_COMMENT=1 +val SCE_ERLANG_VARIABLE=2 +val SCE_ERLANG_NUMBER=3 +val SCE_ERLANG_KEYWORD=4 +val SCE_ERLANG_STRING=5 +val SCE_ERLANG_OPERATOR=6 +val SCE_ERLANG_ATOM=7 +val SCE_ERLANG_FUNCTION_NAME=8 +val SCE_ERLANG_CHARACTER=9 +val SCE_ERLANG_MACRO=10 +val SCE_ERLANG_RECORD=11 +val SCE_ERLANG_SEPARATOR=12 +val SCE_ERLANG_NODE_NAME=13 +val SCE_ERLANG_UNKNOWN=31 +# Lexical states for SCLEX_OCTAVE are identical to MatLab +lex Octave=SCLEX_OCTAVE SCE_MATLAB_ # Events diff --git a/src/stc/scintilla/src/CallTip.cxx b/src/stc/scintilla/src/CallTip.cxx index 314f9bfa71..2f299afffd 100644 --- a/src/stc/scintilla/src/CallTip.cxx +++ b/src/stc/scintilla/src/CallTip.cxx @@ -48,6 +48,10 @@ void CallTip::RefreshColourPalette(Palette &pal, bool want) { pal.WantFind(colourLight, want); } +static bool IsArrowCharacter(char ch) { + return (ch >= 0) && (ch <= '\002'); +} + void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw) { @@ -56,7 +60,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int maxEnd = 0; int ends[10]; for (int i=0;i 0) ends[maxEnd++] = i; ends[maxEnd++] = i+1; @@ -68,7 +72,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, for (int seg = 0; seg startSeg) { - if (s[startSeg] <= '\002') { + if (IsArrowCharacter(s[startSeg])) { xEnd = x + widthArrow; offsetMain = xEnd; if (draw) { diff --git a/src/stc/scintilla/src/ContractionState.cxx b/src/stc/scintilla/src/ContractionState.cxx index 5b36b2cadf..8833b07bc0 100644 --- a/src/stc/scintilla/src/ContractionState.cxx +++ b/src/stc/scintilla/src/ContractionState.cxx @@ -175,6 +175,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) { if (i != 0) // Line zero is always visible lines[i].visible = lines[i + lineCount].visible; lines[i].expanded = lines[i + lineCount].expanded; + lines[i].height = lines[i + lineCount].height; } linesInDoc -= lineCount; linesInDisplay += deltaDisplayed; diff --git a/src/stc/scintilla/src/Document.cxx b/src/stc/scintilla/src/Document.cxx index 487262f8ad..fb28144dd7 100644 --- a/src/stc/scintilla/src/Document.cxx +++ b/src/stc/scintilla/src/Document.cxx @@ -50,7 +50,7 @@ Document::Document() { stylingBits = 5; stylingBitsMask = 0x1F; stylingMask = 0; - SetWordChars(0); + SetDefaultCharClasses(); endStyled = 0; styleClock = 0; enteredCount = 0; @@ -761,7 +761,7 @@ int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) pos++; } - return pos; + return MovePositionOutsideChar(pos, delta); } /** @@ -791,6 +791,40 @@ int Document::NextWordStart(int pos, int delta) { return pos; } +/** + * Find the end of the next word in either a forward (delta >= 0) or backwards direction + * (delta < 0). + * This is looking for a transition between character classes although there is also some + * additional movement to transit white space. + * Used by cursor movement by word commands. + */ +int Document::NextWordEnd(int pos, int delta) { + if (delta < 0) { + if (pos > 0) { + charClassification ccStart = WordCharClass(cb.CharAt(pos-1)); + if (ccStart != ccSpace) { + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccStart) { + pos--; + } + } + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccSpace) { + pos--; + } + } + } else { + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccSpace) { + pos++; + } + if (pos < Length()) { + charClassification ccStart = WordCharClass(cb.CharAt(pos)); + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccStart) { + pos++; + } + } + } + return pos; +} + /** * Check that the character at the given position is a word or punctuation character and that * the previous character is of a different character class. @@ -1012,7 +1046,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, } } pos += increment; - if (dbcsCodePage) { + if (dbcsCodePage && (pos >= 0)) { // Ensure trying to match from start of character pos = MovePositionOutsideChar(pos, increment, false); } @@ -1032,10 +1066,24 @@ const char *Document::SubstituteByPosition(const char *text, int *length) { return 0; unsigned int lenResult = 0; for (int i = 0; i < *length; i++) { - if ((text[i] == '\\') && (text[i + 1] >= '1' && text[i + 1] <= '9')) { - unsigned int patNum = text[i + 1] - '0'; - lenResult += pre->eopat[patNum] - pre->bopat[patNum]; - i++; + if (text[i] == '\\') { + if (text[i + 1] >= '1' && text[i + 1] <= '9') { + unsigned int patNum = text[i + 1] - '0'; + lenResult += pre->eopat[patNum] - pre->bopat[patNum]; + i++; + } else { + switch (text[i + 1]) { + case 'a': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + i++; + } + lenResult++; + } } else { lenResult++; } @@ -1045,13 +1093,43 @@ const char *Document::SubstituteByPosition(const char *text, int *length) { return 0; char *o = substituted; for (int j = 0; j < *length; j++) { - if ((text[j] == '\\') && (text[j + 1] >= '1' && text[j + 1] <= '9')) { - unsigned int patNum = text[j + 1] - '0'; - unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; - if (pre->pat[patNum]) // Will be null if try for a match that did not occur - memcpy(o, pre->pat[patNum], len); - o += len; - j++; + if (text[j] == '\\') { + if (text[j + 1] >= '1' && text[j + 1] <= '9') { + unsigned int patNum = text[j + 1] - '0'; + unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; + if (pre->pat[patNum]) // Will be null if try for a match that did not occur + memcpy(o, pre->pat[patNum], len); + o += len; + j++; + } else { + j++; + switch (text[j]) { + case 'a': + *o++ = '\a'; + break; + case 'b': + *o++ = '\b'; + break; + case 'f': + *o++ = '\f'; + break; + case 'n': + *o++ = '\n'; + break; + case 'r': + *o++ = '\r'; + break; + case 't': + *o++ = '\t'; + break; + case 'v': + *o++ = '\v'; + break; + default: + *o++ = '\\'; + j--; + } + } } else { *o++ = text[j]; } @@ -1085,26 +1163,27 @@ void Document::ChangeCase(Range r, bool makeUpperCase) { } } -void Document::SetWordChars(unsigned char *chars) { - int ch; - for (ch = 0; ch < 256; ch++) { +void Document::SetDefaultCharClasses() { + // Initialize all char classes to default values + for (int ch = 0; ch < 256; ch++) { if (ch == '\r' || ch == '\n') charClass[ch] = ccNewLine; else if (ch < 0x20 || ch == ' ') charClass[ch] = ccSpace; + else if (ch >= 0x80 || isalnum(ch) || ch == '_') + charClass[ch] = ccWord; else charClass[ch] = ccPunctuation; } +} + +void Document::SetCharClasses(unsigned char *chars, charClassification newCharClass) { + // Apply the newCharClass to the specifed chars if (chars) { while (*chars) { - charClass[*chars] = ccWord; + charClass[*chars] = newCharClass; chars++; } - } else { - for (ch = 0; ch < 256; ch++) { - if (ch >= 0x80 || isalnum(ch) || ch == '_') - charClass[ch] = ccWord; - } } } @@ -1335,14 +1414,18 @@ int Document::WordPartRight(int pos) { return pos; } -int Document::ExtendStyleRange(int pos, int delta) { +bool IsLineEndChar(char c) { + return (c == '\n' || c == '\r'); +} + +int Document::ExtendStyleRange(int pos, int delta, bool singleLine) { int sStart = cb.StyleAt(pos); if (delta < 0) { - while (pos > 0 && (cb.StyleAt(pos) == sStart)) + while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos--; pos++; } else { - while (pos < (Length()) && (cb.StyleAt(pos) == sStart)) + while (pos < (Length()) && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos++; } return pos; diff --git a/src/stc/scintilla/src/Document.h b/src/stc/scintilla/src/Document.h index bcdbe00ca5..dc9e38e21d 100644 --- a/src/stc/scintilla/src/Document.h +++ b/src/stc/scintilla/src/Document.h @@ -87,11 +87,12 @@ public: userData = 0; } }; + + enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; private: int refCount; CellBuffer cb; - enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; charClassification charClass[256]; char stylingMask; int endStyled; @@ -190,6 +191,7 @@ public: void Indent(bool forwards); int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false); int NextWordStart(int pos, int delta); + int NextWordEnd(int pos, int delta); int Length() { return cb.Length(); } long FindText(int minPos, int maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length); @@ -198,8 +200,9 @@ public: int LinesTotal(); void ChangeCase(Range r, bool makeUpperCase); - - void SetWordChars(unsigned char *chars); + + void SetDefaultCharClasses(); + void SetCharClasses(unsigned char *chars, charClassification newCharClass); void SetStylingBits(int bits); void StartStyling(int position, char mask); bool SetStyleFor(int length, char style); @@ -220,7 +223,7 @@ public: bool IsWordPartSeparator(char ch); int WordPartLeft(int pos); int WordPartRight(int pos); - int ExtendStyleRange(int pos, int delta); + int ExtendStyleRange(int pos, int delta, bool singleLine = false); int ParaUp(int pos); int ParaDown(int pos); diff --git a/src/stc/scintilla/src/Editor.cxx b/src/stc/scintilla/src/Editor.cxx index df260ed512..f0f10e25a3 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -35,6 +35,9 @@ active(false), on(false), period(500) {} Timer::Timer() : ticking(false), ticksToWait(0), tickerID(0) {} +Idler::Idler() : +state(false), idlerID(0) {} + LineLayout::LineLayout(int maxLineLength_) : lineStarts(0), lenLineStarts(0), @@ -53,6 +56,8 @@ LineLayout::LineLayout(int maxLineLength_) : styles(0), indicators(0), positions(0), + hsStart(0), + hsEnd(0), widthLine(wrapWidthInfinite), lines(1) { Resize(maxLineLength_); @@ -316,6 +321,7 @@ Editor::Editor() { originalAnchorPos = 0; selType = selStream; + moveExtendsSelection = false; xStartSelect = 0; xEndSelect = 0; primarySelection = true; @@ -373,6 +379,8 @@ Editor::Editor() { wrapState = eWrapNone; wrapWidth = LineLayout::wrapWidthInfinite; docLineLastWrapped = -1; + docLastLineToWrap = -1; + backgroundWrapEnabled = true; hsStart = -1; hsEnd = -1; @@ -393,6 +401,7 @@ Editor::~Editor() { } void Editor::Finalise() { + SetIdle(false); CancelModes(); } @@ -408,6 +417,10 @@ void Editor::InvalidateStyleData() { palette.Release(); DropGraphics(); llc.Invalidate(LineLayout::llInvalid); + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); + } } void Editor::InvalidateStyleRedraw() { @@ -495,7 +508,9 @@ const char *ControlCharacterString(unsigned char ch) { } } -// Convenience class to ensure LineLayout objects are always disposed. +/** + * Convenience class to ensure LineLayout objects are always disposed. + */ class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; @@ -518,6 +533,84 @@ public: } }; +/** + * Allows to iterate through the lines of a selection. + * Althought it can be called for a stream selection, in most cases + * it is inefficient and it should be used only for + * a rectangular or a line selection. + */ +class SelectionLineIterator { +private: + Editor *ed; + int line; ///< Current line within the iteration. + bool forward; ///< True if iterating by increasing line number, false otherwise. + int selStart, selEnd; ///< Positions of the start and end of the selection relative to the start of the document. + int minX, maxX; ///< Left and right of selection rectangle. + +public: + int lineStart, lineEnd; ///< Line numbers, first and last lines of the selection. + int startPos, endPos; ///< Positions of the beginning and end of the selection on the current line. + + void Reset() { + if (forward) { + line = lineStart; + } else { + line = lineEnd; + } + } + + SelectionLineIterator(Editor *ed_, bool forward_ = true) : line(0), startPos(0), endPos(0) { + ed = ed_; + forward = forward_; + selStart = ed->SelectionStart(); + selEnd = ed->SelectionEnd(); + lineStart = ed->pdoc->LineFromPosition(selStart); + lineEnd = ed->pdoc->LineFromPosition(selEnd); + // Left of rectangle + minX = Platform::Minimum(ed->xStartSelect, ed->xEndSelect); + // Right of rectangle + maxX = Platform::Maximum(ed->xStartSelect, ed->xEndSelect); + Reset(); + } + ~SelectionLineIterator() {} + + void SetAt(int line) { + if (line < lineStart || line > lineEnd) { + startPos = endPos = INVALID_POSITION; + } else { + if (ed->selType == ed->selRectangle) { + // Measure line and return character closest to minX + startPos = ed->PositionFromLineX(line, minX); + // Measure line and return character closest to maxX + endPos = ed->PositionFromLineX(line, maxX); + } else if (ed->selType == ed->selLines) { + startPos = ed->pdoc->LineStart(line); + endPos = ed->pdoc->LineStart(line + 1); + } else { // Stream selection, here only for completion + if (line == lineStart) { + startPos = selStart; + } else { + startPos = ed->pdoc->LineStart(line); + } + if (line == lineEnd) { + endPos = selEnd; + } else { + endPos = ed->pdoc->LineStart(line + 1); + } + } + } + } + bool Iterate() { + SetAt(line); + if (forward) { + line++; + } else { + line--; + } + return startPos != INVALID_POSITION; + } +}; + Point Editor::LocationFromPosition(int pos) { Point pt; RefreshStyleData(); @@ -681,8 +774,10 @@ int Editor::PositionFromLineX(int lineDoc, int x) { return retVal; } -// If painting then abandon the painting because a wider redraw is needed. -// Return true if calling code should stop drawing +/** + * If painting then abandon the painting because a wider redraw is needed. + * @return true if calling code should stop drawing. + */ bool Editor::AbandonPaint() { if ((paintState == painting) && !paintingAllText) { paintState = paintAbandoned; @@ -765,63 +860,44 @@ bool Editor::SelectionEmpty() { return anchor == currentPos; } -int Editor::SelectionStart(int line) { - if ((line == -1) || (selType == selStream)) { - return Platform::Minimum(currentPos, anchor); - } else { // selType == selRectangle - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); - int lineStart = pdoc->LineFromPosition(selStart); - int lineEnd = pdoc->LineFromPosition(selEnd); - if (line < lineStart || line > lineEnd) { - return -1; - } else { - int minX = Platform::Minimum(xStartSelect, xEndSelect); - return PositionFromLineX(line, minX); - } - } +int Editor::SelectionStart() { + return Platform::Minimum(currentPos, anchor); } -int Editor::SelectionEnd(int line) { - if ((line == -1) || (selType == selStream)) { - return Platform::Maximum(currentPos, anchor); - } else { // selType == selRectangle - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); - int lineStart = pdoc->LineFromPosition(selStart); - int lineEnd = pdoc->LineFromPosition(selEnd); - if (line < lineStart || line > lineEnd) { - return -1; - } else { - int maxX = Platform::Maximum(xStartSelect, xEndSelect); - // measure line and return character closest to minx - return PositionFromLineX(line, maxX); - } - } +int Editor::SelectionEnd() { + return Platform::Maximum(currentPos, anchor); +} + +void Editor::InvalidateSelection(int currentPos_, int anchor_) { + int firstAffected = anchor; + if (firstAffected > currentPos) + firstAffected = currentPos; + if (firstAffected > anchor_) + firstAffected = anchor_; + if (firstAffected > currentPos_) + firstAffected = currentPos_; + int lastAffected = anchor; + if (lastAffected < currentPos) + lastAffected = currentPos; + if (lastAffected < anchor_) + lastAffected = anchor_; + if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted + lastAffected = (currentPos_ + 1); + needUpdateUI = true; + InvalidateRange(firstAffected, lastAffected); } void Editor::SetSelection(int currentPos_, int anchor_) { currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_); anchor_ = pdoc->ClampPositionIntoDocument(anchor_); if ((currentPos != currentPos_) || (anchor != anchor_)) { - int firstAffected = anchor; - if (firstAffected > currentPos) - firstAffected = currentPos; - if (firstAffected > anchor_) - firstAffected = anchor_; - if (firstAffected > currentPos_) - firstAffected = currentPos_; - int lastAffected = anchor; - if (lastAffected < currentPos) - lastAffected = currentPos; - if (lastAffected < anchor_) - lastAffected = anchor_; - if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted - lastAffected = (currentPos_ + 1); + InvalidateSelection(currentPos_, anchor_); currentPos = currentPos_; anchor = anchor_; - needUpdateUI = true; - InvalidateRange(firstAffected, lastAffected); + } + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); } ClaimSelection(); } @@ -829,25 +905,19 @@ void Editor::SetSelection(int currentPos_, int anchor_) { void Editor::SetSelection(int currentPos_) { currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_); if (currentPos != currentPos_) { - int firstAffected = anchor; - if (firstAffected > currentPos) - firstAffected = currentPos; - if (firstAffected > currentPos_) - firstAffected = currentPos_; - int lastAffected = anchor; - if (lastAffected < currentPos) - lastAffected = currentPos; - if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted - lastAffected = (currentPos_ + 1); + InvalidateSelection(currentPos_, currentPos_); currentPos = currentPos_; - needUpdateUI = true; - InvalidateRange(firstAffected, lastAffected); + } + if (selType == selRectangle) { + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); } ClaimSelection(); } void Editor::SetEmptySelection(int currentPos_) { selType = selStream; + moveExtendsSelection = false; SetSelection(currentPos_, currentPos_); } @@ -867,13 +937,27 @@ bool Editor::RangeContainsProtected(int start, int end) const { return false; } -bool Editor::SelectionContainsProtected() const { - // TODO: make support rectangular selection - return RangeContainsProtected(anchor, currentPos); +bool Editor::SelectionContainsProtected() { + // DONE, but untested...: make support rectangular selection + bool scp = false; + if (selType == selStream) { + scp = RangeContainsProtected(anchor, currentPos); + } else { + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + if (RangeContainsProtected(lineIterator.startPos, lineIterator.endPos)) { + scp = true; + break; + } + } + } + return scp; } +/** + * Asks document to find a good position and then moves out of any invisible positions. + */ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { - // Asks document to find a good position and then moves out of any invisible positions pos = pdoc->MovePositionOutsideChar(pos, moveDir, checkLineEnd); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; @@ -894,18 +978,22 @@ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { return pos; } -int Editor::MovePositionTo(int newPos, bool extend, bool ensureVisible) { +int Editor::MovePositionTo(int newPos, selTypes sel, bool ensureVisible) { int delta = newPos - currentPos; newPos = pdoc->ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); - if (extend) { + if (sel != noSel) { + selType = sel; + } + if (sel != noSel || moveExtendsSelection) { SetSelection(newPos); } else { SetEmptySelection(newPos); } ShowCaretAtCurrentPosition(); - if (ensureVisible) + if (ensureVisible) { EnsureCaretVisible(); + } NotifyMove(newPos); return 0; } @@ -929,7 +1017,10 @@ int Editor::MovePositionSoVisible(int pos, int moveDir) { } } -// Choose the x position that the caret will try to stick to as it is moves up and down +/** + * Choose the x position that the caret will try to stick to + * as it moves up and down. + */ void Editor::SetLastXChosen() { Point pt = LocationFromPosition(currentPos); lastXChosen = pt.x; @@ -976,12 +1067,12 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { if (pt.y < rcClient.top) { MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top)), - false, ensureVisible); + noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)), - false, ensureVisible); + noSel, ensureVisible); } } @@ -1032,7 +1123,7 @@ This way, we favour the displaying of useful information: the begining of lines, where most code reside, and the lines after the caret, eg. the body of a function. | | | | | -slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of +slop | strict | jumps | even | Caret can go to the margin | When reaching limitÝ(caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right @@ -1298,18 +1389,57 @@ void Editor::InvalidateCaret() { InvalidateRange(currentPos, currentPos + 1); } -void Editor::NeedWrapping(int docLineStartWrapping) { +void Editor::NeedWrapping(int docLineStartWrapping, int docLineEndWrapping) { + bool noWrap = (docLastLineToWrap == docLineLastWrapped); if (docLineLastWrapped > (docLineStartWrapping - 1)) { docLineLastWrapped = docLineStartWrapping - 1; if (docLineLastWrapped < -1) docLineLastWrapped = -1; llc.Invalidate(LineLayout::llPositions); } + if (noWrap) { + docLastLineToWrap = docLineEndWrapping; + } else if (docLastLineToWrap < docLineEndWrapping) { + docLastLineToWrap = docLineEndWrapping + 1; + } + if (docLastLineToWrap < -1) + docLastLineToWrap = -1; + if (docLastLineToWrap >= pdoc->LinesTotal()) + docLastLineToWrap = pdoc->LinesTotal()-1; + // Wrap lines during idle. + if (backgroundWrapEnabled && docLastLineToWrap != docLineLastWrapped ) { + SetIdle(true); + } } // Check if wrapping needed and perform any needed wrapping. +// fullwrap: if true, all lines which need wrapping will be done, +// in this single call. +// priorityWrapLineStart: If greater than zero, all lines starting from +// here to 100 lines past will be wrapped (even if there are +// more lines under wrapping process in idle). +// If it is neither fullwrap, nor priorityWrap, then 100 lines will be +// wrapped, if there are any wrapping going on in idle. (Generally this +// condition is called only from idler). // Return true if wrapping occurred. -bool Editor::WrapLines() { +bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { + // If there are any pending wraps, do them during idle if possible. + if (wrapState != eWrapNone) { + if (docLineLastWrapped < docLastLineToWrap) { + if (!(backgroundWrapEnabled && SetIdle(true))) { + // Background wrapping is disabled, or idle processing + // not supported. A full wrap is required. + fullWrap = true; + } + } + if (!fullWrap && priorityWrapLineStart >= 0 && + // .. and if the paint window is outside pending wraps + (((priorityWrapLineStart + 100) < docLineLastWrapped) || + (priorityWrapLineStart > docLastLineToWrap))) { + // No priority wrap pending + return false; + } + } int goodTopLine = topLine; bool wrapOccurred = false; if (docLineLastWrapped < pdoc->LinesTotal()) { @@ -1332,21 +1462,47 @@ bool Editor::WrapLines() { wrapWidth = rcTextArea.Width(); // Ensure all of the document is styled. pdoc->EnsureStyledTo(pdoc->Length()); + RefreshStyleData(); AutoSurface surface(this); if (surface) { - int lastLineToWrap = pdoc->LinesTotal(); - while (docLineLastWrapped <= lastLineToWrap) { - docLineLastWrapped++; - AutoLineLayout ll(llc, RetrieveLineLayout(docLineLastWrapped)); + bool priorityWrap = false; + int lastLineToWrap = docLastLineToWrap; + int firstLineToWrap = docLineLastWrapped; + if (!fullWrap) { + if (priorityWrapLineStart >= 0) { + // This is a priority wrap. + firstLineToWrap = priorityWrapLineStart; + lastLineToWrap = firstLineToWrap + 100; + priorityWrap = true; + } else { + // This is idle wrap. + lastLineToWrap = docLineLastWrapped + 100; + } + if (lastLineToWrap >= docLastLineToWrap) + lastLineToWrap = docLastLineToWrap; + } // else do a fullWrap. + + // printf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, firstLineToWrap, lastLineToWrap); + // printf("Pending wraps: %d to %d\n", docLineLastWrapped, docLastLineToWrap); + while (firstLineToWrap < lastLineToWrap) { + firstLineToWrap++; + if (!priorityWrap) + docLineLastWrapped++; + AutoLineLayout ll(llc, RetrieveLineLayout(firstLineToWrap)); int linesWrapped = 1; if (ll) { - LayoutLine(docLineLastWrapped, surface, vs, ll, wrapWidth); + LayoutLine(firstLineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } - if (cs.SetHeight(docLineLastWrapped, linesWrapped)) { + if (cs.SetHeight(firstLineToWrap, linesWrapped)) { wrapOccurred = true; } } + // If wrapping is done, bring it to resting position + if (docLineLastWrapped > docLastLineToWrap) { + docLineLastWrapped = -1; + docLastLineToWrap = -1; + } } goodTopLine = cs.DisplayFromDoc(lineDocTop); if (subLineTop < cs.GetHeight(lineDocTop)) @@ -1666,6 +1822,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; + PLATFORM_ASSERT(line < pdoc->LinesTotal()); int posLineStart = pdoc->LineStart(line); int posLineEnd = pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport @@ -1684,13 +1841,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou int numCharsInLine = 0; // See if chars, styles, indicators, are all the same bool allSame = true; - char styleByte; - int styleMask = pdoc->stylingBitsMask; + const int styleMask = pdoc->stylingBitsMask; // Check base line layout for (int charInDoc = posLineStart; allSame && (charInDoc < posLineEnd); charInDoc++) { char chDoc = pdoc->CharAt(charInDoc); - styleByte = pdoc->StyleAt(charInDoc); - if (vstyle.viewEOL || (!IsEOLChar(chDoc != '\r'))) { + if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { + char styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && (ll->styles[numCharsInLine] == static_cast(styleByte & styleMask)); allSame = allSame && @@ -1884,7 +2040,7 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun (i >= ll->edgeColumn) && !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour.allocated; - if (inHotspot) + if (inHotspot && vsDraw.hotspotBackgroundSet) return vsDraw.hotspotBackground.allocated; if (overrideBackground) return background; @@ -2220,20 +2376,26 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis for (int indica = 0; indica <= INDIC_MAX; indica++) indStart[indica] = 0; - for (int indicPos = 0; indicPos < ll->numCharsInLine; indicPos++) { - if (ll->indicators[indicPos] != ll->indicators[indicPos + 1]) { + for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { + if ((indicPos == lineEnd) || (ll->indicators[indicPos] != ll->indicators[indicPos + 1])) { int mask = 1 << pdoc->stylingBits; for (int indicnum = 0; mask < 0x100; indicnum++) { - if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) { + if ((indicPos == lineEnd)) { + indStart[indicnum] = ll->positions[indicPos]; + } else if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) { indStart[indicnum] = ll->positions[indicPos + 1]; } - if (!(ll->indicators[indicPos + 1] & mask) && (ll->indicators[indicPos] & mask)) { + if ((ll->indicators[indicPos] & mask) && + ((indicPos == lineEnd) || !(ll->indicators[indicPos + 1] & mask))) { + int endIndicator = indicPos; + if (endIndicator >= lineEnd) + endIndicator = lineEnd-1; PRectangle rcIndic( - indStart[indicnum] + xStart, - rcLine.top + vsDraw.maxAscent, - ll->positions[indicPos + 1] + xStart, - rcLine.top + vsDraw.maxAscent + 3); - vsDraw.indicators[indicnum].Draw(surface, rcIndic); + indStart[indicnum] + xStart - subLineStart, + rcLine.top + vsDraw.maxAscent, + ll->positions[endIndicator + 1] + xStart - subLineStart, + rcLine.top + vsDraw.maxAscent + 3); + vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); } mask = mask << 1; } @@ -2358,11 +2520,15 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { needUpdateUI = false; } - PaintSelMargin(surfaceWindow, rcArea); - - if (WrapLines()) { - // The wrapping process has changed the height of some lines so abandon this - // paint for a complete repaint. + // Call priority lines wrap on a window of lines which are likely + // to rendered with the following paint (that is wrap the visible + // lines first). + int startLineToWrap = cs.DocFromDisplay(topLine) - 5; + if (startLineToWrap < 0) + startLineToWrap = -1; + if (WrapLines(false, startLineToWrap)) { + // The wrapping process has changed the height of some lines so + // abandon this paint for a complete repaint. if (AbandonPaint()) { return; } @@ -2370,6 +2536,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } PLATFORM_ASSERT(pixmapSelPattern->Initialised()); + PaintSelMargin(surfaceWindow, rcArea); + PRectangle rcRightMargin = rcClient; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; if (rcArea.Intersects(rcRightMargin)) { @@ -2423,6 +2591,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //ElapsedTime etWhole; int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times AutoLineLayout ll(llc, 0); + SelectionLineIterator lineIterator(this); while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) { int lineDoc = cs.DocFromDisplay(visibleLine); @@ -2442,8 +2611,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //durLayout += et.Duration(true); if (ll) { - ll->selStart = SelectionStart(lineDoc); - ll->selEnd = SelectionEnd(lineDoc); + if (selType == selStream) { + ll->selStart = SelectionStart(); + ll->selEnd = SelectionEnd(); + } else { + lineIterator.SetAt(lineDoc); + ll->selStart = lineIterator.startPos; + ll->selEnd = lineIterator.endPos; + } ll->containsCaret = lineDoc == lineCaret; if (hideSelection) { ll->selStart = -1; @@ -2466,7 +2641,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); //durPaint += et.Duration(true); - // Restore the precvious styles for the brace highlights in case layout is in cache. + // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, braces); bool expanded = cs.GetExpanded(lineDoc); @@ -2917,31 +3092,28 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { void Editor::ClearSelection() { if (!SelectionContainsProtected()) { - if (selType == selRectangle) { + int startPos = SelectionStart(); + if (selType == selStream) { + unsigned int chars = SelectionEnd() - startPos; + if (0 != chars) { + pdoc->BeginUndoAction(); + pdoc->DeleteChars(startPos, chars); + pdoc->EndUndoAction(); + } + } else { pdoc->BeginUndoAction(); - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - int startPos = SelectionStart(); - for (int line = lineEnd; line >= lineStart; line--) { - startPos = SelectionStart(line); - unsigned int chars = SelectionEnd(line) - startPos; + SelectionLineIterator lineIterator(this, false); + while (lineIterator.Iterate()) { + startPos = lineIterator.startPos; + unsigned int chars = lineIterator.endPos - startPos; if (0 != chars) { pdoc->DeleteChars(startPos, chars); } } - SetEmptySelection(startPos); pdoc->EndUndoAction(); selType = selStream; - } else { - int startPos = SelectionStart(); - unsigned int chars = SelectionEnd() - startPos; - SetEmptySelection(startPos); - if (0 != chars) { - pdoc->BeginUndoAction(); - pdoc->DeleteChars(startPos, chars); - pdoc->EndUndoAction(); - } } + SetEmptySelection(startPos); } } @@ -3234,20 +3406,18 @@ void Editor::CheckModificationForWrap(DocModification mh) { llc.Invalidate(LineLayout::llCheckTextAndStyle); if (wrapState != eWrapNone) { int lineDoc = pdoc->LineFromPosition(mh.position); - if (mh.linesAdded == 0) { + if (mh.linesAdded <= 0) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); if (cs.GetHeight(lineDoc) != ll->lines) { - NeedWrapping(lineDoc - 1); + NeedWrapping(lineDoc - 1, lineDoc + 1); Redraw(); } - } else { - NeedWrapping(lineDoc); } } else { - NeedWrapping(lineDoc); + NeedWrapping(lineDoc, lineDoc + 1 + mh.linesAdded); } } } @@ -3281,7 +3451,6 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } - CheckModificationForWrap(mh); if (mh.modificationType & SC_MOD_CHANGESTYLE) { if (paintState == notPainting) { if (mh.position < pdoc->LineStart(topLine)) { @@ -3322,6 +3491,9 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { } else { cs.DeleteLines(lineOfPos, -mh.linesAdded); } + } + CheckModificationForWrap(mh); + if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine) { int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); @@ -3420,6 +3592,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: + case SCI_WORDLEFTEND: + case SCI_WORDLEFTENDEXTEND: + case SCI_WORDRIGHTEND: + case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: @@ -3432,6 +3608,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: + case SCI_STUTTEREDPAGEUP: + case SCI_STUTTEREDPAGEUPEXTEND: + case SCI_STUTTEREDPAGEDOWN: + case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: @@ -3464,10 +3644,20 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: - break; - - // Filter out all others like display changes. Also, newlines are redundant - // with char insert messages. + case SCI_SETSELECTIONMODE: + case SCI_LINEDOWNRECTEXTEND: + case SCI_LINEUPRECTEXTEND: + case SCI_CHARLEFTRECTEXTEND: + case SCI_CHARRIGHTRECTEXTEND: + case SCI_HOMERECTEXTEND: + case SCI_VCHOMERECTEXTEND: + case SCI_LINEENDRECTEXTEND: + case SCI_PAGEUPRECTEXTEND: + case SCI_PAGEDOWNRECTEXTEND: + break; + + // Filter out all others like display changes. Also, newlines are redundant + // with char insert messages. case SCI_NEWLINE: default: // printf("Filtered out %ld of macro recording\n", iMessage); @@ -3483,20 +3673,44 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long NotifyParent(scn); } -// Force scroll and keep position relative to top of window -void Editor::PageMove(int direction, bool extend) { - Point pt = LocationFromPosition(currentPos); - int topLineNew = Platform::Clamp( +/** + * Force scroll and keep position relative to top of window. + * + * If stuttered = true and not already at first/last row, move to first/last row of window. + * If stuttered = true and already at first/last row, scroll as normal. + */ +void Editor::PageMove(int direction, selTypes sel, bool stuttered) { + int topLineNew, newPos; + + // I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem? + int currentLine = pdoc->LineFromPosition(currentPos); + int topStutterLine = topLine + caretYSlop; + int bottomStutterLine = topLine + LinesToScroll() - caretYSlop; + + if (stuttered && (direction < 0 && currentLine > topStutterLine)) { + topLineNew = topLine; + newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * caretYSlop)); + + } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { + topLineNew = topLine; + newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * (LinesToScroll() - caretYSlop))); + + } else { + Point pt = LocationFromPosition(currentPos); + + topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); - int newPos = PositionFromLocation( + newPos = PositionFromLocation( Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll()))); + } + if (topLineNew != topLine) { SetTopLine(topLineNew); - MovePositionTo(newPos, extend); + MovePositionTo(newPos, sel); Redraw(); SetVerticalScrollPos(); } else { - MovePositionTo(newPos, extend); + MovePositionTo(newPos, sel); } } @@ -3504,21 +3718,19 @@ void Editor::ChangeCaseOfSelection(bool makeUpperCase) { pdoc->BeginUndoAction(); int startCurrent = currentPos; int startAnchor = anchor; - if (selType == selRectangle) { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - for (int line = lineEnd; line >= lineStart; line--) { + if (selType == selStream) { + pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), + makeUpperCase); + SetSelection(startCurrent, startAnchor); + } else { + SelectionLineIterator lineIterator(this, false); + while (lineIterator.Iterate()) { pdoc->ChangeCase( - Range(SelectionStart(line), SelectionEnd(line)), + Range(lineIterator.startPos, lineIterator.endPos), makeUpperCase); } // Would be nicer to keep the rectangular selection but this is complex - selType = selStream; - SetSelection(startCurrent, startCurrent); - } else { - pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), - makeUpperCase); - SetSelection(startCurrent, startAnchor); + SetEmptySelection(startCurrent); } pdoc->EndUndoAction(); } @@ -3566,7 +3778,9 @@ void Editor::LineDuplicate() { delete []thisLine; } -void Editor::CancelModes() {} +void Editor::CancelModes() { + moveExtendsSelection = false; +} void Editor::NewLine() { ClearSelection(); @@ -3587,7 +3801,7 @@ void Editor::NewLine() { EnsureCaretVisible(); } -void Editor::CursorUpOrDown(int direction, bool extend) { +void Editor::CursorUpOrDown(int direction, selTypes sel) { Point pt = LocationFromPosition(currentPos); int posNew = PositionFromLocation( Point(lastXChosen, pt.y + direction * vs.lineHeight)); @@ -3602,7 +3816,7 @@ void Editor::CursorUpOrDown(int direction, bool extend) { ptNew = LocationFromPosition(posNew); } } - MovePositionTo(posNew, extend); + MovePositionTo(posNew, sel); } int Editor::StartEndDisplayLine(int pos, bool start) { @@ -3643,13 +3857,16 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: - CursorUpOrDown(1, true); + CursorUpOrDown(1, selStream); + break; + case SCI_LINEDOWNRECTEXTEND: + CursorUpOrDown(1, selRectangle); break; case SCI_PARADOWN: MovePositionTo(pdoc->ParaDown(currentPos)); break; case SCI_PARADOWNEXTEND: - MovePositionTo(pdoc->ParaDown(currentPos), true); + MovePositionTo(pdoc->ParaDown(currentPos), selStream); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); @@ -3659,20 +3876,23 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: - CursorUpOrDown(-1, true); + CursorUpOrDown(-1, selStream); + break; + case SCI_LINEUPRECTEXTEND: + CursorUpOrDown(-1, selRectangle); break; case SCI_PARAUP: MovePositionTo(pdoc->ParaUp(currentPos)); break; case SCI_PARAUPEXTEND: - MovePositionTo(pdoc->ParaUp(currentPos), true); + MovePositionTo(pdoc->ParaUp(currentPos), selStream); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); break; case SCI_CHARLEFT: - if (SelectionEmpty()) { + if (SelectionEmpty() || moveExtendsSelection) { MovePositionTo(MovePositionSoVisible(currentPos - 1, -1)); } else { MovePositionTo(SelectionStart()); @@ -3680,11 +3900,15 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_CHARLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), true); + MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selStream); + SetLastXChosen(); + break; + case SCI_CHARLEFTRECTEXTEND: + MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selRectangle); SetLastXChosen(); break; case SCI_CHARRIGHT: - if (SelectionEmpty()) { + if (SelectionEmpty() || moveExtendsSelection) { MovePositionTo(MovePositionSoVisible(currentPos + 1, 1)); } else { MovePositionTo(SelectionEnd()); @@ -3692,7 +3916,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_CHARRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), true); + MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selStream); + SetLastXChosen(); + break; + case SCI_CHARRIGHTRECTEXTEND: + MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selRectangle); SetLastXChosen(); break; case SCI_WORDLEFT: @@ -3700,7 +3928,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1), true); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1), selStream); SetLastXChosen(); break; case SCI_WORDRIGHT: @@ -3708,15 +3936,37 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1), true); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1), selStream); + SetLastXChosen(); + break; + + case SCI_WORDLEFTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1)); + SetLastXChosen(); + break; + case SCI_WORDLEFTENDEXTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1), selStream); + SetLastXChosen(); + break; + case SCI_WORDRIGHTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1)); SetLastXChosen(); break; + case SCI_WORDRIGHTENDEXTEND: + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1), selStream); + SetLastXChosen(); + break; + case SCI_HOME: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos))); SetLastXChosen(); break; case SCI_HOMEEXTEND: - MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), true); + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selStream); + SetLastXChosen(); + break; + case SCI_HOMERECTEXTEND: + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selRectangle); SetLastXChosen(); break; case SCI_LINEEND: @@ -3724,7 +3974,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_LINEENDEXTEND: - MovePositionTo(pdoc->LineEndPosition(currentPos), true); + MovePositionTo(pdoc->LineEndPosition(currentPos), selStream); + SetLastXChosen(); + break; + case SCI_LINEENDRECTEXTEND: + MovePositionTo(pdoc->LineEndPosition(currentPos), selRectangle); SetLastXChosen(); break; case SCI_HOMEWRAP: { @@ -3739,7 +3993,7 @@ int Editor::KeyCommand(unsigned int iMessage) { int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); if (currentPos <= homePos) homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos)); - MovePositionTo(homePos, true); + MovePositionTo(homePos, selStream); SetLastXChosen(); } break; @@ -3755,7 +4009,7 @@ int Editor::KeyCommand(unsigned int iMessage) { int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1); if (currentPos >= endPos) endPos = pdoc->LineEndPosition(currentPos); - MovePositionTo(endPos, true); + MovePositionTo(endPos, selStream); SetLastXChosen(); } break; @@ -3764,7 +4018,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTSTARTEXTEND: - MovePositionTo(0, true); + MovePositionTo(0, selStream); SetLastXChosen(); break; case SCI_DOCUMENTEND: @@ -3772,20 +4026,38 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTENDEXTEND: - MovePositionTo(pdoc->Length(), true); + MovePositionTo(pdoc->Length(), selStream); SetLastXChosen(); break; + case SCI_STUTTEREDPAGEUP: + PageMove(-1, noSel, true); + break; + case SCI_STUTTEREDPAGEUPEXTEND: + PageMove(-1, selStream, true); + break; + case SCI_STUTTEREDPAGEDOWN: + PageMove(1, noSel, true); + break; + case SCI_STUTTEREDPAGEDOWNEXTEND: + PageMove(1, selStream, true); + break; case SCI_PAGEUP: PageMove(-1); break; case SCI_PAGEUPEXTEND: - PageMove(-1, true); + PageMove(-1, selStream); + break; + case SCI_PAGEUPRECTEXTEND: + PageMove(-1, selRectangle); break; case SCI_PAGEDOWN: PageMove(1); break; case SCI_PAGEDOWNEXTEND: - PageMove(1, true); + PageMove(1, selStream); + break; + case SCI_PAGEDOWNRECTEXTEND: + PageMove(1, selRectangle); break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; @@ -3828,7 +4100,11 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_VCHOMEEXTEND: - MovePositionTo(pdoc->VCHomePosition(currentPos), true); + MovePositionTo(pdoc->VCHomePosition(currentPos), selStream); + SetLastXChosen(); + break; + case SCI_VCHOMERECTEXTEND: + MovePositionTo(pdoc->VCHomePosition(currentPos), selRectangle); SetLastXChosen(); break; case SCI_VCHOMEWRAP: { @@ -3847,7 +4123,7 @@ int Editor::KeyCommand(unsigned int iMessage) { if ((viewLineStart < currentPos) && (viewLineStart > homePos)) homePos = viewLineStart; - MovePositionTo(homePos, true); + MovePositionTo(homePos, selStream); SetLastXChosen(); } break; @@ -3930,7 +4206,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDPARTLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1), true); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1), selStream); SetLastXChosen(); break; case SCI_WORDPARTRIGHT: @@ -3938,7 +4214,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_WORDPARTRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), true); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), selStream); SetLastXChosen(); break; case SCI_HOMEDISPLAY: @@ -3948,7 +4224,7 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1), true); + StartEndDisplayLine(currentPos, true), -1), selStream); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: @@ -3958,7 +4234,7 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1), true); + StartEndDisplayLine(currentPos, false), 1), selStream); SetLastXChosen(); break; } @@ -4073,9 +4349,9 @@ void Editor::Indent(bool forwards) { * @return The position of the found text, -1 if not found. */ long Editor::FindText( - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, - ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. - sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. + sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. TextToFind *ft = reinterpret_cast(lParam); int lengthFound = istrlen(ft->lpstrText); @@ -4114,9 +4390,9 @@ void Editor::SearchAnchor() { * @return The position of the found text, -1 if not found. */ long Editor::SearchText( - unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, - ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. + unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< The text to search for. const char *txt = reinterpret_cast(lParam); @@ -4205,36 +4481,45 @@ void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) { } void Editor::CopySelectionRange(SelectionText *ss) { - if (selType == selRectangle) { + if (selType == selStream) { + CopySelectionFromRange(ss, SelectionStart(), SelectionEnd()); + } else { char *text = 0; int size = 0; - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - int line; - for (line = lineStart; line <= lineEnd; line++) { - size += SelectionEnd(line) - SelectionStart(line) + 1; - if (pdoc->eolMode == SC_EOL_CRLF) + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + size += lineIterator.endPos - lineIterator.startPos; + if (selType != selLines) { size++; + if (pdoc->eolMode == SC_EOL_CRLF) { + size++; + } + } } if (size > 0) { text = new char[size + 1]; if (text) { int j = 0; - for (line = lineStart; line <= lineEnd; line++) { - for (int i = SelectionStart(line);i < SelectionEnd(line);i++) { + lineIterator.Reset(); + while (lineIterator.Iterate()) { + for (int i = lineIterator.startPos; + i < lineIterator.endPos; + i++) { text[j++] = pdoc->CharAt(i); } - if (pdoc->eolMode != SC_EOL_LF) - text[j++] = '\r'; - if (pdoc->eolMode != SC_EOL_CR) - text[j++] = '\n'; + if (selType != selLines) { + if (pdoc->eolMode != SC_EOL_LF) { + text[j++] = '\r'; + } + if (pdoc->eolMode != SC_EOL_CR) { + text[j++] = '\n'; + } + } } text[size] = '\0'; } } - ss->Set(text, size + 1, true); - } else { - CopySelectionFromRange(ss, SelectionStart(), SelectionEnd()); + ss->Set(text, size + 1, selType == selRectangle); } } @@ -4300,17 +4585,14 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul int positionAfterDeletion = position; if (inDragDrop && moving) { // Remove dragged out text - if (rectangular) { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); - for (int line = lineStart; line <= lineEnd; line++) { - int startPos = SelectionStart(line); - int endPos = SelectionEnd(line); - if (position >= startPos) { - if (position > endPos) { - positionAfterDeletion -= endPos - startPos; + if (rectangular || selType == selLines) { + SelectionLineIterator lineIterator(this); + while (lineIterator.Iterate()) { + if (position >= lineIterator.startPos) { + if (position > lineIterator.endPos) { + positionAfterDeletion -= lineIterator.endPos - lineIterator.startPos; } else { - positionAfterDeletion -= position - startPos; + positionAfterDeletion -= position - lineIterator.startPos; } } } @@ -4327,7 +4609,7 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul PasteRectangular(position, value, istrlen(value)); pdoc->EndUndoAction(); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position - SetSelection(position, position); + SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, currentPos - position); if (pdoc->InsertString(position, value)) { @@ -4336,53 +4618,65 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul pdoc->EndUndoAction(); } } else if (inDragDrop) { - SetSelection(position, position); + SetEmptySelection(position); } } -static int BeforeInOrAfter(int val, int minim, int maxim) { - if (val < minim) +/** + * @return -1 if given position is before the selection, + * 1 if position is after the selection, + * 0 if position is inside the selection, + */ +int Editor::PositionInSelection(int pos) { + pos = MovePositionOutsideChar(pos, currentPos - pos); + if (pos < SelectionStart()) { return -1; - else if (val > maxim) + } + if (pos > SelectionEnd()) { return 1; - else + } + if (selType == selStream) { return 0; -} - -int Editor::PositionInSelection(int pos) { - pos = MovePositionOutsideChar(pos, currentPos - pos); - if (selType == selRectangle) { - if (pos < SelectionStart()) + } else { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(pdoc->LineFromPosition(pos)); + if (pos < lineIterator.startPos) { return -1; - if (pos > SelectionEnd()) + } else if (pos > lineIterator.endPos) { return 1; - int linePos = pdoc->LineFromPosition(pos); - return BeforeInOrAfter(pos, SelectionStart(linePos), SelectionEnd(linePos)); - } else { - if (currentPos > anchor) { - return BeforeInOrAfter(pos, anchor, currentPos); - } else if (currentPos < anchor) { - return BeforeInOrAfter(pos, currentPos, anchor); + } else { + return 0; } } - return 1; } bool Editor::PointInSelection(Point pt) { - // TODO: fix up for rectangular selection int pos = PositionFromLocation(pt); if (0 == PositionInSelection(pos)) { - if (pos == SelectionStart()) { + // Probably inside, but we must make a finer test + int selStart, selEnd; + if (selType == selStream) { + selStart = SelectionStart(); + selEnd = SelectionEnd(); + } else { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(pdoc->LineFromPosition(pos)); + selStart = lineIterator.startPos; + selEnd = lineIterator.endPos; + } + if (pos == selStart) { // see if just before selection Point locStart = LocationFromPosition(pos); - if (pt.x < locStart.x) + if (pt.x < locStart.x) { return false; + } } - if (pos == SelectionEnd()) { + if (pos == selEnd) { // see if just after selection Point locEnd = LocationFromPosition(pos); - if (pt.x > locEnd.x) + if (pt.x > locEnd.x) { return false; + } } return true; } @@ -4430,6 +4724,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b int newPos = PositionFromLocation(pt); newPos = MovePositionOutsideChar(newPos, currentPos - newPos); inDragDrop = false; + moveExtendsSelection = false; bool processed = NotifyMarginClick(pt, shift, ctrl, alt); if (processed) @@ -4475,7 +4770,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift); - if (PositionIsHotspot(newPos)) + if (PointIsHotspot(newPos)) NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt); } } else { // Single click @@ -4507,7 +4802,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b SetMouseCapture(true); selectionType = selLine; } else { - if (PositionIsHotspot(newPos)) { + if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newPos, shift, ctrl, alt); } if (!shift) { @@ -4519,13 +4814,13 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b CopySelectionRange(&drag); StartDrag(); } else { - xStartSelect = pt.x - vs.fixedColumnWidth + xOffset; - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; SetDragPosition(invalidPosition); SetMouseCapture(true); - if (!shift) + if (!shift) { SetEmptySelection(newPos); + } selType = alt ? selRectangle : selStream; + xStartSelect = xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; selectionType = selChar; originalAnchorPos = currentPos; } @@ -4537,11 +4832,13 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } bool Editor::PositionIsHotspot(int position) { - return vs.styles[pdoc->StyleAt(position)].hotspot; + return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; } bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocation(pt); + int pos = PositionFromLocationClose(pt); + if (pos == INVALID_POSITION) + return false; return PositionIsHotspot(pos); } @@ -4552,8 +4849,8 @@ void Editor::SetHotSpotRange(Point *pt) { // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. - int hsStart_ = pdoc->ExtendStyleRange(pos, -1); - int hsEnd_ = pdoc->ExtendStyleRange(pos, 1); + int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); + int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... if (hsStart_ != hsStart || hsEnd_ != hsEnd) { @@ -4598,7 +4895,6 @@ void Editor::ButtonMove(Point pt) { autoScrollTimer.ticksToWait = autoScrollDelay; // Adjust selection - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; int movePos = PositionFromLocation(pt); movePos = MovePositionOutsideChar(movePos, currentPos - movePos); if (posDrag >= 0) { @@ -4608,7 +4904,17 @@ void Editor::ButtonMove(Point pt) { SetSelection(movePos); } else if (selectionType == selWord) { // Continue selecting by word - if (movePos >= originalAnchorPos) { // Moved forward + if (movePos == originalAnchorPos) { // Didn't move + // No need to do anything. Previously this case was lumped + // in with "Moved forward", but that can be harmful in this + // case: a handler for the NotifyDoubleClick re-adjusts + // the selection for a fancier definition of "word" (for + // example, in Perl it is useful to include the leading + // '$', '%' or '@' on variables for word selection). In this + // the ButtonMove() called via Tick() for auto-scrolling + // could result in the fancier word selection adjustment + // being unmade. + } else if (movePos > originalAnchorPos) { // Moved forward SetSelection(pdoc->ExtendWordSelect(movePos, 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward @@ -4621,6 +4927,9 @@ void Editor::ButtonMove(Point pt) { LineSelection(lineMove, lineAnchor); } } + // While dragging to make rectangular selection, we don't want the current + // position to jump to the end of smaller or empty lines. + xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; // Autoscroll PRectangle rcClient = GetClientRectangle(); @@ -4659,7 +4968,6 @@ void Editor::ButtonMove(Point pt) { SetHotSpotRange(NULL); } } - } void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { @@ -4671,7 +4979,6 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } - xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; ptMouseLast = pt; SetMouseCapture(false); int newPos = PositionFromLocation(pt); @@ -4708,6 +5015,9 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { SetSelection(newPos); } } + // Now we rely on the current pos to compute rectangular selection + xStartSelect = XFromPosition(anchor); + xEndSelect = XFromPosition(currentPos); lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x; @@ -4745,6 +5055,30 @@ void Editor::Tick() { } } +bool Editor::Idle() { + + bool idleDone; + + bool wrappingDone = (wrapState == eWrapNone) || (!backgroundWrapEnabled); + + if (!wrappingDone) { + // Wrap lines during idle. + WrapLines(false, -1); + // No more wrapping + if (docLineLastWrapped == docLastLineToWrap) + wrappingDone = true; + } + + // Add more idle things to do here, but make sure idleDone is + // set correctly before the function returns. returning + // false will stop calling this idle funtion until SetIdle() is + // called again. + + idleDone = wrappingDone; // && thatDone && theOtherThingDone... + + return !idleDone; +} + void Editor::SetFocusState(bool focusState) { hasFocus = focusState; NotifyFocus(hasFocus); @@ -4898,6 +5232,7 @@ void Editor::SetDocPointer(Document *document) { pdoc->AddRef(); // Ensure all positions within document + selType = selStream; currentPos = 0; anchor = 0; targetStart = 0; @@ -4914,7 +5249,9 @@ void Editor::SetDocPointer(Document *document) { SetScrollBars(); } -// Recursively expand a fold, making lines visible except where they have an unexpanded parent +/** + * Recursively expand a fold, making lines visible except where they have an unexpanded parent. + */ void Editor::Expand(int &line, bool doExpand) { int lineMaxSubord = pdoc->GetLastChild(line); line++; @@ -4953,12 +5290,14 @@ void Editor::ToggleContraction(int line) { } } -// Recurse up from this line to find any folds that prevent this line from being visible -// and unfold them all-> +/** + * Recurse up from this line to find any folds that prevent this line from being visible + * and unfold them all. + */ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { // In case in need of wrapping to ensure DisplayFromDoc works. - WrapLines(); + WrapLines(true, -1); if (!cs.GetVisible(lineDoc)) { int lineParent = pdoc->GetFoldParent(lineDoc); @@ -5157,7 +5496,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (selectedText.len) { for (; iChar < selectedText.len; iChar++) ptr[iChar] = selectedText.s[iChar]; - ptr[iChar] = '\0'; } else { ptr[0] = '\0'; } @@ -5307,6 +5645,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); + PLATFORM_ASSERT(cpMax <= pdoc->Length()); int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); // Spec says copied text is terminated with a NUL @@ -5360,7 +5699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; int insertPos = wParam; - if (static_cast(wParam) == -1) + if (static_cast(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); char *sz = CharPtrFromSPtr(lParam); @@ -5406,12 +5745,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETWORDCHARS: { + pdoc->SetDefaultCharClasses(); if (lParam == 0) return 0; - pdoc->SetWordChars(reinterpret_cast(lParam)); + pdoc->SetCharClasses(reinterpret_cast(lParam), Document::ccWord); } break; + case SCI_SETWHITESPACECHARS: { + if (lParam == 0) + return 0; + pdoc->SetCharClasses(reinterpret_cast(lParam), Document::ccSpace); + } + break; + + case SCI_SETCHARSDEFAULT: + pdoc->SetDefaultCharClasses(); + break; + case SCI_GETLENGTH: return pdoc->Length(); @@ -5468,7 +5819,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return printWrapState; case SCI_GETSTYLEAT: - if (static_cast(wParam) >= pdoc->Length()) + if (static_cast(wParam) >= pdoc->Length()) return 0; else return pdoc->StyleAt(wParam); @@ -5843,8 +6194,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINWIDTHN: if (ValidMargin(wParam)) { - vs.ms[wParam].width = lParam; - InvalidateStyleRedraw(); + // Short-circuit if the width is unchanged, to avoid unnecessary redraw. + if (vs.ms[wParam].width != lParam) { + vs.ms[wParam].width = lParam; + InvalidateStyleRedraw(); + } } break; @@ -6192,6 +6546,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: + case SCI_WORDLEFTEND: + case SCI_WORDLEFTENDEXTEND: + case SCI_WORDRIGHTEND: + case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: @@ -6204,6 +6562,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: + + case SCI_STUTTEREDPAGEUP: + case SCI_STUTTEREDPAGEUPEXTEND: + case SCI_STUTTEREDPAGEDOWN: + case SCI_STUTTEREDPAGEDOWNEXTEND: + case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: @@ -6243,6 +6607,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: + case SCI_LINEDOWNRECTEXTEND: + case SCI_LINEUPRECTEXTEND: + case SCI_CHARLEFTRECTEXTEND: + case SCI_CHARRIGHTRECTEXTEND: + case SCI_HOMERECTEXTEND: + case SCI_VCHOMERECTEXTEND: + case SCI_LINEENDRECTEXTEND: + case SCI_PAGEUPRECTEXTEND: + case SCI_PAGEDOWNRECTEXTEND: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: @@ -6336,7 +6709,49 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_SELECTIONISRECTANGLE: - return (selType == selRectangle) ? 1 : 0; + return selType == selRectangle ? 1 : 0; + + case SCI_SETSELECTIONMODE: { + switch (wParam) { + case SC_SEL_STREAM: + moveExtendsSelection = !moveExtendsSelection || (selType != selStream); + selType = selStream; + break; + case SC_SEL_RECTANGLE: + moveExtendsSelection = !moveExtendsSelection || (selType != selRectangle); + selType = selRectangle; + break; + case SC_SEL_LINES: + moveExtendsSelection = !moveExtendsSelection || (selType != selLines); + selType = selLines; + break; + default: + moveExtendsSelection = !moveExtendsSelection || (selType != selStream); + selType = selStream; + } + InvalidateSelection(currentPos, anchor); + } + case SCI_GETSELECTIONMODE: + switch (selType) { + case selStream: + return SC_SEL_STREAM; + case selRectangle: + return SC_SEL_RECTANGLE; + case selLines: + return SC_SEL_LINES; + default: // ?! + return SC_SEL_STREAM; + } + case SCI_GETLINESELSTARTPOSITION: { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(wParam); + return lineIterator.startPos; + } + case SCI_GETLINESELENDPOSITION: { + SelectionLineIterator lineIterator(this); + lineIterator.SetAt(wParam); + return lineIterator.endPos; + } case SCI_SETOVERTYPE: inOverstrike = wParam != 0; @@ -6422,6 +6837,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_SETHOTSPOTSINGLELINE: + vs.hotspotSingleLine = wParam != 0; + InvalidateStyleRedraw(); + break; + default: return DefWndProc(iMessage, wParam, lParam); } diff --git a/src/stc/scintilla/src/Editor.h b/src/stc/scintilla/src/Editor.h index bd4669192f..08c56f7a41 100644 --- a/src/stc/scintilla/src/Editor.h +++ b/src/stc/scintilla/src/Editor.h @@ -31,6 +31,16 @@ public: Timer(); }; +/** + */ +class Idler { +public: + bool state; + IdlerID idlerID; + + Idler(); +}; + /** */ class LineLayout { @@ -115,6 +125,10 @@ public: void Dispose(LineLayout *ll); }; +/** + * Hold a piece of text selected for copying or dragging. + * The text is expected to hold a terminating '\0'. + */ class SelectionText { public: char *s; @@ -208,6 +222,8 @@ protected: // ScintillaBase subclass needs access to much of Editor Timer autoScrollTimer; enum { autoScrollDelay = 200 }; + Idler idler; + Point lastClick; unsigned int lastClickTime; int dwellDelay; @@ -244,9 +260,11 @@ protected: // ScintillaBase subclass needs access to much of Editor int modEventMask; SelectionText drag; - enum { selStream, selRectangle, selRectangleFixed } selType; - int xStartSelect; - int xEndSelect; + enum selTypes { noSel, selStream, selRectangle, selLines }; + selTypes selType; + bool moveExtendsSelection; + int xStartSelect; ///< x position of start of rectangular selection + int xEndSelect; ///< x position of end of rectangular selection bool primarySelection; int caretXPolicy; @@ -271,8 +289,10 @@ protected: // ScintillaBase subclass needs access to much of Editor // Wrapping support enum { eWrapNone, eWrapWord } wrapState; + bool backgroundWrapEnabled; int wrapWidth; int docLineLastWrapped; + int docLastLineToWrap; Document *pdoc; @@ -310,15 +330,16 @@ protected: // ScintillaBase subclass needs access to much of Editor int CurrentPosition(); bool SelectionEmpty(); - int SelectionStart(int line=-1); - int SelectionEnd(int line=-1); + int SelectionStart(); + int SelectionEnd(); + void InvalidateSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_); void SetEmptySelection(int currentPos_); bool RangeContainsProtected(int start, int end) const; - bool SelectionContainsProtected() const; + bool SelectionContainsProtected(); int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); - int MovePositionTo(int newPos, bool extend=false, bool ensureVisible=true); + int MovePositionTo(int newPos, selTypes sel=noSel, bool ensureVisible=true); int MovePositionSoVisible(int pos, int moveDir); void SetLastXChosen(); @@ -332,8 +353,8 @@ protected: // ScintillaBase subclass needs access to much of Editor void DropCaret(); void InvalidateCaret(); - void NeedWrapping(int docLineStartWrapping=0); - bool WrapLines(); + void NeedWrapping(int docLineStartWrapping = 0, int docLineEndWrapping = 0x7ffffff); + bool WrapLines(bool fullWrap, int priorityWrapLineStart); void LinesJoin(); void LinesSplit(int pixelWidth); @@ -406,13 +427,13 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyStyleNeeded(Document *doc, void *userData, int endPos); void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - void PageMove(int direction, bool extend=false); + void PageMove(int direction, selTypes sel=noSel, bool stuttered = false); void ChangeCaseOfSelection(bool makeUpperCase); void LineTranspose(); void LineDuplicate(); virtual void CancelModes(); void NewLine(); - void CursorUpOrDown(int direction, bool extend=false); + void CursorUpOrDown(int direction, selTypes sel=noSel); int StartEndDisplayLine(int pos, bool start); virtual int KeyCommand(unsigned int iMessage); virtual int KeyDefault(int /* key */, int /*modifiers*/); @@ -451,7 +472,9 @@ protected: // ScintillaBase subclass needs access to much of Editor void ButtonUp(Point pt, unsigned int curTime, bool ctrl); void Tick(); + bool Idle(); virtual void SetTicking(bool on) = 0; + virtual bool SetIdle(bool) { return false; } virtual void SetMouseCapture(bool on) = 0; virtual bool HaveMouseCapture() = 0; void SetFocusState(bool focusState); @@ -484,6 +507,7 @@ public: // Public so scintilla_set_id can use it. int ctrlID; friend class AutoSurface; + friend class SelectionLineIterator; }; /** diff --git a/src/stc/scintilla/src/ExternalLexer.cxx b/src/stc/scintilla/src/ExternalLexer.cxx index 88be76f249..752118b770 100644 --- a/src/stc/scintilla/src/ExternalLexer.cxx +++ b/src/stc/scintilla/src/ExternalLexer.cxx @@ -232,8 +232,9 @@ void LexerManager::Clear() { if (NULL != first) { LexerLibrary *cur = first; - LexerLibrary *next = first->next; + LexerLibrary *next; while (cur) { + next = cur->next; delete cur; cur = next; } diff --git a/src/stc/scintilla/src/Indicator.cxx b/src/stc/scintilla/src/Indicator.cxx index 1e386b68e3..a42abb2037 100644 --- a/src/stc/scintilla/src/Indicator.cxx +++ b/src/stc/scintilla/src/Indicator.cxx @@ -10,7 +10,7 @@ #include "Scintilla.h" #include "Indicator.h" -void Indicator::Draw(Surface *surface, PRectangle &rc) { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { surface->PenColour(fore.allocated); int ymid = (rc.bottom + rc.top) / 2; if (style == INDIC_SQUIGGLE) { @@ -57,6 +57,12 @@ void Indicator::Draw(Surface *surface, PRectangle &rc) { surface->LineTo(rc.right, rc.top - 4); } else if (style == INDIC_HIDDEN) { // Draw nothing + } else if (style == INDIC_BOX) { + surface->MoveTo(rc.left, ymid+1); + surface->LineTo(rc.right, ymid+1); + surface->LineTo(rc.right, rcLine.top+1); + surface->LineTo(rc.left, rcLine.top+1); + surface->LineTo(rc.left, ymid+1); } else { // Either INDIC_PLAIN or unknown surface->MoveTo(rc.left, ymid); surface->LineTo(rc.right, ymid); diff --git a/src/stc/scintilla/src/Indicator.h b/src/stc/scintilla/src/Indicator.h index 56e9420bcc..716db1051f 100644 --- a/src/stc/scintilla/src/Indicator.h +++ b/src/stc/scintilla/src/Indicator.h @@ -16,7 +16,7 @@ public: ColourPair fore; Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) { } - void Draw(Surface *surface, PRectangle &rc); + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine); }; #endif diff --git a/src/stc/scintilla/src/KeyMap.cxx b/src/stc/scintilla/src/KeyMap.cxx index f15842af68..950916bd08 100644 --- a/src/stc/scintilla/src/KeyMap.cxx +++ b/src/stc/scintilla/src/KeyMap.cxx @@ -2,7 +2,7 @@ /** @file KeyMap.cxx ** Defines a mapping between keystrokes and commands. **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include "Platform.h" @@ -15,7 +15,7 @@ KeyMap::KeyMap() : kmap(0), len(0), alloc(0) { for (int i = 0; MapDefault[i].key; i++) { AssignCmdKey(MapDefault[i].key, MapDefault[i].modifiers, - MapDefault[i].msg); + MapDefault[i].msg); } } @@ -35,7 +35,7 @@ void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) { KeyToCommand *ktcNew = new KeyToCommand[alloc + 5]; if (!ktcNew) return; - for (int k=0;k +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -22,24 +24,25 @@ #include "SciLexer.h" - static inline bool IsAWordChar(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch =='\\'); + return (ch < 0x80) && (isalnum(ch) || ch == '.' || + ch == '_' || ch == '?'); } static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' || + ch == '%' || ch == '@' || ch == '$' || ch == '?'); } -inline bool isAsmOperator(char ch) { +static inline bool IsAsmOperator(char ch) { if (isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || - ch == '(' || ch == ')' || ch == '=' || - ch == '[' || ch == ']' || ch == '<' || - ch == '>' || ch == ',' || - ch == '.' || ch == '%' || ch == ':') + ch == '(' || ch == ')' || ch == '=' || ch == '^' || + ch == '[' || ch == ']' || ch == '<' || ch == '&' || + ch == '>' || ch == ',' || ch == '|' || ch == '~' || + ch == '%' || ch == ':') return true; return false; } @@ -52,48 +55,63 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo WordList ®isters = *keywordlists[2]; WordList &directive = *keywordlists[3]; WordList &directiveOperand = *keywordlists[4]; + WordList &extInstruction = *keywordlists[5]; + + // Do not leak onto next line + if (initStyle == SCE_ASM_STRINGEOL) + initStyle = SCE_ASM_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { + + // Prevent SCE_ASM_STRINGEOL from leaking back to previous line + if (sc.atLineStart && (sc.state == SCE_ASM_STRING)) { + sc.SetState(SCE_ASM_STRING); + } else if (sc.atLineStart && (sc.state == SCE_ASM_CHARACTER)) { + sc.SetState(SCE_ASM_CHARACTER); + } + // Handle line continuation generically. if (sc.ch == '\\') { - if (sc.Match("\\\n")) { - sc.Forward(); - continue; - } - if (sc.Match("\\\r\n")) { - sc.Forward(); + if (sc.chNext == '\n' || sc.chNext == '\r') { sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); + } continue; } } // Determine if the current state should terminate. if (sc.state == SCE_ASM_OPERATOR) { - sc.SetState(SCE_ASM_DEFAULT); + if (!IsAsmOperator(static_cast(sc.ch))) { + sc.SetState(SCE_ASM_DEFAULT); + } }else if (sc.state == SCE_ASM_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_IDENTIFIER) { if (!IsAWordChar(sc.ch) ) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - - if (cpuInstruction.InList(s)) { - sc.ChangeState(SCE_ASM_CPUINSTRUCTION); - } else if (mathInstruction.InList(s)) { - sc.ChangeState(SCE_ASM_MATHINSTRUCTION); - } else if (registers.InList(s)) { - sc.ChangeState(SCE_ASM_REGISTER); - } else if (directive.InList(s)) { - sc.ChangeState(SCE_ASM_DIRECTIVE); - } else if (directiveOperand.InList(s)) { - sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); - } - sc.SetState(SCE_ASM_DEFAULT); + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + + if (cpuInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_CPUINSTRUCTION); + } else if (mathInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_MATHINSTRUCTION); + } else if (registers.InList(s)) { + sc.ChangeState(SCE_ASM_REGISTER); + } else if (directive.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVE); + } else if (directiveOperand.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); + } else if (extInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_EXTINSTRUCTION); + } + sc.SetState(SCE_ASM_DEFAULT); } } else if (sc.state == SCE_ASM_COMMENT ) { @@ -108,20 +126,36 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo } else if (sc.ch == '\"') { sc.ForwardSetState(SCE_ASM_DEFAULT); } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_CHARACTER) { + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); sc.ForwardSetState(SCE_ASM_DEFAULT); } } // Determine if a new state should be entered. - else if (sc.state == SCE_ASM_DEFAULT) { + if (sc.state == SCE_ASM_DEFAULT) { if (sc.ch == ';'){ sc.SetState(SCE_ASM_COMMENT); } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { sc.SetState(SCE_ASM_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_ASM_IDENTIFIER); - } else if (sc.Match('\"')) { + } else if (sc.ch == '\"') { sc.SetState(SCE_ASM_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_ASM_CHARACTER); + } else if (IsAsmOperator(static_cast(sc.ch))) { + sc.SetState(SCE_ASM_OPERATOR); } } @@ -135,6 +169,7 @@ static const char * const asmWordListDesc[] = { "Registers", "Directives", "Directive operands", + "Extended instructions", 0 }; diff --git a/src/stc/scintilla/src/LexCLW.cxx b/src/stc/scintilla/src/LexCLW.cxx new file mode 100644 index 0000000000..e5240776cc --- /dev/null +++ b/src/stc/scintilla/src/LexCLW.cxx @@ -0,0 +1,441 @@ +// Scintilla source code edit control +/** @file LexClw.cxx + ** Lexer for Clarion. + **/ +// Copyright 2003 by Ron Schofield +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static char MakeUpperCase(char ch) { + if (ch < 'a' || ch > 'z') + return ch; + else + return static_cast(ch - 'a' + 'A'); +} + +static void MakeUpperCaseString(char *s) { + while (*s) { + *s = MakeUpperCase(*s); + s++; + } +} + +// Is a label start character +inline bool IsALabelStart(const int iChar) { + return(isalpha(iChar) || iChar == '_'); +} + +// Is a label character +inline bool IsALabelCharacter(const int iChar) { + return(isalnum(iChar) || iChar == '_' || iChar == ':'); +} + +// Is the character is a ! and the the next character is not a ! +inline bool IsACommentStart(StyleContext &scDoc) { + return(scDoc.ch == '!' && scDoc.chNext != '!'); +} + +// Is the character a Clarion hex character (ABCDEF) +inline bool IsAHexCharacter(const int iChar, bool bCaseSensitive) { + // Case insensitive. + if (!bCaseSensitive) { + if (strchr("ABCDEFabcdef", iChar) != NULL) { + return(true); + } + } + // Case sensitive + else { + if (strchr("ABCDEF", iChar) != NULL) { + return(true); + } + } + return(false); +} + +// Is the character a Clarion base character (B=Binary, O=Octal, H=Hex) +inline bool IsANumericBaseCharacter(const int iChar, bool bCaseSensitive) { + // Case insensitive. + if (!bCaseSensitive) { + // If character is a numeric base character + if (strchr("BOHboh", iChar) != NULL) { + return(true); + } + } + // Case sensitive + else { + // If character is a numeric base character + if (strchr("BOH", iChar) != NULL) { + return(true); + } + } + return(false); +} + +// Set the correct numeric constant state +inline bool SetNumericConstantState(StyleContext &scDoc) { + int iPoints = 0; // Point counter + char cNumericString[100]; // Numeric string buffer + + // Buffer the current numberic string + scDoc.GetCurrent(cNumericString, sizeof(cNumericString)); + // Loop through the string until end of string (NULL termination) + for (int iIndex = 0; cNumericString[iIndex] != '\0'; iIndex++) { + // Depending on the character + switch (cNumericString[iIndex]) { + // Is a . (point) + case '.' : + // Increment point counter + iPoints++; + break; + default : + break; + } + } + // If points found (can be more than one for improper formatted number + if (iPoints > 0) { + return(true); + } + // Else no points found + else { + return(false); + } +} + +// Clarion Language Colouring Procedure +static void ColouriseClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { + + int iParenthesesLevel=0; // Parenthese Level + + WordList &wlClarionKeywords = *wlKeywords[0]; // Clarion Keywords + WordList &wlCompilerDirectives = *wlKeywords[1]; // Compiler Directives + WordList &wlBuiltInProcsFuncs = *wlKeywords[2]; // Builtin Procedures and Functions + WordList &wlStructsDataTypes = *wlKeywords[3]; // Structures and Data Types + WordList &wlAttributes = *wlKeywords[4]; // Procedure Attributes + WordList &wlStandardEquates = *wlKeywords[5]; // Standard Equates + WordList &wlReservedWords = *wlKeywords[6]; // Clarion Reserved Keywords + + StyleContext scDoc(uiStartPos, iLength, iInitStyle, accStyler); + + // lex source code + for (; scDoc.More(); scDoc.Forward()) + { + // + // Determine if the current state should terminate. + // + + // Label State Handling + if (scDoc.state == SCE_CLW_LABEL) { + // If the character is not a valid label + if (!IsALabelCharacter(scDoc.ch)) { + // If the character is a . (dot syntax) + if (scDoc.ch == '.') { + // Uncolour the . (dot) to default state, move forward one character, + // and change back to the label state. + scDoc.SetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + scDoc.SetState(SCE_CLW_LABEL); + } + // Else terminate the label state + else { + char cLabel[100]; // Label buffer + // Buffer the current label string + scDoc.GetCurrent(cLabel,sizeof(cLabel)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cLabel); + } + // If label string is in the Clarion reserved keyword list + if (wlReservedWords.InList(cLabel)){ + // change to error state + scDoc.ChangeState(SCE_CLW_ERROR); + } + // Else if label string is in the compiler directive keyword list + else if (wlCompilerDirectives.InList(cLabel)) { + // change the state to compiler directive state + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + } + // Terminate the label state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + } + // Keyword State Handling + else if (scDoc.state == SCE_CLW_KEYWORD) { + // If character is : (colon) + if (scDoc.ch == ':') { + char cEquate[100]; // Equate buffer + // Move forward to include : (colon) in buffer + scDoc.Forward(); + // Buffer the equate string + scDoc.GetCurrent(cEquate,sizeof(cEquate)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cEquate); + } + // If statement string is in the equate list + if (wlStandardEquates.InList(cEquate)) { + // Change to equate state + scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE); + } + } + // If the character is not a valid label character + else if (!IsALabelCharacter(scDoc.ch)) { + char cStatement[100]; // Statement buffer + // Buffer the statement string + scDoc.GetCurrent(cStatement,sizeof(cStatement)); + // If case insensitive, convert string to UPPERCASE to match passed keywords. + if (!bCaseSensitive) { + MakeUpperCaseString(cStatement); + } + // If statement string is in the Clarion keyword list + if (wlClarionKeywords.InList(cStatement)) { + // Set to the Clarion keyword state + scDoc.ChangeState(SCE_CLW_KEYWORD); + } + // Else if statement string is in the compiler directive keyword list + else if (wlCompilerDirectives.InList(cStatement)) { + // Set to the compiler directive state + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + } + // Else if statement string is in the builtin procedures and functions keyword list + else if (wlBuiltInProcsFuncs.InList(cStatement)) { + // Set to the builtin procedures and functions state + scDoc.ChangeState(SCE_CLW_BUILTIN_PROCEDURES_FUNCTION); + } + // Else if statement string is in the tructures and data types keyword list + else if (wlStructsDataTypes.InList(cStatement)) { + // Set to the structures and data types state + scDoc.ChangeState(SCE_CLW_STRUCTURE_DATA_TYPE); + } + // Else if statement string is in the procedure attribute keyword list + else if (wlAttributes.InList(cStatement)) { + // Set to the procedure attribute state + scDoc.ChangeState(SCE_CLW_ATTRIBUTE); + } + // Else if statement string is in the standard equate keyword list + else if (wlStandardEquates.InList(cStatement)) { + // Set to the standard equate state + scDoc.ChangeState(SCE_CLW_STANDARD_EQUATE); + } + // Terminate the keyword state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + // String State Handling + else if (scDoc.state == SCE_CLW_STRING) { + // If the character is an ' (single quote) + if (scDoc.ch == '\'') { + // Set the state to default and move forward colouring + // the ' (single quote) as default state + // terminating the string state + scDoc.SetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + } + // If the next character is an ' (single quote) + if (scDoc.chNext == '\'') { + // Move forward one character and set to default state + // colouring the next ' (single quote) as default state + // terminating the string state + scDoc.ForwardSetState(SCE_CLW_DEFAULT); + scDoc.Forward(); + } + } + // Picture String State Handling + else if (scDoc.state == SCE_CLW_PICTURE_STRING) { + // If the character is an ( (open parenthese) + if (scDoc.ch == '(') { + // Increment the parenthese level + iParenthesesLevel++; + } + // Else if the character is a ) (close parenthese) + else if (scDoc.ch == ')') { + // If the parenthese level is set to zero + // parentheses matched + if (!iParenthesesLevel) { + scDoc.SetState(SCE_CLW_DEFAULT); + } + // Else parenthese level is greater than zero + // still looking for matching parentheses + else { + // Decrement the parenthese level + iParenthesesLevel--; + } + } + } + // Standard Equate State Handling + else if (scDoc.state == SCE_CLW_STANDARD_EQUATE) { + if (!isalnum(scDoc.ch)) { + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + // Integer Constant State Handling + else if (scDoc.state == SCE_CLW_INTEGER_CONSTANT) { + // If the character is not a digit (0-9) + // or character is not a hexidecimal character (A-F) + // or character is not a . (point) + // or character is not a numberic base character (B,O,H) + if (!(isdigit(scDoc.ch) + || IsAHexCharacter(scDoc.ch, bCaseSensitive) + || scDoc.ch == '.' + || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) { + // If the number was a real + if (SetNumericConstantState(scDoc)) { + // Colour the matched string to the real constant state + scDoc.ChangeState(SCE_CLW_REAL_CONSTANT); + } + // Else the number was an integer + else { + // Colour the matched string to an integer constant state + scDoc.ChangeState(SCE_CLW_INTEGER_CONSTANT); + } + // Terminate the integer constant state and set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + } + + // + // Determine if a new state should be entered. + // + + // Beginning of Line Handling + if (scDoc.atLineStart) { + // If column 1 character is a label start character + if (IsALabelStart(scDoc.ch)) { + // Set the state to label + scDoc.SetState(SCE_CLW_LABEL); + } + // else if character is a space or tab + else if (IsASpace(scDoc.ch)){ + // Set to default state + scDoc.SetState(SCE_CLW_DEFAULT); + } + // else if the start of a comment or is an * (asterisk) + else if (IsACommentStart(scDoc) || scDoc.ch == '*' ) { + // then set the state to comment. + scDoc.SetState(SCE_CLW_COMMENT); + } + // else the character is a ? (question mark) + else if (scDoc.ch == '?') { + // Change to the compiler directive state, move forward, + // colouring the ? (question mark), change back to default state. + scDoc.ChangeState(SCE_CLW_COMPILER_DIRECTIVE); + scDoc.Forward(); + scDoc.SetState(SCE_CLW_DEFAULT); + } + // else an invalid character in column 1 + else { + // Set to error state + scDoc.SetState(SCE_CLW_ERROR); + } + } + // End of Line Handling + else if (scDoc.atLineEnd) { + // Reset to the default state at the end of each line. + scDoc.SetState(SCE_CLW_DEFAULT); + } + // Default Handling + else { + // If in default state + if (scDoc.state == SCE_CLW_DEFAULT) { + // If is a letter could be a possible statement + if (isalpha(scDoc.ch)) { + // Set the state to Clarion Keyword and verify later + scDoc.SetState(SCE_CLW_KEYWORD); + } + // else is a number + else if (isdigit(scDoc.ch)) { + // Set the state to Integer Constant and verify later + scDoc.SetState(SCE_CLW_INTEGER_CONSTANT); + } + // else if the start of a comment or a | (line continuation) + else if (IsACommentStart(scDoc) || scDoc.ch == '|') { + // then set the state to comment. + scDoc.SetState(SCE_CLW_COMMENT); + } + // else if the character is a ' (single quote) + else if (scDoc.ch == '\'') { + // If the character is also a ' (single quote) + // Embedded Apostrophe + if (scDoc.chNext == '\'') { + // Move forward colouring it as default state + scDoc.ForwardSetState(SCE_CLW_DEFAULT); + } + else { + // move to the next character and then set the state to comment. + scDoc.ForwardSetState(SCE_CLW_STRING); + } + } + // else the character is an @ (apersand) + else if (scDoc.ch == '@') { + // Case insensitive. + if (!bCaseSensitive) { + // If character is a valid picture token character + if (strchr("DEKNPSTdeknpst", scDoc.chNext) != NULL) { + // Set to the picture string state + scDoc.SetState(SCE_CLW_PICTURE_STRING); + } + } + // Case sensitive + else { + // If character is a valid picture token character + if (strchr("DEKNPST", scDoc.chNext) != NULL) { + // Set the picture string state + scDoc.SetState(SCE_CLW_PICTURE_STRING); + } + } + } + } + } + } + // lexing complete + scDoc.Complete(); +} + +// Clarion Language Case Sensitive Colouring Procedure +static void ColouriseClwDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true); +} + +// Clarion Language Case Insensitive Colouring Procedure +static void ColouriseClwDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + ColouriseClwDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false); +} + +// Clarion Language Folding Procedure +#ifdef FOLDING_IMPLEMENTED +static void FoldClwDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { + +} +#endif + +// Word List Descriptions +static const char * const rgWordListDescriptions[] = { + "Clarion Keywords", + "Compiler Directives", + "Built-in Procedures and Functions", + "Structure and Data Types", + "Attributes", + "Standard Equates", + "Reserved Words", + 0, +}; + +// Case Sensitive Clarion Language Lexer +LexerModule lmClw(SCLEX_CLW, ColouriseClwDocSensitive, "clw", NULL, rgWordListDescriptions); + +// Case Insensitive Clarion Language Lexer +LexerModule lmClwNoCase(SCLEX_CLWNOCASE, ColouriseClwDocInsensitive, "clwnocase", NULL, rgWordListDescriptions); diff --git a/src/stc/scintilla/src/LexErlang.cxx b/src/stc/scintilla/src/LexErlang.cxx new file mode 100644 index 0000000000..9444eb9501 --- /dev/null +++ b/src/stc/scintilla/src/LexErlang.cxx @@ -0,0 +1,522 @@ +// Scintilla source code edit control +/** @file LexErlang.cxx + ** Lexer for Erlang. + ** Written by Peter-Henry Mander, based on Matlab lexer by José Fonseca + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +/* + TODO: + o _Param should be a new lexical type +*/ + +static int is_radix(int radix, int ch) { + int digit; + if ( 16 < radix || 2 > radix ) { + return 0; + } + if ( isdigit(ch) ) { + digit = ch - '0'; + } else if ( isxdigit(ch) ) { + digit = toupper(ch) - 'A' + 10; + } else { + return 0; + } + if ( digit < radix ) { + return 1; + } else { + return 0; + } +} + +typedef enum { + STATE_NULL, + ATOM_UNQUOTED, + ATOM_QUOTED, + ATOM_FUN_NAME, + NODE_NAME_UNQUOTED, + NODE_NAME_QUOTED, + MACRO_START, + MACRO_UNQUOTED, + MACRO_QUOTED, + RECORD_START, + RECORD_UNQUOTED, + RECORD_QUOTED, + NUMERAL_START, + NUMERAL_SIGNED, + NUMERAL_RADIX_LITERAL, + NUMERAL_SPECULATIVE_MANTISSA, + NUMERAL_FLOAT_MANTISSA, + NUMERAL_FLOAT_EXPONENT, + NUMERAL_FLOAT_SIGNED_EXPONENT, + PARSE_ERROR +} atom_parse_state_t; + +static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + + styler.StartAt(startPos); + + StyleContext sc(startPos, length, initStyle, styler); + atom_parse_state_t parse_state = STATE_NULL; + int radix_digits = 0; + int exponent_digits = 0; + for (; sc.More(); sc.Forward()) { + if ( STATE_NULL != parse_state ) { + switch (parse_state) { + case STATE_NULL: + sc.SetState(SCE_ERLANG_DEFAULT); + break; + case ATOM_UNQUOTED: + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_UNQUOTED; + } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { + char s[100]; + sc.GetCurrent(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(SCE_ERLANG_KEYWORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + if ( '/' == sc.ch ) { + parse_state = ATOM_FUN_NAME; + } else { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } + } + break; + case ATOM_QUOTED: + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_QUOTED; + } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case ATOM_FUN_NAME: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_FUNCTION_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NODE_NAME_QUOTED: + if ( '@' == sc.ch ) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NODE_NAME_UNQUOTED: + if ( '@' == sc.ch ) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_START: + if ( '\'' == sc.ch ) { + parse_state = RECORD_QUOTED; + } else if (isalpha(sc.ch) && islower(sc.ch)) { + parse_state = RECORD_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_QUOTED: + if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case RECORD_UNQUOTED: + if ( !isalpha(sc.ch) && '_' != sc.ch ) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_START: + if ( '\'' == sc.ch ) { + parse_state = MACRO_QUOTED; + } else if (isalpha(sc.ch)) { + parse_state = MACRO_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_UNQUOTED: + if ( !isalpha(sc.ch) && '_' != sc.ch ) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case MACRO_QUOTED: + if ( '\'' == sc.ch && '\\' != sc.chPrev ) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_START: + if ( isdigit(sc.ch) ) { + radix_digits *= 10; + radix_digits += sc.ch - '0'; // Assuming ASCII here! + } else if ( '#' == sc.ch ) { + if ( 2 > radix_digits || 16 < radix_digits) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_RADIX_LITERAL; + } + } else if ( '.' == sc.ch && isdigit(sc.chNext)) { + radix_digits = 0; + parse_state = NUMERAL_FLOAT_MANTISSA; + } else if ( 'e' == sc.ch || 'E' == sc.ch ) { + exponent_digits = 0; + parse_state = NUMERAL_FLOAT_EXPONENT; + } else { + radix_digits = 0; + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_RADIX_LITERAL: + if ( !is_radix(radix_digits,sc.ch) ) { + radix_digits = 0; + if ( !isalnum(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_FLOAT_MANTISSA: + if ( 'e' == sc.ch || 'E' == sc.ch ) { + exponent_digits = 0; + parse_state = NUMERAL_FLOAT_EXPONENT; + } else if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + break; + case NUMERAL_FLOAT_EXPONENT: + if ( '-' == sc.ch || '+' == sc.ch ) { + parse_state = NUMERAL_FLOAT_SIGNED_EXPONENT; + } else if ( !isdigit(sc.ch) ) { + if ( 0 < exponent_digits ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + break; + case NUMERAL_FLOAT_SIGNED_EXPONENT: + if ( !isdigit(sc.ch) ) { + if ( 0 < exponent_digits ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + } + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + break; + case NUMERAL_SIGNED: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ( '.' == sc.ch ) { + parse_state = NUMERAL_FLOAT_MANTISSA; + } + break; + case NUMERAL_SPECULATIVE_MANTISSA: + if ( !isdigit(sc.ch) ) { + sc.ChangeState(SCE_ERLANG_OPERATOR); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_FLOAT_MANTISSA; + } + break; + case PARSE_ERROR: + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + break; + } + } else if (sc.state == SCE_ERLANG_OPERATOR) { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_VARIABLE) { + if (!isalnum(sc.ch) && sc.ch != '_') { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_STRING) { + if (sc.ch == '\"' && sc.chPrev != '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_COMMENT ) { + if (sc.atLineEnd) { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else if (sc.state == SCE_ERLANG_CHARACTER ) { + if ( sc.chPrev == '\\' ) { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if ( sc.ch != '\\' ) { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } + + if (sc.state == SCE_ERLANG_DEFAULT) { + if (sc.ch == '%') { + sc.SetState(SCE_ERLANG_COMMENT); + } else if (sc.ch == '\"') { + sc.SetState(SCE_ERLANG_STRING); + } else if (sc.ch == '#') { + parse_state = RECORD_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch == '?') { + parse_state = MACRO_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch == '$') { + sc.SetState(SCE_ERLANG_CHARACTER); + } else if (sc.ch == '\'') { + parse_state = ATOM_QUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if ( isdigit(sc.ch) ) { + parse_state = NUMERAL_START; + radix_digits = sc.ch - '0'; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if ( '.' == sc.ch ) { + parse_state = NUMERAL_SPECULATIVE_MANTISSA; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isalpha(sc.ch) && isupper(sc.ch)) { + sc.SetState(SCE_ERLANG_VARIABLE); + } else if (isalpha(sc.ch)) { + parse_state = ATOM_UNQUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isoperator(static_cast(sc.ch)) || sc.ch == '\\') { + sc.SetState(SCE_ERLANG_OPERATOR); + } + } + } + sc.Complete(); +} + +static int ClassifyFoldPointErlang( + Accessor &styler, + int styleNext, + int keyword_start +) { + int lev = 0; + if ( styler.Match(keyword_start,"case") + || ( + styler.Match(keyword_start,"fun") + && SCE_ERLANG_FUNCTION_NAME != styleNext) + || styler.Match(keyword_start,"if") + || styler.Match(keyword_start,"query") + || styler.Match(keyword_start,"receive") + ) { + ++lev; + } else if ( styler.Match(keyword_start,"end") ) { + --lev; + } + return lev; +} + + +static void FoldErlangDoc( + unsigned int startPos, int length, int initStyle, + WordList** /*keywordlists*/, Accessor &styler +) { + unsigned int endPos = startPos + length; + //~ int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; + int levelCurrent = levelPrev; + char chNext = styler.SafeGetCharAt(startPos); + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int keyword_start = 0; + + bool fold_keywords = true; + bool fold_comments = true; + bool fold_braces = true; + bool fold_function_clauses = false; + bool fold_clauses = false; + + //int clause_level = 0; + + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + if ( (stylePrev != SCE_ERLANG_KEYWORD) && (style == SCE_ERLANG_KEYWORD) ) { + keyword_start = i; + } + if ( fold_keywords ) { + if ( (stylePrev == SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_ATOM) + ) { + levelCurrent += ClassifyFoldPointErlang(styler,styleNext,keyword_start); + } + } + + if ( fold_comments ) { + if (style == SCE_ERLANG_COMMENT) { + if ((ch == '%') && (chNext == '{')) { + levelCurrent++; + } else if ((ch == '%') && (chNext == '}')) { + levelCurrent--; + } + } + } + + if ( fold_function_clauses ) { + if ( (SC_FOLDLEVELBASE == levelCurrent) /*&& (style == SCE_ERLANG_OPERATOR)*/ ) { + if ( (ch == '-') && (chNext == '>')) { + //~ fprintf(stderr,"levelCurrent=%d\n", levelCurrent); + //++clause_level; + //~ if ( 0 < clause_level ) + ++levelCurrent; + } + } + //~ if ( (stylePrev != SCE_ERLANG_RECORD) + //~ && (style != SCE_ERLANG_NUMBER) + //~ && (style != SCE_ERLANG_STRING) + //~ && (style != SCE_ERLANG_COMMENT) + //~ ) { + if ( (SC_FOLDLEVELBASE+1 == levelCurrent) && (ch == '.') ) { + //--clause_level; + //~ if ( 0 == clause_level ) + --levelCurrent; + } + //~ } + } + + if ( fold_clauses ) { + if ( (0 < levelCurrent) && (style == SCE_ERLANG_OPERATOR) ) { + if ((ch == '-') && (chNext == '>')) { + levelCurrent++; + } + if ( (ch == ';') ) { + levelCurrent--; + } + } + if ( (stylePrev != SCE_ERLANG_RECORD) + && (style != SCE_ERLANG_NUMBER) + && (style != SCE_ERLANG_STRING) + && (style != SCE_ERLANG_COMMENT) + ) { + if ( (ch == '.') ) { + levelCurrent--; + } + } + if ( (stylePrev == SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_KEYWORD) + && (style != SCE_ERLANG_ATOM) + && ( + styler.Match(keyword_start,"end") // 'end' counted twice if fold_keywords too + || styler.Match(keyword_start,"after") ) + ) { + levelCurrent--; + } + } + + if ( fold_braces ) { + if (style == SCE_ERLANG_OPERATOR) { + if ( (ch == '{') || (ch == '(') || (ch == '[') ) { + levelCurrent++; + } else if ( (ch == '}') || (ch == ')') || (ch == ']') ) { + levelCurrent--; + } + } + } + + if (atEOL) { + int lev = levelPrev; + //~ if (visibleChars == 0 && foldCompact) + //~ lev |= SC_FOLDLEVELWHITEFLAG; + //~ if ((levelCurrent > levelPrev) && (visibleChars > 0)) + if ((levelCurrent > levelPrev)) { + lev |= SC_FOLDLEVELHEADERFLAG; + } + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelPrev = levelCurrent; + //~ visibleChars = 0; + } + //~ if (!isspacechar(ch)) + //~ visibleChars++; + + } + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} + +static const char * const erlangWordListDesc[] = { + "Keywords", + 0 +}; + +LexerModule lmErlang( + SCLEX_ERLANG, + ColouriseErlangDoc, + "erlang", + FoldErlangDoc, + erlangWordListDesc); + diff --git a/src/stc/scintilla/src/LexForth.cxx b/src/stc/scintilla/src/LexForth.cxx new file mode 100644 index 0000000000..3f128156d6 --- /dev/null +++ b/src/stc/scintilla/src/LexForth.cxx @@ -0,0 +1,348 @@ +// 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.eserv.ru/) + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +bool is_whitespace(int ch){ + return ch == '\n' || ch == '\r' || ch == '\t' || ch == ' '; +} + +bool is_blank(int ch){ + return ch == '\t' || ch == ' '; +} +//#define FORTH_DEBUG +#ifdef FORTH_DEBUG +static FILE *f_debug; +#define log(x) fputs(f_debug,x); +#else +#define log(x) +#endif + +#define STATE_LOCALE +#define BL ' ' + +static Accessor *st; +static int cur_pos,pos1,pos2,pos0,lengthDoc; +char *buffer; + +char getChar(bool is_bl){ + char ch=st->SafeGetCharAt(cur_pos); + if(is_bl) if(is_whitespace(ch)) ch=BL; + return ch; +} + +char getCharBL(){ + char ch=st->SafeGetCharAt(cur_pos); + return ch; +} +bool is_eol(char ch){ + return ch=='\n' || ch=='\r'; +} + +int parse(char ch, bool skip_eol){ +// pos1 - start pos of word +// pos2 - pos after of word +// pos0 - start pos + char c=0; + int len; + bool is_bl=ch==BL; + pos0=pos1=pos2=cur_pos; + for(;cur_pos9 && base>10) digit-=7; + if(digit<0) return false; + if(digit>=base) return false; + } + return true; +} + +bool is_number(char *s){ + if(strncmp(s,"0x",2)==0) return _is_number(s+2,16); + return _is_number(s,10); +} + +static void ColouriseForthDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +{ + st=&styler; + cur_pos=startPos; + lengthDoc = startPos + length; + buffer = new char[length]; + +#ifdef FORTH_DEBUG + f_debug=fopen("c:\\sci.log","at"); +#endif + + WordList &control = *keywordLists[0]; + WordList &keyword = *keywordLists[1]; + WordList &defword = *keywordLists[2]; + WordList &preword1 = *keywordLists[3]; + WordList &preword2 = *keywordLists[4]; + WordList &strings = *keywordLists[5]; + + // go through all provided text segment + // using the hand-written state machine shown below + styler.StartAt(startPos); + styler.StartSegment(startPos); + while(parse(BL,true)!=0){ + if(pos0!=pos1){ + styler.ColourTo(pos0,SCE_FORTH_DEFAULT); + styler.ColourTo(pos1-1,SCE_FORTH_DEFAULT); + } + if(strcmp("\\",buffer)==0){ + styler.ColourTo(pos1,SCE_FORTH_COMMENT); + parse(1,false); + styler.ColourTo(pos2,SCE_FORTH_COMMENT); + }else if(strcmp("(",buffer)==0){ + styler.ColourTo(pos1,SCE_FORTH_COMMENT); + parse(')',true); + if(cur_pos // The License.txt file describes the conditions under which this software may be distributed. - +/***************************************/ #include #include #include #include #include - +/***************************************/ #include "Platform.h" - #include "PropSet.h" #include "Accessor.h" #include "StyleContext.h" #include "KeyWords.h" #include "Scintilla.h" #include "SciLexer.h" - +/***********************************************/ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%'); } - +/**********************************************/ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch)); } - +/***************************************/ inline bool IsABlank(unsigned int ch) { return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ; } -static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler, bool isFixFormat) { - +/***************************************/ +inline bool IsALineEnd(char ch) { + return ((ch == '\n') || (ch == '\r')) ; +} +/***************************************/ +unsigned int GetContinuedPos(unsigned int pos, Accessor &styler) { + while (!IsALineEnd(styler.SafeGetCharAt(pos++))) continue; + if (styler.SafeGetCharAt(pos) == '\n') pos++; + while (IsABlank(styler.SafeGetCharAt(pos++))) continue; + char chCur = styler.SafeGetCharAt(pos); + if (chCur == '&') { + while (IsABlank(styler.SafeGetCharAt(++pos))) continue; + return pos; + } else { + return pos; + } +} +/***************************************/ +static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, bool isFixFormat) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; - - int posLineStart = 0, prevState = 0; + /***************************************/ + int posLineStart = 0, numNonBlank = 0, prevState = 0; int endPos = startPos + length; - - // backtrack to the beginning of the document, this may be slow for big documents. - // initStyle = SCE_F_DEFAULT; - // StyleContext sc(0, startPos+length, initStyle, styler); - + /***************************************/ // backtrack to the nearest keyword while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_F_WORD)) { startPos--; @@ -53,22 +65,47 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle startPos = styler.LineStart(styler.GetLine(startPos)); initStyle = styler.StyleAt(startPos - 1); StyleContext sc(startPos, endPos-startPos, initStyle, styler); - + /***************************************/ for (; sc.More(); sc.Forward()) { - - // remember the position of the line + // remember the start position of the line if (sc.atLineStart) { posLineStart = sc.currentPos; + numNonBlank = 0; sc.SetState(SCE_F_DEFAULT); } - + if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; + /***********************************************/ + // Handle the fix format generically + int toLineStart = sc.currentPos - posLineStart; + if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) { + if (toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') { + sc.SetState(SCE_F_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart > 72) { + sc.SetState(SCE_F_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart < 5) { + if (IsADigit(sc.ch)) + sc.SetState(SCE_F_LABEL); + else + sc.SetState(SCE_F_DEFAULT); + } else if (toLineStart == 5) { + if (!IsASpace(sc.ch) && sc.ch != '0') { + sc.SetState(SCE_F_CONTINUATION); + sc.ForwardSetState(prevState); + } else + sc.SetState(SCE_F_DEFAULT); + } + continue; + } + /***************************************/ // Handle line continuation generically. - if (sc.ch == '&') { + if (!isFixFormat && sc.ch == '&') { char chTemp = ' '; int j = 1; while (IsABlank(chTemp) && j<132) { chTemp = static_cast(sc.GetRelative(j)); - j ++; + j++; } if (chTemp == '!') { sc.SetState(SCE_F_CONTINUATION); @@ -76,24 +113,21 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } else if (chTemp == '\r' || chTemp == '\n') { int currentState = sc.state; sc.SetState(SCE_F_CONTINUATION); - if (currentState == SCE_F_STRING1 || currentState == SCE_F_STRING2) { - sc.ForwardSetState(SCE_F_DEFAULT); - while (IsASpace(sc.ch) && sc.More()) sc.Forward(); - if (sc.ch == '&') { - sc.SetState(SCE_F_CONTINUATION); - sc.Forward(); - } - sc.SetState(currentState); + sc.ForwardSetState(SCE_F_DEFAULT); + while (IsASpace(sc.ch) && sc.More()) sc.Forward(); + if (sc.ch == '&') { + sc.SetState(SCE_F_CONTINUATION); + sc.Forward(); } + sc.SetState(currentState); } - continue; } - + /***************************************/ // Determine if the current state should terminate. if (sc.state == SCE_F_OPERATOR) { sc.SetState(SCE_F_DEFAULT); } else if (sc.state == SCE_F_NUMBER) { - if (!IsAWordChar(sc.ch)) { + if (!(IsAWordChar(sc.ch) || sc.ch=='\'' || sc.ch=='\"' || sc.ch=='.')) { sc.SetState(SCE_F_DEFAULT); } } else if (sc.state == SCE_F_IDENTIFIER) { @@ -109,7 +143,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } sc.SetState(SCE_F_DEFAULT); } - } else if (sc.state == SCE_F_COMMENT) { + } else if (sc.state == SCE_F_COMMENT || sc.state == SCE_F_PREPROCESSOR) { if (sc.ch == '\r' || sc.ch == '\n') { sc.SetState(SCE_F_DEFAULT); } @@ -123,24 +157,14 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle prevState = SCE_F_DEFAULT; } } else if (sc.atLineEnd) { - if (isFixFormat) { - sc.ForwardSetState(SCE_F_DEFAULT); - posLineStart = sc.currentPos; - } else { - sc.ChangeState(SCE_F_STRINGEOL); - sc.ForwardSetState(SCE_F_DEFAULT); - } + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); } } else if (sc.state == SCE_F_STRING2) { prevState = sc.state; if (sc.atLineEnd) { - if (isFixFormat) { - sc.ForwardSetState(SCE_F_DEFAULT); - posLineStart = sc.currentPos; - } else { - sc.ChangeState(SCE_F_STRINGEOL); - sc.ForwardSetState(SCE_F_DEFAULT); - } + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); } else if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); @@ -156,33 +180,36 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } else if (sc.state == SCE_F_CONTINUATION) { sc.SetState(SCE_F_DEFAULT); } else if (sc.state == SCE_F_LABEL) { - if (sc.currentPos >= static_cast(posLineStart+5)) { + if (!IsADigit(sc.ch)) { sc.SetState(SCE_F_DEFAULT); + } else { + if (isFixFormat && sc.currentPos-posLineStart > 4) + sc.SetState(SCE_F_DEFAULT); + else if (numNonBlank > 5) + sc.SetState(SCE_F_DEFAULT); } } - + /***************************************/ // Determine if a new state should be entered. if (sc.state == SCE_F_DEFAULT) { - int toLineStart = sc.currentPos - posLineStart; - if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) { - if (sc.atLineStart && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') { - sc.SetState(SCE_F_COMMENT); - } else if (toLineStart > 72) { + if (sc.ch == '!') { + if (sc.chNext == '$') { + sc.SetState(SCE_F_PREPROCESSOR); + } else { sc.SetState(SCE_F_COMMENT); - } else if (toLineStart < 5 && !IsASpace(sc.ch)) { - sc.SetState(SCE_F_LABEL); - } else if (toLineStart == 5 && (!IsASpace(sc.ch) && sc.ch != '0')) { - sc.SetState(SCE_F_CONTINUATION); - sc.ForwardSetState(prevState); } + } else if ((!isFixFormat) && IsADigit(sc.ch) && numNonBlank == 1) { + sc.SetState(SCE_F_LABEL); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_F_NUMBER); + } else if ((tolower(sc.ch) == 'b' || tolower(sc.ch) == 'o' || + tolower(sc.ch) == 'z') && (sc.chNext == '\"' || sc.chNext == '\'')) { + sc.SetState(SCE_F_NUMBER); + sc.Forward(); } else if (sc.ch == '.' && isalpha(sc.chNext)) { sc.SetState(SCE_F_OPERATOR2); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_F_IDENTIFIER); - } else if (sc.ch == '!') { - sc.SetState(SCE_F_COMMENT); } else if (sc.ch == '\"') { sc.SetState(SCE_F_STRING2); } else if (sc.ch == '\'') { @@ -194,37 +221,46 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle } sc.Complete(); } - -// The folding depends on the mercy of the programer. -static int classifyFoldPointFortran(const char* s, const char* prevWord) { +/***************************************/ +// To determine the folding level depending on keywords +static int classifyFoldPointFortran(const char* s, const char* prevWord, const char chNextNonBlank) { int lev = 0; - if (strcmp(prevWord, "end") == 0) return lev; if ((strcmp(prevWord, "else") == 0 && strcmp(s, "if") == 0) || strcmp(s, "elseif") == 0) return -1; if (strcmp(s, "associate") == 0 || strcmp(s, "block") == 0 || strcmp(s, "blockdata") == 0 || strcmp(s, "select") == 0 || strcmp(s, "do") == 0 || strcmp(s, "enum") ==0 - || strcmp(s, "forall") == 0 || strcmp(s, "function") == 0 - || strcmp(s, "interface") == 0 || strcmp(s, "module") == 0 - || strcmp(s, "program") == 0 || strcmp(s, "subroutine") == 0 - || strcmp(s, "then") == 0 || strcmp(s, "where") == 0) { - lev = 1; - } else if (strcmp(s, "end") == 0 || strcmp(s, "continue") == 0 - || strcmp(s, "endassociate") == 0 || strcmp(s, "endblock") == 0 - || strcmp(s, "endblockdata") == 0 || strcmp(s, "endselect") == 0 - || strcmp(s, "enddo") == 0 || strcmp(s, "endenum") ==0 - || strcmp(s, "endif") == 0 - || strcmp(s, "endforall") == 0 || strcmp(s, "endfunction") == 0 - || strcmp(s, "endinterface") == 0 || strcmp(s, "endmodule") == 0 - || strcmp(s, "endprogram") == 0 || strcmp(s, "endsubroutine") == 0 - || strcmp(s, "endwhere") == 0 || strcmp(s, "procedure") == 0 ) { - lev = -1; + || strcmp(s, "function") == 0 || strcmp(s, "interface") == 0 + || strcmp(s, "module") == 0 || strcmp(s, "program") == 0 + || strcmp(s, "subroutine") == 0 || strcmp(s, "then") == 0 + || (strcmp(s, "type") == 0 && chNextNonBlank != '(') ){ + if (strcmp(prevWord, "end") == 0) + lev = 0; + else + lev = 1; + } else if (strcmp(s, "end") == 0 && chNextNonBlank != '=' + || strcmp(s, "endassociate") == 0 || strcmp(s, "endblock") == 0 + || strcmp(s, "endblockdata") == 0 || strcmp(s, "endselect") == 0 + || strcmp(s, "enddo") == 0 || strcmp(s, "endenum") ==0 + || strcmp(s, "endif") == 0 || strcmp(s, "endforall") == 0 + || strcmp(s, "endfunction") == 0 || strcmp(s, "endinterface") == 0 + || strcmp(s, "endmodule") == 0 || strcmp(s, "endprogram") == 0 + || strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0 + || strcmp(s, "endwhere") == 0 + || strcmp(s, "procedure") == 0 ) { // Take care of the module procedure statement + lev = -1; + } else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if + lev = 0; } return lev; } -static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { - //~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0; +// Folding the code +static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, + Accessor &styler, bool isFixFormat) { + // + // bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. + // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; @@ -232,37 +268,133 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, Wor int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; + char chNextNonBlank; int styleNext = styler.StyleAt(startPos); int style = initStyle; - + /***************************************/ int lastStart = 0; - char prevWord[32] = ""; - + char prevWord[32] = "", Label[6] = ""; + // Variables for do label folding. + static int doLabels[100], posLabel=-1; + /***************************************/ for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); + chNextNonBlank = chNext; + unsigned int j=i+1; + while(IsABlank(chNextNonBlank) && j(tolower(styler[lastStart + j])); + unsigned int k; + for(k=0; (k<31 ) && (k(tolower(styler[lastStart+k])); + } + s[k] = '\0'; + // Handle the forall and where statement and structure. + if (strcmp(s, "forall") == 0 || strcmp(s, "where") == 0) { + if (strcmp(prevWord, "end") != 0) { + j = i + 1; + char chBrace = '(', chSeek = ')', ch1 = styler.SafeGetCharAt(j); + // Find the position of the first ( + while (ch1 != chBrace && j -1) { + levelCurrent--; + posLabel--; + } + } } if (atEOL) { int lev = levelPrev; @@ -278,33 +410,41 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, Wor visibleChars = 0; strcpy(prevWord, ""); } - - if (!isspacechar(ch)) - visibleChars++; + /***************************************/ + if (!isspacechar(ch)) visibleChars++; } - + /***************************************/ // Fill in the real level of the next line, keeping the current flags as they will be filled in later int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } - +/***************************************/ static const char * const FortranWordLists[] = { "Primary keywords and identifiers", "Intrinsic functions", "Extended and user defined functions", 0, }; - +/***************************************/ static void ColouriseFortranDocFreeFormat(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, false); } - +/***************************************/ static void ColouriseFortranDocFixFormat(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, true); } - - -LexerModule lmFortran(SCLEX_FORTRAN, ColouriseFortranDocFreeFormat, "fortran", FoldFortranDoc, FortranWordLists); -LexerModule lmF77(SCLEX_F77, ColouriseFortranDocFixFormat, "f77", FoldFortranDoc, FortranWordLists); +/***************************************/ +static void FoldFortranDocFreeFormat(unsigned int startPos, int length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, false); +} +/***************************************/ +static void FoldFortranDocFixFormat(unsigned int startPos, int length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, true); +} +/***************************************/ +LexerModule lmFortran(SCLEX_FORTRAN, ColouriseFortranDocFreeFormat, "fortran", FoldFortranDocFreeFormat, FortranWordLists); +LexerModule lmF77(SCLEX_F77, ColouriseFortranDocFixFormat, "f77", FoldFortranDocFixFormat, FortranWordLists); diff --git a/src/stc/scintilla/src/LexLua.cxx b/src/stc/scintilla/src/LexLua.cxx index 18612c9ee3..3781eed83a 100644 --- a/src/stc/scintilla/src/LexLua.cxx +++ b/src/stc/scintilla/src/LexLua.cxx @@ -27,21 +27,31 @@ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); } -inline bool IsAWordStart(const int ch) { +static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -inline bool isLuaOperator(char ch) { - if (isalnum(ch)) +static inline bool IsANumberChar(const int ch) { + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. + return (ch < 0x80) && + (isdigit(ch) || toupper(ch) == 'E' || + ch == '.' || ch == '-' || ch == '+'); +} + +static inline bool IsLuaOperator(int ch) { + if (ch >= 0x80 || isalnum(ch)) { return false; + } // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == '=' || ch == '{' || ch == '}' || ch == '~' || ch == '[' || ch == ']' || ch == ';' || ch == '<' || ch == '>' || ch == ',' || - ch == '.' || ch == '^' || ch == '%' || ch == ':') + ch == '.' || ch == '^' || ch == '%' || ch == ':') { return true; + } return false; } @@ -124,11 +134,8 @@ static void ColouriseLuaDoc( sc.SetState(SCE_LUA_DEFAULT); } else if (sc.state == SCE_LUA_NUMBER) { // We stop the number definition on non-numerical non-dot non-eE non-sign char - if (!(isdigit(sc.ch) || sc.ch == '.' || - toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) { - // Not exactly following number definition (several dots are seen as OK, etc.) - // but probably enough in most cases. - sc.SetState(SCE_LUA_DEFAULT); + if (!IsANumberChar(sc.ch)) { + sc.SetState(SCE_LUA_DEFAULT); } } else if (sc.state == SCE_LUA_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { @@ -233,7 +240,7 @@ static void ColouriseLuaDoc( sc.Forward(); } else if (sc.atLineStart && sc.Match('$')) { sc.SetState(SCE_LUA_PREPROCESSOR); // Obsolete since Lua 4.0, but still in old code - } else if (isLuaOperator(static_cast(sc.ch))) { + } else if (IsLuaOperator(static_cast(sc.ch))) { sc.SetState(SCE_LUA_OPERATOR); } } diff --git a/src/stc/scintilla/src/LexMPT.cxx b/src/stc/scintilla/src/LexMPT.cxx new file mode 100644 index 0000000000..1058b9b496 --- /dev/null +++ b/src/stc/scintilla/src/LexMPT.cxx @@ -0,0 +1,182 @@ +// Scintilla source code edit control +/** @file LexMPT.cxx + ** Lexer for MPT specific files. Based on LexOthers.cxx + ** LOT = the text log file created by the MPT application while running a test program + ** Other MPT specific files to be added later. + **/ +// Copyright 2003 by Marius Gheorghe +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "SString.h" + +static int GetLotLineState(SString &line) { + if (line.length()) { + // Most of the time the first non-blank character in line determines that line's type + // Now finds the first non-blank character + unsigned i; // Declares counter here to make it persistent after the for loop + for (i = 0; i < line.length(); ++i) { + if (!isspace(line[i])) + break; + } + + // Checks if it was a blank line + if (i == line.length()) + return SCE_LOT_DEFAULT; + + switch (line[i]) { + case '*': // Fail measurement + return SCE_LOT_FAIL; + + case '+': // Header + case '|': // Header + return SCE_LOT_HEADER; + + case ':': // Set test limits + return SCE_LOT_SET; + + case '-': // Section break + return SCE_LOT_BREAK; + + default: // Any other line + // Checks for message at the end of lot file + if (line.contains("PASSED")) { + return SCE_LOT_PASS; + } + else if (line.contains("FAILED")) { + return SCE_LOT_FAIL; + } + else if (line.contains("ABORTED")) { + return SCE_LOT_ABORT; + } + else { + return i ? SCE_LOT_PASS : SCE_LOT_DEFAULT; + } + } + } + else { + return SCE_LOT_DEFAULT; + } +} + +static void ColourizeLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { + styler.StartAt(startPos); + styler.StartSegment(startPos); + bool atLineStart = true;// Arms the 'at line start' flag + char chNext = styler.SafeGetCharAt(startPos); + SString line(""); + line.setsizegrowth(256); // Lot lines are less than 256 chars long most of the time. This should avoid reallocations + + // Styles LOT document + unsigned int i; // Declared here because it's used after the for loop + for (i = startPos; i < startPos + length; ++i) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + line += ch; + atLineStart = false; + + // LOT files are only used on the Win32 platform, thus EOL == CR+LF + // Searches for the end of line + if (ch == '\r' && chNext == '\n') { + line += chNext; // Gets the '\n' + ++i; // Advances past the '\n' + chNext = styler.SafeGetCharAt(i + 1); // Gets character of next line + styler.ColourTo(i, GetLotLineState(line)); + line = ""; + atLineStart = true; // Arms flag for next line + } + } + + // Last line may not have a line ending + if (!atLineStart) { + styler.ColourTo(i - 1, GetLotLineState(line)); + } +} + +// Folds an MPT LOT file: the blocks that can be folded are: +// sections (headed by a set line) +// passes (contiguous pass results within a section) +// fails (contiguous fail results within a section) +static void FoldLotDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { + bool foldCompact = styler.GetPropertyInt("fold.compact", 0) != 0; + unsigned int endPos = startPos + length; + int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + + char chNext = styler.SafeGetCharAt(startPos); + int style = SCE_LOT_DEFAULT; + int styleNext = styler.StyleAt(startPos); + int lev = SC_FOLDLEVELBASE; + + // Gets style of previous line if not at the beginning of the document + if (startPos > 1) + style = styler.StyleAt(startPos - 2); + + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if (ch == '\r' && chNext == '\n') { + // TO DO: + // Should really get the state of the previous line from the styler + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 2); + + switch (style) { +/* + case SCE_LOT_SET: + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + break; +*/ + case SCE_LOT_FAIL: +/* + if (stylePrev != SCE_LOT_FAIL) + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else + lev = SC_FOLDLEVELBASE + 1; +*/ + lev = SC_FOLDLEVELBASE; + break; + + default: + if (lineCurrent == 0 || stylePrev == SCE_LOT_FAIL) + lev = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else + lev = SC_FOLDLEVELBASE + 1; + + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + break; + } + + if (lev != styler.LevelAt(lineCurrent)) + styler.SetLevel(lineCurrent, lev); + + lineCurrent++; + visibleChars = 0; + } + + if (!isspacechar(ch)) + visibleChars++; + } + + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, lev | flagsNext); +} + +static const char * const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmLot(SCLEX_LOT, ColourizeLotDoc, "lot", FoldLotDoc, emptyWordListDesc); diff --git a/src/stc/scintilla/src/LexMatlab.cxx b/src/stc/scintilla/src/LexMatlab.cxx index 5f4dff3b8e..249fa67ce2 100644 --- a/src/stc/scintilla/src/LexMatlab.cxx +++ b/src/stc/scintilla/src/LexMatlab.cxx @@ -2,6 +2,10 @@ /** @file LexMatlab.cxx ** Lexer for Matlab. ** Written by José Fonseca + ** + ** Changes by Christoph Dalitz 2003/12/04: + ** - added support for Octave + ** - Strings can now be included both in single or double quotes **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -21,8 +25,21 @@ #include "Scintilla.h" #include "SciLexer.h" + +static bool IsMatlabCommentChar(int c) { + return (c == '%') ; +} + +static bool IsOctaveCommentChar(int c) { + return (c == '%' || c == '#') ; +} + static bool IsMatlabComment(Accessor &styler, int pos, int len) { - return len > 0 && (styler[pos] == '%' || styler[pos] == '!') ; + return len > 0 && IsMatlabCommentChar(styler[pos]) ; +} + +static bool IsOctaveComment(Accessor &styler, int pos, int len) { + return len > 0 && IsOctaveCommentChar(styler[pos]) ; } static inline bool IsAWordChar(const int ch) { @@ -33,8 +50,10 @@ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) { +static void ColouriseMatlabOctaveDoc( + unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, + bool (*IsCommentChar)(int)) { WordList &keywords = *keywordlists[0]; @@ -81,9 +100,11 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, transpose = true; } } else if (sc.state == SCE_MATLAB_STRING) { - // Matlab doubles quotes to preserve them, so just end this string - // state now as a following quote will start again - if (sc.ch == '\'') { + if (sc.ch == '\'' && sc.chPrev != '\\') { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + } + } else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) { + if (sc.ch == '"' && sc.chPrev != '\\') { sc.ForwardSetState(SCE_MATLAB_DEFAULT); } } else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) { @@ -94,7 +115,7 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, } if (sc.state == SCE_MATLAB_DEFAULT) { - if (sc.ch == '%') { + if (IsCommentChar(sc.ch)) { sc.SetState(SCE_MATLAB_COMMENT); } else if (sc.ch == '!') { sc.SetState(SCE_MATLAB_COMMAND); @@ -104,6 +125,8 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, } else { sc.SetState(SCE_MATLAB_STRING); } + } else if (sc.ch == '"') { + sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING); } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { sc.SetState(SCE_MATLAB_NUMBER); } else if (isalpha(sc.ch)) { @@ -123,8 +146,20 @@ static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldMatlabDoc(unsigned int startPos, int length, int, - WordList *[], Accessor &styler) { +static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar); +} + +static void ColouriseOctaveDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar); +} + +static void FoldMatlabOctaveDoc(unsigned int startPos, int length, int, + WordList *[], Accessor &styler, + bool (*IsComment)(Accessor&,int,int)) { + int endPos = startPos + length; // Backtrack to previous line in case need to fix its fold status @@ -136,7 +171,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } } int spaceFlags = 0; - int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsMatlabComment); + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsComment); char chNext = styler[startPos]; for (int i = startPos; i < endPos; i++) { char ch = chNext; @@ -144,7 +179,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) { int lev = indentCurrent; - int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsMatlabComment); + int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsComment); if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { // Only non whitespace lines can be headers if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { @@ -152,7 +187,7 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { // Line after is blank so check the next - maybe should continue further? int spaceFlags2 = 0; - int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsMatlabComment); + int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsComment); if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { lev |= SC_FOLDLEVELHEADERFLAG; } @@ -165,9 +200,26 @@ static void FoldMatlabDoc(unsigned int startPos, int length, int, } } +static void FoldMatlabDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment); +} + +static void FoldOctaveDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment); +} + static const char * const matlabWordListDesc[] = { "Keywords", 0 }; +static const char * const octaveWordListDesc[] = { + "Keywords", + 0 +}; + LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc, matlabWordListDesc); + +LexerModule lmOctave(SCLEX_OCTAVE, ColouriseOctaveDoc, "octave", FoldOctaveDoc, octaveWordListDesc); diff --git a/src/stc/scintilla/src/LexMetapost.cxx b/src/stc/scintilla/src/LexMetapost.cxx new file mode 100644 index 0000000000..b7d482c0f1 --- /dev/null +++ b/src/stc/scintilla/src/LexMetapost.cxx @@ -0,0 +1,320 @@ +// Scintilla source code edit control + +// File: LexMetapost.cxx - general context conformant metapost coloring scheme +// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com +// Version: September 28, 2003 + +// Copyright: 1998-2003 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// This lexer is derived from the one written for the texwork environment (1999++) which in +// turn is inspired on texedit (1991++) which finds its roots in wdt (1986). + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "StyleContext.h" + +// val SCE_METAPOST_DEFAULT = 0 +// val SCE_METAPOST_SPECIAL = 1 +// val SCE_METAPOST_GROUP = 2 +// val SCE_METAPOST_SYMBOL = 3 +// val SCE_METAPOST_COMMAND = 4 +// val SCE_METAPOST_TEXT = 5 + +// Definitions in SciTEGlobal.properties: +// +// Metapost Highlighting +// +// # Default +// style.metapost.0=fore:#7F7F00 +// # Special +// style.metapost.1=fore:#007F7F +// # Group +// style.metapost.2=fore:#880000 +// # Symbol +// style.metapost.3=fore:#7F7F00 +// # Command +// style.metapost.4=fore:#008800 +// # Text +// style.metapost.5=fore:#000000 + +// lexer.tex.comment.process=0 + +// Auxiliary functions: + +static inline bool endOfLine(Accessor &styler, unsigned int i) { + return + (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')) ; +} + +static inline bool isMETAPOSTcomment(int ch) { + return + (ch == '%') ; +} + +static inline bool isMETAPOSTone(int ch) { + return + (ch == '[') || (ch == ']') || (ch == '(') || (ch == ')') || + (ch == ':') || (ch == '=') || (ch == '<') || (ch == '>') || + (ch == '{') || (ch == '}') || (ch == '\'') || (ch == '\"') ; +} + +static inline bool isMETAPOSTtwo(int ch) { + return + (ch == ';') || (ch == '$') || (ch == '@') || (ch == '#'); +} + +static inline bool isMETAPOSTthree(int ch) { + return + (ch == '.') || (ch == '-') || (ch == '+') || (ch == '/') || + (ch == '*') || (ch == ',') || (ch == '|') || (ch == '`') || + (ch == '!') || (ch == '?') || (ch == '^') || (ch == '&') || + (ch == '%') ; +} + +static inline bool isMETAPOSTidentifier(int ch) { + return + ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || + (ch == '_') ; +} + +static inline bool isMETAPOSTnumber(int ch) { + return + (ch >= '0') && (ch <= '9') ; +} + +static inline bool isMETAPOSTstring(int ch) { + return + (ch == '\"') ; +} + +static inline bool isMETAPOSTcolon(int ch) { + return + (ch == ':') ; +} + +static inline bool isMETAPOSTequal(int ch) { + return + (ch == '=') ; +} + +static int CheckMETAPOSTInterface( + unsigned int startPos, + int length, + Accessor &styler, + int defaultInterface) { + + char lineBuffer[1024] ; + unsigned int linePos = 0 ; + + // some day we can make something lexer.metapost.mapping=(none,0)(metapost,1)(mp,1)(metafun,2)... + + if (styler.SafeGetCharAt(0) == '%') { + for (unsigned int i = 0; i < startPos + length; i++) { + lineBuffer[linePos++] = styler.SafeGetCharAt(i) ; + if (endOfLine(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + lineBuffer[linePos] = '\0'; + if (strstr(lineBuffer, "interface=none")) { + return 0 ; + } else if (strstr(lineBuffer, "interface=metapost") || strstr(lineBuffer, "interface=mp")) { + return 1 ; + } else if (strstr(lineBuffer, "interface=metafun")) { + return 2 ; + } else if (styler.SafeGetCharAt(1) == 'D' && strstr(lineBuffer, "%D \\module")) { + // better would be to limit the search to just one line + return 2 ; + } else { + return defaultInterface ; + } + } + } + } + + return defaultInterface ; +} + +static void ColouriseMETAPOSTDoc( + unsigned int startPos, + int length, + int, + WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos) ; + styler.StartSegment(startPos) ; + + bool processComment = styler.GetPropertyInt("lexer.metapost.comment.process", 0) == 1 ; + int defaultInterface = styler.GetPropertyInt("lexer.metapost.interface.default", 1) ; + + int currentInterface = CheckMETAPOSTInterface(startPos,length,styler,defaultInterface) ; + + // 0 no keyword highlighting + // 1 metapost keyword hightlighting + // 2+ metafun keyword hightlighting + + int extraInterface = 0 ; + + if (currentInterface != 0) { + extraInterface = currentInterface ; + } + + WordList &keywords = *keywordlists[0] ; + WordList &keywords2 = *keywordlists[extraInterface-1] ; + + StyleContext sc(startPos, length, SCE_METAPOST_TEXT, styler) ; + + char key[100] ; + + bool inTeX = false ; + bool inComment = false ; + bool inString = false ; + bool inClause = false ; + + bool going = sc.More() ; // needed because of a fuzzy end of file state + + for (; going; sc.Forward()) { + + if (! sc.More()) { going = false ; } // we need to go one behind the end of text + + if (inClause) { + sc.SetState(SCE_METAPOST_TEXT) ; + inClause = false ; + } + + if (inComment) { + if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; // not correct but we want to stimulate one-lines + } + } else if (inString) { + if (isMETAPOSTstring(sc.ch)) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + sc.ForwardSetState(SCE_METAPOST_TEXT) ; + inString = false ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; // not correct but we want to stimulate one-lines + } + } else { + if ((! isMETAPOSTidentifier(sc.ch)) && (sc.LengthCurrent() > 0)) { + if (sc.state == SCE_METAPOST_COMMAND) { + sc.GetCurrent(key, sizeof(key)) ; + if ((strcmp(key,"btex") == 0) || (strcmp(key,"verbatimtex") == 0)) { + sc.ChangeState(SCE_METAPOST_GROUP) ; + inTeX = true ; + } else if (inTeX) { + if (strcmp(key,"etex") == 0) { + sc.ChangeState(SCE_METAPOST_GROUP) ; + inTeX = false ; + } else { + sc.ChangeState(SCE_METAPOST_TEXT) ; + } + } else { + if (keywords && keywords.InList(key)) { + sc.ChangeState(SCE_METAPOST_COMMAND) ; + } else if (keywords2 && keywords2.InList(key)) { + sc.ChangeState(SCE_METAPOST_EXTRA) ; + } else { + sc.ChangeState(SCE_METAPOST_TEXT) ; + } + } + } + } + if (isMETAPOSTcomment(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SYMBOL) ; + sc.ForwardSetState(SCE_METAPOST_DEFAULT) ; + inComment = ! processComment ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTstring(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + if (! isMETAPOSTstring(sc.chNext)) { + sc.ForwardSetState(SCE_METAPOST_TEXT) ; + } + inString = true ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTcolon(sc.ch)) { + if (! inTeX) { + if (! isMETAPOSTequal(sc.chNext)) { + sc.SetState(SCE_METAPOST_COMMAND) ; + inClause = true ; + } else { + sc.SetState(SCE_METAPOST_SPECIAL) ; + } + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTone(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SPECIAL) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTtwo(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_GROUP) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTthree(sc.ch)) { + if (! inTeX) { + sc.SetState(SCE_METAPOST_SYMBOL) ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } else if (isMETAPOSTidentifier(sc.ch)) { + if (sc.state != SCE_METAPOST_COMMAND) { + sc.SetState(SCE_METAPOST_TEXT) ; + sc.ChangeState(SCE_METAPOST_COMMAND) ; + } + } else if (isMETAPOSTnumber(sc.ch)) { + // rather redundant since for the moment we don't handle numbers + sc.SetState(SCE_METAPOST_TEXT) ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_METAPOST_TEXT) ; + inTeX = false ; + inComment = false ; + inClause = false ; + inString = false ; + } else { + sc.SetState(SCE_METAPOST_TEXT) ; + } + } + + } + + sc.Complete(); + +} + +// Hooks info the system: + +static const char * const metapostWordListDesc[] = { + "MetaPost", + "MetaFun", + 0 +} ; + +LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", 0, metapostWordListDesc); diff --git a/src/stc/scintilla/src/LexOthers.cxx b/src/stc/scintilla/src/LexOthers.cxx index 31ac415ad4..819dd31290 100644 --- a/src/stc/scintilla/src/LexOthers.cxx +++ b/src/stc/scintilla/src/LexOthers.cxx @@ -427,6 +427,12 @@ static void ColouriseErrorListLine( styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION); } else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') { styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE); + } else if (strstart(lineBuffer, "cf90-")) { + // Absoft Pro Fortran 90/95 v8.2 error and/or warning message + styler.ColourTo(endPos, SCE_ERR_ABSF); + } else if (strstart(lineBuffer, "fortcom:")) { + // Intel Fortran Compiler v8.0 error/warning message + styler.ColourTo(endPos, SCE_ERR_IFORT); } else if (lineBuffer[0] == '-') { styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION); } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) { diff --git a/src/stc/scintilla/src/LexPB.cxx b/src/stc/scintilla/src/LexPB.cxx new file mode 100644 index 0000000000..d35944ecf7 --- /dev/null +++ b/src/stc/scintilla/src/LexPB.cxx @@ -0,0 +1,228 @@ +// Scintilla source code edit control +/** @file LexPB.cxx + ** Lexer for PowerBasic by Roland Walter, roland@rowalt.de + ** Last update: 17.10.2003 (toggling of subs/functions now until next sub/functin - this gives better results) + **/ +// +// Necessary changes in Scintilla project: +// - In SciLexer.h and Scintilla.iface: +// +// #define SCLEX_PB 51 //ID for PowerBasic lexer +// (...) +// #define SCE_B_DEFAULT 0 //in both VB and PB lexer +// #define SCE_B_COMMENT 1 //in both VB and PB lexer +// #define SCE_B_NUMBER 2 //in both VB and PB lexer +// #define SCE_B_KEYWORD 3 //in both VB and PB lexer +// #define SCE_B_STRING 4 //in both VB and PB lexer +// #define SCE_B_PREPROCESSOR 5 //VB lexer only, unsupported by PB lexer +// #define SCE_B_OPERATOR 6 //in both VB and PB lexer +// #define SCE_B_IDENTIFIER 7 //in both VB and PB lexer +// #define SCE_B_DATE 8 //VB lexer only, unsupported by PB lexer + +// - Statement added to KeyWords.cxx: 'LINK_LEXER(lmPB);' +// - Statement added to scintilla_vc6.mak: '$(DIR_O)\LexPB.obj: ...\src\LexPB.cxx $(LEX_HEADERS)' +// +// Copyright for Scintilla: 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static inline bool IsTypeCharacter(const int ch) { + return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$'; +} + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); +} + +static inline bool IsAWordStart(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_'); +} + +bool MatchUpperCase(Accessor &styler, int pos, const char *s) //Same as styler.Match() but uppercase comparison (a-z,A-Z and space only) +{ + char ch; + for (int i=0; *s; i++) + { + ch=styler.SafeGetCharAt(pos+i); + if (ch > 0x60) ch -= '\x20'; + if (*s != ch) return false; + s++; + } + return true; +} + +static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[], + Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + + styler.StartAt(startPos); + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + if (sc.state == SCE_B_OPERATOR) + { + sc.SetState(SCE_B_DEFAULT); + } + else if (sc.state == SCE_B_KEYWORD) + { + if (!IsAWordChar(sc.ch)) + { + if (!IsTypeCharacter(sc.ch)) + { + if (sc.ch == ']') {sc.Forward();} + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) + { + if (strcmp(s, "rem") == 0) + { + sc.ChangeState(SCE_B_COMMENT); + if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);} + } + else + { + sc.SetState(SCE_B_DEFAULT); + } + } + else + { + sc.ChangeState(SCE_B_IDENTIFIER); + sc.SetState(SCE_B_DEFAULT); + } + } + } + } + else if (sc.state == SCE_B_NUMBER) + { + if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);} + } + else if (sc.state == SCE_B_STRING) + { + // PB doubles quotes to preserve them, so just end this string + // state now as a following quote will start again + if (sc.ch == '\"') + { + if (tolower(sc.chNext) == 'c') {sc.Forward();} + sc.ForwardSetState(SCE_B_DEFAULT); + } + } + else if (sc.state == SCE_B_COMMENT) + { + if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);} + } + + if (sc.state == SCE_B_DEFAULT) + { + if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);} + else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);} + else if (sc.ch == '#') + { int n = 1; + int chSeek = ' '; + while ((n < 100) && (chSeek == ' ' || chSeek == '\t')) + { + chSeek = sc.GetRelative(n); + n++; + } + sc.SetState(SCE_B_OPERATOR); + } + else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);} + else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);} + else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);} + else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);} + else if (IsAWordStart(sc.ch) || (sc.ch == '[')) {sc.SetState(SCE_B_KEYWORD);} + else if (isoperator(static_cast(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);} + } + + } + sc.Complete(); +} + +static void FoldPBDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +{ + // No folding enabled, no reason to continue... + if( styler.GetPropertyInt("fold") == 0 ) + return; + + unsigned int endPos = startPos + length; + int lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + + bool atEOL=1; + for (unsigned int i = startPos; i < endPos; i++) + { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if( atEOL ) //Begin of a new line (The Sub/Function/Macro keywords may occur at begin of line only) + { + if( MatchUpperCase(styler,i,"FUNCTION") ) //else if( + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"CALLBACK FUNCTION") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"STATIC FUNCTION") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"SUB") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + else if( MatchUpperCase(styler,i,"STATIC SUB") ) + { + styler.SetLevel(lineCurrent, (SC_FOLDLEVELBASE << 16) | SC_FOLDLEVELHEADERFLAG); + levelNext=SC_FOLDLEVELBASE+1; + } + //else if( MatchUpperCase(styler,i,"MACRO") ) //ToDo: What's with single-line macros? + } + + atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if( atEOL ) + { + lineCurrent++; + levelCurrent = levelNext; + } + } + + if (levelNext == SC_FOLDLEVELBASE) + { + int levelUse = levelCurrent; + int lev = levelUse | levelNext << 16; + styler.SetLevel(lineCurrent, lev); + } +} + +static const char * const pbWordListDesc[] = { + "Keywords", + 0 +}; + +LexerModule lmPB(SCLEX_POWERBASIC, ColourisePBDoc, "powerbasic", FoldPBDoc, pbWordListDesc); diff --git a/src/stc/scintilla/src/LexPOV.cxx b/src/stc/scintilla/src/LexPOV.cxx index 33ba6a490f..0c1a21ab48 100644 --- a/src/stc/scintilla/src/LexPOV.cxx +++ b/src/stc/scintilla/src/LexPOV.cxx @@ -33,10 +33,18 @@ static inline bool IsAWordChar(const int ch) { return ch < 0x80 && (isalnum(ch) || ch == '_'); } -inline bool IsAWordStart(const int ch) { +static inline bool IsAWordStart(const int ch) { return ch < 0x80 && isalpha(ch); } +static inline bool IsANumberChar(const int ch) { + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. + return (ch < 0x80) && + (isdigit(ch) || toupper(ch) == 'E' || + ch == '.' || ch == '-' || ch == '+'); +} + static void ColourisePovDoc( unsigned int startPos, int length, @@ -91,11 +99,8 @@ static void ColourisePovDoc( sc.SetState(SCE_POV_DEFAULT); } else if (sc.state == SCE_POV_NUMBER) { // We stop the number definition on non-numerical non-dot non-eE non-sign char - if (!(isdigit(sc.ch) || sc.ch == '.' || - toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) { - // Not exactly following number definition (several dots are seen as OK, etc.) - // but probably enough in most cases. - sc.SetState(SCE_POV_DEFAULT); + if (!IsANumberChar(sc.ch)) { + sc.SetState(SCE_POV_DEFAULT); } } else if (sc.state == SCE_POV_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { diff --git a/src/stc/scintilla/src/LexPerl.cxx b/src/stc/scintilla/src/LexPerl.cxx index 211c3b8751..16a068778e 100644 --- a/src/stc/scintilla/src/LexPerl.cxx +++ b/src/stc/scintilla/src/LexPerl.cxx @@ -2,7 +2,8 @@ /** @file LexPerl.cxx ** Lexer for subset of Perl. **/ -// Copyright 1998-2001 by Neil Hodgson +// Lexical analysis fixes by Kein-Hong Man 20031020 +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -19,6 +20,14 @@ #include "Scintilla.h" #include "SciLexer.h" +#define PERLNUM_DECIMAL 1 +#define PERLNUM_NON_DEC 2 +#define PERLNUM_FLOAT 3 +#define PERLNUM_VECTOR 4 +#define PERLNUM_V_VECTOR 5 + +#define HERE_DELIM_MAX 256 + static inline bool isEOLChar(char ch) { return (ch == '\r') || (ch == '\n'); } @@ -31,9 +40,6 @@ static bool isSingleCharOp(char ch) { } static inline bool isPerlOperator(char ch) { - if (isalnum(ch)) - return false; - // '.' left out as it is used to make up numbers if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' || ch == '(' || ch == ')' || ch == '-' || ch == '+' || ch == '=' || ch == '|' || ch == '{' || ch == '}' || @@ -46,18 +52,13 @@ static inline bool isPerlOperator(char ch) { static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { char s[100]; - bool wordIsNumber = isdigit(styler[start]) || (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_PL_IDENTIFIER; - if (wordIsNumber) - chAttr = SCE_PL_NUMBER; - else { - if (keywords.InList(s)) - chAttr = SCE_PL_WORD; - } + if (keywords.InList(s)) + chAttr = SCE_PL_WORD; styler.ColourTo(end, chAttr); return chAttr; } @@ -67,6 +68,23 @@ static inline bool isEndVar(char ch) { ch != '_' && ch != '\''; } +static inline bool isNonQuote(char ch) { + return isalnum(ch) || ch == '_'; +} + +static inline char actualNumStyle(int numberStyle) { + switch (numberStyle) { + case PERLNUM_VECTOR: + case PERLNUM_V_VECTOR: + return SCE_PL_STRING; + case PERLNUM_DECIMAL: + case PERLNUM_NON_DEC: + case PERLNUM_FLOAT: + default: + return SCE_PL_NUMBER; + } +} + static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) { if ((pos + static_cast(strlen(val))) >= lengthDoc) { return false; @@ -109,12 +127,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, char Quote; // the char after '<<' bool Quoted; // true if Quote in ('\'','"','`') int DelimiterLength; // strlen(Delimiter) - char Delimiter[256]; // the Delimiter, 256: sizeof PL_tokenbuf + char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf HereDocCls() { State = 0; DelimiterLength = 0; + Delimiter = new char[HERE_DELIM_MAX]; Delimiter[0] = '\0'; } + ~HereDocCls() { + delete []Delimiter; + } }; HereDocCls HereDoc; // TODO: FIFO for stacked here-docs @@ -141,14 +163,17 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, }; QuoteCls Quote; - char sooked[100]; - int sookedpos = 0; - bool preferRE = true; - sooked[sookedpos] = '\0'; int state = initStyle; + char numState = PERLNUM_DECIMAL; + int dotCount = 0; unsigned int lengthDoc = startPos + length; + //int sookedpos = 0; // these have no apparent use, see POD state + //char sooked[100]; + //sooked[sookedpos] = '\0'; - // If in a long distance lexical state, seek to the beginning to find quote characters + // If in a long distance lexical state, seek to the beginning to find quote characters + // Perl strings can be multi-line with embedded newlines, so backtrack. + // Perl numbers have additional state during lexing, so backtrack too. if (state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX) { while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_PL_HERE_DELIM)) { startPos--; @@ -163,6 +188,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, || state == SCE_PL_STRING_QW || state == SCE_PL_REGEX || state == SCE_PL_REGSUBST + || state == SCE_PL_STRING + || state == SCE_PL_BACKTICKS + || state == SCE_PL_CHARACTER + || state == SCE_PL_NUMBER ) { while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) { startPos--; @@ -179,6 +208,9 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, for (unsigned int i = startPos; i < lengthDoc; i++) { char ch = chNext; + // if the current character is not consumed due to the completion of an + // earlier style, lexing can be restarted via a simple goto + restartLexer: chNext = styler.SafeGetCharAt(i + 1); char chNext2 = styler.SafeGetCharAt(i + 2); @@ -189,32 +221,36 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, continue; } if ((chPrev == '\r' && ch == '\n')) { // skip on DOS/Windows + styler.ColourTo(i, state); chPrev = ch; continue; } if (HereDoc.State == 1 && isEOLChar(ch)) { // Begin of here-doc (the line after the here-doc delimiter): + // Lexically, the here-doc starts from the next line after the >>, but the + // first line of here-doc seem to follow the style of the last EOL sequence HereDoc.State = 2; - styler.ColourTo(i - 1, state); if (HereDoc.Quoted) { if (state == SCE_PL_HERE_DELIM) { // Missing quote at end of string! We are stricter than perl. + // Colour here-doc anyway while marking this bit as an error. state = SCE_PL_ERROR; - } else { - switch (HereDoc.Quote) { - case '\'': - state = SCE_PL_HERE_Q ; - break; - case '"': - state = SCE_PL_HERE_QQ; - break; - case '`': - state = SCE_PL_HERE_QX; - break; - } + } + styler.ColourTo(i - 1, state); + switch (HereDoc.Quote) { + case '\'': + state = SCE_PL_HERE_Q ; + break; + case '"': + state = SCE_PL_HERE_QQ; + break; + case '`': + state = SCE_PL_HERE_QX; + break; } } else { + styler.ColourTo(i - 1, state); switch (HereDoc.Quote) { case '\\': state = SCE_PL_HERE_Q ; @@ -226,26 +262,37 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } if (state == SCE_PL_DEFAULT) { - if (iswordstart(ch)) { - styler.ColourTo(i - 1, state); - if (ch == 's' && !isalnum(chNext)) { + if (isdigit(ch) || (isdigit(chNext) && + (ch == '.' || ch == 'v'))) { + state = SCE_PL_NUMBER; + numState = PERLNUM_DECIMAL; + dotCount = 0; + if (ch == '0') { // hex,bin,octal + if (chNext == 'x' || chNext == 'b' || isdigit(chNext)) { + numState = PERLNUM_NON_DEC; + } + } else if (ch == 'v') { // vector + numState = PERLNUM_V_VECTOR; + } + } else if (iswordstart(ch)) { + if (ch == 's' && !isNonQuote(chNext)) { state = SCE_PL_REGSUBST; Quote.New(2); - } else if (ch == 'm' && !isalnum(chNext)) { + } else if (ch == 'm' && !isNonQuote(chNext)) { state = SCE_PL_REGEX; Quote.New(1); - } else if (ch == 'q' && !isalnum(chNext)) { + } else if (ch == 'q' && !isNonQuote(chNext)) { state = SCE_PL_STRING_Q; Quote.New(1); - } else if (ch == 'y' && !isalnum(chNext)) { + } else if (ch == 'y' && !isNonQuote(chNext)) { state = SCE_PL_REGSUBST; Quote.New(2); - } else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) { + } else if (ch == 't' && chNext == 'r' && !isNonQuote(chNext2)) { state = SCE_PL_REGSUBST; Quote.New(2); i++; chNext = chNext2; - } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) { + } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isNonQuote(chNext2)) { if (chNext == 'q') state = SCE_PL_STRING_QQ; else if (chNext == 'x') state = SCE_PL_STRING_QX; else if (chNext == 'r') state = SCE_PL_STRING_QR; @@ -253,9 +300,12 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, i++; chNext = chNext2; Quote.New(1); + } else if (ch == 'x' && (chNext == '=' || // repetition + (chNext != '_' && !isalnum(chNext)) || + (isdigit(chPrev) && isdigit(chNext)))) { + styler.ColourTo(i, SCE_PL_OPERATOR); } else { state = SCE_PL_WORD; - preferRE = false; if ((!iswordchar(chNext) && chNext != '\'') || (chNext == '.' && chNext2 == '.')) { // We need that if length of word == 1! @@ -265,10 +315,8 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } } } else if (ch == '#') { - styler.ColourTo(i - 1, state); state = SCE_PL_COMMENTLINE; } else if (ch == '\"') { - styler.ColourTo(i - 1, state); state = SCE_PL_STRING; Quote.New(1); Quote.Open(ch); @@ -277,31 +325,32 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, // Archaic call styler.ColourTo(i, state); } else { - styler.ColourTo(i - 1, state); state = SCE_PL_CHARACTER; Quote.New(1); Quote.Open(ch); } } else if (ch == '`') { - styler.ColourTo(i - 1, state); state = SCE_PL_BACKTICKS; Quote.New(1); Quote.Open(ch); } else if (ch == '$') { - preferRE = false; - styler.ColourTo(i - 1, state); if ((chNext == '{') || isspacechar(chNext)) { styler.ColourTo(i, SCE_PL_SCALAR); } else { state = SCE_PL_SCALAR; - i++; - ch = chNext; - chNext = chNext2; + if (chNext == '`' && chNext2 == '`') { + i += 2; + ch = styler.SafeGetCharAt(i); + chNext = styler.SafeGetCharAt(i + 1); + } else { + i++; + ch = chNext; + chNext = chNext2; + } } } else if (ch == '@') { - preferRE = false; - styler.ColourTo(i - 1, state); - if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { + if (isalpha(chNext) || chNext == '#' || chNext == '$' + || chNext == '_' || chNext == '+') { state = SCE_PL_ARRAY; } else if (chNext != '{' && chNext != '[') { styler.ColourTo(i, SCE_PL_ARRAY); @@ -311,8 +360,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, styler.ColourTo(i, SCE_PL_ARRAY); } } else if (ch == '%') { - preferRE = false; - styler.ColourTo(i - 1, state); if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { state = SCE_PL_HASH; } else if (chNext == '{') { @@ -321,56 +368,189 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, styler.ColourTo(i, SCE_PL_OPERATOR); } } else if (ch == '*') { - styler.ColourTo(i - 1, state); - state = SCE_PL_SYMBOLTABLE; - } else if (ch == '/' && preferRE) { - styler.ColourTo(i - 1, state); - state = SCE_PL_REGEX; - Quote.New(1); - Quote.Open(ch); + if (isalpha(chNext) || chNext == '_' || chNext == '{') { + state = SCE_PL_SYMBOLTABLE; + } else { + if (chNext == '*') { // exponentiation + i++; + ch = chNext; + chNext = chNext2; + } + styler.ColourTo(i, SCE_PL_OPERATOR); + } + } else if (ch == '/') { + // Explicit backward peeking to set a consistent preferRE for + // any slash found, so no longer need to track preferRE state. + // Find first previous significant lexed element and interpret. + bool preferRE = false; + unsigned int bk = (i > 0)? i - 1: 0; + char bkch; + styler.Flush(); + while ((bk > 0) && (styler.StyleAt(bk) == SCE_PL_DEFAULT || + styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) { + bk--; + } + if (bk == 0) { + preferRE = true; + } else { + int bkstyle = styler.StyleAt(bk); + switch(bkstyle) { + case SCE_PL_OPERATOR: + preferRE = true; + bkch = styler.SafeGetCharAt(bk); + if (bkch == ')' || bkch == ']') { + preferRE = false; + } else if (bkch == '}') { + // backtrack further, count balanced brace pairs + // if a brace pair found, see if it's a variable + int braceCount = 1; + while (--bk > 0) { + bkstyle = styler.StyleAt(bk); + if (bkstyle == SCE_PL_OPERATOR) { + bkch = styler.SafeGetCharAt(bk); + if (bkch == '}') { + braceCount++; + } else if (bkch == '{') { + if (--braceCount == 0) + break; + } + } + } + if (bk == 0) { + // at beginning, true + } else if (braceCount == 0) { + // balanced { found, check for variable + bkstyle = styler.StyleAt(bk - 1); + if (bkstyle == SCE_PL_SCALAR + || bkstyle == SCE_PL_ARRAY + || bkstyle == SCE_PL_HASH + || bkstyle == SCE_PL_SYMBOLTABLE) { + preferRE = false; + } + } + } + break; + // other styles uses the default, preferRE=false + case SCE_PL_IDENTIFIER: + case SCE_PL_POD: + case SCE_PL_WORD: + case SCE_PL_HERE_Q: + case SCE_PL_HERE_QQ: + case SCE_PL_HERE_QX: + preferRE = true; + break; + } + } + if (preferRE) { + state = SCE_PL_REGEX; + Quote.New(1); + Quote.Open(ch); + } else { + styler.ColourTo(i, SCE_PL_OPERATOR); + } } else if (ch == '<' && chNext == '<') { - styler.ColourTo(i - 1, state); state = SCE_PL_HERE_DELIM; HereDoc.State = 0; - } else if (ch == '=' + } else if (ch == '=' // POD && isalpha(chNext) && (isEOLChar(chPrev))) { - styler.ColourTo(i - 1, state); state = SCE_PL_POD; - sookedpos = 0; - sooked[sookedpos] = '\0'; - } else if (ch == '-' + //sookedpos = 0; + //sooked[sookedpos] = '\0'; + } else if (ch == '-' // file test operators && isSingleCharOp(chNext) && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) { - styler.ColourTo(i - 1, state); styler.ColourTo(i + 1, SCE_PL_WORD); state = SCE_PL_DEFAULT; - preferRE = false; - i += 2; - ch = chNext2; - chNext = chNext2 = styler.SafeGetCharAt(i + 1); + i++; + ch = chNext; + chNext = chNext2; } else if (isPerlOperator(ch)) { - if (ch == ')' || ch == ']') - preferRE = false; - else - preferRE = true; - styler.ColourTo(i - 1, state); + if (ch == '.' && chNext == '.') { // .. and ... + i++; + if (chNext2 == '.') { i++; } + state = SCE_PL_DEFAULT; + ch = styler.SafeGetCharAt(i); + chNext = styler.SafeGetCharAt(i + 1); + } styler.ColourTo(i, SCE_PL_OPERATOR); + } else { + // keep colouring defaults to make restart easier + styler.ColourTo(i, SCE_PL_DEFAULT); + } + } else if (state == SCE_PL_NUMBER) { + if (ch == '.') { + if (chNext == '.') { + // double dot is always an operator + goto numAtEnd; + } else if (numState == PERLNUM_NON_DEC || numState == PERLNUM_FLOAT) { + // non-decimal number or float exponent, consume next dot + styler.ColourTo(i - 1, SCE_PL_NUMBER); + styler.ColourTo(i, SCE_PL_OPERATOR); + state = SCE_PL_DEFAULT; + } else { // decimal or vectors allows dots + dotCount++; + if (numState == PERLNUM_DECIMAL) { + if (dotCount > 1) { + if (isdigit(chNext)) { // really a vector + numState = PERLNUM_VECTOR; + } else // number then dot + goto numAtEnd; + } + } else { // vectors + if (!isdigit(chNext)) // vector then dot + goto numAtEnd; + } + } + } else if (ch == '_' && numState == PERLNUM_DECIMAL) { + if (!isdigit(chNext)) { + goto numAtEnd; + } + } else if (isalnum(ch)) { + if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) { + if (isalpha(ch)) { + if (dotCount == 0) { // change to word + state = SCE_PL_WORD; + } else { // vector then word + goto numAtEnd; + } + } + } else if (numState == PERLNUM_DECIMAL) { + if (ch == 'E' || ch == 'e') { // exponent + numState = PERLNUM_FLOAT; + if (chNext == '+' || chNext == '-') { + i++; + ch = chNext; + chNext = chNext2; + } + } else if (!isdigit(ch)) { // number then word + goto numAtEnd; + } + } else if (numState == PERLNUM_FLOAT) { + if (!isdigit(ch)) { // float then word + goto numAtEnd; + } + } else {// (numState == PERLNUM_NON_DEC) + // allow alphanum for bin,hex,oct for now + } + } else { + // complete current number or vector + numAtEnd: + styler.ColourTo(i - 1, actualNumStyle(numState)); + state = SCE_PL_DEFAULT; + goto restartLexer; } } else if (state == SCE_PL_WORD) { if ((!iswordchar(chNext) && chNext != '\'') || (chNext == '.' && chNext2 == '.')) { // ".." is always an operator if preceded by a SCE_PL_WORD. // Archaic Perl has quotes inside names - if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) { - styler.ColourTo(i, SCE_PL_DATASECTION); - state = SCE_PL_DATASECTION; - } else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) { + if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__") + || isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) { styler.ColourTo(i, SCE_PL_DATASECTION); state = SCE_PL_DATASECTION; } else { - if (classifyWordPerl(styler.GetStartSegment(), i, keywords, styler) == SCE_PL_WORD) - preferRE = true; + classifyWordPerl(styler.GetStartSegment(), i, keywords, styler); state = SCE_PL_DEFAULT; ch = ' '; } @@ -380,6 +560,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, if (isEOLChar(ch)) { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; + goto restartLexer; + } else if (isEOLChar(chNext)) { + styler.ColourTo(i, state); + state = SCE_PL_DEFAULT; } } else if (state == SCE_PL_HERE_DELIM) { // @@ -398,9 +582,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, // There must be no space between the << and the identifier. // (If you put a space it will be treated as a null identifier, // which is valid, and matches the first empty line.) + // (This is deprecated, -w warns of this syntax) // The terminating string must appear by itself (unquoted and with no // surrounding whitespace) on the terminating line. // + // From Bash info: + // --------------- + // Specifier format is: <<[-]WORD + // Optional '-' is for removal of leading tabs from here-doc. + // Whitespace acceptable after <<[-] operator. + // if (HereDoc.State == 0) { // '<<' encountered HereDoc.State = 1; HereDoc.Quote = chNext; @@ -412,15 +603,16 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, ch = chNext; chNext = chNext2; HereDoc.Quoted = true; - } else if (chNext == '\\') { // ref? - i++; - ch = chNext; - chNext = chNext2; - } else if (isalnum(chNext) || chNext == '_') { // an unquoted here-doc delimiter - } - else if (isspacechar(chNext)) { // deprecated here-doc delimiter || TODO: left shift operator - } - else { // TODO: ??? + } else if (isalpha(chNext) || chNext == '_') { + // an unquoted here-doc delimiter, no special handling + } else if (isspacechar(chNext) || isdigit(chNext) || chNext == '\\' + || chNext == '=' || chNext == '$' || chNext == '@') { + // left shift << or <<= operator cases + styler.ColourTo(i, SCE_PL_OPERATOR); + state = SCE_PL_DEFAULT; + HereDoc.State = 0; + } else { + // symbols terminates; deprecated zero-length delimiter } } else if (HereDoc.State == 1) { // collect the delimiter @@ -428,9 +620,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, if (ch == HereDoc.Quote) { // closing quote => end of delimiter styler.ColourTo(i, state); state = SCE_PL_DEFAULT; - i++; - ch = chNext; - chNext = chNext2; } else { if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote i++; @@ -447,24 +636,27 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } else { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; + goto restartLexer; } } - if (HereDoc.DelimiterLength >= static_cast(sizeof(HereDoc.Delimiter)) - 1) { + if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { styler.ColourTo(i - 1, state); state = SCE_PL_ERROR; + goto restartLexer; } } } else if (HereDoc.State == 2) { // state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX if (isEOLChar(chPrev) && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) { i += HereDoc.DelimiterLength; - chNext = styler.SafeGetCharAt(i); - if (isEOLChar(chNext)) { + chPrev = styler.SafeGetCharAt(i - 1); + ch = styler.SafeGetCharAt(i); + if (isEOLChar(ch)) { styler.ColourTo(i - 1, state); state = SCE_PL_DEFAULT; HereDoc.State = 0; + goto restartLexer; } - ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } } else if (state == SCE_PL_POD) { @@ -474,33 +666,30 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, i += 4; state = SCE_PL_DEFAULT; ch = styler.SafeGetCharAt(i); - chNext = styler.SafeGetCharAt(i + 1); + //chNext = styler.SafeGetCharAt(i + 1); + goto restartLexer; } } - } else if (state == SCE_PL_SCALAR) { - if (isEndVar(ch)) { - if (i == (styler.GetStartSegment() + 1)) { + } else if (state == SCE_PL_SCALAR // variable names + || state == SCE_PL_ARRAY + || state == SCE_PL_HASH + || state == SCE_PL_SYMBOLTABLE) { + if (ch == ':' && chNext == ':') { // skip :: + i++; + ch = chNext; + chNext = chNext2; + } + else if (isEndVar(ch)) { + if ((state == SCE_PL_SCALAR || state == SCE_PL_ARRAY) + && i == (styler.GetStartSegment() + 1)) { // Special variable: $(, $_ etc. styler.ColourTo(i, state); + state = SCE_PL_DEFAULT; } else { styler.ColourTo(i - 1, state); + state = SCE_PL_DEFAULT; + goto restartLexer; } - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_ARRAY) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_HASH) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; - } - } else if (state == SCE_PL_SYMBOLTABLE) { - if (isEndVar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_PL_DEFAULT; } } else if (state == SCE_PL_REGEX || state == SCE_PL_STRING_QR @@ -627,29 +816,6 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, Quote.Count++; } } - - if (state == SCE_PL_DEFAULT) { // One of the above succeeded - if (ch == '#') { - state = SCE_PL_COMMENTLINE; - } else if (ch == '\"') { - state = SCE_PL_STRING; - Quote.New(1); - Quote.Open(ch); - } else if (ch == '\'') { - state = SCE_PL_CHARACTER; - Quote.New(1); - Quote.Open(ch); - } else if (iswordstart(ch)) { - state = SCE_PL_WORD; - preferRE = false; - } else if (isPerlOperator(ch)) { - if (ch == ')' || ch == ']') - preferRE = false; - else - preferRE = true; - styler.ColourTo(i, SCE_PL_OPERATOR); - } - } } if (state == SCE_PL_ERROR) { break; diff --git a/src/stc/scintilla/src/LexRuby.cxx b/src/stc/scintilla/src/LexRuby.cxx index 43a874968d..692a47adef 100644 --- a/src/stc/scintilla/src/LexRuby.cxx +++ b/src/stc/scintilla/src/LexRuby.cxx @@ -96,6 +96,11 @@ static int GetRbStringState(Accessor &styler, int i, int *nextIndex) { return SCE_P_DEFAULT; } + if (i>0 && styler.SafeGetCharAt(i-1) == '$') { + *nextIndex = i + 1; + return SCE_P_DEFAULT; + } + if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) { *nextIndex = i + 3; diff --git a/src/stc/scintilla/src/LexSQL.cxx b/src/stc/scintilla/src/LexSQL.cxx index 3f65b12097..144176855e 100644 --- a/src/stc/scintilla/src/LexSQL.cxx +++ b/src/stc/scintilla/src/LexSQL.cxx @@ -88,7 +88,10 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, } else if (ch == '-' && chNext == '-') { styler.ColourTo(i - 1, state); state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + styler.ColourTo(i - 1, state); + state = SCE_C_CHARACTER; + } else if (ch == '"') { styler.ColourTo(i - 1, state); state = SCE_C_STRING; } else if (isoperator(ch)) { @@ -103,7 +106,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_C_COMMENT; } else if (ch == '-' && chNext == '-') { state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (ch == '"') { state = SCE_C_STRING; } else if (isoperator(ch)) { styler.ColourTo(i, SCE_C_OPERATOR); @@ -123,7 +128,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, styler.ColourTo(i - 1, state); state = SCE_C_DEFAULT; } - } else if (state == SCE_C_STRING) { + } else if (state == SCE_C_CHARACTER) { if (ch == '\'') { if ( chNext == '\'' ) { i++; @@ -134,7 +139,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, } ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - } else if (ch == '"') { + } + } else if (state == SCE_C_STRING) { + if (ch == '"') { if (chNext == '"') { i++; } else { @@ -151,7 +158,9 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_C_COMMENT; } else if (ch == '-' && chNext == '-') { state = SCE_C_COMMENTLINE; - } else if ((ch == '\'') || (ch == '"')) { + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (ch == '"') { state = SCE_C_STRING; } else if (iswordstart(ch)) { state = SCE_C_WORD; diff --git a/src/stc/scintilla/src/LexScriptol.cxx b/src/stc/scintilla/src/LexScriptol.cxx index fda10e316c..faaa2d46df 100644 --- a/src/stc/scintilla/src/LexScriptol.cxx +++ b/src/stc/scintilla/src/LexScriptol.cxx @@ -19,32 +19,31 @@ static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) { - char s[100]; - bool wordIsNumber = isdigit(styler[start]) != 0; - 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 (wordIsNumber) chAttr = SCE_P_NUMBER; - else if (keywords.InList(s)) chAttr = SCE_P_WORD; + char s[100]; + bool wordIsNumber = isdigit(styler[start]) != 0; + for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) + { + s[i] = styler[start + i]; + s[i + 1] = '\0'; + } + char chAttr = SCE_SCRIPTOL_IDENTIFIER; + if (0 == strcmp(prevWord, "class")) chAttr = SCE_SCRIPTOL_CLASSNAME; + else if (wordIsNumber) chAttr = SCE_SCRIPTOL_NUMBER; + else if (keywords.InList(s)) chAttr = SCE_SCRIPTOL_KEYWORD; else for (unsigned int i = 0; i < end - start + 1; i++) // test dotted idents { - if (styler[start + 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); + styler.ColourTo(start + i - 1, chAttr); + styler.ColourTo(start + i, SCE_SCRIPTOL_OPERATOR); + } + } + styler.ColourTo(end, chAttr); + strcpy(prevWord, s); } static bool IsSolComment(Accessor &styler, int pos, int len) { -// return len > 0 && styler[pos]=='`'; char c; if(len > 0) { @@ -63,60 +62,62 @@ static bool IsSolComment(Accessor &styler, int pos, int len) return false; } -static bool IsSolStringStart(char ch, char /*chNext*/) +static bool IsSolStringStart(char ch) { if (ch == '\'' || ch == '"') return true; - //chNext = chNext; // for future use - - return false; + return false; } -static bool IsSolWordStart(char ch, char chNext) +static bool IsSolWordStart(char ch) { - return (iswordchar(ch) && !IsSolStringStart(ch, chNext)); + return (iswordchar(ch) && !IsSolStringStart(ch)); } -/* 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 GetSolStringState(Accessor &styler, int i, int *nextIndex) { char ch = styler.SafeGetCharAt(i); char chNext = styler.SafeGetCharAt(i + 1); - if (ch != '"' && ch != '\'') { - *nextIndex = i + 1; - return SCE_P_DEFAULT; + if (ch != '\"' && ch != '\'') + { + *nextIndex = i + 1; + return SCE_SCRIPTOL_DEFAULT; } - + // ch is either single or double quotes in string + // code below seem non-sense but is here for future extensions if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) - { - *nextIndex = i + 3; - if (ch == '"') return SCE_P_TRIPLEDOUBLE; - else return SCE_P_TRIPLE; + { + *nextIndex = i + 3; + if(ch == '\"') return SCE_SCRIPTOL_TRIPLE; + if(ch == '\'') return SCE_SCRIPTOL_TRIPLE; + return SCE_SCRIPTOL_STRING; } - else - { - *nextIndex = i + 1; - if (ch == '"') return SCE_P_STRING; - else return SCE_P_CHARACTER; + else + { + *nextIndex = i + 1; + if (ch == '"') return SCE_SCRIPTOL_STRING; + else return SCE_SCRIPTOL_STRING; } } + static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) + WordList *keywordlists[], Accessor &styler) { int lengthDoc = startPos + length; + char stringType = '\"'; - // Backtrack to previous line in case need to fix its tab whinging if (startPos > 0) - { - int lineCurrent = styler.GetLine(startPos); - if (lineCurrent > 0) { - startPos = styler.LineStart(lineCurrent-1); - if (startPos == 0) initStyle = SCE_P_DEFAULT; - else initStyle = styler.StyleAt(startPos-1); - } + int lineCurrent = styler.GetLine(startPos); + if (lineCurrent > 0) + { + startPos = styler.LineStart(lineCurrent-1); + if (startPos == 0) initStyle = SCE_SCRIPTOL_DEFAULT; + else initStyle = styler.StyleAt(startPos-1); + } } styler.StartAt(startPos, 127); @@ -126,241 +127,216 @@ static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); char prevWord[200]; prevWord[0] = '\0'; - if (length == 0) return ; + if (length == 0) return; int state = initStyle & 31; int nextIndex = 0; - char chPrev = ' '; - //char chPrev2 = ' '; - char chNext = styler[startPos]; + char chPrev = ' '; + char chPrev2 = ' '; + char chNext = styler[startPos]; styler.StartSegment(startPos); bool atStartLine = true; int spaceFlags = 0; for (int i = startPos; i < lengthDoc; i++) - { + { - if (atStartLine) - { + if (atStartLine) + { char chBad = static_cast(64); char chGood = static_cast(0); char chFlags = chGood; if (whingeLevel == 1) { - chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; + chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; } else if (whingeLevel == 2) { - chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; + chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; } else if (whingeLevel == 3) { - chFlags = (spaceFlags & wsSpace) ? chBad : chGood; + chFlags = (spaceFlags & wsSpace) ? chBad : chGood; } else if (whingeLevel == 4) { - chFlags = (spaceFlags & wsTab) ? chBad : chGood; + chFlags = (spaceFlags & wsTab) ? chBad : chGood; } styler.SetFlags(chFlags, static_cast(state)); atStartLine = false; } - char ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); - if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) - { - if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) - { - styler.ColourTo(i, state); - } - atStartLine = true; - } + if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) + { + if ((state == SCE_SCRIPTOL_DEFAULT) || + (state == SCE_SCRIPTOL_TRIPLE) || + (state == SCE_SCRIPTOL_COMMENTBLOCK)) + { + styler.ColourTo(i, state); + } + atStartLine = true; + } - if (styler.IsLeadByte(ch)) - { - chNext = styler.SafeGetCharAt(i + 2); - chPrev = ' '; - //chPrev2 = ' '; - i += 1; - continue; - } + if (styler.IsLeadByte(ch)) + { + chNext = styler.SafeGetCharAt(i + 2); + chPrev = ' '; + chPrev2 = ' '; + i += 1; + continue; + } - if (state == SCE_P_STRINGEOL) - { - if (ch != '\r' && ch != '\n') + if (state == SCE_SCRIPTOL_STRINGEOL) + { + if (ch != '\r' && ch != '\n') { - styler.ColourTo(i - 1, state); - state = SCE_P_DEFAULT; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_DEFAULT; } - } + } - if (state == SCE_P_DEFAULT) - { - if (IsSolWordStart(ch, chNext)) + if (state == SCE_SCRIPTOL_DEFAULT) + { + if (IsSolWordStart(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_P_WORD; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_KEYWORD; } else if (ch == '`') { - styler.ColourTo(i - 1, state); - state = SCE_P_COMMENTLINE; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_COMMENTLINE; } else if (ch == '/') { - styler.ColourTo(i - 1, state); - if(chNext == '/') state = SCE_P_COMMENTLINE; - if(chNext == '*') state = SCE_P_COMMENTBLOCK; + styler.ColourTo(i - 1, state); + if(chNext == '/') state = SCE_SCRIPTOL_CSTYLE; + if(chNext == '*') state = SCE_SCRIPTOL_COMMENTBLOCK; } - else if (ch == '=' && chNext == 'b') - { - // =begin indicates the start of a comment (doc) block - if(styler.SafeGetCharAt(i + 2) == 'e' && styler.SafeGetCharAt(i + 3) == 'g' && styler.SafeGetCharAt(i + 4) == 'i' && styler.SafeGetCharAt(i + 5) == 'n') - { - styler.ColourTo(i - 1, state); - state = SCE_P_TRIPLEDOUBLE; //SCE_C_COMMENT; - } - } - else if (IsSolStringStart(ch, chNext)) + else if (IsSolStringStart(ch)) { styler.ColourTo(i - 1, state); state = GetSolStringState(styler, i, &nextIndex); + if(state == SCE_SCRIPTOL_STRING) + { + stringType = ch; + } if (nextIndex != i + 1) { - i = nextIndex - 1; - ch = ' '; - //chPrev = ' '; - chNext = styler.SafeGetCharAt(i + 1); + i = nextIndex - 1; + ch = ' '; + chPrev = ' '; + chNext = styler.SafeGetCharAt(i + 1); } - } + } else if (isoperator(ch)) { - styler.ColourTo(i - 1, state); - styler.ColourTo(i, SCE_P_OPERATOR); - } + styler.ColourTo(i - 1, state); + styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR); + } } - else if (state == SCE_P_WORD) + else if (state == SCE_SCRIPTOL_KEYWORD) { if (!iswordchar(ch)) { ClassifyWordSol(styler.GetStartSegment(), i - 1, keywords, styler, prevWord); - state = SCE_P_DEFAULT; + state = SCE_SCRIPTOL_DEFAULT; if (ch == '`') { - state = chNext == '`' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE; + state = chNext == '`' ? SCE_SCRIPTOL_PERSISTENT : SCE_SCRIPTOL_COMMENTLINE; } - else if (IsSolStringStart(ch, chNext)) + else if (IsSolStringStart(ch)) { styler.ColourTo(i - 1, state); state = GetSolStringState(styler, i, &nextIndex); - if (nextIndex != i + 1) + if (nextIndex != i + 1) { - i = nextIndex - 1; - ch = ' '; - //chPrev = ' '; - chNext = styler.SafeGetCharAt(i + 1); - } + i = nextIndex - 1; + ch = ' '; + chPrev = ' '; + chNext = styler.SafeGetCharAt(i + 1); + } } else if (isoperator(ch)) { - styler.ColourTo(i, SCE_P_OPERATOR); + styler.ColourTo(i, SCE_SCRIPTOL_OPERATOR); } } } else { - if (state == SCE_P_COMMENTLINE) + if (state == SCE_SCRIPTOL_COMMENTLINE || + state == SCE_SCRIPTOL_PERSISTENT || + state == SCE_SCRIPTOL_CSTYLE) { - if (ch == '\r' || ch == '\n') + if (ch == '\r' || ch == '\n') { - styler.ColourTo(i - 1, state); - state = SCE_P_DEFAULT; + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_DEFAULT; } } - else if(state == SCE_P_COMMENTBLOCK) + else if(state == SCE_SCRIPTOL_COMMENTBLOCK) { - if(ch == '*' && chNext == '/') state = SCE_P_DEFAULT; + if(chPrev == '*' && ch == '/') + { + styler.ColourTo(i, state); + state = SCE_SCRIPTOL_DEFAULT; + } } - else if (state == SCE_P_STRING) + else if ((state == SCE_SCRIPTOL_STRING) || + (state == SCE_SCRIPTOL_CHARACTER)) { - if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) + if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) { - styler.ColourTo(i - 1, state); - state = SCE_P_STRINGEOL; - } + styler.ColourTo(i - 1, state); + state = SCE_SCRIPTOL_STRINGEOL; + } else if (ch == '\\') { if (chNext == '\"' || chNext == '\'' || chNext == '\\') { - i++; - ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); + 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 == '\'') + else if ((ch == '\"') || (ch == '\'')) { - styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } - } - /* - else if (state == SCE_P_TRIPLE) + // must match the entered quote type + if(ch == stringType) + { + styler.ColourTo(i, state); + state = SCE_SCRIPTOL_DEFAULT; + } + } + } + else if (state == SCE_SCRIPTOL_TRIPLE) { - if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') + if ((ch == '\'' && chPrev == '\'' && chPrev2 == '\'') || + (ch == '\"' && chPrev == '\"' && chPrev2 == '\"')) { styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } - } - else if (state == SCE_P_TRIPLEDOUBLE) - { - // =end terminates the comment block - if (ch == 'd' && chPrev == 'n' && chPrev2 == 'e') - { - if (styler.SafeGetCharAt(i - 3) == '=') - { - styler.ColourTo(i, state); - state = SCE_P_DEFAULT; - } + state = SCE_SCRIPTOL_DEFAULT; } - } - */ - } - //chPrev2 = chPrev; - chPrev = ch; + } + + } + chPrev2 = chPrev; + chPrev = ch; } - if (state == SCE_P_WORD) - { - ClassifyWordSol(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord); + if (state == SCE_SCRIPTOL_KEYWORD) + { + ClassifyWordSol(styler.GetStartSegment(), + lengthDoc-1, keywords, styler, prevWord); } - else - { - styler.ColourTo(lengthDoc-1, state); + else + { + styler.ColourTo(lengthDoc-1, state); } } @@ -369,57 +345,58 @@ static void FoldSolDoc(unsigned int startPos, int length, int initStyle, { int lengthDoc = startPos + length; - // Backtrack to previous line in case need to fix its fold status int lineCurrent = styler.GetLine(startPos); - if (startPos > 0) { - if (lineCurrent > 0) + if (startPos > 0) { - lineCurrent--; - startPos = styler.LineStart(lineCurrent); - if (startPos == 0) - initStyle = SCE_P_DEFAULT; - else - initStyle = styler.StyleAt(startPos-1); - } + if (lineCurrent > 0) + { + lineCurrent--; + startPos = styler.LineStart(lineCurrent); + if (startPos == 0) + initStyle = SCE_SCRIPTOL_DEFAULT; + else + initStyle = styler.StyleAt(startPos-1); + } } int state = initStyle & 31; int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsSolComment); - if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) - indentCurrent |= SC_FOLDLEVELWHITEFLAG; + if ((state == SCE_SCRIPTOL_TRIPLE)) + indentCurrent |= SC_FOLDLEVELWHITEFLAG; char chNext = styler[startPos]; for (int i = startPos; i < lengthDoc; i++) - { + { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i) & 31; if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) - { - int lev = indentCurrent; - int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsSolComment); - if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE)) - indentNext |= SC_FOLDLEVELWHITEFLAG; - if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) - { - // Only non whitespace lines can be headers - if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) - { - lev |= SC_FOLDLEVELHEADERFLAG; - } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { - // Line after is blank so check the next - maybe should continue further? - int spaceFlags2 = 0; - int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsSolComment); - if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) + int lev = indentCurrent; + int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsSolComment); + if (style == SCE_SCRIPTOL_TRIPLE) + indentNext |= SC_FOLDLEVELWHITEFLAG; + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { - lev |= SC_FOLDLEVELHEADERFLAG; - } - } - } - indentCurrent = indentNext; - styler.SetLevel(lineCurrent, lev); - lineCurrent++; + // Only non whitespace lines can be headers + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) + { + lev |= SC_FOLDLEVELHEADERFLAG; + } + else if (indentNext & SC_FOLDLEVELWHITEFLAG) + { + // Line after is blank so check the next - maybe should continue further? + int spaceFlags2 = 0; + int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsSolComment); + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) + { + lev |= SC_FOLDLEVELHEADERFLAG; + } + } + } + indentCurrent = indentNext; + styler.SetLevel(lineCurrent, lev); + lineCurrent++; } } } diff --git a/src/stc/scintilla/src/LexTeX.cxx b/src/stc/scintilla/src/LexTeX.cxx new file mode 100644 index 0000000000..a5b0946701 --- /dev/null +++ b/src/stc/scintilla/src/LexTeX.cxx @@ -0,0 +1,288 @@ +// Scintilla source code edit control + +// File: LexTeX.cxx - general context conformant tex coloring scheme +// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com +// Version: September 28, 2003 + +// Copyright: 1998-2003 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// This lexer is derived from the one written for the texwork environment (1999++) which in +// turn is inspired on texedit (1991++) which finds its roots in wdt (1986). + +// If you run into strange boundary cases, just tell me and I'll look into it. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "StyleContext.h" + +// val SCE_TEX_DEFAULT = 0 +// val SCE_TEX_SPECIAL = 1 +// val SCE_TEX_GROUP = 2 +// val SCE_TEX_SYMBOL = 3 +// val SCE_TEX_COMMAND = 4 +// val SCE_TEX_TEXT = 5 + +// Definitions in SciTEGlobal.properties: +// +// TeX Highlighting +// +// # Default +// style.tex.0=fore:#7F7F00 +// # Special +// style.tex.1=fore:#007F7F +// # Group +// style.tex.2=fore:#880000 +// # Symbol +// style.tex.3=fore:#7F7F00 +// # Command +// style.tex.4=fore:#008800 +// # Text +// style.tex.5=fore:#000000 + +// lexer.tex.interface.default=0 +// lexer.tex.comment.process=0 + +// todo: lexer.tex.auto.if + +// Auxiliary functions: + +static inline bool endOfLine(Accessor &styler, unsigned int i) { + return + (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')) ; +} + +static inline bool isTeXzero(int ch) { + return + (ch == '%') ; +} + +static inline bool isTeXone(int ch) { + return + (ch == '[') || (ch == ']') || (ch == '=') || (ch == '#') || + (ch == '(') || (ch == ')') || (ch == '<') || (ch == '>') || + (ch == '"') ; +} + +static inline bool isTeXtwo(int ch) { + return + (ch == '{') || (ch == '}') || (ch == '$') ; +} + +static inline bool isTeXthree(int ch) { + return + (ch == '~') || (ch == '^') || (ch == '_') || (ch == '&') || + (ch == '-') || (ch == '+') || (ch == '\"') || (ch == '`') || + (ch == '/') || (ch == '|') || (ch == '%') ; +} + +static inline bool isTeXfour(int ch) { + return + (ch == '\\') ; +} + +static inline bool isTeXfive(int ch) { + return + ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || + (ch == '@') || (ch == '!') || (ch == '?') ; +} + +static inline bool isTeXsix(int ch) { + return + (ch == ' ') ; +} + +static inline bool isTeXseven(int ch) { + return + (ch == '^') ; +} + +// Interface determination + +static int CheckTeXInterface( + unsigned int startPos, + int length, + Accessor &styler, + int defaultInterface) { + + char lineBuffer[1024] ; + unsigned int linePos = 0 ; + + // some day we can make something lexer.tex.mapping=(all,0)(nl,1)(en,2)... + + if (styler.SafeGetCharAt(0) == '%') { + for (unsigned int i = 0; i < startPos + length; i++) { + lineBuffer[linePos++] = styler.SafeGetCharAt(i) ; + if (endOfLine(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + lineBuffer[linePos] = '\0'; + if (strstr(lineBuffer, "interface=all")) { + return 0 ; + } else if (strstr(lineBuffer, "interface=tex")) { + return 1 ; + } else if (strstr(lineBuffer, "interface=nl")) { + return 2 ; + } else if (strstr(lineBuffer, "interface=en")) { + return 3 ; + } else if (strstr(lineBuffer, "interface=de")) { + return 4 ; + } else if (strstr(lineBuffer, "interface=cz")) { + return 5 ; + } else if (strstr(lineBuffer, "interface=it")) { + return 6 ; + } else if (strstr(lineBuffer, "interface=ro")) { + return 7 ; + } else if (strstr(lineBuffer, "interface=latex")) { + // we will move latex cum suis up to 91+ when more keyword lists are supported + return 8 ; + } else if (styler.SafeGetCharAt(1) == 'D' && strstr(lineBuffer, "%D \\module")) { + // better would be to limit the search to just one line + return 3 ; + } else { + return defaultInterface ; + } + } + } + } + + return defaultInterface ; +} + +static void ColouriseTeXDoc( + unsigned int startPos, + int length, + int, + WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos) ; + styler.StartSegment(startPos) ; + + bool processComment = styler.GetPropertyInt("lexer.tex.comment.process", 0) == 1 ; + bool useKeywords = styler.GetPropertyInt("lexer.tex.use.keywords", 1) == 1 ; + bool autoIf = styler.GetPropertyInt("lexer.tex.auto.if", 1) == 1 ; + int defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ; + + char key[100] ; + int k ; + bool newifDone = false ; + bool inComment = false ; + + int currentInterface = CheckTeXInterface(startPos,length,styler,defaultInterface) ; + + if (currentInterface == 0) { + useKeywords = false ; + currentInterface = 1 ; + } + + WordList &keywords = *keywordlists[currentInterface-1] ; + + StyleContext sc(startPos, length, SCE_TEX_TEXT, styler); + + bool going = sc.More() ; // needed because of a fuzzy end of file state + + for (; going; sc.Forward()) { + + if (! sc.More()) { going = false ; } // we need to go one behind the end of text + + if (inComment) { + if (sc.atLineEnd) { + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + inComment = false ; + } + } else { + if (! isTeXfive(sc.ch)) { + if (sc.state == SCE_TEX_COMMAND) { + if (sc.LengthCurrent() == 1) { // \ + if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { + sc.Forward(2) ; // \^^ and \^^ + } + sc.ForwardSetState(SCE_TEX_TEXT) ; + } else { + sc.GetCurrent(key, sizeof(key)-1) ; + k = strlen(key) ; + memmove(key,key+1,k) ; // shift left over escape token + key[k] = '\0' ; + k-- ; + if (! keywords || ! useKeywords) { + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = false ; + } else if (k == 1) { //\ + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = false ; + } else if (keywords.InList(key)) { + sc.SetState(SCE_TEX_COMMAND) ; + newifDone = autoIf && (strcmp(key,"newif") == 0) ; + } else if (autoIf && ! newifDone && (key[0] == 'i') && (key[1] == 'f') && keywords.InList("if")) { + sc.SetState(SCE_TEX_COMMAND) ; + } else { + sc.ChangeState(SCE_TEX_TEXT) ; + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + } + } + } + if (isTeXzero(sc.ch)) { + sc.SetState(SCE_TEX_SYMBOL) ; + sc.ForwardSetState(SCE_TEX_DEFAULT) ; + inComment = ! processComment ; + newifDone = false ; + } else if (isTeXseven(sc.ch) && isTeXseven(sc.chNext)) { + sc.SetState(SCE_TEX_TEXT) ; + sc.ForwardSetState(SCE_TEX_TEXT) ; + } else if (isTeXone(sc.ch)) { + sc.SetState(SCE_TEX_SPECIAL) ; + newifDone = false ; + } else if (isTeXtwo(sc.ch)) { + sc.SetState(SCE_TEX_GROUP) ; + newifDone = false ; + } else if (isTeXthree(sc.ch)) { + sc.SetState(SCE_TEX_SYMBOL) ; + newifDone = false ; + } else if (isTeXfour(sc.ch)) { + sc.SetState(SCE_TEX_COMMAND) ; + } else if (isTeXsix(sc.ch)) { + sc.SetState(SCE_TEX_TEXT) ; + } else if (sc.atLineEnd) { + sc.SetState(SCE_TEX_TEXT) ; + newifDone = false ; + inComment = false ; + } else { + sc.SetState(SCE_TEX_TEXT) ; + } + } else if (sc.state != SCE_TEX_COMMAND) { + sc.SetState(SCE_TEX_TEXT) ; + } + } + } + sc.ChangeState(SCE_TEX_TEXT) ; + sc.Complete(); + +} + + +// Hooks into the system: + +static const char * const texWordListDesc[] = { + "TeX, eTeX, pdfTeX, Omega" + "ConTeXt Dutch", + "ConTeXt English", + "ConTeXt German", + "ConTeXt Czech", + "ConTeXt Italian", + "ConTeXt Romanian", + 0, +} ; + +LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", 0, texWordListDesc); diff --git a/src/stc/scintilla/src/LexVB.cxx b/src/stc/scintilla/src/LexVB.cxx index 72fdb9c3cf..93bdedbd89 100644 --- a/src/stc/scintilla/src/LexVB.cxx +++ b/src/stc/scintilla/src/LexVB.cxx @@ -2,7 +2,7 @@ /** @file LexVB.cxx ** Lexer for Visual Basic and VBScript. **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -24,16 +24,19 @@ static bool IsVBComment(Accessor &styler, int pos, int len) { return len>0 && styler[pos]=='\''; } -static inline bool IsTypeCharacter(const int ch) { +static inline bool IsTypeCharacter(int ch) { return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$'; } -static inline bool IsAWordChar(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); +// Extended to accept accented characters +static inline bool IsAWordChar(int ch) { + return ch >= 0x80 || + (isalnum(ch) || ch == '.' || ch == '_'); } -static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_'); +static inline bool IsAWordStart(int ch) { + return ch >= 0x80 || + (isalnum(ch) || ch == '_'); } static inline bool IsADateCharacter(const int ch) { @@ -45,6 +48,9 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) { WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; + WordList &keywords4 = *keywordlists[3]; styler.StartAt(startPos); @@ -56,26 +62,37 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, if (sc.state == SCE_B_OPERATOR) { sc.SetState(SCE_B_DEFAULT); - } else if (sc.state == SCE_B_KEYWORD) { + } else if (sc.state == SCE_B_IDENTIFIER) { if (!IsAWordChar(sc.ch)) { - if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) { - if (sc.ch == ']') - sc.Forward(); - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); + // In Basic (except VBScript), a variable name or a function name + // can end with a special character indicating the type of the value + // held or returned. + bool skipType = false; + if (!vbScriptSyntax && IsTypeCharacter(sc.ch)) { + sc.Forward(); // Skip it + skipType = true; + } + if (sc.ch == ']') { + sc.Forward(); + } + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (skipType) { + s[strlen(s) - 1] = '\0'; + } + if (strcmp(s, "rem") == 0) { + sc.ChangeState(SCE_B_COMMENT); + } else { if (keywords.InList(s)) { - if (strcmp(s, "rem") == 0) { - sc.ChangeState(SCE_B_COMMENT); - if (sc.atLineEnd) { - sc.SetState(SCE_B_DEFAULT); - } - } else { - sc.SetState(SCE_B_DEFAULT); - } - } else { - sc.ChangeState(SCE_B_IDENTIFIER); - sc.SetState(SCE_B_DEFAULT); - } + sc.ChangeState(SCE_B_KEYWORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD2); + } else if (keywords3.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD3); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_B_KEYWORD4); + } // Else, it is really an identifier... + sc.SetState(SCE_B_DEFAULT); } } } else if (sc.state == SCE_B_NUMBER) { @@ -90,6 +107,9 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, sc.Forward(); } sc.ForwardSetState(SCE_B_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_B_STRINGEOL); + sc.ForwardSetState(SCE_B_DEFAULT); } } else if (sc.state == SCE_B_COMMENT) { if (sc.atLineEnd) { @@ -132,7 +152,7 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_B_NUMBER); } else if (IsAWordStart(sc.ch) || (sc.ch == '[')) { - sc.SetState(SCE_B_KEYWORD); + sc.SetState(SCE_B_IDENTIFIER); } else if (isoperator(static_cast(sc.ch)) || (sc.ch == '\\')) { sc.SetState(SCE_B_OPERATOR); } @@ -202,6 +222,9 @@ static void ColouriseVBScriptDoc(unsigned int startPos, int length, int initStyl static const char * const vbWordListDesc[] = { "Keywords", + "user1", + "user2", + "user3", 0 }; diff --git a/src/stc/scintilla/src/LexYAML.cxx b/src/stc/scintilla/src/LexYAML.cxx new file mode 100644 index 0000000000..e3053f8140 --- /dev/null +++ b/src/stc/scintilla/src/LexYAML.cxx @@ -0,0 +1,305 @@ +// Scintilla source code edit control +/** @file LexYAML.cxx + ** Lexer for YAML. + **/ +// Copyright 2003- by Sean O'Dell +// Release under the same license as Scintilla/SciTE. + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +static const char * const yamlWordListDesc[] = { + "Keywords", + 0 +}; + +static inline bool AtEOL(Accessor &styler, unsigned int i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +static unsigned int SpaceCount(char* lineBuffer) { + if (lineBuffer == NULL) + return 0; + + char* headBuffer = lineBuffer; + + while (*headBuffer == ' ') + headBuffer++; + + return headBuffer - lineBuffer; +} + +#define YAML_STATE_BITSIZE 16 +#define YAML_STATE_MASK (0xFFFF0000) +#define YAML_STATE_DOCUMENT (1 << YAML_STATE_BITSIZE) +#define YAML_STATE_VALUE (2 << YAML_STATE_BITSIZE) +#define YAML_STATE_COMMENT (3 << YAML_STATE_BITSIZE) +#define YAML_STATE_TEXT_PARENT (4 << YAML_STATE_BITSIZE) +#define YAML_STATE_TEXT (5 << YAML_STATE_BITSIZE) + +static void ColouriseYAMLLine( + char *lineBuffer, + unsigned int currentLine, + unsigned int lengthLine, + unsigned int startLine, + unsigned int endPos, + WordList &keywords, + Accessor &styler) { + + unsigned int i = 0; + bool bInQuotes = false; + unsigned int indentAmount = SpaceCount(lineBuffer); + + if (currentLine > 0) { + int parentLineState = styler.GetLineState(currentLine - 1); + + if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) { + unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK); + if (indentAmount > parentIndentAmount) { + styler.SetLineState(currentLine, YAML_STATE_TEXT | parentIndentAmount); + styler.ColourTo(endPos, SCE_YAML_TEXT); + return; + } + } + } + styler.SetLineState(currentLine, 0); + if (strncmp(lineBuffer, "---", 3) == 0) { // Document marker + styler.SetLineState(currentLine, YAML_STATE_DOCUMENT); + styler.ColourTo(endPos, SCE_YAML_DOCUMENT); + return; + } + // Skip initial spaces + while ((i < lengthLine) && lineBuffer[i] == ' ') { // YAML always uses space, never TABS or anything else + i++; + } + if (lineBuffer[i] == '\t') { // if we skipped all spaces, and we are NOT inside a text block, this is wrong + styler.ColourTo(endPos, SCE_YAML_ERROR); + return; + } + if (lineBuffer[i] == '#') { // Comment + styler.SetLineState(currentLine, YAML_STATE_COMMENT); + styler.ColourTo(endPos, SCE_YAML_COMMENT); + return; + } + while (i < lengthLine) { + if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') { + bInQuotes = !bInQuotes; + } else if (lineBuffer[i] == ':' && !bInQuotes) { + styler.ColourTo(startLine + i, SCE_YAML_IDENTIFIER); + // Non-folding scalar + i++; + while ((i < lengthLine) && isspacechar(lineBuffer[i])) + i++; + unsigned int endValue = lengthLine - 1; + while ((endValue >= i) && isspacechar(lineBuffer[endValue])) + endValue--; + lineBuffer[endValue + 1] = '\0'; + if (lineBuffer[i] == '|' || lineBuffer[i] == '>') { + i++; + if (lineBuffer[i] == '+' || lineBuffer[i] == '-') + i++; + while ((i < lengthLine) && isspacechar(lineBuffer[i])) + i++; + if (lineBuffer[i] == '\0') { + styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount); + styler.ColourTo(endPos, SCE_YAML_DEFAULT); + return; + } else if (lineBuffer[i] == '#') { + styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount); + styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT); + styler.ColourTo(endPos, SCE_YAML_COMMENT); + return; + } else { + styler.ColourTo(endPos, SCE_YAML_ERROR); + return; + } + } + styler.SetLineState(currentLine, YAML_STATE_VALUE); + if (lineBuffer[i] == '&' || lineBuffer[i] == '*') { + styler.ColourTo(endPos, SCE_YAML_REFERENCE); + return; + } + if (keywords.InList(&lineBuffer[i])) { // Convertible value (true/false, etc.) + styler.ColourTo(endPos, SCE_YAML_KEYWORD); + return; + } else { + unsigned int i2 = i; + while ((i < lengthLine) && lineBuffer[i]) { + if (!isdigit(lineBuffer[i]) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') { + styler.ColourTo(endPos, SCE_YAML_DEFAULT); + return; + } + i++; + } + if (i > i2) { + styler.ColourTo(endPos, SCE_YAML_NUMBER); + return; + } + } + break; // shouldn't get here, but just in case, the rest of the line is coloured the default + } + i++; + } + styler.ColourTo(endPos, SCE_YAML_DEFAULT); +} + +static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { + char lineBuffer[1024]; + styler.StartAt(startPos); + styler.StartSegment(startPos); + unsigned int linePos = 0; + unsigned int startLine = startPos; + unsigned int endPos = startPos + length; + unsigned int maxPos = styler.Length(); + unsigned int lineCurrent = styler.GetLine(startPos); + + for (unsigned int i = startPos; i < maxPos && i < endPos; i++) { + lineBuffer[linePos++] = styler[i]; + if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + // End of line (or of line buffer) met, colourise it + lineBuffer[linePos] = '\0'; + ColouriseYAMLLine(lineBuffer, lineCurrent, linePos, startLine, i, *keywordLists[0], styler); + linePos = 0; + startLine = i + 1; + lineCurrent++; + } + } + if (linePos > 0) { // Last line does not have ending characters + ColouriseYAMLLine(lineBuffer, lineCurrent, linePos, startLine, startPos + length - 1, *keywordLists[0], styler); + } +} + +static bool IsCommentLine(int line, Accessor &styler) { + int pos = styler.LineStart(line); + if (styler[pos] == '#') + return true; + return false; +} + +static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unused*/, + WordList *[], Accessor &styler) { + 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.yaml") != 0; + + // Backtrack to previous non-blank line so we can determine indent level + // for any white space lines + // and so we can fix any preceding fold level (which is why we go back + // at least one line in all cases) + int spaceFlags = 0; + int lineCurrent = styler.GetLine(startPos); + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + while (lineCurrent > 0) { + lineCurrent--; + indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) && + (!IsCommentLine(lineCurrent, styler))) + break; + } + int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + + // Set up initial loop state + int prevComment = 0; + if (lineCurrent >= 1) + prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler); + + // Process all characters to end of requested range + // or comment that hangs over the end of the range. Cap processing in all cases + // to end of document (in case of unclosed comment at end). + while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) { + + // Gather info + int lev = indentCurrent; + int lineNext = lineCurrent + 1; + int indentNext = indentCurrent; + if (lineNext <= docLines) { + // Information about next line is only available if not at end of document + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + const int comment = foldComment && IsCommentLine(lineCurrent, styler); + const int comment_start = (comment && !prevComment && (lineNext <= docLines) && + IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE)); + const int comment_continue = (comment && prevComment); + if (!comment) + indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + if (indentNext & SC_FOLDLEVELWHITEFLAG) + indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel; + + if (comment_start) { + // Place fold point at start of a block of comments + lev |= SC_FOLDLEVELHEADERFLAG; + } else if (comment_continue) { + // Add level to rest of lines in the block + lev = lev + 1; + } + + // Skip past any blank lines for next indent level info; we skip also + // comments (all comments, not just those starting in column 0) + // which effectively folds them into surrounding code rather + // than screwing up folding. + + while ((lineNext < docLines) && + ((indentNext & SC_FOLDLEVELWHITEFLAG) || + (lineNext <= docLines && IsCommentLine(lineNext, styler)))) { + + lineNext++; + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + + const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK; + const int levelBeforeComments = Platform::Maximum(indentCurrentLevel,levelAfterComments); + + // Now set all the indent levels on the lines we skipped + // Do this from end to start. Once we encounter one line + // which is indented more than the line after the end of + // the comment-block, use the level of the block before + + int skipLine = lineNext; + int skipLevel = levelAfterComments; + + while (--skipLine > lineCurrent) { + int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL); + + if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments) + skipLevel = levelBeforeComments; + + int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG; + + styler.SetLevel(skipLine, skipLevel | whiteFlag); + } + + // Set fold header on non-comment line + if (!comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) { + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) + lev |= SC_FOLDLEVELHEADERFLAG; + } + + // Keep track of block comment state of previous line + prevComment = comment_start || comment_continue; + + // Set fold level for this line and move to next line + styler.SetLevel(lineCurrent, lev); + indentCurrent = indentNext; + lineCurrent = lineNext; + } + + // 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 lmYAML(SCLEX_YAML, ColouriseYAMLDoc, "yaml", FoldYAMLDoc, yamlWordListDesc); diff --git a/src/stc/scintilla/src/PropSet.cxx b/src/stc/scintilla/src/PropSet.cxx index 021a657273..658d5046a4 100644 --- a/src/stc/scintilla/src/PropSet.cxx +++ b/src/stc/scintilla/src/PropSet.cxx @@ -562,7 +562,7 @@ bool WordList::InList(const char *s) { * The length of the word to compare is passed too. * Letter case can be ignored or preserved (default). */ -const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) { +const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */, int wordIndex /*= -1 */) { int start = 0; // lower bound of the api array block to search int end = len - 1; // upper bound of the api array block to search int pivot; // index of api array element just being compared @@ -580,8 +580,33 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 pivot = (start + end) >> 1; word = wordsNoCase[pivot]; cond = CompareNCaseInsensitive(wordStart, word, searchLen); - if (!cond && (!wordCharacters.contains(word[searchLen]))) + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found a word in a binary fashion. Now checks if a specific index was requested + if (wordIndex < 0) return word; // result must not be freed with free() + + // Finds first word in a series of equal words + int first = pivot; + end = pivot - 1; + while (start <= end) { + pivot = (start + end) >> 1; + word = wordsNoCase[pivot]; + cond = CompareNCaseInsensitive(wordStart, word, searchLen); + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found another word + first = pivot; + end = pivot - 1; + } + else if (cond > 0) + start = pivot + 1; + else if (cond <= 0) + break; + } + + // Gets the word at the requested index + word = wordsNoCase[first + wordIndex]; + return word; + } else if (cond > 0) start = pivot + 1; else if (cond <= 0) @@ -592,8 +617,33 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 pivot = (start + end) >> 1; word = words[pivot]; cond = strncmp(wordStart, word, searchLen); - if (!cond && (!wordCharacters.contains(word[searchLen]))) - return word; // result must not be freed with free() + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found a word in a binary fashion. Now checks if a specific index was requested + if (wordIndex < 0) + return word; // result must not be freed with free() + + // Finds first word in a series of equal words + int first = pivot; + end = pivot - 1; + while (start <= end) { + pivot = (start + end) >> 1; + word = words[pivot]; + cond = strncmp(wordStart, word, searchLen); + if (!cond && (!wordCharacters.contains(word[searchLen]))) { + // Found another word + first = pivot; + end = pivot - 1; + } + else if (cond > 0) + start = pivot + 1; + else if (cond <= 0) + break; + } + + // Gets the word at the requested index + word = words[first + wordIndex]; + return word; + } else if (cond > 0) start = pivot + 1; else if (cond <= 0) diff --git a/src/stc/scintilla/src/RESearch.cxx b/src/stc/scintilla/src/RESearch.cxx index 3ca61bb9ce..b7ea71bfb9 100644 --- a/src/stc/scintilla/src/RESearch.cxx +++ b/src/stc/scintilla/src/RESearch.cxx @@ -10,11 +10,11 @@ * Dept. of Computer Science * York University * - * Original code available from http://www.cs.yorku.ca/~oz/ + * Original code available from http://www.cs.yorku.ca/~oz/ * Translation to C++ by Neil Hodgson neilh@scintilla.org * Removed all use of register. * Converted to modern function prototypes. - * Put all global/static variables into an object so this code can be + * Put all global/static variables into an object so this code can be * used from multiple threads etc. * * These routines are the PUBLIC DOMAIN equivalents of regex @@ -27,74 +27,8 @@ * see Henry Spencer's regexp routines, or GNU Emacs pattern * matching module. * - * Modification history: - * - * $Log$ - * Revision 1.8 2003/09/18 05:05:38 RD - * Updated to Scintilla 1.54 - * Applied most of patch #806092 - * Added new wxSTC sample from Otto Wyss - * - * Revision 1.9 2003/03/21 10:36:08 nyamatongwe - * Detect patterns too long in regular expression search. - * - * Revision 1.8 2003/03/04 10:53:59 nyamatongwe - * Patch from Jakub to optionally implement more POSIX compatible regular - * expressions. \(..\) changes to (..) - * Fixes problem where find previous would not find earlier matches on same - * line. - * - * Revision 1.8 2003/03/03 20:12:56 vrana - * Added posix syntax. - * - * Revision 1.7 2002/09/28 00:33:28 nyamatongwe - * Fixed problem with character ranges caused by expansion to 8 bits. - * - * Revision 1.6 2001/04/29 13:32:10 nyamatongwe - * Addition of new target methods - versions of ReplaceTarget that take counted - * strings to allow for nulls, SearchInTarget and Get/SetSearchFlags to use a - * series of calls rather than a structure. - * Handling of \000 in search and replace. - * Handling of /escapes within character ranges of regular expressions. - * Some handling of bare ^ and $ regular expressions. - * - * Revision 1.5 2001/04/20 07:36:09 nyamatongwe - * Removed DEBUG code that failed to compile on GTK+. - * - * Revision 1.4 2001/04/13 03:52:13 nyamatongwe - * Added URL to find original code to comments. - * - * Revision 1.3 2001/04/06 12:24:21 nyamatongwe - * Made regular expression searching work on a line by line basis, made ^ and - * $ work, made [set] work, and added a case insensitive option. - * - * Revision 1.2 2001/04/05 01:58:04 nyamatongwe - * Replace target functionality to make find and replace operations faster - * by diminishing screen updates and allow for \d patterns in the replacement - * text. - * - * Revision 1.1 2001/04/04 12:52:44 nyamatongwe - * Moved to public domain regular expresion implementation. - * - * Revision 1.4 1991/10/17 03:56:42 oz - * miscellaneous changes, small cleanups etc. - * - * Revision 1.3 1989/04/01 14:18:09 oz - * Change all references to a dfa: this is actually an nfa. - * - * Revision 1.2 88/08/28 15:36:04 oz - * Use a complement bitmap to represent NCL. - * This removes the need to have seperate - * code in the PMatch case block - it is - * just CCL code now. - * - * Use the actual CCL code in the CLO - * section of PMatch. No need for a recursive - * PMatch call. - * - * Use a bitmap table to set char bits in an - * 8-bit chunk. - * + * Modification history removed. + * * Interfaces: * RESearch::Compile: compile a regular expression into a NFA. * @@ -124,7 +58,7 @@ * void re_fail(msg, op) * char *msg; * char op; - * + * * Regular Expressions: * * [1] char matches itself, unless it is a special @@ -134,20 +68,20 @@ * * [3] \ matches the character following it, except * when followed by a left or right round bracket, - * a digit 1 to 9 or a left or right angle bracket. + * a digit 1 to 9 or a left or right angle bracket. * (see [7], [8] and [9]) - * It is used as an escape character for all + * It is used as an escape character for all * other meta-characters, and itself. When used * in a set ([4]), it is treated as an ordinary * character. * * [4] [set] matches one of the characters in the set. * If the first character in the set is "^", - * it matches a character NOT in the set, i.e. - * complements the set. A shorthand S-E is - * used to specify a set of characters S upto - * E, inclusive. The special characters "]" and - * "-" have no special meaning if they appear + * it matches a character NOT in the set, i.e. + * complements the set. A shorthand S-E is + * used to specify a set of characters S upto + * E, inclusive. The special characters "]" and + * "-" have no special meaning if they appear * as the first chars in the set. * examples: match: * @@ -212,8 +146,8 @@ * Notes: * * This implementation uses a bit-set representation for character - * classes for speed and compactness. Each character is represented - * by one bit in a 128-bit block. Thus, CCL always takes a + * classes for speed and compactness. Each character is represented + * by one bit in a 128-bit block. Thus, CCL always takes a * constant 16 bytes in the internal nfa, and RESearch::Execute does a single * bit comparison to locate the character in the set. * @@ -223,7 +157,7 @@ * compile: CHR f CHR o CLO CHR o END CLO ANY END END * matches: fo foo fooo foobar fobar foxx ... * - * pattern: fo[ob]a[rz] + * pattern: fo[ob]a[rz] * compile: CHR f CHR o CCL bitset CHR a CCL bitset END * matches: fobar fooar fobaz fooaz * @@ -263,7 +197,7 @@ * The following defines are not meant to be changeable. * They are for readability only. */ -#define BLKIND 0170 +#define BLKIND 0370 #define BITIND 07 #define ASCIIB 0177 @@ -271,7 +205,7 @@ const char bitarr[] = {1,2,4,8,16,32,64,'\200'}; #define badpat(x) (*nfa = END, x) - + RESearch::RESearch() { Init(); } @@ -361,7 +295,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b int n; char mask; /* xor mask -CCL/NCL */ int c1, c2; - + if (!pat || !length) if (sta) return 0; @@ -403,7 +337,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b i++; if (*++p == '^') { - mask = '\377'; + mask = '\377'; i++; p++; } else @@ -447,7 +381,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b for (n = 0; n < BITBLK; bittab[n++] = (char) 0) *mp++ = static_cast(mask ^ bittab[n]); - + break; case '*': /* match 0 or more.. */ @@ -592,7 +526,7 @@ const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, b * RESearch::Execute: * execute nfa to find a match. * - * special cases: (nfa[0]) + * special cases: (nfa[0]) * BOL * Match only once, starting from the * beginning. @@ -617,7 +551,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { bol = lp; failure = 0; - + Clear(); switch(*ap) { @@ -658,7 +592,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { return 1; } -/* +/* * PMatch: internal routine for the hard part * * This code is partly snarfed from an early grep written by @@ -684,7 +618,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { * * At the end of a successful match, bopat[n] and eopat[n] * are set to the beginning and end of subpatterns matched - * by tagged expressions (n = 1 to 9). + * by tagged expressions (n = 1 to 9). * */ @@ -695,23 +629,23 @@ extern void re_fail(char *,char); * and EOW. the reason for not using ctype macros is that we can * let the user add into our own table. see RESearch::ModifyWord. This table * is not in the bitset form, since we may wish to extend it in the - * future for other character classifications. + * future for other character classifications. * * TRUE for 0-9 A-Z a-z _ */ static char chrtyp[MAXCHR] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; @@ -833,10 +767,10 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { * the compact bitset representation for the default table] */ -static char deftab[16] = { - 0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207', - '\376', '\377', '\377', 007 -}; +static char deftab[16] = { + 0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207', + '\376', '\377', '\377', 007 +}; void RESearch::ModifyWord(char *s) { int i; @@ -883,7 +817,7 @@ int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) { pin = c - '0'; break; } - + default: *dst++ = c; continue; diff --git a/src/stc/scintilla/src/ScintillaBase.cxx b/src/stc/scintilla/src/ScintillaBase.cxx index 039539ad3c..e42b5dc65e 100644 --- a/src/stc/scintilla/src/ScintillaBase.cxx +++ b/src/stc/scintilla/src/ScintillaBase.cxx @@ -198,16 +198,18 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { if (ac.chooseSingle && (listType == 0)) { if (list && !strchr(list, ac.GetSeparator())) { + const char *typeSep = strchr(list, ac.GetTypesep()); + size_t lenInsert = (typeSep) ? (typeSep-list) : strlen(list); if (ac.ignoreCase) { SetEmptySelection(currentPos - lenEntered); pdoc->DeleteChars(currentPos, lenEntered); SetEmptySelection(currentPos); - pdoc->InsertString(currentPos, list); - SetEmptySelection(currentPos + static_cast(strlen(list))); + pdoc->InsertString(currentPos, list, lenInsert); + SetEmptySelection(currentPos + lenInsert); } else { SetEmptySelection(currentPos); - pdoc->InsertString(currentPos, list + lenEntered); - SetEmptySelection(currentPos + static_cast(strlen(list + lenEntered))); + pdoc->InsertString(currentPos, list + lenEntered, lenInsert - lenEntered); + SetEmptySelection(currentPos + lenInsert - lenEntered); } return; } @@ -345,6 +347,10 @@ void ScintillaBase::AutoCompleteCompleted() { pdoc->EndUndoAction(); } +int ScintillaBase::AutoCompleteGetCurrent() { + return ac.lb->GetSelection(); +} + void ScintillaBase::CallTipShow(Point pt, const char *defn) { AutoCompleteCancel(); pt.y += vs.lineHeight; @@ -497,6 +503,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara ac.Select(reinterpret_cast(lParam)); break; + case SCI_AUTOCGETCURRENT: + return AutoCompleteGetCurrent(); + case SCI_AUTOCSETCANCELATSTART: ac.cancelAtStartPos = wParam != 0; break; @@ -557,7 +566,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.GetTypesep(); case SCI_CALLTIPSHOW: - CallTipShow(LocationFromPosition(wParam), + CallTipShow(LocationFromPosition(wParam), reinterpret_cast(lParam)); break; diff --git a/src/stc/scintilla/src/ScintillaBase.h b/src/stc/scintilla/src/ScintillaBase.h index bb09e3f5b3..6ea23ab5a3 100644 --- a/src/stc/scintilla/src/ScintillaBase.h +++ b/src/stc/scintilla/src/ScintillaBase.h @@ -65,6 +65,7 @@ protected: void AutoCompleteStart(int lenEntered, const char *list); void AutoCompleteCancel(); void AutoCompleteMove(int delta); + int AutoCompleteGetCurrent(); void AutoCompleteCharacterAdded(char ch); void AutoCompleteCharacterDeleted(); void AutoCompleteCompleted(); diff --git a/src/stc/scintilla/src/ViewStyle.cxx b/src/stc/scintilla/src/ViewStyle.cxx index eb8e54f2f8..e2a65e09e4 100644 --- a/src/stc/scintilla/src/ViewStyle.cxx +++ b/src/stc/scintilla/src/ViewStyle.cxx @@ -84,6 +84,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { hotspotBackgroundSet = source.hotspotBackgroundSet; hotspotBackground.desired = source.hotspotBackground.desired; hotspotUnderline = source.hotspotUnderline; + hotspotSingleLine = source.hotspotSingleLine; whitespaceForegroundSet = source.whitespaceForegroundSet; whitespaceForeground.desired = source.whitespaceForeground.desired; @@ -164,6 +165,7 @@ void ViewStyle::Init() { hotspotBackgroundSet = false; hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff); hotspotUnderline = true; + hotspotSingleLine = true; leftMarginWidth = 1; rightMarginWidth = 1; diff --git a/src/stc/scintilla/src/ViewStyle.h b/src/stc/scintilla/src/ViewStyle.h index ff38efef2e..5f27cc08cb 100644 --- a/src/stc/scintilla/src/ViewStyle.h +++ b/src/stc/scintilla/src/ViewStyle.h @@ -68,6 +68,7 @@ public: bool hotspotBackgroundSet; ColourPair hotspotBackground; bool hotspotUnderline; + bool hotspotSingleLine; /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin enum { margins=3 }; int leftMarginWidth; ///< Spacing margin on left of text diff --git a/src/stc/scintilla/src/XPM.cxx b/src/stc/scintilla/src/XPM.cxx index c3f66c2e40..e693736a21 100644 --- a/src/stc/scintilla/src/XPM.cxx +++ b/src/stc/scintilla/src/XPM.cxx @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file XPM.cxx - ** Define a class that holds data in the X Pixmap (XPM) format, + ** Define a class that holds data in the X Pixmap (XPM) format. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -33,7 +33,7 @@ static size_t MeasureLength(const char *s) { ColourAllocated XPM::ColourFromCode(int ch) { return colourCodeTable[ch]->allocated; #ifdef SLOW - for (int i=0;iGetId() == id) { set[i]->Init(textForm); return; } } - // No present, so add to end + // Not present, so add to end XPM *pxpm = new XPM(textForm); if (pxpm) { pxpm->SetId(id); pxpm->CopyDesiredColours(); if (len == maximum) { - int lenNew = len + 100; - XPM **setNew = new XPM *[lenNew]; - for (int i=0; iGetId() == id) { return set[i]; } @@ -276,7 +276,7 @@ XPM *XPMSet::Get(int id) { int XPMSet::GetHeight() { if (height < 0) { - for (int i=0; iGetHeight()) { height = set[i]->GetHeight(); } @@ -287,7 +287,7 @@ int XPMSet::GetHeight() { int XPMSet::GetWidth() { if (width < 0) { - for (int i=0; iGetWidth()) { width = set[i]->GetWidth(); } diff --git a/src/stc/scintilla/src/XPM.h b/src/stc/scintilla/src/XPM.h index 948e557a92..4d3da28d36 100644 --- a/src/stc/scintilla/src/XPM.h +++ b/src/stc/scintilla/src/XPM.h @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file XPM.h - ** Define a class that holds data in the X Pixmap (XPM) format, + ** Define a class that holds data in the X Pixmap (XPM) format. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -31,11 +31,11 @@ public: void Init(const char *textForm); void Init(const char * const *linesForm); void Clear(); - // Similar to same named method in ViewStyle: + /// Similar to same named method in ViewStyle: void RefreshColourPalette(Palette &pal, bool want); - // No palette used, so just copy the desired colours to the allocated colours: + /// No palette used, so just copy the desired colours to the allocated colours void CopyDesiredColours(); - // Decompose image into runs and use FillRectangle for each run: + /// Decompose image into runs and use FillRectangle for each run void Draw(Surface *surface, PRectangle &rc); char **InLinesForm() { return lines; } void SetId(int id_) { id = id_; } @@ -49,18 +49,23 @@ public: * A collection of pixmaps indexed by integer id. */ class XPMSet { - XPM **set; - int len; - int maximum; - int height; - int width; + XPM **set; ///< The stored XPMs. + int len; ///< Current number of XPMs. + int maximum; ///< Current maximum number of XPMs, increased by steps if reached. + int height; ///< Memorize largest height of the set. + int width; ///< Memorize largest width of the set. public: XPMSet(); ~XPMSet(); + /// Remove all XPMs. void Clear(); + /// Add a XPM. void Add(int id, const char *textForm); + /// Get XPM by id. XPM *Get(int id); + /// Give the largest height of the set. int GetHeight(); + /// Give the largest width of the set. int GetWidth(); }; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 8d03e9c92d..2f5ea9eae1 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -154,7 +154,7 @@ void wxStyledTextCtrl::Create(wxWindow *parent, style |= wxVSCROLL | wxHSCROLL; #endif wxControl::Create(parent, id, pos, size, - style | wxWANTS_CHARS | wxCLIP_CHILDREN, + style | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name); #ifdef LINK_LEXERS @@ -619,7 +619,7 @@ void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { SendMsg(2070, MAKELONG(key, modifiers), cmd); } -// When key+modifier combination km do nothing. +// When key+modifier combination km is pressed do nothing. void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { SendMsg(2071, MAKELONG(key, modifiers)); } @@ -650,6 +650,7 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { } // Set the set of characters making up words for when moving or selecting by word. +// First sets deaults like SetCharsDefault. void wxStyledTextCtrl::SetWordChars(const wxString& characters) { SendMsg(2077, 0, (long)(const char*)wx2stc(characters)); } @@ -1049,7 +1050,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; @@ -1305,7 +1306,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // Returns the length of the replacement text. int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { @@ -1314,7 +1315,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text after \d processing. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // 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 @@ -1326,7 +1327,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Search for a counted string in the target and set the target to the found -// range. Text is counted so it can contain nulls. +// range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int wxStyledTextCtrl::SearchInTarget(const wxString& text) { @@ -1533,7 +1534,7 @@ int wxStyledTextCtrl::GetScrollWidth() { } // Measure the pixel width of some text in a particular style. -// Nul terminated text argument. +// NUL terminated text argument. // Does not handle tab or control characters. int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { return SendMsg(2276, style, (long)(const char*)wx2stc(text)); @@ -1884,7 +1885,7 @@ int wxStyledTextCtrl::GetXOffset() { return SendMsg(2398, 0, 0); } -// Set the last x chosen value to be the caret x position +// Set the last x chosen value to be the caret x position. void wxStyledTextCtrl::ChooseCaretX() { SendMsg(2399, 0, 0); } @@ -1906,7 +1907,7 @@ void wxStyledTextCtrl::SetPrintWrapMode(int mode) { SendMsg(2406, mode, 0); } -// Is printing line wrapped. +// Is printing line wrapped? int wxStyledTextCtrl::GetPrintWrapMode() { return SendMsg(2407, 0, 0); } @@ -1926,6 +1927,11 @@ void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) { SendMsg(2412, underline, 0); } +// Limit hotspots to single line so hotspots on two lines don't merge. +void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) { + SendMsg(2421, singleLine, 0); +} + // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int wxStyledTextCtrl::PositionBefore(int pos) { @@ -1948,6 +1954,43 @@ void wxStyledTextCtrl::CopyText(int length, const wxString& text) { SendMsg(2420, length, (long)(const char*)wx2stc(text)); } +// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +// by lines (SC_SEL_LINES). +void wxStyledTextCtrl::SetSelectionMode(int mode) { + SendMsg(2422, mode, 0); +} + +// Get the mode of the current selection. +int wxStyledTextCtrl::GetSelectionMode() { + return SendMsg(2423, 0, 0); +} + +// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelStartPosition(int line) { + return SendMsg(2424, line, 0); +} + +// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelEndPosition(int line) { + return SendMsg(2425, line, 0); +} + +// Set the set of characters making up whitespace for when moving or selecting by word. +// Should be called after SetWordChars. +void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) { + SendMsg(2443, 0, (long)(const char*)wx2stc(characters)); +} + +// Reset the set of characters for whitespace and word characters to the defaults. +void wxStyledTextCtrl::SetCharsDefault() { + SendMsg(2444, 0, 0); +} + +// Get currently selected item position in the auto-completion list +int wxStyledTextCtrl::AutoCompGetCurrent() { + return SendMsg(2445, 0, 0); +} + // Start notifying the container of all key presses and commands. void wxStyledTextCtrl::StartRecord() { SendMsg(3001, 0, 0); @@ -2336,6 +2379,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index b10b081bb7..f8fb2d1cc6 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -541,6 +541,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 0f9b62df2a..04c205e341 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -237,7 +237,8 @@ private: void OnEraseBackground(wxEraseEvent& evt); void OnMenu(wxCommandEvent& evt); void OnListBox(wxCommandEvent& evt); - + void OnIdle(wxIdleEvent& evt); + // Turn notifications from Scintilla into events void NotifyChange(); -- 2.45.2