diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 279b0458b2..a06899cb71 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -310,6 +310,8 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_SEL_THIN 3 #define wxSTC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE 0 #define wxSTC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 +#define wxSTC_MULTIAUTOC_ONCE 0 +#define wxSTC_MULTIAUTOC_EACH 1 #define wxSTC_ORDER_PRESORTED 0 #define wxSTC_ORDER_PERFORMSORT 1 #define wxSTC_ORDER_CUSTOM 2 @@ -4149,6 +4151,12 @@ public: // Get auto-completion case insensitive behaviour. int AutoCompGetCaseInsensitiveBehaviour() const; + // Change the effect of autocompleting when there are multiple selections. + void AutoCompSetMulti(int multi); + + // Retrieve the effect of autocompleting when there are multiple selections.. + int AutoCompGetMulti() const; + // Set the way autocompletion lists are ordered. void AutoCompSetOrder(int order); diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index e04d0bea04..31dda9f42d 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -266,6 +266,8 @@ #define wxSTC_SEL_THIN 3 #define wxSTC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE 0 #define wxSTC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 +#define wxSTC_MULTIAUTOC_ONCE 0 +#define wxSTC_MULTIAUTOC_EACH 1 #define wxSTC_ORDER_PRESORTED 0 #define wxSTC_ORDER_PERFORMSORT 1 #define wxSTC_ORDER_CUSTOM 2 @@ -5095,6 +5097,16 @@ public: */ int AutoCompGetCaseInsensitiveBehaviour() const; + /** + Change the effect of autocompleting when there are multiple selections. + */ + void AutoCompSetMulti(int multi); + + /** + Retrieve the effect of autocompleting when there are multiple selections.. + */ + int AutoCompGetMulti() const; + /** Set the way autocompletion lists are ordered. */ diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 78fe754bd2..730dd23116 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -406,6 +406,8 @@ methodOverrideMap = { 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0), 'AutoCSetCaseInsensitiveBehaviour' : ('AutoCompSetCaseInsensitiveBehaviour', 0, 0, 0), 'AutoCGetCaseInsensitiveBehaviour' : ('AutoCompGetCaseInsensitiveBehaviour', 0, 0, 0), + 'AutoCSetMulti' : ('AutoCompSetMulti', 0, 0, 0), + 'AutoCGetMulti' : ('AutoCompGetMulti', 0, 0, 0), 'AutoCSetOrder' : ('AutoCompSetOrder', 0, 0, 0), 'AutoCGetOrder' : ('AutoCompGetOrder', 0, 0, 0), diff --git a/src/stc/scintilla/README.txt b/src/stc/scintilla/README.txt index 39f7624a88..fe78ff9e85 100644 --- a/src/stc/scintilla/README.txt +++ b/src/stc/scintilla/README.txt @@ -3,7 +3,7 @@ directories from the Scintilla source distribution. All other code needed to implement Scintilla on top of wxWidgets is located in the directory above this one. -The current version of the Scintilla code is 3.4.3 +The current version of the Scintilla code is 3.4.4 These are the basic steps needed to update the version of Scintilla used by wxSTC. diff --git a/src/stc/scintilla/include/Scintilla.h b/src/stc/scintilla/include/Scintilla.h index a579b40dbb..a769398d8a 100644 --- a/src/stc/scintilla/include/Scintilla.h +++ b/src/stc/scintilla/include/Scintilla.h @@ -728,6 +728,10 @@ inline int isascii(int c) { return !(c & ~0x7F); } #define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 #define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 #define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 +#define SC_MULTIAUTOC_ONCE 0 +#define SC_MULTIAUTOC_EACH 1 +#define SCI_AUTOCSETMULTI 2636 +#define SCI_AUTOCGETMULTI 2637 #define SC_ORDER_PRESORTED 0 #define SC_ORDER_PERFORMSORT 1 #define SC_ORDER_CUSTOM 2 @@ -1028,7 +1032,7 @@ inline int isascii(int c) { return !(c & ~0x7F); } * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. * So older code that treats Scintilla as a RichEdit will work. */ -#ifdef SCI_NAMESPACE +#if defined(__cplusplus) && defined(SCI_NAMESPACE) namespace Scintilla { #endif @@ -1120,7 +1124,7 @@ struct SCNotification { int updated; /* SCN_UPDATEUI */ }; -#ifdef SCI_NAMESPACE +#if defined(__cplusplus) && defined(SCI_NAMESPACE) } #endif diff --git a/src/stc/scintilla/include/Scintilla.iface b/src/stc/scintilla/include/Scintilla.iface index f6b17bca83..3e5f51b9cf 100644 --- a/src/stc/scintilla/include/Scintilla.iface +++ b/src/stc/scintilla/include/Scintilla.iface @@ -1884,6 +1884,16 @@ set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,) # Get auto-completion case insensitive behaviour. get int AutoCGetCaseInsensitiveBehaviour=2635(,) +enu MultiAutoComplete=SC_MULTIAUTOC_ +val SC_MULTIAUTOC_ONCE=0 +val SC_MULTIAUTOC_EACH=1 + +# Change the effect of autocompleting when there are multiple selections. +set void AutoCSetMulti=2636(int multi,) + +# Retrieve the effect of autocompleting when there are multiple selections.. +get int AutoCGetMulti=2637(,) + enu Ordering=SC_ORDER_ val SC_ORDER_PRESORTED=0 val SC_ORDER_PERFORMSORT=1 diff --git a/src/stc/scintilla/lexers/LexBash.cxx b/src/stc/scintilla/lexers/LexBash.cxx index b85d01a7dc..3ebba8911c 100644 --- a/src/stc/scintilla/lexers/LexBash.cxx +++ b/src/stc/scintilla/lexers/LexBash.cxx @@ -767,6 +767,7 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; + int skipHereCh = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -798,7 +799,15 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], // Here Document folding if (style == SCE_SH_HERE_DELIM) { if (ch == '<' && chNext == '<') { - levelCurrent++; + if (styler.SafeGetCharAt(i + 2) == '<') { + skipHereCh = 1; + } else { + if (skipHereCh == 0) { + levelCurrent++; + } else { + skipHereCh = 0; + } + } } } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_SH_DEFAULT) { levelCurrent--; diff --git a/src/stc/scintilla/lexers/LexCPP.cxx b/src/stc/scintilla/lexers/LexCPP.cxx index 7fe6809918..5485bf228a 100644 --- a/src/stc/scintilla/lexers/LexCPP.cxx +++ b/src/stc/scintilla/lexers/LexCPP.cxx @@ -8,10 +8,10 @@ #include #include -#include #include #include #include +#include #include #include @@ -821,10 +821,18 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, ((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) || ((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8')); if (valid) { - if (literalString) - sc.ChangeState((raw ? SCE_C_STRINGRAW : SCE_C_STRING)|activitySet); - else + if (literalString) { + if (raw) { + // Set the style of the string prefix to SCE_C_STRINGRAW but then change to + // SCE_C_DEFAULT as that allows the raw string start code to run. + sc.ChangeState(SCE_C_STRINGRAW|activitySet); + sc.SetState(SCE_C_DEFAULT|activitySet); + } else { + sc.ChangeState(SCE_C_STRING|activitySet); + } + } else { sc.ChangeState(SCE_C_CHARACTER|activitySet); + } } else { sc.SetState(SCE_C_DEFAULT | activitySet); } @@ -1203,7 +1211,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, while ((endName < restOfLine.length()) && setWord.Contains(static_cast(restOfLine[endName]))) endName++; std::string key = restOfLine.substr(startName, endName-startName); - if (restOfLine[endName] == '(') { + if ((endName < restOfLine.length()) && (restOfLine.at(endName) == '(')) { // Macro size_t endArgs = endName; while ((endArgs < restOfLine.length()) && (restOfLine[endArgs] != ')')) @@ -1212,7 +1220,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, size_t startValue = endArgs+1; while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue])) startValue++; - std::string value = restOfLine.substr(startValue); + std::string value; + if (startValue < restOfLine.length()) + value = restOfLine.substr(startValue); preprocessorDefinitions[key] = SymbolValue(value, args); ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args)); definitionsChanged = true; diff --git a/src/stc/scintilla/lexers/LexDMIS.cxx b/src/stc/scintilla/lexers/LexDMIS.cxx index 7f23ba96b7..a903e9da65 100644 --- a/src/stc/scintilla/lexers/LexDMIS.cxx +++ b/src/stc/scintilla/lexers/LexDMIS.cxx @@ -13,14 +13,14 @@ #include #include "ILexer.h" -#include "SciLexer.h" #include "Scintilla.h" +#include "SciLexer.h" -#include "LexerModule.h" +#include "WordList.h" #include "LexAccessor.h" #include "StyleContext.h" #include "CharacterSet.h" -#include "WordList.h" +#include "LexerModule.h" #ifdef SCI_NAMESPACE using namespace Scintilla; diff --git a/src/stc/scintilla/lexers/LexECL.cxx b/src/stc/scintilla/lexers/LexECL.cxx index 6a08d58c25..d8065f7226 100644 --- a/src/stc/scintilla/lexers/LexECL.cxx +++ b/src/stc/scintilla/lexers/LexECL.cxx @@ -7,10 +7,10 @@ #include #include -#include #include #include #include +#include #ifdef _MSC_VER #pragma warning(disable: 4786) diff --git a/src/stc/scintilla/lexers/LexEScript.cxx b/src/stc/scintilla/lexers/LexEScript.cxx index 9a7560e1e4..28466bc8e0 100644 --- a/src/stc/scintilla/lexers/LexEScript.cxx +++ b/src/stc/scintilla/lexers/LexEScript.cxx @@ -6,10 +6,10 @@ #include #include -#include #include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexers/LexHTML.cxx b/src/stc/scintilla/lexers/LexHTML.cxx index f5da934d2a..d6b0b31bcb 100644 --- a/src/stc/scintilla/lexers/LexHTML.cxx +++ b/src/stc/scintilla/lexers/LexHTML.cxx @@ -576,8 +576,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords - // Lexer for HTML requires more lexical states (8 bits worth) than most lexers - styler.StartAt(startPos, static_cast(STYLE_MAX)); + styler.StartAt(startPos); char prevWord[200]; prevWord[0] = '\0'; char phpStringDelimiter[200]; // PHP is not limited in length, we are @@ -609,7 +608,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (startPos == 0) state = SCE_H_DEFAULT; } - styler.StartAt(startPos, static_cast(STYLE_MAX)); + styler.StartAt(startPos); int lineCurrent = styler.GetLine(startPos); int lineState; @@ -2180,6 +2179,6 @@ static const char * const phpscriptWordListDesc[] = { 0, }; -LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8); -LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8); -LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8); +LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc); +LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc); +LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc); diff --git a/src/stc/scintilla/lexers/LexHaskell.cxx b/src/stc/scintilla/lexers/LexHaskell.cxx index e10cb8c810..24355fa4e4 100644 --- a/src/stc/scintilla/lexers/LexHaskell.cxx +++ b/src/stc/scintilla/lexers/LexHaskell.cxx @@ -38,9 +38,9 @@ #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" +#include "CharacterCategory.h" #include "LexerModule.h" #include "OptionSet.h" -#include "CharacterCategory.h" #ifdef SCI_NAMESPACE using namespace Scintilla; diff --git a/src/stc/scintilla/lexers/LexMySQL.cxx b/src/stc/scintilla/lexers/LexMySQL.cxx index d3e0033b09..b873ccda1f 100644 --- a/src/stc/scintilla/lexers/LexMySQL.cxx +++ b/src/stc/scintilla/lexers/LexMySQL.cxx @@ -570,4 +570,4 @@ static const char * const mysqlWordListDesc[] = { 0 }; -LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc, 7); +LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc); diff --git a/src/stc/scintilla/lexers/LexPS.cxx b/src/stc/scintilla/lexers/LexPS.cxx index 3661c4b66e..2c8917daea 100644 --- a/src/stc/scintilla/lexers/LexPS.cxx +++ b/src/stc/scintilla/lexers/LexPS.cxx @@ -6,6 +6,12 @@ ** The License.txt file describes the conditions under which this software may be distributed. **/ +// Previous releases of this lexer included support for marking token starts with +// a style byte indicator. This was used by the wxGhostscript IDE/debugger. +// Style byte indicators were removed in version 3.4.3. +// Anyone wanting to restore this functionality for wxGhostscript using 'modern' +// indicators can examine the earlier source in the Mercurial repository. + #include #include #include @@ -72,7 +78,6 @@ static void ColourisePSDoc( StyleContext sc(startPos, length, initStyle, styler); - bool tokenizing = styler.GetPropertyInt("ps.tokenize") != 0; int pslevel = styler.GetPropertyInt("ps.level", 3); int lineCurrent = styler.GetLine(startPos); int nestTextCurrent = 0; @@ -83,15 +88,6 @@ static void ColourisePSDoc( bool numHasExponent = false; bool numHasSign = false; - // Clear out existing tokenization - if (tokenizing && length > 0) { - styler.StartAt(startPos, static_cast(INDIC2_MASK)); - styler.ColourTo(startPos + length-1, 0); - styler.Flush(); - styler.StartAt(startPos); - styler.StartSegment(startPos); - } - for (; sc.More(); sc.Forward()) { if (sc.atLineStart) lineCurrent = styler.GetLine(sc.currentPos); @@ -196,7 +192,6 @@ static void ColourisePSDoc( // Determine if a new state should be entered. if (sc.state == SCE_C_DEFAULT) { - unsigned int tokenpos = sc.currentPos; if (sc.ch == '[' || sc.ch == ']') { sc.SetState(SCE_PS_PAREN_ARRAY); @@ -262,17 +257,6 @@ static void ColourisePSDoc( } else if (!IsAWhitespaceChar(sc.ch)) { sc.SetState(SCE_PS_NAME); } - - // Mark the start of tokens - if (tokenizing && sc.state != SCE_C_DEFAULT && sc.state != SCE_PS_COMMENT && - sc.state != SCE_PS_DSC_COMMENT && sc.state != SCE_PS_DSC_VALUE) { - styler.Flush(); - styler.StartAt(tokenpos, static_cast(INDIC2_MASK)); - styler.ColourTo(tokenpos, INDIC2_MASK); - styler.Flush(); - styler.StartAt(tokenpos); - styler.StartSegment(tokenpos); - } } if (sc.atLineEnd) @@ -296,11 +280,10 @@ static void FoldPSDoc(unsigned int startPos, int length, int, WordList *[], int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); - int style; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - style = styleNext; + int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); //mac?? if ((style & 31) == SCE_PS_PAREN_PROC) { diff --git a/src/stc/scintilla/lexers/LexPerl.cxx b/src/stc/scintilla/lexers/LexPerl.cxx index 8fa516b34f..b4a2dd12eb 100644 --- a/src/stc/scintilla/lexers/LexPerl.cxx +++ b/src/stc/scintilla/lexers/LexPerl.cxx @@ -1726,4 +1726,4 @@ void SCI_METHOD LexerPerl::Fold(unsigned int startPos, int length, int /* initSt styler.SetLevel(lineCurrent, levelPrev | flagsNext); } -LexerModule lmPerl(SCLEX_PERL, LexerPerl::LexerFactoryPerl, "perl", perlWordListDesc, 8); +LexerModule lmPerl(SCLEX_PERL, LexerPerl::LexerFactoryPerl, "perl", perlWordListDesc); diff --git a/src/stc/scintilla/lexers/LexRuby.cxx b/src/stc/scintilla/lexers/LexRuby.cxx index e19a5147e7..f818d3d473 100644 --- a/src/stc/scintilla/lexers/LexRuby.cxx +++ b/src/stc/scintilla/lexers/LexRuby.cxx @@ -705,8 +705,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, char chPrev = styler.SafeGetCharAt(startPos - 1); char chNext = styler.SafeGetCharAt(startPos); bool is_real_number = true; // Differentiate between constants and ?-sequences. - // Ruby uses a different mask because bad indentation is marked by oring with 32 - styler.StartAt(startPos, 127); + styler.StartAt(startPos); styler.StartSegment(startPos); static int q_states[] = {SCE_RB_STRING_Q, @@ -1776,4 +1775,4 @@ static const char * const rubyWordListDesc[] = { 0 }; -LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc, 6); +LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc); diff --git a/src/stc/scintilla/lexers/LexRust.cxx b/src/stc/scintilla/lexers/LexRust.cxx index bf59933afb..8a30205327 100644 --- a/src/stc/scintilla/lexers/LexRust.cxx +++ b/src/stc/scintilla/lexers/LexRust.cxx @@ -21,6 +21,7 @@ #include "Scintilla.h" #include "SciLexer.h" +#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -28,7 +29,6 @@ #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" -#include "PropSetSimple.h" #ifdef SCI_NAMESPACE using namespace Scintilla; diff --git a/src/stc/scintilla/lexers/LexScriptol.cxx b/src/stc/scintilla/lexers/LexScriptol.cxx index 31747b88ea..40ef0de580 100644 --- a/src/stc/scintilla/lexers/LexScriptol.cxx +++ b/src/stc/scintilla/lexers/LexScriptol.cxx @@ -127,11 +127,10 @@ static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, } } - styler.StartAt(startPos, 127); + styler.StartAt(startPos); WordList &keywords = *keywordlists[0]; - int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); char prevWord[200]; prevWord[0] = '\0'; if (length == 0) return; @@ -143,37 +142,9 @@ static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, char chPrev2 = ' '; char chNext = styler[startPos]; styler.StartSegment(startPos); - bool atStartLine = true; - int spaceFlags = 0; for (int i = startPos; i < lengthDoc; i++) { - if (atStartLine) - { - char chBad = static_cast(64); - char chGood = static_cast(0); - char chFlags = chGood; - - if (whingeLevel == 1) - { - chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; - } - else if (whingeLevel == 2) - { - chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; - } - else if (whingeLevel == 3) - { - chFlags = (spaceFlags & wsSpace) ? chBad : chGood; - } - else if (whingeLevel == 4) - { - chFlags = (spaceFlags & wsTab) ? chBad : chGood; - } - styler.SetFlags(chFlags, static_cast(state)); - atStartLine = false; - } - char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -185,7 +156,6 @@ static void ColouriseSolDoc(unsigned int startPos, int length, int initStyle, { styler.ColourTo(i, state); } - atStartLine = true; } if (styler.IsLeadByte(ch)) diff --git a/src/stc/scintilla/lexers/LexSpecman.cxx b/src/stc/scintilla/lexers/LexSpecman.cxx index 1b96482ea0..918edaf987 100644 --- a/src/stc/scintilla/lexers/LexSpecman.cxx +++ b/src/stc/scintilla/lexers/LexSpecman.cxx @@ -8,10 +8,10 @@ #include #include -#include #include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexers/LexTCL.cxx b/src/stc/scintilla/lexers/LexTCL.cxx index f6924e05e0..7c883a644b 100644 --- a/src/stc/scintilla/lexers/LexTCL.cxx +++ b/src/stc/scintilla/lexers/LexTCL.cxx @@ -358,7 +358,7 @@ static const char * const tclWordListDesc[] = { "TK Keywords", "iTCL Keywords", "tkCommands", - "expand" + "expand", "user1", "user2", "user3", diff --git a/src/stc/scintilla/lexers/LexVHDL.cxx b/src/stc/scintilla/lexers/LexVHDL.cxx index 88d8efb276..189416425d 100644 --- a/src/stc/scintilla/lexers/LexVHDL.cxx +++ b/src/stc/scintilla/lexers/LexVHDL.cxx @@ -12,10 +12,10 @@ #include #include -#include #include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexers/LexVisualProlog.cxx b/src/stc/scintilla/lexers/LexVisualProlog.cxx index 0acdb26a1c..24e19e24ea 100644 --- a/src/stc/scintilla/lexers/LexVisualProlog.cxx +++ b/src/stc/scintilla/lexers/LexVisualProlog.cxx @@ -13,10 +13,10 @@ #include #include -#include #include #include #include +#include #ifdef _MSC_VER #pragma warning(disable: 4786) diff --git a/src/stc/scintilla/lexlib/Accessor.cxx b/src/stc/scintilla/lexlib/Accessor.cxx index 61661626f8..f67737d4d6 100644 --- a/src/stc/scintilla/lexlib/Accessor.cxx +++ b/src/stc/scintilla/lexlib/Accessor.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexlib/CharacterCategory.cxx b/src/stc/scintilla/lexlib/CharacterCategory.cxx index 765469a3f7..2be46c0130 100644 --- a/src/stc/scintilla/lexlib/CharacterCategory.cxx +++ b/src/stc/scintilla/lexlib/CharacterCategory.cxx @@ -3287,7 +3287,7 @@ const int nRanges = ELEMENTS(catRanges); // Initial version has 3249 entries and adds about 13K to the executable. // The array is in ascending order so can be searched using binary search. // Therefore the average call takes log2(3249) = 12 comparisons. -// For speed, it may be an useful to make a linear table for the common values, +// For speed, it may be useful to make a linear table for the common values, // possibly for 0..0xff for most Western European text or 0..0xfff for most // alphabetic languages. diff --git a/src/stc/scintilla/lexlib/CharacterSet.cxx b/src/stc/scintilla/lexlib/CharacterSet.cxx index 2f41df1166..0ab2cc0cc9 100644 --- a/src/stc/scintilla/lexlib/CharacterSet.cxx +++ b/src/stc/scintilla/lexlib/CharacterSet.cxx @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include "CharacterSet.h" diff --git a/src/stc/scintilla/lexlib/LexAccessor.h b/src/stc/scintilla/lexlib/LexAccessor.h index 45a3a0a93e..35e15726c8 100644 --- a/src/stc/scintilla/lexlib/LexAccessor.h +++ b/src/stc/scintilla/lexlib/LexAccessor.h @@ -29,11 +29,8 @@ private: int codePage; enum EncodingType encodingType; int lenDoc; - int mask; char styleBuf[bufferSize]; int validLen; - char chFlags; - char chWhile; unsigned int startSeg; int startPosStyling; int documentVersion; @@ -58,7 +55,7 @@ public: codePage(pAccess->CodePage()), encodingType(enc8bit), lenDoc(pAccess->Length()), - mask(127), validLen(0), chFlags(0), chWhile(0), + validLen(0), startSeg(0), startPosStyling(0), documentVersion(pAccess->Version()) { switch (codePage) { @@ -111,7 +108,7 @@ public: return true; } char StyleAt(int position) const { - return static_cast(pAccess->StyleAt(position) & mask); + return static_cast(pAccess->StyleAt(position)); } int GetLine(int position) const { return pAccess->LineFromPosition(position); @@ -152,16 +149,10 @@ public: return pAccess->SetLineState(line, state); } // Style setting - void StartAt(unsigned int start, char chMask=31) { - // Store the mask specified for use with StyleAt. - mask = chMask; - pAccess->StartStyling(start, chMask); + void StartAt(unsigned int start) { + pAccess->StartStyling(start, '\377'); startPosStyling = start; } - void SetFlags(char chFlags_, char chWhile_) { - chFlags = chFlags_; - chWhile = chWhile_; - } unsigned int GetStartSegment() const { return startSeg; } @@ -182,9 +173,6 @@ public: // Too big for buffer so send directly pAccess->SetStyleFor(pos - startSeg + 1, static_cast(chAttr)); } else { - if (chAttr != chWhile) - chFlags = 0; - chAttr = static_cast(chAttr | chFlags); for (unsigned int i = startSeg; i <= pos; i++) { assert((startPosStyling + validLen) < Length()); styleBuf[validLen++] = static_cast(chAttr); diff --git a/src/stc/scintilla/lexlib/LexerBase.cxx b/src/stc/scintilla/lexlib/LexerBase.cxx index 0e86562bf9..bbef3f1593 100644 --- a/src/stc/scintilla/lexlib/LexerBase.cxx +++ b/src/stc/scintilla/lexlib/LexerBase.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexlib/LexerModule.cxx b/src/stc/scintilla/lexlib/LexerModule.cxx index c77b317751..6cefbee778 100644 --- a/src/stc/scintilla/lexlib/LexerModule.cxx +++ b/src/stc/scintilla/lexlib/LexerModule.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include @@ -34,28 +34,24 @@ LexerModule::LexerModule(int language_, LexerFunction fnLexer_, const char *languageName_, LexerFunction fnFolder_, - const char *const wordListDescriptions_[], - int styleBits_) : + const char *const wordListDescriptions_[]) : language(language_), fnLexer(fnLexer_), fnFolder(fnFolder_), fnFactory(0), wordListDescriptions(wordListDescriptions_), - styleBits(styleBits_), languageName(languageName_) { } LexerModule::LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[], - int styleBits_) : + const char * const wordListDescriptions_[]) : language(language_), fnLexer(0), fnFolder(0), fnFactory(fnFactory_), wordListDescriptions(wordListDescriptions_), - styleBits(styleBits_), languageName(languageName_) { } @@ -82,10 +78,6 @@ const char *LexerModule::GetWordListDescription(int index) const { } } -int LexerModule::GetStyleBitsNeeded() const { - return styleBits; -} - ILexer *LexerModule::Create() const { if (fnFactory) return fnFactory(); diff --git a/src/stc/scintilla/lexlib/LexerModule.h b/src/stc/scintilla/lexlib/LexerModule.h index 35fa30c69b..ee092e68fd 100644 --- a/src/stc/scintilla/lexlib/LexerModule.h +++ b/src/stc/scintilla/lexlib/LexerModule.h @@ -31,7 +31,6 @@ protected: LexerFunction fnFolder; LexerFactoryFunction fnFactory; const char * const * wordListDescriptions; - int styleBits; public: const char *languageName; @@ -39,13 +38,11 @@ public: LexerFunction fnLexer_, const char *languageName_=0, LexerFunction fnFolder_=0, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=5); + const char * const wordListDescriptions_[] = NULL); LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=8); + const char * const wordListDescriptions_[] = NULL); virtual ~LexerModule() { } int GetLanguage() const { return language; } @@ -54,8 +51,6 @@ public: int GetNumWordLists() const; const char *GetWordListDescription(int index) const; - int GetStyleBitsNeeded() const; - ILexer *Create() const; virtual void Lex(unsigned int startPos, int length, int initStyle, diff --git a/src/stc/scintilla/lexlib/LexerNoExceptions.cxx b/src/stc/scintilla/lexlib/LexerNoExceptions.cxx index 5f31f22688..9ebae2af09 100644 --- a/src/stc/scintilla/lexlib/LexerNoExceptions.cxx +++ b/src/stc/scintilla/lexlib/LexerNoExceptions.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include "ILexer.h" #include "Scintilla.h" diff --git a/src/stc/scintilla/lexlib/LexerSimple.cxx b/src/stc/scintilla/lexlib/LexerSimple.cxx index 5489ab886e..4d0e178ca9 100644 --- a/src/stc/scintilla/lexlib/LexerSimple.cxx +++ b/src/stc/scintilla/lexlib/LexerSimple.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include diff --git a/src/stc/scintilla/lexlib/StyleContext.cxx b/src/stc/scintilla/lexlib/StyleContext.cxx index ec0c5047ce..9429c5ba87 100644 --- a/src/stc/scintilla/lexlib/StyleContext.cxx +++ b/src/stc/scintilla/lexlib/StyleContext.cxx @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include "ILexer.h" diff --git a/src/stc/scintilla/lexlib/StyleContext.h b/src/stc/scintilla/lexlib/StyleContext.h index 9b5ce5dff8..837386cef9 100644 --- a/src/stc/scintilla/lexlib/StyleContext.h +++ b/src/stc/scintilla/lexlib/StyleContext.h @@ -66,7 +66,7 @@ public: int widthNext; StyleContext(unsigned int startPos, unsigned int length, - int initStyle, LexAccessor &styler_, char chMask=31) : + int initStyle, LexAccessor &styler_, char chMask='\377') : styler(styler_), multiByteAccess(0), endPos(startPos + length), @@ -86,7 +86,7 @@ public: if (styler.Encoding() != enc8bit) { multiByteAccess = styler.MultiByteAccess(); } - styler.StartAt(startPos, chMask); + styler.StartAt(startPos /*, chMask*/); styler.StartSegment(startPos); currentLine = styler.GetLine(startPos); lineStartNext = styler.LineStart(currentLine+1); diff --git a/src/stc/scintilla/lexlib/WordList.cxx b/src/stc/scintilla/lexlib/WordList.cxx index 10b6fe349f..68b384a954 100644 --- a/src/stc/scintilla/lexlib/WordList.cxx +++ b/src/stc/scintilla/lexlib/WordList.cxx @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include diff --git a/src/stc/scintilla/src/CaseFolder.cxx b/src/stc/scintilla/src/CaseFolder.cxx index 44a94da6f5..200ac99b8e 100644 --- a/src/stc/scintilla/src/CaseFolder.cxx +++ b/src/stc/scintilla/src/CaseFolder.cxx @@ -8,9 +8,9 @@ #include #include +#include "CaseFolder.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "CaseFolder.h" #ifdef SCI_NAMESPACE using namespace Scintilla; diff --git a/src/stc/scintilla/src/Catalogue.cxx b/src/stc/scintilla/src/Catalogue.cxx index c507296d21..ac1fc3818b 100644 --- a/src/stc/scintilla/src/Catalogue.cxx +++ b/src/stc/scintilla/src/Catalogue.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include diff --git a/src/stc/scintilla/src/CellBuffer.cxx b/src/stc/scintilla/src/CellBuffer.cxx index c050608656..0c56c9e927 100644 --- a/src/stc/scintilla/src/CellBuffer.cxx +++ b/src/stc/scintilla/src/CellBuffer.cxx @@ -413,25 +413,24 @@ const char *CellBuffer::InsertString(int position, const char *s, int insertLeng return data; } -bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) { - styleValue &= mask; +bool CellBuffer::SetStyleAt(int position, char styleValue) { char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast((curVal & ~mask) | styleValue)); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); return true; } else { return false; } } -bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) { +bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) { bool changed = false; PLATFORM_ASSERT(lengthStyle == 0 || (lengthStyle > 0 && lengthStyle + position <= style.Length())); while (lengthStyle--) { char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast((curVal & ~mask) | styleValue)); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); changed = true; } position++; diff --git a/src/stc/scintilla/src/CellBuffer.h b/src/stc/scintilla/src/CellBuffer.h index 6b719de275..f07b459832 100644 --- a/src/stc/scintilla/src/CellBuffer.h +++ b/src/stc/scintilla/src/CellBuffer.h @@ -180,8 +180,8 @@ public: /// Setting styles for positions outside the range of the buffer is safe and has no effect. /// @return true if the style of a character is changed. - bool SetStyleAt(int position, char styleValue, char mask='\377'); - bool SetStyleFor(int position, int length, char styleValue, char mask); + bool SetStyleAt(int position, char styleValue); + bool SetStyleFor(int position, int length, char styleValue); const char *DeleteChars(int position, int deleteLength, bool &startSequence); diff --git a/src/stc/scintilla/src/Document.cxx b/src/stc/scintilla/src/Document.cxx index 0108669c29..32d5f18960 100644 --- a/src/stc/scintilla/src/Document.cxx +++ b/src/stc/scintilla/src/Document.cxx @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include #include @@ -20,13 +20,13 @@ #include "ILexer.h" #include "Scintilla.h" +#include "CharacterSet.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "CellBuffer.h" #include "PerLine.h" #include "CharClassify.h" -#include "CharacterSet.h" #include "Decoration.h" #include "CaseFolder.h" #include "Document.h" @@ -58,7 +58,7 @@ void LexInterface::Colourise(int start, int end) { int styleStart = 0; if (start > 0) - styleStart = pdoc->StyleAt(start - 1) & pdoc->stylingBitsMask; + styleStart = pdoc->StyleAt(start - 1); if (len > 0) { instance->Lex(start, len, styleStart, pdoc); @@ -90,9 +90,6 @@ Document::Document() { #endif dbcsCodePage = 0; lineEndBitSet = SC_LINE_END_TYPE_DEFAULT; - stylingBits = 5; - stylingBitsMask = 0x1F; - stylingMask = 0; endStyled = 0; styleClock = 0; enteredModification = 0; @@ -1712,13 +1709,7 @@ int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *bu return charClass.GetCharsOfClass(characterClass, buffer); } -void Document::SetStylingBits(int bits) { - stylingBits = bits; - stylingBitsMask = (1 << stylingBits) - 1; -} - -void SCI_METHOD Document::StartStyling(int position, char mask) { - stylingMask = mask; +void SCI_METHOD Document::StartStyling(int position, char) { endStyled = position; } @@ -1727,9 +1718,8 @@ bool SCI_METHOD Document::SetStyleFor(int length, char style) { return false; } else { enteredStyling++; - style &= stylingMask; int prevEndStyled = endStyled; - if (cb.SetStyleFor(endStyled, length, style, stylingMask)) { + if (cb.SetStyleFor(endStyled, length, style)) { DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, prevEndStyled, length); NotifyModified(mh); @@ -1750,7 +1740,7 @@ bool SCI_METHOD Document::SetStyles(int length, const char *styles) { int endMod = 0; for (int iPos = 0; iPos < length; iPos++, endStyled++) { PLATFORM_ASSERT(endStyled < Length()); - if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) { + if (cb.SetStyleAt(endStyled, styles[iPos])) { if (!didChange) { startMod = endStyled; } @@ -2080,7 +2070,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { char chSeek = BraceOpposite(chBrace); if (chSeek == '\0') return - 1; - char styBrace = static_cast(StyleAt(position) & stylingBitsMask); + char styBrace = static_cast(StyleAt(position)); int direction = -1; if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') direction = 1; @@ -2088,7 +2078,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { position = NextPosition(position, direction); while ((position >= 0) && (position < Length())) { char chAtPos = CharAt(position); - char styAtPos = static_cast(StyleAt(position) & stylingBitsMask); + char styAtPos = static_cast(StyleAt(position)); if ((position > GetEndStyled()) || (styAtPos == styBrace)) { if (chAtPos == chBrace) depth++; diff --git a/src/stc/scintilla/src/Document.h b/src/stc/scintilla/src/Document.h index e2414bd364..a59f192a96 100644 --- a/src/stc/scintilla/src/Document.h +++ b/src/stc/scintilla/src/Document.h @@ -39,6 +39,10 @@ public: start(start_), end(end_) { } + bool operator==(const Range &other) const { + return (start == other.start) && (end == other.end); + } + bool Valid() const { return (start != invalidPosition) && (end != invalidPosition); } @@ -206,7 +210,6 @@ private: CellBuffer cb; CharClassify charClass; CaseFolder *pcf; - char stylingMask; int endStyled; int styleClock; int enteredModification; @@ -229,9 +232,6 @@ public: LexInterface *pli; - int stylingBits; - int stylingBitsMask; - int eolMode; /// Can also be SC_CP_UTF8 to enable UTF-8 mode int dbcsCodePage; @@ -369,7 +369,6 @@ public: void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer); - void SetStylingBits(int bits); void SCI_METHOD StartStyling(int position, char mask); bool SCI_METHOD SetStyleFor(int length, char style); bool SCI_METHOD SetStyles(int length, const char *styles); diff --git a/src/stc/scintilla/src/Editor.cxx b/src/stc/scintilla/src/Editor.cxx index 4966d8efd7..db0aecf43b 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -220,8 +220,7 @@ Editor::Editor() { convertPastes = true; - hsStart = -1; - hsEnd = -1; + hotspot = Range(invalidPosition); llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); @@ -885,9 +884,8 @@ bool Editor::RangeContainsProtected(int start, int end) const { start = end; end = t; } - int mask = pdoc->stylingBitsMask; for (int pos = start; pos < end; pos++) { - if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) + if (vs.styles[pdoc->StyleAt(pos)].IsProtected()) return true; } } @@ -916,17 +914,16 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov if (posMoved != pos.Position()) pos.SetPosition(posMoved); if (vs.ProtectionActive()) { - int mask = pdoc->stylingBitsMask; if (moveDir > 0) { - if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected()) { + if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()) { while ((pos.Position() < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { - if (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected()) { + if (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()) { while ((pos.Position() > 0) && - (vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected())) pos.Add(-1); } } @@ -1741,7 +1738,7 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const { return markerCheck; } -bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { +bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { for (size_t iStyle=0; iStyle(styles[endSegment+1]) == style)) endSegment++; - width += static_cast(surface->WidthText(vs.styles[style + styleOffset].font, text + start, + FontAlias fontText = vs.styles[style + styleOffset].font; + width += static_cast(surface->WidthText(fontText, text + start, static_cast(endSegment - start + 1))); start = endSegment + 1; } return width; } -static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { +static int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, const StyledText &st) { int widthMax = 0; size_t start = 0; while (start < st.length) { @@ -1779,7 +1777,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { - widthSubLine = static_cast(surface->WidthText(vs.styles[styleOffset + st.style].font, + FontAlias fontText = vs.styles[styleOffset + st.style].font; + widthSubLine = static_cast(surface->WidthText(fontText, st.text + start, static_cast(lenLine))); } if (widthSubLine > widthMax) @@ -1789,7 +1788,13 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con return widthMax; } -void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, +static void DrawTextInStyle(Surface *surface, PRectangle rcText, const Style &style, XYPOSITION ybase, const char *s, size_t length) { + FontAlias fontText = style.font; + surface->DrawTextNoClip(rcText, fontText, ybase, s, static_cast(length), + style.fore, style.back); +} + +static void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { @@ -1797,30 +1802,25 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle size_t i = 0; while (i < length) { size_t end = i; - int style = st.styles[i + start]; + size_t style = st.styles[i + start]; while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; - int width = static_cast(surface->WidthText(vs.styles[style].font, + FontAlias fontText = vs.styles[style].font; + const int width = static_cast(surface->WidthText(fontText, st.text + start + i, static_cast(end - i + 1))); PRectangle rcSegment = rcText; rcSegment.left = static_cast(x); rcSegment.right = static_cast(x + width + 1); - surface->DrawTextNoClip(rcSegment, vs.styles[style].font, - static_cast(ascent), st.text + start + i, - static_cast(end - i + 1), - vs.styles[style].fore, - vs.styles[style].back); + DrawTextInStyle(surface, rcSegment, vs.styles[style], rcText.top + vs.maxAscent, + st.text + start + i, end - i + 1); x += width; i = end + 1; } } else { - size_t style = st.style + styleOffset; - surface->DrawTextNoClip(rcText, vs.styles[style].font, - rcText.top + vs.maxAscent, st.text + start, - static_cast(length), - vs.styles[style].fore, - vs.styles[style].back); + const size_t style = st.style + styleOffset; + DrawTextInStyle(surface, rcText, vs.styles[style], rcText.top + vs.maxAscent, + st.text + start, length); } } @@ -1832,6 +1832,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { RefreshStyleData(); RefreshPixMaps(surfWindow); + // On GTK+ with Ubuntu overlay scroll bars, the surface may have been finished + // at this point. The Initialised call checks for this case and sets the status + // to be bad which avoids crashes in following calls. + if (!surfWindow->Initialised()) { + return; + } + PRectangle rcMargin = GetClientRectangle(); Point ptOrigin = GetVisibleOriginInMain(); rcMargin.Move(0, -ptOrigin.y); @@ -2057,10 +2064,8 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { XYPOSITION width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number)); XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding; rcNumber.left = xpos; - surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, - rcNumber.top + vs.maxAscent, number, istrlen(number), - vs.styles[STYLE_LINENUMBER].fore, - vs.styles[STYLE_LINENUMBER].back); + DrawTextInStyle(surface, rcNumber, vs.styles[STYLE_LINENUMBER], + rcNumber.top + vs.maxAscent, number, strlen(number)); } else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) { PRectangle rcWrapMarker = rcMarker; rcWrapMarker.right -= 3; @@ -2077,7 +2082,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } - DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, static_cast(rcMarker.top) + vs.maxAscent, + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, stMargin, 0, stMargin.length); } } @@ -2157,8 +2162,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ -void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { -//void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width, Document *pdoc, PositionCache &posCache, SpecialRepresentations &reprs) { +void Editor::LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; @@ -2178,7 +2182,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (lineLength == ll->numCharsInLine) { // See if chars, styles, indicators, are all the same bool allSame = true; - const int styleMask = pdoc->stylingBitsMask; // Check base line layout char styleByte = 0; int numCharsInLine = 0; @@ -2187,9 +2190,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou char chDoc = pdoc->CharAt(charInDoc); styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && - (ll->styles[numCharsInLine] == static_cast(styleByte & styleMask)); - allSame = allSame && - (ll->indicators[numCharsInLine] == static_cast(styleByte & ~styleMask)); + (ll->styles[numCharsInLine] == static_cast(styleByte)); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) allSame = allSame && (ll->chars[numCharsInLine] == chDoc); @@ -2223,8 +2224,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->edgeColumn = -1; } - const int styleMask = pdoc->stylingBitsMask; - ll->styleBitsSet = 0; // Fill base line layout const int lineLength = posLineEnd - posLineStart; pdoc->GetCharRange(ll->chars, posLineStart, lineLength); @@ -2233,11 +2232,9 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) { const unsigned char styleByte = ll->styles[styleInLine]; - ll->styleBitsSet |= styleByte; - ll->styles[styleInLine] = styleByte & styleMask; - ll->indicators[styleInLine] = static_cast(styleByte & ~styleMask); + ll->styles[styleInLine] = styleByte; } - const unsigned char styleByteLast = ((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask; + const unsigned char styleByteLast = (lineLength > 0) ? ll->styles[lineLength-1] : 0; if (vstyle.someStylesForceCase) { for (int charInLine = 0; charInLinechars[charInLine]; @@ -2251,14 +2248,13 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou // Extra element at the end of the line to hold end x position and act as ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character ll->styles[numCharsInLine] = styleByteLast; // For eolFilled - ll->indicators[numCharsInLine] = 0; // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. ll->positions[0] = 0; bool lastSegItalics = false; - BreakFinder bfLayout(ll, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs); + BreakFinder bfLayout(ll, NULL, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs); while (bfLayout.More()) { const TextSegment ts = bfLayout.Next(); @@ -2390,14 +2386,14 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } } -ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const { +ColourDesired Editor::SelectionBackground(const ViewStyle &vsDraw, bool main) const { return main ? (primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) : vsDraw.selAdditionalBackground; } -ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, - ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const { +ColourDesired Editor::TextBackground(const ViewStyle &vsDraw, + ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const { if (inSelection == 1) { if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, true); @@ -2414,7 +2410,7 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, if (inHotspot && vsDraw.hotspotColours.back.isSet) return vsDraw.hotspotColours.back; } - if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) { + if (background.isSet && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) { return background; } else { return vsDraw.styles[styleMain].back; @@ -2478,12 +2474,12 @@ static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired } } -void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, +void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) { if (!twoPhaseDraw) { surface->FillRectangle(rcSegment, textBack); } - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; int normalCharHeight = static_cast(surface->Ascent(ctrlCharsFont) - surface->InternalLeading(ctrlCharsFont)); PRectangle rcCChar = rcSegment; @@ -2502,13 +2498,11 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, textBack, textFore); } -void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, +void Editor::DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, - bool overrideBackground, ColourDesired background, - bool drawWrapMarkEnd, ColourDesired wrapColour) { + ColourOptional background) { const int posLineStart = pdoc->LineStart(line); - const int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); @@ -2523,7 +2517,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (virtualSpace) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; - surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back); if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line)))); for (size_t r=0; rchars[eolPos]; int styleMain = ll->styles[eolPos]; - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll); + ColourDesired textBack = TextBackground(vsDraw, background, eolInSelection, false, styleMain, eolPos, ll); if (UTF8IsAscii(chEOL)) { ctrlChar = ControlCharacterString(chEOL); } else { - Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); + const Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); if (repr) { ctrlChar = repr->stringRep.c_str(); eolPos = ll->numCharsInLine; @@ -2604,12 +2598,12 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { - if (overrideBackground) { + if (background.isSet) { surface->FillRectangle(rcSegment, background); } else if (line < pdoc->LinesTotal() - 1) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } @@ -2627,10 +2621,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { - if (overrideBackground) { + if (background.isSet) { surface->FillRectangle(rcSegment, background); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } @@ -2639,6 +2633,14 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin } } + bool drawWrapMarkEnd = false; + + if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { + if (subLine + 1 < ll->lines) { + drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; + } + } + if (drawWrapMarkEnd) { PRectangle rcPlace = rcSegment; @@ -2650,11 +2652,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin rcPlace.right = rcLine.right; rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; } - DrawWrapMarker(surface, rcPlace, true, wrapColour); + DrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour()); } } -void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, +void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( @@ -2665,45 +2667,13 @@ void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surf vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine); } -void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { // Draw decorators const int posLineStart = pdoc->LineStart(line); const int lineStart = ll->LineStart(subLine); const int posLineEnd = posLineStart + lineEnd; - if (!under) { - // Draw indicators - // foreach indicator... - for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { - if (!(mask & ll->styleBitsSet)) { - mask <<= 1; - continue; - } - int startPos = -1; - // foreach style pos in line... - for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { - // look for starts... - if (startPos < 0) { - // NOT in indicator run, looking for START - if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) - startPos = indicPos; - } - // ... or ends - if (startPos >= 0) { - // IN indicator run, looking for END - if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { - // AT end of indicator run, DRAW it! - DrawIndicator(indicnum, startPos, indicPos, surface, vsDraw, xStart, rcLine, ll, subLine); - // RESET control var - startPos = -1; - } - } - } - mask <<= 1; - } - } - for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { if (under == vsDraw.indicators[deco->indicator].under) { int startPos = posLineStart + lineStart; @@ -2725,9 +2695,9 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } // Use indicators to highlight matching braces - if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || - (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { - int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vs.braceHighlightIndicator : vs.braceBadLightIndicator; + if ((vsDraw.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || + (vsDraw.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { + int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator; if (under == vsDraw.indicators[braceIndicator].under) { Range rangeLine(posLineStart + lineStart, posLineEnd); if (rangeLine.ContainsCharacter(braces[0])) { @@ -2746,7 +2716,7 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = static_cast(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; @@ -2755,15 +2725,15 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back); rcSegment.left = static_cast(xStart); - if (trackLineWidth || (vs.annotationVisible == ANNOTATION_BOXED)) { + if (trackLineWidth || (vsDraw.annotationVisible == ANNOTATION_BOXED)) { // Only care about calculating width if tracking or need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { widthAnnotation += static_cast(vsDraw.spaceWidth * 2); // Margins } if (widthAnnotation > lineWidthMaxSeen) lineWidthMaxSeen = widthAnnotation; - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { rcSegment.left = static_cast(xStart + indent); rcSegment.right = rcSegment.left + widthAnnotation; } @@ -2778,14 +2748,14 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x lineInAnnotation++; } PRectangle rcText = rcSegment; - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; } - DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, static_cast(rcText.top + vsDraw.maxAscent), + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, stAnnotation, start, lengthAnnotation); - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); surface->MoveTo(static_cast(rcSegment.left), static_cast(rcSegment.top)); surface->LineTo(static_cast(rcSegment.left), static_cast(rcSegment.bottom)); @@ -2803,7 +2773,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, +void Editor::DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { if (subLine >= ll->lines) { @@ -2816,49 +2786,13 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Using one font for all control characters so it can be controlled independently to ensure // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - // See if something overrides the line background color: Either if caret is on the line - // and background color is set for that, or if a marker is defined that forces its background - // color onto the line, or if a marker is defined but has no selection margin in which to - // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order - // with the earlier taking precedence. When multiple markers cause background override, - // the color for the highest numbered one is used. - bool overrideBackground = false; - ColourDesired background; - if ((caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) { - overrideBackground = true; - background = vsDraw.caretLineBackground; - } - if (!overrideBackground) { - int marks = pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && - (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { - background = vsDraw.markers[markBit].back; - overrideBackground = true; - } - marks >>= 1; - } - } - if (!overrideBackground) { - if (vsDraw.maskInLine) { - int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; - if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { - if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && - (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { - overrideBackground = true; - background = vsDraw.markers[markBit].back; - } - marksMasked >>= 1; - } - } - } - } + // See if something overrides the line background color. + const ColourOptional background = vsDraw.Background(pdoc->GetMark(line), caret.active, ll->containsCaret); const bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) && - (!overrideBackground) && (vsDraw.whitespaceColours.back.isSet); + (!background.isSet) && (vsDraw.whitespaceColours.back.isSet); bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth; @@ -2878,16 +2812,6 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } - const ColourDesired wrapColour = vsDraw.WrapColour(); - - bool drawWrapMarkEnd = false; - - if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { - if (subLine + 1 < ll->lines) { - drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; - } - } - if (ll->wrapIndent != 0) { bool continuedWrapLine = false; @@ -2903,7 +2827,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. - surface->FillRectangle(rcSegment, overrideBackground ? background : + surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[STYLE_DEFAULT].back); // main line style would be below but this would be inconsistent with end markers @@ -2918,7 +2842,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis else rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; - DrawWrapMarker(surface, rcPlace, false, wrapColour); + DrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour()); } xStart += static_cast(ll->wrapIndent); @@ -2931,10 +2855,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Does not take margin into account but not significant const int xStartVisible = static_cast(subLineStart) - xStart; - ll->psel = &sel; - if (twoPhaseDraw) { - BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs); + BreakFinder bfBack(ll, &sel, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs); // Background drawing loop while (bfBack.More()) { @@ -2955,8 +2877,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcSegment.right = rcLine.right; const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); - const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, + const bool inHotspot = (ll->hotspot.Valid()) && ll->hotspot.ContainsCharacter(iDoc); + ColourDesired textBack = TextBackground(vsDraw, background, inSelection, inHotspot, ll->styles[i], i, ll); if (ts.representation) { if (ll->chars[i] == '\t') { @@ -2997,8 +2919,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background, - drawWrapMarkEnd, wrapColour); + xStart, subLine, subLineStart, background); } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); @@ -3027,7 +2948,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop - BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, xStartVisible, + BreakFinder bfFore(ll, &sel, lineStart, lineEnd, posLineStart, xStartVisible, ((!twoPhaseDraw && selBackDrawn) || vsDraw.selColours.fore.isSet), pdoc, &reprs); while (bfFore.More()) { @@ -3043,9 +2964,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (rcSegment.Intersects(rcLine)) { int styleMain = ll->styles[i]; ColourDesired textFore = vsDraw.styles[styleMain].fore; - Font &textFont = vsDraw.styles[styleMain].font; + FontAlias textFont = vsDraw.styles[styleMain].font; //hotspot foreground - if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { + const bool inHotspot = (ll->hotspot.Valid()) && ll->hotspot.ContainsCharacter(iDoc); + if (inHotspot) { if (vsDraw.hotspotColours.fore.isSet) textFore = vsDraw.hotspotColours.fore; } @@ -3053,8 +2975,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (inSelection && (vsDraw.selColours.fore.isSet)) { textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground; } - const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); + ColourDesired textBack = TextBackground(vsDraw, background, inSelection, inHotspot, styleMain, i, ll); if (ts.representation) { if (ll->chars[i] == '\t') { // Tab display @@ -3130,8 +3051,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } PRectangle rcDot(xmid + xStart - static_cast(subLineStart), rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); - rcDot.right = rcDot.left + vs.whitespaceSize; - rcDot.bottom = rcDot.top + vs.whitespaceSize; + rcDot.right = rcDot.left + vsDraw.whitespaceSize; + rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } @@ -3152,7 +3073,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } } - if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd) { + if (ll->hotspot.Valid() && vsDraw.hotspotUnderline && ll->hotspot.ContainsCharacter(iDoc)) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; @@ -3225,8 +3146,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // End of the drawing of the current line if (!twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background, - drawWrapMarkEnd, wrapColour); + xStart, subLine, subLineStart, background); } if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) { // For each selection draw @@ -3289,8 +3209,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } -void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, - int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) { +void Editor::DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) const { int lineStart = ll->LineStart(subLine); int posBefore = posCaret; @@ -3348,7 +3268,8 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. int styleMain = ll->styles[offsetFirstChar]; - surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, + FontAlias fontText = vsDraw.styles[styleMain].font; + surface->DrawTextClipped(rcCaret, fontText, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back, caretColour); @@ -3422,7 +3343,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { } } -void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, +void Editor::DrawCarets(Surface *surface, const ViewStyle &vsDraw, int lineDoc, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { // When drag is active it is the only caret drawn bool drawDrag = posDrag.IsValid(); @@ -3654,7 +3575,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll->containsCaret = false; } - GetHotSpotRange(ll->hsStart, ll->hsEnd); + ll->hotspot = GetHotSpotRange(); PRectangle rcLine = rcTextArea; rcLine.top = static_cast(ypos); @@ -6536,7 +6457,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } bool Editor::PositionIsHotspot(int position) const { - return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; + return vs.styles[pdoc->StyleAt(position)].hotspot; } bool Editor::PointIsHotspot(Point pt) { @@ -6553,35 +6474,28 @@ 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, vs.hotspotSingleLine); - int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); + Range hsNew; + hsNew.start = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); + hsNew.end = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... - if (hsStart_ != hsStart || hsEnd_ != hsEnd) { - if (hsStart != -1) { - InvalidateRange(hsStart, hsEnd); + if (!(hsNew == hotspot)) { + if (hotspot.Valid()) { + InvalidateRange(hotspot.start, hotspot.end); } - hsStart = hsStart_; - hsEnd = hsEnd_; - InvalidateRange(hsStart, hsEnd); + hotspot = hsNew; + InvalidateRange(hotspot.start, hotspot.end); } } else { - if (hsStart != -1) { - int hsStart_ = hsStart; - int hsEnd_ = hsEnd; - hsStart = -1; - hsEnd = -1; - InvalidateRange(hsStart_, hsEnd_); - } else { - hsStart = -1; - hsEnd = -1; + if (hotspot.Valid()) { + InvalidateRange(hotspot.start, hotspot.end); } + hotspot = Range(invalidPosition); } } -void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) const { - hsStart_ = hsStart; - hsEnd_ = hsEnd; +Range Editor::GetHotSpotRange() const { + return hotspot; } void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { @@ -6668,7 +6582,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { } EnsureCaretVisible(false, false, true); - if (hsStart != -1 && !PointIsHotspot(pt)) + if (hotspot.Valid() && !PointIsHotspot(pt)) SetHotSpotRange(NULL); if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt,true,true) != hotSpotClickPos) { @@ -8647,12 +8561,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; case SCI_SETSTYLEBITS: - vs.EnsureStyle((1 << wParam) - 1); - pdoc->SetStylingBits(static_cast(wParam)); + vs.EnsureStyle(0xff); break; case SCI_GETSTYLEBITS: - return pdoc->stylingBits; + return 8; case SCI_SETLINESTATE: return pdoc->SetLineState(static_cast(wParam), static_cast(lParam)); @@ -9293,7 +9206,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETREPRESENTATION: { - Representation *repr = reprs.RepresentationFromCharacter( + const Representation *repr = reprs.RepresentationFromCharacter( reinterpret_cast(wParam), UTF8MaxBytes); if (repr) { return StringResult(lParam, repr->stringRep.c_str()); diff --git a/src/stc/scintilla/src/Editor.h b/src/stc/scintilla/src/Editor.h index 15a0fcf047..c7d44c16d6 100644 --- a/src/stc/scintilla/src/Editor.h +++ b/src/stc/scintilla/src/Editor.h @@ -309,8 +309,7 @@ protected: // ScintillaBase subclass needs access to much of Editor ContractionState cs; // Hotspot support - int hsStart; - int hsEnd; + Range hotspot; // Wrapping support int wrapWidth; @@ -435,27 +434,26 @@ protected: // ScintillaBase subclass needs access to much of Editor int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const; void PaintSelMargin(Surface *surface, PRectangle &rc); LineLayout *RetrieveLineLayout(int lineNumber); - void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, + void LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width=LineLayout::wrapWidthInfinite); - ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main) const; - ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const; + ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main) const; + ColourDesired TextBackground(const ViewStyle &vsDraw, ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const; void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight); static void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); - void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, + void DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, - bool overrideBackground, ColourDesired background, - bool drawWrapMark, ColourDesired wrapColour); - static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, + ColourOptional background); + static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under); - void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, + void DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, - int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour); - void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) const; + void DrawCarets(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); @@ -623,7 +621,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool PositionIsHotspot(int position) const; bool PointIsHotspot(Point pt); void SetHotSpotRange(Point *pt); - void GetHotSpotRange(int &hsStart, int &hsEnd) const; + Range GetHotSpotRange() const; int CodePage() const; virtual bool ValidCodePage(int /* codePage */) const { return true; } diff --git a/src/stc/scintilla/src/ExternalLexer.cxx b/src/stc/scintilla/src/ExternalLexer.cxx index 6823208892..25d83ceb8b 100644 --- a/src/stc/scintilla/src/ExternalLexer.cxx +++ b/src/stc/scintilla/src/ExternalLexer.cxx @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include diff --git a/src/stc/scintilla/src/Indicator.cxx b/src/stc/scintilla/src/Indicator.cxx index 63735d4804..d8ad64ed6b 100644 --- a/src/stc/scintilla/src/Indicator.cxx +++ b/src/stc/scintilla/src/Indicator.cxx @@ -11,8 +11,8 @@ #include "Platform.h" #include "Scintilla.h" -#include "XPM.h" #include "Indicator.h" +#include "XPM.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -23,7 +23,7 @@ static PRectangle PixelGridAlign(const PRectangle &rc) { return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom)); } -void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const { surface->PenColour(fore); int ymid = static_cast(rc.bottom + rc.top) / 2; if (style == INDIC_SQUIGGLE) { diff --git a/src/stc/scintilla/src/Indicator.h b/src/stc/scintilla/src/Indicator.h index 0284a855bc..beda8214b9 100644 --- a/src/stc/scintilla/src/Indicator.h +++ b/src/stc/scintilla/src/Indicator.h @@ -23,7 +23,7 @@ public: int outlineAlpha; Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)), fillAlpha(30), outlineAlpha(50) { } - void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine); + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const; }; #ifdef SCI_NAMESPACE diff --git a/src/stc/scintilla/src/LineMarker.cxx b/src/stc/scintilla/src/LineMarker.cxx index 938288b1f0..8ae815a653 100644 --- a/src/stc/scintilla/src/LineMarker.cxx +++ b/src/stc/scintilla/src/LineMarker.cxx @@ -71,7 +71,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C surface->FillRectangle(rcH, fore); } -void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) { +void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const { ColourDesired head = back; ColourDesired body = back; ColourDesired tail = back; diff --git a/src/stc/scintilla/src/LineMarker.h b/src/stc/scintilla/src/LineMarker.h index c8c9e10a19..4004a8a427 100644 --- a/src/stc/scintilla/src/LineMarker.h +++ b/src/stc/scintilla/src/LineMarker.h @@ -66,7 +66,7 @@ public: void SetXPM(const char *textForm); void SetXPM(const char *const *linesForm); void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); - void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle); + void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const; }; #ifdef SCI_NAMESPACE diff --git a/src/stc/scintilla/src/PositionCache.cxx b/src/stc/scintilla/src/PositionCache.cxx index 2a120c1cf5..9e55c1a82f 100644 --- a/src/stc/scintilla/src/PositionCache.cxx +++ b/src/stc/scintilla/src/PositionCache.cxx @@ -17,6 +17,7 @@ #include "Platform.h" +#include "ILexer.h" #include "Scintilla.h" #include "SplitVector.h" @@ -32,7 +33,6 @@ #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" -#include "ILexer.h" #include "CaseFolder.h" #include "Document.h" #include "UniConversion.h" @@ -54,16 +54,12 @@ LineLayout::LineLayout(int maxLineLength_) : validity(llInvalid), xHighlightGuide(0), highlightColumn(0), - psel(NULL), containsCaret(false), edgeColumn(0), chars(0), styles(0), - styleBitsSet(0), - indicators(0), positions(0), - hsStart(0), - hsEnd(0), + hotspot(0,0), widthLine(wrapWidthInfinite), lines(1), wrapIndent(0) { @@ -81,7 +77,6 @@ void LineLayout::Resize(int maxLineLength_) { Free(); chars = new char[maxLineLength_ + 1]; styles = new unsigned char[maxLineLength_ + 1]; - indicators = new char[maxLineLength_ + 1]; // Extra position allocated as sometimes the Windows // GetTextExtentExPoint API writes an extra element. positions = new XYPOSITION[maxLineLength_ + 1 + 1]; @@ -94,8 +89,6 @@ void LineLayout::Free() { chars = 0; delete []styles; styles = 0; - delete []indicators; - indicators = 0; delete []positions; positions = 0; delete []lineStarts; @@ -153,7 +146,7 @@ void LineLayout::SetLineStart(int line, int start) { lineStarts[line] = start; } -void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], +void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; @@ -175,7 +168,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], } } -void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle) { +void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { @@ -410,11 +403,11 @@ void SpecialRepresentations::ClearRepresentation(const char *charBytes) { } } -Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) { +const Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) const { PLATFORM_ASSERT(len <= 4); if (!startByteHasReprs[static_cast(charBytes[0])]) return 0; - MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, len)); + MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len)); if (it != mapReprs.end()) { return &(it->second); } @@ -445,8 +438,8 @@ void BreakFinder::Insert(int val) { } } -BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, - int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_) : +BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_, + int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) : ll(ll_), lineStart(lineStart_), lineEnd(lineEnd_), @@ -472,8 +465,8 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL SelectionPosition posStart(posLineStart); SelectionPosition posEnd(posLineStart + lineEnd); SelectionSegment segmentLine(posStart, posEnd); - for (size_t r=0; rpsel->Count(); r++) { - SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine); + for (size_t r=0; rCount(); r++) { + SelectionSegment portion = psel->Range(r).Intersect(segmentLine); if (!(portion.start == portion.end)) { if (portion.start.IsValid()) Insert(portion.start.Position() - posLineStart); @@ -500,7 +493,7 @@ TextSegment BreakFinder::Next() { charWidth = UTF8DrawBytes(reinterpret_cast(ll->chars) + nextBreak, lineEnd - nextBreak); else if (encodingFamily == efDBCS) charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1; - Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); + const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) || repr || (nextBreak == saeNext)) { @@ -565,7 +558,7 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, for (unsigned int i=0; i(positions + len), s_, len); + memcpy(reinterpret_cast(reinterpret_cast(positions + len)), s_, len); } } @@ -584,7 +577,7 @@ void PositionCacheEntry::Clear() { bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const { if ((styleNumber == styleNumber_) && (len == len_) && - (memcmp(reinterpret_cast(positions + len), s_, len)== 0)) { + (memcmp(reinterpret_cast(reinterpret_cast(positions + len)), s_, len)== 0)) { for (unsigned int i=0; iSafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); - surface->MeasureWidths(vstyle.styles[styleNumber].font, s + startSegment, lenSegment, positions + startSegment); + FontAlias fontStyle = vstyle.styles[styleNumber].font; + surface->MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment); for (unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) { positions[startSegment + inSeg] += xStartSegment; } @@ -680,7 +674,8 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned startSegment += lenSegment; } } else { - surface->MeasureWidths(vstyle.styles[styleNumber].font, s, len, positions); + FontAlias fontStyle = vstyle.styles[styleNumber].font; + surface->MeasureWidths(fontStyle, s, len, positions); } if (probe < pces.size()) { // Store into cache diff --git a/src/stc/scintilla/src/PositionCache.h b/src/stc/scintilla/src/PositionCache.h index d8ea0119df..05005e9ac6 100644 --- a/src/stc/scintilla/src/PositionCache.h +++ b/src/stc/scintilla/src/PositionCache.h @@ -34,19 +34,15 @@ public: enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity; int xHighlightGuide; bool highlightColumn; - Selection *psel; bool containsCaret; int edgeColumn; char *chars; unsigned char *styles; - int styleBitsSet; - char *indicators; XYPOSITION *positions; char bracePreviousStyles[2]; // Hotspot support - int hsStart; - int hsEnd; + Range hotspot; // Wrapped line support int widthLine; @@ -63,9 +59,9 @@ public: Range SubLineRange(int line) const; bool InLine(int offset, int line) const; void SetLineStart(int line, int start); - void SetBracesHighlight(Range rangeLine, Position braces[], + void SetBracesHighlight(Range rangeLine, const Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle); - void RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle); + void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle); int FindBefore(XYPOSITION x, int lower, int upper) const; int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const; Point PointFromPosition(int posInLine, int lineHeight) const; @@ -132,7 +128,7 @@ public: SpecialRepresentations(); void SetRepresentation(const char *charBytes, const char *value); void ClearRepresentation(const char *charBytes); - Representation *RepresentationFromCharacter(const char *charBytes, size_t len); + const Representation *RepresentationFromCharacter(const char *charBytes, size_t len) const; bool Contains(const char *charBytes, size_t len) const; void Clear(); }; @@ -140,8 +136,8 @@ public: struct TextSegment { int start; int length; - Representation *representation; - TextSegment(int start_=0, int length_=0, Representation *representation_=0) : + const Representation *representation; + TextSegment(int start_=0, int length_=0, const Representation *representation_=0) : start(start_), length(length_), representation(representation_) { } int end() const { @@ -151,7 +147,7 @@ struct TextSegment { // Class to break a line of text into shorter runs at sensible places. class BreakFinder { - LineLayout *ll; + const LineLayout *ll; int lineStart; int lineEnd; int posLineStart; @@ -160,9 +156,9 @@ class BreakFinder { unsigned int saeCurrentPos; int saeNext; int subBreak; - Document *pdoc; + const Document *pdoc; EncodingFamily encodingFamily; - SpecialRepresentations *preprs; + const SpecialRepresentations *preprs; void Insert(int val); // Private so BreakFinder objects can not be copied BreakFinder(const BreakFinder &); @@ -172,8 +168,8 @@ public: enum { lengthStartSubdivision = 300 }; // Try to make each subdivided run lengthEachSubdivision or shorter. enum { lengthEachSubdivision = 100 }; - BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, - int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_); + BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_, + int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_); ~BreakFinder(); TextSegment Next(); bool More() const; @@ -191,7 +187,7 @@ public: void Clear(); void SetSize(size_t size_); size_t GetSize() const { return pces.size(); } - void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber, + void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber, const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc); }; diff --git a/src/stc/scintilla/src/ScintillaBase.cxx b/src/stc/scintilla/src/ScintillaBase.cxx index 9736c52f01..d42dfc7ff6 100644 --- a/src/stc/scintilla/src/ScintillaBase.cxx +++ b/src/stc/scintilla/src/ScintillaBase.cxx @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include #include @@ -21,12 +21,17 @@ #include "ILexer.h" #include "Scintilla.h" -#include "PropSetSimple.h" #ifdef SCI_LEXER #include "SciLexer.h" +#endif + +#include "PropSetSimple.h" + +#ifdef SCI_LEXER #include "LexerModule.h" #include "Catalogue.h" #endif + #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -39,7 +44,6 @@ #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" -#include "AutoComplete.h" #include "CharClassify.h" #include "Decoration.h" #include "CaseFolder.h" @@ -47,6 +51,7 @@ #include "Selection.h" #include "PositionCache.h" #include "Editor.h" +#include "AutoComplete.h" #include "ScintillaBase.h" #ifdef SCI_NAMESPACE @@ -57,6 +62,7 @@ ScintillaBase::ScintillaBase() { displayPopupMenu = true; listType = 0; maxListWidth = 0; + multiAutoCMode = SC_MULTIAUTOC_ONCE; } ScintillaBase::~ScintillaBase() { @@ -197,9 +203,30 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) { void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { UndoGroup ug(pdoc); - pdoc->DeleteChars(startPos, removeLen); - const int lengthInserted = pdoc->InsertString(startPos, text, textLen); - SetEmptySelection(startPos + lengthInserted); + if (multiAutoCMode == SC_MULTIAUTOC_ONCE) { + pdoc->DeleteChars(startPos, removeLen); + const int lengthInserted = pdoc->InsertString(startPos, text, textLen); + SetEmptySelection(startPos + lengthInserted); + } else { + // SC_MULTIAUTOC_EACH + for (size_t r=0; r= 0) { + positionInsert -= removeLen; + pdoc->DeleteChars(positionInsert, removeLen); + } + const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen); + if (lengthInserted > 0) { + sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); + sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted); + } + sel.Range(r).ClearVirtualSpace(); + } + } + } } void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { @@ -492,7 +519,6 @@ public: void SetLexerLanguage(const char *languageName); const char *DescribeWordListSets(); void SetWordList(int n, const char *wl); - int GetStyleBitsNeeded() const; const char *GetName() const; void *PrivateCall(int operation, void *pointer); const char *PropertyNames(); @@ -594,10 +620,6 @@ void LexState::SetWordList(int n, const char *wl) { } } -int LexState::GetStyleBitsNeeded() const { - return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5; -} - const char *LexState::GetName() const { return lexCurrent ? lexCurrent->languageName : ""; } @@ -740,8 +762,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { void ScintillaBase::NotifyLexerChanged(Document *, void *) { #ifdef SCI_LEXER - int bits = DocumentLexState()->GetStyleBitsNeeded(); - vs.EnsureStyle((1 << bits) - 1); + vs.EnsureStyle(0xff); #endif } @@ -819,6 +840,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: return ac.ignoreCaseBehaviour; + case SCI_AUTOCSETMULTI: + multiAutoCMode = static_cast(wParam); + break; + + case SCI_AUTOCGETMULTI: + return multiAutoCMode; + case SCI_AUTOCSETORDER: ac.autoSort = static_cast(wParam); break; @@ -982,7 +1010,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara DocumentLexState()->PrivateCall(wParam, reinterpret_cast(lParam))); case SCI_GETSTYLEBITSNEEDED: - return DocumentLexState()->GetStyleBitsNeeded(); + return 8; case SCI_PROPERTYNAMES: return StringResult(lParam, DocumentLexState()->PropertyNames()); diff --git a/src/stc/scintilla/src/ScintillaBase.h b/src/stc/scintilla/src/ScintillaBase.h index 59ffea41e6..8440ebecc9 100644 --- a/src/stc/scintilla/src/ScintillaBase.h +++ b/src/stc/scintilla/src/ScintillaBase.h @@ -46,6 +46,7 @@ protected: int listType; ///< 0 is an autocomplete list int maxListWidth; /// Maximum width of list, in average character widths + int multiAutoCMode; /// Mode for autocompleting when multiple selections are present #ifdef SCI_LEXER LexState *DocumentLexState(); diff --git a/src/stc/scintilla/src/Selection.cxx b/src/stc/scintilla/src/Selection.cxx index 4c2ab0508e..b46dca890d 100644 --- a/src/stc/scintilla/src/Selection.cxx +++ b/src/stc/scintilla/src/Selection.cxx @@ -226,10 +226,18 @@ SelectionRange &Selection::Range(size_t r) { return ranges[r]; } +const SelectionRange &Selection::Range(size_t r) const { + return ranges[r]; +} + SelectionRange &Selection::RangeMain() { return ranges[mainRange]; } +const SelectionRange &Selection::RangeMain() const { + return ranges[mainRange]; +} + SelectionPosition Selection::Start() const { if (IsRectangular()) { return rangeRectangular.Start(); diff --git a/src/stc/scintilla/src/Selection.h b/src/stc/scintilla/src/Selection.h index e7f62f061e..9e95fb043c 100644 --- a/src/stc/scintilla/src/Selection.h +++ b/src/stc/scintilla/src/Selection.h @@ -156,7 +156,9 @@ public: size_t Main() const; void SetMain(size_t r); SelectionRange &Range(size_t r); + const SelectionRange &Range(size_t r) const; SelectionRange &RangeMain(); + const SelectionRange &RangeMain() const; SelectionPosition Start() const; bool MoveExtends() const; void SetMoveExtends(bool moveExtends_); diff --git a/src/stc/scintilla/src/Style.cxx b/src/stc/scintilla/src/Style.cxx index 4f1143914c..ba3f97c3d5 100644 --- a/src/stc/scintilla/src/Style.cxx +++ b/src/stc/scintilla/src/Style.cxx @@ -19,6 +19,10 @@ using namespace Scintilla; FontAlias::FontAlias() { } +FontAlias::FontAlias(const FontAlias &other) : Font() { + SetID(other.fid); +} + FontAlias::~FontAlias() { SetID(0); // ~Font will not release the actual font resource since it is now 0 diff --git a/src/stc/scintilla/src/Style.h b/src/stc/scintilla/src/Style.h index 4bd79de140..411b11a08b 100644 --- a/src/stc/scintilla/src/Style.h +++ b/src/stc/scintilla/src/Style.h @@ -33,11 +33,11 @@ struct FontSpecification { // Just like Font but only has a copy of the FontID so should not delete it class FontAlias : public Font { - // Private so FontAlias objects can not be copied - FontAlias(const FontAlias &); + // Private so FontAlias objects can not be assigned except for intiialization FontAlias &operator=(const FontAlias &); public: FontAlias(); + FontAlias(const FontAlias &); virtual ~FontAlias(); void MakeAlias(Font &fontOrigin); void ClearFont(); diff --git a/src/stc/scintilla/src/ViewStyle.cxx b/src/stc/scintilla/src/ViewStyle.cxx index af808f3c1c..2983bb0c0f 100644 --- a/src/stc/scintilla/src/ViewStyle.cxx +++ b/src/stc/scintilla/src/ViewStyle.cxx @@ -434,6 +434,43 @@ void ViewStyle::CalcLargestMarkerHeight() { } } +// See if something overrides the line background color: Either if caret is on the line +// and background color is set for that, or if a marker is defined that forces its background +// color onto the line, or if a marker is defined but has no selection margin in which to +// display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order +// with the earlier taking precedence. When multiple markers cause background override, +// the color for the highest numbered one is used. +ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const { + ColourOptional background; + if ((caretActive || alwaysShowCaretLineBackground) && showCaretLineBackground && (caretLineAlpha == SC_ALPHA_NOALPHA) && lineContainsCaret) { + background = ColourOptional(caretLineBackground, true); + } + if (!background.isSet && marksOfLine) { + int marks = marksOfLine; + for (int markBit = 0; (markBit < 32) && marks; markBit++) { + if ((marks & 1) && (markers[markBit].markType == SC_MARK_BACKGROUND) && + (markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + background = ColourOptional(markers[markBit].back, true); + } + marks >>= 1; + } + } + if (!background.isSet && maskInLine) { + int marksMasked = marksOfLine & maskInLine; + if (marksMasked) { + for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + if ((marksMasked & 1) && (markers[markBit].markType != SC_MARK_EMPTY) && + (markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + background = ColourOptional(markers[markBit].back, true); + } + marksMasked >>= 1; + } + } + } + return background; +} + + ColourDesired ViewStyle::WrapColour() const { if (whitespaceColours.fore.isSet) return whitespaceColours.fore; diff --git a/src/stc/scintilla/src/ViewStyle.h b/src/stc/scintilla/src/ViewStyle.h index be9d8abfcc..60bd9688ee 100644 --- a/src/stc/scintilla/src/ViewStyle.h +++ b/src/stc/scintilla/src/ViewStyle.h @@ -157,7 +157,7 @@ public: ViewStyle(); ViewStyle(const ViewStyle &source); ~ViewStyle(); - void Init(size_t stylesSize_=64); + void Init(size_t stylesSize_=256); void Refresh(Surface &surface, int tabInChars); void ReleaseAllExtendedStyles(); int AllocateExtendedStyles(int numberStyles); @@ -169,6 +169,7 @@ public: int ExternalMarginWidth() const; bool ValidStyle(size_t styleIndex) const; void CalcLargestMarkerHeight(); + ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const; ColourDesired WrapColour() const; bool SetWrapState(int wrapState_); bool SetWrapVisualFlags(int wrapVisualFlags_); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index e2f2c6ca39..1fb5018248 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -3291,6 +3291,18 @@ int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const return SendMsg(SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR, 0, 0); } +// Change the effect of autocompleting when there are multiple selections. +void wxStyledTextCtrl::AutoCompSetMulti(int multi) +{ + SendMsg(SCI_AUTOCSETMULTI, multi, 0); +} + +// Retrieve the effect of autocompleting when there are multiple selections.. +int wxStyledTextCtrl::AutoCompGetMulti() const +{ + return SendMsg(SCI_AUTOCGETMULTI, 0, 0); +} + // Set the way autocompletion lists are ordered. void wxStyledTextCtrl::AutoCompSetOrder(int order) { @@ -5323,7 +5335,7 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() { - return wxVersionInfo("Scintilla", 3, 4, 3, "Scintilla 3.4.3"); + return wxVersionInfo("Scintilla", 3, 4, 4, "Scintilla 3.4.4"); } #endif // wxUSE_STC diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index c73c230245..f273c20501 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -1205,7 +1205,7 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() { - return wxVersionInfo("Scintilla", 3, 4, 3, "Scintilla 3.4.3"); + return wxVersionInfo("Scintilla", 3, 4, 4, "Scintilla 3.4.4"); } #endif // wxUSE_STC