[geany/geany] 798849: Merge branch 'scintilla-update-335'

Colomban Wendling git-noreply at xxxxx
Wed Sep 18 13:23:06 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 18 Sep 2013 13:23:06 UTC
Commit:      798849b64cb3f21066814450e06d69fb5e3c707a
             https://github.com/geany/geany/commit/798849b64cb3f21066814450e06d69fb5e3c707a

Log Message:
-----------
Merge branch 'scintilla-update-335'


Modified Paths:
--------------
    NEWS
    scintilla/gtk/Converter.h
    scintilla/gtk/PlatGTK.cxx
    scintilla/gtk/ScintillaGTK.cxx
    scintilla/include/SciLexer.h
    scintilla/include/Scintilla.h
    scintilla/include/Scintilla.iface
    scintilla/lexers/LexAda.cxx
    scintilla/lexers/LexAsm.cxx
    scintilla/lexers/LexCOBOL.cxx
    scintilla/lexers/LexD.cxx
    scintilla/lexers/LexForth.cxx
    scintilla/lexers/LexHTML.cxx
    scintilla/lexers/LexLaTeX.cxx
    scintilla/lexers/LexLisp.cxx
    scintilla/lexers/LexNsis.cxx
    scintilla/lexers/LexOthers.cxx
    scintilla/lexers/LexPerl.cxx
    scintilla/lexers/LexPython.cxx
    scintilla/lexers/LexR.cxx
    scintilla/lexers/LexYAML.cxx
    scintilla/lexlib/Accessor.cxx
    scintilla/lexlib/CharacterSet.cxx
    scintilla/lexlib/LexerBase.cxx
    scintilla/lexlib/LexerModule.cxx
    scintilla/lexlib/LexerNoExceptions.cxx
    scintilla/lexlib/LexerNoExceptions.h
    scintilla/lexlib/LexerSimple.cxx
    scintilla/lexlib/StyleContext.cxx
    scintilla/lexlib/WordList.cxx
    scintilla/scintilla_changes.patch
    scintilla/src/AutoComplete.cxx
    scintilla/src/CaseConvert.cxx
    scintilla/src/Catalogue.cxx
    scintilla/src/CellBuffer.cxx
    scintilla/src/Decoration.cxx
    scintilla/src/Document.cxx
    scintilla/src/Document.h
    scintilla/src/Editor.cxx
    scintilla/src/Editor.h
    scintilla/src/ExternalLexer.cxx
    scintilla/src/FontQuality.h
    scintilla/src/KeyMap.h
    scintilla/src/LineMarker.h
    scintilla/src/Partitioning.h
    scintilla/src/PositionCache.cxx
    scintilla/src/PositionCache.h
    scintilla/src/RunStyles.cxx
    scintilla/src/ScintillaBase.cxx
    scintilla/src/SplitVector.h
    scintilla/src/UniConversion.cxx
    scintilla/src/UniConversion.h
    scintilla/src/UnicodeFromUTF8.h
    scintilla/src/ViewStyle.cxx
    scintilla/src/ViewStyle.h
    scintilla/src/XPM.cxx
    scintilla/version.txt

Modified: NEWS
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -7,7 +7,7 @@ Geany 1.24 (unreleased)
     * Fix custom GTK styles under KDE (#3607935).
 
     Editor
-    * Update Scintilla to version 3.3.3.
+    * Update Scintilla to version 3.3.5.
 
     Filetypes
     * Extend list of recognized keywords for SQL


Modified: scintilla/gtk/Converter.h
13 files changed, 13 insertions(+), 0 deletions(-)
===================================================================
@@ -3,6 +3,13 @@
 // Copyright 2004 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#ifndef CONVERTER_H
+#define CONVERTER_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 typedef GIConv ConverterHandle;
 const ConverterHandle iconvhBad = (ConverterHandle)(-1);
 // Since various versions of iconv can not agree on whether the src argument
@@ -68,3 +75,9 @@ class Converter {
 		}
 	}
 };
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif


Modified: scintilla/gtk/PlatGTK.cxx
24 files changed, 19 insertions(+), 5 deletions(-)
===================================================================
@@ -3,9 +3,9 @@
 // Copyright 1998-2004 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <stddef.h>
 #include <math.h>
 
@@ -46,6 +46,8 @@
 #define IS_WIDGET_FOCUSSED(w) (GTK_WIDGET_HAS_FOCUS(w))
 #endif
 
+static const double kPi = 3.14159265358979323846;
+
 // The Pango version guard for pango_units_from_double and pango_units_to_double 
 // is more complex than simply implementing these here.
 
@@ -739,7 +741,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi
 }
 
 static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) {
-	double degrees = M_PI / 180.0;
+	double degrees = kPi / 180.0;
 
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
 	cairo_new_sub_path(context);
@@ -820,7 +822,7 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
 void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
 	PenColour(back);
 	cairo_arc(context, (rc.left + rc.right) / 2 + 0.5, (rc.top + rc.bottom) / 2 + 0.5,
-		Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*M_PI);
+		Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi);
 	cairo_fill_preserve(context);
 	PenColour(fore);
 	cairo_stroke(context);
