aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scintilla_backports/6419_8760026bba6a.patch142
-rw-r--r--src/scintilla_backports/6421_fd2f856b8d58.patch68
-rw-r--r--src/scintilla_backports/6425_73343682cbda.patch168
-rw-r--r--src/scintilla_backports/6434_ed27432729c3.patch50
-rw-r--r--src/scintilla_backports/6436_a366ce1a811e.patch110
-rw-r--r--src/scintilla_backports/6441_92c8f0f1b3e6.patch157
-rw-r--r--src/scintilla_backports/6442_3e3bfe29a819.patch319
-rw-r--r--src/scintilla_backports/6444_1bd57324aa36.patch279
-rw-r--r--src/scintilla_backports/6445_89d992f380a1.patch418
-rw-r--r--src/scintilla_backports/6448_431b814a54a6.patch307
-rw-r--r--src/scintilla_backports/6449_1280ef150bbb.patch42
11 files changed, 2060 insertions, 0 deletions
diff --git a/src/scintilla_backports/6419_8760026bba6a.patch b/src/scintilla_backports/6419_8760026bba6a.patch
new file mode 100644
index 00000000..a477a80e
--- /dev/null
+++ b/src/scintilla_backports/6419_8760026bba6a.patch
@@ -0,0 +1,142 @@
+# HG changeset patch
+# User Neil Hodgson <nyamatongwe@gmail.com>
+# Date 1511240678 -39600
+# Node ID 8760026bba6ab6a5c6ee3d2d7bd7a291ecb74574
+# Parent 85205da6ec1b8eeb14c3edc94064fb0d8f685377
+Update marshalling of signals from Scintilla, changing deprecated NONE to VOID.
+Has no effect on clients as NONE was an alias for VOID.
+
+diff -r 85205da6ec1b -r 8760026bba6a gtk/scintilla-marshal.c
+--- a/gtk/scintilla-marshal.c Mon Nov 20 12:24:51 2017 +1100
++++ b/gtk/scintilla-marshal.c Tue Nov 21 16:04:38 2017 +1100
+@@ -1,6 +1,4 @@
+-
+-#include <glib-object.h>
+-
++#include <glib-object.h>
+
+ #ifdef G_ENABLE_DEBUG
+ #define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+@@ -48,8 +46,7 @@
+ #define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
+ #endif /* !G_ENABLE_DEBUG */
+
+-
+-/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
++/* VOID:INT,OBJECT (scintilla-marshal.list:1) */
+ void
+ scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+@@ -58,13 +55,13 @@
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+ {
+- typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1,
+- gint arg_1,
+- gpointer arg_2,
+- gpointer data2);
++ typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1,
++ gint arg1,
++ gpointer arg2,
++ gpointer data2);
++ GCClosure *cc = (GCClosure *) closure;
++ gpointer data1, data2;
+ GMarshalFunc_VOID__INT_OBJECT callback;
+- GCClosure *cc = (GCClosure*) closure;
+- gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+@@ -86,7 +83,7 @@
+ data2);
+ }
+
+-/* NONE:INT,BOXED (scintilla-marshal.list:2) */
++/* VOID:INT,BOXED (scintilla-marshal.list:2) */
+ void
+ scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+@@ -95,13 +92,13 @@
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+ {
+- typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
+- gint arg_1,
+- gpointer arg_2,
+- gpointer data2);
++ typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
++ gint arg1,
++ gpointer arg2,
++ gpointer data2);
++ GCClosure *cc = (GCClosure *) closure;
++ gpointer data1, data2;
+ GMarshalFunc_VOID__INT_BOXED callback;
+- GCClosure *cc = (GCClosure*) closure;
+- gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+diff -r 85205da6ec1b -r 8760026bba6a gtk/scintilla-marshal.h
+--- a/gtk/scintilla-marshal.h Mon Nov 20 12:24:51 2017 +1100
++++ b/gtk/scintilla-marshal.h Tue Nov 21 16:04:38 2017 +1100
+@@ -1,30 +1,30 @@
++/* This file is generated, all changes will be lost */
++#ifndef __SCINTILLA_MARSHAL_MARSHAL_H__
++#define __SCINTILLA_MARSHAL_MARSHAL_H__
+
+-#ifndef __scintilla_marshal_MARSHAL_H__
+-#define __scintilla_marshal_MARSHAL_H__
+-
+-#include <glib-object.h>
++#include <glib-object.h>
+
+ G_BEGIN_DECLS
+
+-/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
+-extern void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
+- GValue *return_value,
+- guint n_param_values,
+- const GValue *param_values,
+- gpointer invocation_hint,
+- gpointer marshal_data);
+-#define scintilla_marshal_NONE__INT_OBJECT scintilla_marshal_VOID__INT_OBJECT
++/* VOID:INT,OBJECT (scintilla-marshal.list:1) */
++extern
++void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
++ GValue *return_value,
++ guint n_param_values,
++ const GValue *param_values,
++ gpointer invocation_hint,
++ gpointer marshal_data);
+
+-/* NONE:INT,BOXED (scintilla-marshal.list:2) */
+-extern void scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
+- GValue *return_value,
+- guint n_param_values,
+- const GValue *param_values,
+- gpointer invocation_hint,
+- gpointer marshal_data);
+-#define scintilla_marshal_NONE__INT_BOXED scintilla_marshal_VOID__INT_BOXED
++/* VOID:INT,BOXED (scintilla-marshal.list:2) */
++extern
++void scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
++ GValue *return_value,
++ guint n_param_values,
++ const GValue *param_values,
++ gpointer invocation_hint,
++ gpointer marshal_data);
++
+
+ G_END_DECLS
+
+-#endif /* __scintilla_marshal_MARSHAL_H__ */
+-
++#endif /* __SCINTILLA_MARSHAL_MARSHAL_H__ */
+diff -r 85205da6ec1b -r 8760026bba6a gtk/scintilla-marshal.list
+--- a/gtk/scintilla-marshal.list Mon Nov 20 12:24:51 2017 +1100
++++ b/gtk/scintilla-marshal.list Tue Nov 21 16:04:38 2017 +1100
+@@ -1,2 +1,2 @@
+-NONE:INT,OBJECT
+-NONE:INT,BOXED
++VOID:INT,OBJECT
++VOID:INT,BOXED
diff --git a/src/scintilla_backports/6421_fd2f856b8d58.patch b/src/scintilla_backports/6421_fd2f856b8d58.patch
new file mode 100644
index 00000000..9e354864
--- /dev/null
+++ b/src/scintilla_backports/6421_fd2f856b8d58.patch
@@ -0,0 +1,68 @@
+# HG changeset patch
+# User Greg Smith
+# Date 1513111541 -39600
+# Node ID fd2f856b8d582df2e3e60073721a84b9f464a72b
+# Parent 2286dd5fa6259c67cc8ce0d4c39b1c2e6f85ff1f
+Use explicit typedefs instead of deprecated derivation from std::iterator.
+This fixes a C4996 / STL4015 warning from Visual C++ 2017.5 that the
+std::iterator class template is deprecated in C++17.
+
+diff -r 2286dd5fa625 -r fd2f856b8d58 src/Document.cxx
+--- a/src/Document.cxx Tue Nov 21 16:16:25 2017 +1100
++++ b/src/Document.cxx Wed Dec 13 07:45:41 2017 +1100
+@@ -2600,8 +2600,14 @@
+
+ #ifndef NO_CXX11_REGEX
+
+-class ByteIterator : public std::iterator<std::bidirectional_iterator_tag, char> {
++class ByteIterator {
+ public:
++ typedef std::bidirectional_iterator_tag iterator_category;
++ typedef char value_type;
++ typedef ptrdiff_t difference_type;
++ typedef char* pointer;
++ typedef char& reference;
++
+ const Document *doc;
+ Sci::Position position;
+ ByteIterator(const Document *doc_ = 0, Sci::Position position_ = 0) : doc(doc_), position(position_) {
+@@ -2663,7 +2669,7 @@
+
+ // On Windows, report non-BMP characters as 2 separate surrogates as that
+ // matches wregex since it is based on wchar_t.
+-class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar_t> {
++class UTF8Iterator {
+ // These 3 fields determine the iterator position and are used for comparisons
+ const Document *doc;
+ Sci::Position position;
+@@ -2673,6 +2679,12 @@
+ size_t lenCharacters;
+ wchar_t buffered[2];
+ public:
++ typedef std::bidirectional_iterator_tag iterator_category;
++ typedef wchar_t value_type;
++ typedef ptrdiff_t difference_type;
++ typedef wchar_t* pointer;
++ typedef wchar_t& reference;
++
+ UTF8Iterator(const Document *doc_ = 0, Sci::Position position_ = 0) :
+ doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) {
+ buffered[0] = 0;
+@@ -2775,10 +2787,16 @@
+
+ // On Unix, report non-BMP characters as single characters
+
+-class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar_t> {
++class UTF8Iterator {
+ const Document *doc;
+ Sci::Position position;
+ public:
++ typedef std::bidirectional_iterator_tag iterator_category;
++ typedef wchar_t value_type;
++ typedef ptrdiff_t difference_type;
++ typedef wchar_t* pointer;
++ typedef wchar_t& reference;
++
+ UTF8Iterator(const Document *doc_=0, Sci::Position position_=0) : doc(doc_), position(position_) {
+ }
+ UTF8Iterator(const UTF8Iterator &other) NOEXCEPT {
diff --git a/src/scintilla_backports/6425_73343682cbda.patch b/src/scintilla_backports/6425_73343682cbda.patch
new file mode 100644
index 00000000..80225666
--- /dev/null
+++ b/src/scintilla_backports/6425_73343682cbda.patch
@@ -0,0 +1,168 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1513656040 -39600
+# Node ID 73343682cbda0937c5427ee45ea6c9104d97ac1e
+# Parent 5246ca55cf2443dbd6d37bc6dfede6d5f3a14a36
+Start of bidirectional code - implement SCI_SETBIDIRECTIONAL.
+
+diff -r 5246ca55cf24 -r 73343682cbda doc/ScintillaDoc.html
+--- a/doc/ScintillaDoc.html Wed Jan 10 10:04:03 2018 +1100
++++ b/doc/ScintillaDoc.html Tue Dec 19 15:00:40 2017 +1100
+@@ -119,7 +119,7 @@
+
+ <h1>Scintilla Documentation</h1>
+
+- <p>Last edited 11 August 2017 NH</p>
++ <p>Last edited 10 January 2018 NH</p>
+
+ <p>There is <a class="jump" href="Design.html">an overview of the internal design of
+ Scintilla</a>.<br />
+@@ -3594,6 +3594,10 @@
+ <a class="message" href="#SCI_GETCODEPAGE">SCI_GETCODEPAGE &rarr; int</a><br />
+ <a class="message" href="#SCI_SETIMEINTERACTION">SCI_SETIMEINTERACTION(int imeInteraction)</a><br />
+ <a class="message" href="#SCI_GETIMEINTERACTION">SCI_GETIMEINTERACTION &rarr; int</a><br />
++<div class="provisional">
++ <a class="message" href="#SCI_SETBIDIRECTIONAL"><span class="provisional">SCI_SETBIDIRECTIONAL(int bidirectional)</span></a><br />
++ <a class="message" href="#SCI_GETBIDIRECTIONAL">SCI_GETBIDIRECTIONAL &rarr; int</a><br />
++</div>
+ <a class="message" href="#SCI_GRABFOCUS">SCI_GRABFOCUS</a><br />
+ <a class="message" href="#SCI_SETFOCUS">SCI_SETFOCUS(bool focus)</a><br />
+ <a class="message" href="#SCI_GETFOCUS">SCI_GETFOCUS &rarr; bool</a><br />
+@@ -3718,6 +3722,27 @@
+ and the inline behaviour with <code>SCI_SETIMEINTERACTION(SC_IME_INLINE)</code>.
+ Scintilla may ignore this call in some cases. For example, the inline behaviour might only be supported for some languages.</p>
+
++<div class="provisional">
++ <a href="#ProvisionalMessages">These bidirectional features are not yet implemented and the API is provisional</a><br />
++ <p><b id="SCI_SETBIDIRECTIONAL">SCI_SETBIDIRECTIONAL(int bidirectional)</b><br />
++ <b id="SCI_GETBIDIRECTIONAL">SCI_GETBIDIRECTIONAL &rarr; int</b><br />
++ Some languages, like Arabic and Hebrew, are written from right to left instead of from left to right as English is.
++ Documents that use multiple languages may contain both directions and this is termed "bidirectional".
++ The default text direction may be right to left or left to right.
++ Scintilla only correctly displays bidirectional text on some platforms and there can be additional processing and storage
++ costs to this.
++ Currently, bidirectional text only works on Win32 using DirectWrite.
++ As some applications may not want to pay the costs, bidirectional support must be explicitly enabled by calling
++ <code>SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_L2R)</code> (1) which chooses left to right as the default direction or
++ <code>SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_R2L)</code> (2) for default right to left.
++ This should be done after setting the technology to <code>SC_TECHNOLOGY_DIRECTWRITE</code>,
++ <code>SC_TECHNOLOGY_DIRECTWRITERETAIN</code>, or
++ <code>SC_TECHNOLOGY_DIRECTWRITEDC</code>.</p>
++ <p>If the call succeeded <code>SCI_GETBIDIRECTIONAL</code> will return the same value otherwise
++ <code>SC_BIDIRECTIONAL_DISABLED</code> (0) is returned.
++ </p>
++</div>
++
+ <p><b id="SCI_GRABFOCUS">SCI_GRABFOCUS</b><br />
+ <b id="SCI_SETFOCUS">SCI_SETFOCUS(bool focus)</b><br />
+ <b id="SCI_GETFOCUS">SCI_GETFOCUS &rarr; bool</b><br />
+@@ -8073,8 +8098,6 @@
+
+ <p>Provisional features are displayed in this document with <span class="provisional">a distinctive background colour</span>.</p>
+
+- <p>There are currently no provisional messages or values.</p>
+-
+ <p>Some developers may want to only use features that are stable and have graduated from
+ provisional status. To avoid using provisional messages compile with the symbol
+ <code>SCI_DISABLE_PROVISIONAL</code> defined.</p>
+diff -r 5246ca55cf24 -r 73343682cbda include/Scintilla.h
+--- a/include/Scintilla.h Wed Jan 10 10:04:03 2018 +1100
++++ b/include/Scintilla.h Tue Dec 19 15:00:40 2017 +1100
+@@ -1103,5 +1103,12 @@
+ #define SCN_AUTOCCOMPLETED 2030
+ #define SCN_MARGINRIGHTCLICK 2031
++#ifndef SCI_DISABLE_PROVISIONAL
++#define SC_BIDIRECTIONAL_DISABLED 0
++#define SC_BIDIRECTIONAL_L2R 1
++#define SC_BIDIRECTIONAL_R2L 2
++#define SCI_GETBIDIRECTIONAL 2708
++#define SCI_SETBIDIRECTIONAL 2709
++#endif
+ /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
+
+ /* These structures are defined to be exactly the same shape as the Win32
+diff -r 5246ca55cf24 -r 73343682cbda include/Scintilla.iface
+--- a/include/Scintilla.iface Wed Jan 10 10:04:03 2018 +1100
++++ b/include/Scintilla.iface Tue Dec 19 15:00:40 2017 +1100
+@@ -4861,9 +4861,18 @@
+ evt void MarginRightClick=2031(int modifiers, int position, int margin)
+
+-# There are no provisional APIs currently, but some arguments to SCI_SETTECHNOLOGY are provisional.
+-
+ cat Provisional
+
++enu Bidirectional=SC_BIDIRECTIONAL_
++val SC_BIDIRECTIONAL_DISABLED=0
++val SC_BIDIRECTIONAL_L2R=1
++val SC_BIDIRECTIONAL_R2L=2
++
++# Retrieve bidirectional text display state.
++get int GetBidirectional=2708(,)
++
++# Set bidirectional text display state.
++set void SetBidirectional=2709(int bidirectional,)
++
+ cat Deprecated
+
+ # Divide each styling byte into lexical class bits (default: 5) and indicator
+diff -r 5246ca55cf24 -r 73343682cbda src/EditModel.cxx
+--- a/src/EditModel.cxx Wed Jan 10 10:04:03 2018 +1100
++++ b/src/EditModel.cxx Tue Dec 19 15:00:40 2017 +1100
+@@ -63,6 +63,7 @@
+ highlightGuideColumn = 0;
+ primarySelection = true;
+ imeInteraction = imeWindowed;
++ bidirectional = Bidirectional::bidiDisabled;
+ foldFlags = 0;
+ foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN;
+ hotspot = Range(Sci::invalidPosition);
+diff -r 5246ca55cf24 -r 73343682cbda src/EditModel.h
+--- a/src/EditModel.h Wed Jan 10 10:04:03 2018 +1100
++++ b/src/EditModel.h Tue Dec 19 15:00:40 2017 +1100
+@@ -38,6 +38,8 @@
+
+ enum IMEInteraction { imeWindowed, imeInline } imeInteraction;
+
++ enum class Bidirectional { bidiDisabled, bidiL2R, bidiR2L } bidirectional;
++
+ int foldFlags;
+ int foldDisplayTextStyle;
+ ContractionState cs;
+diff -r 5246ca55cf24 -r 73343682cbda src/Editor.cxx
+--- a/src/Editor.cxx Wed Jan 10 10:04:03 2018 +1100
++++ b/src/Editor.cxx Tue Dec 19 15:00:40 2017 +1100
+@@ -6736,6 +6736,13 @@
+ case SCI_GETIMEINTERACTION:
+ return imeInteraction;
+
++ case SCI_SETBIDIRECTIONAL:
++ // SCI_SETBIDIRECTIONAL is implemented on platform subclasses if they support bidirectional text.
++ break;
++
++ case SCI_GETBIDIRECTIONAL:
++ return static_cast<sptr_t>(bidirectional);
++
+ // Marker definition and setting
+ case SCI_MARKERDEFINE:
+ if (wParam <= MARKER_MAX) {
+diff -r 5246ca55cf24 -r 73343682cbda win32/ScintillaWin.cxx
+--- a/win32/ScintillaWin.cxx Wed Jan 10 10:04:03 2018 +1100
++++ b/win32/ScintillaWin.cxx Tue Dec 19 15:00:40 2017 +1100
+@@ -1744,6 +1744,17 @@
+ }
+ break;
+
++ case SCI_SETBIDIRECTIONAL:
++ if (technology == SC_TECHNOLOGY_DEFAULT) {
++ bidirectional = EditModel::Bidirectional::bidiDisabled;
++ } else if ((wParam >= SC_BIDIRECTIONAL_DISABLED) && (wParam <= SC_BIDIRECTIONAL_R2L)) {
++ bidirectional = static_cast<EditModel::Bidirectional>(wParam);
++ }
++ // Invalidate all cached information including layout.
++ DropGraphics(true);
++ InvalidateStyleRedraw();
++ break;
++
+ #ifdef SCI_LEXER
+ case SCI_LOADLEXERLIBRARY:
+ LexerManager::GetInstance()->Load(reinterpret_cast<const char *>(lParam));
diff --git a/src/scintilla_backports/6434_ed27432729c3.patch b/src/scintilla_backports/6434_ed27432729c3.patch
new file mode 100644
index 00000000..fafca810
--- /dev/null
+++ b/src/scintilla_backports/6434_ed27432729c3.patch
@@ -0,0 +1,50 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1517090168 -39600
+# Node ID ed27432729c386c48ef4f11459aeb2ed1f0856c8
+# Parent 231ac99e1fdc2b0fa62668cf5495b2f7df3f4d82
+Use std::abs in preference to abs as std::abs is generic and abs casts to int
+which may drop information.
+
+diff -r 231ac99e1fdc -r ed27432729c3 src/Document.cxx
+--- a/src/Document.cxx Sun Jan 28 08:32:17 2018 +1100
++++ b/src/Document.cxx Sun Jan 28 08:56:08 2018 +1100
+@@ -10,6 +10,7 @@
+ #include <cassert>
+ #include <cstring>
+ #include <cstdio>
++#include <cmath>
+
+ #include <stdexcept>
+ #include <string>
+@@ -877,7 +878,7 @@
+ const Sci::Position posNext = NextPosition(pos, increment);
+ if (posNext == pos)
+ return INVALID_POSITION;
+- if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
++ if (std::abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
+ characterOffset -= increment;
+ pos = posNext;
+ characterOffset -= increment;
+diff -r 231ac99e1fdc -r ed27432729c3 src/Editor.cxx
+--- a/src/Editor.cxx Sun Jan 28 08:32:17 2018 +1100
++++ b/src/Editor.cxx Sun Jan 28 08:56:08 2018 +1100
+@@ -11,8 +11,8 @@
+ #include <cstring>
+ #include <cctype>
+ #include <cstdio>
+-
+ #include <cmath>
++
+ #include <stdexcept>
+ #include <string>
+ #include <vector>
+@@ -934,7 +934,7 @@
+ // Try to optimise small scrolls
+ #ifndef UNDER_CE
+ const Sci::Line linesToMove = topLine - topLineNew;
+- const bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
++ const bool performBlit = (std::abs(linesToMove) <= 10) && (paintState == notPainting);
+ willRedrawAll = !performBlit;
+ #endif
+ SetTopLine(topLineNew);
diff --git a/src/scintilla_backports/6436_a366ce1a811e.patch b/src/scintilla_backports/6436_a366ce1a811e.patch
new file mode 100644
index 00000000..f2a22132
--- /dev/null
+++ b/src/scintilla_backports/6436_a366ce1a811e.patch
@@ -0,0 +1,110 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1517091000 -39600
+# Node ID a366ce1a811e322b24f08a20825947113d39d698
+# Parent 5dd1b26df75f0ffa20624a61d1b77d24406ba048
+Use std::end when filling arrays as reduces chance of mistake.
+
+diff -r 5dd1b26df75f -r a366ce1a811e lexlib/WordList.cxx
+--- a/lexlib/WordList.cxx Sun Jan 28 08:57:56 2018 +1100
++++ b/lexlib/WordList.cxx Sun Jan 28 09:10:00 2018 +1100
+@@ -10,6 +10,7 @@
+ #include <cstring>
+
+ #include <algorithm>
++#include <iterator>
+
+ #include "StringCopy.h"
+ #include "WordList.h"
+@@ -128,7 +129,7 @@
+ #else
+ SortWordList(words, len);
+ #endif
+- std::fill(starts, starts + ELEMENTS(starts), -1);
++ std::fill(starts, std::end(starts), -1);
+ for (int l = len - 1; l >= 0; l--) {
+ unsigned char indexChar = words[l][0];
+ starts[indexChar] = l;
+diff -r 5dd1b26df75f -r a366ce1a811e scripts/HeaderOrder.txt
+--- a/scripts/HeaderOrder.txt Sun Jan 28 08:57:56 2018 +1100
++++ b/scripts/HeaderOrder.txt Sun Jan 28 09:10:00 2018 +1100
+@@ -39,6 +39,7 @@
+ #include <set>
+ #include <forward_list>
+ #include <algorithm>
++#include <iterator>
+ #include <functional>
+ #include <memory>
+ #include <regex>
+diff -r 5dd1b26df75f -r a366ce1a811e src/PositionCache.cxx
+--- a/src/PositionCache.cxx Sun Jan 28 08:57:56 2018 +1100
++++ b/src/PositionCache.cxx Sun Jan 28 09:10:00 2018 +1100
+@@ -14,5 +14,6 @@
+ #include <vector>
+ #include <map>
+ #include <algorithm>
++#include <iterator>
+
+ #include "Platform.h"
+@@ -378,7 +379,7 @@
+ }
+
+ SpecialRepresentations::SpecialRepresentations() {
+- std::fill(startByteHasReprs, startByteHasReprs+0x100, static_cast<short>(0));
++ std::fill(startByteHasReprs, std::end(startByteHasReprs), static_cast<short>(0));
+ }
+
+ void SpecialRepresentations::SetRepresentation(const char *charBytes, const char *value) {
+@@ -419,7 +420,7 @@
+
+ void SpecialRepresentations::Clear() {
+ mapReprs.clear();
+- std::fill(startByteHasReprs, startByteHasReprs+0x100, static_cast<short>(0));
++ std::fill(startByteHasReprs, std::end(startByteHasReprs), static_cast<short>(0));
+ }
+
+ void BreakFinder::Insert(int val) {
+diff -r 5dd1b26df75f -r a366ce1a811e src/RESearch.cxx
+--- a/src/RESearch.cxx Sun Jan 28 08:57:56 2018 +1100
++++ b/src/RESearch.cxx Sun Jan 28 09:10:00 2018 +1100
+@@ -205,6 +205,7 @@
+ #include <stdexcept>
+ #include <string>
+ #include <algorithm>
++#include <iterator>
+
+ #include "Position.h"
+ #include "CharClassify.h"
+@@ -254,9 +255,9 @@
+ charClass = charClassTable;
+ sta = NOP; /* status of lastpat */
+ bol = 0;
+- std::fill(bittab, bittab + BITBLK, static_cast<unsigned char>(0));
+- std::fill(tagstk, tagstk + MAXTAG, 0);
+- std::fill(nfa, nfa + MAXNFA, '\0');
++ std::fill(bittab, std::end(bittab), static_cast<unsigned char>(0));
++ std::fill(tagstk, std::end(tagstk), 0);
++ std::fill(nfa, std::end(nfa), '\0');
+ Clear();
+ }
+
+diff -r 5dd1b26df75f -r a366ce1a811e src/XPM.cxx
+--- a/src/XPM.cxx Sun Jan 28 08:57:56 2018 +1100
++++ b/src/XPM.cxx Sun Jan 28 09:10:00 2018 +1100
+@@ -11,5 +11,7 @@
+ #include <stdexcept>
+ #include <vector>
+ #include <map>
++#include <algorithm>
++#include <iterator>
+
+ #include "Platform.h"
+@@ -87,7 +89,7 @@
+ if (!linesForm)
+ return;
+
+- std::fill(colourCodeTable, colourCodeTable+256, 0);
++ std::fill(colourCodeTable, std::end(colourCodeTable), 0);
+ const char *line0 = linesForm[0];
+ width = atoi(line0);
+ line0 = NextField(line0);
diff --git a/src/scintilla_backports/6441_92c8f0f1b3e6.patch b/src/scintilla_backports/6441_92c8f0f1b3e6.patch
new file mode 100644
index 00000000..edcc6338
--- /dev/null
+++ b/src/scintilla_backports/6441_92c8f0f1b3e6.patch
@@ -0,0 +1,157 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1516925530 -39600
+# Node ID 92c8f0f1b3e64900cbb868a56936898693b9cfcc
+# Parent a1731ae83d2ac87c29f6b502efc5c4a747e0b704
+Add documentOption argument to SCI_CREATELOADER.
+
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 doc/ScintillaDoc.html
+--- a/doc/ScintillaDoc.html Tue Jan 30 12:40:53 2018 +1100
++++ b/doc/ScintillaDoc.html Fri Jan 26 11:12:10 2018 +1100
+@@ -119,7 +119,7 @@
+
+ <h1>Scintilla Documentation</h1>
+
+- <p>Last edited 10 January 2018 NH</p>
++ <p>Last edited 31 January 2018 NH</p>
+
+ <p>There is <a class="jump" href="Design.html">an overview of the internal design of
+ Scintilla</a>.<br />
+@@ -5711,7 +5711,7 @@
+ <code><a class="message" href="#SCI_GETDOCPOINTER">SCI_GETDOCPOINTER &rarr; document *</a><br />
+ <a class="message" href="#SCI_SETDOCPOINTER">SCI_SETDOCPOINTER(&lt;unused&gt;, document
+ *doc)</a><br />
+- <a class="message" href="#SCI_CREATEDOCUMENT">SCI_CREATEDOCUMENT &rarr; document *</a><br />
++ <a class="message" href="#SCI_CREATEDOCUMENT">SCI_CREATEDOCUMENT(int bytes, int documentOption) &rarr; document *</a><br />
+ <a class="message" href="#SCI_ADDREFDOCUMENT">SCI_ADDREFDOCUMENT(&lt;unused&gt;, document
+ *doc)</a><br />
+ <a class="message" href="#SCI_RELEASEDOCUMENT">SCI_RELEASEDOCUMENT(&lt;unused&gt;, document
+@@ -5732,13 +5732,20 @@
+ window.<br />
+ 6. If <code class="parameter">doc</code> was not 0, its reference count is increased by 1.</p>
+
+- <p><b id="SCI_CREATEDOCUMENT">SCI_CREATEDOCUMENT &rarr; document *</b><br />
++ <p><b id="SCI_CREATEDOCUMENT">SCI_CREATEDOCUMENT(int bytes, int documentOption) &rarr; document *</b><br />
+ This message creates a new, empty document and returns a pointer to it. This document is not
+- selected into the editor and starts with a reference count of 1. This means that you have
+- ownership of it and must either reduce its reference count by 1 after using
++ selected into the editor and starts with a reference count of 1. This means that you have
++ ownership of it and must either reduce its reference count by 1 after using
+ <code>SCI_SETDOCPOINTER</code> so that the Scintilla window owns it or you must make sure that
+- you reduce the reference count by 1 with <code>SCI_RELEASEDOCUMENT</code> before you close the
+- application to avoid memory leaks.</p>
++ you reduce the reference count by 1 with <code>SCI_RELEASEDOCUMENT</code> before you close the
++ application to avoid memory leaks. The <code class="parameter">bytes</code> argument determines
++ the initial memory allocation for the document as it is more efficient
++ to allocate once rather than rely on the buffer growing as data is added.
++ If <code>SCI_CREATEDOCUMENT</code> fails then 0 is returned.</p>
++
++ <p>The <code class="parameter">documentOption</code> argument may be used in future versions
++ to choose between different document capabilities which affect memory allocation and performance.
++ The only valid value for now is <code>SC_DOCUMENTOPTION_DEFAULT</code> (0).</p>
+
+ <p><b id="SCI_ADDREFDOCUMENT">SCI_ADDREFDOCUMENT(&lt;unused&gt;, document *doc)</b><br />
+ This increases the reference count of a document by 1. If you want to replace the current
+@@ -5765,7 +5772,7 @@
+
+ <h3 id="BackgroundLoad">Loading in the background</h3>
+
+- <code><a class="message" href="#SCI_CREATELOADER">SCI_CREATELOADER(int bytes) &rarr; int</a><br />
++ <code><a class="message" href="#SCI_CREATELOADER">SCI_CREATELOADER(int bytes, int documentOption) &rarr; int</a><br />
+ </code>
+
+ <p>An application can load all of a file into a buffer it allocates on a background thread and then add the data in that buffer
+@@ -5774,13 +5781,17 @@
+
+ <p>To avoid these issues, a loader object may be created and used to load the file. The loader object supports the ILoader interface.</p>
+
+- <p><b id="SCI_CREATELOADER">SCI_CREATELOADER(int bytes) &rarr; int</b><br />
++ <p><b id="SCI_CREATELOADER">SCI_CREATELOADER(int bytes, int documentOption) &rarr; int</b><br />
+ Create an object that supports the <code>ILoader</code> interface which can be used to load data and then
+ be turned into a Scintilla document object for attachment to a view object.
+ The <code class="parameter">bytes</code> argument determines the initial memory allocation for the document as it is more efficient
+ to allocate once rather than rely on the buffer growing as data is added.
+ If <code>SCI_CREATELOADER</code> fails then 0 is returned.</p>
+
++ <p>The <code class="parameter">documentOption</code> argument may be used in future versions
++ to choose between different document capabilities which affect memory allocation and performance.
++ The only valid value for now is <code>SC_DOCUMENTOPTION_DEFAULT</code> (0).</p>
++
+ <h4>ILoader</h4>
+
+ <div class="highlighted">
+@@ -6573,7 +6584,7 @@
+ On GTK+, there are storage and performance costs to accessibility, so it can be disabled
+ by calling <code>SCI_SETACCESSIBILITY</code>.
+ </p>
+-
++
+ <table class="standard" summary="Accessibility status">
+ <tbody>
+ <tr>
+@@ -6603,7 +6614,7 @@
+ </tr>
+ </tbody>
+ </table>
+-
++
+ <h2 id="Lexer">Lexer</h2>
+
+ <p>If you define the symbol <code>SCI_LEXER</code> when building Scintilla, (this is sometimes
+@@ -6894,7 +6905,7 @@
+ <p>
+ Methods that return strings as <code>const char *</code> are not required to maintain separate allocations indefinitely:
+ lexer implementations may own a single buffer that is reused for each call.
+-Callers should make an immediate copy of returned strings.
++Callers should make an immediate copy of returned strings.
+ </p>
+
+ <p>
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 include/Scintilla.h
+--- a/include/Scintilla.h Tue Jan 30 12:40:53 2018 +1100
++++ b/include/Scintilla.h Fri Jan 26 11:12:10 2018 +1100
+@@ -689,6 +689,7 @@
+ #define SCI_SELECTIONISRECTANGLE 2372
+ #define SCI_SETZOOM 2373
+ #define SCI_GETZOOM 2374
++#define SC_DOCUMENTOPTION_DEFAULT 0
+ #define SCI_CREATEDOCUMENT 2375
+ #define SCI_ADDREFDOCUMENT 2376
+ #define SCI_RELEASEDOCUMENT 2377
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 include/Scintilla.iface
+--- a/include/Scintilla.iface Tue Jan 30 12:40:53 2018 +1100
++++ b/include/Scintilla.iface Fri Jan 26 11:12:10 2018 +1100
+@@ -1771,9 +1771,12 @@
+ # Retrieve the zoom level.
+ get int GetZoom=2374(,)
+
++enu DocumentOption=SC_DOCUMENTOPTION_
++val SC_DOCUMENTOPTION_DEFAULT=0
++
+ # Create a new document object.
+ # Starts with reference count of 1 and not selected into editor.
+-fun int CreateDocument=2375(,)
++fun int CreateDocument=2375(int bytes, int documentOption)
+ # Extend life of document.
+ fun void AddRefDocument=2376(, int doc)
+ # Release a reference to the document, deleting document if it fades to black.
+@@ -2540,7 +2543,7 @@
+ get int GetTechnology=2631(,)
+
+ # Create an ILoader*.
+-fun int CreateLoader=2632(int bytes,)
++fun int CreateLoader=2632(int bytes, int documentOption)
+
+ # On OS X, show a find indicator.
+ fun void FindIndicatorShow=2640(position start, position end)
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 src/Editor.cxx
+--- a/src/Editor.cxx Tue Jan 30 12:40:53 2018 +1100
++++ b/src/Editor.cxx Fri Jan 26 11:12:10 2018 +1100
+@@ -7556,6 +7556,7 @@
+ case SCI_CREATEDOCUMENT: {
+ Document *doc = new Document();
+ doc->AddRef();
++ doc->Allocate(static_cast<int>(wParam));
+ return reinterpret_cast<sptr_t>(doc);
+ }
+
diff --git a/src/scintilla_backports/6442_3e3bfe29a819.patch b/src/scintilla_backports/6442_3e3bfe29a819.patch
new file mode 100644
index 00000000..acc6dbae
--- /dev/null
+++ b/src/scintilla_backports/6442_3e3bfe29a819.patch
@@ -0,0 +1,319 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1516950278 -39600
+# Node ID 3e3bfe29a819c1f7a1761096ec54e9b6ee446a68
+# Parent 92c8f0f1b3e64900cbb868a56936898693b9cfcc
+Extend SplitVector to allow more than 2 billion elements on 64-bit systems.
+
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/CellBuffer.cxx
+--- a/src/CellBuffer.cxx Fri Jan 26 11:12:10 2018 +1100
++++ b/src/CellBuffer.cxx Fri Jan 26 18:04:38 2018 +1100
+@@ -394,7 +394,7 @@
+ }
+
+ Sci::Position CellBuffer::GapPosition() const {
+- return substance.GapPosition();
++ return static_cast<Sci::Position>(substance.GapPosition());
+ }
+
+ // The char* returned is to an allocation owned by the undo history
+@@ -457,7 +457,7 @@
+ }
+
+ Sci::Position CellBuffer::Length() const {
+- return substance.Length();
++ return static_cast<Sci::Position>(substance.Length());
+ }
+
+ void CellBuffer::Allocate(Sci::Position newSize) {
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/Partitioning.h
+--- a/src/Partitioning.h Fri Jan 26 11:12:10 2018 +1100
++++ b/src/Partitioning.h Fri Jan 26 18:04:38 2018 +1100
+@@ -16,7 +16,7 @@
+
+ class SplitVectorWithRangeAdd : public SplitVector<int> {
+ public:
+- explicit SplitVectorWithRangeAdd(int growSize_) {
++ explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {
+ SetGrowSize(growSize_);
+ ReAllocate(growSize_);
+ }
+@@ -25,12 +25,12 @@
+ void operator=(const SplitVectorWithRangeAdd &) = delete;
+ ~SplitVectorWithRangeAdd() {
+ }
+- void RangeAddDelta(int start, int end, int delta) {
++ void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {
+ // end is 1 past end, so end-start is number of elements to change
+- int i = 0;
+- const int rangeLength = end - start;
+- int range1Length = rangeLength;
+- const int part1Left = part1Length - start;
++ ptrdiff_t i = 0;
++ const ptrdiff_t rangeLength = end - start;
++ ptrdiff_t range1Length = rangeLength;
++ const ptrdiff_t part1Left = part1Length - start;
+ if (range1Length > part1Left)
+ range1Length = part1Left;
+ while (i < range1Length) {
+@@ -67,7 +67,7 @@
+ }
+ stepPartition = partitionUpTo;
+ if (stepPartition >= body->Length()-1) {
+- stepPartition = body->Length()-1;
++ stepPartition = Partitions();
+ stepLength = 0;
+ }
+ }
+@@ -80,7 +80,7 @@
+ stepPartition = partitionDownTo;
+ }
+
+- void Allocate(int growSize) {
++ void Allocate(ptrdiff_t growSize) {
+ body = new SplitVectorWithRangeAdd(growSize);
+ stepPartition = 0;
+ stepLength = 0;
+@@ -101,7 +101,7 @@
+ }
+
+ int Partitions() const {
+- return body->Length()-1;
++ return static_cast<int>(body->Length()-1);
+ }
+
+ void InsertPartition(int partition, int pos) {
+@@ -132,7 +132,7 @@
+ BackStep(partitionInsert);
+ stepLength += delta;
+ } else {
+- ApplyStep(body->Length()-1);
++ ApplyStep(Partitions());
+ stepPartition = partitionInsert;
+ stepLength = delta;
+ }
+@@ -168,10 +168,10 @@
+ int PartitionFromPosition(int pos) const {
+ if (body->Length() <= 1)
+ return 0;
+- if (pos >= (PositionFromPartition(body->Length()-1)))
+- return body->Length() - 1 - 1;
++ if (pos >= (PositionFromPartition(Partitions())))
++ return Partitions() - 1;
+ int lower = 0;
+- int upper = body->Length()-1;
++ int upper = Partitions();
+ do {
+ const int middle = (upper + lower + 1) / 2; // Round high
+ int posMiddle = body->ValueAt(middle);
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/PerLine.cxx
+--- a/src/PerLine.cxx Fri Jan 26 11:12:10 2018 +1100
++++ b/src/PerLine.cxx Fri Jan 26 18:04:38 2018 +1100
+@@ -135,7 +135,7 @@
+ Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
+ if (lineStart < 0)
+ lineStart = 0;
+- const Sci::Line length = markers.Length();
++ const Sci::Line length = static_cast<Sci::Line>(markers.Length());
+ for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
+ const MarkerHandleSet *onLine = markers[iLine].get();
+ if (onLine && ((onLine->MarkValue() & mask) != 0))
+@@ -281,7 +281,7 @@
+ }
+
+ Sci::Line LineState::GetMaxLineState() const {
+- return lineStates.Length();
++ return static_cast<Sci::Line>(lineStates.Length());
+ }
+
+ static int NumberLines(const char *text) {
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/SplitVector.h
+--- a/src/SplitVector.h Fri Jan 26 11:12:10 2018 +1100
++++ b/src/SplitVector.h Fri Jan 26 18:04:38 2018 +1100
+@@ -16,15 +16,15 @@
+ protected:
+ T *body;
+- int size;
+- int lengthBody;
+- int part1Length;
+- int gapLength; /// invariant: gapLength == size - lengthBody
+- int growSize;
++ ptrdiff_t size;
++ ptrdiff_t lengthBody;
++ ptrdiff_t part1Length;
++ ptrdiff_t gapLength; /// invariant: gapLength == size - lengthBody
++ ptrdiff_t growSize;
+
+ /// Move the gap to a particular position so that insertion and
+ /// deletion at that point will not require much copying and
+ /// hence be fast.
+- void GapTo(int position) {
++ void GapTo(ptrdiff_t position) {
+ if (position != part1Length) {
+ if (position < part1Length) {
+ // Moving the gap towards start so moving elements towards end
+@@ -45,11 +45,11 @@
+
+ /// Check that there is room in the buffer for an insertion,
+ /// reallocating if more space needed.
+- void RoomFor(int insertionLength) {
++ void RoomFor(ptrdiff_t insertionLength) {
+ if (gapLength <= insertionLength) {
+ while (growSize < size / 6)
+ growSize *= 2;
+ ReAllocate(size + insertionLength + growSize);
+ }
+ }
+
+@@ -75,18 +75,18 @@
+ ~SplitVector() {
+ }
+
+- int GetGrowSize() const {
++ ptrdiff_t GetGrowSize() const {
+ return growSize;
+ }
+-
+- void SetGrowSize(int growSize_) {
++
++ void SetGrowSize(ptrdiff_t growSize_) {
+ growSize = growSize_;
+ }
+
+ /// Reallocate the storage for the buffer to be newSize and
+ /// copy exisiting contents to the new buffer.
+ /// Must not be used to decrease the size of the buffer.
+- void ReAllocate(int newSize) {
++ void ReAllocate(ptrdiff_t newSize) {
+ if (newSize < 0)
+ throw std::runtime_error("SplitVector::ReAllocate: negative size.");
+
+@@ -104,9 +104,9 @@
+
+ /// Retrieve the character at a particular position.
+ /// Retrieving positions outside the range of the buffer returns 0.
+ /// The assertions here are disabled since calling code can be
+ /// simpler if out of range access works and returns 0.
+- T ValueAt(int position) const {
++ T ValueAt(ptrdiff_t position) const {
+ if (position < part1Length) {
+ //PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+@@ -124,7 +124,7 @@
+ }
+ }
+
+- void SetValueAt(int position, T v) {
++ void SetValueAt(ptrdiff_t position, T v) {
+ if (position < part1Length) {
+ PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+@@ -144,7 +144,7 @@
+ }
+ }
+
+- T &operator[](int position) const {
++ T &operator[](ptrdiff_t position) const {
+ PLATFORM_ASSERT(position >= 0 && position < lengthBody);
+ if (position < part1Length) {
+ return body[position];
+@@ -166,13 +166,13 @@
+ }
+
+ /// Retrieve the length of the buffer.
+- int Length() const {
++ ptrdiff_t Length() const {
+ return lengthBody;
+ }
+
+ /// Insert a single value into the buffer.
+ /// Inserting at positions outside the current range fails.
+- void Insert(int position, T v) {
++ void Insert(ptrdiff_t position, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if ((position < 0) || (position > lengthBody)) {
+ return;
+@@ -187,7 +187,7 @@
+
+ /// Insert a number of elements into the buffer setting their value.
+ /// Inserting at positions outside the current range fails.
+- void InsertValue(int position, int insertLength, T v) {
++ void InsertValue(ptrdiff_t position, ptrdiff_t insertLength, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if (insertLength > 0) {
+ if ((position < 0) || (position > lengthBody)) {
+@@ -225,14 +225,14 @@
+
+ /// Ensure at least length elements allocated,
+ /// appending zero valued elements if needed.
+- void EnsureLength(int wantedLength) {
++ void EnsureLength(ptrdiff_t wantedLength) {
+ if (Length() < wantedLength) {
+ InsertValue(Length(), wantedLength - Length(), 0);
+ }
+ }
+
+ /// Insert text into the buffer from an array.
+- void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
++ void InsertFromArray(ptrdiff_t positionToInsert, const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength) {
+ PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
+ if (insertLength > 0) {
+ if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {
+@@ -248,7 +248,7 @@
+ }
+
+ /// Delete one element from the buffer.
+- void Delete(int position) {
++ void Delete(ptrdiff_t position) {
+ PLATFORM_ASSERT((position >= 0) && (position < lengthBody));
+ if ((position < 0) || (position >= lengthBody)) {
+ return;
+@@ -258,7 +258,7 @@
+
+ /// Delete a range from the buffer.
+ /// Deleting positions outside the current range fails.
+- void DeleteRange(int position, int deleteLength) {
++ void DeleteRange(ptrdiff_t position, ptrdiff_t deleteLength) {
+ PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));
+ if ((position < 0) || ((position + deleteLength) > lengthBody)) {
+ return;
+@@ -277,17 +277,17 @@
+ // Retrieve a range of elements into an array
+- void GetRange(T *buffer, int position, int retrieveLength) const {
++ void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const {
+ // Split into up to 2 ranges, before and after the split then use memcpy on each.
+- int range1Length = 0;
++ ptrdiff_t range1Length = 0;
+ if (position < part1Length) {
+- const int part1AfterPosition = part1Length - position;
++ const ptrdiff_t part1AfterPosition = part1Length - position;
+ range1Length = retrieveLength;
+ if (range1Length > part1AfterPosition)
+ range1Length = part1AfterPosition;
+ }
+ std::copy(body + position, body + position + range1Length, buffer);
+ buffer += range1Length;
+ position = position + range1Length + gapLength;
+- int range2Length = retrieveLength - range1Length;
++ ptrdiff_t range2Length = retrieveLength - range1Length;
+ std::copy(body + position, body + position + range2Length, buffer);
+ }
+
+@@ -308,7 +308,7 @@
+ return body;
+ }
+
+- T *RangePointer(int position, int rangeLength) {
++ T *RangePointer(ptrdiff_t position, ptrdiff_t rangeLength) {
+ if (position < part1Length) {
+ if ((position + rangeLength) > part1Length) {
+ // Range overlaps gap, so move gap to start of range.
+@@ -323,7 +323,7 @@
+ }
+ }
+
+- int GapPosition() const {
++ ptrdiff_t GapPosition() const {
+ return part1Length;
+ }
+ };
diff --git a/src/scintilla_backports/6444_1bd57324aa36.patch b/src/scintilla_backports/6444_1bd57324aa36.patch
new file mode 100644
index 00000000..93552ba4
--- /dev/null
+++ b/src/scintilla_backports/6444_1bd57324aa36.patch
@@ -0,0 +1,279 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1517436441 -39600
+# Node ID 1bd57324aa36e3fce1ed8a2371001b062322884b
+# Parent ab4efcbfdae68d1ec053db212edb1440326a7f1c
+Templatize Partitioning so it can hold different types.
+
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/CellBuffer.h
+--- a/src/CellBuffer.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/CellBuffer.h Thu Feb 01 09:07:21 2018 +1100
+@@ -24,7 +24,7 @@
+ */
+ class LineVector {
+
+- Partitioning starts;
++ Partitioning<int> starts;
+ PerLine *perLine;
+
+ public:
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/ContractionState.cxx
+--- a/src/ContractionState.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/src/ContractionState.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -39,7 +39,7 @@
+ expanded = new RunStyles();
+ heights = new RunStyles();
+ foldDisplayTexts = new SparseVector<const char *>();
+- displayLines = new Partitioning(4);
++ displayLines = new Partitioning<int>(4);
+ InsertLines(0, linesInDocument);
+ }
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/ContractionState.h
+--- a/src/ContractionState.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/ContractionState.h Thu Feb 01 09:07:21 2018 +1100
+@@ -21,7 +21,7 @@
+ RunStyles *expanded;
+ RunStyles *heights;
+ SparseVector<const char *> *foldDisplayTexts;
+- Partitioning *displayLines;
++ Partitioning<int> *displayLines;
+ Sci::Line linesInDocument;
+
+ void EnsureData();
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/Partitioning.h
+--- a/src/Partitioning.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/Partitioning.h Thu Feb 01 09:07:21 2018 +1100
+@@ -14,29 +14,30 @@
+ /// in a range.
+ /// Used by the Partitioning class.
+
+-class SplitVectorWithRangeAdd : public SplitVector<int> {
++template <typename T>
++class SplitVectorWithRangeAdd : public SplitVector<T> {
+ public:
+ explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {
+- SetGrowSize(growSize_);
+- ReAllocate(growSize_);
++ this->SetGrowSize(growSize_);
++ this->ReAllocate(growSize_);
+ }
+ ~SplitVectorWithRangeAdd() {
+ }
+- void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {
++ void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, T delta) {
+ // end is 1 past end, so end-start is number of elements to change
+ ptrdiff_t i = 0;
+ const ptrdiff_t rangeLength = end - start;
+ ptrdiff_t range1Length = rangeLength;
+- const ptrdiff_t part1Left = part1Length - start;
++ const ptrdiff_t part1Left = this->part1Length - start;
+ if (range1Length > part1Left)
+ range1Length = part1Left;
+ while (i < range1Length) {
+- body[start++] += delta;
++ this->body[start++] += delta;
+ i++;
+ }
+- start += gapLength;
++ start += this->gapLength;
+ while (i < rangeLength) {
+- body[start++] += delta;
++ this->body[start++] += delta;
+ i++;
+ }
+ }
+@@ -52,16 +53,17 @@
+ /// When needed, positions after the interval are considered part of the last partition
+ /// but the end of the last partition can be found with PositionFromPartition(last+1).
+
++template <typename T>
+ class Partitioning {
+ private:
+ // To avoid calculating all the partition positions whenever any text is inserted
+ // there may be a step somewhere in the list.
+- int stepPartition;
+- int stepLength;
+- SplitVectorWithRangeAdd *body;
++ T stepPartition;
++ T stepLength;
++ SplitVectorWithRangeAdd<T> *body;
+
+ // Move step forward
+- void ApplyStep(int partitionUpTo) {
++ void ApplyStep(T partitionUpTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength);
+ }
+@@ -73,7 +75,7 @@
+ }
+
+ // Move step backward
+- void BackStep(int partitionDownTo) {
++ void BackStep(T partitionDownTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength);
+ }
+@@ -81,7 +83,7 @@
+ }
+
+ void Allocate(ptrdiff_t growSize) {
+- body = new SplitVectorWithRangeAdd(growSize);
++ body = new SplitVectorWithRangeAdd<T>(growSize);
+ stepPartition = 0;
+ stepLength = 0;
+ body->Insert(0, 0); // This value stays 0 for ever
+@@ -100,11 +102,11 @@
+ ~Partitioning() {
+ }
+
+- int Partitions() const {
+- return static_cast<int>(body->Length()-1);
++ T Partitions() const {
++ return static_cast<T>(body->Length())-1;
+ }
+
+- void InsertPartition(int partition, int pos) {
++ void InsertPartition(T partition, T pos) {
+ if (stepPartition < partition) {
+ ApplyStep(partition);
+ }
+@@ -112,7 +114,7 @@
+ stepPartition++;
+ }
+
+- void SetPartitionStartPosition(int partition, int pos) {
++ void SetPartitionStartPosition(T partition, T pos) {
+ ApplyStep(partition+1);
+ if ((partition < 0) || (partition > body->Length())) {
+ return;
+@@ -120,7 +122,7 @@
+ body->SetValueAt(partition, pos);
+ }
+
+- void InsertText(int partitionInsert, int delta) {
++ void InsertText(T partitionInsert, T delta) {
+ // Point all the partitions after the insertion point further along in the buffer
+ if (stepLength != 0) {
+ if (partitionInsert >= stepPartition) {
+@@ -142,7 +144,7 @@
+ }
+ }
+
+- void RemovePartition(int partition) {
++ void RemovePartition(T partition) {
+ if (partition > stepPartition) {
+ ApplyStep(partition);
+ stepPartition--;
+@@ -152,29 +154,29 @@
+ body->Delete(partition);
+ }
+
+- int PositionFromPartition(int partition) const {
++ T PositionFromPartition(T partition) const {
+ PLATFORM_ASSERT(partition >= 0);
+ PLATFORM_ASSERT(partition < body->Length());
+ if ((partition < 0) || (partition >= body->Length())) {
+ return 0;
+ }
+- int pos = body->ValueAt(partition);
++ T pos = body->ValueAt(partition);
+ if (partition > stepPartition)
+ pos += stepLength;
+ return pos;
+ }
+
+ /// Return value in range [0 .. Partitions() - 1] even for arguments outside interval
+- int PartitionFromPosition(int pos) const {
++ T PartitionFromPosition(T pos) const {
+ if (body->Length() <= 1)
+ return 0;
+ if (pos >= (PositionFromPartition(Partitions())))
+ return Partitions() - 1;
+- int lower = 0;
+- int upper = Partitions();
++ T lower = 0;
++ T upper = Partitions();
+ do {
+- const int middle = (upper + lower + 1) / 2; // Round high
+- int posMiddle = body->ValueAt(middle);
++ const T middle = (upper + lower + 1) / 2; // Round high
++ T posMiddle = body->ValueAt(middle);
+ if (middle > stepPartition)
+ posMiddle += stepLength;
+ if (pos < posMiddle) {
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/RunStyles.cxx
+--- a/src/RunStyles.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/src/RunStyles.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -70,7 +70,7 @@
+ }
+
+ RunStyles::RunStyles() {
+- starts = new Partitioning(8);
++ starts = new Partitioning<int>(8);
+ styles = new SplitVector<int>();
+ styles->InsertValue(0, 2, 0);
+ }
+@@ -204,7 +204,7 @@
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+- starts = new Partitioning(8);
++ starts = new Partitioning<int>(8);
+ styles = new SplitVector<int>();
+ styles->InsertValue(0, 2, 0);
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/RunStyles.h
+--- a/src/RunStyles.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/RunStyles.h Thu Feb 01 09:07:21 2018 +1100
+@@ -14,7 +14,7 @@
+
+ class RunStyles {
+ private:
+- Partitioning *starts;
++ Partitioning<int> *starts;
+ SplitVector<int> *styles;
+ int RunFromPosition(int position) const;
+ int SplitRun(int position);
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/SparseVector.h
+--- a/src/SparseVector.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/SparseVector.h Thu Feb 01 09:07:21 2018 +1100
+@@ -15,7 +15,7 @@
+ template <typename T>
+ class SparseVector {
+ private:
+- Partitioning *starts;
++ Partitioning<int> *starts;
+ SplitVector<T> *values;
+ // Private so SparseVector objects can not be copied
+ SparseVector(const SparseVector &);
+@@ -26,7 +26,7 @@
+ }
+ public:
+ SparseVector() {
+- starts = new Partitioning(8);
++ starts = new Partitioning<int>(8);
+ values = new SplitVector<T>();
+ values->InsertValue(0, 2, T());
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 test/unit/testPartitioning.cxx
+--- a/test/unit/testPartitioning.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/test/unit/testPartitioning.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -26,7 +26,7 @@
+
+ TEST_CASE("SplitVectorWithRangeAdd") {
+
+- SplitVectorWithRangeAdd svwra(growSize);
++ SplitVectorWithRangeAdd<int> svwra(growSize);
+
+ SECTION("IsEmptyInitially") {
+ REQUIRE(0 == svwra.Length());
+@@ -49,7 +49,7 @@
+
+ TEST_CASE("Partitioning") {
+
+- Partitioning part(growSize);
++ Partitioning<int> part(growSize);
+
+ SECTION("IsEmptyInitially") {
+ REQUIRE(1 == part.Partitions());
diff --git a/src/scintilla_backports/6445_89d992f380a1.patch b/src/scintilla_backports/6445_89d992f380a1.patch
new file mode 100644
index 00000000..b0b9acae
--- /dev/null
+++ b/src/scintilla_backports/6445_89d992f380a1.patch
@@ -0,0 +1,418 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1517437334 -39600
+# Node ID 89d992f380a1ce28a3ba6934230388ffaf1ea611
+# Parent 1bd57324aa36e3fce1ed8a2371001b062322884b
+Templatize RunStyles so it can be over ranges of different types and contain
+different style types.
+Currently only instantiated over <int, int>.
+
+diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.cxx
+--- a/src/ContractionState.cxx Thu Feb 01 09:07:21 2018 +1100
++++ b/src/ContractionState.cxx Thu Feb 01 09:22:14 2018 +1100
+@@ -35,9 +35,9 @@
+
+ void ContractionState::EnsureData() {
+ if (OneToOne()) {
+- visible = new RunStyles();
+- expanded = new RunStyles();
+- heights = new RunStyles();
++ visible = new RunStyles<int, int>();
++ expanded = new RunStyles<int, int>();
++ heights = new RunStyles<int, int>();
+ foldDisplayTexts = new SparseVector<const char *>();
+ displayLines = new Partitioning<int>(4);
+ InsertLines(0, linesInDocument);
+diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.h
+--- a/src/ContractionState.h Thu Feb 01 09:07:21 2018 +1100
++++ b/src/ContractionState.h Thu Feb 01 09:22:14 2018 +1100
+@@ -17,9 +17,9 @@
+ */
+ class ContractionState {
+ // These contain 1 element for every document line.
+- RunStyles *visible;
+- RunStyles *expanded;
+- RunStyles *heights;
++ RunStyles<int, int> *visible;
++ RunStyles<int, int> *expanded;
++ RunStyles<int, int> *heights;
+ SparseVector<const char *> *foldDisplayTexts;
+ Partitioning<int> *displayLines;
+ Sci::Line linesInDocument;
+diff -r 1bd57324aa36 -r 89d992f380a1 src/Decoration.h
+--- a/src/Decoration.h Thu Feb 01 09:07:21 2018 +1100
++++ b/src/Decoration.h Thu Feb 01 09:22:14 2018 +1100
+@@ -12,7 +12,7 @@
+ class Decoration {
+ int indicator;
+ public:
+ Decoration *next;
+- RunStyles rs;
++ RunStyles<int, int> rs;
+
+ explicit Decoration(int indicator_);
+diff -r 1bd57324aa36 -r 89d992f380a1 src/RunStyles.cxx
+--- a/src/RunStyles.cxx Thu Feb 01 09:07:21 2018 +1100
++++ b/src/RunStyles.cxx Thu Feb 01 09:22:14 2018 +1100
+@@ -26,8 +26,9 @@
+ using namespace Scintilla;
+
+ // Find the first run at a position
+-int RunStyles::RunFromPosition(int position) const {
+- int run = starts->PartitionFromPosition(position);
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::RunFromPosition(DISTANCE position) const {
++ DISTANCE run = starts->PartitionFromPosition(position);
+ // Go to first element with this position
+ while ((run > 0) && (position == starts->PositionFromPartition(run-1))) {
+ run--;
+@@ -36,11 +37,12 @@
+ }
+
+ // If there is no run boundary at position, insert one continuing style.
+-int RunStyles::SplitRun(int position) {
+- int run = RunFromPosition(position);
+- const int posRun = starts->PositionFromPartition(run);
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::SplitRun(DISTANCE position) {
++ DISTANCE run = RunFromPosition(position);
++ const DISTANCE posRun = starts->PositionFromPartition(run);
+ if (posRun < position) {
+- int runStyle = ValueAt(position);
++ STYLE runStyle = ValueAt(position);
+ run++;
+ starts->InsertPartition(run, position);
+ styles->InsertValue(run, 1, runStyle);
+@@ -48,12 +50,14 @@
+ return run;
+ }
+
+-void RunStyles::RemoveRun(int run) {
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::RemoveRun(DISTANCE run) {
+ starts->RemovePartition(run);
+ styles->DeleteRange(run, 1);
+ }
+
+-void RunStyles::RemoveRunIfEmpty(int run) {
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::RemoveRunIfEmpty(DISTANCE run) {
+ if ((run < starts->Partitions()) && (starts->Partitions() > 1)) {
+ if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) {
+ RemoveRun(run);
+@@ -61,7 +65,8 @@
+ }
+ }
+
+-void RunStyles::RemoveRunIfSameAsPrevious(int run) {
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::RemoveRunIfSameAsPrevious(DISTANCE run) {
+ if ((run > 0) && (run < starts->Partitions())) {
+ if (styles->ValueAt(run-1) == styles->ValueAt(run)) {
+ RemoveRun(run);
+@@ -69,34 +74,39 @@
+ }
+ }
+
+-RunStyles::RunStyles() {
+- starts = new Partitioning<int>(8);
+- styles = new SplitVector<int>();
++template <typename DISTANCE, typename STYLE>
++RunStyles<DISTANCE, STYLE>::RunStyles() {
++ starts = new Partitioning<DISTANCE>(8);
++ styles = new SplitVector<STYLE>();
+ styles->InsertValue(0, 2, 0);
+ }
+
+-RunStyles::~RunStyles() {
++template <typename DISTANCE, typename STYLE>
++RunStyles<DISTANCE, STYLE>::~RunStyles() {
+ delete starts;
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+ }
+
+-int RunStyles::Length() const {
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::Length() const {
+ return starts->PositionFromPartition(starts->Partitions());
+ }
+
+-int RunStyles::ValueAt(int position) const {
++template <typename DISTANCE, typename STYLE>
++STYLE RunStyles<DISTANCE, STYLE>::ValueAt(DISTANCE position) const {
+ return styles->ValueAt(starts->PartitionFromPosition(position));
+ }
+
+-int RunStyles::FindNextChange(int position, int end) const {
+- const int run = starts->PartitionFromPosition(position);
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::FindNextChange(DISTANCE position, DISTANCE end) const {
++ const DISTANCE run = starts->PartitionFromPosition(position);
+ if (run < starts->Partitions()) {
+- const int runChange = starts->PositionFromPartition(run);
++ const DISTANCE runChange = starts->PositionFromPartition(run);
+ if (runChange > position)
+ return runChange;
+- const int nextChange = starts->PositionFromPartition(run + 1);
++ const DISTANCE nextChange = starts->PositionFromPartition(run + 1);
+ if (nextChange > position) {
+ return nextChange;
+ } else if (position < end) {
+@@ -105,23 +115,26 @@
+ }
+ }
+
+-int RunStyles::StartRun(int position) const {
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::StartRun(DISTANCE position) const {
+ return starts->PositionFromPartition(starts->PartitionFromPosition(position));
+ }
+
+-int RunStyles::EndRun(int position) const {
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::EndRun(DISTANCE position) const {
+ return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1);
+ }
+
+-bool RunStyles::FillRange(int &position, int value, int &fillLength) {
++template <typename DISTANCE, typename STYLE>
++bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DISTANCE &fillLength) {
+ if (fillLength <= 0) {
+ return false;
+ }
+- int end = position + fillLength;
++ DISTANCE end = position + fillLength;
+ if (end > Length()) {
+ return false;
+ }
+- int runEnd = RunFromPosition(end);
++ DISTANCE runEnd = RunFromPosition(end);
+ if (styles->ValueAt(runEnd) == value) {
+ // End already has value so trim range.
+ end = starts->PositionFromPartition(runEnd);
+@@ -133,7 +146,7 @@
+ } else {
+ runEnd = SplitRun(end);
+ }
+- int runStart = RunFromPosition(position);
++ DISTANCE runStart = RunFromPosition(position);
+ if (styles->ValueAt(runStart) == value) {
+ // Start is in expected value so trim range.
+ runStart++;
+@@ -148,7 +161,7 @@
+ if (runStart < runEnd) {
+ styles->SetValueAt(runStart, value);
+ // Remove each old run over the range
+- for (int run=runStart+1; run<runEnd; run++) {
++ for (DISTANCE run=runStart+1; run<runEnd; run++) {
+ RemoveRun(runStart+1);
+ }
+ runEnd = RunFromPosition(end);
+@@ -162,20 +175,22 @@
+ }
+ }
+
+-void RunStyles::SetValueAt(int position, int value) {
+- int len = 1;
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::SetValueAt(DISTANCE position, STYLE value) {
++ DISTANCE len = 1;
+ FillRange(position, value, len);
+ }
+
+-void RunStyles::InsertSpace(int position, int insertLength) {
+- int runStart = RunFromPosition(position);
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::InsertSpace(DISTANCE position, DISTANCE insertLength) {
++ DISTANCE runStart = RunFromPosition(position);
+ if (starts->PositionFromPartition(runStart) == position) {
+- int runStyle = ValueAt(position);
++ STYLE runStyle = ValueAt(position);
+ // Inserting at start of run so make previous longer
+ if (runStart == 0) {
+ // Inserting at start of document so ensure 0
+ if (runStyle) {
+- styles->SetValueAt(0, 0);
++ styles->SetValueAt(0, STYLE());
+ starts->InsertPartition(1, 0);
+ styles->InsertValue(1, 1, runStyle);
+ starts->InsertText(0, insertLength);
+@@ -195,20 +210,22 @@
+ }
+ }
+
+-void RunStyles::DeleteAll() {
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::DeleteAll() {
+ delete starts;
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+- starts = new Partitioning<int>(8);
+- styles = new SplitVector<int>();
++ starts = new Partitioning<DISTANCE>(8);
++ styles = new SplitVector<STYLE>();
+ styles->InsertValue(0, 2, 0);
+ }
+
+-void RunStyles::DeleteRange(int position, int deleteLength) {
+- int end = position + deleteLength;
+- int runStart = RunFromPosition(position);
+- int runEnd = RunFromPosition(end);
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::DeleteRange(DISTANCE position, DISTANCE deleteLength) {
++ DISTANCE end = position + deleteLength;
++ DISTANCE runStart = RunFromPosition(position);
++ DISTANCE runEnd = RunFromPosition(end);
+ if (runStart == runEnd) {
+ // Deleting from inside one run
+ starts->InsertText(runStart, -deleteLength);
+@@ -214,7 +231,7 @@
+ runEnd = SplitRun(end);
+ starts->InsertText(runStart, -deleteLength);
+ // Remove each old run over the range
+- for (int run=runStart; run<runEnd; run++) {
++ for (DISTANCE run=runStart; run<runEnd; run++) {
+ RemoveRun(runStart);
+ }
+ RemoveRunIfEmpty(runStart);
+@@ -222,11 +239,13 @@
+ }
+ }
+
+-int RunStyles::Runs() const {
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::Runs() const {
+ return starts->Partitions();
+ }
+
+-bool RunStyles::AllSame() const {
++template <typename DISTANCE, typename STYLE>
++bool RunStyles<DISTANCE, STYLE>::AllSame() const {
+ for (int run = 1; run < starts->Partitions(); run++) {
+ if (styles->ValueAt(run) != styles->ValueAt(run - 1))
+ return false;
+@@ -234,13 +253,15 @@
+ return true;
+ }
+
+-bool RunStyles::AllSameAs(int value) const {
++template <typename DISTANCE, typename STYLE>
++bool RunStyles<DISTANCE, STYLE>::AllSameAs(STYLE value) const {
+ return AllSame() && (styles->ValueAt(0) == value);
+ }
+
+-int RunStyles::Find(int value, int start) const {
++template <typename DISTANCE, typename STYLE>
++DISTANCE RunStyles<DISTANCE, STYLE>::Find(STYLE value, DISTANCE start) const {
+ if (start < Length()) {
+- int run = start ? RunFromPosition(start) : 0;
++ DISTANCE run = start ? RunFromPosition(start) : 0;
+ if (styles->ValueAt(run) == value)
+ return start;
+ run++;
+@@ -253,7 +274,8 @@
+ return -1;
+ }
+
+-void RunStyles::Check() const {
++template <typename DISTANCE, typename STYLE>
++void RunStyles<DISTANCE, STYLE>::Check() const {
+ if (Length() < 0) {
+ throw std::runtime_error("RunStyles: Length can not be negative.");
+ }
+@@ -263,9 +285,9 @@
+ if (starts->Partitions() != styles->Length()-1) {
+ throw std::runtime_error("RunStyles: Partitions and styles different lengths.");
+ }
+- int start=0;
++ DISTANCE start=0;
+ while (start < Length()) {
+- const int end = EndRun(start);
++ const DISTANCE end = EndRun(start);
+ if (start >= end) {
+ throw std::runtime_error("RunStyles: Partition is 0 length.");
+ }
+@@ -280,3 +302,9 @@
+ }
+ }
+ }
++
++#ifdef SCI_NAMESPACE
++template class Scintilla::RunStyles<int, int>;
++#else
++template class RunStyles<int, int>;
++#endif
+diff -r 1bd57324aa36 -r 89d992f380a1 src/RunStyles.h
+--- a/src/RunStyles.h Thu Feb 01 09:07:21 2018 +1100
++++ b/src/RunStyles.h Thu Feb 01 09:22:14 2018 +1100
+@@ -12,35 +12,36 @@
+ namespace Scintilla {
+ #endif
+
++template <typename DISTANCE, typename STYLE>
+ class RunStyles {
+ private:
+- Partitioning<int> *starts;
+- SplitVector<int> *styles;
+- int RunFromPosition(int position) const;
+- int SplitRun(int position);
+- void RemoveRun(int run);
+- void RemoveRunIfEmpty(int run);
+- void RemoveRunIfSameAsPrevious(int run);
++ Partitioning<DISTANCE> *starts;
++ SplitVector<STYLE> *styles;
++ DISTANCE RunFromPosition(DISTANCE position) const;
++ DISTANCE SplitRun(DISTANCE position);
++ void RemoveRun(DISTANCE run);
++ void RemoveRunIfEmpty(DISTANCE run);
++ void RemoveRunIfSameAsPrevious(DISTANCE run);
+ // Private so RunStyles objects can not be copied
+ RunStyles(const RunStyles &);
+ public:
+ RunStyles();
+ ~RunStyles();
+- int Length() const;
+- int ValueAt(int position) const;
+- int FindNextChange(int position, int end) const;
+- int StartRun(int position) const;
+- int EndRun(int position) const;
++ DISTANCE Length() const;
++ STYLE ValueAt(DISTANCE position) const;
++ DISTANCE FindNextChange(DISTANCE position, DISTANCE end) const;
++ DISTANCE StartRun(DISTANCE position) const;
++ DISTANCE EndRun(DISTANCE position) const;
+ // Returns true if some values may have changed
+- bool FillRange(int &position, int value, int &fillLength);
+- void SetValueAt(int position, int value);
+- void InsertSpace(int position, int insertLength);
++ bool FillRange(DISTANCE &position, STYLE value, DISTANCE &fillLength);
++ void SetValueAt(DISTANCE position, STYLE value);
++ void InsertSpace(DISTANCE position, DISTANCE insertLength);
+ void DeleteAll();
+- void DeleteRange(int position, int deleteLength);
+- int Runs() const;
++ void DeleteRange(DISTANCE position, DISTANCE deleteLength);
++ DISTANCE Runs() const;
+ bool AllSame() const;
+- bool AllSameAs(int value) const;
+- int Find(int value, int start) const;
++ bool AllSameAs(STYLE value) const;
++ DISTANCE Find(STYLE value, DISTANCE start) const;
+
+ void Check() const;
+ };
+diff -r 1bd57324aa36 -r 89d992f380a1 test/unit/testRunStyles.cxx
+--- a/test/unit/testRunStyles.cxx Thu Feb 01 09:07:21 2018 +1100
++++ b/test/unit/testRunStyles.cxx Thu Feb 01 09:22:14 2018 +1100
+@@ -22,7 +22,7 @@
+
+ TEST_CASE("RunStyles") {
+
+- RunStyles rs;
++ RunStyles<int, int> rs;
+
+ SECTION("IsEmptyInitially") {
+ REQUIRE(0 == rs.Length());
diff --git a/src/scintilla_backports/6448_431b814a54a6.patch b/src/scintilla_backports/6448_431b814a54a6.patch
new file mode 100644
index 00000000..a0fca282
--- /dev/null
+++ b/src/scintilla_backports/6448_431b814a54a6.patch
@@ -0,0 +1,307 @@
+# HG changeset patch
+# User Neil <nyamatongwe@gmail.com>
+# Date 1517542495 -39600
+# Node ID 431b814a54a62d81c8069655bbbebec7bda782e3
+# Parent 44ff2195a2026367e556e7dd9ef83af81a07219e
+Implement SC_DOCUMENTOPTION_STYLES_NONE.
+
+diff -r 44ff2195a202 -r 431b814a54a6 doc/ScintillaDoc.html
+--- a/doc/ScintillaDoc.html Fri Feb 02 08:37:32 2018 +1100
++++ b/doc/ScintillaDoc.html Fri Feb 02 14:34:55 2018 +1100
+@@ -119,7 +119,7 @@
+
+ <h1>Scintilla Documentation</h1>
+
+- <p>Last edited 31 January 2018 NH</p>
++ <p>Last edited 1 February 2018 NH</p>
+
+ <p>There is <a class="jump" href="Design.html">an overview of the internal design of
+ Scintilla</a>.<br />
+@@ -5743,9 +5743,38 @@
+ to allocate once rather than rely on the buffer growing as data is added.
+ If <code>SCI_CREATEDOCUMENT</code> fails then 0 is returned.</p>
+
+- <p>The <code class="parameter">documentOption</code> argument may be used in future versions
+- to choose between different document capabilities which affect memory allocation and performance.
+- The only valid value for now is <code>SC_DOCUMENTOPTION_DEFAULT</code> (0).</p>
++ <p id="documentOption">The <code class="parameter">documentOption</code> argument
++ chooses between different document capabilities which affect memory allocation and performance with
++ <code>SC_DOCUMENTOPTION_DEFAULT</code> (0) choosing standard options.
++ <code>SC_DOCUMENTOPTION_STYLES_NONE</code> (1) stops allocation of memory to style characters
++ which saves significant memory, often 40% with the whole document treated as being style 0.
++ Lexers may still produce visual styling by using indicators.</p>
++
++ <table class="standard" summary="Document options">
++ <tbody>
++ <tr>
++ <th align="left">Symbol</th>
++ <th align="left">Value</th>
++ <th align="left">Effect</th>
++ </tr>
++ </tbody>
++
++ <tbody valign="top">
++
++ <tr>
++ <td align="left">SC_DOCUMENTOPTION_DEFAULT</td>
++ <td align="left">0</td>
++ <td align="left">Standard behaviour</td>
++ </tr>
++
++ <tr>
++ <td align="left">SC_DOCUMENTOPTION_STYLES_NONE</td>
++ <td align="left">1</td>
++ <td align="left">Stop allocation of memory for styles and treat all text as style 0.</td>
++ </tr>
++
++ </tbody>
++ </table>
+
+ <p><b id="SCI_ADDREFDOCUMENT">SCI_ADDREFDOCUMENT(&lt;unused&gt;, document *doc)</b><br />
+ This increases the reference count of a document by 1. If you want to replace the current
+@@ -5788,9 +5817,8 @@
+ to allocate once rather than rely on the buffer growing as data is added.
+ If <code>SCI_CREATELOADER</code> fails then 0 is returned.</p>
+
+- <p>The <code class="parameter">documentOption</code> argument may be used in future versions
+- to choose between different document capabilities which affect memory allocation and performance.
+- The only valid value for now is <code>SC_DOCUMENTOPTION_DEFAULT</code> (0).</p>
++ <p>The <code class="parameter">documentOption</code> argument
++ is described in the <a class="seealso" href="#documentOption"><code>SCI_CREATEDOCUMENT</code></a> section.</p>
+
+ <h4>ILoader</h4>
+
+diff -r 44ff2195a202 -r 431b814a54a6 doc/ScintillaHistory.html
+--- a/doc/ScintillaHistory.html Fri Feb 02 08:37:32 2018 +1100
++++ b/doc/ScintillaHistory.html Fri Feb 02 14:34:55 2018 +1100
+@@ -539,6 +539,11 @@
+ </li>
+ <li>
+ SCI_CREATEDOCUMENT adds a bytes argument to allocate memory for an initial size.
++ SCI_CREATELOADER and SCI_CREATEDOCUMENT add a documentOption argument to
++ allow choosing different document capabilities.
++ </li>
++ <li>
++ Add SC_DOCUMENTOPTION_STYLES_NONE option to stop allocating memory for styles.
+ </li>
+ <li>
+ Add SCI_GETMOVEEXTENDSSELECTION to allow applications to add more
+diff -r 44ff2195a202 -r 431b814a54a6 include/Scintilla.h
+--- a/include/Scintilla.h Fri Feb 02 08:37:32 2018 +1100
++++ b/include/Scintilla.h Fri Feb 02 14:34:55 2018 +1100
+@@ -690,6 +690,7 @@
+ #define SCI_SETZOOM 2373
+ #define SCI_GETZOOM 2374
+ #define SC_DOCUMENTOPTION_DEFAULT 0
++#define SC_DOCUMENTOPTION_STYLES_NONE 1
+ #define SCI_CREATEDOCUMENT 2375
+ #define SCI_ADDREFDOCUMENT 2376
+ #define SCI_RELEASEDOCUMENT 2377
+diff -r 44ff2195a202 -r 431b814a54a6 include/Scintilla.iface
+--- a/include/Scintilla.iface Fri Feb 02 08:37:32 2018 +1100
++++ b/include/Scintilla.iface Fri Feb 02 14:34:55 2018 +1100
+@@ -1773,6 +1773,7 @@
+
+ enu DocumentOption=SC_DOCUMENTOPTION_
+ val SC_DOCUMENTOPTION_DEFAULT=0
++val SC_DOCUMENTOPTION_STYLES_NONE=1
+
+ # Create a new document object.
+ # Starts with reference count of 1 and not selected into editor.
+diff -r 44ff2195a202 -r 431b814a54a6 qt/ScintillaEdit/ScintillaDocument.cpp
+--- a/qt/ScintillaEdit/ScintillaDocument.cpp Fri Feb 02 08:37:32 2018 +1100
++++ b/qt/ScintillaEdit/ScintillaDocument.cpp Fri Feb 02 14:34:55 2018 +1100
+@@ -91,7 +91,7 @@
+ ScintillaDocument::ScintillaDocument(QObject *parent, void *pdoc_) :
+ QObject(parent), pdoc(pdoc_), docWatcher(0) {
+ if (!pdoc) {
+- pdoc = new Document();
++ pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ }
+ docWatcher = new WatcherHelper(this);
+ (static_cast<Document *>(pdoc))->AddRef();
+diff -r 44ff2195a202 -r 431b814a54a6 src/CellBuffer.cxx
+--- a/src/CellBuffer.cxx Fri Feb 02 08:37:32 2018 +1100
++++ b/src/CellBuffer.cxx Fri Feb 02 14:34:55 2018 +1100
+@@ -342,7 +342,8 @@
+ currentAction++;
+ }
+
+-CellBuffer::CellBuffer() {
++CellBuffer::CellBuffer(bool hasStyles_) :
++ hasStyles(hasStyles_) {
+ readOnly = false;
+ utf8LineEnds = 0;
+ collectingUndo = true;
+@@ -369,7 +370,7 @@
+ }
+
+ char CellBuffer::StyleAt(Sci::Position position) const {
+- return style.ValueAt(position);
++ return hasStyles ? style.ValueAt(position) : 0;
+ }
+
+ void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
+@@ -377,6 +378,10 @@
+ return;
+ if (position < 0)
+ return;
++ if (!hasStyles) {
++ std::fill(buffer, buffer + lengthRetrieve, static_cast<unsigned char>(0));
++ return;
++ }
+ if ((position + lengthRetrieve) > style.Length()) {
+ Platform::DebugPrintf("Bad GetStyleRange %d for %d of %d\n", position,
+ lengthRetrieve, style.Length());
+@@ -414,6 +419,9 @@
+ }
+
+ bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
++ if (!hasStyles) {
++ return false;
++ }
+ const char curVal = style.ValueAt(position);
+ if (curVal != styleValue) {
+ style.SetValueAt(position, styleValue);
+@@ -424,6 +432,9 @@
+ }
+
+ bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) {
++ if (!hasStyles) {
++ return false;
++ }
+ bool changed = false;
+ PLATFORM_ASSERT(lengthStyle == 0 ||
+ (lengthStyle > 0 && lengthStyle + position <= style.Length()));
+@@ -462,7 +473,9 @@
+
+ void CellBuffer::Allocate(Sci::Position newSize) {
+ substance.ReAllocate(newSize);
+- style.ReAllocate(newSize);
++ if (hasStyles) {
++ style.ReAllocate(newSize);
++ }
+ }
+
+ void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
+@@ -608,7 +621,9 @@
+ }
+
+ substance.InsertFromArray(position, s, 0, insertLength);
+- style.InsertValue(position, insertLength, 0);
++ if (hasStyles) {
++ style.InsertValue(position, insertLength, 0);
++ }
+
+ Sci::Line lineInsert = lv.LineFromPosition(position) + 1;
+ bool atLineStart = lv.LineStart(lineInsert-1) == position;
+@@ -738,7 +753,9 @@
+ }
+ }
+ substance.DeleteRange(position, deleteLength);
+- style.DeleteRange(position, deleteLength);
++ if (hasStyles) {
++ style.DeleteRange(position, deleteLength);
++ }
+ }
+
+ bool CellBuffer::SetUndoCollection(bool collectUndo) {
+diff -r 44ff2195a202 -r 431b814a54a6 src/CellBuffer.h
+--- a/src/CellBuffer.h Fri Feb 02 08:37:32 2018 +1100
++++ b/src/CellBuffer.h Fri Feb 02 14:34:55 2018 +1100
+@@ -133,6 +133,7 @@
+ */
+ class CellBuffer {
+ private:
++ bool hasStyles;
+ SplitVector<char> substance;
+ SplitVector<char> style;
+ bool readOnly;
+@@ -151,7 +152,7 @@
+
+ public:
+
+- CellBuffer();
++ CellBuffer(bool hasStyles_);
+ ~CellBuffer();
+
+ /// Retrieving positions outside the range of the buffer works and returns 0
+diff -r 44ff2195a202 -r 431b814a54a6 src/Document.cxx
+--- a/src/Document.cxx Fri Feb 02 08:37:32 2018 +1100
++++ b/src/Document.cxx Fri Feb 02 14:34:55 2018 +1100
+@@ -90,7 +90,8 @@
+ return 0;
+ }
+
+-Document::Document() {
++Document::Document(int options) :
++ cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0) {
+ refCount = 0;
+ #ifdef _WIN32
+ eolMode = SC_EOL_CRLF;
+diff -r 44ff2195a202 -r 431b814a54a6 src/Document.h
+--- a/src/Document.h Fri Feb 02 08:37:32 2018 +1100
++++ b/src/Document.h Fri Feb 02 14:34:55 2018 +1100
+@@ -265,7 +265,7 @@
+
+ DecorationList decorations;
+
+- Document();
++ Document(int options);
+ virtual ~Document();
+
+ int AddRef();
+diff -r 44ff2195a202 -r 431b814a54a6 src/EditModel.cxx
+--- a/src/EditModel.cxx Fri Feb 02 08:37:32 2018 +1100
++++ b/src/EditModel.cxx Fri Feb 02 14:34:55 2018 +1100
+@@ -69,7 +69,7 @@
+ hotspot = Range(Sci::invalidPosition);
+ hoverIndicatorPos = Sci::invalidPosition;
+ wrapWidth = LineLayout::wrapWidthInfinite;
+- pdoc = new Document();
++ pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ pdoc->AddRef();
+ }
+
+diff -r 44ff2195a202 -r 431b814a54a6 src/Editor.cxx
+--- a/src/Editor.cxx Fri Feb 02 08:37:32 2018 +1100
++++ b/src/Editor.cxx Fri Feb 02 14:34:55 2018 +1100
+@@ -5162,7 +5162,7 @@
+ pdoc->RemoveWatcher(this, 0);
+ pdoc->Release();
+ if (document == NULL) {
+- pdoc = new Document();
++ pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ } else {
+ pdoc = document;
+ }
+@@ -7554,7 +7554,7 @@
+ return 0;
+
+ case SCI_CREATEDOCUMENT: {
+- Document *doc = new Document();
++ Document *doc = new Document(static_cast<int>(lParam));
+ doc->AddRef();
+ doc->Allocate(static_cast<int>(wParam));
+ return reinterpret_cast<sptr_t>(doc);
+@@ -7569,7 +7569,7 @@
+ break;
+
+ case SCI_CREATELOADER: {
+- Document *doc = new Document();
++ Document *doc = new Document(static_cast<int>(lParam));
+ doc->AddRef();
+ doc->Allocate(static_cast<int>(wParam));
+ doc->SetUndoCollection(false);
+diff -r 44ff2195a202 -r 431b814a54a6 test/unit/testCellBuffer.cxx
+--- a/test/unit/testCellBuffer.cxx Fri Feb 02 08:37:32 2018 +1100
++++ b/test/unit/testCellBuffer.cxx Fri Feb 02 14:34:55 2018 +1100
+@@ -25,7 +25,7 @@
+ const char sText[] = "Scintilla";
+ const Sci::Position sLength = static_cast<Sci::Position>(strlen(sText));
+
+- CellBuffer cb;
++ CellBuffer cb(true);
+
+ SECTION("InsertOneLine") {
+ bool startSequence = false;
diff --git a/src/scintilla_backports/6449_1280ef150bbb.patch b/src/scintilla_backports/6449_1280ef150bbb.patch
new file mode 100644
index 00000000..0a8dfb11
--- /dev/null
+++ b/src/scintilla_backports/6449_1280ef150bbb.patch
@@ -0,0 +1,42 @@
+# HG changeset patch
+# User Dimitar Radev
+# Date 1517896632 -39600
+# Node ID 1280ef150bbb364e25d01bf04146305389123e78
+# Parent 431b814a54a62d81c8069655bbbebec7bda782e3
+[Bug #1983] Fix double tap word selection on Windows 10 1709 Fall Creators Update.
+Times of observed mouse events went backwards causing unsigned overflow.
+
+diff -r 431b814a54a6 -r 1280ef150bbb doc/ScintillaHistory.html
+--- a/doc/ScintillaHistory.html Fri Feb 02 14:34:55 2018 +1100
++++ b/doc/ScintillaHistory.html Tue Feb 06 16:57:12 2018 +1100
+@@ -519,6 +519,7 @@
+ </tr><tr>
+ <td>Georger Araújo</td>
+ <td>Tobias Kühne</td>
++ <td>Dimitar Radev</td>
+ </tr>
+ </table>
+ <p>
+@@ -557,6 +558,10 @@
+ Improve VHDL lexer's handling of character literals and escape characters in strings.
+ </li>
+ <li>
++ Fix double tap word selection on Windows 10 1709 Fall Creators Update.
++ <a href="http://sourceforge.net/p/scintilla/bugs/1983/">Bug #1983</a>.
++ </li>
++ <li>
+ Fix closing autocompletion lists on Cocoa for macOS 10.13 where the window
+ was emptying but staying visible.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1981/">Bug #1981</a>.
+diff -r 431b814a54a6 -r 1280ef150bbb src/Editor.cxx
+--- a/src/Editor.cxx Fri Feb 02 14:34:55 2018 +1100
++++ b/src/Editor.cxx Tue Feb 06 16:57:12 2018 +1100
+@@ -4455,7 +4455,7 @@
+ if (shift && !inSelMargin) {
+ SetSelection(newPos);
+ }
+- if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, doubleClickCloseThreshold)) {
++ if ((curTime < (lastClickTime+Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold)) {
+ //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);
+ SetMouseCapture(true);
+ FineTickerStart(tickScroll, 100, 10);