• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28493 (tree)
Time2019-01-11 03:02:28
Authorstefankueng

Log Message

update to scintilla 4.1.3

Change Summary

Incremental Difference

--- trunk/ext/scintilla/.hg_archival.txt (revision 28492)
+++ trunk/ext/scintilla/.hg_archival.txt (revision 28493)
@@ -1,6 +1,6 @@
11 repo: bdf8c3ef2fb01ea24578e726337888e706d10b92
2-node: 20455b6997e3ec64d5c68870682b87d8d09d0a1d
2+node: 974d0f564d0da81442861a23ce670e4312bebda0
33 branch: default
4-latesttag: rel-4-1-2
4+latesttag: rel-4-1-3
55 latesttagdistance: 1
66 changessincelatesttag: 1
--- trunk/ext/scintilla/doc/ScintillaDoc.html (revision 28492)
+++ trunk/ext/scintilla/doc/ScintillaDoc.html (revision 28493)
@@ -7263,6 +7263,8 @@
72637263 <p>The following <code>SCI_*</code> messages are associated with these notifications:</p>
72647264 <code><a class="message" href="#SCI_SETMODEVENTMASK">SCI_SETMODEVENTMASK(int eventMask)</a><br />
72657265 <a class="message" href="#SCI_GETMODEVENTMASK">SCI_GETMODEVENTMASK &rarr; int</a><br />
7266+ <a class="message" href="#SCI_SETCOMMANDEVENTS">SCI_SETCOMMANDEVENTS(bool commandEvents)</a><br />
7267+ <a class="message" href="#SCI_GETCOMMANDEVENTS">SCI_GETCOMMANDEVENTS &rarr; bool</a><br />
72667268 <a class="message" href="#SCI_SETMOUSEDWELLTIME">SCI_SETMOUSEDWELLTIME(int periodMilliseconds)</a><br />
72677269 <a class="message" href="#SCI_GETMOUSEDWELLTIME">SCI_GETMOUSEDWELLTIME &rarr; int</a><br />
72687270 <a class="message" href="#SCI_SETIDENTIFIER">SCI_SETIDENTIFIER(int identifier)</a><br />
@@ -7749,7 +7751,9 @@
77497751 <code>EN_CHANGE</code>). No other information is sent. If you need more detailed information
77507752 use <a class="message" href="#SCN_MODIFIED"><code>SCN_MODIFIED</code></a>. You can filter the
77517753 types of changes you are notified about with <a class="message"
7752- href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a>.</p>
7754+ href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a> and
7755+ <a class="message"
7756+ href="#SCI_SETCOMMANDEVENTS"><code>SCI_SETCOMMANDEVENTS</code></a>.</p>
77537757
77547758 <p><b id="SCI_SETMODEVENTMASK">SCI_SETMODEVENTMASK(int eventMask)</b><br />
77557759 <b id="SCI_GETMODEVENTMASK">SCI_GETMODEVENTMASK &rarr; int</b><br />
@@ -7769,6 +7773,14 @@
77697773 <code>SC_MOD_BEFOREINSERT</code>, <code>SC_MOD_BEFOREDELETE</code>,
77707774 <code>SC_MULTILINEUNDOREDO</code>, and <code>SC_MODEVENTMASKALL</code>.</p>
77717775
7776+ <p><b id="SCI_SETCOMMANDEVENTS">SCI_SETCOMMANDEVENTS(bool commandEvents)</b><br />
7777+ <b id="SCI_GETCOMMANDEVENTS">SCI_GETCOMMANDEVENTS &rarr; bool</b><br />
7778+ These messages set and get whether <code>SCEN_*</code> command events are
7779+ sent to the container. For <code>SCEN_CHANGE</code> this acts as an additional filter over
7780+ <a class="message" href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a>.
7781+ Most applications should set this off to avoid overhead and only use
7782+ <a class="message" href="#SCN_MODIFIED"><code>SCN_MODIFIED</code></a>.</p>
7783+
77727784 <p><b id="SCEN_SETFOCUS">SCEN_SETFOCUS</b><br />
77737785 <b id="SCEN_KILLFOCUS">SCEN_KILLFOCUS</b><br />
77747786 <code>SCEN_SETFOCUS</code> (512) is fired when Scintilla receives focus and
--- trunk/ext/scintilla/doc/ScintillaDownload.html (revision 28492)
+++ trunk/ext/scintilla/doc/ScintillaDownload.html (revision 28493)
@@ -26,9 +26,9 @@
2626 <table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
2727 <tr>
2828 <td>
29- <font size="4"> <a href="https://www.scintilla.org/scintilla412.zip">
29+ <font size="4"> <a href="https://www.scintilla.org/scintilla413.zip">
3030 Windows</a>&nbsp;&nbsp;
31- <a href="https://www.scintilla.org/scintilla412.tgz">
31+ <a href="https://www.scintilla.org/scintilla413.tgz">
3232 GTK+/Linux</a>&nbsp;&nbsp;
3333 </font>
3434 </td>
@@ -42,7 +42,7 @@
4242 containing very few restrictions.
4343 </p>
4444 <h3>
45- Release 4.1.2
45+ Release 4.1.3
4646 </h3>
4747 <h4>
4848 Source Code
@@ -50,8 +50,8 @@
5050 The source code package contains all of the source code for Scintilla but no binary
5151 executable code and is available in
5252 <ul>
53- <li><a href="https://www.scintilla.org/scintilla412.zip">zip format</a> (1600K) commonly used on Windows</li>
54- <li><a href="https://www.scintilla.org/scintilla412.tgz">tgz format</a> (1400K) commonly used on Linux and compatible operating systems</li>
53+ <li><a href="https://www.scintilla.org/scintilla413.zip">zip format</a> (1600K) commonly used on Windows</li>
54+ <li><a href="https://www.scintilla.org/scintilla413.tgz">tgz format</a> (1400K) commonly used on Linux and compatible operating systems</li>
5555 </ul>
5656 Instructions for building on both Windows and Linux are included in the readme file.
5757 <h4>
--- trunk/ext/scintilla/doc/ScintillaHistory.html (revision 28492)
+++ trunk/ext/scintilla/doc/ScintillaHistory.html (revision 28493)
@@ -536,6 +536,10 @@
536536 </tr><tr>
537537 <td>maboroshin</td>
538538 <td>Gokul Krishnan</td>
539+ <td>John Horigan</td>
540+ <td>jj5</td>
541+ </tr><tr>
542+ <td>Jad Altahan</td>
539543 </tr>
540544 </table>
541545 <p>
@@ -548,6 +552,94 @@
548552 </li>
549553 </ul>
550554 <h3>
555+ <a href="https://www.scintilla.org/scite413.zip">Release 4.1.3</a>
556+ </h3>
557+ <ul>
558+ <li>
559+ Released 10 January 2019.
560+ </li>
561+ <li>
562+ Add SCI_SETCOMMANDEVENTS API to allow turning off command events as they
563+ can be a significant performance cost.
564+ </li>
565+ <li>
566+ Improve efficiency of idle wrapping by wrapping in blocks as large as possible while
567+ still remaining responsive.
568+ </li>
569+ <li>
570+ Updated case conversion and character categories to Unicode 11.
571+ </li>
572+ <li>
573+ Errorlist lexer recognizes negative line numbers as some programs show whole-file
574+ errors occurring on line -1.
575+ SciTE's parsing of diagnostics also updated to handle this case.
576+ </li>
577+ <li>
578+ Added "nim" lexer (SCLEX_NIM) for the Nim language which was previously called Nimrod.
579+ For compatibility, the old "nimrod" lexer is still present but is deprecated and will be removed at the
580+ next major version.
581+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1242/">Feature #1242</a>.
582+ </li>
583+ <li>
584+ The Bash lexer implements substyles for multiple sets of keywords and supports SCI_PROPERTYNAMES.
585+ <a href="https://sourceforge.net/p/scintilla/bugs/2054/">Bug #2054</a>.
586+ </li>
587+ <li>
588+ The C++ lexer interprets continued preprocessor lines correctly by reading all of
589+ the logical line.
590+ <a href="https://sourceforge.net/p/scintilla/bugs/2062/">Bug #2062</a>.
591+ </li>
592+ <li>
593+ The C++ lexer interprets preprocessor arithmetic expressions containing multiplicative and additive
594+ operators correctly by following operator precedence rules.
595+ <a href="https://sourceforge.net/p/scintilla/bugs/2069/">Bug #2069</a>.
596+ </li>
597+ <li>
598+ The EDIFACT lexer handles message groups as well as messages.
599+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1247/">Feature #1247</a>.
600+ </li>
601+ <li>
602+ For SciTE's Find in Files, allow case-sensitivity and whole-word options when running
603+ a user defined command.
604+ <a href="https://sourceforge.net/p/scintilla/bugs/2053/">Bug #2053</a>.
605+ </li>
606+ <li>
607+ Notify with SC_UPDATE_SELECTION when user performs a multiple selection add.
608+ </li>
609+ <li>
610+ On macOS 10.14 Cocoa, fix incorrect horizontal offset.
611+ <a href="https://sourceforge.net/p/scintilla/bugs/2022/">Bug #2022</a>.
612+ </li>
613+ <li>
614+ On Cocoa, fix a crash that occurred when entering a dead key diacritic then a character
615+ that can not take that diacritic, such as option+e (acute accent) followed by g.
616+ <a href="https://sourceforge.net/p/scintilla/bugs/2061/">Bug #2061</a>.
617+ </li>
618+ <li>
619+ On Cocoa, use dark info bar background when system is set to Dark Appearance.
620+ <a href="https://sourceforge.net/p/scintilla/bugs/2055/">Bug #2055</a>.
621+ </li>
622+ <li>
623+ Fixed a crash on Cocoa in bidirectional mode where some patterns of invalid UTF-8
624+ caused failures to create Unicode strings.
625+ </li>
626+ <li>
627+ SCI_MARKERADD returns -1 for invalid lines as documented instead of 0.
628+ <a href="https://sourceforge.net/p/scintilla/bugs/2051/">Bug #2051</a>.
629+ </li>
630+ <li>
631+ Improve performance of text insertion when Unicode line indexing off.
632+ </li>
633+ <li>
634+ For Qt on Windows, stop specifying -std:c++latest as that is no longer needed
635+ to enable C++17 with MSVC 2017 and Qt 5.12 and it caused duplicate flag warnings.
636+ </li>
637+ <li>
638+ On Linux, enable Lua to access dynamic libraries.
639+ <a href="https://sourceforge.net/p/scintilla/bugs/2058/">Bug #2058</a>.
640+ </li>
641+ </ul>
642+ <h3>
551643 <a href="https://www.scintilla.org/scite412.zip">Release 4.1.2</a>
552644 </h3>
553645 <ul>
--- trunk/ext/scintilla/doc/index.html (revision 28492)
+++ trunk/ext/scintilla/doc/index.html (revision 28493)
@@ -9,7 +9,7 @@
99 <meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
1010 <meta name="Description"
1111 content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
12- <meta name="Date.Modified" content="20181002" />
12+ <meta name="Date.Modified" content="20190110" />
1313 <meta name="viewport" content="width=device-width, initial-scale=1" />
1414 <style type="text/css">
1515 #versionlist {
@@ -56,8 +56,8 @@
5656 GTK+, and OS X</font>
5757 </td>
5858 <td width="40%" align="right">
59- <font color="#FFCC99" size="3"> Release version 4.1.2<br />
60- Site last modified October 2 2018</font>
59+ <font color="#FFCC99" size="3"> Release version 4.1.3<br />
60+ Site last modified January 10 2019</font>
6161 </td>
6262 <td width="20%">
6363 &nbsp;
@@ -72,11 +72,10 @@
7272 </tr>
7373 </table>
7474 <ul id="versionlist">
75+ <li>Version 4.1.3 is compatible with macOS 10.14, improves performance, and adds a new lexer for Nim which will replace the "nimrod" lexer.</li>
7576 <li>Version 4.1.2 is a minor release.</li>
7677 <li>Version 4.1.1 adds optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units.</li>
7778 <li>Version 4.1.0 adds experimental support for bidirectional text as used by Arabic and Hebrew on Win32 and Cocoa.</li>
78- <li>Version 4.0.5 adds experimental support for documents larger than 2 GigaBytes.</li>
79- <li>Version 4.0.4 adds a lexer for Maxima.</li>
8079 </ul>
8180 <ul id="menu">
8281 <li id="remote1"><a href="https://www.scintilla.org/SciTEImage.html">Screenshot</a></li>
--- trunk/ext/scintilla/include/SciLexer.h (revision 28492)
+++ trunk/ext/scintilla/include/SciLexer.h (revision 28493)
@@ -138,6 +138,7 @@
138138 #define SCLEX_MAXIMA 123
139139 #define SCLEX_STATA 124
140140 #define SCLEX_SAS 125
141+#define SCLEX_NIM 126
141142 #define SCLEX_AUTOMATIC 1000
142143 #define SCE_P_DEFAULT 0
143144 #define SCE_P_COMMENTLINE 1
@@ -1855,6 +1856,23 @@
18551856 #define SCE_SAS_BLOCK_KEYWORD 13
18561857 #define SCE_SAS_MACRO_FUNCTION 14
18571858 #define SCE_SAS_STATEMENT 15
1859+#define SCE_NIM_DEFAULT 0
1860+#define SCE_NIM_COMMENT 1
1861+#define SCE_NIM_COMMENTDOC 2
1862+#define SCE_NIM_COMMENTLINE 3
1863+#define SCE_NIM_COMMENTLINEDOC 4
1864+#define SCE_NIM_NUMBER 5
1865+#define SCE_NIM_STRING 6
1866+#define SCE_NIM_CHARACTER 7
1867+#define SCE_NIM_WORD 8
1868+#define SCE_NIM_TRIPLE 9
1869+#define SCE_NIM_TRIPLEDOUBLE 10
1870+#define SCE_NIM_BACKTICKS 11
1871+#define SCE_NIM_FUNCNAME 12
1872+#define SCE_NIM_STRINGEOL 13
1873+#define SCE_NIM_NUMERROR 14
1874+#define SCE_NIM_OPERATOR 15
1875+#define SCE_NIM_IDENTIFIER 16
18581876 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
18591877
18601878 #endif
--- trunk/ext/scintilla/include/Scintilla.h (revision 28492)
+++ trunk/ext/scintilla/include/Scintilla.h (revision 28493)
@@ -697,6 +697,8 @@
697697 #define SCI_RELEASEDOCUMENT 2377
698698 #define SCI_GETDOCUMENTOPTIONS 2379
699699 #define SCI_GETMODEVENTMASK 2378
700+#define SCI_SETCOMMANDEVENTS 2717
701+#define SCI_GETCOMMANDEVENTS 2718
700702 #define SCI_SETFOCUS 2380
701703 #define SCI_GETFOCUS 2381
702704 #define SC_STATUS_OK 0
@@ -1125,8 +1127,6 @@
11251127 #endif
11261128 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
11271129
1128-#define SCN_GETBKCOLOR 5000
1129-
11301130 /* These structures are defined to be exactly the same shape as the Win32
11311131 * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
11321132 * So older code that treats Scintilla as a RichEdit will work. */
--- trunk/ext/scintilla/lexers/LexAU3.cxx (revision 28492)
+++ trunk/ext/scintilla/lexers/LexAU3.cxx (revision 28493)
@@ -1,6 +1,6 @@
11 // Scintilla source code edit control
22 // @file LexAU3.cxx
3-// Lexer for AutoIt3 http://www.hiddensoft.com/autoit3
3+// Lexer for AutoIt3 https://www.autoitscript.com/site/
44 // by Jos van der Zande, jvdzande@yahoo.com
55 //
66 // Changes:
--- trunk/ext/scintilla/lexers/LexBash.cxx (revision 28492)
+++ trunk/ext/scintilla/lexers/LexBash.cxx (revision 28493)
@@ -12,16 +12,23 @@
1212 #include <stdarg.h>
1313 #include <assert.h>
1414
15+#include <string>
16+#include <vector>
17+#include <map>
18+
1519 #include "ILexer.h"
1620 #include "Scintilla.h"
1721 #include "SciLexer.h"
1822
23+#include "StringCopy.h"
1924 #include "WordList.h"
2025 #include "LexAccessor.h"
21-#include "Accessor.h"
2226 #include "StyleContext.h"
2327 #include "CharacterSet.h"
2428 #include "LexerModule.h"
29+#include "OptionSet.h"
30+#include "SubStyles.h"
31+#include "DefaultLexer.h"
2532
2633 using namespace Scintilla;
2734
@@ -58,7 +65,9 @@
5865
5966 #define BASH_DELIM_STACK_MAX 7
6067
61-static inline int translateBashDigit(int ch) {
68+namespace {
69+
70+inline int translateBashDigit(int ch) {
6271 if (ch >= '0' && ch <= '9') {
6372 return ch - '0';
6473 } else if (ch >= 'a' && ch <= 'z') {
@@ -73,7 +82,7 @@
7382 return BASH_BASE_ERROR;
7483 }
7584
76-static inline int getBashNumberBase(char *s) {
85+inline int getBashNumberBase(char *s) {
7786 int i = 0;
7887 int base = 0;
7988 while (*s) {
@@ -86,7 +95,7 @@
8695 return base;
8796 }
8897
89-static int opposite(int ch) {
98+int opposite(int ch) {
9099 if (ch == '(') return ')';
91100 if (ch == '[') return ']';
92101 if (ch == '{') return '}';
@@ -94,7 +103,7 @@
94103 return ch;
95104 }
96105
97-static int GlobScan(StyleContext &sc) {
106+int GlobScan(StyleContext &sc) {
98107 // forward scan for zsh globs, disambiguate versus bash arrays
99108 // complex expressions may still fail, e.g. unbalanced () '' "" etc
100109 int c, sLen = 0;
@@ -120,10 +129,171 @@
120129 return 0;
121130 }
122131
123-static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
124- WordList *keywordlists[], Accessor &styler) {
132+bool IsCommentLine(Sci_Position line, LexAccessor &styler) {
133+ Sci_Position pos = styler.LineStart(line);
134+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
135+ for (Sci_Position i = pos; i < eol_pos; i++) {
136+ char ch = styler[i];
137+ if (ch == '#')
138+ return true;
139+ else if (ch != ' ' && ch != '\t')
140+ return false;
141+ }
142+ return false;
143+}
125144
126- WordList &keywords = *keywordlists[0];
145+struct OptionsBash {
146+ bool fold;
147+ bool foldComment;
148+ bool foldCompact;
149+
150+ OptionsBash() {
151+ fold = false;
152+ foldComment = false;
153+ foldCompact = true;
154+ }
155+};
156+
157+const char * const bashWordListDesc[] = {
158+ "Keywords",
159+ 0
160+};
161+
162+struct OptionSetBash : public OptionSet<OptionsBash> {
163+ OptionSetBash() {
164+ DefineProperty("fold", &OptionsBash::fold);
165+
166+ DefineProperty("fold.comment", &OptionsBash::foldComment);
167+
168+ DefineProperty("fold.compact", &OptionsBash::foldCompact);
169+
170+ DefineWordListSets(bashWordListDesc);
171+ }
172+};
173+
174+const char styleSubable[] = { SCE_SH_IDENTIFIER, SCE_SH_SCALAR, 0 };
175+
176+LexicalClass lexicalClasses[] = {
177+ // Lexer Bash SCLEX_BASH SCE_SH_:
178+ 0, "SCE_SH_DEFAULT", "default", "White space",
179+ 1, "SCE_SH_ERROR", "error", "Error",
180+ 2, "SCE_SH_COMMENTLINE", "comment line", "Line comment: #",
181+ 3, "SCE_SH_NUMBER", "literal numeric", "Number",
182+ 4, "SCE_SH_WORD", "keyword", "Keyword",
183+ 5, "SCE_SH_STRING", "literal string", "String",
184+ 6, "SCE_SH_CHARACTER", "literal string", "Single quoted string",
185+ 7, "SCE_SH_OPERATOR", "operator", "Operators",
186+ 8, "SCE_SH_IDENTIFIER", "identifier", "Identifiers",
187+ 9, "SCE_SH_SCALAR", "identifier", "Scalar variable",
188+ 10, "SCE_SH_PARAM", "identifier", "Parameter",
189+ 11, "SCE_SH_BACKTICKS", "literal string", "Backtick quoted command",
190+ 12, "SCE_SH_HERE_DELIM", "operator", "Heredoc delimiter",
191+ 13, "SCE_SH_HERE_Q", "literal string", "Heredoc quoted string",
192+};
193+
194+}
195+
196+class LexerBash : public DefaultLexer {
197+ WordList keywords;
198+ OptionsBash options;
199+ OptionSetBash osBash;
200+ enum { ssIdentifier, ssScalar };
201+ SubStyles subStyles;
202+public:
203+ LexerBash() :
204+ DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses)),
205+ subStyles(styleSubable, 0x80, 0x40, 0) {
206+ }
207+ virtual ~LexerBash() {
208+ }
209+ void SCI_METHOD Release() override {
210+ delete this;
211+ }
212+ int SCI_METHOD Version() const override {
213+ return lvRelease4;
214+ }
215+ const char * SCI_METHOD PropertyNames() override {
216+ return osBash.PropertyNames();
217+ }
218+ int SCI_METHOD PropertyType(const char* name) override {
219+ return osBash.PropertyType(name);
220+ }
221+ const char * SCI_METHOD DescribeProperty(const char *name) override {
222+ return osBash.DescribeProperty(name);
223+ }
224+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
225+ const char * SCI_METHOD DescribeWordListSets() override {
226+ return osBash.DescribeWordListSets();
227+ }
228+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
229+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
230+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
231+
232+ void * SCI_METHOD PrivateCall(int, void *) override {
233+ return 0;
234+ }
235+
236+ int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
237+ return subStyles.Allocate(styleBase, numberStyles);
238+ }
239+ int SCI_METHOD SubStylesStart(int styleBase) override {
240+ return subStyles.Start(styleBase);
241+ }
242+ int SCI_METHOD SubStylesLength(int styleBase) override {
243+ return subStyles.Length(styleBase);
244+ }
245+ int SCI_METHOD StyleFromSubStyle(int subStyle) override {
246+ const int styleBase = subStyles.BaseStyle(subStyle);
247+ return styleBase;
248+ }
249+ int SCI_METHOD PrimaryStyleFromStyle(int style) override {
250+ return style;
251+ }
252+ void SCI_METHOD FreeSubStyles() override {
253+ subStyles.Free();
254+ }
255+ void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
256+ subStyles.SetIdentifiers(style, identifiers);
257+ }
258+ int SCI_METHOD DistanceToSecondaryStyles() override {
259+ return 0;
260+ }
261+ const char *SCI_METHOD GetSubStyleBases() override {
262+ return styleSubable;
263+ }
264+
265+ static ILexer4 *LexerFactoryBash() {
266+ return new LexerBash();
267+ }
268+};
269+
270+Sci_Position SCI_METHOD LexerBash::PropertySet(const char *key, const char *val) {
271+ if (osBash.PropertySet(&options, key, val)) {
272+ return 0;
273+ }
274+ return -1;
275+}
276+
277+Sci_Position SCI_METHOD LexerBash::WordListSet(int n, const char *wl) {
278+ WordList *wordListN = 0;
279+ switch (n) {
280+ case 0:
281+ wordListN = &keywords;
282+ break;
283+ }
284+ Sci_Position firstModification = -1;
285+ if (wordListN) {
286+ WordList wlNew;
287+ wlNew.Set(wl);
288+ if (*wordListN != wlNew) {
289+ wordListN->Set(wl);
290+ firstModification = 0;
291+ }
292+ }
293+ return firstModification;
294+}
295+
296+void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
127297 WordList cmdDelimiter, bashStruct, bashStruct_in;
128298 cmdDelimiter.Set("| || |& & && ; ;; ( ) { }");
129299 bashStruct.Set("if elif fi while until else then do done esac eval");
@@ -237,11 +407,15 @@
237407 };
238408 QuoteStackCls QuoteStack;
239409
410+ const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_SH_IDENTIFIER);
411+ const WordClassifier &classifierScalars = subStyles.Classifier(SCE_SH_SCALAR);
412+
240413 int numBase = 0;
241414 int digit;
242415 Sci_PositionU endPos = startPos + length;
243416 int cmdState = BASH_CMD_START;
244417 int testExprType = 0;
418+ LexAccessor styler(pAccess);
245419
246420 // Always backtracks to the start of a line that is not a continuation
247421 // of the previous line (i.e. start of a bash command segment)
@@ -306,6 +480,11 @@
306480 char s[500];
307481 char s2[10];
308482 sc.GetCurrent(s, sizeof(s));
483+ int identifierStyle = SCE_SH_IDENTIFIER;
484+ int subStyle = classifierIdentifiers.ValueFor(s);
485+ if (subStyle >= 0) {
486+ identifierStyle = subStyle;
487+ }
309488 // allow keywords ending in a whitespace or command delimiter
310489 s2[0] = static_cast<char>(sc.ch);
311490 s2[1] = '\0';
@@ -317,7 +496,7 @@
317496 else if (strcmp(s, "do") == 0 && keywordEnds)
318497 cmdStateNew = BASH_CMD_START;
319498 else
320- sc.ChangeState(SCE_SH_IDENTIFIER);
499+ sc.ChangeState(identifierStyle);
321500 sc.SetState(SCE_SH_DEFAULT);
322501 break;
323502 }
@@ -327,7 +506,7 @@
327506 cmdStateNew = BASH_CMD_TEST;
328507 testExprType = 0;
329508 } else
330- sc.ChangeState(SCE_SH_IDENTIFIER);
509+ sc.ChangeState(identifierStyle);
331510 }
332511 // detect bash construct keywords
333512 else if (bashStruct.InList(s)) {
@@ -334,7 +513,7 @@
334513 if (cmdState == BASH_CMD_START && keywordEnds)
335514 cmdStateNew = BASH_CMD_START;
336515 else
337- sc.ChangeState(SCE_SH_IDENTIFIER);
516+ sc.ChangeState(identifierStyle);
338517 }
339518 // 'for'|'case'|'select' needs 'in'|'do' to be highlighted later
340519 else if (bashStruct_in.InList(s)) {
@@ -341,28 +520,35 @@
341520 if (cmdState == BASH_CMD_START && keywordEnds)
342521 cmdStateNew = BASH_CMD_WORD;
343522 else
344- sc.ChangeState(SCE_SH_IDENTIFIER);
523+ sc.ChangeState(identifierStyle);
345524 }
346525 // disambiguate option items and file test operators
347526 else if (s[0] == '-') {
348527 if (cmdState != BASH_CMD_TEST)
349- sc.ChangeState(SCE_SH_IDENTIFIER);
528+ sc.ChangeState(identifierStyle);
350529 }
351530 // disambiguate keywords and identifiers
352531 else if (cmdState != BASH_CMD_START
353532 || !(keywords.InList(s) && keywordEnds)) {
354- sc.ChangeState(SCE_SH_IDENTIFIER);
533+ sc.ChangeState(identifierStyle);
355534 }
356535 sc.SetState(SCE_SH_DEFAULT);
357536 }
358537 break;
359538 case SCE_SH_IDENTIFIER:
360- if (sc.chPrev == '\\') { // for escaped chars
361- sc.ForwardSetState(SCE_SH_DEFAULT);
362- } else if (!setWord.Contains(sc.ch)) {
363- sc.SetState(SCE_SH_DEFAULT);
364- } else if (cmdState == BASH_CMD_ARITH && !setWordStart.Contains(sc.ch)) {
365- sc.SetState(SCE_SH_DEFAULT);
539+ if (sc.chPrev == '\\' || !setWord.Contains(sc.ch) ||
540+ (cmdState == BASH_CMD_ARITH && !setWordStart.Contains(sc.ch))) {
541+ char s[500];
542+ sc.GetCurrent(s, sizeof(s));
543+ int subStyle = classifierIdentifiers.ValueFor(s);
544+ if (subStyle >= 0) {
545+ sc.ChangeState(subStyle);
546+ }
547+ if (sc.chPrev == '\\') { // for escaped chars
548+ sc.ForwardSetState(SCE_SH_DEFAULT);
549+ } else {
550+ sc.SetState(SCE_SH_DEFAULT);
551+ }
366552 }
367553 break;
368554 case SCE_SH_NUMBER:
@@ -516,6 +702,12 @@
516702 break;
517703 case SCE_SH_SCALAR: // variable names
518704 if (!setParam.Contains(sc.ch)) {
705+ char s[500];
706+ sc.GetCurrent(s, sizeof(s));
707+ int subStyle = classifierScalars.ValueFor(&s[1]); // skip the $
708+ if (subStyle >= 0) {
709+ sc.ChangeState(subStyle);
710+ }
519711 if (sc.LengthCurrent() == 1) {
520712 // Special variable: $(, $_ etc.
521713 sc.ForwardSetState(SCE_SH_DEFAULT);
@@ -799,23 +991,12 @@
799991 sc.Complete();
800992 }
801993
802-static bool IsCommentLine(Sci_Position line, Accessor &styler) {
803- Sci_Position pos = styler.LineStart(line);
804- Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
805- for (Sci_Position i = pos; i < eol_pos; i++) {
806- char ch = styler[i];
807- if (ch == '#')
808- return true;
809- else if (ch != ' ' && ch != '\t')
810- return false;
811- }
812- return false;
813-}
994+void SCI_METHOD LexerBash::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) {
995+ if(!options.fold)
996+ return;
814997
815-static void FoldBashDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
816- Accessor &styler) {
817- bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
818- bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
998+ LexAccessor styler(pAccess);
999+
8191000 Sci_PositionU endPos = startPos + length;
8201001 int visibleChars = 0;
8211002 int skipHereCh = 0;
@@ -833,7 +1014,7 @@
8331014 styleNext = styler.StyleAt(i + 1);
8341015 bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
8351016 // Comment folding
836- if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
1017+ if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler))
8371018 {
8381019 if (!IsCommentLine(lineCurrent - 1, styler)
8391020 && IsCommentLine(lineCurrent + 1, styler))
@@ -880,7 +1061,7 @@
8801061 }
8811062 if (atEOL) {
8821063 int lev = levelPrev;
883- if (visibleChars == 0 && foldCompact)
1064+ if (visibleChars == 0 && options.foldCompact)
8841065 lev |= SC_FOLDLEVELWHITEFLAG;
8851066 if ((levelCurrent > levelPrev) && (visibleChars > 0))
8861067 lev |= SC_FOLDLEVELHEADERFLAG;
@@ -899,9 +1080,4 @@
8991080 styler.SetLevel(lineCurrent, levelPrev | flagsNext);
9001081 }
9011082
902-static const char * const bashWordListDesc[] = {
903- "Keywords",
904- 0
905-};
906-
907-LexerModule lmBash(SCLEX_BASH, ColouriseBashDoc, "bash", FoldBashDoc, bashWordListDesc);
1083+LexerModule lmBash(SCLEX_BASH, LexerBash::LexerFactoryBash, "bash", bashWordListDesc);
--- trunk/ext/scintilla/lexers/LexCPP.cxx (revision 28492)
+++ trunk/ext/scintilla/lexers/LexCPP.cxx (revision 28493)
@@ -201,17 +201,27 @@
201201
202202 std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) {
203203 std::string restOfLine;
204- Sci_Position i =0;
204+ Sci_Position line = styler.GetLine(start);
205+ Sci_Position pos = start;
206+ Sci_Position endLine = styler.LineEnd(line);
205207 char ch = styler.SafeGetCharAt(start, '\n');
206- const Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
207- while (((start+i) < endLine) && (ch != '\r')) {
208- const char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
209- if (ch == '/' && (chNext == '/' || chNext == '*'))
210- break;
211- if (allowSpace || (ch != ' '))
212- restOfLine += ch;
213- i++;
214- ch = chNext;
208+ while (pos < endLine) {
209+ if (ch == '\\' && ((pos + 1) == endLine)) {
210+ // Continuation line
211+ line++;
212+ pos = styler.LineStart(line);
213+ endLine = styler.LineEnd(line);
214+ ch = styler.SafeGetCharAt(pos, '\n');
215+ } else {
216+ const char chNext = styler.SafeGetCharAt(pos + 1, '\n');
217+ if (ch == '/' && (chNext == '/' || chNext == '*'))
218+ break;
219+ if (allowSpace || (ch != ' ')) {
220+ restOfLine += ch;
221+ }
222+ pos++;
223+ ch = chNext;
224+ }
215225 }
216226 return restOfLine;
217227 }
@@ -474,7 +484,8 @@
474484 bool caseSensitive;
475485 CharacterSet setWord;
476486 CharacterSet setNegationOp;
477- CharacterSet setArithmethicOp;
487+ CharacterSet setAddOp;
488+ CharacterSet setMultOp;
478489 CharacterSet setRelOp;
479490 CharacterSet setLogicalOp;
480491 CharacterSet setWordStart;
@@ -515,7 +526,8 @@
515526 caseSensitive(caseSensitive_),
516527 setWord(CharacterSet::setAlphaNum, "._", 0x80, true),
517528 setNegationOp(CharacterSet::setNone, "!"),
518- setArithmethicOp(CharacterSet::setNone, "+-/*%"),
529+ setAddOp(CharacterSet::setNone, "+-"),
530+ setMultOp(CharacterSet::setNone, "*/%"),
519531 setRelOp(CharacterSet::setNone, "=!<>"),
520532 setLogicalOp(CharacterSet::setNone, "|&"),
521533 subStyles(styleSubable, 0x80, 0x40, activeFlag) {
@@ -1618,13 +1630,15 @@
16181630 }
16191631
16201632 // Evaluate expressions in precedence order
1621- enum precedence { precArithmetic, precRelative, precLogical };
1622- for (int prec=precArithmetic; prec <= precLogical; prec++) {
1633+ enum precedence { precMult, precAdd, precRelative
1634+ , precLogical, /* end marker */ precLast };
1635+ for (int prec = precMult; prec < precLast; prec++) {
16231636 // Looking at 3 tokens at a time so end at 2 before end
16241637 for (size_t k=0; (k+2)<tokens.size();) {
16251638 const char chOp = tokens[k+1][0];
16261639 if (
1627- ((prec==precArithmetic) && setArithmethicOp.Contains(chOp)) ||
1640+ ((prec==precMult) && setMultOp.Contains(chOp)) ||
1641+ ((prec==precAdd) && setAddOp.Contains(chOp)) ||
16281642 ((prec==precRelative) && setRelOp.Contains(chOp)) ||
16291643 ((prec==precLogical) && setLogicalOp.Contains(chOp))
16301644 ) {
@@ -1657,11 +1671,9 @@
16571671 result = valA || valB;
16581672 else if (tokens[k+1] == "&&")
16591673 result = valA && valB;
1660- char sResult[30];
1661- sprintf(sResult, "%d", result);
16621674 std::vector<std::string>::iterator itInsert =
16631675 tokens.erase(tokens.begin() + k, tokens.begin() + k + 3);
1664- tokens.insert(itInsert, sResult);
1676+ tokens.insert(itInsert, std::to_string(result));
16651677 } else {
16661678 k++;
16671679 }
--- trunk/ext/scintilla/lexers/LexEDIFACT.cxx (revision 28492)
+++ trunk/ext/scintilla/lexers/LexEDIFACT.cxx (revision 28493)
@@ -80,8 +80,8 @@
8080 {
8181 return -1;
8282 }
83- void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
84- void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
83+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
84+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
8585 void * SCI_METHOD PrivateCall(int, void *) override
8686 {
8787 return NULL;
@@ -125,9 +125,9 @@
125125 m_chSegment = '\'';
126126 }
127127
128-void LexerEDIFACT::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess)
128+void LexerEDIFACT::Lex(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess)
129129 {
130- Sci_PositionU posFinish = startPos + lengthDoc;
130+ Sci_PositionU posFinish = startPos + length;
131131 InitialiseFromUNA(pAccess, posFinish);
132132
133133 // Look backwards for a ' or a document beginning
@@ -205,40 +205,85 @@
205205 pAccess->SetStyleFor(posFinish - posSegmentStart, SCE_EDI_BADSEGMENT);
206206 }
207207
208-void LexerEDIFACT::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess)
208+void LexerEDIFACT::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess)
209209 {
210210 if (!m_bFold)
211211 return;
212212
213- // Fold at UNx lines. ie, UNx segments = 0, other segments = 1.
214- // There's no sub folding, so we can be quite simple.
215- Sci_Position endPos = startPos + lengthDoc;
213+ Sci_PositionU endPos = startPos + length;
214+ startPos = FindPreviousEnd(pAccess, startPos);
215+ char c;
216216 char SegmentHeader[4] = { 0 };
217217
218- int iIndentPrevious = 0;
219- Sci_Position lineLast = pAccess->LineFromPosition(endPos);
218+ bool AwaitingSegment = true;
219+ Sci_PositionU currLine = pAccess->LineFromPosition(startPos);
220+ int levelCurrentStyle = SC_FOLDLEVELBASE;
221+ if (currLine > 0)
222+ levelCurrentStyle = pAccess->GetLevel(currLine - 1); // bottom 12 bits are level
223+ int indentCurrent = levelCurrentStyle & SC_FOLDLEVELNUMBERMASK;
224+ int indentNext = indentCurrent;
220225
221- for (Sci_Position lineCurrent = pAccess->LineFromPosition(startPos); lineCurrent <= lineLast; lineCurrent++)
226+ while (startPos < endPos)
222227 {
223- Sci_Position posLineStart = pAccess->LineStart(lineCurrent);
224- posLineStart = ForwardPastWhitespace(pAccess, posLineStart, endPos);
225- Sci_Position lineDataStart = pAccess->LineFromPosition(posLineStart);
226- // Fill in whitespace lines?
227- for (; lineCurrent < lineDataStart; lineCurrent++)
228- pAccess->SetLevel(lineCurrent, SC_FOLDLEVELBASE | SC_FOLDLEVELWHITEFLAG | iIndentPrevious);
229- pAccess->GetCharRange(SegmentHeader, posLineStart, 3);
230- //if (DetectSegmentHeader(SegmentHeader) == SCE_EDI_BADSEGMENT) // Abort if this is not a proper segment header
228+ pAccess->GetCharRange(&c, startPos, 1);
229+ switch (c)
230+ {
231+ case '\t':
232+ case '\r':
233+ case ' ':
234+ startPos++;
235+ continue;
236+ case '\n':
237+ currLine = pAccess->LineFromPosition(startPos);
238+ pAccess->SetLevel(currLine, levelCurrentStyle | indentCurrent);
239+ startPos++;
240+ levelCurrentStyle = SC_FOLDLEVELBASE;
241+ indentCurrent = indentNext;
242+ continue;
243+ }
244+ if (c == m_chRelease)
245+ {
246+ startPos += 2;
247+ continue;
248+ }
249+ if (c == m_chSegment)
250+ {
251+ AwaitingSegment = true;
252+ startPos++;
253+ continue;
254+ }
231255
232- int level = 0;
233- if (memcmp(SegmentHeader, "UNH", 3) == 0) // UNH starts blocks
234- level = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
235- // Check for UNA,B and Z. All others are inside messages
236- else if (!memcmp(SegmentHeader, "UNA", 3) || !memcmp(SegmentHeader, "UNB", 3) || !memcmp(SegmentHeader, "UNZ", 3))
237- level = SC_FOLDLEVELBASE;
238- else
239- level = SC_FOLDLEVELBASE | 1;
240- pAccess->SetLevel(lineCurrent, level);
241- iIndentPrevious = level & SC_FOLDLEVELNUMBERMASK;
256+ if (!AwaitingSegment)
257+ {
258+ startPos++;
259+ continue;
260+ }
261+
262+ // Segment!
263+ pAccess->GetCharRange(SegmentHeader, startPos, 3);
264+ if (SegmentHeader[0] != 'U' || SegmentHeader[1] != 'N')
265+ {
266+ startPos++;
267+ continue;
268+ }
269+
270+ AwaitingSegment = false;
271+ switch (SegmentHeader[2])
272+ {
273+ case 'H':
274+ case 'G':
275+ indentNext++;
276+ levelCurrentStyle = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
277+ break;
278+
279+ case 'T':
280+ case 'E':
281+ if (indentNext > 0)
282+ indentNext--;
283+ break;
284+ }
285+
286+ startPos += 3;
242287 }
243288 }
244289
@@ -314,8 +359,10 @@
314359
315360 if (m_bHighlightAllUN && !memcmp(SegmentHeader, "UN", 2))
316361 return SCE_EDI_UNH;
317- else if (memcmp(SegmentHeader, "UNH", 3) == 0)
362+ else if (!memcmp(SegmentHeader, "UNH", 3))
318363 return SCE_EDI_UNH;
364+ else if (!memcmp(SegmentHeader, "UNG", 3))
365+ return SCE_EDI_UNH;
319366
320367 return SCE_EDI_SEGMENTSTART;
321368 }
--- trunk/ext/scintilla/lexers/LexErrorList.cxx (revision 28492)
+++ trunk/ext/scintilla/lexers/LexErrorList.cxx (revision 28493)
@@ -25,28 +25,30 @@
2525
2626 using namespace Scintilla;
2727
28-static bool strstart(const char *haystack, const char *needle) {
28+namespace {
29+
30+bool strstart(const char *haystack, const char *needle) noexcept {
2931 return strncmp(haystack, needle, strlen(needle)) == 0;
3032 }
3133
32-static bool Is0To9(char ch) {
34+constexpr bool Is0To9(char ch) noexcept {
3335 return (ch >= '0') && (ch <= '9');
3436 }
3537
36-static bool Is1To9(char ch) {
38+constexpr bool Is1To9(char ch) noexcept {
3739 return (ch >= '1') && (ch <= '9');
3840 }
3941
40-static bool IsAlphabetic(int ch) {
42+bool IsAlphabetic(int ch) {
4143 return IsASCII(ch) && isalpha(ch);
4244 }
4345
44-static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
46+inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
4547 return (styler[i] == '\n') ||
4648 ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
4749 }
4850
49-static int RecogniseErrorListLine(const char *lineBuffer, Sci_PositionU lengthLine, Sci_Position &startValue) {
51+int RecogniseErrorListLine(const char *lineBuffer, Sci_PositionU lengthLine, Sci_Position &startValue) {
5052 if (lineBuffer[0] == '>') {
5153 // Command or return status
5254 return SCE_ERR_CMD;
@@ -175,7 +177,7 @@
175177 canBeCtags = false;
176178 }
177179 } else if (state == stGccStart) { // <filename>:
178- state = Is0To9(ch) ? stGccDigit : stUnrecognized;
180+ state = ((ch == '-') || Is0To9(ch)) ? stGccDigit : stUnrecognized;
179181 } else if (state == stGccDigit) { // <filename>:<line>
180182 if (ch == ':') {
181183 state = stGccColumn; // :9.*: is GCC
@@ -206,14 +208,13 @@
206208 } else if ((ch == ':' && chNext == ' ') || (ch == ' ')) {
207209 // Possibly Delphi.. don't test against chNext as it's one of the strings below.
208210 char word[512];
209- Sci_PositionU j, chPos;
210211 unsigned numstep;
211- chPos = 0;
212212 if (ch == ' ')
213213 numstep = 1; // ch was ' ', handle as if it's a delphi errorline, only add 1 to i.
214214 else
215215 numstep = 2; // otherwise add 2.
216- for (j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
216+ Sci_PositionU chPos = 0;
217+ for (Sci_PositionU j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
217218 word[chPos++] = lineBuffer[j];
218219 word[chPos] = 0;
219220 if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") ||
@@ -268,13 +269,11 @@
268269
269270 #define CSI "\033["
270271
271-namespace {
272-
273-bool SequenceEnd(int ch) {
272+constexpr bool SequenceEnd(int ch) noexcept {
274273 return (ch == 0) || ((ch >= '@') && (ch <= '~'));
275274 }
276275
277-int StyleFromSequence(const char *seq) {
276+int StyleFromSequence(const char *seq) noexcept {
278277 int bold = 0;
279278 int colour = 0;
280279 while (!SequenceEnd(*seq)) {
@@ -301,9 +300,7 @@
301300 return SCE_ERR_ES_BLACK + bold * 8 + colour;
302301 }
303302
304-}
305-
306-static void ColouriseErrorListLine(
303+void ColouriseErrorListLine(
307304 char *lineBuffer,
308305 Sci_PositionU lengthLine,
309306 Sci_PositionU endPos,
@@ -311,7 +308,7 @@
311308 bool valueSeparate,
312309 bool escapeSequences) {
313310 Sci_Position startValue = -1;
314- int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue);
311+ const int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue);
315312 if (escapeSequences && strstr(lineBuffer, CSI)) {
316313 const Sci_Position startPos = endPos - lengthLine;
317314 const char *linePortion = lineBuffer;
@@ -354,7 +351,7 @@
354351 }
355352 }
356353
357-static void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) {
354+void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) {
358355 char lineBuffer[10000];
359356 styler.StartAt(startPos);
360357 styler.StartSegment(startPos);
@@ -386,8 +383,10 @@
386383 }
387384 }
388385
389-static const char *const emptyWordListDesc[] = {
390- 0
386+const char *const emptyWordListDesc[] = {
387+ nullptr
391388 };
392389
390+}
391+
393392 LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
--- trunk/ext/scintilla/lexers/LexNim.cxx (nonexistent)
+++ trunk/ext/scintilla/lexers/LexNim.cxx (revision 28493)
@@ -0,0 +1,711 @@
1+// Scintilla source code edit control
2+/** @file LexNim.cxx
3+** Lexer for Nim
4+** Written by Jad Altahan (github.com/xv)
5+** Nim manual: https://nim-lang.org/docs/manual.html
6+**/
7+// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
8+// The License.txt file describes the conditions under which this software may be distributed.
9+
10+#include <stdlib.h>
11+#include <string.h>
12+#include <stdio.h>
13+#include <stdarg.h>
14+#include <assert.h>
15+#include <ctype.h>
16+
17+#include <string>
18+#include <map>
19+#include <algorithm>
20+
21+#include "ILexer.h"
22+#include "Scintilla.h"
23+#include "SciLexer.h"
24+
25+#include "StringCopy.h"
26+#include "WordList.h"
27+#include "LexAccessor.h"
28+#include "Accessor.h"
29+#include "StyleContext.h"
30+#include "CharacterSet.h"
31+#include "CharacterCategory.h"
32+#include "LexerModule.h"
33+#include "OptionSet.h"
34+#include "DefaultLexer.h"
35+
36+using namespace Scintilla;
37+
38+namespace {
39+ // Use an unnamed namespace to protect the functions and classes from name conflicts
40+
41+enum NumType {
42+ Binary,
43+ Octal,
44+ Exponent,
45+ Hexadecimal,
46+ Decimal,
47+ FormatError
48+};
49+
50+int GetNumStyle(const int numType) {
51+ if (numType == NumType::FormatError) {
52+ return SCE_NIM_NUMERROR;
53+ }
54+
55+ return SCE_NIM_NUMBER;
56+}
57+
58+bool IsAWordChar(const int ch) {
59+ return ch < 0x80 && (isalnum(ch) || ch == '_' || ch == '.');
60+}
61+
62+int IsNumHex(const StyleContext &sc) {
63+ return sc.chNext == 'x' || sc.chNext == 'X';
64+}
65+
66+int IsNumBinary(const StyleContext &sc) {
67+ return sc.chNext == 'b' || sc.chNext == 'B';
68+}
69+
70+int IsNumOctal(const StyleContext &sc) {
71+ return IsADigit(sc.chNext) || sc.chNext == 'o';
72+}
73+
74+bool IsNewline(const int ch) {
75+ return (ch == '\n' || ch == '\r');
76+}
77+
78+constexpr bool IsTripleLiteral(const int style) noexcept {
79+ return style == SCE_NIM_TRIPLE || style == SCE_NIM_TRIPLEDOUBLE;
80+}
81+
82+constexpr bool IsLineComment(const int style) noexcept {
83+ return style == SCE_NIM_COMMENTLINE || style == SCE_NIM_COMMENTLINEDOC;
84+}
85+
86+constexpr bool IsStreamComment(const int style) noexcept {
87+ return style == SCE_NIM_COMMENT || style == SCE_NIM_COMMENTDOC;
88+}
89+
90+// Adopted from Accessor.cxx
91+int GetIndent(const Sci_Position line, Accessor &styler) {
92+ Sci_Position startPos = styler.LineStart(line);
93+ Sci_Position eolPos = styler.LineStart(line + 1) - 1;
94+
95+ char ch = styler[startPos];
96+ int style = styler.StyleAt(startPos);
97+
98+ int indent = 0;
99+ bool inPrevPrefix = line > 0;
100+ Sci_Position posPrev = inPrevPrefix ? styler.LineStart(line - 1) : 0;
101+
102+ // No fold points inside block comments and triple literals
103+ while ((IsASpaceOrTab(ch)
104+ || IsStreamComment(style)
105+ || IsTripleLiteral(style)) && (startPos < eolPos)) {
106+ if (inPrevPrefix) {
107+ char chPrev = styler[posPrev++];
108+ if (chPrev != ' ' && chPrev != '\t') {
109+ inPrevPrefix = false;
110+ }
111+ }
112+
113+ if (ch == '\t') {
114+ indent = (indent / 8 + 1) * 8;
115+ } else {
116+ indent++;
117+ }
118+
119+ startPos++;
120+ ch = styler[startPos];
121+ style = styler.StyleAt(startPos);
122+ }
123+
124+ indent += SC_FOLDLEVELBASE;
125+
126+ if (styler.LineStart(line) == styler.Length()
127+ || IsASpaceOrTab(ch)
128+ || IsNewline(ch)
129+ || IsLineComment(style)) {
130+ return indent | SC_FOLDLEVELWHITEFLAG;
131+ } else {
132+ return indent;
133+ }
134+}
135+
136+int IndentAmount(const Sci_Position line, Accessor &styler) {
137+ const int indent = GetIndent(line, styler);
138+ const int indentLevel = indent & SC_FOLDLEVELNUMBERMASK;
139+ return indentLevel <= SC_FOLDLEVELBASE ? indent : indentLevel | (indent & ~SC_FOLDLEVELNUMBERMASK);
140+}
141+
142+struct OptionsNim {
143+ bool fold;
144+ bool foldCompact;
145+
146+ OptionsNim() {
147+ fold = true;
148+ foldCompact = true;
149+ }
150+};
151+
152+static const char *const nimWordListDesc[] = {
153+ "Keywords",
154+ 0
155+};
156+
157+struct OptionSetNim : public OptionSet<OptionsNim> {
158+ OptionSetNim() {
159+ DefineProperty("fold", &OptionsNim::fold);
160+ DefineProperty("fold.compact", &OptionsNim::foldCompact);
161+
162+ DefineWordListSets(nimWordListDesc);
163+ }
164+};
165+
166+LexicalClass lexicalClasses[] = {
167+ // Lexer Nim SCLEX_NIM SCE_NIM_:
168+ 0, "SCE_NIM_DEFAULT", "default", "White space",
169+ 1, "SCE_NIM_COMMENT", "comment block", "Block comment",
170+ 2, "SCE_NIM_COMMENTDOC", "comment block doc", "Block doc comment",
171+ 3, "SCE_NIM_COMMENTLINE", "comment line", "Line comment",
172+ 4, "SCE_NIM_COMMENTLINEDOC", "comment doc", "Line doc comment",
173+ 5, "SCE_NIM_NUMBER", "literal numeric", "Number",
174+ 6, "SCE_NIM_STRING", "literal string", "String",
175+ 7, "SCE_NIM_CHARACTER", "literal string", "Single quoted string",
176+ 8, "SCE_NIM_WORD", "keyword", "Keyword",
177+ 9, "SCE_NIM_TRIPLE", "literal string", "Triple quotes",
178+ 10, "SCE_NIM_TRIPLEDOUBLE", "literal string", "Triple double quotes",
179+ 11, "SCE_NIM_BACKTICKS", "operator definition", "Identifiers",
180+ 12, "SCE_NIM_FUNCNAME", "identifier", "Function name definition",
181+ 13, "SCE_NIM_STRINGEOL", "error literal string", "String is not closed",
182+ 14, "SCE_NIM_NUMERROR", "numeric error", "Numeric format error",
183+ 15, "SCE_NIM_OPERATOR", "operator", "Operators",
184+ 16, "SCE_NIM_IDENTIFIER", "identifier", "Identifiers",
185+};
186+
187+}
188+
189+class LexerNim : public DefaultLexer {
190+ CharacterSet setWord;
191+ WordList keywords;
192+ OptionsNim options;
193+ OptionSetNim osNim;
194+
195+public:
196+ LexerNim() :
197+ DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses)),
198+ setWord(CharacterSet::setAlphaNum, "_", 0x80, true) { }
199+
200+ virtual ~LexerNim() { }
201+
202+ void SCI_METHOD Release() override {
203+ delete this;
204+ }
205+
206+ int SCI_METHOD Version() const override {
207+ return lvRelease4;
208+ }
209+
210+ const char * SCI_METHOD PropertyNames() override {
211+ return osNim.PropertyNames();
212+ }
213+
214+ int SCI_METHOD PropertyType(const char *name) override {
215+ return osNim.PropertyType(name);
216+ }
217+
218+ const char * SCI_METHOD DescribeProperty(const char *name) override {
219+ return osNim.DescribeProperty(name);
220+ }
221+
222+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
223+
224+ const char * SCI_METHOD DescribeWordListSets() override {
225+ return osNim.DescribeWordListSets();
226+ }
227+
228+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
229+
230+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
231+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
232+
233+ void * SCI_METHOD PrivateCall(int, void *) override {
234+ return 0;
235+ }
236+
237+ int SCI_METHOD LineEndTypesSupported() override {
238+ return SC_LINE_END_TYPE_UNICODE;
239+ }
240+
241+ int SCI_METHOD PrimaryStyleFromStyle(int style) override {
242+ return style;
243+ }
244+
245+ static ILexer4 *LexerFactoryNim() {
246+ return new LexerNim();
247+ }
248+};
249+
250+Sci_Position SCI_METHOD LexerNim::PropertySet(const char *key, const char *val) {
251+ if (osNim.PropertySet(&options, key, val)) {
252+ return 0;
253+ }
254+
255+ return -1;
256+}
257+
258+Sci_Position SCI_METHOD LexerNim::WordListSet(int n, const char *wl) {
259+ WordList *wordListN = 0;
260+
261+ switch (n) {
262+ case 0:
263+ wordListN = &keywords;
264+ break;
265+ }
266+
267+ Sci_Position firstModification = -1;
268+
269+ if (wordListN) {
270+ WordList wlNew;
271+ wlNew.Set(wl);
272+
273+ if (*wordListN != wlNew) {
274+ wordListN->Set(wl);
275+ firstModification = 0;
276+ }
277+ }
278+
279+ return firstModification;
280+}
281+
282+void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
283+ int initStyle, IDocument *pAccess) {
284+ // No one likes a leaky string
285+ if (initStyle == SCE_NIM_STRINGEOL) {
286+ initStyle = SCE_NIM_DEFAULT;
287+ }
288+
289+ Accessor styler(pAccess, NULL);
290+ StyleContext sc(startPos, length, initStyle, styler);
291+
292+ // Nim supports nested block comments!
293+ Sci_Position lineCurrent = styler.GetLine(startPos);
294+ int commentNestLevel = lineCurrent > 0 ? styler.GetLineState(lineCurrent - 1) : 0;
295+
296+ int numType = NumType::Decimal;
297+ int decimalCount = 0;
298+
299+ bool funcNameExists = false;
300+ bool isStylingRawString = false;
301+
302+ for (; sc.More(); sc.Forward()) {
303+ if (sc.atLineStart) {
304+ if (sc.state == SCE_NIM_STRING) {
305+ sc.SetState(SCE_NIM_STRING);
306+ }
307+
308+ lineCurrent = styler.GetLine(sc.currentPos);
309+ styler.SetLineState(lineCurrent, commentNestLevel);
310+ }
311+
312+ // Handle string line continuation
313+ if (sc.ch == '\\' && (sc.chNext == '\n' || sc.chNext == '\r') &&
314+ (sc.state == SCE_NIM_STRING || sc.state == SCE_NIM_CHARACTER) && !isStylingRawString) {
315+ sc.Forward();
316+
317+ if (sc.ch == '\r' && sc.chNext == '\n') {
318+ sc.Forward();
319+ }
320+
321+ continue;
322+ }
323+
324+ switch (sc.state) {
325+ case SCE_NIM_OPERATOR:
326+ funcNameExists = false;
327+ sc.SetState(SCE_NIM_DEFAULT);
328+ break;
329+ case SCE_NIM_NUMBER:
330+ // For a type suffix, such as 0x80'u8
331+ if (sc.ch == '\'') {
332+ if (sc.chNext == 'i' || sc.chNext == 'I' ||
333+ sc.chNext == 'u' || sc.chNext == 'U' ||
334+ sc.chNext == 'f' || sc.chNext == 'F' ||
335+ sc.chNext == 'd' || sc.chNext == 'D') {
336+ sc.Forward(2);
337+ }
338+ } else if (sc.ch == '.') {
339+ if (sc.chNext == '.') {
340+ // Pass
341+ } else if (numType <= NumType::Exponent) {
342+ sc.SetState(SCE_NIM_OPERATOR);
343+ break;
344+ } else {
345+ decimalCount++;
346+
347+ if (numType == NumType::Decimal) {
348+ if (decimalCount <= 1 && !IsAWordChar(sc.chNext)) {
349+ break;
350+ }
351+ } else if (numType == NumType::Hexadecimal) {
352+ if (decimalCount <= 1 && IsADigit(sc.chNext, 16)) {
353+ break;
354+ }
355+
356+ sc.SetState(SCE_NIM_OPERATOR);
357+ break;
358+ }
359+ }
360+ } else if (sc.ch == '_') {
361+ break;
362+ } else if (numType == NumType::Decimal) {
363+ if (sc.chPrev != '\'' && (sc.ch == 'e' || sc.ch == 'E')) {
364+ numType = NumType::Exponent;
365+
366+ if (sc.chNext == '-' || sc.chNext == '+') {
367+ sc.Forward();
368+ }
369+
370+ break;
371+ }
372+
373+ if (IsADigit(sc.ch)) {
374+ break;
375+ }
376+ } else if (numType == NumType::Hexadecimal) {
377+ if (IsADigit(sc.ch, 16)) {
378+ break;
379+ }
380+ } else if (IsADigit(sc.ch)) {
381+ if (numType == NumType::Exponent) {
382+ break;
383+ }
384+
385+ if (numType == NumType::Octal) {
386+ // Accept only 0-7
387+ if (sc.ch <= '7') {
388+ break;
389+ }
390+ } else if (numType == NumType::Binary) {
391+ // Accept only 0 and 1
392+ if (sc.ch <= '1') {
393+ break;
394+ }
395+ }
396+
397+ numType = NumType::FormatError;
398+ break;
399+ }
400+
401+ sc.ChangeState(GetNumStyle(numType));
402+ sc.SetState(SCE_NIM_DEFAULT);
403+ break;
404+ case SCE_NIM_IDENTIFIER:
405+ if (!IsAWordChar(sc.ch)) {
406+ char s[100];
407+ sc.GetCurrent(s, sizeof(s));
408+ int style = SCE_NIM_IDENTIFIER;
409+
410+ if (keywords.InList(s) && !funcNameExists) {
411+ style = SCE_NIM_WORD;
412+ } else if (funcNameExists) {
413+ style = SCE_NIM_FUNCNAME;
414+ }
415+
416+ sc.ChangeState(style);
417+ sc.SetState(SCE_NIM_DEFAULT);
418+
419+ if (style == SCE_NIM_WORD) {
420+ if (0 == strcmp(s, "proc")
421+ || 0 == strcmp(s, "func")
422+ || 0 == strcmp(s, "macro")
423+ || 0 == strcmp(s, "method")
424+ || 0 == strcmp(s, "template")
425+ || 0 == strcmp(s, "iterator")
426+ || 0 == strcmp(s, "converter")) {
427+ funcNameExists = true;
428+ } else {
429+ funcNameExists = false;
430+ }
431+ } else {
432+ funcNameExists = false;
433+ }
434+ }
435+ break;
436+ case SCE_NIM_COMMENT:
437+ if (sc.Match(']', '#')) {
438+ if (commentNestLevel > 0) {
439+ commentNestLevel--;
440+ }
441+
442+ lineCurrent = styler.GetLine(sc.currentPos);
443+ styler.SetLineState(lineCurrent, commentNestLevel);
444+ sc.Forward();
445+
446+ if (commentNestLevel == 0) {
447+ sc.ForwardSetState(SCE_NIM_DEFAULT);
448+ }
449+ } else if (sc.Match('#', '[')) {
450+ commentNestLevel++;
451+ lineCurrent = styler.GetLine(sc.currentPos);
452+ styler.SetLineState(lineCurrent, commentNestLevel);
453+ }
454+ break;
455+ case SCE_NIM_COMMENTDOC:
456+ if (sc.Match("]##")) {
457+ if (commentNestLevel > 0) {
458+ commentNestLevel--;
459+ }
460+
461+ lineCurrent = styler.GetLine(sc.currentPos);
462+ styler.SetLineState(lineCurrent, commentNestLevel);
463+ sc.Forward(2);
464+
465+ if (commentNestLevel == 0) {
466+ sc.ForwardSetState(SCE_NIM_DEFAULT);
467+ }
468+ } else if (sc.Match("##[")) {
469+ commentNestLevel++;
470+ lineCurrent = styler.GetLine(sc.currentPos);
471+ styler.SetLineState(lineCurrent, commentNestLevel);
472+ }
473+ break;
474+ case SCE_NIM_COMMENTLINE:
475+ case SCE_NIM_COMMENTLINEDOC:
476+ if (sc.atLineStart) {
477+ sc.SetState(SCE_NIM_DEFAULT);
478+ }
479+ break;
480+ case SCE_NIM_STRING:
481+ if (sc.ch == '\\' && !isStylingRawString) {
482+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
483+ sc.Forward();
484+ }
485+ } else if (sc.ch == '\"') {
486+ sc.ForwardSetState(SCE_NIM_DEFAULT);
487+ } else if (sc.atLineEnd) {
488+ sc.ChangeState(SCE_NIM_STRINGEOL);
489+ sc.ForwardSetState(SCE_NIM_DEFAULT);
490+ }
491+ break;
492+ case SCE_NIM_CHARACTER:
493+ if (sc.ch == '\\') {
494+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
495+ sc.Forward();
496+ }
497+ } else if (sc.ch == '\'') {
498+ sc.ForwardSetState(SCE_NIM_DEFAULT);
499+ } else if (sc.atLineEnd) {
500+ sc.ChangeState(SCE_NIM_STRINGEOL);
501+ sc.ForwardSetState(SCE_NIM_DEFAULT);
502+ }
503+ break;
504+ case SCE_NIM_BACKTICKS:
505+ if (sc.ch == '`' || sc.atLineEnd) {
506+ sc.ForwardSetState(SCE_NIM_DEFAULT);
507+ }
508+ break;
509+ case SCE_NIM_TRIPLEDOUBLE:
510+ if (sc.Match(R"(""")")) {
511+ sc.Forward(2);
512+ sc.ForwardSetState(SCE_NIM_DEFAULT);
513+ }
514+ break;
515+ case SCE_NIM_TRIPLE:
516+ if (sc.Match("'''")) {
517+ sc.Forward(2);
518+ sc.ForwardSetState(SCE_NIM_DEFAULT);
519+ }
520+ break;
521+ }
522+
523+ if (sc.state == SCE_NIM_DEFAULT) {
524+ // Number
525+ if (IsADigit(sc.ch) || (IsADigit(sc.chNext) && sc.ch == '.')) {
526+ sc.SetState(SCE_NIM_NUMBER);
527+
528+ numType = NumType::Decimal;
529+ decimalCount = 0;
530+
531+ if (sc.ch == '0') {
532+ if (IsNumHex(sc)) {
533+ numType = NumType::Hexadecimal;
534+ } else if (IsNumBinary(sc)) {
535+ numType = NumType::Binary;
536+ } else if (IsNumOctal(sc)) {
537+ numType = NumType::Octal;
538+ }
539+
540+ if (numType != NumType::Decimal) {
541+ sc.Forward();
542+ }
543+ }
544+ }
545+ // Raw string
546+ else if ((sc.ch == 'r' || sc.ch == 'R') && sc.chNext == '\"') {
547+ isStylingRawString = true;
548+
549+ sc.SetState(SCE_NIM_STRING);
550+ sc.Forward();
551+ }
552+ // String and triple double literal
553+ else if (sc.ch == '\"') {
554+ isStylingRawString = false;
555+
556+ if (sc.Match(R"(""")")) {
557+ sc.SetState(SCE_NIM_TRIPLEDOUBLE);
558+ } else {
559+ sc.SetState(SCE_NIM_STRING);
560+ }
561+ }
562+ // Charecter and triple literal
563+ else if (sc.ch == '\'') {
564+ if (sc.Match("'''")) {
565+ sc.SetState(SCE_NIM_TRIPLE);
566+ } else {
567+ sc.SetState(SCE_NIM_CHARACTER);
568+ }
569+ }
570+ // Operator definition
571+ else if (sc.ch == '`') {
572+ sc.SetState(SCE_NIM_BACKTICKS);
573+
574+ if (funcNameExists) {
575+ funcNameExists = false;
576+ }
577+ }
578+ // Keyword
579+ else if (iswordstart(sc.ch)) {
580+ sc.SetState(SCE_NIM_IDENTIFIER);
581+ }
582+ // Comments
583+ else if (sc.ch == '#') {
584+ if (sc.Match("##[") || sc.Match("#[")) {
585+ commentNestLevel++;
586+ lineCurrent = styler.GetLine(sc.currentPos);
587+ styler.SetLineState(lineCurrent, commentNestLevel);
588+ }
589+
590+ if (sc.Match("##[")) {
591+ sc.SetState(SCE_NIM_COMMENTDOC);
592+ sc.Forward();
593+ } else if (sc.Match("#[")) {
594+ sc.SetState(SCE_NIM_COMMENT);
595+ sc.Forward();
596+ } else if (sc.Match("##")) {
597+ sc.SetState(SCE_NIM_COMMENTLINEDOC);
598+ } else {
599+ sc.SetState(SCE_NIM_COMMENTLINE);
600+ }
601+ }
602+ // Operators
603+ else if (strchr("()[]{}:=;-\\/&%$!+<>|^?,.*~@", sc.ch)) {
604+ sc.SetState(SCE_NIM_OPERATOR);
605+
606+ // Ignore decimal coloring in input like: range[0..5]
607+ if (sc.Match('.', '.')) {
608+ sc.Forward();
609+
610+ if (sc.chNext == '.') {
611+ sc.Forward();
612+ }
613+ }
614+ }
615+ }
616+
617+ if (sc.atLineEnd) {
618+ funcNameExists = false;
619+ }
620+ }
621+
622+ sc.Complete();
623+}
624+
625+void SCI_METHOD LexerNim::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) {
626+ if (!options.fold) {
627+ return;
628+ }
629+
630+ Accessor styler(pAccess, NULL);
631+
632+ const Sci_Position docLines = styler.GetLine(styler.Length());
633+ const Sci_Position maxPos = startPos + length;
634+ const Sci_Position maxLines = styler.GetLine(maxPos == styler.Length() ? maxPos : maxPos - 1);
635+
636+ Sci_Position lineCurrent = styler.GetLine(startPos);
637+ int indentCurrent = IndentAmount(lineCurrent, styler);
638+
639+ while (lineCurrent > 0) {
640+ lineCurrent--;
641+ indentCurrent = IndentAmount(lineCurrent, styler);
642+
643+ if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
644+ break;
645+ }
646+ }
647+
648+ int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
649+ indentCurrent = indentCurrentLevel | (indentCurrent & ~SC_FOLDLEVELNUMBERMASK);
650+
651+ while (lineCurrent <= docLines && lineCurrent <= maxLines) {
652+ Sci_Position lineNext = lineCurrent + 1;
653+ int indentNext = indentCurrent;
654+ int lev = indentCurrent;
655+
656+ if (lineNext <= docLines) {
657+ indentNext = IndentAmount(lineNext, styler);
658+ }
659+
660+ if (indentNext & SC_FOLDLEVELWHITEFLAG) {
661+ indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
662+ }
663+
664+ while (lineNext < docLines && (indentNext & SC_FOLDLEVELWHITEFLAG)) {
665+ lineNext++;
666+ indentNext = IndentAmount(lineNext, styler);
667+ }
668+
669+ const int indentNextLevel = indentNext & SC_FOLDLEVELNUMBERMASK;
670+ indentNext = indentNextLevel | (indentNext & ~SC_FOLDLEVELNUMBERMASK);
671+
672+ const int levelBeforeComments = std::max(indentCurrentLevel, indentNextLevel);
673+
674+ Sci_Position skipLine = lineNext;
675+ int skipLevel = indentNextLevel;
676+
677+ while (--skipLine > lineCurrent) {
678+ int skipLineIndent = IndentAmount(skipLine, styler);
679+
680+ if (options.foldCompact) {
681+ if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > indentNextLevel) {
682+ skipLevel = levelBeforeComments;
683+ }
684+
685+ int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
686+ styler.SetLevel(skipLine, skipLevel | whiteFlag);
687+ } else {
688+ if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > indentNextLevel &&
689+ !(skipLineIndent & SC_FOLDLEVELWHITEFLAG)) {
690+ skipLevel = levelBeforeComments;
691+ }
692+
693+ styler.SetLevel(skipLine, skipLevel);
694+ }
695+ }
696+
697+ if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
698+ if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
699+ lev |= SC_FOLDLEVELHEADERFLAG;
700+ }
701+ }
702+
703+ styler.SetLevel(lineCurrent, options.foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
704+
705+ indentCurrent = indentNext;
706+ indentCurrentLevel = indentNextLevel;
707+ lineCurrent = lineNext;
708+ }
709+}
710+
711+LexerModule lmNim(SCLEX_NIM, LexerNim::LexerFactoryNim, "nim", nimWordListDesc);
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
--- trunk/ext/scintilla/lexlib/CharacterCategory.cxx (revision 28492)
+++ trunk/ext/scintilla/lexlib/CharacterCategory.cxx (revision 28493)
@@ -19,7 +19,7 @@
1919
2020 const int catRanges[] = {
2121 //++Autogenerated -- start of section automatically generated
22-// Created with Python 3.6.1, Unicode 9.0.0
22+// Created with Python 3.7.0, Unicode 11.0.0
2323 25,
2424 1046,
2525 1073,
@@ -651,9 +651,7 @@
651651 43773,
652652 43811,
653653 43857,
654-44061,
655-44065,
656-45341,
654+44033,
657655 45361,
658656 45388,
659657 45437,
@@ -672,7 +670,7 @@
672670 47389,
673671 47620,
674672 48509,
675-48644,
673+48612,
676674 48753,
677675 48829,
678676 49178,
@@ -730,6 +728,8 @@
730728 65265,
731729 65347,
732730 65405,
731+65445,
732+65491,
733733 65540,
734734 66245,
735735 66371,
@@ -746,11 +746,13 @@
746746 68509,
747747 68561,
748748 68605,
749+68612,
750+68989,
749751 70660,
750752 71357,
751753 71364,
752754 71645,
753-72325,
755+72293,
754756 72794,
755757 72805,
756758 73830,
@@ -812,7 +814,10 @@
812814 81546,
813815 81749,
814816 81779,
815-81821,
817+81796,
818+81841,
819+81861,
820+81917,
816821 81957,
817822 82022,
818823 82077,
@@ -849,7 +854,8 @@
849854 85509,
850855 85572,
851856 85669,
852-85725,
857+85713,
858+85757,
853859 86053,
854860 86118,
855861 86173,
@@ -886,7 +892,8 @@
886892 89651,
887893 89693,
888894 89892,
889-89949,
895+89925,
896+90141,
890897 90149,
891898 90182,
892899 90269,
@@ -969,7 +976,7 @@
969976 98173,
970977 98309,
971978 98342,
972-98461,
979+98437,
973980 98468,
974981 98749,
975982 98756,
@@ -1000,7 +1007,7 @@
10001007 102404,
10011008 102437,
10021009 102470,
1003-102557,
1010+102545,
10041011 102564,
10051012 102845,
10061013 102852,
@@ -1034,7 +1041,7 @@
10341041 106013,
10351042 106020,
10361043 106109,
1037-106533,
1044+106501,
10381045 106566,
10391046 106653,
10401047 106660,
@@ -1042,7 +1049,7 @@
10421049 106948,
10431050 107069,
10441051 107076,
1045-108413,
1052+108389,
10461053 108452,
10471054 108486,
10481055 108581,
@@ -1229,10 +1236,11 @@
12291236 137501,
12301237 137632,
12311238 137693,
1232-137732,
1239+137729,
12331240 139121,
12341241 139139,
1235-139172,
1242+139169,
1243+139268,
12361244 149821,
12371245 149828,
12381246 149981,
@@ -1337,7 +1345,7 @@
13371345 197636,
13381346 198755,
13391347 198788,
1340-200477,
1348+200509,
13411349 200708,
13421350 200869,
13431351 200932,
@@ -1463,6 +1471,9 @@
14631471 233425,
14641472 233473,
14651473 233789,
1474+233984,
1475+235389,
1476+235424,
14661477 235537,
14671478 235805,
14681479 236037,
@@ -1476,7 +1487,7 @@
14761487 237126,
14771488 237189,
14781489 237220,
1479-237309,
1490+237286,
14801491 237317,
14811492 237405,
14821493 237569,
@@ -1486,7 +1497,7 @@
14861497 241441,
14871498 242531,
14881499 243717,
1489-245469,
1500+245597,
14901501 245605,
14911502 245760,
14921503 245793,
@@ -1849,7 +1860,7 @@
18491860 266755,
18501861 267197,
18511862 267283,
1852-268285,
1863+268317,
18531864 268805,
18541865 269223,
18551866 269349,
@@ -1940,8 +1951,6 @@
19401951 292501,
19411952 293778,
19421953 293973,
1943-294909,
1944-294933,
19451954 296189,
19461955 296981,
19471956 297341,
@@ -2030,13 +2039,9 @@
20302039 356053,
20312040 357085,
20322041 357141,
2033-358237,
2034-358325,
20352042 358717,
20362043 358741,
2037-359005,
2038-359829,
2039-359965,
2044+360445,
20402045 360448,
20412046 361981,
20422047 361985,
@@ -2239,7 +2244,7 @@
22392244 378929,
22402245 378957,
22412246 378993,
2242-379069,
2247+379389,
22432248 380949,
22442249 381789,
22452250 381813,
@@ -2302,7 +2307,7 @@
23022307 401380,
23032308 401437,
23042309 401572,
2305-402909,
2310+402973,
23062311 402980,
23072312 406013,
23082313 406037,
@@ -2331,7 +2336,7 @@
23312336 636637,
23322337 636949,
23332338 638980,
2334-1309405,
2339+1310237,
23352340 1310724,
23362341 1311395,
23372342 1311428,
@@ -2563,12 +2568,14 @@
25632568 1373440,
25642569 1373473,
25652570 1373504,
2566-1373693,
2571+1373665,
25672572 1373696,
25682573 1373857,
25692574 1373888,
25702575 1373921,
2571-1373981,
2576+1373952,
2577+1373985,
2578+1374045,
25722579 1375972,
25732580 1376003,
25742581 1376065,
@@ -2606,7 +2613,7 @@
26062613 1384292,
26072614 1384337,
26082615 1384356,
2609-1384413,
2616+1384421,
26102617 1384456,
26112618 1384772,
26122619 1385669,
@@ -2919,7 +2926,7 @@
29192926 2121732,
29202927 2122762,
29212928 2122909,
2922-2123268,
2929+2123172,
29232930 2123817,
29242931 2123844,
29252932 2124105,
@@ -3010,12 +3017,12 @@
30103017 2179748,
30113018 2179869,
30123019 2179876,
3013-2180765,
3020+2180829,
30143021 2180869,
30153022 2180989,
30163023 2181093,
30173024 2181130,
3018-2181405,
3025+2181437,
30193026 2181649,
30203027 2181949,
30213028 2182148,
@@ -3054,9 +3061,22 @@
30543061 2201601,
30553062 2203261,
30563063 2203466,
3057-2203677,
3064+2203652,
3065+2204805,
3066+2204957,
3067+2205192,
3068+2205533,
30583069 2214922,
30593070 2215933,
3071+2220036,
3072+2220970,
3073+2221284,
3074+2221341,
3075+2221572,
3076+2222277,
3077+2222634,
3078+2222769,
3079+2222941,
30603080 2228230,
30613081 2228261,
30623082 2228294,
@@ -3078,6 +3098,8 @@
30783098 2234298,
30793099 2234321,
30803100 2234461,
3101+2234810,
3102+2234845,
30813103 2234884,
30823104 2235709,
30833105 2235912,
@@ -3090,7 +3112,9 @@
30903112 2238141,
30913113 2238152,
30923114 2238481,
3093-2238621,
3115+2238596,
3116+2238630,
3117+2238717,
30943118 2238980,
30953119 2240101,
30963120 2240145,
@@ -3104,7 +3128,7 @@
31043128 2242534,
31053129 2242596,
31063130 2242737,
3107-2242885,
3131+2242853,
31083132 2242993,
31093133 2243037,
31103134 2243080,
@@ -3160,7 +3184,7 @@
31603184 2254493,
31613185 2254500,
31623186 2254685,
3163-2254725,
3187+2254693,
31643188 2254756,
31653189 2254790,
31663190 2254853,
@@ -3195,7 +3219,8 @@
31953219 2263921,
31963220 2263965,
31973221 2263985,
3198-2264029,
3222+2264005,
3223+2264061,
31993224 2265092,
32003225 2266630,
32013226 2266725,
@@ -3249,7 +3274,7 @@
32493274 2283528,
32503275 2283869,
32513276 2285572,
3252-2286429,
3277+2286461,
32533278 2286501,
32543279 2286598,
32553280 2286661,
@@ -3261,6 +3286,13 @@
32613286 2287505,
32623287 2287605,
32633288 2287645,
3289+2293764,
3290+2295174,
3291+2295269,
3292+2295558,
3293+2295589,
3294+2295665,
3295+2295709,
32643296 2298880,
32653297 2299905,
32663298 2300936,
@@ -3268,6 +3300,30 @@
32683300 2301565,
32693301 2301924,
32703302 2301981,
3303+2310148,
3304+2310181,
3305+2310500,
3306+2311781,
3307+2311974,
3308+2312004,
3309+2312037,
3310+2312177,
3311+2312421,
3312+2312477,
3313+2312708,
3314+2312741,
3315+2312934,
3316+2312997,
3317+2313092,
3318+2314397,
3319+2314436,
3320+2314565,
3321+2314982,
3322+2315013,
3323+2315089,
3324+2315172,
3325+2315217,
3326+2315389,
32713327 2316292,
32723328 2318141,
32733329 2326532,
@@ -3297,6 +3353,45 @@
32973353 2332294,
32983354 2332325,
32993355 2332413,
3356+2334724,
3357+2334973,
3358+2334980,
3359+2335069,
3360+2335076,
3361+2336293,
3362+2336509,
3363+2336581,
3364+2336637,
3365+2336645,
3366+2336733,
3367+2336741,
3368+2336964,
3369+2336997,
3370+2337053,
3371+2337288,
3372+2337629,
3373+2337796,
3374+2338013,
3375+2338020,
3376+2338109,
3377+2338116,
3378+2339142,
3379+2339325,
3380+2339333,
3381+2339421,
3382+2339430,
3383+2339493,
3384+2339526,
3385+2339557,
3386+2339588,
3387+2339645,
3388+2339848,
3389+2340189,
3390+2350084,
3391+2350693,
3392+2350758,
3393+2350833,
3394+2350909,
33003395 2359300,
33013396 2388829,
33023397 2392073,
@@ -3338,6 +3433,11 @@
33383433 2977565,
33393434 2977700,
33403435 2978333,
3436+3000320,
3437+3001345,
3438+3002378,
3439+3003121,
3440+3003261,
33413441 3006468,
33423442 3008701,
33433443 3009028,
@@ -3347,13 +3447,15 @@
33473447 3011171,
33483448 3011613,
33493449 3013635,
3350-3013693,
3450+3013725,
33513451 3014660,
3352-3210685,
3452+3210845,
33533453 3211268,
33543454 3235453,
33553455 3538948,
3356-3539037,
3456+3548157,
3457+3550724,
3458+3563421,
33573459 3637252,
33583460 3640701,
33593461 3640836,
@@ -3388,10 +3490,12 @@
33883490 3819589,
33893491 3819701,
33903492 3819741,
3493+3824650,
3494+3825309,
33913495 3825685,
33923496 3828477,
33933497 3828746,
3394-3829341,
3498+3829565,
33953499 3833856,
33963500 3834689,
33973501 3835520,
@@ -3520,6 +3624,12 @@
35203624 4008797,
35213625 4008913,
35223626 4008989,
3627+4034090,
3628+4035989,
3629+4036010,
3630+4036115,
3631+4036138,
3632+4036285,
35233633 4046852,
35243634 4047005,
35253635 4047012,
@@ -3603,8 +3713,6 @@
36033713 4071434,
36043714 4071869,
36053715 4071957,
3606-4072957,
3607-4072981,
36083716 4074909,
36093717 4075029,
36103718 4076989,
@@ -3616,18 +3724,20 @@
36163724 4081981,
36173725 4082197,
36183726 4082269,
3727+4082709,
3728+4082909,
36193729 4087829,
36203730 4095860,
36213731 4096021,
3622-4119165,
3732+4119229,
36233733 4119573,
36243734 4119997,
36253735 4120085,
3626-4120317,
3736+4120413,
36273737 4120597,
36283738 4124317,
36293739 4124693,
3630-4127421,
3740+4127549,
36313741 4128789,
36323742 4129181,
36333743 4129301,
@@ -3638,22 +3748,26 @@
36383748 4133149,
36393749 4133397,
36403750 4134365,
3751+4136981,
3752+4137373,
36413753 4137493,
3642-4137981,
3643-4138005,
3644-4138269,
3645-4138517,
3646-4138557,
3647-4138613,
36483754 4139005,
36493755 4139029,
3650-4139421,
3651-4139541,
3652-4140029,
3653-4141077,
3654-4141661,
3756+4140605,
3757+4140661,
3758+4140797,
3759+4140885,
3760+4140925,
3761+4140949,
3762+4142205,
3763+4142613,
3764+4142941,
36553765 4143125,
3656-4143165,
3766+4143229,
3767+4143637,
3768+4145181,
3769+4148245,
3770+4148701,
36573771 4194308,
36583772 5561085,
36593773 5562372,
@@ -3662,6 +3776,8 @@
36623776 5702621,
36633777 5702660,
36643778 5887069,
3779+5887492,
3780+6126653,
36653781 6225924,
36663782 6243293,
36673783 29360186,
--- trunk/ext/scintilla/lexlib/PropSetSimple.cxx (revision 28492)
+++ trunk/ext/scintilla/lexlib/PropSetSimple.cxx (revision 28493)
@@ -117,7 +117,7 @@
117117 innerVarStart = withVars.find("$(", varStart+2);
118118 }
119119
120- std::string var(withVars.c_str(), varStart + 2, varEnd - varStart - 2);
120+ std::string var(withVars, varStart + 2, varEnd - varStart - 2);
121121 std::string val = props.Get(var.c_str());
122122
123123 if (blankVars.contains(var.c_str())) {
--- trunk/ext/scintilla/src/CaseConvert.cxx (revision 28492)
+++ trunk/ext/scintilla/src/CaseConvert.cxx (revision 28493)
@@ -56,6 +56,7 @@
5656 1218,1217,7,2,
5757 1233,1232,48,2,
5858 1377,1329,38,1,
59+4304,7312,43,1,
5960 7681,7680,75,2,
6061 7841,7840,48,2,
6162 7936,7944,8,1,
@@ -80,6 +81,7 @@
8081 66776,66736,36,1,
8182 68800,68736,51,1,
8283 71872,71840,32,1,
84+93792,93760,32,1,
8385 125218,125184,34,1,
8486
8587 //--Autogenerated -- end of section automatically generated
@@ -185,6 +187,9 @@
185187 1016,1015,
186188 1019,1018,
187189 1231,1216,
190+4349,7357,
191+4350,7358,
192+4351,7359,
188193 7545,42877,
189194 7549,11363,
190195 8017,8025,
@@ -234,6 +239,7 @@
234239 42899,42898,
235240 42933,42932,
236241 42935,42934,
242+42937,42936,
237243 43859,42931,
238244
239245 //--Autogenerated -- end of section automatically generated
@@ -594,7 +600,7 @@
594600 }
595601 virtual ~CaseConverter() = default;
596602 bool Initialised() const {
597- return characters.size() > 0;
603+ return !characters.empty();
598604 }
599605 void Add(int character, const char *conversion) {
600606 characterToConversion.emplace_back(character, conversion);
@@ -602,11 +608,11 @@
602608 const char *Find(int character) {
603609 const std::vector<int>::iterator it = std::lower_bound(characters.begin(), characters.end(), character);
604610 if (it == characters.end())
605- return 0;
611+ return nullptr;
606612 else if (*it == character)
607613 return conversions[it - characters.begin()].conversion;
608614 else
609- return 0;
615+ return nullptr;
610616 }
611617 size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override {
612618 size_t lenConverted = 0;
@@ -614,7 +620,7 @@
614620 unsigned char bytes[UTF8MaxBytes + 1]{};
615621 while (mixedPos < lenMixed) {
616622 const unsigned char leadByte = mixed[mixedPos];
617- const char *caseConverted = 0;
623+ const char *caseConverted = nullptr;
618624 size_t lenMixedChar = 1;
619625 if (UTF8IsAscii(leadByte)) {
620626 caseConverted = Find(leadByte);
@@ -779,7 +785,7 @@
779785 case CaseConversionLower:
780786 return &caseConvLow;
781787 }
782- return 0;
788+ return nullptr;
783789 }
784790
785791 }
--- trunk/ext/scintilla/src/Catalogue.cxx (revision 28492)
+++ trunk/ext/scintilla/src/Catalogue.cxx (revision 28493)
@@ -33,7 +33,7 @@
3333 return lm;
3434 }
3535 }
36- return 0;
36+ return nullptr;
3737 }
3838
3939 const LexerModule *Catalogue::Find(const char *languageName) {
@@ -45,7 +45,7 @@
4545 }
4646 }
4747 }
48- return 0;
48+ return nullptr;
4949 }
5050
5151 void Catalogue::AddLexerModule(LexerModule *plm) {
@@ -142,6 +142,7 @@
142142 LINK_LEXER(lmModula);
143143 LINK_LEXER(lmMSSQL);
144144 LINK_LEXER(lmMySQL);
145+ LINK_LEXER(lmNim);
145146 LINK_LEXER(lmNimrod);
146147 LINK_LEXER(lmNncrontab);
147148 LINK_LEXER(lmNsis);
--- trunk/ext/scintilla/src/CellBuffer.cxx (revision 28492)
+++ trunk/ext/scintilla/src/CellBuffer.cxx (revision 28493)
@@ -138,7 +138,7 @@
138138 LineStartIndex<POS> startsUTF16;
139139 LineStartIndex<POS> startsUTF32;
140140 public:
141- LineVector() : starts(256), perLine(0) {
141+ LineVector() : starts(256), perLine(nullptr) {
142142 Init();
143143 }
144144 // Deleted so LineVector objects can not be copied.
@@ -650,7 +650,7 @@
650650 const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence) {
651651 // InsertString and DeleteChars are the bottleneck though which all changes occur
652652 PLATFORM_ASSERT(deleteLength > 0);
653- const char *data = 0;
653+ const char *data = nullptr;
654654 if (!readOnly) {
655655 if (collectingUndo) {
656656 // Save into the undo/redo stack, but only the characters - not the formatting
@@ -900,6 +900,10 @@
900900
901901 }
902902
903+bool CellBuffer::MaintainingLineCharacterIndex() const noexcept {
904+ return plv->LineCharacterIndex() != SC_LINECHARACTERINDEX_NONE;
905+}
906+
903907 void CellBuffer::RecalculateIndexLineStarts(Sci::Line lineFirst, Sci::Line lineLast) {
904908 std::string text;
905909 Sci::Position posLineEnd = LineStart(lineFirst);
@@ -932,8 +936,10 @@
932936 // A simple insertion is one that inserts valid text on a single line at a character boundary
933937 bool simpleInsertion = false;
934938
939+ const bool maintainingIndex = MaintainingLineCharacterIndex();
940+
935941 // Check for breaking apart a UTF-8 sequence and inserting invalid UTF-8
936- if (utf8Substance && (plv->LineCharacterIndex() != SC_LINECHARACTERINDEX_NONE)) {
942+ if (utf8Substance && maintainingIndex) {
937943 // Actually, don't need to check that whole insertion is valid just that there
938944 // are no potential fragments at ends.
939945 simpleInsertion = UTF8IsCharacterBoundary(position) &&
@@ -1011,11 +1017,13 @@
10111017 chPrev = chAt;
10121018 }
10131019 }
1014- if (simpleInsertion) {
1015- const CountWidths cw = CountCharacterWidthsUTF8(std::string_view(s, insertLength));
1016- plv->InsertCharacters(linePosition, cw);
1017- } else {
1018- RecalculateIndexLineStarts(linePosition, lineInsert - 1);
1020+ if (maintainingIndex) {
1021+ if (simpleInsertion) {
1022+ const CountWidths cw = CountCharacterWidthsUTF8(std::string_view(s, insertLength));
1023+ plv->InsertCharacters(linePosition, cw);
1024+ } else {
1025+ RecalculateIndexLineStarts(linePosition, lineInsert - 1);
1026+ }
10191027 }
10201028 }
10211029
@@ -1043,7 +1051,7 @@
10431051
10441052 // Check for breaking apart a UTF-8 sequence
10451053 // Needs further checks that text is UTF-8 or that some other break apart is occurring
1046- if (utf8Substance && (plv->LineCharacterIndex() != SC_LINECHARACTERINDEX_NONE)) {
1054+ if (utf8Substance && MaintainingLineCharacterIndex()) {
10471055 const Sci::Position posEnd = position + deleteLength;
10481056 const Sci::Line lineEndRemove = plv->LineFromPosition(posEnd);
10491057 const bool simpleDeletion =
@@ -1140,7 +1148,7 @@
11401148
11411149 void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) {
11421150 bool startSequence;
1143- uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce);
1151+ uh.AppendAction(containerAction, token, nullptr, 0, startSequence, mayCoalesce);
11441152 }
11451153
11461154 void CellBuffer::DeleteUndoHistory() {
--- trunk/ext/scintilla/src/CellBuffer.h (revision 28492)
+++ trunk/ext/scintilla/src/CellBuffer.h (revision 28493)
@@ -125,6 +125,7 @@
125125 bool UTF8IsCharacterBoundary(Sci::Position position) const;
126126 void ResetLineEnds();
127127 void RecalculateIndexLineStarts(Sci::Line lineFirst, Sci::Line lineLast);
128+ bool MaintainingLineCharacterIndex() const noexcept;
128129 /// Actions without undo
129130 void BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength);
130131 void BasicDeleteChars(Sci::Position position, Sci::Position deleteLength);
--- trunk/ext/scintilla/src/ContractionState.cxx (revision 28492)
+++ trunk/ext/scintilla/src/ContractionState.cxx (revision 28493)
@@ -211,7 +211,7 @@
211211
212212 template <typename LINE>
213213 void ContractionState<LINE>::InsertLines(Sci::Line lineDoc, Sci::Line lineCount) {
214- for (int l = 0; l < lineCount; l++) {
214+ for (Sci::Line l = 0; l < lineCount; l++) {
215215 InsertLine(lineDoc + l);
216216 }
217217 Check();
--- trunk/ext/scintilla/src/Document.cxx (revision 28492)
+++ trunk/ext/scintilla/src/Document.cxx (revision 28493)
@@ -84,8 +84,31 @@
8484 return 0;
8585 }
8686
87+ActionDuration::ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept :
88+ duration(duration_), minDuration(minDuration_), maxDuration(maxDuration_) {
89+}
90+
91+void ActionDuration::AddSample(size_t numberActions, double durationOfActions) noexcept {
92+ // Only adjust for multiple actions to avoid instability
93+ if (numberActions < 8)
94+ return;
95+
96+ // Alpha value for exponential smoothing.
97+ // Most recent value contributes 25% to smoothed value.
98+ const double alpha = 0.25;
99+
100+ const double durationOne = durationOfActions / numberActions;
101+ duration = std::clamp(alpha * durationOne + (1.0 - alpha) * duration,
102+ minDuration, maxDuration);
103+}
104+
105+double ActionDuration::Duration() const noexcept {
106+ return duration;
107+}
108+
87109 Document::Document(int options) :
88- cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0) {
110+ cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0),
111+ durationStyleOneLine(0.00001, 0.000001, 0.0001) {
89112 refCount = 0;
90113 #ifdef _WIN32
91114 eolMode = SC_EOL_CRLF;
@@ -106,7 +129,6 @@
106129 useTabs = true;
107130 tabIndents = true;
108131 backspaceUnindents = false;
109- durationStyleOneLine = 0.00001;
110132
111133 matchesValid = false;
112134
@@ -300,7 +322,7 @@
300322 NotifyModified(mh);
301323 return prev;
302324 } else {
303- return 0;
325+ return -1;
304326 }
305327 }
306328
@@ -905,8 +927,8 @@
905927 int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const {
906928 int character;
907929 int bytesInCharacter = 1;
930+ const unsigned char leadByte = cb.UCharAt(position);
908931 if (dbcsCodePage) {
909- const unsigned char leadByte = cb.UCharAt(position);
910932 if (SC_CP_UTF8 == dbcsCodePage) {
911933 if (UTF8IsAscii(leadByte)) {
912934 // Single byte character or invalid
@@ -934,7 +956,7 @@
934956 }
935957 }
936958 } else {
937- character = cb.CharAt(position);
959+ character = leadByte;
938960 }
939961 if (pWidth) {
940962 *pWidth = bytesInCharacter;
@@ -2211,30 +2233,11 @@
22112233 }
22122234
22132235 void Document::StyleToAdjustingLineDuration(Sci::Position pos) {
2214- // Place bounds on the duration used to avoid glitches spiking it
2215- // and so causing slow styling or non-responsive scrolling
2216- const double minDurationOneLine = 0.000001;
2217- const double maxDurationOneLine = 0.0001;
2218-
2219- // Alpha value for exponential smoothing.
2220- // Most recent value contributes 25% to smoothed value.
2221- const double alpha = 0.25;
2222-
22232236 const Sci::Line lineFirst = SciLineFromPosition(GetEndStyled());
22242237 ElapsedPeriod epStyling;
22252238 EnsureStyledTo(pos);
2226- const double durationStyling = epStyling.Duration();
22272239 const Sci::Line lineLast = SciLineFromPosition(GetEndStyled());
2228- if (lineLast >= lineFirst + 8) {
2229- // Only adjust for styling multiple lines to avoid instability
2230- const double durationOneLine = durationStyling / (lineLast - lineFirst);
2231- durationStyleOneLine = alpha * durationOneLine + (1.0 - alpha) * durationStyleOneLine;
2232- if (durationStyleOneLine < minDurationOneLine) {
2233- durationStyleOneLine = minDurationOneLine;
2234- } else if (durationStyleOneLine > maxDurationOneLine) {
2235- durationStyleOneLine = maxDurationOneLine;
2236- }
2237- }
2240+ durationStyleOneLine.AddSample(lineLast - lineFirst, epStyling.Duration());
22382241 }
22392242
22402243 void Document::LexerChanged() {
@@ -3188,7 +3191,7 @@
31883191 substituted.clear();
31893192 const DocumentIndexer di(doc, doc->Length());
31903193 search.GrabMatches(di);
3191- for (int j = 0; j < *length; j++) {
3194+ for (Sci::Position j = 0; j < *length; j++) {
31923195 if (text[j] == '\\') {
31933196 if (text[j + 1] >= '0' && text[j + 1] <= '9') {
31943197 const unsigned int patNum = text[j + 1] - '0';
--- trunk/ext/scintilla/src/Document.h (revision 28492)
+++ trunk/ext/scintilla/src/Document.h (revision 28493)
@@ -190,7 +190,27 @@
190190 };
191191
192192 /**
193+ * The ActionDuration class stores the average time taken for some action such as styling or
194+ * wrapping a line. It is used to decide how many repetitions of that action can be performed
195+ * on idle to maximize efficiency without affecting application responsiveness.
196+ * The duration changes if the time for the action changes. For example, if a simple lexer is
197+ * changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy
198+ * or difficult processing moving the value too far leading to inefficiency or poor user
199+ * experience.
193200 */
201+
202+class ActionDuration {
203+ double duration;
204+ const double minDuration;
205+ const double maxDuration;
206+public:
207+ ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept;
208+ void AddSample(size_t numberActions, double durationOfActions) noexcept;
209+ double Duration() const noexcept;
210+};
211+
212+/**
213+ */
194214 class Document : PerLine, public IDocument, public ILoader {
195215
196216 public:
@@ -259,7 +279,7 @@
259279 bool useTabs;
260280 bool tabIndents;
261281 bool backspaceUnindents;
262- double durationStyleOneLine;
282+ ActionDuration durationStyleOneLine;
263283
264284 std::unique_ptr<IDecorationList> decorations;
265285
--- trunk/ext/scintilla/src/EditModel.cxx (revision 28492)
+++ trunk/ext/scintilla/src/EditModel.cxx (revision 28493)
@@ -75,7 +75,7 @@
7575
7676 EditModel::~EditModel() {
7777 pdoc->Release();
78- pdoc = 0;
78+ pdoc = nullptr;
7979 }
8080
8181 bool EditModel::BidirectionalEnabled() const {
--- trunk/ext/scintilla/src/EditView.cxx (revision 28492)
+++ trunk/ext/scintilla/src/EditView.cxx (revision 28493)
@@ -56,7 +56,6 @@
5656 #include "MarginView.h"
5757 #include "EditView.h"
5858 #include "ElapsedPeriod.h"
59-#include "Editor.h"
6059
6160 using namespace Scintilla;
6261
@@ -189,7 +188,6 @@
189188 tabArrowHeight = 4;
190189 customDrawTabArrow = nullptr;
191190 customDrawWrapMarker = nullptr;
192- editor = NULL;
193191 }
194192
195193 EditView::~EditView() {
@@ -976,7 +974,7 @@
976974 int alpha = SC_ALPHA_NOALPHA;
977975 if (!hideSelection) {
978976 const Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1);
979- eolInSelection = (lastSubLine == true) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
977+ eolInSelection = lastSubLine ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
980978 alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
981979 }
982980
@@ -2017,17 +2015,7 @@
20172015 }
20182016
20192017 // See if something overrides the line background color.
2020- ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
2021- SCNotification scn = { 0 };
2022- scn.nmhdr.code = SCN_GETBKCOLOR;
2023- scn.line = line;
2024- scn.lParam = -1;
2025- if (editor)
2026- ((Editor*)editor)->NotifyParent(&scn);
2027- if (scn.lParam != -1)
2028- {
2029- background = ColourOptional(true, scn.lParam);
2030- }
2018+ const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
20312019
20322020 const Sci::Position posLineStart = model.pdoc->LineStart(line);
20332021
--- trunk/ext/scintilla/src/EditView.h (revision 28492)
+++ trunk/ext/scintilla/src/EditView.h (revision 28493)
@@ -77,7 +77,6 @@
7777 std::unique_ptr<Surface> pixmapLine;
7878 std::unique_ptr<Surface> pixmapIndentGuide;
7979 std::unique_ptr<Surface> pixmapIndentGuideHighlight;
80- void *editor;
8180
8281 LineLayoutCache llc;
8382 PositionCache posCache;
--- trunk/ext/scintilla/src/Editor.cxx (revision 28492)
+++ trunk/ext/scintilla/src/Editor.cxx (revision 28493)
@@ -22,6 +22,7 @@
2222 #include <algorithm>
2323 #include <iterator>
2424 #include <memory>
25+#include <chrono>
2526
2627 #include "Platform.h"
2728
@@ -54,6 +55,7 @@
5455 #include "MarginView.h"
5556 #include "EditView.h"
5657 #include "Editor.h"
58+#include "ElapsedPeriod.h"
5759
5860 using namespace Scintilla;
5961
@@ -89,7 +91,7 @@
8991 }
9092
9193 Timer::Timer() :
92- ticking(false), ticksToWait(0), tickerID(0) {}
94+ ticking(false), ticksToWait(0), tickerID{} {}
9395
9496 Idler::Idler() :
9597 state(false), idlerID(0) {}
@@ -103,8 +105,7 @@
103105 return true;
104106 }
105107
106-Editor::Editor() {
107- view.editor = this;
108+Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) {
108109 ctrlID = 0;
109110
110111 stylesValid = false;
@@ -182,6 +183,7 @@
182183 needIdleStyling = false;
183184
184185 modEventMask = SC_MODEVENTMASKALL;
186+ commandEvents = true;
185187
186188 pdoc->AddWatcher(this, 0);
187189
@@ -771,6 +773,7 @@
771773 selectedText.c_str(), searchFlags, &lengthFound);
772774 if (pos >= 0) {
773775 sel.AddSelection(SelectionRange(pos + lengthFound, pos));
776+ ContainerNeedsUpdate(SC_UPDATE_SELECTION);
774777 ScrollRange(sel.RangeMain());
775778 Redraw();
776779 if (addNumber == addOne)
@@ -1536,7 +1539,12 @@
15361539 return false;
15371540 }
15381541 } else if (ws == WrapScope::wsIdle) {
1539- lineToWrapEnd = lineToWrap + LinesOnScreen() + 100;
1542+ // Try to keep time taken by wrapping reasonable so interaction remains smooth.
1543+ const double secondsAllowed = 0.01;
1544+ const Sci::Line linesInAllowedTime = std::clamp<Sci::Line>(
1545+ static_cast<Sci::Line>(secondsAllowed / durationWrapOneLine.Duration()),
1546+ LinesOnScreen() + 50, 0x10000);
1547+ lineToWrapEnd = lineToWrap + linesInAllowedTime;
15401548 }
15411549 const Sci::Line lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal());
15421550 lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap);
@@ -1555,6 +1563,8 @@
15551563 if (surface) {
15561564 //Platform::DebugPrintf("Wraplines: scope=%0d need=%0d..%0d perform=%0d..%0d\n", ws, wrapPending.start, wrapPending.end, lineToWrap, lineToWrapEnd);
15571565
1566+ const Sci::Line linesBeingWrapped = lineToWrapEnd - lineToWrap;
1567+ ElapsedPeriod epWrapping;
15581568 while (lineToWrap < lineToWrapEnd) {
15591569 if (WrapOneLine(surface, lineToWrap)) {
15601570 wrapOccurred = true;
@@ -1562,6 +1572,7 @@
15621572 wrapPending.Wrapped(lineToWrap);
15631573 lineToWrap++;
15641574 }
1575+ durationWrapOneLine.AddSample(linesBeingWrapped, epWrapping.Duration());
15651576
15661577 goodTopLine = pcs->DisplayFromDoc(lineDocTop) + std::min(
15671578 subLineTop, static_cast<Sci::Line>(pcs->GetHeight(lineDocTop)-1));
@@ -2678,9 +2689,11 @@
26782689
26792690 // If client wants to see this modification
26802691 if (mh.modificationType & modEventMask) {
2681- if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
2682- // Real modification made to text of document.
2683- NotifyChange(); // Send EN_CHANGE
2692+ if (commandEvents) {
2693+ if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
2694+ // Real modification made to text of document.
2695+ NotifyChange(); // Send EN_CHANGE
2696+ }
26842697 }
26852698
26862699 SCNotification scn = {};
@@ -4159,9 +4172,7 @@
41594172 if (start < end) {
41604173 const Sci::Position len = end - start;
41614174 std::string ret(len, '\0');
4162- for (int i = 0; i < len; i++) {
4163- ret[i] = pdoc->CharAt(start + i);
4164- }
4175+ pdoc->GetCharRange(ret.data(), start, len);
41654176 return ret;
41664177 }
41674178 return std::string();
@@ -5055,7 +5066,8 @@
50555066 // When scrolling, allow less time to ensure responsive
50565067 const double secondsAllowed = scrolling ? 0.005 : 0.02;
50575068
5058- const Sci::Line linesToStyle = std::clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
5069+ const Sci::Line linesToStyle = std::clamp(
5070+ static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine.Duration()),
50595071 10, 0x10000);
50605072 const Sci::Line stylingMaxLine = std::min(
50615073 pdoc->SciLineFromPosition(pdoc->GetEndStyled()) + linesToStyle,
@@ -5767,7 +5779,7 @@
57675779 if (wParam == 0)
57685780 return 0;
57695781 char *ptr = CharPtrFromSPtr(lParam);
5770- unsigned int iChar = 0;
5782+ size_t iChar = 0;
57715783 for (; iChar < wParam - 1; iChar++)
57725784 ptr[iChar] = pdoc->CharAt(iChar);
57735785 ptr[iChar] = '\0';
@@ -5901,7 +5913,7 @@
59015913 return selectedText.LengthWithTerminator();
59025914 } else {
59035915 char *ptr = CharPtrFromSPtr(lParam);
5904- unsigned int iChar = 0;
5916+ size_t iChar = 0;
59055917 if (selectedText.Length()) {
59065918 for (; iChar < selectedText.LengthWithTerminator(); iChar++)
59075919 ptr[iChar] = selectedText.Data()[iChar];
@@ -7654,6 +7666,13 @@
76547666 case SCI_GETMODEVENTMASK:
76557667 return modEventMask;
76567668
7669+ case SCI_SETCOMMANDEVENTS:
7670+ commandEvents = static_cast<bool>(wParam);
7671+ return 0;
7672+
7673+ case SCI_GETCOMMANDEVENTS:
7674+ return commandEvents;
7675+
76577676 case SCI_CONVERTEOLS:
76587677 pdoc->ConvertLineEnds(static_cast<int>(wParam));
76597678 SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
--- trunk/ext/scintilla/src/Editor.h (revision 28492)
+++ trunk/ext/scintilla/src/Editor.h (revision 28493)
@@ -229,6 +229,7 @@
229229 bool needIdleStyling;
230230
231231 int modEventMask;
232+ bool commandEvents;
232233
233234 SelectionText drag;
234235
@@ -249,6 +250,7 @@
249250
250251 // Wrapping support
251252 WrapPending wrapPending;
253+ ActionDuration durationWrapOneLine;
252254
253255 bool convertPastes;
254256
@@ -594,7 +596,6 @@
594596 static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len);
595597
596598 public:
597- virtual void NotifyParent(SCNotification * scn) = 0;
598599 // Public so the COM thunks can access it.
599600 bool IsUnicodeMode() const;
600601 // Public so scintilla_send_message can use it.
--- trunk/ext/scintilla/src/ExternalLexer.cxx (revision 28492)
+++ trunk/ext/scintilla/src/ExternalLexer.cxx (revision 28493)
@@ -65,7 +65,7 @@
6565 // Assign a buffer for the lexer name.
6666 char lexname[100] = "";
6767 GetLexerName(i, lexname, sizeof(lexname));
68- ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL);
68+ ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, nullptr, lexname, nullptr);
6969 // This is storing a second reference to lex in the Catalogue as well as in modules.
7070 // TODO: Should use std::shared_ptr or similar to ensure allocation safety.
7171 Catalogue::AddLexerModule(lex);
--- trunk/ext/scintilla/src/Indicator.cxx (revision 28492)
+++ trunk/ext/scintilla/src/Indicator.cxx (revision 28493)
@@ -60,7 +60,7 @@
6060 const PRectangle rcSquiggle = PixelGridAlign(rc);
6161
6262 const int width = std::min(4000, static_cast<int>(rcSquiggle.Width()));
63- RGBAImage image(width, 3, 1.0, 0);
63+ RGBAImage image(width, 3, 1.0, nullptr);
6464 enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f };
6565 for (int x = 0; x < width; x++) {
6666 if (x%2) {
@@ -165,7 +165,7 @@
165165 IntegerRectangle ircBox(rcBox);
166166 // Cap width at 4000 to avoid large allocations when mistakes made
167167 const int width = std::min(ircBox.Width(), 4000);
168- RGBAImage image(width, ircBox.Height(), 1.0, 0);
168+ RGBAImage image(width, ircBox.Height(), 1.0, nullptr);
169169 // Draw horizontal lines top and bottom
170170 for (int x=0; x<width; x++) {
171171 for (int y = 0; y<ircBox.Height(); y += ircBox.Height() - 1) {
--- trunk/ext/scintilla/src/PerLine.cxx (revision 28492)
+++ trunk/ext/scintilla/src/PerLine.cxx (revision 28493)
@@ -350,7 +350,7 @@
350350 if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
351351 return annotations[line].get()+sizeof(AnnotationHeader);
352352 else
353- return 0;
353+ return nullptr;
354354 }
355355
356356 const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
@@ -357,7 +357,7 @@
357357 if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line] && MultipleStyles(line))
358358 return reinterpret_cast<unsigned char *>(annotations[line].get() + sizeof(AnnotationHeader) + Length(line));
359359 else
360- return 0;
360+ return nullptr;
361361 }
362362
363363 static std::unique_ptr<char[]>AllocateAnnotation(int length, int style) {
--- trunk/ext/scintilla/src/PositionCache.cxx (revision 28492)
+++ trunk/ext/scintilla/src/PositionCache.cxx (revision 28493)
@@ -683,7 +683,7 @@
683683 }
684684
685685 void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
686- unsigned int len_, XYPOSITION *positions_, unsigned int clock_) {
686+ unsigned int len_, const XYPOSITION *positions_, unsigned int clock_) {
687687 Clear();
688688 styleNumber = styleNumber_;
689689 len = len_;
--- trunk/ext/scintilla/src/PositionCache.h (revision 28492)
+++ trunk/ext/scintilla/src/PositionCache.h (revision 28493)
@@ -192,7 +192,7 @@
192192 void operator=(const PositionCacheEntry &) = delete;
193193 void operator=(PositionCacheEntry &&) = delete;
194194 ~PositionCacheEntry();
195- void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock_);
195+ void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, const XYPOSITION *positions_, unsigned int clock_);
196196 void Clear();
197197 bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
198198 static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_);
--- trunk/ext/scintilla/src/RESearch.cxx (revision 28492)
+++ trunk/ext/scintilla/src/RESearch.cxx (revision 28493)
@@ -445,7 +445,7 @@
445445
446446 if (!pattern || !length) {
447447 if (sta)
448- return 0;
448+ return nullptr;
449449 else
450450 return badpat("No previous regular expression");
451451 }
@@ -727,7 +727,7 @@
727727 return badpat((posix ? "Unmatched (" : "Unmatched \\("));
728728 *mp = END;
729729 sta = OKP;
730- return 0;
730+ return nullptr;
731731 }
732732
733733 /*
--- trunk/ext/scintilla/src/RunStyles.cxx (revision 28492)
+++ trunk/ext/scintilla/src/RunStyles.cxx (revision 28493)
@@ -250,7 +250,7 @@
250250
251251 template <typename DISTANCE, typename STYLE>
252252 bool RunStyles<DISTANCE, STYLE>::AllSame() const noexcept {
253- for (int run = 1; run < starts->Partitions(); run++) {
253+ for (DISTANCE run = 1; run < starts->Partitions(); run++) {
254254 if (styles->ValueAt(run) != styles->ValueAt(run - 1))
255255 return false;
256256 }
@@ -300,7 +300,7 @@
300300 if (styles->ValueAt(styles->Length()-1) != 0) {
301301 throw std::runtime_error("RunStyles: Unused style at end changed.");
302302 }
303- for (int j=1; j<styles->Length()-1; j++) {
303+ for (ptrdiff_t j=1; j<styles->Length()-1; j++) {
304304 if (styles->ValueAt(j) == styles->ValueAt(j-1)) {
305305 throw std::runtime_error("RunStyles: Style of a partition same as previous.");
306306 }
--- trunk/ext/scintilla/src/ScintillaBase.cxx (revision 28492)
+++ trunk/ext/scintilla/src/ScintillaBase.cxx (revision 28493)
@@ -443,12 +443,12 @@
443443 const int item = ac.GetSelection();
444444 if (item != -1) {
445445 const std::string selected = ac.GetValue(item);
446- if (buffer != NULL)
446+ if (buffer)
447447 memcpy(buffer, selected.c_str(), selected.length()+1);
448448 return static_cast<int>(selected.length());
449449 }
450450 }
451- if (buffer != NULL)
451+ if (buffer)
452452 *buffer = '\0';
453453 return 0;
454454 }
@@ -593,7 +593,7 @@
593593 }
594594
595595 LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) {
596- lexCurrent = 0;
596+ lexCurrent = nullptr;
597597 performingStyle = false;
598598 interfaceVersion = lvRelease4;
599599 lexLanguage = SCLEX_CONTAINER;
@@ -602,7 +602,7 @@
602602 LexState::~LexState() {
603603 if (instance) {
604604 instance->Release();
605- instance = 0;
605+ instance = nullptr;
606606 }
607607 }
608608
@@ -617,7 +617,7 @@
617617 if (lex != lexCurrent) {
618618 if (instance) {
619619 instance->Release();
620- instance = 0;
620+ instance = nullptr;
621621 }
622622 interfaceVersion = lvRelease4;
623623 lexCurrent = lex;
@@ -632,7 +632,7 @@
632632 void LexState::SetLexer(uptr_t wParam) {
633633 lexLanguage = static_cast<int>(wParam);
634634 if (lexLanguage == SCLEX_CONTAINER) {
635- SetLexerModule(0);
635+ SetLexerModule(nullptr);
636636 } else {
637637 const LexerModule *lex = Catalogue::Find(lexLanguage);
638638 if (!lex)
@@ -654,7 +654,7 @@
654654 if (instance) {
655655 return instance->DescribeWordListSets();
656656 } else {
657- return 0;
657+ return nullptr;
658658 }
659659 }
660660
@@ -675,7 +675,7 @@
675675 if (pdoc && instance) {
676676 return instance->PrivateCall(operation, pointer);
677677 } else {
678- return 0;
678+ return nullptr;
679679 }
680680 }
681681
@@ -683,7 +683,7 @@
683683 if (instance) {
684684 return instance->PropertyNames();
685685 } else {
686- return 0;
686+ return nullptr;
687687 }
688688 }
689689
@@ -699,7 +699,7 @@
699699 if (instance) {
700700 return instance->DescribeProperty(name);
701701 } else {
702- return 0;
702+ return nullptr;
703703 }
704704 }
705705
@@ -806,7 +806,7 @@
806806 if (instance) {
807807 return instance->NameOfStyle(style);
808808 } else {
809- return 0;
809+ return nullptr;
810810 }
811811 }
812812
@@ -814,7 +814,7 @@
814814 if (instance) {
815815 return instance->TagsOfStyle(style);
816816 } else {
817- return 0;
817+ return nullptr;
818818 }
819819 }
820820
@@ -822,7 +822,7 @@
822822 if (instance) {
823823 return instance->DescriptionOfStyle(style);
824824 } else {
825- return 0;
825+ return nullptr;
826826 }
827827 }
828828
--- trunk/ext/scintilla/src/Style.cxx (revision 28492)
+++ trunk/ext/scintilla/src/Style.cxx (revision 28493)
@@ -77,13 +77,13 @@
7777
7878 Style::Style() : FontSpecification() {
7979 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
80- Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
80+ Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, nullptr, SC_CHARSET_DEFAULT,
8181 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
8282 }
8383
8484 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
8585 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
86- 0, 0, 0,
86+ 0, nullptr, 0,
8787 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
8888 fore = source.fore;
8989 back = source.back;
@@ -107,7 +107,7 @@
107107 if (this == &source)
108108 return * this;
109109 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
110- 0, 0, SC_CHARSET_DEFAULT,
110+ 0, nullptr, SC_CHARSET_DEFAULT,
111111 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
112112 fore = source.fore;
113113 back = source.back;
--- trunk/ext/scintilla/src/ViewStyle.cxx (revision 28492)
+++ trunk/ext/scintilla/src/ViewStyle.cxx (revision 28493)
@@ -404,7 +404,7 @@
404404
405405 void ViewStyle::ClearStyles() {
406406 // Reset all styles to be like the default style
407- for (unsigned int i=0; i<styles.size(); i++) {
407+ for (size_t i=0; i<styles.size(); i++) {
408408 if (i != STYLE_DEFAULT) {
409409 styles[i].ClearTo(styles[STYLE_DEFAULT]);
410410 }
@@ -601,7 +601,7 @@
601601 // Should always reach here since map was just set for all styles
602602 return it->second.get();
603603 }
604- return 0;
604+ return nullptr;
605605 }
606606
607607 void ViewStyle::FindMaxAscentDescent() {
--- trunk/ext/scintilla/version.txt (revision 28492)
+++ trunk/ext/scintilla/version.txt (revision 28493)
@@ -1 +1 @@
1-412
1+413
--- trunk/ext/scintilla/win32/PlatWin.cxx (revision 28492)
+++ trunk/ext/scintilla/win32/PlatWin.cxx (revision 28493)
@@ -75,8 +75,8 @@
7575 IDWriteRenderingParams *defaultRenderingParams = nullptr;
7676 IDWriteRenderingParams *customClearTypeRenderingParams = nullptr;
7777
78-static HMODULE hDLLD2D = NULL;
79-static HMODULE hDLLDWrite = NULL;
78+static HMODULE hDLLD2D {};
79+static HMODULE hDLLDWrite {};
8080
8181 bool LoadD2D() {
8282 static bool triedLoadingD2D = false;
@@ -156,7 +156,7 @@
156156 FormatAndMetrics(HFONT hfont_, int extraFontFlag_, int characterSet_) :
157157 technology(SCWIN_TECH_GDI), hfont(hfont_),
158158 #if defined(USE_D2D)
159- pTextFormat(0),
159+ pTextFormat(nullptr),
160160 #endif
161161 extraFontFlag(extraFontFlag_), characterSet(characterSet_), yAscent(2), yDescent(1), yInternalLeading(0) {
162162 }
@@ -168,7 +168,7 @@
168168 FLOAT yDescent_,
169169 FLOAT yInternalLeading_) :
170170 technology(SCWIN_TECH_DIRECTWRITE),
171- hfont(0),
171+ hfont{},
172172 pTextFormat(pTextFormat_),
173173 extraFontFlag(extraFontFlag_),
174174 characterSet(characterSet_),
@@ -238,9 +238,9 @@
238238 }
239239
240240 CRITICAL_SECTION crPlatformLock;
241-HINSTANCE hinstPlatformRes = 0;
241+HINSTANCE hinstPlatformRes {};
242242
243-HCURSOR reverseArrowCursor = NULL;
243+HCURSOR reverseArrowCursor {};
244244
245245 FormatAndMetrics *FamFromFontID(void *fid) {
246246 return static_cast<FormatAndMetrics *>(fid);
@@ -332,7 +332,7 @@
332332 FontCached *FontCached::first = nullptr;
333333
334334 FontCached::FontCached(const FontParameters &fp) :
335- next(0), usage(0), size(1.0), hash(0) {
335+ next(nullptr), usage(0), size(1.0), hash(0) {
336336 SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic, fp.extraFontFlag);
337337 technology = fp.technology;
338338 hash = HashFont(fp);
@@ -407,7 +407,7 @@
407407 }
408408
409409 FontID FontCached::FindOrCreate(const FontParameters &fp) {
410- FontID ret = 0;
410+ FontID ret {};
411411 ::EnterCriticalSection(&crPlatformLock);
412412 const int hashFind = HashFont(fp);
413413 for (FontCached *cur=first; cur; cur=cur->next) {
@@ -446,7 +446,7 @@
446446 ::LeaveCriticalSection(&crPlatformLock);
447447 }
448448
449-Font::Font() noexcept : fid(0) {
449+Font::Font() noexcept : fid{} {
450450 }
451451
452452 Font::~Font() {
@@ -513,21 +513,22 @@
513513 typedef VarBuffer<XYPOSITION, stackBufferLength> TextPositions;
514514
515515 class SurfaceGDI : public Surface {
516- bool unicodeMode;
517- HDC hdc;
518- bool hdcOwned;
519- HPEN pen;
520- HPEN penOld;
521- HBRUSH brush;
522- HBRUSH brushOld;
523- HFONT font;
524- HFONT fontOld;
525- HBITMAP bitmap;
526- HBITMAP bitmapOld;
527- int maxWidthMeasure;
528- int maxLenText;
516+ bool unicodeMode=false;
517+ HDC hdc{};
518+ bool hdcOwned=false;
519+ HPEN pen{};
520+ HPEN penOld{};
521+ HBRUSH brush{};
522+ HBRUSH brushOld{};
523+ HFONT font{};
524+ HFONT fontOld{};
525+ HBITMAP bitmap{};
526+ HBITMAP bitmapOld{};
527+ int maxWidthMeasure = INT_MAX;
528+ // There appears to be a 16 bit string length limit in GDI on NT.
529+ int maxLenText = 65535;
529530
530- int codePage;
531+ int codePage = 0;
531532
532533 void BrushColor(ColourDesired back);
533534 void SetFont(Font &font_);
@@ -588,18 +589,7 @@
588589 void SetBidiR2L(bool bidiR2L_) override;
589590 };
590591
591-SurfaceGDI::SurfaceGDI() :
592- unicodeMode(false),
593- hdc(0), hdcOwned(false),
594- pen(0), penOld(0),
595- brush(0), brushOld(0),
596- font(0), fontOld(0),
597- bitmap(0), bitmapOld(0) {
598- maxWidthMeasure = INT_MAX;
599- // There appears to be a 16 bit string length limit in GDI on NT.
600- maxLenText = 65535;
601-
602- codePage = 0;
592+SurfaceGDI::SurfaceGDI() {
603593 }
604594
605595 SurfaceGDI::~SurfaceGDI() {
@@ -1118,7 +1108,7 @@
11181108 SurfaceD2D(SurfaceD2D &&) = delete;
11191109 SurfaceD2D &operator=(const SurfaceD2D &) = delete;
11201110 SurfaceD2D &operator=(SurfaceD2D &&) = delete;
1121- virtual ~SurfaceD2D() override;
1111+ ~SurfaceD2D() override;
11221112
11231113 void SetScale();
11241114 void Init(WindowID wid) override;
@@ -1228,7 +1218,7 @@
12281218 }
12291219
12301220 bool SurfaceD2D::Initialised() {
1231- return pRenderTarget != 0;
1221+ return pRenderTarget != nullptr;
12321222 }
12331223
12341224 HRESULT SurfaceD2D::FlushDrawing() {
@@ -1277,9 +1267,9 @@
12771267 void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) {
12781268 if (pRenderTarget) {
12791269 D2D_COLOR_F col;
1280- col.r = (fore.AsInteger() & 0xff) / 255.0f;
1281- col.g = ((fore.AsInteger() & 0xff00) >> 8) / 255.0f;
1282- col.b = (fore.AsInteger() >> 16) / 255.0f;
1270+ col.r = fore.GetRedComponent();
1271+ col.g = fore.GetGreenComponent();
1272+ col.b = fore.GetBlueComponent();
12831273 col.a = alpha / 255.0f;
12841274 if (pBrush) {
12851275 pBrush->SetColor(col);
@@ -1374,7 +1364,7 @@
13741364 if (pRenderTarget) {
13751365 ID2D1Factory *pFactory = nullptr;
13761366 pRenderTarget->GetFactory(&pFactory);
1377- ID2D1PathGeometry *geometry=0;
1367+ ID2D1PathGeometry *geometry=nullptr;
13781368 HRESULT hr = pFactory->CreatePathGeometry(&geometry);
13791369 if (SUCCEEDED(hr)) {
13801370 ID2D1GeometrySink *sink = nullptr;
@@ -2526,7 +2516,7 @@
25262516 static const Point ImageInset; // Padding around image
25272517
25282518 public:
2529- ListBoxX() : lineHeight(10), fontCopy(0), technology(0), lb(0), unicodeMode(false),
2519+ ListBoxX() : lineHeight(10), fontCopy{}, technology(0), lb{}, unicodeMode(false),
25302520 desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8),
25312521 parent(nullptr), ctrlID(0),
25322522 delegate(nullptr),
@@ -3334,7 +3324,7 @@
33343324
33353325 }
33363326
3337-Menu::Menu() noexcept : mid(0) {
3327+Menu::Menu() noexcept : mid{} {
33383328 }
33393329
33403330 void Menu::CreatePopUp() {
--- trunk/ext/scintilla/win32/ScintillaWin.cxx (revision 28492)
+++ trunk/ext/scintilla/win32/ScintillaWin.cxx (revision 28493)
@@ -358,7 +358,6 @@
358358 void SetCtrlID(int identifier) override;
359359 int GetCtrlID() override;
360360 void NotifyParent(SCNotification scn) override;
361- virtual void NotifyParent(SCNotification * scn);
362361 void NotifyDoubleClick(Point pt, int modifiers) override;
363362 CaseFolder *CaseFolderForEncoding() override;
364363 std::string CaseMapString(const std::string &s, int caseMapping) override;
@@ -430,7 +429,7 @@
430429 int sysCaretHeight;
431430 };
432431
433-HINSTANCE ScintillaWin::hInstance = 0;
432+HINSTANCE ScintillaWin::hInstance {};
434433 ATOM ScintillaWin::scintillaClassAtom = 0;
435434 ATOM ScintillaWin::callClassAtom = 0;
436435
@@ -475,7 +474,7 @@
475474 sysCaretHeight = 0;
476475
477476 #if defined(USE_D2D)
478- pRenderTarget = 0;
477+ pRenderTarget = nullptr;
479478 renderTargetValid = true;
480479 #endif
481480
@@ -605,7 +604,7 @@
605604 void ScintillaWin::DropRenderTarget() {
606605 if (pRenderTarget) {
607606 pRenderTarget->Release();
608- pRenderTarget = 0;
607+ pRenderTarget = nullptr;
609608 }
610609 }
611610
@@ -1682,7 +1681,7 @@
16821681 if (lParam) {
16831682 *reinterpret_cast<int *>(lParam) = static_cast<int>(SelectionEnd().Position());
16841683 }
1685- return MAKELONG(SelectionStart().Position(), SelectionEnd().Position());
1684+ return MAKELRESULT(SelectionStart().Position(), SelectionEnd().Position());
16861685
16871686 case EM_EXGETSEL: {
16881687 if (lParam == 0) {
@@ -1997,14 +1996,16 @@
19971996
19981997 void ScintillaWin::NotifyChange() {
19991998 ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
2000- MAKELONG(GetCtrlID(), SCEN_CHANGE),
1999+ MAKEWPARAM(GetCtrlID(), SCEN_CHANGE),
20012000 reinterpret_cast<LPARAM>(MainHWND()));
20022001 }
20032002
20042003 void ScintillaWin::NotifyFocus(bool focus) {
2005- ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
2006- MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
2007- reinterpret_cast<LPARAM>(MainHWND()));
2004+ if (commandEvents) {
2005+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
2006+ MAKEWPARAM(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
2007+ reinterpret_cast<LPARAM>(MainHWND()));
2008+ }
20082009 Editor::NotifyFocus(focus);
20092010 }
20102011
@@ -2023,13 +2024,6 @@
20232024 GetCtrlID(), reinterpret_cast<LPARAM>(&scn));
20242025 }
20252026
2026-void ScintillaWin::NotifyParent(SCNotification * scn) {
2027- scn->nmhdr.hwndFrom = MainHWND();
2028- scn->nmhdr.idFrom = GetCtrlID();
2029- ::SendMessage(::GetParent(MainHWND()), WM_NOTIFY,
2030- GetCtrlID(), reinterpret_cast<LPARAM>(scn));
2031-}
2032-
20332027 void ScintillaWin::NotifyDoubleClick(Point pt, int modifiers) {
20342028 //Platform::DebugPrintf("ScintillaWin Double click 0\n");
20352029 ScintillaBase::NotifyDoubleClick(pt, modifiers);
@@ -2191,12 +2185,12 @@
21912185 namespace {
21922186
21932187 class GlobalMemory {
2194- HGLOBAL hand;
2188+ HGLOBAL hand {};
21952189 public:
2196- void *ptr;
2197- GlobalMemory() : hand(0), ptr(0) {
2190+ void *ptr {};
2191+ GlobalMemory() {
21982192 }
2199- explicit GlobalMemory(HGLOBAL hand_) : hand(hand_), ptr(0) {
2193+ explicit GlobalMemory(HGLOBAL hand_) : hand(hand_) {
22002194 if (hand) {
22012195 ptr = ::GlobalLock(hand);
22022196 }
@@ -2229,7 +2223,7 @@
22292223 ::SetClipboardData(uFormat, Unlock());
22302224 }
22312225 operator bool() const {
2232- return ptr != 0;
2226+ return ptr != nullptr;
22332227 }
22342228 SIZE_T Size() {
22352229 return ::GlobalSize(hand);
@@ -2476,7 +2470,7 @@
24762470
24772471 DropSource::DropSource() {
24782472 vtbl = vtDropSource;
2479- sci = 0;
2473+ sci = nullptr;
24802474 }
24812475
24822476 /// Implement IUnkown
@@ -2602,7 +2596,7 @@
26022596
26032597 DataObject::DataObject() {
26042598 vtbl = vtDataObject;
2605- sci = 0;
2599+ sci = nullptr;
26062600 }
26072601
26082602 /// Implement IUnknown
@@ -2665,7 +2659,7 @@
26652659
26662660 DropTarget::DropTarget() {
26672661 vtbl = vtDropTarget;
2668- sci = 0;
2662+ sci = nullptr;
26692663 }
26702664
26712665 /**
@@ -3322,7 +3316,7 @@
33223316 ScintillaWin *sciThis = static_cast<ScintillaWin *>(PointerFromWindow(hWnd));
33233317 try {
33243318 // ctp will be zero if WM_CREATE not seen yet
3325- if (sciThis == 0) {
3319+ if (sciThis == nullptr) {
33263320 if (iMessage == WM_CREATE) {
33273321 // Associate CallTip object with window
33283322 CREATESTRUCT *pCreate = static_cast<CREATESTRUCT *>(PtrFromSPtr(lParam));
@@ -3436,7 +3430,7 @@
34363430 // Find C++ object associated with window.
34373431 ScintillaWin *sci = static_cast<ScintillaWin *>(PointerFromWindow(hWnd));
34383432 // sci will be zero if WM_CREATE not seen yet
3439- if (sci == 0) {
3433+ if (sci == nullptr) {
34403434 try {
34413435 if (iMessage == WM_CREATE) {
34423436 // Create C++ object associated with window
Show on old repository browser