@@ -1051,8 +1053,10 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION
 					}
 				}
 				if (positionsCalculated < 1 ) {
-					// Either Latin1 or DBCS conversion failed so treat as Latin1.
+					// Either 8-bit or DBCS conversion failed so treat as 8-bit.
 					SetConverter(PFont(font_)->characterSet);
+					const bool rtlCheck = PFont(font_)->characterSet == SC_CHARSET_HEBREW ||
+						PFont(font_)->characterSet == SC_CHARSET_ARABIC;
 					std::string utfForm = UTF8FromIconv(conv, s, len);
 					if (utfForm.empty()) {
 						utfForm = UTF8FromLatin1(s, len);
@@ -1060,13 +1064,23 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION
 					pango_layout_set_text(layout, utfForm.c_str(), utfForm.length());
 					int i = 0;
 					int clusterStart = 0;
-					// Each Latin1 input character may take 1 or 2 bytes in UTF-8
+					// Each 8-bit input character may take 1 or 2 bytes in UTF-8
 					// and groups of up to 3 may be represented as ligatures.
 					ClusterIterator iti(layout, utfForm.length());
 					while (!iti.finished) {
 						iti.Next();
 						int clusterEnd = iti.curIndex;
 						int ligatureLength = g_utf8_strlen(utfForm.c_str() + clusterStart, clusterEnd - clusterStart);
+						if (rtlCheck && ((clusterEnd <= clusterStart) || (ligatureLength == 0) || (ligatureLength > 3))) {
+							// Something has gone wrong: exit quickly but pretend all the characters are equally spaced:
+							int widthLayout = 0;
+							pango_layout_get_size(layout, &widthLayout, NULL);
+							XYPOSITION widthTotal = doubleFromPangoUnits(widthLayout);
+							for (int bytePos=0;bytePos<lenPositions; bytePos++) {
+								positions[bytePos] = widthTotal / lenPositions * (bytePos + 1);
+							}
+							return;
+						}
 						PLATFORM_ASSERT(ligatureLength > 0 && ligatureLength <= 3);
 						for (int charInLig=0; charInLig<ligatureLength; charInLig++) {
 							positions[i++] = iti.position - (ligatureLength - 1 - charInLig) * iti.distance / ligatureLength;


Modified: scintilla/gtk/ScintillaGTK.cxx
15 files changed, 9 insertions(+), 6 deletions(-)
===================================================================
@@ -3,14 +3,14 @@
 // Copyright 1998-2004 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
-#include <new>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <assert.h>
 #include <ctype.h>
 #include <time.h>
+#include <assert.h>
 
+#include <new>
 #include <string>
 #include <vector>
 #include <map>
@@ -1096,7 +1096,7 @@ PRectangle ScintillaGTK::GetClientRectangle() {
 	PRectangle rc = wMain.GetClientPosition();
 	if (verticalScrollBarVisible)
 		rc.right -= verticalScrollBarWidth;
-	if (horizontalScrollBarVisible && (wrapState == eWrapNone))
+	if (horizontalScrollBarVisible && !Wrapping())
 		rc.bottom -= horizontalScrollBarHeight;
 	// Move to origin
 	rc.right -= rc.left;
@@ -1676,7 +1676,7 @@ void ScintillaGTK::Resize(int width, int height) {
 
 	// These allocations should never produce negative sizes as they would wrap around to huge
 	// unsigned numbers inside GTK+ causing warnings.
-	bool showSBHorizontal = horizontalScrollBarVisible && (wrapState == eWrapNone);
+	bool showSBHorizontal = horizontalScrollBarVisible && !Wrapping();
 
 	GtkAllocation alloc;
 	if (showSBHorizontal) {
@@ -1845,7 +1845,7 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
 				// If mouse released on scroll bar then the position is relative to the
 				// scrollbar, not the drawing window so just repeat the most recent point.
 				pt = sciThis->ptMouseLast;
-			sciThis->ButtonUp(pt, event->time, (event->state & 4) != 0);
+			sciThis->ButtonUp(pt, event->time, (event->state & GDK_CONTROL_MASK) != 0);
 		}
 	} catch (...) {
 		sciThis->errorStatus = SC_STATUS_FAILURE;
@@ -1962,7 +1962,10 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) {
 		//Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
 		//	sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
 		Point pt(x, y);
-		sciThis->ButtonMove(pt);
+		int modifiers = ((event->state & GDK_SHIFT_MASK) != 0 ? SCI_SHIFT : 0) |
+		                ((event->state & GDK_CONTROL_MASK) != 0 ? SCI_CTRL : 0) |
+		                ((event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0 ? SCI_ALT : 0);
+		sciThis->ButtonMoveWithModifiers(pt, modifiers);
 	} catch (...) {
 		sciThis->errorStatus = SC_STATUS_FAILURE;
 	}


Modified: scintilla/include/SciLexer.h
14 files changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -122,6 +122,7 @@
 #define SCLEX_VISUALPROLOG 107
 #define SCLEX_LITERATEHASKELL 108
 #define SCLEX_STTXT 109
+#define SCLEX_KVIRC 110
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -1647,6 +1648,19 @@
 #define SCE_STTXT_DATETIME 16
 #define SCE_STTXT_VARS 17
 #define SCE_STTXT_PRAGMAS 18
+#define SCE_KVIRC_DEFAULT 0
+#define SCE_KVIRC_COMMENT 1
+#define SCE_KVIRC_COMMENTBLOCK 2
+#define SCE_KVIRC_STRING 3
+#define SCE_KVIRC_WORD 4
+#define SCE_KVIRC_KEYWORD 5
+#define SCE_KVIRC_FUNCTION_KEYWORD 6
+#define SCE_KVIRC_FUNCTION 7
+#define SCE_KVIRC_VARIABLE 8
+#define SCE_KVIRC_NUMBER 9
+#define SCE_KVIRC_OPERATOR 10
+#define SCE_KVIRC_STRING_FUNCTION 11
+#define SCE_KVIRC_STRING_VARIABLE 12
 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
 
 #endif


Modified: scintilla/include/Scintilla.h
6 files changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -673,6 +673,7 @@
 #define SCI_PARAUPEXTEND 2416
 #define SCI_POSITIONBEFORE 2417
 #define SCI_POSITIONAFTER 2418
+#define SCI_POSITIONRELATIVE 2670
 #define SCI_COPYRANGE 2419
 #define SCI_COPYTEXT 2420
 #define SC_SEL_STREAM 0
@@ -801,6 +802,8 @@
 #define SCI_ADDUNDOACTION 2560
 #define SCI_CHARPOSITIONFROMPOINT 2561
 #define SCI_CHARPOSITIONFROMPOINTCLOSE 2562
+#define SCI_SETMOUSESELECTIONRECTANGULARSWITCH 2668
+#define SCI_GETMOUSESELECTIONRECTANGULARSWITCH 2669
 #define SCI_SETMULTIPLESELECTION 2563
 #define SCI_GETMULTIPLESELECTION 2564
 #define SCI_SETADDITIONALSELECTIONTYPING 2565
@@ -877,6 +880,9 @@
 #define SCI_VCHOMEDISPLAYEXTEND 2653
 #define SCI_GETCARETLINEVISIBLEALWAYS 2654
 #define SCI_SETCARETLINEVISIBLEALWAYS 2655
+#define SCI_SETREPRESENTATION 2665
+#define SCI_GETREPRESENTATION 2666
+#define SCI_CLEARREPRESENTATION 2667
 #define SCI_STARTRECORD 3001
 #define SCI_STOPRECORD 3002
 #define SCI_SETLEXER 4001


Modified: scintilla/include/Scintilla.iface
35 files changed, 35 insertions(+), 0 deletions(-)
===================================================================
@@ -1756,6 +1756,10 @@ fun position PositionBefore=2417(position pos,)
 # page into account. Maximum value returned is the last position in the document.
 fun position PositionAfter=2418(position pos,)
 
+# Given a valid document position, return a position that differs in a number
+# of characters. Returned value is always between 0 and last position in document.
+fun position PositionRelative=2670(position pos, int relative)
+
 # Copy a range of text to the clipboard. Positions are clipped into the document.
 fun void CopyRange=2419(position start, position end)
 
@@ -2127,6 +2131,12 @@ fun position CharPositionFromPoint=2561(int x, int y)
 # Return INVALID_POSITION if not close to text.
 fun position CharPositionFromPointClose=2562(int x, int y)
 
+# Set whether switching to rectangular mode while selecting with the mouse is allowed.
+set void SetMouseSelectionRectangularSwitch=2668(bool mouseSelectionRectangularSwitch,)
+
+# Whether switching to rectangular mode while selecting with the mouse is allowed.
+get bool GetMouseSelectionRectangularSwitch=2669(,)
+
 # Set whether multiple selections can be made
 set void SetMultipleSelection=2563(bool multipleSelection,)
 
@@ -2326,6 +2336,15 @@ get bool GetCaretLineVisibleAlways=2654(,)
 # Sets the caret line to always visible.
 set void SetCaretLineVisibleAlways=2655(bool alwaysVisible,)
 
+# Set the way a character is drawn.
+set void SetRepresentation=2665(string encodedCharacter, string representation)
+
+# Set the way a character is drawn.
+get int GetRepresentation=2666(string encodedCharacter, stringresult representation)
+
+# Remove a character representation.
+fun void ClearRepresentation=2667(string encodedCharacter,)
+
 # Start notifying the container of all key presses and commands.
 fun void StartRecord=3001(,)
 
@@ -2580,6 +2599,7 @@ val SCLEX_OSCRIPT=106
 val SCLEX_VISUALPROLOG=107
 val SCLEX_LITERATEHASKELL=108
 val SCLEX_STTXT=109
+val SCLEX_KVIRC=110
 
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -4305,6 +4325,21 @@ val SCE_STTXT_IDENTIFIER=15
 val SCE_STTXT_DATETIME=16
 val SCE_STTXT_VARS=17
 val SCE_STTXT_PRAGMAS=18
+# Lexical states for SCLEX_KVIRC
+lex KVIrc=SCLEX_KVIRC SCLEX_KVIRC_
+val SCE_KVIRC_DEFAULT=0
+val SCE_KVIRC_COMMENT=1
+val SCE_KVIRC_COMMENTBLOCK=2
+val SCE_KVIRC_STRING=3
+val SCE_KVIRC_WORD=4
+val SCE_KVIRC_KEYWORD=5
+val SCE_KVIRC_FUNCTION_KEYWORD=6
+val SCE_KVIRC_FUNCTION=7
+val SCE_KVIRC_VARIABLE=8
+val SCE_KVIRC_NUMBER=9
+val SCE_KVIRC_OPERATOR=10
+val SCE_KVIRC_STRING_FUNCTION=11
+val SCE_KVIRC_STRING_VARIABLE=12
 
 # Events
 


Modified: scintilla/lexers/LexAda.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -511,5 +511,5 @@ static inline bool IsWordCharacter(int ch) {
 }
 
 static inline bool IsWordStartCharacter(int ch) {
-	return (isascii(ch) && isalpha(ch)) || ch == '_';
+	return (IsASCII(ch) && isalpha(ch)) || ch == '_';
 }


Modified: scintilla/lexers/LexAsm.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -344,7 +344,7 @@ void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle,
 		if (sc.state == SCE_ASM_DEFAULT) {
 			if (sc.ch == ';'){
 				sc.SetState(SCE_ASM_COMMENT);
-			} else if (isascii(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && isascii(sc.chNext) && isdigit(sc.chNext)))) {
+			} else if (IsASCII(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && IsASCII(sc.chNext) && isdigit(sc.chNext)))) {
 				sc.SetState(SCE_ASM_NUMBER);
 			} else if (IsAWordStart(sc.ch)) {
 				sc.SetState(SCE_ASM_IDENTIFIER);


Modified: scintilla/lexers/LexCOBOL.cxx
8 files changed, 5 insertions(+), 3 deletions(-)
===================================================================
@@ -44,13 +44,13 @@ inline bool isCOBOLoperator(char ch)
 
 inline bool isCOBOLwordchar(char ch)
     {
-    return isascii(ch) && (isalnum(ch) || ch == '-');
+    return IsASCII(ch) && (isalnum(ch) || ch == '-');
 
     }
 
 inline bool isCOBOLwordstart(char ch)
     {
-    return isascii(ch) && isalnum(ch);
+    return IsASCII(ch) && isalnum(ch);
     }
 
 static int CountBits(int nBits)
@@ -90,6 +90,8 @@ static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &k
     WordList& c_keywords = *keywordlists[2];
 
     char s[100];
+    s[0] = '\0';
+    s[1] = '\0';
     getRange(start, end, styler, s, sizeof(s));
 
     char chAttr = SCE_C_IDENTIFIER;
@@ -205,7 +207,7 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle,
         }
 
         if (state == SCE_C_DEFAULT) {
-            if (isCOBOLwordstart(ch) || (ch == '$' && isascii(chNext) && isalpha(chNext))) {
+            if (isCOBOLwordstart(ch) || (ch == '$' && IsASCII(chNext) && isalpha(chNext))) {
                 ColourTo(styler, i-1, state);
                 state = SCE_C_IDENTIFIER;
             } else if (column == 6 && ch == '*') {


Modified: scintilla/lexers/LexD.cxx
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -41,15 +41,15 @@
 // Underscore, letter, digit and universal alphas from C99 Appendix D.
 
 static bool IsWordStart(int ch) {
-	return (isascii(ch) && (isalpha(ch) || ch == '_')) || !isascii(ch);
+	return (IsASCII(ch) && (isalpha(ch) || ch == '_')) || !IsASCII(ch);
 }
 
 static bool IsWord(int ch) {
-	return (isascii(ch) && (isalnum(ch) || ch == '_')) || !isascii(ch);
+	return (IsASCII(ch) && (isalnum(ch) || ch == '_')) || !IsASCII(ch);
 }
 
 static bool IsDoxygen(int ch) {
-	if (isascii(ch) && islower(ch))
+	if (IsASCII(ch) && islower(ch))
 		return true;
 	if (ch == '$' || ch == '@' || ch == '\\' ||
 		ch == '&' || ch == '#' || ch == '<' || ch == '>' ||
@@ -267,7 +267,7 @@ void SCI_METHOD LexerD::Lex(unsigned int startPos, int length, int initStyle, ID
 				break;
 			case SCE_D_NUMBER:
 				// We accept almost anything because of hex. and number suffixes
-				if (isascii(sc.ch) && (isalnum(sc.ch) || sc.ch == '_')) {
+				if (IsASCII(sc.ch) && (isalnum(sc.ch) || sc.ch == '_')) {
 					continue;
 				} else if (sc.ch == '.' && sc.chNext != '.' && !numFloat) {
 					// Don't parse 0..2 as number.


Modified: scintilla/lexers/LexForth.cxx
16 files changed, 8 insertions(+), 8 deletions(-)
===================================================================
@@ -123,29 +123,29 @@ static void ColouriseForthDoc(unsigned int startPos, int length, int initStyle,
 					(sc.atLineStart || IsASpaceChar(sc.chPrev)) &&
 					(sc.atLineEnd   || IsASpaceChar(sc.chNext))) {
 				sc.SetState(SCE_FORTH_COMMENT_ML);
-			} else if (	(sc.ch == '$' && (isascii(sc.chNext) && isxdigit(sc.chNext))) ) {
+			} else if (	(sc.ch == '$' && (IsASCII(sc.chNext) && isxdigit(sc.chNext))) ) {
 				// number starting with $ is a hex number
 				sc.SetState(SCE_FORTH_NUMBER);
-				while(sc.More() && isascii(sc.chNext) && isxdigit(sc.chNext))
+				while(sc.More() && IsASCII(sc.chNext) && isxdigit(sc.chNext))
 					sc.Forward();
-			} else if ( (sc.ch == '%' && (isascii(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1'))) ) {
+			} else if ( (sc.ch == '%' && (IsASCII(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1'))) ) {
 				// number starting with % is binary
 				sc.SetState(SCE_FORTH_NUMBER);
-				while(sc.More() && isascii(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1'))
+				while(sc.More() && IsASCII(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1'))
 					sc.Forward();
-			} else if (	isascii(sc.ch) &&
-						(isxdigit(sc.ch) || ((sc.ch == '.' || sc.ch == '-') && isascii(sc.chNext) && isxdigit(sc.chNext)) )
+			} else if (	IsASCII(sc.ch) &&
+						(isxdigit(sc.ch) || ((sc.ch == '.' || sc.ch == '-') && IsASCII(sc.chNext) && isxdigit(sc.chNext)) )
 					){
 				sc.SetState(SCE_FORTH_NUMBER);
 			} else if (IsAWordStart(sc.ch)) {
 				sc.SetState(SCE_FORTH_IDENTIFIER);
 			} else if (sc.ch == '{') {
 				sc.SetState(SCE_FORTH_LOCALE);
-			} else if (sc.ch == ':' && isascii(sc.chNext) && isspace(sc.chNext)) {
+			} else if (sc.ch == ':' && IsASCII(sc.chNext) && isspace(sc.chNext)) {
 				// highlight word definitions e.g.  : GCD ( n n -- n ) ..... ;
 				//                                  ^ ^^^
 				sc.SetState(SCE_FORTH_DEFWORD);
-				while(sc.More() && isascii(sc.chNext) && isspace(sc.chNext))
+				while(sc.More() && IsASCII(sc.chNext) && isspace(sc.chNext))
 					sc.Forward();
 			} else if (sc.ch == ';' &&
 					(sc.atLineStart || IsASpaceChar(sc.chPrev)) &&


Modified: scintilla/lexers/LexHTML.cxx
19 files changed, 10 insertions(+), 9 deletions(-)
===================================================================
@@ -43,7 +43,7 @@ static inline bool IsAWordStart(const int ch) {
 }
 
 inline bool IsOperator(int ch) {
-	if (isascii(ch) && isalnum(ch))
+	if (IsASCII(ch) && isalnum(ch))
 		return false;
 	// '.' left out as it is used to make up numbers
 	if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
@@ -446,12 +446,12 @@ static int StateForScript(script_type scriptLanguage) {
 }
 
 static inline bool issgmlwordchar(int ch) {
-	return !isascii(ch) ||
+	return !IsASCII(ch) ||
 		(isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[');
 }
 
 static inline bool IsPhpWordStart(int ch) {
-	return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f);
+	return (IsASCII(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f);
 }
 
 static inline bool IsPhpWordChar(int ch) {
@@ -1233,7 +1233,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 					styler.ColourTo(i - 2, StateToPrint);
 				}
 				state = SCE_H_SGML_COMMENT;
-			} else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) {
+			} else if (IsASCII(ch) && isalpha(ch) && (chPrev == '%')) {
 				styler.ColourTo(i - 2, StateToPrint);
 				state = SCE_H_SGML_ENTITY;
 			} else if (ch == '#') {
@@ -1312,6 +1312,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 				styler.ColourTo(i - 2, StateToPrint);
 				state = SCE_H_SGML_COMMENT;
 			}
+			break;
 		case SCE_H_SGML_DOUBLESTRING:
 			if (ch == '\"') {
 				styler.ColourTo(i, StateToPrint);
@@ -1351,7 +1352,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 			}
 			break;
 		case SCE_H_SGML_SPECIAL:
-			if (!(isascii(ch) && isupper(ch))) {
+			if (!(IsASCII(ch) && isupper(ch))) {
 				styler.ColourTo(i - 1, StateToPrint);
 				if (isalnum(ch)) {
 					state = SCE_H_SGML_ERROR;
@@ -1364,7 +1365,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 			if (ch == ';') {
 				styler.ColourTo(i, StateToPrint);
 				state = SCE_H_SGML_DEFAULT;
-			} else if (!(isascii(ch) && isalnum(ch)) && ch != '-' && ch != '.') {
+			} else if (!(IsASCII(ch) && isalnum(ch)) && ch != '-' && ch != '.') {
 				styler.ColourTo(i, SCE_H_SGML_ERROR);
 				state = SCE_H_SGML_DEFAULT;
 			}
@@ -1374,9 +1375,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 				styler.ColourTo(i, StateToPrint);
 				state = SCE_H_DEFAULT;
 			}
-			if (ch != '#' && !(isascii(ch) && isalnum(ch))	// Should check that '#' follows '&', but it is unlikely anyway...
+			if (ch != '#' && !(IsASCII(ch) && isalnum(ch))	// Should check that '#' follows '&', but it is unlikely anyway...
 				&& ch != '.' && ch != '-' && ch != '_' && ch != ':') { // valid in XML
-				if (!isascii(ch))	// Possibly start of a multibyte character so don't allow this byte to be in entity style
+				if (!IsASCII(ch))	// Possibly start of a multibyte character so don't allow this byte to be in entity style
 					styler.ColourTo(i-1, SCE_H_TAGUNKNOWN);
 				else
 					styler.ColourTo(i, SCE_H_TAGUNKNOWN);
@@ -1702,7 +1703,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 		case SCE_HJ_REGEX:
 			if (ch == '\r' || ch == '\n' || ch == '/') {
 				if (ch == '/') {
-					while (isascii(chNext) && islower(chNext)) {   // gobble regex flags
+					while (IsASCII(chNext) && islower(chNext)) {   // gobble regex flags
 						i++;
 						ch = chNext;
 						chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));


Modified: scintilla/lexers/LexLaTeX.cxx
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -99,7 +99,7 @@ static bool latexIsBlankAndNL(int ch) {
 }
 
 static bool latexIsLetter(int ch) {
-	return isascii(ch) && isalpha(ch);
+	return IsASCII(ch) && isalpha(ch);
 }
 
 static bool latexIsTagValid(int &i, int l, Accessor &styler) {
@@ -224,7 +224,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle
 					chNext = styler.SafeGetCharAt(i + 1);
 				} else if (chNext == '\r' || chNext == '\n') {
 					styler.ColourTo(i, SCE_L_ERROR);
-				} else if (isascii(chNext)) {
+				} else if (IsASCII(chNext)) {
 					styler.ColourTo(i + 1, SCE_L_SHORTCMD);
 					if (chNext == '(') {
 						mode = 1;
@@ -340,7 +340,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle
 					chNext = styler.SafeGetCharAt(i + 1);
 				} else if (chNext == '\r' || chNext == '\n') {
 					styler.ColourTo(i, SCE_L_ERROR);
-				} else if (isascii(chNext)) {
+				} else if (IsASCII(chNext)) {
 					if (chNext == ')') {
 						mode = 0;
 						state = SCE_L_DEFAULT;
@@ -382,7 +382,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle
 					chNext = styler.SafeGetCharAt(i + 1);
 				} else if (chNext == '\r' || chNext == '\n') {
 					styler.ColourTo(i, SCE_L_ERROR);
-				} else if (isascii(chNext)) {
+				} else if (IsASCII(chNext)) {
 					if (chNext == ']') {
 						mode = 0;
 						state = SCE_L_DEFAULT;


Modified: scintilla/lexers/LexLisp.cxx
6 files changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -33,7 +33,7 @@
 #define SCE_LISP_MACRO_DISPATCH 31
 
 static inline bool isLispoperator(char ch) {
-	if (isascii(ch) && isalnum(ch))
+	if (IsASCII(ch) && isalnum(ch))
 		return false;
 	if (ch == '\'' || ch == '`' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '{' || ch == '}')
 		return true;
@@ -41,7 +41,7 @@ static inline bool isLispoperator(char ch) {
 }
 
 static inline bool isLispwordstart(char ch) {
-	return isascii(ch) && ch != ';'  && !isspacechar(ch) && !isLispoperator(ch) &&
+	return IsASCII(ch) && ch != ';'  && !isspacechar(ch) && !isLispoperator(ch) &&
 		ch != '\n' && ch != '\r' &&  ch != '\"';
 }
 
@@ -142,7 +142,7 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W
 				}
 			}
 		} else if (state == SCE_LISP_MACRO_DISPATCH) {
-			if (!(isascii(ch) && isdigit(ch))) {
+			if (!(IsASCII(ch) && isdigit(ch))) {
 				if (ch != 'r' && ch != 'R' && (i - styler.GetStartSegment()) > 1) {
 					state = SCE_LISP_DEFAULT;
 				} else {


Modified: scintilla/lexers/LexNsis.cxx
2 files changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -180,6 +180,8 @@ static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keyw
     bUserVars = true;
 
 	char s[100];
+	s[0] = '\0';
+	s[1] = '\0';
 
 	WordList &Functions = *keywordLists[0];
 	WordList &Variables = *keywordLists[1];


Modified: scintilla/lexers/LexOthers.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -40,7 +40,7 @@ static bool Is1To9(char ch) {
 }
 
 static bool IsAlphabetic(int ch) {
-	return isascii(ch) && isalpha(ch);
+	return IsASCII(ch) && isalpha(ch);
 }
 
 static inline bool AtEOL(Accessor &styler, unsigned int i) {


Modified: scintilla/lexers/LexPerl.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1626,7 +1626,7 @@ void SCI_METHOD LexerPerl::Fold(unsigned int startPos, int length, int /* initSt
 				else if (styler.Match(i, "=head"))
 					podHeading = PodHeadingLevel(i, styler);
 			} else if (style == SCE_PL_DATASECTION) {
-				if (ch == '=' && isascii(chNext) && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE)
+				if (ch == '=' && IsASCII(chNext) && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE)
 					levelCurrent++;
 				else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE)
 					levelCurrent = (levelCurrent & ~PERL_HEADFOLD_MASK) - 1;


Modified: scintilla/lexers/LexPython.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -385,7 +385,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
 					base_n_number = false;
 					sc.SetState(SCE_P_NUMBER);
 				}
-			} else if ((isascii(sc.ch) && isoperator(static_cast<char>(sc.ch))) || sc.ch == '`') {
+			} else if ((IsASCII(sc.ch) && isoperator(static_cast<char>(sc.ch))) || sc.ch == '`') {
 				sc.SetState(SCE_P_OPERATOR);
 			} else if (sc.ch == '#') {
 				sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);


Modified: scintilla/lexers/LexR.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -37,7 +37,7 @@ static inline bool IsAWordStart(const int ch) {
 }
 
 static inline bool IsAnOperator(const int ch) {
-	if (isascii(ch) && isalnum(ch))
+	if (IsASCII(ch) && isalnum(ch))
 		return false;
 	// '.' left out as it is used to make up numbers
 	if (ch == '-' || ch == '+' || ch == '!' || ch == '~' ||


Modified: scintilla/lexers/LexYAML.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -150,7 +150,7 @@ static void ColouriseYAMLLine(
 			} else {
 				unsigned int i2 = i;
 				while ((i < lengthLine) && lineBuffer[i]) {
-					if (!(isascii(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
+					if (!(IsASCII(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
 						styler.ColourTo(endPos, SCE_YAML_DEFAULT);
 						return;
 					}


Modified: scintilla/lexlib/Accessor.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,9 +8,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <ctype.h>
 
 #include "ILexer.h"
 #include "Scintilla.h"


Modified: scintilla/lexlib/CharacterSet.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,8 +8,8 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <assert.h>
 
 #include "CharacterSet.h"


Modified: scintilla/lexlib/LexerBase.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,9 +8,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <ctype.h>
 
 #include "ILexer.h"
 #include "Scintilla.h"


Modified: scintilla/lexlib/LexerModule.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,9 +8,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <ctype.h>
 
 #include <string>
 


Modified: scintilla/lexlib/LexerNoExceptions.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,9 +8,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <ctype.h>
 
 #include "ILexer.h"
 #include "Scintilla.h"


Modified: scintilla/lexlib/LexerNoExceptions.h
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -5,8 +5,8 @@
 // Copyright 1998-2010 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
-#ifndef LexerNoExceptions_H
-#define LexerNoExceptions_H
+#ifndef LEXERNOEXCEPTIONS_H
+#define LEXERNOEXCEPTIONS_H
 
 #ifdef SCI_NAMESPACE
 namespace Scintilla {


Modified: scintilla/lexlib/LexerSimple.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,9 +8,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <ctype.h>
 
 #include <string>
 


Modified: scintilla/lexlib/StyleContext.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -7,8 +7,8 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <assert.h>
 
 #include "ILexer.h"


Modified: scintilla/lexlib/WordList.cxx
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -7,8 +7,8 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 
 #include <algorithm>
@@ -103,7 +103,7 @@ void WordList::Clear() {
 #ifdef _MSC_VER
 
 static bool cmpWords(const char *a, const char *b) {
-	return strcmp(a, b) == -1;
+	return strcmp(a, b) < 0;
 }
 
 #else


Modified: scintilla/scintilla_changes.patch
5 files changed, 3 insertions(+), 2 deletions(-)
===================================================================
@@ -31,9 +31,9 @@ diff --git b/scintilla/src/Catalogue.cxx a/scintilla/src/Catalogue.cxx
 index 84d003e..37b2a3c 100644
 +++ scintilla/src/Catalogue.cxx
 --- scintilla/src/Catalogue.cxx
-@@ -81,110 +81,47 @@ int Scintilla_LinkLexers() {
+@@ -81,111 +81,47 @@ int Scintilla_LinkLexers() {
  
- //++Autogenerated -- run src/LexGen.py to regenerate
+ //++Autogenerated -- run scripts/LexGen.py to regenerate
  //**\(\tLINK_LEXER(\*);\n\)
 -	LINK_LEXER(lmA68k);
  	LINK_LEXER(lmAbaqus);
@@ -80,6 +80,7 @@ index 84d003e..37b2a3c 100644
  	LINK_LEXER(lmHTML);
 -	LINK_LEXER(lmInno);
 -	LINK_LEXER(lmKix);
+-	LINK_LEXER(lmKVIrc);
  	LINK_LEXER(lmLatex);
  	LINK_LEXER(lmLISP);
 -	LINK_LEXER(lmLiterateHaskell);


Modified: scintilla/src/AutoComplete.cxx
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -10,9 +10,9 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include <algorithm>
 #include <string>
 #include <vector>
+#include <algorithm>
 
 #include "Platform.h"
 


Modified: scintilla/src/CaseConvert.cxx
256 files changed, 128 insertions(+), 128 deletions(-)
===================================================================
@@ -2,7 +2,7 @@
 // Encoding: UTF-8
 /** @file CaseConvert.cxx
  ** Case fold characters and convert them to upper or lower case.
- ** Tables automatically regenerated by scripts/GenerateCharacterCategory.py
+ ** Tables automatically regenerated by scripts/GenerateCaseConvert.py
  ** Should only be rarely regenerated for new versions of Unicode.
  **/
 // Copyright 2013 by Neil Hodgson <neilh at scintilla.org>
@@ -232,132 +232,132 @@
 // Original | Folded | Upper | Lower |
 //++Autogenerated -- start of section automatically generated
 //**2 \(\*\n\)
-"µ|μ|Μ||"
-"ß|ss|SS||"
-"İ|i̇||i̇|"
-"ı||I||"
-"ʼn|ʼn|ʼN||"
-"ſ|s|S||"
-"Dž|dž|DŽ|dž|"
-"Lj|lj|LJ|lj|"
-"Nj|nj|NJ|nj|"
-"ǰ|ǰ|J̌||"
-"Dz|dz|DZ|dz|"
-"ͅ|ι|Ι||"
-"ΐ|ΐ|Ϊ́||"
-"ΰ|ΰ|Ϋ́||"
-"ς|σ|Σ||"
-"ϐ|β|Β||"
-"ϑ|θ|Θ||"
-"ϕ|φ|Φ||"
-"ϖ|π|Π||"
-"ϰ|κ|Κ||"
-"ϱ|ρ|Ρ||"
-"ϴ|θ||θ|"
-"ϵ|ε|Ε||"
-"և|եւ|ԵՒ||"
-"ẖ|ẖ|H̱||"
-"ẗ|ẗ|T̈||"
-"ẘ|ẘ|W̊||"
-"ẙ|ẙ|Y̊||"
-"ẚ|aʾ|Aʾ||"
-"ẛ|ṡ|Ṡ||"
-"ẞ|ss||ß|"
-"ὐ|ὐ|Υ̓||"
-"ὒ|ὒ|Υ̓̀||"
-"ὔ|ὔ|Υ̓́||"
-"ὖ|ὖ|Υ̓͂||"
-"ᾀ|ἀι|ἈΙ||"
-"ᾁ|ἁι|ἉΙ||"
-"ᾂ|ἂι|ἊΙ||"
-"ᾃ|ἃι|ἋΙ||"
-"ᾄ|ἄι|ἌΙ||"
-"ᾅ|ἅι|ἍΙ||"
-"ᾆ|ἆι|ἎΙ||"
-"ᾇ|ἇι|ἏΙ||"
-"ᾈ|ἀι|ἈΙ|ᾀ|"
-"ᾉ|ἁι|ἉΙ|ᾁ|"
-"ᾊ|ἂι|ἊΙ|ᾂ|"
-"ᾋ|ἃι|ἋΙ|ᾃ|"
-"ᾌ|ἄι|ἌΙ|ᾄ|"
-"ᾍ|ἅι|ἍΙ|ᾅ|"
-"ᾎ|ἆι|ἎΙ|ᾆ|"
-"ᾏ|ἇι|ἏΙ|ᾇ|"
-"ᾐ|ἠι|ἨΙ||"
-"ᾑ|ἡι|ἩΙ||"
-"ᾒ|ἢι|ἪΙ||"
-"ᾓ|ἣι|ἫΙ||"
-"ᾔ|ἤι|ἬΙ||"
-"ᾕ|ἥι|ἭΙ||"
-"ᾖ|ἦι|ἮΙ||"
-"ᾗ|ἧι|ἯΙ||"
-"ᾘ|ἠι|ἨΙ|ᾐ|"
-"ᾙ|ἡι|ἩΙ|ᾑ|"
-"ᾚ|ἢι|ἪΙ|ᾒ|"
-"ᾛ|ἣι|ἫΙ|ᾓ|"
-"ᾜ|ἤι|ἬΙ|ᾔ|"
-"ᾝ|ἥι|ἭΙ|ᾕ|"
-"ᾞ|ἦι|ἮΙ|ᾖ|"
-"ᾟ|ἧι|ἯΙ|ᾗ|"
-"ᾠ|ὠι|ὨΙ||"
-"ᾡ|ὡι|ὩΙ||"
-"ᾢ|ὢι|ὪΙ||"
-"ᾣ|ὣι|ὫΙ||"
-"ᾤ|ὤι|ὬΙ||"
-"ᾥ|ὥι|ὭΙ||"
-"ᾦ|ὦι|ὮΙ||"
-"ᾧ|ὧι|ὯΙ||"
-"ᾨ|ὠι|ὨΙ|ᾠ|"
-"ᾩ|ὡι|ὩΙ|ᾡ|"
-"ᾪ|ὢι|ὪΙ|ᾢ|"
-"ᾫ|ὣι|ὫΙ|ᾣ|"
-"ᾬ|ὤι|ὬΙ|ᾤ|"
-"ᾭ|ὥι|ὭΙ|ᾥ|"
-"ᾮ|ὦι|ὮΙ|ᾦ|"
-"ᾯ|ὧι|ὯΙ|ᾧ|"
-"ᾲ|ὰι|ᾺΙ||"
-"ᾳ|αι|ΑΙ||"
-"ᾴ|άι|ΆΙ||"
-"ᾶ|ᾶ|Α͂||"
-"ᾷ|ᾶι|Α͂Ι||"
-"ᾼ|αι|ΑΙ|ᾳ|"
-"ι|ι|Ι||"
-"ῂ|ὴι|ῊΙ||"
-"ῃ|ηι|ΗΙ||"
-"ῄ|ήι|ΉΙ||"
-"ῆ|ῆ|Η͂||"
-"ῇ|ῆι|Η͂Ι||"
-"ῌ|ηι|ΗΙ|ῃ|"
-"ῒ|ῒ|Ϊ̀||"
-"ΐ|ΐ|Ϊ́||"
-"ῖ|ῖ|Ι͂||"
-"ῗ|ῗ|Ϊ͂||"
-"ῢ|ῢ|Ϋ̀||"
-"ΰ|ΰ|Ϋ́||"
-"ῤ|ῤ|Ρ̓||"
-"ῦ|ῦ|Υ͂||"
-"ῧ|ῧ|Ϋ͂||"
-"ῲ|ὼι|ῺΙ||"
-"ῳ|ωι|ΩΙ||"
-"ῴ|ώι|ΏΙ||"
-"ῶ|ῶ|Ω͂||"
-"ῷ|ῶι|Ω͂Ι||"
-"ῼ|ωι|ΩΙ|ῳ|"
-"Ω|ω||ω|"
-"K|k||k|"
-"Å|å||å|"
-"ff|ff|FF||"
-"fi|fi|FI||"
-"fl|fl|FL||"
-"ffi|ffi|FFI||"
-"ffl|ffl|FFL||"
-"ſt|st|ST||"
-"st|st|ST||"
-"ﬓ|մն|ՄՆ||"
-"ﬔ|մե|ՄԵ||"
-"ﬕ|մի|ՄԻ||"
-"ﬖ|վն|ՎՆ||"
-"ﬗ|մխ|ՄԽ||"
+"\xc2\xb5|\xce\xbc|\xce\x9c||"
+"\xc3\x9f|ss|SS||"
+"\xc4\xb0|i\xcc\x87||i\xcc\x87|"
+"\xc4\xb1||I||"
+"\xc5\x89|\xca\xbcn|\xca\xbcN||"
+"\xc5\xbf|s|S||"
+"\xc7\x85|\xc7\x86|\xc7\x84|\xc7\x86|"
+"\xc7\x88|\xc7\x89|\xc7\x87|\xc7\x89|"
+"\xc7\x8b|\xc7\x8c|\xc7\x8a|\xc7\x8c|"
+"\xc7\xb0|j\xcc\x8c|J\xcc\x8c||"
+"\xc7\xb2|\xc7\xb3|\xc7\xb1|\xc7\xb3|"
+"\xcd\x85|\xce\xb9|\xce\x99||"
+"\xce\x90|\xce\xb9\xcc\x88\xcc\x81|\xce\x99\xcc\x88\xcc\x81||"
+"\xce\xb0|\xcf\x85\xcc\x88\xcc\x81|\xce\xa5\xcc\x88\xcc\x81||"
+"\xcf\x82|\xcf\x83|\xce\xa3||"
+"\xcf\x90|\xce\xb2|\xce\x92||"
+"\xcf\x91|\xce\xb8|\xce\x98||"
+"\xcf\x95|\xcf\x86|\xce\xa6||"
+"\xcf\x96|\xcf\x80|\xce\xa0||"
+"\xcf\xb0|\xce\xba|\xce\x9a||"
+"\xcf\xb1|\xcf\x81|\xce\xa1||"
+"\xcf\xb4|\xce\xb8||\xce\xb8|"
+"\xcf\xb5|\xce\xb5|\xce\x95||"
+"\xd6\x87|\xd5\xa5\xd6\x82|\xd4\xb5\xd5\x92||"
+"\xe1\xba\x96|h\xcc\xb1|H\xcc\xb1||"
+"\xe1\xba\x97|t\xcc\x88|T\xcc\x88||"
+"\xe1\xba\x98|w\xcc\x8a|W\xcc\x8a||"
+"\xe1\xba\x99|y\xcc\x8a|Y\xcc\x8a||"
+"\xe1\xba\x9a|a\xca\xbe|A\xca\xbe||"
+"\xe1\xba\x9b|\xe1\xb9\xa1|\xe1\xb9\xa0||"
+"\xe1\xba\x9e|ss||\xc3\x9f|"
+"\xe1\xbd\x90|\xcf\x85\xcc\x93|\xce\xa5\xcc\x93||"
+"\xe1\xbd\x92|\xcf\x85\xcc\x93\xcc\x80|\xce\xa5\xcc\x93\xcc\x80||"
+"\xe1\xbd\x94|\xcf\x85\xcc\x93\xcc\x81|\xce\xa5\xcc\x93\xcc\x81||"
+"\xe1\xbd\x96|\xcf\x85\xcc\x93\xcd\x82|\xce\xa5\xcc\x93\xcd\x82||"
+"\xe1\xbe\x80|\xe1\xbc\x80\xce\xb9|\xe1\xbc\x88\xce\x99||"
+"\xe1\xbe\x81|\xe1\xbc\x81\xce\xb9|\xe1\xbc\x89\xce\x99||"
+"\xe1\xbe\x82|\xe1\xbc\x82\xce\xb9|\xe1\xbc\x8a\xce\x99||"
+"\xe1\xbe\x83|\xe1\xbc\x83\xce\xb9|\xe1\xbc\x8b\xce\x99||"
+"\xe1\xbe\x84|\xe1\xbc\x84\xce\xb9|\xe1\xbc\x8c\xce\x99||"
+"\xe1\xbe\x85|\xe1\xbc\x85\xce\xb9|\xe1\xbc\x8d\xce\x99||"
+"\xe1\xbe\x86|\xe1\xbc\x86\xce\xb9|\xe1\xbc\x8e\xce\x99||"
+"\xe1\xbe\x87|\xe1\xbc\x87\xce\xb9|\xe1\xbc\x8f\xce\x99||"
+"\xe1\xbe\x88|\xe1\xbc\x80\xce\xb9|\xe1\xbc\x88\xce\x99|\xe1\xbe\x80|"
+"\xe1\xbe\x89|\xe1\xbc\x81\xce\xb9|\xe1\xbc\x89\xce\x99|\xe1\xbe\x81|"
+"\xe1\xbe\x8a|\xe1\xbc\x82\xce\xb9|\xe1\xbc\x8a\xce\x99|\xe1\xbe\x82|"
+"\xe1\xbe\x8b|\xe1\xbc\x83\xce\xb9|\xe1\xbc\x8b\xce\x99|\xe1\xbe\x83|"
+"\xe1\xbe\x8c|\xe1\xbc\x84\xce\xb9|\xe1\xbc\x8c\xce\x99|\xe1\xbe\x84|"
+"\xe1\xbe\x8d|\xe1\xbc\x85\xce\xb9|\xe1\xbc\x8d\xce\x99|\xe1\xbe\x85|"
+"\xe1\xbe\x8e|\xe1\xbc\x86\xce\xb9|\xe1\xbc\x8e\xce\x99|\xe1\xbe\x86|"
+"\xe1\xbe\x8f|\xe1\xbc\x87\xce\xb9|\xe1\xbc\x8f\xce\x99|\xe1\xbe\x87|"
+"\xe1\xbe\x90|\xe1\xbc\xa0\xce\xb9|\xe1\xbc\xa8\xce\x99||"
+"\xe1\xbe\x91|\xe1\xbc\xa1\xce\xb9|\xe1\xbc\xa9\xce\x99||"
+"\xe1\xbe\x92|\xe1\xbc\xa2\xce\xb9|\xe1\xbc\xaa\xce\x99||"
+"\xe1\xbe\x93|\xe1\xbc\xa3\xce\xb9|\xe1\xbc\xab\xce\x99||"
+"\xe1\xbe\x94|\xe1\xbc\xa4\xce\xb9|\xe1\xbc\xac\xce\x99||"
+"\xe1\xbe\x95|\xe1\xbc\xa5\xce\xb9|\xe1\xbc\xad\xce\x99||"
+"\xe1\xbe\x96|\xe1\xbc\xa6\xce\xb9|\xe1\xbc\xae\xce\x99||"
+"\xe1\xbe\x97|\xe1\xbc\xa7\xce\xb9|\xe1\xbc\xaf\xce\x99||"
+"\xe1\xbe\x98|\xe1\xbc\xa0\xce\xb9|\xe1\xbc\xa8\xce\x99|\xe1\xbe\x90|"
+"\xe1\xbe\x99|\xe1\xbc\xa1\xce\xb9|\xe1\xbc\xa9\xce\x99|\xe1\xbe\x91|"
+"\xe1\xbe\x9a|\xe1\xbc\xa2\xce\xb9|\xe1\xbc\xaa\xce\x99|\xe1\xbe\x92|"
+"\xe1\xbe\x9b|\xe1\xbc\xa3\xce\xb9|\xe1\xbc\xab\xce\x99|\xe1\xbe\x93|"
+"\xe1\xbe\x9c|\xe1\xbc\xa4\xce\xb9|\xe1\xbc\xac\xce\x99|\xe1\xbe\x94|"
+"\xe1\xbe\x9d|\xe1\xbc\xa5\xce\xb9|\xe1\xbc\xad\xce\x99|\xe1\xbe\x95|"
+"\xe1\xbe\x9e|\xe1\xbc\xa6\xce\xb9|\xe1\xbc\xae\xce\x99|\xe1\xbe\x96|"
+"\xe1\xbe\x9f|\xe1\xbc\xa7\xce\xb9|\xe1\xbc\xaf\xce\x99|\xe1\xbe\x97|"
+"\xe1\xbe\xa0|\xe1\xbd\xa0\xce\xb9|\xe1\xbd\xa8\xce\x99||"
+"\xe1\xbe\xa1|\xe1\xbd\xa1\xce\xb9|\xe1\xbd\xa9\xce\x99||"
+"\xe1\xbe\xa2|\xe1\xbd\xa2\xce\xb9|\xe1\xbd\xaa\xce\x99||"
+"\xe1\xbe\xa3|\xe1\xbd\xa3\xce\xb9|\xe1\xbd\xab\xce\x99||"
+"\xe1\xbe\xa4|\xe1\xbd\xa4\xce\xb9|\xe1\xbd\xac\xce\x99||"
+"\xe1\xbe\xa5|\xe1\xbd\xa5\xce\xb9|\xe1\xbd\xad\xce\x99||"
+"\xe1\xbe\xa6|\xe1\xbd\xa6\xce\xb9|\xe1\xbd\xae\xce\x99||"
+"\xe1\xbe\xa7|\xe1\xbd\xa7\xce\xb9|\xe1\xbd\xaf\xce\x99||"
+"\xe1\xbe\xa8|\xe1\xbd\xa0\xce\xb9|\xe1\xbd\xa8\xce\x99|\xe1\xbe\xa0|"
+"\xe1\xbe\xa9|\xe1\xbd\xa1\xce\xb9|\xe1\xbd\xa9\xce\x99|\xe1\xbe\xa1|"
+"\xe1\xbe\xaa|\xe1\xbd\xa2\xce\xb9|\xe1\xbd\xaa\xce\x99|\xe1\xbe\xa2|"
+"\xe1\xbe\xab|\xe1\xbd\xa3\xce\xb9|\xe1\xbd\xab\xce\x99|\xe1\xbe\xa3|"
+"\xe1\xbe\xac|\xe1\xbd\xa4\xce\xb9|\xe1\xbd\xac\xce\x99|\xe1\xbe\xa4|"
+"\xe1\xbe\xad|\xe1\xbd\xa5\xce\xb9|\xe1\xbd\xad\xce\x99|\xe1\xbe\xa5|"
+"\xe1\xbe\xae|\xe1\xbd\xa6\xce\xb9|\xe1\xbd\xae\xce\x99|\xe1\xbe\xa6|"
+"\xe1\xbe\xaf|\xe1\xbd\xa7\xce\xb9|\xe1\xbd\xaf\xce\x99|\xe1\xbe\xa7|"
+"\xe1\xbe\xb2|\xe1\xbd\xb0\xce\xb9|\xe1\xbe\xba\xce\x99||"
+"\xe1\xbe\xb3|\xce\xb1\xce\xb9|\xce\x91\xce\x99||"
+"\xe1\xbe\xb4|\xce\xac\xce\xb9|\xce\x86\xce\x99||"
+"\xe1\xbe\xb6|\xce\xb1\xcd\x82|\xce\x91\xcd\x82||"
+"\xe1\xbe\xb7|\xce\xb1\xcd\x82\xce\xb9|\xce\x91\xcd\x82\xce\x99||"
+"\xe1\xbe\xbc|\xce\xb1\xce\xb9|\xce\x91\xce\x99|\xe1\xbe\xb3|"
+"\xe1\xbe\xbe|\xce\xb9|\xce\x99||"
+"\xe1\xbf\x82|\xe1\xbd\xb4\xce\xb9|\xe1\xbf\x8a\xce\x99||"
+"\xe1\xbf\x83|\xce\xb7\xce\xb9|\xce\x97\xce\x99||"
+"\xe1\xbf\x84|\xce\xae\xce\xb9|\xce\x89\xce\x99||"
+"\xe1\xbf\x86|\xce\xb7\xcd\x82|\xce\x97\xcd\x82||"
+"\xe1\xbf\x87|\xce\xb7\xcd\x82\xce\xb9|\xce\x97\xcd\x82\xce\x99||"
+"\xe1\xbf\x8c|\xce\xb7\xce\xb9|\xce\x97\xce\x99|\xe1\xbf\x83|"
+"\xe1\xbf\x92|\xce\xb9\xcc\x88\xcc\x80|\xce\x99\xcc\x88\xcc\x80||"
+"\xe1\xbf\x93|\xce\xb9\xcc\x88\xcc\x81|\xce\x99\xcc\x88\xcc\x81||"
+"\xe1\xbf\x96|\xce\xb9\xcd\x82|\xce\x99\xcd\x82||"
+"\xe1\xbf\x97|\xce\xb9\xcc\x88\xcd\x82|\xce\x99\xcc\x88\xcd\x82||"
+"\xe1\xbf\xa2|\xcf\x85\xcc\x88\xcc\x80|\xce\xa5\xcc\x88\xcc\x80||"
+"\xe1\xbf\xa3|\xcf\x85\xcc\x88\xcc\x81|\xce\xa5\xcc\x88\xcc\x81||"
+"\xe1\xbf\xa4|\xcf\x81\xcc\x93|\xce\xa1\xcc\x93||"
+"\xe1\xbf\xa6|\xcf\x85\xcd\x82|\xce\xa5\xcd\x82||"
+"\xe1\xbf\xa7|\xcf\x85\xcc\x88\xcd\x82|\xce\xa5\xcc\x88\xcd\x82||"
+"\xe1\xbf\xb2|\xe1\xbd\xbc\xce\xb9|\xe1\xbf\xba\xce\x99||"
+"\xe1\xbf\xb3|\xcf\x89\xce\xb9|\xce\xa9\xce\x99||"
+"\xe1\xbf\xb4|\xcf\x8e\xce\xb9|\xce\x8f\xce\x99||"
+"\xe1\xbf\xb6|\xcf\x89\xcd\x82|\xce\xa9\xcd\x82||"
+"\xe1\xbf\xb7|\xcf\x89\xcd\x82\xce\xb9|\xce\xa9\xcd\x82\xce\x99||"
+"\xe1\xbf\xbc|\xcf\x89\xce\xb9|\xce\xa9\xce\x99|\xe1\xbf\xb3|"
+"\xe2\x84\xa6|\xcf\x89||\xcf\x89|"
+"\xe2\x84\xaa|k||k|"
+"\xe2\x84\xab|\xc3\xa5||\xc3\xa5|"
+"\xef\xac\x80|ff|FF||"
+"\xef\xac\x81|fi|FI||"
+"\xef\xac\x82|fl|FL||"
+"\xef\xac\x83|ffi|FFI||"
+"\xef\xac\x84|ffl|FFL||"
+"\xef\xac\x85|st|ST||"
+"\xef\xac\x86|st|ST||"
+"\xef\xac\x93|\xd5\xb4\xd5\xb6|\xd5\x84\xd5\x86||"
+"\xef\xac\x94|\xd5\xb4\xd5\xa5|\xd5\x84\xd4\xb5||"
+"\xef\xac\x95|\xd5\xb4\xd5\xab|\xd5\x84\xd4\xbb||"
+"\xef\xac\x96|\xd5\xbe\xd5\xb6|\xd5\x8e\xd5\x86||"
+"\xef\xac\x97|\xd5\xb4\xd5\xad|\xd5\x84\xd4\xbd||"
 
 //--Autogenerated -- end of section automatically generated
 ;
@@ -382,7 +382,7 @@ class CaseConverter : public ICaseConverter {
 	};
 	typedef std::vector<CharacterConversion> CharacterToConversion;
 	CharacterToConversion characterToConversion;
-	// The parallel arrays 
+	// The parallel arrays
 	std::vector<int> characters;
 	std::vector<ConversionString> conversions;
 


Modified: scintilla/src/Catalogue.cxx
11 files changed, 3 insertions(+), 8 deletions(-)
===================================================================
@@ -1,5 +1,5 @@
 // Scintilla source code edit control
-/** @file KeyWords.cxx
+/** @file Catalogue.cxx
  ** Colourise for particular languages.
  **/
 // Copyright 1998-2002 by Neil Hodgson <neilh at scintilla.org>
@@ -7,8 +7,8 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <stdarg.h>
 #include <assert.h>
 
@@ -60,11 +60,6 @@ void Catalogue::AddLexerModule(LexerModule *plm) {
 	lexerCatalogue.push_back(plm);
 }
 
-// Alternative historical name for Scintilla_LinkLexers
-int wxForceScintillaLexers(void) {
-	return Scintilla_LinkLexers();
-}
-
 // To add or remove a lexer, add or remove its file and run LexGen.py.
 
 // Force a reference to all of the Scintilla lexers so that the linker will
@@ -79,7 +74,7 @@ int Scintilla_LinkLexers() {
 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
 
-//++Autogenerated -- run src/LexGen.py to regenerate
+//++Autogenerated -- run scripts/LexGen.py to regenerate
 //**\(\tLINK_LEXER(\*);\n\)
 	LINK_LEXER(lmAbaqus);
 	LINK_LEXER(lmAda);


Modified: scintilla/src/CellBuffer.cxx
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -5,9 +5,9 @@
 // Copyright 1998-2001 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
-#include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
 #include <stdarg.h>
 
 #include <algorithm>


Modified: scintilla/src/Decoration.cxx
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -4,9 +4,9 @@
 // Copyright 1998-2007 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
-#include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
 #include <stdarg.h>
 
 #include <algorithm>


Modified: scintilla/src/Document.cxx
23 files changed, 16 insertions(+), 7 deletions(-)
===================================================================
@@ -38,7 +38,7 @@
 #endif
 
 static inline bool IsPunctuation(char ch) {
-	return isascii(ch) && ispunct(ch);
+	return IsASCII(ch) && ispunct(ch);
 }
 
 void LexInterface::Colourise(int start, int end) {
@@ -825,7 +825,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
 		return length;
 	int lastSpaceBreak = -1;
 	int lastPunctuationBreak = -1;
-	int lastEncodingAllowedBreak = -1;
+	int lastEncodingAllowedBreak = 0;
 	for (int j=0; j < lengthSegment;) {
 		unsigned char ch = static_cast<unsigned char>(text[j]);
 		if (j > 0) {
@@ -854,6 +854,15 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
 	return lastEncodingAllowedBreak;
 }
 
+EncodingFamily Document::CodePageFamily() const {
+	if (SC_CP_UTF8 == dbcsCodePage)
+		return efUnicode;
+	else if (dbcsCodePage)
+		return efDBCS;
+	else
+		return efEightBit;
+}
+
 void Document::ModifiedAt(int pos) {
 	if (endStyled > pos)
 		endStyled = pos;
@@ -1965,10 +1974,10 @@ int Document::WordPartLeft(int pos) {
 					--pos;
 				if (!isspacechar(cb.CharAt(pos)))
 					++pos;
-			} else if (!isascii(startChar)) {
-				while (pos > 0 && !isascii(cb.CharAt(pos)))
+			} else if (!IsASCII(startChar)) {
+				while (pos > 0 && !IsASCII(cb.CharAt(pos)))
 					--pos;
-				if (isascii(cb.CharAt(pos)))
+				if (IsASCII(cb.CharAt(pos)))
 					++pos;
 			} else {
 				++pos;
@@ -1986,8 +1995,8 @@ int Document::WordPartRight(int pos) {
 			++pos;
 		startChar = cb.CharAt(pos);
 	}
-	if (!isascii(startChar)) {
-		while (pos < length && !isascii(cb.CharAt(pos)))
+	if (!IsASCII(startChar)) {
+		while (pos < length && !IsASCII(cb.CharAt(pos)))
 			++pos;
 	} else if (IsLowerCase(startChar)) {
 		while (pos < length && IsLowerCase(cb.CharAt(pos)))


Modified: scintilla/src/Document.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -19,6 +19,8 @@
 typedef int Position;
 const Position invalidPosition = -1;
 
+enum EncodingFamily { efEightBit, efUnicode, efDBCS };
+
 /**
  * The range class represents a range of text in a document.
  * The two values are not sorted as one end may be more significant than the other
@@ -266,6 +268,7 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader {
 	int SCI_METHOD CodePage() const;
 	bool SCI_METHOD IsDBCSLeadByte(char ch) const;
 	int SafeSegment(const char *text, int length, int lengthSegment) const;
+	EncodingFamily CodePageFamily() const;
 
 	// Gateways to modifying document
 	void ModifiedAt(int pos);


Modified: scintilla/src/Editor.cxx
737 files changed, 379 insertions(+), 358 deletions(-)
===================================================================
@@ -101,6 +101,12 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
 	return true;
 }
 
+PrintParameters::PrintParameters() {
+	magnification = 0;
+	colourMode = SC_PRINT_NORMAL;
+	wrapState = eWrapWord;
+}
+
 Editor::Editor() {
 	ctrlID = 0;
 
@@ -108,11 +114,7 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
 	technology = SC_TECHNOLOGY_DEFAULT;
 	scaleRGBAImage = 100;
 
-	printMagnification = 0;
-	printColourMode = SC_PRINT_NORMAL;
-	printWrapState = eWrapWord;
 	cursorMode = SC_CURSORNORMAL;
-	controlCharSymbol = 0;	/* Draw the control characters */
 
 	hasFocus = false;
 	hideSelection = false;
@@ -167,6 +169,7 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
 	endAtLastLine = true;
 	caretSticky = SC_CARETSTICKY_OFF;
 	marginOptions = SC_MARGINOPTION_NONE;
+	mouseSelectionRectangularSwitch = false;
 	multipleSelection = false;
 	additionalSelectionTyping = false;
 	multiPasteMode = SC_MULTIPASTE_ONCE;
@@ -197,9 +200,9 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
 	bracesMatchStyle = STYLE_BRACEBAD;
 	highlightGuideColumn = 0;
 
-	theEdge = 0;
-
 	paintState = notPainting;
+	paintAbandonedByStyling = false;
+	paintingAllText = false;
 	willRedrawAll = false;
 
 	modEventMask = SC_MODEVENTMASKALL;
@@ -212,24 +215,17 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
 	foldFlags = 0;
 	foldAutomatic = 0;
 
-	wrapState = eWrapNone;
 	wrapWidth = LineLayout::wrapWidthInfinite;
-	wrapVisualFlags = 0;
-	wrapVisualFlagsLocation = 0;
-	wrapVisualStartIndent = 0;
-	wrapIndentMode = SC_WRAPINDENT_FIXED;
 
 	convertPastes = true;
 
-	marginNumberPadding = 3;
-	ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side
-	lastSegItalicsOffset = 2;
-
 	hsStart = -1;
 	hsEnd = -1;
 
 	llc.SetLevel(LineLayoutCache::llcCaret);
 	posCache.SetSize(0x400);
+
+	SetRepresentations();
 }
 
 Editor::~Editor() {
@@ -244,6 +240,47 @@ void Editor::Finalise() {
 	CancelModes();
 }
 
+void Editor::SetRepresentations() {
+	reprs.Clear();
+
+	// C0 control set
+	const char *reps[] = {
+		"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
+		"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
+		"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
+		"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
+	};
+	for (size_t j=0; j < (sizeof(reps) / sizeof(reps[0])); j++) {
+		char c[2] = { static_cast<char>(j), 0 };
+		reprs.SetRepresentation(c, reps[j]);
+	}
+
+	// C1 control set
+	// As well as Unicode mode, ISO-8859-1 should use these
+	if (IsUnicodeMode()) {
+		const char *repsC1[] = {
+			"PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA",
+			"HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3",
+			"DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA",
+			"SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC"
+		};
+		for (size_t j=0; j < (sizeof(repsC1) / sizeof(repsC1[0])); j++) {
+			char c1[3] = { '\xc2',  static_cast<char>(0x80+j), 0 };
+			reprs.SetRepresentation(c1, repsC1[j]);
+		}
+	}
+
+	// UTF-8 invalid bytes
+	if (IsUnicodeMode()) {
+		for (int k=0x80; k < 0x100; k++) {
+			char hiByte[2] = {  static_cast<char>(k), 0 };
+			char hexits[4];
+			sprintf(hexits, "x%2X", k);
+			reprs.SetRepresentation(hiByte, hexits);
+		}
+	}
+}
+
 void Editor::DropGraphics(bool freeObjects) {
 	if (freeObjects) {
 		delete pixmapLine;
@@ -309,7 +346,7 @@ void Editor::RefreshStyleData() {
 		stylesValid = true;
 		AutoSurface surface(this);
 		if (surface) {
-			vs.Refresh(*surface);
+			vs.Refresh(*surface, pdoc->tabInChars);
 		}
 		SetScrollBars();
 		SetRectangularRange();
@@ -944,6 +981,7 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
 	}
 	if (!sel.IsRectangular() && (selt == Selection::selRectangle)) {
 		// Switching to rectangular
+		InvalidateSelection(sel.RangeMain(), false);
 		SelectionRange rangeMain = sel.RangeMain();
 		sel.Clear();
 		sel.Rectangular() = rangeMain;
@@ -1059,7 +1097,7 @@ void Editor::HorizontalScrollTo(int xPos) {
 	//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
 	if (xPos < 0)
 		xPos = 0;
-	if ((wrapState == eWrapNone) && (xOffset != xPos)) {
+	if (!Wrapping() && (xOffset != xPos)) {
 		xOffset = xPos;
 		ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
 		SetHorizontalScrollPos();
@@ -1353,7 +1391,7 @@ This value defines an unwanted zone (UZ) where the caret is... unwanted.
 	}
 
 	// Horizontal positioning
-	if ((options & xysHorizontal) && (wrapState == eWrapNone)) {
+	if ((options & xysHorizontal) && !Wrapping()) {
 		const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2;
 		const bool bSlop = (caretXPolicy & CARET_SLOP) != 0;
 		const bool bStrict = (caretXPolicy & CARET_STRICT) != 0;
@@ -1540,13 +1578,17 @@ void Editor::InvalidateCaret() {
 void Editor::UpdateSystemCaret() {
 }
 
+bool Editor::Wrapping() const {
+	return vs.wrapState != eWrapNone;
+}
+
 void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
 //Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd);
 	if (wrapPending.AddRange(docLineStart, docLineEnd)) {
 		llc.Invalidate(LineLayout::llPositions);
 	}
 	// Wrap lines during idle.
-	if ((wrapState != eWrapNone) && wrapPending.NeedsWrap()) {
+	if (Wrapping() && wrapPending.NeedsWrap()) {
 		SetIdle(true);
 	}
 }
@@ -1570,7 +1612,7 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
 bool Editor::WrapLines(enum wrapScope ws) {
 	int goodTopLine = topLine;
 	bool wrapOccurred = false;
-	if (wrapState == eWrapNone) {
+	if (!Wrapping()) {
 		if (wrapWidth != LineLayout::wrapWidthInfinite) {
 			wrapWidth = LineLayout::wrapWidthInfinite;
 			for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
@@ -2030,13 +2072,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 						PRectangle rcNumber = rcMarker;
 						// Right justify
 						XYPOSITION width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number));
-						XYPOSITION xpos = rcNumber.right - width - marginNumberPadding;
+						XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
 						rcNumber.left = xpos;
 						surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
 								rcNumber.top + vs.maxAscent, number, istrlen(number),
 								vs.styles[STYLE_LINENUMBER].fore,
 								vs.styles[STYLE_LINENUMBER].back);
-					} else if (wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
+					} else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
 						PRectangle rcWrapMarker = rcMarker;
 						rcWrapMarker.right -= 3;
 						rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth;
@@ -2127,27 +2169,13 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
 	        LinesOnScreen() + 1, pdoc->LinesTotal());
 }
 
-bool BadUTF(const char *s, int len, int &trailBytes) {
-	// For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-	if (trailBytes) {
-		trailBytes--;
-		return false;
-	}
-	int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(s), len);
-	if (utf8status & UTF8MaskInvalid) {
-		return true;
-	} else {
-		trailBytes = (utf8status & UTF8MaskWidth) - 1;
-		return false;
-	}
-}
-
 /**
  * Fill in the LineLayout data for the given line.
  * Copy the given @a line and its styles from the document into local arrays.
  * Also determine the x position at which each character starts.
  */
 void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
+//void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width, Document *pdoc, PositionCache &posCache, SpecialRepresentations &reprs) {
 	if (!ll)
 		return;
 
@@ -2204,7 +2232,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 		ll->widthLine = LineLayout::wrapWidthInfinite;
 		ll->lines = 1;
 		if (vstyle.edgeState == EDGE_BACKGROUND) {
-			ll->edgeColumn = pdoc->FindColumn(line, theEdge);
+			ll->edgeColumn = pdoc->FindColumn(line, vstyle.theEdge);
 			if (ll->edgeColumn >= posLineStart) {
 				ll->edgeColumn -= posLineStart;
 			}
@@ -2245,75 +2273,52 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 
 		// Layout the line, determining the position of each character,
 		// with an extra element at the end for the end of the line.
-		int startseg = 0;	// Start of the current segment, in char. number
-		XYACCUMULATOR startsegx = 0;	// Start of the current segment, in pixels
 		ll->positions[0] = 0;
-		XYPOSITION tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
 		bool lastSegItalics = false;
-		Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
-
-		XYPOSITION ctrlCharWidth[32] = {0};
-		bool isControlNext = IsControlCharacter(ll->chars[0]);
-		int trailBytes = 0;
-		bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes);
-		for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
-			bool isControl = isControlNext;
-			isControlNext = IsControlCharacter(ll->chars[charInLine + 1]);
-			bool isBadUTF = isBadUTFNext;
-			isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes);
-			if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
-			        isControl || isControlNext || isBadUTF || isBadUTFNext || ((charInLine+1) >= numCharsBeforeEOL)) {
-				ll->positions[startseg] = 0;
-				if (vstyle.styles[ll->styles[charInLine]].visible) {
-					if (isControl) {
-						if (ll->chars[charInLine] == '\t') {
-							ll->positions[charInLine + 1] =
-								((static_cast<int>((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx;
-						} else if (controlCharSymbol < 32) {
-							if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
-								const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
-								ctrlCharWidth[ll->chars[charInLine]] =
-								    surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + ctrlCharPadding;
-							}
-							ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]];
-						} else {
-							char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
-							surface->MeasureWidths(ctrlCharsFont, cc, 1,
-							        ll->positions + startseg + 1);
-						}
-						lastSegItalics = false;
-					} else if ((isBadUTF) || (charInLine >= numCharsBeforeEOL)) {
-						char hexits[4];
-						sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff);
-						ll->positions[charInLine + 1] =
-						    surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3;
-					} else {	// Regular character
-						int lenSeg = charInLine - startseg + 1;
-						if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
-							lastSegItalics = false;
-							// Over half the segments are single characters and of these about half are space characters.
-							ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
-						} else {
-							lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
-							posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg,
-							        lenSeg, ll->positions + startseg + 1, pdoc);
-						}
+
+		BreakFinder bfLayout(ll, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs);
+		while (bfLayout.More()) {
+
+			const TextSegment ts = bfLayout.Next();
+
+			std::fill(&ll->positions[ts.start+1], &ll->positions[ts.end()+1], 0.0f);
+			if (vstyle.styles[ll->styles[ts.start]].visible) {
+				if (ts.representation) {
+					XYPOSITION representationWidth = vstyle.controlCharWidth;
+					if (ll->chars[ts.start] == '\t') {
+						// Tab is a special case of representation, taking a variable amount of space
+						representationWidth =
+							((static_cast<int>((ll->positions[ts.start] + 2) / vstyle.tabWidth) + 1) * vstyle.tabWidth) - ll->positions[ts.start];
+					} else {
+						if (representationWidth <= 0.0) {
+							XYPOSITION positionsRepr[256];	// Should expand when needed
+							posCache.MeasureWidths(surface, vstyle, STYLE_CONTROLCHAR, ts.representation->stringRep.c_str(),
+								static_cast<unsigned int>(ts.representation->stringRep.length()), positionsRepr, pdoc);
+							representationWidth = positionsRepr[ts.representation->stringRep.length()-1] + vstyle.ctrlCharPadding;
+ 						}
 					}
-				} else {    // invisible
-					for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
-						ll->positions[posToZero] = 0;
+					for (int ii=0; ii < ts.length; ii++)
+						ll->positions[ts.start + 1 + ii] = representationWidth;
+				} else {
+					if ((ts.length == 1) && (' ' == ll->chars[ts.start])) {
+						// Over half the segments are single characters and of these about half are space characters.
+						ll->positions[ts.start + 1] = vstyle.styles[ll->styles[ts.start]].spaceWidth;
+					} else {
+						posCache.MeasureWidths(surface, vstyle, ll->styles[ts.start], ll->chars + ts.start,
+							    ts.length, ll->positions + ts.start + 1, pdoc);
 					}
 				}
-				for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
-					ll->positions[posToIncrease] += startsegx;
-				}
-				startsegx = ll->positions[charInLine + 1];
-				startseg = charInLine + 1;
+				lastSegItalics = (!ts.representation) && ((ll->chars[ts.end()-1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic);
+			}
+
+			for (int posToIncrease = ts.start+1; posToIncrease <= ts.end(); posToIncrease++) {
+				ll->positions[posToIncrease] += ll->positions[ts.start];
 			}
 		}
+
 		// Small hack to make lines that end with italics not cut off the edge of the last character
-		if ((startseg > 0) && lastSegItalics) {
-			ll->positions[startseg] += lastSegItalicsOffset;
+		if (lastSegItalics) {
+			ll->positions[numCharsInLine] += vstyle.lastSegItalicsOffset;
 		}
 		ll->numCharsInLine = numCharsInLine;
 		ll->numCharsBeforeEOL = numCharsBeforeEOL;
@@ -2331,17 +2336,17 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 			// Simple common case where line does not need wrapping.
 			ll->lines = 1;
 		} else {
-			if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
+			if (vstyle.wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
 				width -= static_cast<int>(vstyle.aveCharWidth); // take into account the space for end wrap mark
 			}
 			XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line
-			if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
+			if (vstyle.wrapIndentMode == SC_WRAPINDENT_INDENT) {
 				wrapAddIndent = pdoc->IndentSize() * vstyle.spaceWidth;
-			} else if (wrapIndentMode == SC_WRAPINDENT_FIXED) {
-				wrapAddIndent = wrapVisualStartIndent * vstyle.aveCharWidth;
+			} else if (vstyle.wrapIndentMode == SC_WRAPINDENT_FIXED) {
+				wrapAddIndent = vstyle.wrapVisualStartIndent * vstyle.aveCharWidth;
 			}
 			ll->wrapIndent = wrapAddIndent;
-			if (wrapIndentMode != SC_WRAPINDENT_FIXED)
+			if (vstyle.wrapIndentMode != SC_WRAPINDENT_FIXED)
 				for (int i = 0; i < ll->numCharsInLine; i++) {
 					if (!IsSpaceOrTab(ll->chars[i])) {
 						ll->wrapIndent += ll->positions[i]; // Add line indent
@@ -2352,7 +2357,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 			if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15)
 				ll->wrapIndent = wrapAddIndent;
 			// Check for wrapIndent minimum
-			if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth))
+			if ((vstyle.wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth))
 				ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual
 			ll->lines = 0;
 			// Calculate line start positions based upon width.
@@ -2384,7 +2389,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 					continue;
 				}
 				if (p > 0) {
-					if (wrapState == eWrapChar) {
+					if (vstyle.wrapState == eWrapChar) {
 						lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
 						        - posLineStart;
 						p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
@@ -2405,18 +2410,18 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 
 ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const {
 	return main ?
-		(primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) :
+		(primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) :
 		vsDraw.selAdditionalBackground;
 }
 
 ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
         ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const {
 	if (inSelection == 1) {
-		if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+		if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
 			return SelectionBackground(vsDraw, true);
 		}
 	} else if (inSelection == 2) {
-		if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) {
+		if (vsDraw.selColours.back.isSet && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) {
 			return SelectionBackground(vsDraw, false);
 		}
 	} else {
@@ -2424,8 +2429,8 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
 		        (i >= ll->edgeColumn) &&
 		        (i < ll->numCharsBeforeEOL))
 			return vsDraw.edgecolour;
-		if (inHotspot && vsDraw.hotspotBackgroundSet)
-			return vsDraw.hotspotBackground;
+		if (inHotspot && vsDraw.hotspotColours.back.isSet)
+			return vsDraw.hotspotColours.back;
 	}
 	if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) {
 		return background;
@@ -2449,11 +2454,9 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
 	int w = rcPlace.right - rcPlace.left - xa - 1;
 
 	bool xStraight = isEndMarker;  // x-mirrored symbol for start marker
-	bool yStraight = true;
-	//bool yStraight= isEndMarker; // comment in for start marker y-mirrowed
 
 	int x0 = xStraight ? rcPlace.left : rcPlace.right - 1;
-	int y0 = yStraight ? rcPlace.top : rcPlace.bottom - 1;
+	int y0 = rcPlace.top;
 
 	int dy = (rcPlace.bottom - rcPlace.top) / 5;
 	int y = (rcPlace.bottom - rcPlace.top) / 2 + dy;
@@ -2471,7 +2474,7 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
 			surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
 		}
 	};
-	Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1};
+	Relative rel = {surface, x0, xStraight ? 1 : -1, y0, 1};
 
 	// arrow head
 	rel.MoveTo(xa, y);
@@ -2585,10 +2588,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 			int styleMain = ll->styles[eolPos];
 			ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll);
 			ColourDesired textFore = vsDraw.styles[styleMain].fore;
-			if (eolInSelection && vsDraw.selforeset) {
-				textFore = (eolInSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
+			if (eolInSelection && vsDraw.selColours.fore.isSet) {
+				textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
 			}
-			if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
+			if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1)) {
 				if (alpha == SC_ALPHA_NOALPHA) {
 					surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
 				} else {
@@ -2598,7 +2601,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 				surface->FillRectangle(rcSegment, textBack);
 			}
 			DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
-			if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+			if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
 				SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
 			}
 		}
@@ -2608,7 +2611,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 	rcSegment.left = xEol + xStart + virtualSpace + blobsWidth;
 	rcSegment.right = rcSegment.left + vsDraw.aveCharWidth;
 
-	if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+	if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
 		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
 	} else {
 		if (overrideBackground) {
@@ -2620,7 +2623,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		} else {
 			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
 		}
-		if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+		if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
 			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
 		}
 	}
@@ -2631,7 +2634,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		rcSegment.left = rcLine.left;
 	rcSegment.right = rcLine.right;
 
-	if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+	if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
 		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
 	} else {
 		if (overrideBackground) {
@@ -2641,7 +2644,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		} else {
 			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
 		}
-		if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+		if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
 			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
 		}
 	}
@@ -2649,7 +2652,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 	if (drawWrapMarkEnd) {
 		PRectangle rcPlace = rcSegment;
 
-		if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
+		if (vsDraw.wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
 			rcPlace.left = xEol + xStart + virtualSpace;
 			rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
 		} else {
@@ -2805,6 +2808,11 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
 void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
         PRectangle rcLine, LineLayout *ll, int subLine) {
 
+	if (subLine >= ll->lines) {
+		DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine);
+		return; // No further drawing
+	}
+
 	PRectangle rcSegment = rcLine;
 
 	// Using one font for all control characters so it can be controlled independently to ensure
@@ -2851,21 +2859,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
-	bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
-	        (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
+	const bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
+	        (!overrideBackground) && (vsDraw.whitespaceColours.back.isSet);
 
 	bool inIndentation = subLine == 0;	// Do not handle indentation except on first subline.
 	const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth;
 	const XYPOSITION epsilon = 0.0001f;	// A small nudge to avoid floating point precision issues
 
-	int posLineStart = pdoc->LineStart(line);
+	const int posLineStart = pdoc->LineStart(line);
 
-	int startseg = ll->LineStart(subLine);
-	XYACCUMULATOR subLineStart = ll->positions[startseg];
-	if (subLine >= ll->lines) {
-		DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine);
-		return; // No further drawing
-	}
+	const int startseg = ll->LineStart(subLine);
+	const XYACCUMULATOR subLineStart = ll->positions[startseg];
 	int lineStart = 0;
 	int lineEnd = 0;
 	if (subLine < ll->lines) {
@@ -2876,13 +2880,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
-	ColourDesired wrapColour = vsDraw.styles[STYLE_DEFAULT].fore;
-	if (vsDraw.whitespaceForegroundSet)
-		wrapColour = vsDraw.whitespaceForeground;
+	const ColourDesired wrapColour = vsDraw.WrapColour();
 
 	bool drawWrapMarkEnd = false;
 
-	if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
+	if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
 		if (subLine + 1 < ll->lines) {
 			drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0;
 		}
@@ -2911,9 +2913,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 			//int styleMain = ll->styles[lineStart];
 			//surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back);
 
-			if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
+			if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
 
-				if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
+				if (vsDraw.wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
 					rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
 				else
 					rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
@@ -2925,77 +2927,76 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
-	bool selBackDrawn = vsDraw.selbackset &&
+	const bool selBackDrawn = vsDraw.selColours.back.isSet &&
 		((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
 
 	// Does not take margin into account but not significant
-	int xStartVisible = static_cast<int>(subLineStart) - xStart;
+	const int xStartVisible = static_cast<int>(subLineStart) - xStart;
 
 	ll->psel = &sel;
 
-	BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc);
-	int next = bfBack.First();
-
-	// Background drawing loop
-	while (twoPhaseDraw && (next < lineEnd)) {
-
-		startseg = next;
-		next = bfBack.Next();
-		int i = next - 1;
-		int iDoc = i + posLineStart;
-
-		rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
-		rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
-		// Only try to draw if really visible - enhances performance by not calling environment to
-		// draw strings that are completely past the right side of the window.
-		if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
-			// Clip to line rectangle, since may have a huge position which will not work with some platforms
-			if (rcSegment.left < rcLine.left)
-				rcSegment.left = rcLine.left;
-			if (rcSegment.right > rcLine.right)
-				rcSegment.right = rcLine.right;
-
-			int styleMain = ll->styles[i];
-			const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
-			bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
-			ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
-			if (ll->chars[i] == '\t') {
-				// Tab display
-				if (drawWhitespaceBackground &&
-				        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
-					textBack = vsDraw.whitespaceBackground;
-				surface->FillRectangle(rcSegment, textBack);
-			} else if (IsControlCharacter(ll->chars[i])) {
-				// Control character display
-				inIndentation = false;
-				surface->FillRectangle(rcSegment, textBack);
-			} else {
-				// Normal text display
-				surface->FillRectangle(rcSegment, textBack);
-				if (vsDraw.viewWhitespace != wsInvisible ||
-				        (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
-					for (int cpos = 0; cpos <= i - startseg; cpos++) {
-						if (ll->chars[cpos + startseg] == ' ') {
-							if (drawWhitespaceBackground &&
-							        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
-								PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
-									rcSegment.top,
-									ll->positions[cpos + startseg + 1] + xStart - subLineStart,
-									rcSegment.bottom);
-								surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground);
+	if (twoPhaseDraw) {
+		BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs);
+
+		// Background drawing loop
+		while (bfBack.More()) {
+
+			const TextSegment ts = bfBack.Next();
+			const int i = ts.end() - 1;
+			const int iDoc = i + posLineStart;
+
+			rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
+			rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
+			// Only try to draw if really visible - enhances performance by not calling environment to
+			// draw strings that are completely past the right side of the window.
+			if (rcSegment.Intersects(rcLine)) {
+				// Clip to line rectangle, since may have a huge position which will not work with some platforms
+				if (rcSegment.left < rcLine.left)
+					rcSegment.left = rcLine.left;
+				if (rcSegment.right > rcLine.right)
+					rcSegment.right = rcLine.right;
+
+				const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
+				const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+				ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection,
+					inHotspot, ll->styles[i], i, ll);
+				if (ts.representation) {
+					if (ll->chars[i] == '\t') {
+						// Tab display
+						if (drawWhitespaceBackground &&
+								(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+							textBack = vsDraw.whitespaceColours.back;
+					} else {
+						// Blob display
+						inIndentation = false;
+					}
+					surface->FillRectangle(rcSegment, textBack);
+				} else {
+					// Normal text display
+					surface->FillRectangle(rcSegment, textBack);
+					if (vsDraw.viewWhitespace != wsInvisible ||
+							(inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
+						for (int cpos = 0; cpos <= i - ts.start; cpos++) {
+							if (ll->chars[cpos + ts.start] == ' ') {
+								if (drawWhitespaceBackground &&
+										(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+									PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
+										rcSegment.top,
+										ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
+										rcSegment.bottom);
+									surface->FillRectangle(rcSpace, vsDraw.whitespaceColours.back);
+								}
+							} else {
+								inIndentation = false;
 							}
-						} else {
-							inIndentation = false;
 						}
 					}
 				}
+			} else if (rcSegment.left > rcLine.right) {
+				break;
 			}
-		} else if (rcSegment.left > rcLine.right) {
-			break;
 		}
-	}
 
-	if (twoPhaseDraw) {
 		DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
 		        xStart, subLine, subLineStart, overrideBackground, background,
 		        drawWrapMarkEnd, wrapColour);
@@ -3004,7 +3005,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true);
 
 	if (vsDraw.edgeState == EDGE_LINE) {
-		int edgeX = theEdge * vsDraw.spaceWidth;
+		int edgeX = vsDraw.theEdge * vsDraw.spaceWidth;
 		rcSegment.left = edgeX + xStart;
 		if ((ll->wrapIndent != 0) && (lineStart != 0))
 			rcSegment.left -= ll->wrapIndent;
@@ -3028,111 +3029,102 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	inIndentation = subLine == 0;	// Do not handle indentation except on first subline.
 	// Foreground drawing loop
 	BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, xStartVisible,
-		((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset), pdoc);
-	next = bfFore.First();
-
-	while (next < lineEnd) {
+		((!twoPhaseDraw && selBackDrawn) || vsDraw.selColours.fore.isSet), pdoc, &reprs);
 
-		startseg = next;
-		next = bfFore.Next();
-		int i = next - 1;
+	while (bfFore.More()) {
 
-		int iDoc = i + posLineStart;
+		const TextSegment ts = bfFore.Next();
+		const int i = ts.end() - 1;
+		const int iDoc = i + posLineStart;
 
-		rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
-		rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+		rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
+		rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
 		// Only try to draw if really visible - enhances performance by not calling environment to
 		// draw strings that are completely past the right side of the window.
-		if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+		if (rcSegment.Intersects(rcLine)) {
 			int styleMain = ll->styles[i];
 			ColourDesired textFore = vsDraw.styles[styleMain].fore;
 			Font &textFont = vsDraw.styles[styleMain].font;
 			//hotspot foreground
 			if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
-				if (vsDraw.hotspotForegroundSet)
-					textFore = vsDraw.hotspotForeground;
+				if (vsDraw.hotspotColours.fore.isSet)
+					textFore = vsDraw.hotspotColours.fore;
 			}
 			const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
-			if (inSelection && (vsDraw.selforeset)) {
-				textFore = (inSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
+			if (inSelection && (vsDraw.selColours.fore.isSet)) {
+				textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
 			}
-			bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+			const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
 			ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
-			if (ll->chars[i] == '\t') {
-				// Tab display
-				if (!twoPhaseDraw) {
-					if (drawWhitespaceBackground &&
-					        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
-						textBack = vsDraw.whitespaceBackground;
-					surface->FillRectangle(rcSegment, textBack);
-				}
-				if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
-					for (int indentCount = (ll->positions[i] + epsilon) / indentWidth;
-						indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
-						indentCount++) {
-						if (indentCount > 0) {
-							int xIndent = indentCount * indentWidth;
-							DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
-								    (ll->xHighlightGuide == xIndent));
+			if (ts.representation) {
+				if (ll->chars[i] == '\t') {
+					// Tab display
+					if (!twoPhaseDraw) {
+						if (drawWhitespaceBackground &&
+								(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+							textBack = vsDraw.whitespaceColours.back;
+						surface->FillRectangle(rcSegment, textBack);
+					}
+					if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+						for (int indentCount = (ll->positions[i] + epsilon) / indentWidth;
+							indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
+							indentCount++) {
+							if (indentCount > 0) {
+								int xIndent = indentCount * indentWidth;
+								DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
+										(ll->xHighlightGuide == xIndent));
+							}
 						}
 					}
-				}
-				if (vsDraw.viewWhitespace != wsInvisible) {
-					if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
-						if (vsDraw.whitespaceForegroundSet)
-							textFore = vsDraw.whitespaceForeground;
-						surface->PenColour(textFore);
-						PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
-						        rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
-						DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+					if (vsDraw.viewWhitespace != wsInvisible) {
+						if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+							if (vsDraw.whitespaceColours.fore.isSet)
+								textFore = vsDraw.whitespaceColours.fore;
+							surface->PenColour(textFore);
+							PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+									rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+							DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+						}
 					}
-				}
-			} else if (IsControlCharacter(ll->chars[i])) {
-				// Control character display
-				inIndentation = false;
-				if (controlCharSymbol < 32) {
-					// Draw the character
-					const char *ctrlChar = ControlCharacterString(ll->chars[i]);
-					DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
 				} else {
-					char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
-					surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
-					        rcSegment.top + vsDraw.maxAscent,
-					        cc, 1, textBack, textFore);
+					inIndentation = false;
+					if (vsDraw.controlCharSymbol >= 32) {
+						char cc[2] = { static_cast<char>(vsDraw.controlCharSymbol), '\0' };
+						surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+								rcSegment.top + vsDraw.maxAscent,
+								cc, 1, textBack, textFore);
+					} else {
+						DrawTextBlob(surface, vsDraw, rcSegment, ts.representation->stringRep.c_str(), textBack, textFore, twoPhaseDraw);
+					}
 				}
-			} else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
-				// A single byte >= 0x80 in UTF-8 is a bad byte and is displayed as its hex value
-				char hexits[4];
-				sprintf(hexits, "x%2X", ll->chars[i] & 0xff);
-				DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
 			} else {
 				// Normal text display
 				if (vsDraw.styles[styleMain].visible) {
 					if (twoPhaseDraw) {
 						surface->DrawTextTransparent(rcSegment, textFont,
-						        rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
-						        i - startseg + 1, textFore);
+						        rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start,
+						        i - ts.start + 1, textFore);
 					} else {
 						surface->DrawTextNoClip(rcSegment, textFont,
-						        rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
-						        i - startseg + 1, textFore, textBack);
+						        rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start,
+						        i - ts.start + 1, textFore, textBack);
 					}
 				}
 				if (vsDraw.viewWhitespace != wsInvisible ||
 				        (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
-					for (int cpos = 0; cpos <= i - startseg; cpos++) {
-						if (ll->chars[cpos + startseg] == ' ') {
+					for (int cpos = 0; cpos <= i - ts.start; cpos++) {
+						if (ll->chars[cpos + ts.start] == ' ') {
 							if (vsDraw.viewWhitespace != wsInvisible) {
-								if (vsDraw.whitespaceForegroundSet)
-									textFore = vsDraw.whitespaceForeground;
+								if (vsDraw.whitespaceColours.fore.isSet)
+									textFore = vsDraw.whitespaceColours.fore;
 								if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
-									XYPOSITION xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+									XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
 									if (!twoPhaseDraw && drawWhitespaceBackground &&
 									        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
-										textBack = vsDraw.whitespaceBackground;
-										PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
+										textBack = vsDraw.whitespaceColours.back;
+										PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
 											rcSegment.top,
-											ll->positions[cpos + startseg + 1] + xStart - subLineStart,
+											ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
 											rcSegment.bottom);
 										surface->FillRectangle(rcSpace, textBack);
 									}
@@ -3143,8 +3135,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 								}
 							}
 							if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
-								for (int indentCount = (ll->positions[cpos + startseg] + epsilon) / indentWidth;
-									indentCount <= (ll->positions[cpos + startseg + 1] - epsilon) / indentWidth;
+								for (int indentCount = (ll->positions[cpos + ts.start] + epsilon) / indentWidth;
+									indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
 									indentCount++) {
 									if (indentCount > 0) {
 										int xIndent = indentCount * indentWidth;
@@ -3163,8 +3155,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 				PRectangle rcUL = rcSegment;
 				rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
 				rcUL.bottom = rcUL.top + 1;
-				if (vsDraw.hotspotForegroundSet)
-					surface->FillRectangle(rcUL, vsDraw.hotspotForeground);
+				if (vsDraw.hotspotColours.fore.isSet)
+					surface->FillRectangle(rcUL, vsDraw.hotspotColours.fore);
 				else
 					surface->FillRectangle(rcUL, textFore);
 			} else if (vsDraw.styles[styleMain].underline) {
@@ -3380,11 +3372,11 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
 			colourFMFill = vs.selbarlight;
 		}
 
-		if (vs.foldmarginColourSet) {
+		if (vs.foldmarginColour.isSet) {
 			// override default fold margin colour
 			colourFMFill = vs.foldmarginColour;
 		}
-		if (vs.foldmarginHighlightColourSet) {
+		if (vs.foldmarginHighlightColour.isSet) {
 			// override default fold margin highlight colour
 			colourFMStripes = vs.foldmarginHighlightColour;
 		}
@@ -3578,7 +3570,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 		// Either styling or NotifyUpdateUI noticed that painting is needed
 		// outside the current painting rectangle
 		//Platform::DebugPrintf("Abandoning paint\n");
-		if (wrapState != eWrapNone) {
+		if (Wrapping()) {
 			if (paintAbandonedByStyling) {
 				// Styling has spilled over a line end, such as occurs by starting a multiline
 				// comment. The width of subsequent text may have changed, so rewrap.
@@ -3747,7 +3739,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 		if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
 			surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back);
 			if (vs.edgeState == EDGE_LINE) {
-				int edgeX = theEdge * vs.spaceWidth;
+				int edgeX = vs.theEdge * vs.spaceWidth;
 				rcBeyondEOF.left = edgeX + xStart;
 				rcBeyondEOF.right = rcBeyondEOF.left + 1;
 				surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour);
@@ -3809,17 +3801,17 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 		}
 	}
 	vsPrint.fixedColumnWidth = 0;
-	vsPrint.zoomLevel = printMagnification;
+	vsPrint.zoomLevel = printParameters.magnification;
 	// Don't show indentation guides
 	// If this ever gets changed, cached pixmap would need to be recreated if technology != SC_TECHNOLOGY_DEFAULT
 	vsPrint.viewIndentationGuides = ivNone;
 	// Don't show the selection when printing
-	vsPrint.selbackset = false;
-	vsPrint.selforeset = false;
+	vsPrint.selColours.back.isSet = false;
+	vsPrint.selColours.fore.isSet = false;
 	vsPrint.selAlpha = SC_ALPHA_NOALPHA;
 	vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA;
-	vsPrint.whitespaceBackgroundSet = false;
-	vsPrint.whitespaceForegroundSet = false;
+	vsPrint.whitespaceColours.back.isSet = false;
+	vsPrint.whitespaceColours.fore.isSet = false;
 	vsPrint.showCaretLineBackground = false;
 	vsPrint.alwaysShowCaretLineBackground = false;
 	// Don't highlight matching braces using indicators
@@ -3828,15 +3820,15 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 
 	// Set colours for printing according to users settings
 	for (size_t sty = 0; sty < vsPrint.styles.size(); sty++) {
-		if (printColourMode == SC_PRINT_INVERTLIGHT) {
+		if (printParameters.colourMode == SC_PRINT_INVERTLIGHT) {
 			vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
 			vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
-		} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
+		} else if (printParameters.colourMode == SC_PRINT_BLACKONWHITE) {
 			vsPrint.styles[sty].fore = ColourDesired(0, 0, 0);
 			vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
-		} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
+		} else if (printParameters.colourMode == SC_PRINT_COLOURONWHITE) {
 			vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
-		} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
+		} else if (printParameters.colourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
 			if (sty <= STYLE_DEFAULT) {
 				vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
 			}
@@ -3849,14 +3841,14 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 	vsPrint.leftMarginWidth = 0;
 	vsPrint.rightMarginWidth = 0;
 
-	vsPrint.Refresh(*surfaceMeasure);
+	vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars);
 	// Determining width must hapen after fonts have been realised in Refresh
 	int lineNumberWidth = 0;
 	if (lineNumberIndex >= 0) {
 		lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
 		        "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
 		vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
-		vsPrint.Refresh(*surfaceMeasure);	// Recalculate fixedColumnWidth
+		vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars);	// Recalculate fixedColumnWidth
 	}
 
 	int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin);
@@ -3884,7 +3876,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 	int nPrintPos = pfr->chrg.cpMin;
 	int visibleLine = 0;
 	int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
-	if (printWrapState == eWrapNone)
+	if (printParameters.wrapState == eWrapNone)
 		widthPrint = LineLayout::wrapWidthInfinite;
 
 	while (lineDoc <= linePrintLast && ypos < pfr->rc.bottom) {
@@ -4011,7 +4003,7 @@ void Editor::SetScrollBars() {
 void Editor::ChangeSize() {
 	DropGraphics(false);
 	SetScrollBars();
-	if (wrapState != eWrapNone) {
+	if (Wrapping()) {
 		PRectangle rcTextArea = GetClientRectangle();
 		rcTextArea.left = vs.textStart;
 		rcTextArea.right -= vs.rightMarginWidth;
@@ -4091,7 +4083,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 				}
 				currentSel->ClearVirtualSpace();
 				// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
-				if (wrapState != eWrapNone) {
+				if (Wrapping()) {
 					AutoSurface surface(this);
 					if (surface) {
 						if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) {
@@ -4104,7 +4096,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 			}
 		}
 	}
-	if (wrapState != eWrapNone) {
+	if (Wrapping()) {
 		SetScrollBars();
 	}
 	ThinRectangularRange();
@@ -4586,7 +4578,7 @@ void Editor::NotifyDwelling(Point pt, bool state) {
 	SCNotification scn = {0};
 	scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
 	scn.position = PositionFromLocation(pt, true);
-	scn.x = pt.x;
+	scn.x = pt.x + vs.ExternalMarginWidth();
 	scn.y = pt.y;
 	NotifyParent(scn);
 }
@@ -4613,7 +4605,7 @@ void Editor::CheckModificationForWrap(DocModification mh) {
 		llc.Invalidate(LineLayout::llCheckTextAndStyle);
 		int lineDoc = pdoc->LineFromPosition(mh.position);
 		int lines = Platform::Maximum(0, mh.linesAdded);
-		if (wrapState != eWrapNone) {
+		if (Wrapping()) {
 			NeedWrapping(lineDoc, lineDoc + lines + 1);
 		}
 		RefreshStyleData();
@@ -6325,7 +6317,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 					selectionType = selWholeLine;
 				} else if (selectionType != selSubLine && selectionType != selWholeLine) {
 					// If it is neither, reset selection type to line selection.
-					selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+					selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
 				}
 			} else {
 				if (selectionType == selChar) {
@@ -6389,7 +6381,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 			if (!shift) {
 				// Single click in margin: select whole line or only subline if word wrap is enabled
 				lineAnchorPos = newPos.Position();
-				selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+				selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
 				LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine);
 			} else {
 				// Single shift+click in margin: select from line anchor to clicked line
@@ -6402,7 +6394,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 				// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
 				// This ensures that we continue selecting in the same selection mode.
 				if (sel.Empty() || (selectionType != selSubLine && selectionType != selWholeLine))
-					selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+					selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
 				LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine);
 			}
 
@@ -6504,7 +6496,7 @@ void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) const {
 	hsEnd_ = hsEnd;
 }
 
-void Editor::ButtonMove(Point pt) {
+void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
 	if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {
 		DwellEnd(true);
 	}
@@ -6538,10 +6530,14 @@ void Editor::ButtonMove(Point pt) {
 			SetDragPosition(movePos);
 		} else {
 			if (selectionType == selChar) {
+				if (sel.selType == Selection::selStream && (modifiers & SCI_ALT) && mouseSelectionRectangularSwitch) {
+					sel.selType = Selection::selRectangle;
+				}
 				if (sel.IsRectangular()) {
 					sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor);
 					SetSelection(movePos, sel.RangeMain().anchor);
 				} else if (sel.Count() > 1) {
+					InvalidateSelection(sel.RangeMain(), false);
 					SelectionRange range(movePos, sel.RangeMain().anchor);
 					sel.TentativeSelection(range);
 					InvalidateSelection(range, true);
@@ -6615,6 +6611,10 @@ void Editor::ButtonMove(Point pt) {
 	}
 }
 
+void Editor::ButtonMove(Point pt) {
+	ButtonMoveWithModifiers(pt, 0);
+}
+
 void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
 	//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
 	SelectionPosition newPos = SPositionFromLocation(pt, false, false,
@@ -6728,7 +6728,7 @@ bool Editor::Idle() {
 
 	bool idleDone;
 
-	bool wrappingDone = wrapState == eWrapNone;
+	bool wrappingDone = !Wrapping();
 
 	if (!wrappingDone) {
 		// Wrap lines during idle.
@@ -6864,7 +6864,7 @@ void Editor::SetAnnotationHeights(int start, int end) {
 		bool changedHeight = false;
 		for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
 			int linesWrapped = 1;
-			if (wrapState != eWrapNone) {
+			if (Wrapping()) {
 				AutoSurface surface(this);
 				AutoLineLayout ll(llc, RetrieveLineLayout(line));
 				if (surface && ll) {
@@ -6902,6 +6902,8 @@ void Editor::SetDocPointer(Document *document) {
 
 	vs.ReleaseAllExtendedStyles();
 
+	SetRepresentations();
+
 	// Reset the contraction state to fully shown.
 	cs.Clear();
 	cs.InsertLines(0, pdoc->LinesTotal() - 1);
@@ -7603,6 +7605,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_POSITIONAFTER:
 		return pdoc->MovePositionOutsideChar(wParam + 1, 1, true);
 
+	case SCI_POSITIONRELATIVE:
+		return Platform::Clamp(pdoc->GetRelativePosition(wParam, lParam), 0, pdoc->Length());
+
 	case SCI_LINESCROLL:
 		ScrollTo(topLine + lParam);
 		HorizontalScrollTo(xOffset + static_cast<int>(wParam) * vs.sp@@ Diff output truncated at 100000 characters. @@

--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list