[anjuta-extras] scintilla: Update to include scintilla 3.0.3



commit 4fa7d3ec4a16691d81a4374236a62ac417f04594
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Sat Mar 3 17:54:48 2012 +0100

    scintilla: Update to include scintilla 3.0.3

 plugins/scintilla/Makefile.am                      |    1 +
 .../scintilla/{scintilla/include => }/PropSet.h    |    0
 plugins/scintilla/aneditor-indent.cxx              |  213 ----
 plugins/scintilla/aneditor-priv.h                  |    2 -
 plugins/scintilla/aneditor.cxx                     |    2 -
 plugins/scintilla/properties/styles.properties     |  959 ++++++++++++----
 plugins/scintilla/scintilla/AutoComplete.cxx       |    4 +-
 plugins/scintilla/scintilla/AutoComplete.h         |    2 +-
 plugins/scintilla/scintilla/CallTip.cxx            |   63 +-
 plugins/scintilla/scintilla/CallTip.h              |   23 +-
 plugins/scintilla/scintilla/Catalogue.cxx          |    3 +
 plugins/scintilla/scintilla/Document.cxx           |   38 +-
 plugins/scintilla/scintilla/Document.h             |    8 +-
 plugins/scintilla/scintilla/Editor.cxx             |  575 +++++-----
 plugins/scintilla/scintilla/Editor.h               |   27 +-
 plugins/scintilla/scintilla/Indicator.cxx          |   14 +-
 plugins/scintilla/scintilla/Indicator.h            |    2 +-
 plugins/scintilla/scintilla/LexAVS.cxx             |  293 +++++
 plugins/scintilla/scintilla/LexAda.cxx             |    1 +
 plugins/scintilla/scintilla/LexAsm.cxx             |    4 -
 plugins/scintilla/scintilla/LexBasic.cxx           |    4 -
 plugins/scintilla/scintilla/LexCPP.cxx             |   27 +-
 plugins/scintilla/scintilla/LexCSS.cxx             |  228 ++++-
 plugins/scintilla/scintilla/LexCoffeeScript.cxx    |  571 ++++++++++
 plugins/scintilla/scintilla/LexD.cxx               |    4 -
 plugins/scintilla/scintilla/LexGen.py              |    5 +-
 plugins/scintilla/scintilla/LexHTML.cxx            |   15 +-
 plugins/scintilla/scintilla/LexMMIXAL.cxx          |    2 +-
 plugins/scintilla/scintilla/LexMPT.cxx             |    1 +
 plugins/scintilla/scintilla/LexOthers.cxx          |   12 +-
 plugins/scintilla/scintilla/LexPerl.cxx            |    4 -
 plugins/scintilla/scintilla/LexRuby.cxx            |    4 +-
 plugins/scintilla/scintilla/LexSQL.cxx             |   33 +-
 plugins/scintilla/scintilla/LexScriptol.cxx        |    2 +-
 plugins/scintilla/scintilla/LexSpice.cxx           |    1 +
 plugins/scintilla/scintilla/LexTCL.cxx             |    1 +
 plugins/scintilla/scintilla/LexTCMD.cxx            |  511 +++++++++
 plugins/scintilla/scintilla/LineMarker.cxx         |  127 +--
 plugins/scintilla/scintilla/LineMarker.h           |    7 +-
 plugins/scintilla/scintilla/PerLine.cxx            |   13 +
 plugins/scintilla/scintilla/PerLine.h              |    1 +
 plugins/scintilla/scintilla/PlatGTK.cxx            | 1188 +++-----------------
 plugins/scintilla/scintilla/PositionCache.cxx      |   18 +-
 plugins/scintilla/scintilla/PositionCache.h        |   14 +-
 plugins/scintilla/scintilla/PropSetSimple.cxx      |    4 +-
 plugins/scintilla/scintilla/ScintillaBase.cxx      |   28 +-
 plugins/scintilla/scintilla/ScintillaBase.h        |    2 -
 plugins/scintilla/scintilla/ScintillaGTK.cxx       |   93 +--
 plugins/scintilla/scintilla/Style.cxx              |   36 +-
 plugins/scintilla/scintilla/Style.h                |   14 +-
 plugins/scintilla/scintilla/ViewStyle.cxx          |  137 +--
 plugins/scintilla/scintilla/ViewStyle.h            |   42 +-
 plugins/scintilla/scintilla/XPM.cxx                |   36 +-
 plugins/scintilla/scintilla/XPM.h                  |   10 +-
 plugins/scintilla/scintilla/include/Accessor.h     |   79 --
 plugins/scintilla/scintilla/include/Face.py        |    6 +-
 plugins/scintilla/scintilla/include/ILexer.h       |    8 +
 plugins/scintilla/scintilla/include/KeyWords.h     |  113 --
 plugins/scintilla/scintilla/include/Makefile.am    |    7 +-
 plugins/scintilla/scintilla/include/Platform.h     |  185 ++--
 plugins/scintilla/scintilla/include/SString.h      |  307 -----
 plugins/scintilla/scintilla/include/SciLexer.h     |   57 +
 plugins/scintilla/scintilla/include/Scintilla.h    |   20 +-
 .../scintilla/scintilla/include/Scintilla.iface    |  120 ++-
 .../scintilla/scintilla/include/WindowAccessor.h   |   67 --
 plugins/scintilla/scintilla/lexers.make            |    6 +
 .../scintilla/patches/scintilla-calltip-above.diff |   42 -
 .../scintilla/patches/scintilla-pango-always.diff  |   20 -
 68 files changed, 3461 insertions(+), 3005 deletions(-)
---
diff --git a/plugins/scintilla/Makefile.am b/plugins/scintilla/Makefile.am
index 7849a4e..2e3dd83 100644
--- a/plugins/scintilla/Makefile.am
+++ b/plugins/scintilla/Makefile.am
@@ -63,6 +63,7 @@ libanjuta_editor_la_SOURCES= \
 	print.h \
 	PropSetFile.h \
 	PropSetFile.cxx \
+	PropSet.h \
 	SString.h \
 	FilePath.cxx \
 	FilePath.h \
diff --git a/plugins/scintilla/scintilla/include/PropSet.h b/plugins/scintilla/PropSet.h
similarity index 100%
rename from plugins/scintilla/scintilla/include/PropSet.h
rename to plugins/scintilla/PropSet.h
diff --git a/plugins/scintilla/aneditor-indent.cxx b/plugins/scintilla/aneditor-indent.cxx
index cb4cf00..8678f42 100644
--- a/plugins/scintilla/aneditor-indent.cxx
+++ b/plugins/scintilla/aneditor-indent.cxx
@@ -104,219 +104,6 @@ bool AnEditor::RangeIsAllWhitespace(int start, int end) {
 	return all_white;
 }
 
-#if 0
-
-unsigned int AnEditor::GetLinePartsInStyle(int line, int style1, int style2,
-										   SString sv[], int len) {
-	for (int i = 0; i < len; i++)
-		sv[i] = "";
-	WindowAccessor acc(wEditor.GetID(), *props);
-	SString s;
-	int part = 0;
-	int thisLineStart = SendEditor(SCI_POSITIONFROMLINE, line);
-	int nextLineStart = SendEditor(SCI_POSITIONFROMLINE, line + 1);
-	for (int pos = thisLineStart; pos < nextLineStart; pos++) {
-		if ((acc.StyleAt(pos) == style1) || (acc.StyleAt(pos) == style2)) {
-			char c[2];
-			c[0] = acc[pos];
-			c[1] = '\0';
-			s += c;
-		} else if (s.length() > 0) {
-			if (part < len) {
-				sv[part++] = s;
-			}
-			s = "";
-		}
-	}
-	if ((s.length() > 0) && (part < len)) {
-		sv[part++] = s;
-	}
-	return part;
-}
-
-static bool includes(const StyleAndWords &symbols, const SString value) {
-	if (symbols.words.length() == 0) {
-		return false;
-	} else if (IsAlphabetic(symbols.words[0])) {
-		// Set of symbols separated by spaces
-		size_t lenVal = value.length();
-		const char *symbol = symbols.words.c_str();
-		while (symbol) {
-			const char *symbolEnd = strchr(symbol, ' ');
-			size_t lenSymbol = strlen(symbol);
-			if (symbolEnd)
-				lenSymbol = symbolEnd - symbol;
-			if (lenSymbol == lenVal) {
-				if (strncmp(symbol, value.c_str(), lenSymbol) == 0) {
-					return true;
-				}
-			}
-			symbol = symbolEnd;
-			if (symbol)
-				symbol++;
-		}
-	} else {
-		// Set of individual characters. Only one character allowed for now
-		char ch = symbols.words[0];
-		return strchr(value.c_str(), ch) != 0;
-	}
-	return false;
-}
-
-#define ELEMENTS(a)	(sizeof(a) / sizeof(a[0]))
-
-IndentationStatus AnEditor::GetIndentState(int line) {
-	// C like language indentation defined by braces and keywords
-	IndentationStatus indentState = isNone;
-	SString controlWords[20];
-	unsigned int parts = GetLinePartsInStyle(line, statementIndent.styleNumber,
-		-1, controlWords, ELEMENTS(controlWords));
-	for (unsigned int i = 0; i < parts; i++) {
-		if (includes(statementIndent, controlWords[i]))
-			indentState = isKeyWordStart;
-	}
-	// Braces override keywords
-	SString controlStrings[20];
-	parts = GetLinePartsInStyle(line, blockEnd.styleNumber,
-		-1, controlStrings, ELEMENTS(controlStrings));
-	for (unsigned int j = 0; j < parts; j++) {
-		if (includes(blockEnd, controlStrings[j]))
-			indentState = isBlockEnd;
-		if (includes(blockStart, controlStrings[j]))
-			indentState = isBlockStart;
-	}
-	return indentState;
-}
-
-int AnEditor::IndentOfBlockProper(int line) {
-	
-	if (line < 0)
-		return 0;
-	
-	int indentSize = SendEditor(SCI_GETINDENT);
-	int indentBlock = GetLineIndentation(line);
-	int minIndent = indentBlock;
-	int backLine = line;
-	
-	IndentationStatus indentState = isNone;
-	if (statementIndent.IsEmpty() && blockStart.IsEmpty() && blockEnd.IsEmpty())
-		indentState = isBlockStart;	// Don't bother searching backwards
-
-	int lineLimit = line - statementLookback;
-	if (lineLimit < 0)
-		lineLimit = 0;
-	bool noIndentFound = true;
-	while ((backLine >= lineLimit) && (indentState == 0)) {
-		indentState = GetIndentState(backLine);
-		if (indentState != 0) {
-			noIndentFound = false;
-			indentBlock = GetLineIndentation(backLine);
-			if (indentState == isBlockStart) {
-				if (!indentOpening)
-					indentBlock += indentSize;
-			}
-			if (indentState == isBlockEnd) {
-				if (indentClosing)
-					indentBlock -= indentSize;
-				if (indentBlock < 0)
-					indentBlock = 0;
-			}
-			if ((indentState == isKeyWordStart) && (backLine == line))
-				indentBlock += indentSize;
-		} else if (noIndentFound) {
-			int currentIndent = GetLineIndentation(backLine);
-			minIndent = MIN(minIndent, currentIndent);
-		}
-		backLine--;
-	}
-	if (noIndentFound && minIndent > 0)
-		indentBlock = minIndent;
-	return indentBlock;
-}
-
-int AnEditor::IndentOfBlock(int line) {
-
-	int backLine = line;
-
-	/* Find mismatched parenthesis */
-	if (lexLanguage == SCLEX_CPP) {
-		WindowAccessor acc(wEditor.GetID(), *props);
-		int currentPos = SendEditor(SCI_POSITIONFROMLINE, backLine + 1);
-		
-		while (backLine >= 0) {
-			int thisLineStart = SendEditor(SCI_POSITIONFROMLINE, backLine);
-			int nextLineStart = currentPos;
-			// printf("Scanning at line: %d (%d)\n", backLine, currentPos);
-	
-			int foundTerminator = false;
-			int pos;
-			for (pos = nextLineStart - 1; pos >= thisLineStart; pos--) {
-	
-				// printf ("Style at %d = %d\n", pos, acc.StyleAt(pos));
-	
-				if ((acc.StyleAt(pos) == 10)) {
-					char c[2];
-					c[0] = acc[pos];
-					c[1] = '\0';
-					// printf ("Looking at: \"%s\"\n", c);
-					if (includes(blockEnd, c) ||
-						includes(blockStart, c) ||
-						includes(statementEnd, c))
-					{
-						// printf ("Found block start/block end/statement end. Breaking\n");
-						foundTerminator = true;
-						break;
-					}
-					if (c[0] == '(' || c[0] == '[') {
-						int indentBlock = SendEditor(SCI_GETCOLUMN, pos) + 1;// - thisLineStart;
-						// printf ("Found Unmatched '(' at col: %d. Returning\n", indentBlock);
-						return indentBlock;
-					}
-					if (c[0] == ')' || c[0] == ']') {
-						int braceOpp;
-						int lineOpp;
-						braceOpp = SendEditor(SCI_BRACEMATCH, pos, 0);
-						// printf ("Brace opp. at %d\n", braceOpp);
-						if (braceOpp >= 0) {
-							currentPos = braceOpp - 1;
-							lineOpp = SendEditor (SCI_LINEFROMPOSITION,
-												  braceOpp);
-							if (backLine != lineOpp) {
-								backLine = lineOpp;
-								// printf ("Jumping to line %d (%d)\n", backLine, currentPos);
-								break;
-							} else {
-								pos = currentPos;
-							}
-						} else {
-							foundTerminator = true;
-							break;
-						}
-					}
-				} else if ((acc.StyleAt(pos) == statementIndent.styleNumber) &&
-						   (acc.StyleAt(pos+1) != statementIndent.styleNumber)) {
-					char buffer[128];
-					if (GetWordAtPosition (buffer, 128, pos)) {
-						if (includes (statementIndent, buffer)) {
-							printf ("Found keyword terminator before unmatched (\n");
-							foundTerminator = true;
-							break;
-						}
-					}
-				}
-			}
-			if (foundTerminator)
-				break;
-			if (pos < thisLineStart) {
-				backLine--;
-				currentPos = pos;
-			}
-		}
-	}
-	return IndentOfBlockProper(backLine);
-}
-#endif
-
 void AnEditor::MaintainIndentation(char ch) {
 	int eolMode = SendEditor(SCI_GETEOLMODE);
 	int curLine = GetCurrentLineNumber();
diff --git a/plugins/scintilla/aneditor-priv.h b/plugins/scintilla/aneditor-priv.h
index 331d5db..1c6e567 100644
--- a/plugins/scintilla/aneditor-priv.h
+++ b/plugins/scintilla/aneditor-priv.h
@@ -40,8 +40,6 @@
 #define GTK
 #include "Platform.h"
 #include "PropSet.h"
-#include "Accessor.h"
-#include "KeyWords.h"
 #include "Scintilla.h"
 #include "ScintillaWidget.h"
 #include "SciLexer.h"
diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx
index c26927f..1c81b20 100644
--- a/plugins/scintilla/aneditor.cxx
+++ b/plugins/scintilla/aneditor.cxx
@@ -2769,8 +2769,6 @@ void AnEditor::ReadProperties(const char *fileForExt, char **typedef_hl) {
 	}
 
 	/* Gtk handles it correctly */
-	SendEditor(SCI_SETUSEPALETTE, 0);
-
 	SendEditor(SCI_SETPRINTMAGNIFICATION, props->GetInt("print.magnification"));
 	SendEditor(SCI_SETPRINTCOLOURMODE, props->GetInt("print.colour.mode"));
 
diff --git a/plugins/scintilla/properties/styles.properties b/plugins/scintilla/properties/styles.properties
index f4238f3..f85201e 100644
--- a/plugins/scintilla/properties/styles.properties
+++ b/plugins/scintilla/properties/styles.properties
@@ -122,55 +122,72 @@ command.go.*.adb=$(FileName)
 
 ###############################################################################
 # From asm.properties
-# Define SciTE settings for Assembler files (IA32 MASM and NASM)
+# Define SciTE settings for Assembler files (NASM)
 # Originally by Black Horus blackhorus gmx net 2002
 # Updated by Kein-Hong Man mkh pl jaring my 2003-10
+# Updated by Marat Dukhan (mdukhan3.at.gatech.dot.edu) 10/4/2011
 
-# Masm files
+# Nasm files
 file.patterns.asm=*.asm
-filter.asm=Assembler (asm)|$(file.patterns.asm)|
+filter.asm=Assembler x86/x64(asm)|$(file.patterns.asm)|
 
 lexer.$(file.patterns.asm)=asm
 
-# these keywords are taken from the masm book (v6.13)
-# updated with Intel Pentium 4, MMX, SSE, SSE2 instructions from NASM
-# 	(note that some are undocumented instructions)
-
-cpu_instruction=aaa aad aam aas adc add and call cbw \
-	clc cld cli cmc cmp cmps cmpsb cmpsw cwd daa das dec div esc hlt \
-	idiv imul in inc int into iret ja jae jb jbe jc jcxz je jg jge jl \
-	jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns \
-	jnz jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop \
-	loope loopew loopne loopnew loopnz loopnzw loopw loopz loopzw \
-	mov movs movsb movsw mul neg nop not or out pop popf push pushf \
-	rcl rcr ret retf retn rol ror sahf sal sar sbb scas scasb scasw \
-	shl shr stc std sti stos stosb stosw sub test wait xchg xlat \
-	xlatb xor \
-	bound enter ins insb insw leave outs outsb outsw popa pusha pushw \
-	arpl lar lsl sgdt sidt sldt smsw str verr verw clts lgdt lidt lldt lmsw ltr \
-	bsf bsr bt btc btr bts cdq cmpsd cwde insd iretd iretdf  iretf \
-	jecxz lfs lgs lodsd loopd  looped  loopned  loopnzd  loopzd  lss \
-	movsd movsx movzx outsd popad popfd pushad pushd  pushfd scasd seta \
-	setae setb setbe setc sete setg setge setl setle setna setnae setnb \
-	setnbe setnc setne setng setnge setnl setnle setno setnp setns \
-	setnz seto setp setpe setpo sets setz shld shrd stosd \
-	bswap cmpxchg invd  invlpg  wbinvd  xadd \
-	lock rep repe repne repnz repz
-
-# these are mostly non-MMX/SSE/SSE2 486+ instructions
-
-cpu_instruction2=cflush cpuid emms femms \
-	cmovo cmovno cmovb cmovc cmovnae cmovae cmovnb cmovnc \
-	cmove cmovz cmovne cmovnz cmovbe cmovna cmova cmovnbe \
-	cmovs cmovns cmovp cmovpe cmovnp cmovpo cmovl cmovnge \
-	cmovge cmovnl cmovle cmovng cmovg cmovnle \
-	cmpxchg486 cmpxchg8b  \
-	loadall loadall286 ibts icebp int1 int3 int01 int03 iretw \
-	popaw popfw pushaw pushfw rdmsr rdpmc rdshr rdtsc \
-	rsdc rsldt rsm rsts salc smi smint smintold svdc svldt svts \
-	syscall sysenter sysexit sysret ud0 ud1 ud2 umov xbts wrmsr wrshr
-
-# fpu instructions, updated for 486+
+
+bcd_instruction=aaa aad aam aas daa das
+flow_instruction=ja jae jb jbe jc jcxz je jg jge jl jle jmp jna \
+	jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz \
+	jo jp jpe jpo js jz \
+	jcxz jecxz jrcxz \
+	loop loope loopne loopz loopnz \
+	call ret
+
+alu_instruction=add sub adc sbb neg cmp inc dec \
+	and or xor not test \
+	shl shr sal sar shld shrd rol ror rcl rcr \
+	cbw cwd cwde cdq cdqe cqo \
+	bsf bsr bt btc btr bts \
+	idiv imul div mul bswap \
+	nop
+
+mem_instruction=lea \
+	mov movsx movsxd movzx \
+	xlatb bound \
+	xchg xadd cmpxchg cmpxchg8b cmpxchg16b
+
+stack_instruction=push pop pushad popad pushf popf pushfd popfd pushfq popfq
+
+pred_instruction=seta setae setb setbe setc sete setg setge setl \
+	setle setna setnae setnb setnbe setnc setne setng setnge \
+	setnl setnle setno setnp setns setnz seto setp setpe setpo \
+	sets setz \
+	salc
+
+flag_instruction=clc cld stc std cmc lahf sahf
+
+cmov_instruction=cmovo cmovno cmovb cmovc cmovnae cmovae cmovnb \
+	cmovnc cmove cmovz cmovne cmovnz cmovbe cmovna cmova \
+	cmovnbe cmovs cmovns cmovp cmovpe cmovnp cmovpo cmovl \
+	cmovnge cmovge cmovnl cmovle cmovng cmovg cmovnle
+
+prefix_instruction=lock rep repe repz repne repnz
+
+string_instruction=cmpsb cmpsw cmpsq \
+	movsb movsw movsq \
+	scasb scasw scasd scasq \
+	stosb stosw stosd stosq
+
+info_instruction=cpuid rdtsc rdtscp rdpmc xgetbv
+
+lwp_instruction=llwpcb slwpcb lwpval lwpins
+
+ext_instruction=crc32 popcnt lzcnt tzcnt movbe pclmulqdq rdrand
+
+bmi1_instruction=andn bextr blsi blsmk blsr
+
+bmi2_instruction=bzhi mulx pdep pext rorx sarx shlx shrx
+
+tbm_instruction=blcfill blci blcic blcmsk blcs blsfill blsic t1mskc tzmsk
 
 fpu_instruction=f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp \
 	fdisi fdiv fdivp fdivr fdivrp feni ffree fiadd ficom ficomp fidiv \
@@ -181,118 +198,327 @@ fpu_instruction=f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fd
 	fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub fsubp \
 	fsubr fsubrp ftst fwait fxam fxch fxtract fyl2x fyl2xp1 \
 	fsetpm fcos fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin fsincos \
-	fstenvd fucom fucomp fucompp fcomi fcomip ffreep \
+	fstenvd fucom fucomp fucompp fcomi fcomip fucomi fucomip ffreep \
 	fcmovb fcmove fcmovbe fcmovu fcmovnb fcmovne fcmovnbe fcmovnu
 
-# these are MMX, SSE, SSE2 instructions
-
-ext_instruction=addpd addps addsd addss andpd andps andnpd andnps \
-	cmpeqpd cmpltpd cmplepd cmpunordpd cmpnepd cmpnltpd cmpnlepd cmpordpd \
-	cmpeqps cmpltps cmpleps cmpunordps cmpneps cmpnltps cmpnleps cmpordps \
-	cmpeqsd cmpltsd cmplesd cmpunordsd cmpnesd cmpnltsd cmpnlesd cmpordsd \
-	cmpeqss cmpltss cmpless cmpunordss cmpness cmpnltss cmpnless cmpordss \
-	comisd comiss cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps \
-	cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtss2sd cvtss2si \
-	cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss \
-	cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi cvttsd2si cvttss2si \
-	divpd divps divsd divss fxrstor fxsave ldmxscr lfence mfence \
-	maskmovdqu maskmovdq maxpd maxps paxsd maxss minpd minps minsd minss \
-	movapd movaps movdq2q movdqa movdqu movhlps movhpd movhps movd movq \
-	movlhps movlpd movlps movmskpd movmskps movntdq movnti movntpd movntps \
-	movntq movq2dq movsd movss movupd movups mulpd mulps mulsd mulss \
-	orpd orps packssdw packsswb packuswb paddb paddsb paddw paddsw \
-	paddd paddsiw paddq paddusb paddusw pand pandn pause paveb pavgb pavgw \
-	pavgusb pdistib pextrw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw pcmpgtd \
-	pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul \
-	pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub pmovmskb \
-	pmulhrwc pmulhriw pmulhrwa pmulhuw pmulhw pmullw pmuludq \
-	pmvzb pmvnzb pmvlzb pmvgezb pfnacc pfpnacc por prefetch prefetchw \
-	prefetchnta prefetcht0 prefetcht1 prefetcht2 pfrcp pfrcpit1 pfrcpit2 \
-	pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pf2iw pinsrw psadbw pshufd \
-	pshufhw pshuflw pshufw psllw pslld psllq pslldq psraw psrad \
-	psrlw psrld psrlq psrldq psubb psubw psubd psubq psubsb psubsw \
-	psubusb psubusw psubsiw pswapd punpckhbw punpckhwd punpckhdq punpckhqdq \
-	punpcklbw punpcklwd punpckldq punpcklqdq pxor rcpps rcpss \
-	rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss \
-	stmxcsr subpd subps subsd subss ucomisd ucomiss \
-	unpckhpd unpckhps unpcklpd unpcklps xorpd xorps
-
-register=ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs \
-	cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp ebx ecx edi edx \
-	es esi esp fs gs si sp ss st tr3 tr4 tr5 tr6 tr7 \
-	st0 st1 st2 st3 st4 st5 st6 st7 mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 \
-	xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7
-
-register_64=rax rcx rdx rbx rsp rbp rsi rdi \
-	r8 r8d r8w r8b r9 r9d r9w r9b \
-	r10 r10d r10w r10b r11 r11d r11w r11b \
-	r12 r12d r12w r12b r13 r13d r13w r13b \
-	r14 r14d r14w r14b r15 r15d r15w r15b \
-	rip rflags gdtr idtr ldtr tr \
-	cr8 xcr0 \
-	xmm8 xmm9 xmm10 xmm12 xmm12 xmm13 xmm14 xmm15
-
-# masm directives
-
-directive=.186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p \
-	.8086 .8087 .alpha .break .code .const .continue .cref .data .data?  \
-	.dosseg .else .elseif .endif .endw .err .err1 .err2 .errb \
-	.errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef \
-	.errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall \
-	.listif .listmacro .listmacroall  .model .no87 .nocref .nolist \
-	.nolistif .nolistmacro .radix .repeat .sall .seq .sfcond .stack \
-	.startup .tfcond .type .until .untilcxz .while .xall .xcref \
-	.xlist alias align assume catstr comm comment db dd df dosseg dq \
-	dt dup dw echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif \
-	elseifdifi elseife elseifidn elseifidni elseifnb elseifndef end \
-	endif endm endp ends eq equ even exitm extern externdef extrn for \
-	forc ge goto group gt high highword if if1 if2 ifb ifdef ifdif \
-	ifdifi ife  ifidn ifidni ifnb ifndef include includelib instr invoke \
-	irp irpc label le length lengthof local low lowword lroffset \
-	lt macro mask mod .msfloat name ne offset opattr option org %out \
-	page popcontext proc proto ptr public purge pushcontext record \
-	repeat rept seg segment short size sizeof sizestr struc struct \
-	substr subtitle subttl textequ this title type typedef union while width
-
-directive_operand=$ ? @b @f addr basic byte c carry? dword \
-	far far16 fortran fword near near16 overflow? parity? pascal qword  \
-	real4  real8 real10 sbyte sdword sign? stdcall sword syscall tbyte \
-	vararg word zero? flat near32 far32 \
-	abs all assumes at casemap common compact \
-	cpu dotname emulator epilogue error export expr16 expr32 farstack flat \
-	forceframe huge language large listing ljmp loadds m510 medium memory \
-	nearstack nodotname noemulator nokeyword noljmp nom510 none nonunique \
-	nooldmacros nooldstructs noreadonly noscoped nosignextend nothing \
-	notpublic oldmacros oldstructs os_dos para private prologue radix \
-	readonly req scoped setif2 smallstack tiny use16 use32 uses \
-
-# nasm directives, mostly complete, does not parse properly
-# the following: %!<env>, %%, %+, %+n %-n, %{n}
-
-directive_nasm=db dw dd dq dt resb resw resd resq rest incbin equ times \
-	%define %idefine %xdefine %xidefine %undef %assign %iassign \
-	%strlen %substr %macro %imacro %endmacro %rotate .nolist \
-	%if %elif %else %endif %ifdef %ifndef %elifdef %elifndef \
-	%ifmacro %ifnmacro %elifmacro %elifnmacro %ifctk %ifnctk %elifctk %elifnctk \
-	%ifidn %ifnidn %elifidn %elifnidn %ifidni %ifnidni %elifidni %elifnidni \
-	%ifid %ifnid %elifid %elifnid %ifstr %ifnstr %elifstr %elifnstr \
-	%ifnum %ifnnum %elifnum %elifnnum %error %rep %endrep %exitrep \
-	%include %push %pop %repl struct endstruc istruc at iend align alignb \
-	%arg %stacksize %local %line \
-	bits use16 use32 section absolute extern global common cpu org \
-	section group import export
-
-directive_operand_nasm=a16 a32 o16 o32 byte word dword nosplit $ $$ seq wrt \
-	flat large small .text .data .bss near far \
-	%0 %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-
-keywords.$(file.patterns.asm)=$(cpu_instruction) $(cpu_instruction2)
+mmx_instruction=movd movq \
+	paddb paddw paddd paddsb paddsw paddusb paddusw \
+	psubb psubw psubd psubsb psubsw psubusb psubusw \
+	pand pandn por pxor \
+	pcmpeqb pcmpeqd pcmpeqw pcmpgtb pcmpgtd pcmpgtw \
+	pmaddwd pmulhw pmullw \
+	psllw pslld psllq psrlw psrld psrlq psraw psrad \
+	packuswb packsswb packssdw \
+	punpcklbw punpcklwd punpckldq punpckhbw punpckhwd punpckhdq \
+	emms
+
+mmx2_instruction=pavgb pavgw \
+	pextrw pinsrw pmovmskb \
+	pmaxsw pmaxub pminsw pminub \
+	pmulhuw psadbw pshufw \
+	prefetchnta prefetcht0 prefetcht1 prefetcht2 \
+	maskmovq movntq sfence
+
+emmx_instruction=paddsiw psubsiw \
+	pmulhrw pmachriw pmulhriw \
+	pmagw pdistib paveb \
+	pmvzb pmvnzb pmvlzb pmvgezb 
+
+k3d_instruction=pfacc pfadd pfsub pfsubr pfmul \
+	pfcmpeq pfcmpge pfcmpgt \
+	pfmax pfmin \
+	pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt \
+	pi2fd pf2id \
+	pavgusb pmulhrw \
+	femms
+
+k3d2_instruction=pfnacc pfpnacc pi2fw pf2iw pswapd
+
+k3dgeode_instruction=pfrsqrtv pfrcpv
+
+k3dprefetch_instruction=prefetch prefetchw
+
+sse_instruction=addss addps subss subps \
+	mulss mulps divss divps sqrtss sqrtps \ 
+	rcpss rcpps rsqrtss rsqrtps \
+	maxss maxps minss minps \
+	cmpss comiss ucomiss cmpps \
+	cmpeqss cmpltss cmpless cmpunordss cmpneqss cmpnltss cmpnless cmpordss \
+	cmpeqps cmpltps cmpleps cmpunordps cmpneqps cmpnltps cmpnleps cmpordps \
+	andnps andps orps xorps \
+	cvtsi2ss cvtss2si cvttss2si \
+	cvtpi2ps cvtps2pi cvttps2pi \
+	movss movlps movhps movlhps movhlps movaps movups movntps movmskps \
+	shufps unpckhps unpcklps \
+	ldmxcsr stmxcsr
+
+sse2_instruction=addpd addsd subpd subsd \
+	mulsd mulpd divsd divpd sqrtsd sqrtpd \
+	maxsd maxpd minsd minpd \
+	cmpsd comisd ucomisd cmppd \
+	cmpeqsd cmpltsd cmplesd cmpunordsd cmpneqsd cmpnltsd cmpnlesd cmpordsd \
+	cmpeqpd cmpltpd cmplepd cmpunordpd cmpneqpd cmpnltpd cmpnlepd cmpordpd \
+	andnpd andpd orpd xorpd \
+	cvtsd2ss cvtpd2ps cvtss2sd cvtps2pd \
+	cvtdq2ps cvtps2dq cvttps2dq \
+	cvtdq2pd cvtpd2dq cvttpd2dq \
+	cvtsi2sd cvtsd2si cvttsd2si \
+	cvtpi2pd cvtpd2pi cvttpd2pi \
+	movsd movlpd movhpd movapd movupd movntpd movmskpd \
+	shufpd unpckhpd unpcklpd \
+	movnti movdqa movdqu movntdq maskmovdqu \
+	movdq2q movq2dq \
+	paddq psubq pmuludq \
+	pslldq psrldq \
+	punpcklqdq punpckhqdq \
+	pshufhw pshuflw pshufd \
+	lfence mfence
+
+sse3_instruction=addsubps addsubpd \
+	haddps haddpd hsubps hsubpd \
+	movsldup movshdup movddup \
+	lddqu \
+	fisttp
+
+ssse3_instruction=psignb psignw psignd \
+	pabsb pabsw pabsd \
+	palignr pshufb \
+	pmulhrsw pmaddubsw \
+	phaddw phaddd phaddsw \
+	phsubw phsubd phsubsw
+
+sse4a_instruction=extrq insertq \
+	movntsd movntss
+
+sse41_instruction=mpsadbw phminposuw \
+	pmuldq pmulld \
+	dpps dppd \
+	blendps blendpd blendvps blendvpd pblendvb pblendw \
+	pmaxsb pmaxuw pmaxsd pmaxud pminsb pminuw pminsd pminud \
+	roundps roundss roundpd roundsd \
+	insertps pinsrb pinsrd pinsrq \
+	extractps pextrb pextrd pextrq \
+	pmovsxbw pmovsxbd pmovsxbq pmovsxwd pmovsxwq pmovsxdq \
+	pmovzxbw pmovzxbd pmovzxbq pmovzxwd pmovzxwq pmovzxdq \
+	ptest \
+	pcmpeqq \
+	packusdw \
+	movntdqa
+
+sse42_instruction=pcmpgtq \
+	pcmpestri pcmpestrm pcmpistri pcmpistrm
+
+aes_instruction=aesenc aesenclast aesdec aesdeclast aeskeygenassist aesimc
+
+padlock_instruction=xcryptcbc xcryptcfb xcryptctr xcryptecb xcryptofb \
+	xsha1 xsha256 montmul xstore
+
+
+avx_instruction=vaddss vaddps vaddsd vaddpd vsubss vsubps vsubsd vsubpd \
+	vaddsubps vaddsubpd \
+	vhaddps vhaddpd vhsubps vhsubpd \
+	vmulss vmulps vmulsd vmulpd \
+	vmaxss vmaxps vmaxsd vmaxpd vminss vminps vminsd vminpd \
+	vandps vandpd vandnps vandnpd vorps vorpd vxorps vxorpd \
+	vblendps vblendpd vblendvps vblendvpd \
+	vcmpss vcomiss vucomiss vcmpsd vcomisd vucomisd vcmpps vcmppd \
+	vcmpeqss vcmpltss vcmpless vcmpunordss vcmpneqss vcmpnltss vcmpnless vcmpordss \
+	vcmpeq_uqss vcmpngess vcmpngtss vcmpfalsess vcmpneq_oqss vcmpgess vcmpgtss vcmptruess \
+	vcmpeq_osss vcmplt_oqss vcmple_oqss vcmpunord_sss vcmpneq_usss vcmpnlt_uqss vcmpnle_uqss vcmpord_sss \
+	vcmpeq_usss vcmpnge_uqss vcmpngt_uqss vcmpfalse_osss vcmpneq_osss vcmpge_oqss vcmpgt_oqss vcmptrue_usss \
+	vcmpeqps vcmpltps vcmpleps vcmpunordps vcmpneqps vcmpnltps vcmpnleps vcmpordps \
+	vcmpeq_uqps vcmpngeps vcmpngtps vcmpfalseps vcmpneq_oqps vcmpgeps vcmpgtps vcmptrueps \
+	vcmpeq_osps vcmplt_oqps vcmple_oqps vcmpunord_sps vcmpneq_usps vcmpnlt_uqps vcmpnle_uqps vcmpord_sps \
+	vcmpeq_usps vcmpnge_uqps vcmpngt_uqps vcmpfalse_osps vcmpneq_osps vcmpge_oqps vcmpgt_oqps vcmptrue_usps \
+	vcmpeqsd vcmpltsd vcmplesd vcmpunordsd vcmpneqsd vcmpnltsd vcmpnlesd vcmpordsd \
+	vcmpeq_uqsd vcmpngesd vcmpngtsd vcmpfalsesd vcmpneq_oqsd vcmpgesd vcmpgtsd vcmptruesd \
+	vcmpeq_ossd vcmplt_oqsd vcmple_oqsd vcmpunord_ssd vcmpneq_ussd vcmpnlt_uqsd vcmpnle_uqsd vcmpord_ssd \
+	vcmpeq_ussd vcmpnge_uqsd vcmpngt_uqsd vcmpfalse_ossd vcmpneq_ossd vcmpge_oqsd vcmpgt_oqsd vcmptrue_ussd \
+	vcmpeqpd vcmpltpd vcmplepd vcmpunordpd vcmpneqpd vcmpnltpd vcmpnlepd vcmpordpd \
+	vcmpeq_uqpd vcmpngepd vcmpngtpd vcmpfalsepd vcmpneq_oqpd vcmpgepd vcmpgtpd vcmptruepd \
+	vcmpeq_ospd vcmplt_oqpd vcmple_oqpd vcmpunord_spd vcmpneq_uspd vcmpnlt_uqpd vcmpnle_uqpd vcmpord_spd \
+	vcmpeq_uspd vcmpnge_uqpd vcmpngt_uqpd vcmpfalse_ospd vcmpneq_ospd vcmpge_oqpd vcmpgt_oqpd vcmptrue_uspd \
+	vcvtsd2ss vcvtpd2ps vcvtss2sd vcvtps2pd \
+	vcvtsi2ss vcvtss2si vcvttss2si \
+	vcvtpi2ps vcvtps2pi vcvttps2pi \
+	vcvtdq2ps vcvtps2dq vcvttps2dq \
+	vcvtdq2pd vcvtpd2dq vcvttpd2dq \
+	vcvtsi2sd vcvtsd2si vcvttsd2si \
+	vcvtpi2pd vcvtpd2pi vcvttpd2pi \
+	vdivss vdivps vdivsd vdivpd vsqrtss vsqrtps vsqrtsd vsqrtpd \
+	vdpps vdppd \
+	vmaskmovps vmaskmovpd \
+	vmovss vmovsd vmovaps vmovapd vmovups vmovupd vmovntps vmovntpd \
+	vmovhlps vmovlhps vmovlps vmovlpd vmovhps vmovhpd \
+	vmovsldup vmovshdup vmovddup \
+	vmovmskps vmovmskpd \
+	vroundss vroundps vroundsd vroundpd \
+	vrcpss vrcpps vrsqrtss vrsqrtps \
+	vunpcklps vunpckhps vunpcklpd vunpckhpd \
+	vbroadcastss vbroadcastsd vbroadcastf128 \
+	vextractps vinsertps vextractf128 vinsertf128 \
+	vshufps vshufpd vpermilps vpermilpd vperm2f128 \
+	vtestps vtestpd \
+	vpaddb vpaddusb vpaddsb vpaddw vpaddusw vpaddsw vpaddd vpaddq \
+	vpsubb vpsubusb vpsubsb vpsubw vpsubusw vpsubsw vpsubd vpsubq \
+	vphaddw vphaddsw vphaddd vphsubw vphsubsw vphsubd \
+	vpsllw vpslld vpsllq vpsrlw vpsrld vpsrlq vpsraw vpsrad \
+	vpand vpandn vpor vpxor \
+	vpblendwb vpblendw \
+	vpsignb vpsignw vpsignd \
+	vpavgb vpavgw \
+	vpabsb vpabsw vpabsd \
+	vmovd vmovq vmovdqa vmovdqu vlddqu vmovntdq vmovntdqa vmaskmovdqu \
+	vpmovsxbw vpmovsxbd vpmovsxbq vpmovsxwd vpmovsxwq vpmovsxdq \
+	vpmovzxbw vpmovzxbd vpmovzxbq vpmovzxwd vpmovzxwq vpmovzxdq \
+	vpackuswb vpacksswb vpackusdw vpackssdw \
+	vpcmpeqb vpcmpeqw vpcmpeqd vpcmpeqq vpcmpgtb vpcmpgtw vpcmpgtd vpcmpgtq \
+	vpmaddubsw vpmaddwd \
+	vpmullw vpmulhuw vpmulhw vpmulhrsw vpmulld vpmuludq vpmuldq \
+	vpmaxub vpmaxsb vpmaxuw vpmaxsw vpmaxud vpmaxsd \
+	vpminub vpminsb vpminuw vpminsw vpminud vpminsd \
+	vpmovmskb vptest \
+	vpunpcklbw vpunpcklwd vpunpckldq vpunpcklqdq \
+	vpunpckhbw vpunpckhwd vpunpckhdq vpunpckhqdq \
+	vpslldq vpsrldq vpalignr \
+	vpshufb vpshuflw vpshufhw vpshufd \
+	vpextrb vpextrw vpextrd vpextrq vpinsrb vpinsrw vpinsrd vpinsrq \
+	vpsadbw vmpsadbw vphminposuw \
+	vpcmpestri vpcmpestrm vpcmpistri vpcmpistrm \
+	vpclmulqdq vaesenc vaesenclast vaesdec vaesdeclast vaeskeygenassist vaesimc \
+	vldmxcsr vstmxcsr vzeroall vzeroupper
+
+avx2_instruction=vbroadcasti128 vpbroadcastb vpbroadcastw vpbroadcastd vpbroadcastq \
+	vpblendd \
+	vpermd vpermq vperm2i128 \
+	vextracti128 vinserti128 \
+	vpmaskmovd vpmaskmovq \
+	vpsllvd vpsllvq vpsravd vpsrlvd vpsrldq \
+	vpgatherdd vpgatherqd vgatherdq vgatherqq \
+	vpermps vpermpd \
+	vgatherdpd vgatherqpd vgatherdps vgatherqps
+
+xop_instruction=vfrczss vfrczps vfrczsd vfrczpd \
+	vpermil2ps vperlil2pd \
+	vtestps vtestpd \
+	vpcomub vpcomb vpcomuw vpcomw vpcomud vpcomd vpcomuq vpcomq \
+	vphaddubw vphaddbw vphaddubd vphaddbd vphaddubq vphaddbq \
+	vphadduwd vphaddwd vphadduwq vphaddwq vphaddudq vphadddq \
+	vphsubbw vphsubwd vphsubdq \
+	vpmacsdd vpmacssdd vpmacsdql vpmacssdql vpmacsdqh vpmacssdqh \
+	vpmacsww vpmacssww vpmacswd vpmacsswd \
+	vpmadcswd vpmadcsswd \
+	vpcmov vpperm \
+	vprotb vprotw vprotd vprotq \
+	vpshab vpshaw vpshad vpshaq \
+	vpshlb vpshlw vpshld vpshlq
+
+cvt16_instruction=vcvtph2ps vcvtps2ph
+
+fma4_instruction=vfmaddss vfmaddps vfmaddsd vfmaddpd \
+	vfmsubss vfmsubps vfmsubsd vfmsubpd \
+	vnfmaddss vnfmaddps vnfmaddsd vnfmaddpd \
+	vnfmsubss vnfmsubps vnfmsubsd vnfmsubpd \
+	vfmaddsubps vfmaddsubpd vfmsubaddps vfmsubaddpd
+
+fma3_instruction=vfmadd132ss vfmadd213ss vfmadd231ss \
+	vfmadd132ps vfmadd213ps vfmadd231ps \
+	vfmadd132sd vfmadd213sd vfmadd231sd \
+	vfmadd132pd vfmadd213pd vfmadd231pd \
+	vfmaddsub132ps vfmaddsub213ps vfmaddsub231ps \
+	vfmaddsub132pd vfmaddsub213pd vfmaddsub231pd \
+	vfmsubadd132ps vfmsubadd213ps vfmsubadd231ps \
+	vfmsubadd132pd vfmsubadd213pd vfmsubadd231pd \
+	vfmsub132ss vfmsub213ss vfmsub231ss \
+	vfmsub132ps vfmsub213ps vfmsub231ps \
+	vfmsub132sd vfmsub213sd vfmsub231sd \
+	vfmsub132pd vfmsub213pd vfmsub231pd \
+	vfnmadd132ss vfnmadd213ss vfnmadd231ss \
+	vfnmadd132ps vfnmadd213ps vfnmadd231ps \
+	vfnmadd132sd vfnmadd213sd vfnmadd231sd \
+	vfnmadd132pd vfnmadd213pd vfnmadd231pd \
+	vfnmsub132ss vfnmsub213ss vfnmsub231ss \
+	vfnmsub132ps vfnmsub213ps vfnmsub231ps \
+	vfnmsub132sd vfnmsub213sd vfnmsub231sd \
+	vfnmsub132pd vfnmsub213pd vfnmsub231pd
+
+register=al ah bl bh cl ch dl dh \
+	ax bx cx dx si di bp \
+	eax ebx ecx edx esi edi ebx esp \
+	st0 st1 st2 st3 st4 st5 st6 st7 \
+	mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 \
+	xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 \
+	ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 \
+	fs
+
+register_64=sil dil bpl \
+	r8b r9b r10b r11b r12b r13b r14b r15b \
+	r8w r9w r10w r11w r12w r13w r14w r15w \
+	rax rcx rdx rbx rsp rbp rsi rdi \
+	r8 r9 r10 r11 r12 r13 r14 r15 \
+	xmm8 xmm9 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 \
+	ymm8 ymm9 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 \
+	gs
+
+directive_nasm=db dw dd dq dt do dy \
+	resb resw resd resq rest reso resy incbin equ times safeseh \
+	__utf16__ __utf32__ %+ \
+	default cpu float start imagebase osabi \
+	..start ..imagebase ..gotpc ..gotoff ..gottpoff ..got ..plt ..sym ..tlsie \
+	section segment __sect__ group absolute \
+	.bss .comment .data .lbss .ldata .lrodata .rdata .rodata .tbss .tdata .text \
+	alloc bss code exec data noalloc nobits noexec nowrite progbits rdata tls write \
+	private public common stack overlay class \
+	extern global common import export \
+	%define %idefine %xdefine %ixdefine %assign %undef %? %?? \
+	%defstr %idefstr %deftok %ideftok \
+	%strcat %strlen %substr \
+	%macro %imacro %rmacro %exitmacro %endmacro %unmacro \
+	%if %ifn %elif %elifn %else %endif \
+	%ifdef %ifndef %elifdef %elifndef \
+	%ifmacro %ifnmacro %elifmacro %elifnmacro \
+	%ifctx %ifnctx %elifctx %elifnctx \
+	%ifidn %ifnidn %elifidn %elifnidn \
+	%ifidni %ifnidni %elifidni %elifnidni \
+	%ifid %ifnid %elifid %elifnid \
+	%ifnum %ifnnum %elifnum %elifnnum \
+	%ifstr %ifnstr %elifstr %elifnstr \
+	%iftoken %ifntoken %eliftoken %elifntoken \
+	%ifempty %elifempty %ifnempty %elifnempty \
+	%ifenv %ifnenv %elifenv %elifnenv \
+	%rep %exitrep %endrep \
+	%while %exitwhile %endwhile \
+	%include %pathsearch %depend %use \
+	%push %pop %repl %arg %local %stacksize flat flat64 large small \
+	%error %warning %fatal \
+	%00 .nolist %rotate %line %! %final %clear \
+	struc endstruc istruc at iend \
+	align alignb sectalign \
+	bits use16 use32 use64 \
+	__nasm_major__ __nasm_minor__ __nasm_subminor__ ___nasm_patchlevel__ \
+	__nasm_version_id__ __nasm_ver__ \
+	__file__ __line__ __pass__ __bits__ __output_format__ \
+	__date__ __time__ __date_num__ __time_num__ __posix_time__ \
+	__utc_date__ __utc_time__ __utc_date_num__ __utc_time_num__ \
+	__float_daz__ __float_round__ __float__ \
+	__use_altreg__ altreg \
+	__use_smartalign__ smartalign __alignmode__ \
+	__use_fp__ __infinity__ __nan__ __qnan__ __snan__ \
+	__float8__ __float16__ __float32__ __float64__ __float80m__ __float80e__ __float128l__ __float128h__
+
+directive_operand_nasm=a16 a32 a64 o16 o32 o64 strict \
+	byte word dword qword tword oword yword nosplit \
+	%0 %1 %2 %3 %4 %5 %6 %7 %8 %9 \
+	abs rel \
+	$ $$ \
+	seg wrt
+
+keywords.$(file.patterns.asm)=$(bcd_instruction) $(flow_instruction) $(alu_instruction) $(mem_instruction) $(stack_instruction) $(pred_instruction) $(flag_instruction) $(cmov_instruction) $(prefix_instruction) $(string_instruction) $(info_instruction) $(lwp_instruction) $(ext_instruction) $(bmi1_instruction) $(bmi2_instruction)
 keywords2.$(file.patterns.asm)=$(fpu_instruction)
 keywords3.$(file.patterns.asm)=$(register) $(register_64)
-keywords4.$(file.patterns.asm)=$(directive) $(directive_nasm)
-keywords5.$(file.patterns.asm)=$(directive_operand) $(directive_operand_nasm)
-keywords6.$(file.patterns.asm)=$(ext_instruction)
+keywords4.$(file.patterns.asm)=$(directive_nasm)
+keywords5.$(file.patterns.asm)=$(directive_operand_nasm)
+keywords6.$(file.patterns.asm)=$(mmx_instruction) $(mmx2_instruction) $(emmx_instruction) $(k3d_instruction) $(k3d2_instruction) $(k3dgeode_instruction) $(k3dprefetch_instruction) $(sse_instruction) $(sse2_instruction) $(sse3_instruction) $(ssse3_instruction) $(sse4a_instruction) $(sse41_instruction) $(sse42_instruction) $(aes_instruction) $(padlock_instruction) $(avx_instruction) $(avx2_instruction) $(xop_instruction) $(cvt16_instruction) $(fma4_instruction) $(fma3_instruction)
 
 comment.block.asm=;
 
@@ -302,7 +528,7 @@ comment.block.asm=;
 #fore:#0000ff
 
 
-command.compile.$(file.patterns.asm)=masm $(FileNameExt)
+command.compile.$(file.patterns.asm)=nasm $(FileNameExt)
 
 command.name.0.*.asm=Link
 command.0.*.asm=link $(FileName)
@@ -526,7 +752,7 @@ keywords6.$(file.patterns.au3)= #region #endregion
 
 ###############################################################################
 # From ave.properties
-# Define SciTE settings for Avennue files.
+# Define SciTE settings for Avenue files.
 
 filter.ave=AVE (ave)|*.ave|
 
@@ -602,6 +828,112 @@ avenueBuild=avebuild "$(FilePath)"
 
 
 ###############################################################################
+# From avs.properties
+# Define SciTE settings for AviSynth scripts.
+
+file.patterns.avs=*.avs;*.avsi
+
+filter.avs=AviSynth (avs avsi)|$(file.patterns.avs)|
+
+lexer.$(file.patterns.avs)=avs
+
+word.chars.avs=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.avs)=$(word.chars.avs)
+
+autocomplete.avs.ignorecase=1
+autocomplete.avs.fillups=(
+calltip.avs_quote.ignorecase=1
+calltip.avs.word.characters=$(word.chars.avs)
+
+comment.block.at.line.start.avs=1
+comment.block.avs=#~
+comment.stream.start.avs=/*
+comment.stream.end.avs=*/
+comment.box.start.avs=/*
+comment.box.middle.avs= *
+comment.box.end.avs= */
+
+# Keywords
+keywords.$(file.patterns.avs)=true false return global
+
+# Filters
+keywords2.$(file.patterns.avs)=addborders alignedsplice amplify amplifydb animate applyrange assumebff \
+assumefieldbased assumefps assumeframebased assumesamplerate assumescaledfps assumetff audiodub audiodubex \
+avifilesource avisource bicubicresize bilinearresize blackmanresize blackness blankclip blur bob cache \
+changefps colorbars colorkeymask coloryuv compare complementparity conditionalfilter conditionalreader \
+convertaudio convertaudioto16bit convertaudioto24bit convertaudioto32bit convertaudioto8bit convertaudiotofloat \
+convertbacktoyuy2 convertfps converttobackyuy2 converttomono converttorgb converttorgb24 converttorgb32 \
+converttoy8 converttoyv16 converttoyv24 converttoyv411 converttoyuy2 converttoyv12 crop cropbottom delayaudio \
+deleteframe dissolve distributor doubleweave duplicateframe ensurevbrmp3sync fadein fadein0 fadein2 fadeio fadeio0 \
+fadeio2 fadeout fadeout0 fadeout2 fixbrokenchromaupsampling fixluminance fliphorizontal flipvertical frameevaluate \
+freezeframe gaussresize generalconvolution getchannel getchannels getmtmode getparity grayscale greyscale histogram \
+horizontalreduceby2 imagereader imagesource imagewriter info interleave internalcache internalcachemt invert killaudio \
+killvideo lanczos4resize lanczosresize layer letterbox levels limiter loop mask maskhs max merge mergeargb mergechannels \
+mergechroma mergeluma mergergb messageclip min mixaudio monotostereo normalize null opendmlsource overlay peculiarblend \
+pointresize pulldown reduceby2 resampleaudio resetmask reverse rgbadjust scriptclip segmentedavisource segmenteddirectshowsource \
+selecteven selectevery selectodd selectrangeevery separatefields setmtmode sharpen showalpha showblue showfiveversions \
+showframenumber showgreen showred showsmpte showtime sincresize skewrows spatialsoften spline16resize spline36resize \
+spline64resize ssrc stackhorizontal stackvertical subtitle subtract supereq swapfields swapuv temporalsoften timestretch \
+tone trim turn180 turnleft turnright tweak unalignedsplice utoy utoy8 version verticalreduceby2 vtoy vtoy8 wavsource \
+weave writefile writefileend writefileif writefilestart ytouv
+
+# Plugins
+keywords3.$(file.patterns.avs)=addgrain addgrainc agc_hdragc analyzelogo animeivtc asharp audiograph autocrop \
+autoyuy2 avsrecursion awarpsharp bassaudiosource bicublinresize bifrost binarize blendfields blindpp blockbuster \
+bordercontrol cfielddiff cframediff chromashift cnr2 colormatrix combmask contra convolution3d convolution3dyv12 \
+dctfilter ddcc deblendlogo deblock deblock_qed decimate decomb dedup deen deflate degrainmedian depan depanestimate \
+depaninterleave depanscenes depanstabilize descratch despot dfttest dgbob dgsource directshowsource distancefunction \
+dss2 dup dupmc edeen edgemask ediupsizer eedi2 eedi3 eedi3_rpow2 expand faerydust fastbicubicresize fastbilinearresize \
+fastediupsizer dedgemask fdecimate ffaudiosource ffdshow ffindex ffmpegsource ffmpegsource2 fft3dfilter fft3dgpu \
+ffvideosource fielddeinterlace fielddiff fillmargins fity2uv fity2u fity2v fitu2y fitv2y fluxsmooth fluxsmoothst fluxsmootht \
+framediff framenumber frfun3b frfun7 gicocu golddust gradfun2db grapesmoother greedyhma grid guavacomb hqdn3d hybridfupp \
+hysteresymask ibob improvesceneswitch inflate inpand inpaintlogo interframe interlacedresize interlacedwarpedresize \
+interleaved2planar iscombed iscombedt iscombedtivtc kerneldeint leakkernelbob leakkerneldeint limitedsharpen limitedsharpenfaster \
+logic lsfmod lumafilter lumayv12 manalyse maskeddeinterlace maskedmerge maskedmix mblockfps mcompensate mctemporaldenoise \
+mctemporaldenoisepp mdegrain1 mdegrain2 mdegrain3 mdepan medianblur mergehints mflow mflowblur mflowfps mflowinter minblur mipsmooth \
+mmask moderatesharpen monitorfilter motionmask mpasource mpeg2source mrecalculate mscdetection msharpen mshow msmooth msu_fieldshiftfixer \
+msu_frc msuper mt mt_adddiff mt_average mt_binarize mt_circle mt_clamp mt_convolution mt_deflate mt_diamond mt_edge mt_ellipse \
+mt_expand mt_freeellipse mt_freelosange mt_freerectangle mt_hysteresis mt_infix mt_inflate mt_inpand mt_invert mt_logic mt_losange \
+mt_lut mt_lutf mt_luts mt_lutspa mt_lutsx mt_lutxy mt_lutxyz mt_makediff mt_mappedblur mt_merge mt_motion mt_polish mt_rectangle \
+mt_square mti mtsource multidecimate mvanalyse mvblockfps mvchangecompensate mvcompensate mvdegrain1 mvdegrain2 mvdegrain3 mvdenoise \
+mvdepan mvflow mvflowblur mvflowfps mvflowfps2 mvflowinter mvincrease mvmask mvrecalculate mvscdetection mvshow nicac3source nicdtssource \
+niclpcmsource nicmpasource nicmpg123source nnedi nnedi2 nnedi2_rpow2 nnedi3 nnedi3_rpow2 nomosmooth overlaymask peachsmoother pixiedust \
+planar2interleaved qtgmc qtinput rawavsource rawsource reduceflicker reinterpolate411 removedirt removedust removegrain removegrainhd \
+removetemporalgrain repair requestlinear reversefielddominance rgb3dlut rgdeinterlace rgsdeinterlace rgblut rotate sangnom seesaw sharpen2 \
+showchannels showcombedtivtc smartdecimate smartdeinterlace smdegrain smoothdeinterlace smoothuv soothess soxfilter spacedust sshiq ssim \
+ssiq stmedianfilter t3dlut tanisotropic tbilateral tcanny tcomb tcombmask tcpserver tcpsource tdecimate tdeint tedgemask telecide \
+temporalcleaner temporalrepair temporalsmoother tfieldblank tfm tisophote tivtc tmaskblank tmaskedmerge tmaskedmerge3 tmm tmonitor tnlmeans \
+tomsmocomp toon textsub ttempsmooth ttempsmoothf tunsharp unblock uncomb undot unfilter unsharpmask vaguedenoiser variableblur verticalcleaner \
+videoscope vinverse vobsub vqmcalc warpedresize warpsharp xsharpen yadif yadifmod yuy2lut yv12convolution yv12interlacedreduceby2 \
+yv12interlacedselecttopfields yv12layer yv12lut yv12lutxy yv12substract yv12torgb24 yv12toyuy2
+
+# Functions
+keywords4.$(file.patterns.avs)=abs apply assert bool ceil chr clip continueddenominator continuednumerator cos default defined \
+eval averagechromau averagechromav averageluma chromaudifference chromavdifference lumadifference exist exp findstr float floor \
+frac hexvalue import int isbool isclip isfloat isint isstring lcase leftstr load_stdcall_plugin loadcplugin loadplugin loadvfapiplugin \
+loadvirtualdubplugin log midstr muldiv nop opt_allowfloataudio opt_avipadscanlines opt_dwchannelmask opt_usewaveextensible \
+opt_vdubplanarhack pi pow rand revstr rightstr round scriptdir scriptfile scriptname select setmemorymax setplanarlegacyalignment \
+rgbdifference rgbdifferencefromprevious rgbdifferencetonext udifferencefromprevious udifferencetonext setworkingdir sign sin spline \
+sqrt string strlen time ucase undefined value versionnumber versionstring uplanemax uplanemedian uplanemin uplaneminmaxdifference \
+vdifferencefromprevious vdifferencetonext vplanemax vplanemedian vplanemin vplaneminmaxdifference ydifferencefromprevious \
+ydifferencetonext yplanemax yplanemedian yplanemin yplaneminmaxdifference
+
+# Clip properties
+keywords5.$(file.patterns.avs)=audiobits audiochannels audiolength audiolengthf audiorate framecount framerate frameratedenominator \
+frameratenumerator getleftchannel getrightchannel hasaudio hasvideo height isaudiofloat isaudioint isfieldbased isframebased \
+isinterleaved isplanar isrgb isrgb24 isrgb32 isyuv isyuy2 isyv12 width
+
+# User defined
+keywords6.$(file.patterns.avs)=
+
+# AviSynth Styles
+
+# Braces are only matched in operator style
+braces.avs.style=5
+
+
+
+###############################################################################
 # From baan.properties
 # Define SciTE settings for Baan files.
 
@@ -1333,7 +1665,8 @@ file.patterns.flash=*.as;*.asc;*.jsfl
 file.patterns.ch=*.ch;*.chf;*.chs
 file.patterns.vala=*.vala
 file.patterns.go=*.go
-file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);$(file.patterns.java);$(file.patterns.js);$(file.patterns.flash);$(file.patterns.ch);$(file.patterns.vala)
+file.patterns.pike=*.pike
+file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);$(file.patterns.java);$(file.patterns.js);$(file.patterns.flash);$(file.patterns.ch);$(file.patterns.vala);$(file.patterns.pike)
 
 shbang.tcc=cpp
 shbang.tinycc=cpp
@@ -1347,6 +1680,7 @@ filter.test=SilkTest (pln inc t)|$(file.patterns.test)|
 filter.flash=Flash (as asc jsfl)|$(file.patterns.flash)|
 filter.ch=Ch (ch chf chs)|$(file.patterns.ch)|
 filter.go=Go (go)|$(file.patterns.go)|
+filter.pike=Pike (pike)|$(file.patterns.pike)|
 
 lexer.$(file.patterns.java)=cpp
 lexer.$(file.patterns.javafx)=cpp
@@ -1360,6 +1694,7 @@ lexer.$(file.patterns.flash)=cpp
 lexer.$(file.patterns.ch)=cpp
 lexer.$(file.patterns.vala)=cpp
 lexer.$(file.patterns.go)=cpp
+lexer.$(file.patterns.pike)=cpp
 
 keywordclass.cpp=and and_eq asm auto bitand bitor bool break \
 case catch char class compl const const_cast continue \
@@ -1471,7 +1806,7 @@ implicit in int interface internal into is join lock let long namespace new null
 object on operator orderby out override params private protected public \
 readonly ref return sbyte sealed select short sizeof stackalloc static \
 string struct switch this throw true try typeof uint ulong \
-unchecked unsafe ushort using var virtual void where while
+unchecked unsafe ushort using var virtual void volatile where while
 keywords.$(file.patterns.cs)=$(keywordclass.cs)
 word.characters.$(file.patterns.cs)=$(word.chars.cxx)
 
@@ -1596,8 +1931,14 @@ using true false null delete generic new this typeof sizeof as owned int string
 keywords.$(file.patterns.vala)=$(keywordclass.vala)
 keywords2.$(file.patterns.vala)=$(keywordclass2.vala)
 
+keywordclass.pike=constant enum if do for while else foreach case switch break continue \
+return typeof catch class lambda import inherit static void int string float mixed object \
+function program array mapping multiset
+keywords.$(file.patterns.pike)=$(keywordclass.pike)
+
 #lexer.cpp.track.preprocessor=1
 #lexer.cpp.update.preprocessor=1
+#lexer.cpp.hashquoted.strings=1
 
 # C++ styles
 
@@ -1605,7 +1946,6 @@ keywords2.$(file.patterns.vala)=$(keywordclass2.vala)
 # Inactive states are 64 greater than their active counterparts
 
 
-
 # Braces are only matched in operator style
 braces.cpp.style=10
 
@@ -3222,6 +3562,9 @@ if PLAT_WIN
 	command.go.subsystem.$(file.patterns.web)=2
 if PLAT_GTK
 	command.go.$(file.patterns.web)=firefox "file://$(FilePath)"
+if PLAT_MAC
+	command.go.$(file.patterns.web)=open "file://$(FilePath)"
+	command.go.subsystem.$(file.patterns.web)=2
 
 command.go.$(file.patterns.php)=php -f "$(FileNameExt)"
 command.compile.$(file.patterns.php)=php -l "$(FileNameExt)"
@@ -3584,6 +3927,8 @@ if PLAT_GTK
 ###############################################################################
 # From lua.properties
 # Define SciTE settings for Lua files.
+# Lua 5.x highlighting is enabled by default. For other choices,
+# including Lua 4 highlighting, see below.
 
 file.patterns.lua=*.lua
 
@@ -3596,75 +3941,203 @@ lexer.$(file.patterns.lua)=lua
 word.chars.lua=$(chars.alpha)$(chars.numeric)$(chars.accented)_%
 word.characters.$(file.patterns.lua)=$(word.chars.lua)
 
-keywordclass.lua=and break do else elseif end false for function goto \
-if in local nil not or repeat return then true until while
-keywords.$(file.patterns.lua)=$(keywordclass.lua)
+#### Lua 4.0.1
 
-# Basic Functions (in both versions of Lua)
-keywordclass2.lua=_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring \
-print rawget rawset require tonumber tostring type unpack
+# Keywords
+keywordclass.lua4=\
+and break do else elseif \
+end for function if in \
+local nil not or repeat \
+return then until while
 
-#### Lua 4.0
 # Basic Functions
-keywordclass2.lua4=_ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT \
-_STDERR _STDIN _STDOUT call dostring foreach foreachi getn globals newtype \
-sort tinsert tremove
+keywordclass2.lua4=\
+_ALERT assert call collectgarbage copytagmethods \
+dofile dostring error foreach foreachi \
+gcinfo getglobal getn gettagmethod globals \
+newtag next print rawget rawset \
+setglobal settag settagmethod sort tag \
+tonumber tostring tinsert tremove type \
+_VERSION _ERRORMESSAGE
 
 # String Manipulation & Mathematical Functions
-keywordclass3.lua4=abs acos asin atan atan2 ceil cos deg exp \
-floor format frexp gsub ldexp log log10 max min mod rad random randomseed \
-sin sqrt strbyte strchar strfind strlen strlower strrep strsub strupper tan
+keywordclass3.lua4=\
+strbyte strchar strfind strlen strlower \
+strrep strsub strupper format gsub \
+abs acos asin atan atan2 \
+ceil cos deg exp floor \
+log log10 max min mod \
+rad sin sqrt tan frexp \
+ldexp random randomseed PI
 
 # Input and Output Facilities & System Facilities
-keywordclass4.lua4=openfile closefile readfrom writeto appendto \
-remove rename flush seek tmpfile tmpname read write \
-clock date difftime execute exit getenv setlocale time
+keywordclass4.lua4=\
+openfile closefile readfrom writeto appendto \
+remove rename flush seek tmpname read write \
+clock date execute exit getenv setlocale \
+_INPUT _OUTPUT _STDIN _STDOUT _STDERR -- file descriptors
+
+# Debug (not enabled by default)
+keywordclass5.lua4=\
+getinfo getlocal setlocal setcallhook setlinehook
+
+#### Lua 5.0.3
+
+# Keywords
+keywordclass.lua50=$(keywordclass.lua4) false true
 
-#### Lua 5.0
 # Basic Functions
-keywordclass2.lua5=_G getfenv getmetatable ipairs loadlib next pairs pcall \
-rawequal setfenv setmetatable xpcall \
-string table math coroutine io os debug \
-load module select
-# I put the library names here, so when highlighted standalone, they are probably variable name from Lua 4.0 times.
-# Last line -> Lua 5.1 functions
-
-# String Manipulation, Table Manipulation, Mathematical Functions (string & table & math)
-keywordclass3.lua5=string.byte string.char string.dump string.find string.len \
-string.lower string.rep string.sub string.upper string.format string.gfind string.gsub \
-table.concat table.foreach table.foreachi table.getn table.sort table.insert table.remove table.setn \
-math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.deg math.exp \
-math.floor math.frexp math.ldexp math.log math.log10 math.max math.min math.mod \
-math.pi math.pow math.rad math.random math.randomseed math.sin math.sqrt math.tan \
-string.gmatch string.match string.reverse table.maxn \
-math.cosh math.fmod math.modf math.sinh math.tanh math.huge
-# Last 2 lines -> Lua 5.1 functions
-
-# Coroutine Manipulation, Input and Output Facilities, System Facilities (coroutine & io & os)
-keywordclass4.lua5=coroutine.create coroutine.resume coroutine.status \
-coroutine.wrap coroutine.yield \
-io.close io.flush io.input io.lines io.open io.output io.read io.tmpfile io.type io.write \
+keywordclass2.lua5=\
+assert collectgarbage dofile error _G \
+getmetatable ipairs loadfile next pairs \
+pcall print rawequal rawget rawset \
+setmetatable tonumber tostring type _VERSION \
+xpcall string table math coroutine io os debug
+
+keywordclass2.lua50=$(keywordclass2.lua5) \
+getfenv gcinfo loadlib loadstring require \
+setfenv unpack _LOADED LUA_PATH _REQUIREDNAME
+
+# String, Table , Mathematical, Bitwise
+keywordclass3.lua5=\
+string.byte string.char string.dump string.find string.format \
+string.gsub string.len string.lower string.rep string.sub string.upper \
+table.concat table.insert table.remove table.sort \
+math.abs math.acos math.asin math.atan math.atan2 \
+math.ceil math.cos math.deg math.exp math.floor \
+math.frexp math.ldexp math.log math.max math.min \
+math.pi math.pow math.rad math.random math.randomseed \
+math.sin math.sqrt math.tan
+
+keywordclass3.lua50=$(keywordclass3.lua5) \
+string.gfind \
+table.foreach table.foreachi table.getn table.setn \
+math.mod math.log10
+
+# Coroutine, Input/Output, System, Package
+keywordclass4.lua50=\
+coroutine.create coroutine.resume coroutine.status coroutine.wrap coroutine.yield \
+io.close io.flush io.input io.lines io.open \
+io.output io.read io.tmpfile io.type io.write \
 io.stdin io.stdout io.stderr \
-os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename \
-os.setlocale os.time os.tmpname \
-coroutine.running package.cpath package.loaded package.loadlib package.path \
-package.preload package.seeall io.popen
-# Last 2 lines -> Lua 5.1 functions
-# debug.debug debug.getfenv debug.gethook debug.getinfo debug.getlocal
-# debug.getmetatable debug.getregistry debug.getupvalue debug.setfenv
-# debug.sethook debug.setlocal debug.setmetatable debug.setupvalue debug.traceback
-
-# I keep keywords5, 6, 7 & 8 for other libraries
-# To make the change from Lua 4 to Lua 5 as smooth as possible, I made these properties
-# modular and flexible.
-# If you use only Lua 4, you can remove the lua5 keywords.
-# If you use only Lua 5, you can either remove the lua4 keywords, or put them
-# in another property to highlight them in a warning/error style.
-# If you still use both, you can keep them like below, or use separate styles.
-
-keywords2.$(file.patterns.lua)=$(keywordclass2.lua) $(keywordclass2.lua4) $(keywordclass2.lua5)
-keywords3.$(file.patterns.lua)=$(keywordclass3.lua4) $(keywordclass3.lua5)
-keywords4.$(file.patterns.lua)=$(keywordclass4.lua4) $(keywordclass4.lua5)
+os.clock os.date os.difftime os.execute os.exit \
+os.getenv os.remove os.rename os.setlocale os.time \
+os.tmpname
+
+# Debug (not enabled by default)
+keywordclass5.lua50=\
+debug.debug debug.gethook debug.getinfo debug.getlocal debug.getupvalue \
+debug.setlocal debug.setupvalue debug.sethook debug.traceback
+
+#### Lua 5.1.4
+
+# Keywords
+keywordclass.lua51=$(keywordclass.lua50)
+
+# Basic Functions
+keywordclass2.lua51=$(keywordclass2.lua5) \
+getfenv load loadstring select \
+setfenv unpack package
+
+# String, Table , Mathematical, Bitwise
+keywordclass3.lua51=$(keywordclass3.lua5) \
+string.gmatch string.match string.reverse \
+table.maxn \
+math.cosh math.fmod math.huge math.log10 math.modf \
+math.sinh math.tanh
+
+# Coroutine, Input/Output, System, Package
+keywordclass4.package=\
+require package.cpath package.loaded \
+package.loadlib package.path package.preload
+
+keywordclass4.lua51=$(keywordclass4.lua50) \
+coroutine.running io.popen \
+module package.loaders package.seeall \
+$(keywordclass4.package)
+
+# Debug (not enabled by default)
+keywordclass5.lua51=$(keywordclass5.lua50) \
+debug.getfenv debug.getmetatable debug.getregistry debug.setfenv debug.setmetatable
+
+#### Lua 5.2.0
+
+# Keywords
+keywordclass.lua52=$(keywordclass.lua50) goto
+
+# Basic Functions
+keywordclass2.lua52=$(keywordclass2.lua5) \
+load rawlen select package bit32 _ENV
+
+# String, Table , Mathematical, Bitwise
+keywordclass3.bit32=\
+bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest \
+bit32.bxor bit32.extract bit32.replace bit32.lrotate bit32.lshift \
+bit32.rrotate bit32.rshift
+
+keywordclass3.lua52=$(keywordclass3.lua5) \
+string.gmatch string.match string.reverse \
+table.pack table.unpack \
+math.cosh math.fmod math.huge math.modf math.sinh math.tanh \
+$(keywordclass3.bit32)
+
+# Coroutine, Input/Output, System, Package
+keywordclass4.lua52=$(keywordclass4.lua50) \
+coroutine.running io.popen \
+package.config package.searchers package.searchpath \
+$(keywordclass4.package)
+
+# Debug (not enabled by default)
+keywordclass5.lua52=$(keywordclass5.lua50) \
+debug.getmetatable debug.getregistry debug.setmetatable \
+debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin
+
+#### Lua 5.x
+
+# Keywords
+keywordclass.lua5x=$(keywordclass.lua52)
+
+# Basic Functions
+keywordclass2.lua5x=$(keywordclass2.lua5) \
+getfenv gcinfo load loadlib loadstring \
+require select setfenv unpack \
+_LOADED LUA_PATH _REQUIREDNAME \
+package rawlen package bit32 _ENV
+
+# String, Table , Mathematical, Bitwise
+keywordclass3.lua5x=$(keywordclass3.lua5) \
+string.gfind string.gmatch string.match string.reverse \
+table.foreach table.foreachi table.getn table.setn \
+table.maxn table.pack table.unpack \
+math.cosh math.fmod math.huge math.log10 math.modf \
+math.mod math.sinh math.tanh \
+$(keywordclass3.bit32)
+
+# Coroutine, Input/Output, System, Package
+keywordclass4.lua5x=$(keywordclass4.lua50) \
+coroutine.running io.popen \
+module package.loaders package.seeall \
+package.config package.searchers package.searchpath \
+$(keywordclass4.package)
+
+# Debug (not enabled by default)
+keywordclass5.lua5x=$(keywordclass5.lua50) \
+debug.getfenv debug.getmetatable debug.getregistry debug.setfenv debug.setmetatable \
+debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin
+
+# Keyword highlighting selection
+# Options: lua4, lua50, lua51, lua52, lua5x (default)
+# or enable everything like this: $(keywordclass.lua4)$(keywordclass.lua5x)
+keywords.$(file.patterns.lua)=$(keywordclass.lua5x)
+keywords2.$(file.patterns.lua)=$(keywordclass2.lua5x)
+keywords3.$(file.patterns.lua)=$(keywordclass3.lua5x)
+keywords4.$(file.patterns.lua)=$(keywordclass4.lua5x)
+
+# Add keywords5, 6, 7 & 8 for user-defined libraries
+#keywords5.$(file.patterns.lua)=
+#keywords6.$(file.patterns.lua)=
+#keywords7.$(file.patterns.lua)=
+#keywords8.$(file.patterns.lua)=
 
 #~ statement.indent.$(file.patterns.lua)=5 do else function then
 #~ statement.lookback.$(file.patterns.lua)=20
@@ -4477,6 +4950,9 @@ lexer.errorlist.value.separate=1
 command.build.makefile=make
 command.build.*.mak=make
 
+command.help.*.properties="file://$(SciteDefaultHome)/SciTEDoc.html#property-$(CurrentSelection)"
+command.help.subsystem.*.properties=2
+
 if PLAT_WIN
 	command.go.*.bat=$(FileNameExt)
 	command.name.0.*.bat=Execute Selection
@@ -5196,9 +5672,15 @@ filter.python=Python (py pyw)|$(file.patterns.py)|
 lexer.$(file.patterns.py)=python
 lexer.$(file.patterns.scons)=python
 
-keywordclass.python=and as assert break class continue def del elif \
-else except exec finally for from global if import in is lambda None \
-not or pass print raise return try while with yield
+keywordclass.python2=and as assert break class continue def del elif \
+else except exec finally for from global if import in is lambda not \
+or pass print raise return try while with yield
+
+keywordclass.python3=False None True and as assert break class continue \
+def del elif else except finally for from global if import in is lambda \
+nonlocal not or pass raise return try while with yield
+
+keywordclass.python=$(keywordclass.python2)
 
 # Extra keywords for cython
 keywordclass.cython=cdef cimport cpdef
@@ -5249,6 +5731,11 @@ if PLAT_GTK
 	command.build.SConscript=scons --up .
 	command.build.SConstruct=scons .
 
+if PLAT_MAC
+	command.go.*.py=python -u "$(FileNameExt)"
+	command.build.SConscript=scons --up .
+	command.build.SConstruct=scons .
+
 command.name.1.*.py=Syntax Check
 command.1.*.py=python -c "import py_compile; py_compile.compile(r'$(FilePath)')"
 
@@ -7205,6 +7692,40 @@ keywords.$(file.patterns.yaml)=true false yes no
 
 
 ###############################################################################
+# Style for avs from file avs.properties
+
+# White space: Visible only in View Whitespace mode (or if it has a back colour)
+	style.avs.0=$(style.anjuta.whitespace)
+# Comment: /* */. Use fixed font to keep boxed comments as boxes
+	style.avs.1=$(style.anjuta.comment)
+# Comment: [* *]. Use fixed font to keep boxed comments as boxes
+	style.avs.2=$(style.anjuta.comment)
+# Line Comment: #. Proportionnal font is generally OK here
+	style.avs.3=$(style.anjuta.comment)
+# Number
+	style.avs.4=$(style.anjuta.number)
+# Operators
+	style.avs.5=$(style.anjuta.operator)
+# Double quoted string
+	style.avs.7=$(style.anjuta.string)
+# String with three double quotes
+	style.avs.8=$(style.anjuta.regex)
+# Keyword
+	style.avs.9=$(style.anjuta.keyword)
+# Filter
+	style.avs.10=$(style.anjuta.localkeyword)
+# Plugin
+	style.avs.11=$(style.anjuta.syskeyword)
+# Function
+	style.avs.12=$(style.anjuta.function)
+# Clip properties
+	style.avs.13=$(style.anjuta.attribute)
+# User defined
+	style.avs.14=$(style.anjuta.extrakeyword)
+
+
+
+###############################################################################
 # Style for baan from file baan.properties
 
 # White space
@@ -7489,6 +8010,8 @@ keywords.$(file.patterns.yaml)=true false yes no
 	style.cpp.20=$(style.anjuta.string)
 # Triple-quoted strings for Vala
 	style.cpp.21=$(style.anjuta.string)
+# Hash-quoted strings for Pike
+	style.cpp.22=$(style.anjuta.string)
 # White space
 	style.cpp.64=$(style.anjuta.whitespace)
 # Comment: /* */.
@@ -7531,6 +8054,8 @@ keywords.$(file.patterns.yaml)=true false yes no
 	style.cpp.84=$(style.anjuta.string)
 # Triple-quoted strings for Vala
 	style.cpp.85=$(style.anjuta.string)
+# Hash-quoted strings for Pike
+	style.cpp.86=$(style.anjuta.string)
 
 
 
diff --git a/plugins/scintilla/scintilla/AutoComplete.cxx b/plugins/scintilla/scintilla/AutoComplete.cxx
index f6a291f..2752ef0 100644
--- a/plugins/scintilla/scintilla/AutoComplete.cxx
+++ b/plugins/scintilla/scintilla/AutoComplete.cxx
@@ -50,11 +50,11 @@ bool AutoComplete::Active() const {
 
 void AutoComplete::Start(Window &parent, int ctrlID,
 	int position, Point location, int startLen_,
-	int lineHeight, bool unicodeMode) {
+	int lineHeight, bool unicodeMode, int technology) {
 	if (active) {
 		Cancel();
 	}
-	lb->Create(parent, ctrlID, location, lineHeight, unicodeMode);
+	lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology);
 	lb->Clear();
 	active = true;
 	startLen = startLen_;
diff --git a/plugins/scintilla/scintilla/AutoComplete.h b/plugins/scintilla/scintilla/AutoComplete.h
index f48cb05..aefab12 100644
--- a/plugins/scintilla/scintilla/AutoComplete.h
+++ b/plugins/scintilla/scintilla/AutoComplete.h
@@ -40,7 +40,7 @@ public:
 
 	/// Display the auto completion list positioned to be near a character position
 	void Start(Window &parent, int ctrlID, int position, Point location,
-		int startLen_, int lineHeight, bool unicodeMode);
+		int startLen_, int lineHeight, bool unicodeMode, int technology);
 
 	/// The stop chars are characters which, when typed, cause the auto completion list to disappear
 	void SetStopChars(const char *stopChars_);
diff --git a/plugins/scintilla/scintilla/CallTip.cxx b/plugins/scintilla/scintilla/CallTip.cxx
index 1db9720..d93d804 100644
--- a/plugins/scintilla/scintilla/CallTip.cxx
+++ b/plugins/scintilla/scintilla/CallTip.cxx
@@ -33,19 +33,20 @@ CallTip::CallTip() {
 	startHighlight = 0;
 	endHighlight = 0;
 	tabSize = 0;
+	above = false;
 	useStyleCallTip = false;    // for backwards compatibility
 
 #ifdef __APPLE__
 	// proper apple colours for the default
-	colourBG.desired = ColourDesired(0xff, 0xff, 0xc6);
-	colourUnSel.desired = ColourDesired(0, 0, 0);
+	colourBG = ColourDesired(0xff, 0xff, 0xc6);
+	colourUnSel = ColourDesired(0, 0, 0);
 #else
-	colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
-	colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+	colourBG = ColourDesired(0xff, 0xff, 0xff);
+	colourUnSel = ColourDesired(0x80, 0x80, 0x80);
 #endif
-	colourSel.desired = ColourDesired(0, 0, 0x80);
-	colourShade.desired = ColourDesired(0, 0, 0);
-	colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+	colourSel = ColourDesired(0, 0, 0x80);
+	colourShade = ColourDesired(0, 0, 0);
+	colourLight = ColourDesired(0xc0, 0xc0, 0xc0);
 	codePage = 0;
 	clickPlace = 0;
 }
@@ -57,14 +58,6 @@ CallTip::~CallTip() {
 	val = 0;
 }
 
-void CallTip::RefreshColourPalette(Palette &pal, bool want) {
-	pal.WantFind(colourBG, want);
-	pal.WantFind(colourUnSel, want);
-	pal.WantFind(colourSel, want);
-	pal.WantFind(colourShade, want);
-	pal.WantFind(colourLight, want);
-}
-
 // Although this test includes 0, we should never see a \0 character.
 static bool IsArrowCharacter(char ch) {
 	return (ch == 0) || (ch == '\001') || (ch == '\002');
@@ -120,10 +113,10 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
 					const int halfWidth = widthArrow / 2 - 3;
 					const int centreX = rcClient.left + widthArrow / 2 - 1;
 					const int centreY = (rcClient.top + rcClient.bottom) / 2;
-					surface->FillRectangle(rcClient, colourBG.allocated);
+					surface->FillRectangle(rcClient, colourBG);
 					PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
 					                         rcClient.right - 2, rcClient.bottom - 1);
-					surface->FillRectangle(rcClientInner, colourUnSel.allocated);
+					surface->FillRectangle(rcClientInner, colourUnSel);
 
 					if (upArrow) {      // Up arrow
 						Point pts[] = {
@@ -132,7 +125,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
     						Point(centreX, centreY - halfWidth + halfWidth / 2),
 						};
 						surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 						colourBG.allocated, colourBG.allocated);
+                 						colourBG, colourBG);
 					} else {            // Down arrow
 						Point pts[] = {
     						Point(centreX - halfWidth, centreY - halfWidth / 2),
@@ -140,7 +133,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
     						Point(centreX, centreY + halfWidth - halfWidth / 2),
 						};
 						surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 						colourBG.allocated, colourBG.allocated);
+                 						colourBG, colourBG);
 					}
 				}
 				xEnd = rcClient.right;
@@ -159,7 +152,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
 					rcClient.right = xEnd;
 					surface->DrawTextTransparent(rcClient, font, ytext,
 										s+startSeg, endSeg - startSeg,
-					                             highlight ? colourSel.allocated : colourUnSel.allocated);
+					                             highlight ? colourSel : colourUnSel);
 				}
 			}
 			x = xEnd;
@@ -227,7 +220,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
 	                        rcClientPos.bottom - rcClientPos.top);
 	PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
 
-	surfaceWindow->FillRectangle(rcClient, colourBG.allocated);
+	surfaceWindow->FillRectangle(rcClient, colourBG);
 
 	offsetMain = insetX;    // initial alignment assuming no arrows
 	PaintContents(surfaceWindow, true);
@@ -236,10 +229,10 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
 	// OSX doesn't put borders on "help tags"
 	// Draw a raised border around the edges of the window
 	surfaceWindow->MoveTo(0, rcClientSize.bottom - 1);
-	surfaceWindow->PenColour(colourShade.allocated);
+	surfaceWindow->PenColour(colourShade);
 	surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1);
 	surfaceWindow->LineTo(rcClientSize.right - 1, 0);
-	surfaceWindow->PenColour(colourLight.allocated);
+	surfaceWindow->PenColour(colourLight);
 	surfaceWindow->LineTo(0, 0);
 	surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
 #endif
@@ -253,16 +246,17 @@ void CallTip::MouseClick(Point pt) {
 		clickPlace = 2;
 }
 
-PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
+PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *defn,
                                  const char *faceName, int size,
-                                 int codePage_, int characterSet, Window &wParent) {
+                                 int codePage_, int characterSet,
+								 int technology, Window &wParent) {
 	clickPlace = 0;
 	delete []val;
 	val = 0;
 	val = new char[strlen(defn) + 1];
 	strcpy(val, defn);
 	codePage = codePage_;
-	Surface *surfaceMeasure = Surface::Allocate();
+	Surface *surfaceMeasure = Surface::Allocate(technology);
 	if (!surfaceMeasure)
 		return PRectangle();
 	surfaceMeasure->Init(wParent.GetID());
@@ -273,7 +267,8 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
 	inCallTipMode = true;
 	posStartCallTip = pos;
 	int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
-	font.Create(faceName, characterSet, deviceHeight, false, false);
+	FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
+	font.Create(fp);
 	// Look for multiple lines in the text
 	// Only support \n here - simply means container must avoid \r!
 	int numLines = 1;
@@ -294,7 +289,11 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
 	// the tip text, else to the tip text left edge.
 	int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2;
 	delete surfaceMeasure;
-	return PRectangle(pt.x - offsetMain, pt.y - 1 - height, pt.x + width - offsetMain, pt.y - 1);
+	if (above) {
+		return PRectangle(pt.x - offsetMain, pt.y - 1 - height, pt.x + width - offsetMain, pt.y - 1);
+	} else {
+		return PRectangle(pt.x - offsetMain, pt.y + 1 + textHeight, pt.x + width - offsetMain, pt.y + 1 + textHeight + height);
+	}
 }
 
 void CallTip::CallTipCancel() {
@@ -322,9 +321,15 @@ void CallTip::SetTabSize(int tabSz) {
 	useStyleCallTip = true;
 }
 
+// Set the calltip position, below the text by default or if above is false
+// else above the text.
+void CallTip::SetPosition(bool aboveText) {
+	above = aboveText;
+}
+
 // It might be better to have two access functions for this and to use
 // them for all settings of colours.
-void CallTip::SetForeBack(const ColourPair &fore, const ColourPair &back) {
+void CallTip::SetForeBack(const ColourDesired &fore, const ColourDesired &back) {
 	colourBG = back;
 	colourUnSel = fore;
 }
diff --git a/plugins/scintilla/scintilla/CallTip.h b/plugins/scintilla/scintilla/CallTip.h
index a9ba82e..657e0ca 100644
--- a/plugins/scintilla/scintilla/CallTip.h
+++ b/plugins/scintilla/scintilla/CallTip.h
@@ -25,6 +25,7 @@ class CallTip {
 	int offsetMain;         // The alignment point of the call tip
 	int tabSize;            // Tab size in pixels, <=0 no TAB expand
 	bool useStyleCallTip;   // if true, STYLE_CALLTIP should be used
+	bool above;		// if true, display calltip above text
 
 	// Private so CallTip objects can not be copied
 	CallTip(const CallTip &);
@@ -41,28 +42,25 @@ public:
 	Window wDraw;
 	bool inCallTipMode;
 	int posStartCallTip;
-	ColourPair colourBG;
-	ColourPair colourUnSel;
-	ColourPair colourSel;
-	ColourPair colourShade;
-	ColourPair colourLight;
+	ColourDesired colourBG;
+	ColourDesired colourUnSel;
+	ColourDesired colourSel;
+	ColourDesired colourShade;
+	ColourDesired colourLight;
 	int codePage;
 	int clickPlace;
 
 	CallTip();
 	~CallTip();
 
-	/// Claim or accept palette entries for the colours required to paint a calltip.
-	void RefreshColourPalette(Palette &pal, bool want);
-
 	void PaintCT(Surface *surfaceWindow);
 
 	void MouseClick(Point pt);
 
 	/// Setup the calltip and return a rectangle of the area required.
-	PRectangle CallTipStart(int pos, Point pt, const char *defn,
+	PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn,
 		const char *faceName, int size, int codePage_,
-		int characterSet, Window &wParent);
+		int characterSet, int technology, Window &wParent);
 
 	void CallTipCancel();
 
@@ -73,11 +71,14 @@ public:
 	/// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand.
 	void SetTabSize(int tabSz);
 
+	/// Set calltip position.
+	void SetPosition(bool aboveText);
+
 	/// Used to determine which STYLE_xxxx to use for call tip information
 	bool UseStyleCallTip() const { return useStyleCallTip;}
 
 	// Modify foreground and background colours
-	void SetForeBack(const ColourPair &fore, const ColourPair &back);
+	void SetForeBack(const ColourDesired &fore, const ColourDesired &back);
 };
 
 #ifdef SCI_NAMESPACE
diff --git a/plugins/scintilla/scintilla/Catalogue.cxx b/plugins/scintilla/scintilla/Catalogue.cxx
index 00785d5..4773fff 100644
--- a/plugins/scintilla/scintilla/Catalogue.cxx
+++ b/plugins/scintilla/scintilla/Catalogue.cxx
@@ -90,6 +90,7 @@ int Scintilla_LinkLexers() {
 	LINK_LEXER(lmASY);
 	LINK_LEXER(lmAU3);
 	LINK_LEXER(lmAVE);
+	LINK_LEXER(lmAVS);
 	LINK_LEXER(lmBaan);
 	LINK_LEXER(lmBash);
 	LINK_LEXER(lmBatch);
@@ -100,6 +101,7 @@ int Scintilla_LinkLexers() {
 	LINK_LEXER(lmClwNoCase);
 	LINK_LEXER(lmCmake);
 	LINK_LEXER(lmCOBOL);
+	LINK_LEXER(lmCoffeeScript);
 	LINK_LEXER(lmConf);
 	LINK_LEXER(lmCPP);
 	LINK_LEXER(lmCPPNoCase);
@@ -171,6 +173,7 @@ int Scintilla_LinkLexers() {
 	LINK_LEXER(lmTADS3);
 	LINK_LEXER(lmTAL);
 	LINK_LEXER(lmTCL);
+	LINK_LEXER(lmTCMD);
 	LINK_LEXER(lmTeX);
 	LINK_LEXER(lmTxt2tags);
 	LINK_LEXER(lmVB);
diff --git a/plugins/scintilla/scintilla/Document.cxx b/plugins/scintilla/scintilla/Document.cxx
index 5c05aa5..a0dc7f5 100644
--- a/plugins/scintilla/scintilla/Document.cxx
+++ b/plugins/scintilla/scintilla/Document.cxx
@@ -169,7 +169,7 @@ int Document::AddRef() {
 
 // Decrease reference count and return its previous value.
 // Delete the document if reference count reaches zero.
-int Document::Release() {
+int SCI_METHOD Document::Release() {
 	int curRefCount = --refCount;
 	if (curRefCount == 0)
 		delete this;
@@ -185,6 +185,10 @@ int Document::GetMark(int line) {
 	return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line);
 }
 
+int Document::MarkerNext(int lineStart, int mask) const {
+	return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkerNext(lineStart, mask);
+}
+
 int Document::AddMark(int line, int markerNum) {
 	if (line >= 0 && line <= LinesTotal()) {
 		int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
@@ -821,6 +825,22 @@ bool Document::InsertString(int position, const char *s, int insertLength) {
 	return !cb.IsReadOnly();
 }
 
+int SCI_METHOD Document::AddData(char *data, int length) {
+	try {
+		int position = Length();
+		InsertString(position,data, length);
+	} catch (std::bad_alloc &) {
+		return SC_STATUS_BADALLOC;
+	} catch (...) {
+		return SC_STATUS_FAILURE;
+	}
+	return 0;
+}
+
+void * SCI_METHOD Document::ConvertToDocument() {
+	return this;
+}
+
 int Document::Undo() {
 	int newPos = -1;
 	CheckReadOnly();
@@ -1074,6 +1094,20 @@ int Document::GetColumn(int pos) {
 	return column;
 }
 
+int Document::CountCharacters(int startPos, int endPos) {
+	startPos = MovePositionOutsideChar(startPos, 1, false);
+	endPos = MovePositionOutsideChar(endPos, -1, false);
+	int count = 0;
+	int i = startPos;
+	while (i < endPos) {
+		count++;
+		if (IsCrLf(i))
+			i++;
+		i = NextPosition(i, 1);
+	}
+	return count;
+}
+
 int Document::FindColumn(int line, int column) {
 	int position = LineStart(line);
 	if ((line >= 0) && (line < LinesTotal())) {
@@ -1427,7 +1461,7 @@ long Document::FindText(int minPos, int maxPos, const char *search,
 		const int endPos = MovePositionOutsideChar(maxPos, increment, false);
 
 		// Compute actual search ranges needed
-		const int lengthFind = (*length == -1) ? static_cast<int>(strlen(search)) : *length;
+		const int lengthFind = *length;
 
 		//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
 		const int limitPos = Platform::Maximum(startPos, endPos);
diff --git a/plugins/scintilla/scintilla/Document.h b/plugins/scintilla/scintilla/Document.h
index 00d23a4..ec41603 100644
--- a/plugins/scintilla/scintilla/Document.h
+++ b/plugins/scintilla/scintilla/Document.h
@@ -193,7 +193,7 @@ public:
 
 /**
  */
-class Document : PerLine, public IDocument {
+class Document : PerLine, public IDocument, public ILoader {
 
 public:
 	/** Used to pair watcher pointer with user data. */
@@ -252,7 +252,7 @@ public:
 	virtual ~Document();
 
 	int AddRef();
-	int Release();
+	int SCI_METHOD Release();
 
 	virtual void Init();
 	virtual void InsertLine(int line);
@@ -281,6 +281,8 @@ public:
 	void CheckReadOnly();
 	bool DeleteChars(int pos, int len);
 	bool InsertString(int position, const char *s, int insertLength);
+	int SCI_METHOD AddData(char *data, int length);
+	void * SCI_METHOD ConvertToDocument();
 	int Undo();
 	int Redo();
 	bool CanUndo() { return cb.CanUndo(); }
@@ -301,6 +303,7 @@ public:
 	void SetLineIndentation(int line, int indent);
 	int GetLineIndentPosition(int line) const;
 	int GetColumn(int position);
+	int CountCharacters(int startPos, int endPos);
 	int FindColumn(int line, int column);
 	void Indent(bool forwards, int lineBottom, int lineTop);
 	static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted);
@@ -323,6 +326,7 @@ public:
 		cb.GetStyleRange(buffer, position, lengthRetrieve);
 	}
 	int GetMark(int line);
+	int MarkerNext(int lineStart, int mask) const;
 	int AddMark(int line, int markerNum);
 	void AddMarkSet(int line, int valueSet);
 	void DeleteMark(int line, int markerNum);
diff --git a/plugins/scintilla/scintilla/Editor.cxx b/plugins/scintilla/scintilla/Editor.cxx
index 7dbaa36..26032b8 100644
--- a/plugins/scintilla/scintilla/Editor.cxx
+++ b/plugins/scintilla/scintilla/Editor.cxx
@@ -102,7 +102,8 @@ Editor::Editor() {
 	ctrlID = 0;
 
 	stylesValid = false;
-
+	technology = SC_TECHNOLOGY_DEFAULT;
+	
 	printMagnification = 0;
 	printColourMode = SC_PRINT_NORMAL;
 	printWrapState = eWrapWord;
@@ -168,11 +169,11 @@ Editor::Editor() {
 	additionalCaretsVisible = true;
 	virtualSpaceOptions = SCVS_NONE;
 
-	pixmapLine = Surface::Allocate();
-	pixmapSelMargin = Surface::Allocate();
-	pixmapSelPattern = Surface::Allocate();
-	pixmapIndentGuide = Surface::Allocate();
-	pixmapIndentGuideHighlight = Surface::Allocate();
+	pixmapLine = 0;
+	pixmapSelMargin = 0;
+	pixmapSelPattern = 0;
+	pixmapIndentGuide = 0;
+	pixmapIndentGuideHighlight = 0;
 
 	targetStart = 0;
 	targetEnd = 0;
@@ -193,6 +194,7 @@ Editor::Editor() {
 	theEdge = 0;
 
 	paintState = notPainting;
+	willRedrawAll = false;
 
 	modEventMask = SC_MODEVENTMASKALL;
 
@@ -226,12 +228,7 @@ Editor::~Editor() {
 	pdoc->RemoveWatcher(this, 0);
 	pdoc->Release();
 	pdoc = 0;
-	DropGraphics();
-	delete pixmapLine;
-	delete pixmapSelMargin;
-	delete pixmapSelPattern;
-	delete pixmapIndentGuide;
-	delete pixmapIndentGuideHighlight;
+	DropGraphics(true);
 }
 
 void Editor::Finalise() {
@@ -239,18 +236,50 @@ void Editor::Finalise() {
 	CancelModes();
 }
 
-void Editor::DropGraphics() {
-	pixmapLine->Release();
-	pixmapSelMargin->Release();
-	pixmapSelPattern->Release();
-	pixmapIndentGuide->Release();
-	pixmapIndentGuideHighlight->Release();
+void Editor::DropGraphics(bool freeObjects) {
+	if (freeObjects) {
+		delete pixmapLine;
+		pixmapLine = 0;
+		delete pixmapSelMargin;
+		pixmapSelMargin = 0;
+		delete pixmapSelPattern;
+		pixmapSelPattern = 0;
+		delete pixmapIndentGuide;
+		pixmapIndentGuide = 0;
+		delete pixmapIndentGuideHighlight;
+		pixmapIndentGuideHighlight = 0;
+	} else {
+		if (pixmapLine)
+			pixmapLine->Release();
+		if (pixmapSelMargin)
+			pixmapSelMargin->Release();
+		if (pixmapSelPattern)
+			pixmapSelPattern->Release();
+		if (pixmapIndentGuide)
+			pixmapIndentGuide->Release();
+		if (pixmapIndentGuideHighlight)
+			pixmapIndentGuideHighlight->Release();
+	}
+}
+
+void Editor::AllocateGraphics() {
+	if (!pixmapLine)
+		pixmapLine = Surface::Allocate(technology);
+	if (!pixmapSelMargin)
+		pixmapSelMargin = Surface::Allocate(technology);
+	if (!pixmapSelPattern)
+		pixmapSelPattern = Surface::Allocate(technology);
+	if (!pixmapIndentGuide)
+		pixmapIndentGuide = Surface::Allocate(technology);
+	if (!pixmapIndentGuideHighlight)
+		pixmapIndentGuideHighlight = Surface::Allocate(technology);
 }
 
 void Editor::InvalidateStyleData() {
 	stylesValid = false;
-	DropGraphics();
-	palette.Release();
+	vs.technology = technology;
+	DropGraphics(false);
+	AllocateGraphics();
 	llc.Invalidate(LineLayout::llInvalid);
 	posCache.Clear();
 }
@@ -261,19 +290,12 @@ void Editor::InvalidateStyleRedraw() {
 	Redraw();
 }
 
-void Editor::RefreshColourPalette(Palette &pal, bool want) {
-	vs.RefreshColourPalette(pal, want);
-}
-
 void Editor::RefreshStyleData() {
 	if (!stylesValid) {
 		stylesValid = true;
 		AutoSurface surface(this);
 		if (surface) {
 			vs.Refresh(*surface);
-			RefreshColourPalette(palette, true);
-			palette.Allocate(wMain);
-			RefreshColourPalette(palette, false);
 		}
 		if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
 			wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth;
@@ -420,7 +442,7 @@ Point Editor::LocationFromPosition(SelectionPosition pos) {
 		}
 		pt.x += vs.fixedColumnWidth - xOffset;
 	}
-	pt.x += pos.VirtualSpace() * static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
+	pt.x += pos.VirtualSpace() * vs.styles[ll->EndLineStyle()].spaceWidth;
 	return pt;
 }
 
@@ -484,7 +506,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
 		if (subLine < ll->lines) {
 			int lineStart = ll->LineStart(subLine);
 			int lineEnd = ll->LineLastVisible(subLine);
-			int subLineStart = ll->positions[lineStart];
+			XYPOSITION subLineStart = ll->positions[lineStart];
 
 			if (ll->wrapIndent != 0) {
 				if (lineStart != 0)	// Wrapped
@@ -504,7 +526,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
 				i++;
 			}
 			if (virtualSpace) {
-				const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
+				const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth;
 				int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) /
 					spaceWidth;
 				return SelectionPosition(lineEnd + posLineStart, spaceOffset);
@@ -530,43 +552,6 @@ int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosit
  * Find the document position corresponding to an x coordinate on a particular document line.
  * Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
  */
-int Editor::PositionFromLineX(int lineDoc, int x) {
-	RefreshStyleData();
-	if (lineDoc >= pdoc->LinesTotal())
-		return pdoc->Length();
-	//Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine);
-	AutoSurface surface(this);
-	AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc));
-	int retVal = 0;
-	if (surface && ll) {
-		unsigned int posLineStart = pdoc->LineStart(lineDoc);
-		LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
-		retVal = ll->numCharsBeforeEOL + posLineStart;
-		int subLine = 0;
-		int lineStart = ll->LineStart(subLine);
-		int lineEnd = ll->LineLastVisible(subLine);
-		int subLineStart = ll->positions[lineStart];
-
-		if (ll->wrapIndent != 0) {
-			if (lineStart != 0)	// Wrapped
-				x -= ll->wrapIndent;
-		}
-		int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd);
-		while (i < lineEnd) {
-			if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) {
-				retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1);
-				break;
-			}
-			i++;
-		}
-	}
-	return retVal;
-}
-
-/**
- * Find the document position corresponding to an x coordinate on a particular document line.
- * Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
- */
 SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
 	RefreshStyleData();
 	if (lineDoc >= pdoc->LinesTotal())
@@ -581,27 +566,32 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
 		int subLine = 0;
 		int lineStart = ll->LineStart(subLine);
 		int lineEnd = ll->LineLastVisible(subLine);
-		int subLineStart = ll->positions[lineStart];
+		XYPOSITION subLineStart = ll->positions[lineStart];
+		XYPOSITION newX = x;
 
 		if (ll->wrapIndent != 0) {
 			if (lineStart != 0)	// Wrapped
-				x -= ll->wrapIndent;
+				newX -= ll->wrapIndent;
 		}
-		int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd);
+		int i = ll->FindBefore(newX + subLineStart, lineStart, lineEnd);
 		while (i < lineEnd) {
-			if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) {
+			if ((newX + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) {
 				retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1);
 				return SelectionPosition(retVal);
 			}
 			i++;
 		}
-		const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
-		int spaceOffset = (x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth;
+		const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth;
+		int spaceOffset = (newX + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth;
 		return SelectionPosition(lineEnd + posLineStart, spaceOffset);
 	}
 	return SelectionPosition(retVal);
 }
 
+int Editor::PositionFromLineX(int lineDoc, int x) {
+	return SPositionFromLineX(lineDoc, x).Position();
+}
+
 /**
  * If painting then abandon the painting because a wider redraw is needed.
  * @return true if calling code should stop drawing.
@@ -984,6 +974,8 @@ void Editor::ScrollTo(int line, bool moveThumb) {
 		// Try to optimise small scrolls
 #ifndef UNDER_CE
 		int linesToMove = topLine - topLineNew;
+		bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
+		willRedrawAll = !performBlit;
 #endif
 		SetTopLine(topLineNew);
 		// Optimize by styling the view as this will invalidate any needed area
@@ -991,11 +983,12 @@ void Editor::ScrollTo(int line, bool moveThumb) {
 		StyleToPositionInView(PositionAfterArea(GetClientRectangle()));
 #ifndef UNDER_CE
 		// Perform redraw rather than scroll if many lines would be redrawn anyway.
-		if ((abs(linesToMove) <= 10) && (paintState == notPainting)) {
+		if (performBlit) {
 			ScrollText(linesToMove);
 		} else {
 			Redraw();
 		}
+		willRedrawAll = false;
 #else
 		Redraw();
 #endif
@@ -1090,12 +1083,14 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {
 	Point pt = PointMainCaret();
 	if (pt.y < rcClient.top) {
 		MovePositionTo(SPositionFromLocation(
-		            Point(lastXChosen - xOffset, rcClient.top)),
+		            Point(lastXChosen - xOffset, rcClient.top),
+					false, false, UserVirtualSpace()),
 					Selection::noSel, ensureVisible);
 	} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
 		int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight;
 		MovePositionTo(SPositionFromLocation(
-		            Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed)),
+		            Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed),
+					false, false, UserVirtualSpace()),
 		        Selection::noSel, ensureVisible);
 	}
 }
@@ -1360,7 +1355,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const bool useMargin, con
 			newXY.xOffset = pt.x + xOffset - rcClient.right + 1;
 			if (vs.caretStyle == CARETSTYLE_BLOCK) {
 				// Ensure we can see a good portion of the block caret
-				newXY.xOffset += vs.aveCharWidth;
+				newXY.xOffset += static_cast<int>(vs.aveCharWidth);
 			}
 		}
 		if (newXY.xOffset < 0) {
@@ -1704,8 +1699,8 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
 			surface->DrawTextNoClip(rcSegment, vs.styles[style].font,
 					ascent, st.text + start + i,
 					static_cast<int>(end - i + 1),
-					vs.styles[style].fore.allocated,
-					vs.styles[style].back.allocated);
+					vs.styles[style].fore,
+					vs.styles[style].back);
 			x += width;
 			i = end + 1;
 		}
@@ -1714,8 +1709,8 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
 		surface->DrawTextNoClip(rcText, vs.styles[style].font,
 				rcText.top + vs.maxAscent, st.text + start,
 				static_cast<int>(length),
-				vs.styles[style].fore.allocated,
-				vs.styles[style].back.allocated);
+				vs.styles[style].fore,
+				vs.styles[style].back);
 	}
 }
 
@@ -1736,6 +1731,12 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 		surface = surfWindow;
 	}
 
+	// Clip vertically to paint area to avoid drawing line numbers
+	if (rcMargin.bottom > rc.bottom)
+		rcMargin.bottom = rc.bottom;
+	if (rcMargin.top < rc.top)
+		rcMargin.top = rc.top;
+
 	PRectangle rcSelMargin = rcMargin;
 	rcSelMargin.right = rcMargin.left;
 
@@ -1750,34 +1751,35 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 					// Required because of special way brush is created for selection margin
 					surface->FillRectangle(rcSelMargin, *pixmapSelPattern);
 				else {
-					ColourAllocated colour;
+					ColourDesired colour;
 					switch (vs.ms[margin].style) {
 					case SC_MARGIN_BACK:
-						colour = vs.styles[STYLE_DEFAULT].back.allocated;
+						colour = vs.styles[STYLE_DEFAULT].back;
 						break;
 					case SC_MARGIN_FORE:
-						colour = vs.styles[STYLE_DEFAULT].fore.allocated;
+						colour = vs.styles[STYLE_DEFAULT].fore;
 						break;
 					default:
-						colour = vs.styles[STYLE_LINENUMBER].back.allocated;
+						colour = vs.styles[STYLE_LINENUMBER].back;
 						break;
 					}
 					surface->FillRectangle(rcSelMargin, colour);
 				}
 			} else {
-				surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
+				surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back);
 			}
 
-			int visibleLine = topLine;
-			int yposScreen = 0;
+			const int lineStartPaint = rcMargin.top / vs.lineHeight;
+			int visibleLine = topLine + lineStartPaint;
+			int yposScreen = lineStartPaint * vs.lineHeight;
 			// Work out whether the top line is whitespace located after a
 			// lessening of fold level which implies a 'fold tail' but which should not
 			// be displayed until the last of a sequence of whitespace.
 			bool needWhiteClosure = false;
 			if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
-				int level = pdoc->GetLevel(cs.DocFromDisplay(topLine));
+				int level = pdoc->GetLevel(cs.DocFromDisplay(visibleLine));
 				if (level & SC_FOLDLEVELWHITEFLAG) {
-					int lineBack = cs.DocFromDisplay(topLine);
+					int lineBack = cs.DocFromDisplay(visibleLine);
 					int levelPrev = level;
 					while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
 						lineBack--;
@@ -1929,14 +1931,14 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 					rcNumber.left = xpos;
 					surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
 					        rcNumber.top + vs.maxAscent, number, istrlen(number),
-					        vs.styles[STYLE_LINENUMBER].fore.allocated,
-					        vs.styles[STYLE_LINENUMBER].back.allocated);
+					        vs.styles[STYLE_LINENUMBER].fore,
+					        vs.styles[STYLE_LINENUMBER].back);
 				} else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
 					if (firstSubLine) {
 						const StyledText stMargin  = pdoc->MarginStyledText(lineDoc);
 						if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
 							surface->FillRectangle(rcMarker,
-								vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated);
+								vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back);
 							if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
 								int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
 								rcMarker.left = rcMarker.right - width - 3;
@@ -1982,10 +1984,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 
 	PRectangle rcBlankMargin = rcMargin;
 	rcBlankMargin.left = rcSelMargin.right;
-	surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back.allocated);
+	surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back);
 
 	if (bufferedDraw) {
-		surfWindow->Copy(rcMargin, Point(), *pixmapSelMargin);
+		surfWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *pixmapSelMargin);
 	}
 }
 
@@ -2216,13 +2218,13 @@ 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
-		int startsegx = 0;	// Start of the current segment, in pixels
+		XYACCUMULATOR startsegx = 0;	// Start of the current segment, in pixels
 		ll->positions[0] = 0;
-		unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
+		XYPOSITION tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
 		bool lastSegItalics = false;
 		Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
 
-		int ctrlCharWidth[32] = {0};
+		XYPOSITION ctrlCharWidth[32] = {0};
 		bool isControlNext = IsControlCharacter(ll->chars[0]);
 		int trailBytes = 0;
 		bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes);
@@ -2237,8 +2239,8 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 				if (vstyle.styles[ll->styles[charInLine]].visible) {
 					if (isControl) {
 						if (ll->chars[charInLine] == '\t') {
-							ll->positions[charInLine + 1] = ((((startsegx + 2) /
-							        tabWidth) + 1) * tabWidth) - startsegx;
+							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]);
@@ -2303,7 +2305,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 			ll->lines = 1;
 		} else {
 			if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
-				width -= vstyle.aveCharWidth; // take into account the space for end wrap mark
+				width -= static_cast<int>(vstyle.aveCharWidth); // take into account the space for end wrap mark
 			}
 			ll->wrapIndent = wrapAddIndent;
 			if (wrapIndentMode != SC_WRAPINDENT_FIXED)
@@ -2317,13 +2319,13 @@ 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 < static_cast<int>(vstyle.aveCharWidth)))
+			if ((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.
 			int lastGoodBreak = 0;
 			int lastLineStart = 0;
-			int startOffset = 0;
+			XYACCUMULATOR startOffset = 0;
 			int p = 0;
 			while (p < ll->numCharsInLine) {
 				if ((ll->positions[p + 1] - startOffset) >= width) {
@@ -2368,14 +2370,14 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 	}
 }
 
-ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
+ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
 	return main ?
-		(primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) :
-		vsDraw.selAdditionalBackground.allocated;
+		(primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) :
+		vsDraw.selAdditionalBackground;
 }
 
-ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
-        ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
+ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
+        ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
 	if (inSelection == 1) {
 		if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
 			return SelectionBackground(vsDraw, true);
@@ -2388,14 +2390,14 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun
 		if ((vsDraw.edgeState == EDGE_BACKGROUND) &&
 		        (i >= ll->edgeColumn) &&
 		        !IsEOLChar(ll->chars[i]))
-			return vsDraw.edgecolour.allocated;
+			return vsDraw.edgecolour;
 		if (inHotspot && vsDraw.hotspotBackgroundSet)
-			return vsDraw.hotspotBackground.allocated;
+			return vsDraw.hotspotBackground;
 	}
 	if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) {
 		return background;
 	} else {
-		return vsDraw.styles[styleMain].back.allocated;
+		return vsDraw.styles[styleMain].back;
 	}
 }
 
@@ -2407,7 +2409,7 @@ void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight,
 }
 
 void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
-        bool isEndMarker, ColourAllocated wrapColour) {
+        bool isEndMarker, ColourDesired wrapColour) {
 	surface->PenColour(wrapColour);
 
 	enum { xa = 1 }; // gap before start
@@ -2452,14 +2454,14 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
 	        y - 2 * dy);
 }
 
-static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) {
+static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired fill, int alpha) {
 	if (alpha != SC_ALPHA_NOALPHA) {
 		surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0);
 	}
 }
 
 void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
-				  const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) {
+				  const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) {
 	if (!twoPhaseDraw) {
 		surface->FillRectangle(rcSegment, textBack);
 	}
@@ -2483,30 +2485,30 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
 }
 
 void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
-        int line, int lineEnd, int xStart, int subLine, int subLineStart,
-        bool overrideBackground, ColourAllocated background,
-        bool drawWrapMarkEnd, ColourAllocated wrapColour) {
+        int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
+        bool overrideBackground, ColourDesired background,
+        bool drawWrapMarkEnd, ColourDesired wrapColour) {
 
 	const int posLineStart = pdoc->LineStart(line);
 	const int styleMask = pdoc->stylingBitsMask;
 	PRectangle rcSegment = rcLine;
 
 	const bool lastSubLine = subLine == (ll->lines - 1);
-	int virtualSpace = 0;
+	XYPOSITION virtualSpace = 0;
 	if (lastSubLine) {
-		const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+		const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
 		virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth;
 	}
 
 	// Fill in a PRectangle representing the end of line characters
 
-	int xEol = ll->positions[lineEnd] - subLineStart;
+	XYPOSITION xEol = ll->positions[lineEnd] - subLineStart;
 
 	// Fill the virtual space and show selections within it
 	if (virtualSpace) {
 		rcSegment.left = xEol + xStart;
 		rcSegment.right = xEol + xStart + virtualSpace;
-		surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
 		if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
 			SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line))));
 			for (size_t r=0; r<sel.Count(); r++) {
@@ -2514,11 +2516,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 				if (alpha == SC_ALPHA_NOALPHA) {
 					SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
 					if (!portion.Empty()) {
-						const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+						const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
 						rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
 						rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
-						rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
-						rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+						rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left;
+						rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right;
 						surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main()));
 					}
 				}
@@ -2541,8 +2543,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 			int inSelection = 0;
 			bool inHotspot = false;
 			int styleMain = ll->styles[eolPos];
-			ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll);
-			ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+			ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll);
+			ColourDesired textFore = vsDraw.styles[styleMain].fore;
 			if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
 				if (alpha == SC_ALPHA_NOALPHA) {
 					surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
@@ -2567,11 +2569,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		if (overrideBackground) {
 			surface->FillRectangle(rcSegment, background);
 		} else if (line < pdoc->LinesTotal() - 1) {
-			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
 		} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
-			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
 		} else {
-			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
 		}
 		if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
 			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
@@ -2590,9 +2592,9 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		if (overrideBackground) {
 			surface->FillRectangle(rcSegment, background);
 		} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
-			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
 		} else {
-			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
 		}
 		if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
 			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
@@ -2616,7 +2618,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 
 void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
 		int xStart, PRectangle rcLine, LineLayout *ll, int subLine) {
-	const int subLineStart = ll->positions[ll->LineStart(subLine)];
+	const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
 	PRectangle rcIndic(
 		ll->positions[startPos] + xStart - subLineStart,
 		rcLine.top + vsDraw.maxAscent,
@@ -2710,14 +2712,14 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
 	int annotationLine = subLine - ll->lines;
 	const StyledText stAnnotation  = pdoc->AnnotationStyledText(line);
 	if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) {
-		surface->FillRectangle(rcSegment, vsDraw.styles[0].back.allocated);
+		surface->FillRectangle(rcSegment, vsDraw.styles[0].back);
 		if (vs.annotationVisible == ANNOTATION_BOXED) {
 			// Only care about calculating width if need to draw box
 			int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation);
 			widthAnnotation += vsDraw.spaceWidth * 2; // Margins
 			rcSegment.left = xStart + indent;
 			rcSegment.right = rcSegment.left + widthAnnotation;
-			surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore.allocated);
+			surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore);
 		} else {
 			rcSegment.left = xStart;
 		}
@@ -2733,7 +2735,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
 		PRectangle rcText = rcSegment;
 		if (vs.annotationVisible == ANNOTATION_BOXED) {
 			surface->FillRectangle(rcText,
-				vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated);
+				vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back);
 			rcText.left += vsDraw.spaceWidth;
 		}
 		DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent,
@@ -2772,17 +2774,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	// with the earlier taking precedence.  When multiple markers cause background override,
 	// the color for the highest numbered one is used.
 	bool overrideBackground = false;
-	ColourAllocated background;
+	ColourDesired background;
 	if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) {
 		overrideBackground = true;
-		background = vsDraw.caretLineBackground.allocated;
+		background = vsDraw.caretLineBackground;
 	}
 	if (!overrideBackground) {
 		int marks = pdoc->GetMark(line);
 		for (int markBit = 0; (markBit < 32) && marks; markBit++) {
 			if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) &&
 			        (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
-				background = vsDraw.markers[markBit].back.allocated;
+				background = vsDraw.markers[markBit].back;
 				overrideBackground = true;
 			}
 			marks >>= 1;
@@ -2796,7 +2798,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 					if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) &&
 					        (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 						overrideBackground = true;
-						background = vsDraw.markers[markBit].back.allocated;
+						background = vsDraw.markers[markBit].back;
 					}
 					marksMasked >>= 1;
 				}
@@ -2813,7 +2815,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	int posLineStart = pdoc->LineStart(line);
 
 	int startseg = ll->LineStart(subLine);
-	int subLineStart = ll->positions[startseg];
+	XYACCUMULATOR subLineStart = ll->positions[startseg];
 	if (subLine >= ll->lines) {
 		DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine);
 		return; // No further drawing
@@ -2828,9 +2830,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
-	ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated;
+	ColourDesired wrapColour = vsDraw.styles[STYLE_DEFAULT].fore;
 	if (vsDraw.whitespaceForegroundSet)
-		wrapColour = vsDraw.whitespaceForeground.allocated;
+		wrapColour = vsDraw.whitespaceForeground;
 
 	bool drawWrapMarkEnd = false;
 
@@ -2856,12 +2858,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 
 			// default bgnd here..
 			surface->FillRectangle(rcSegment, overrideBackground ? background :
-			        vsDraw.styles[STYLE_DEFAULT].back.allocated);
+			        vsDraw.styles[STYLE_DEFAULT].back);
 
 			// main line style would be below but this would be inconsistent with end markers
 			// also would possibly not be the style at wrap point
 			//int styleMain = ll->styles[lineStart];
-			//surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back.allocated);
+			//surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back);
 
 			if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
 
@@ -2873,7 +2875,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 				DrawWrapMarker(surface, rcPlace, false, wrapColour);
 			}
 
-			xStart += ll->wrapIndent;
+			xStart += static_cast<int>(ll->wrapIndent);
 		}
 	}
 
@@ -2881,7 +2883,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
 
 	// Does not take margin into account but not significant
-	int xStartVisible = subLineStart - xStart;
+	int xStartVisible = static_cast<int>(subLineStart) - xStart;
 
 	ll->psel = &sel;
 
@@ -2902,18 +2904,20 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		// 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
-			rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
-			rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+			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);
-			ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
+			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.allocated;
+					textBack = vsDraw.whitespaceBackground;
 				surface->FillRectangle(rcSegment, textBack);
 			} else if (IsControlCharacter(ll->chars[i])) {
 				// Control character display
@@ -2932,7 +2936,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 									rcSegment.top,
 									ll->positions[cpos + startseg + 1] + xStart - subLineStart,
 									rcSegment.bottom);
-								surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
+								surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground);
 							}
 						} else {
 							inIndentation = false;
@@ -2959,7 +2963,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		if ((ll->wrapIndent != 0) && (lineStart != 0))
 			rcSegment.left -= ll->wrapIndent;
 		rcSegment.right = rcSegment.left + 1;
-		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
+		surface->FillRectangle(rcSegment, vsDraw.edgecolour);
 	}
 
 	// Draw underline mark as part of background if not transparent
@@ -2970,7 +2974,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		    (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 			PRectangle rcUnderline = rcLine;
 			rcUnderline.top = rcUnderline.bottom - 2;
-			surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back.allocated);
+			surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back);
 		}
 		marks >>= 1;
 	}
@@ -2995,31 +2999,31 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		// draw strings that are completely past the right side of the window.
 		if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
 			int styleMain = ll->styles[i];
-			ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+			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.allocated;
+					textFore = vsDraw.hotspotForeground;
 			}
 			const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
 			if (inSelection && (vsDraw.selforeset)) {
-				textFore = (inSelection == 1) ? vsDraw.selforeground.allocated : vsDraw.selAdditionalForeground.allocated;
+				textFore = (inSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
 			}
 			bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
-			ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
+			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.allocated;
+						textBack = vsDraw.whitespaceBackground;
 					surface->FillRectangle(rcSegment, textBack);
 				}
 				if ((vsDraw.viewWhitespace != wsInvisible) ||
 				        (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
 					if (vsDraw.whitespaceForegroundSet)
-						textFore = vsDraw.whitespaceForeground.allocated;
+						textFore = vsDraw.whitespaceForeground;
 					surface->PenColour(textFore);
 				}
 				if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
@@ -3074,12 +3078,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 						if (ll->chars[cpos + startseg] == ' ') {
 							if (vsDraw.viewWhitespace != wsInvisible) {
 								if (vsDraw.whitespaceForegroundSet)
-									textFore = vsDraw.whitespaceForeground.allocated;
+									textFore = vsDraw.whitespaceForeground;
 								if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
-									int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+									XYPOSITION xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
 									if (!twoPhaseDraw && drawWhitespaceBackground &&
 									        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
-										textBack = vsDraw.whitespaceBackground.allocated;
+										textBack = vsDraw.whitespaceBackground;
 										PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
 											rcSegment.top,
 											ll->positions[cpos + startseg + 1] + xStart - subLineStart,
@@ -3110,7 +3114,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 				rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
 				rcUL.bottom = rcUL.top + 1;
 				if (vsDraw.hotspotForegroundSet)
-					surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
+					surface->FillRectangle(rcUL, vsDraw.hotspotForeground);
 				else
 					surface->FillRectangle(rcUL, textFore);
 			} else if (vsDraw.styles[styleMain].underline) {
@@ -3195,11 +3199,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 			if (alpha != SC_ALPHA_NOALPHA) {
 				SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
 				if (!portion.Empty()) {
-					const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+					const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
 					rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
 					rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
-					rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
-					rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+					rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left;
+					rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right;
 					SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha);
 				}
 			}
@@ -3210,16 +3214,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	rcSegment.left = 0;
 	rcSegment.right = rcLine.right - 1;
 	if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) {
-		SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha);
+		SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground, vsDraw.caretLineAlpha);
 	}
 	marks = pdoc->GetMark(line);
 	for (markBit = 0; (markBit < 32) && marks; markBit++) {
 		if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) {
-			SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+			SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
 		} else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) {
 			PRectangle rcUnderline = rcSegment;
 			rcUnderline.top = rcUnderline.bottom - 2;
-			SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+			SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
 		}
 		marks >>= 1;
 	}
@@ -3228,7 +3232,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		if (marksMasked) {
 			for (markBit = 0; (markBit < 32) && marksMasked; markBit++) {
 				if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) {
-					SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+					SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
 				}
 				marksMasked >>= 1;
 			}
@@ -3237,7 +3241,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 }
 
 void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
-							int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) {
+							int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) {
 
 	int lineStart = ll->LineStart(subLine);
 	int posBefore = posCaret;
@@ -3285,7 +3289,7 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll,
 
 	// Adjust caret position to take into account any word wrapping symbols.
 	if ((ll->wrapIndent != 0) && (lineStart != 0)) {
-		int wordWrapCharWidth = ll->wrapIndent;
+		XYPOSITION wordWrapCharWidth = ll->wrapIndent;
 		rcCaret.left += wordWrapCharWidth;
 		rcCaret.right += wordWrapCharWidth;
 	}
@@ -3295,7 +3299,7 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll,
 	int styleMain = ll->styles[offsetFirstChar];
 	surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font,
 	        rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar,
-	        numCharsToDraw, vsDraw.styles[styleMain].back.allocated,
+	        numCharsToDraw, vsDraw.styles[styleMain].back,
 	        caretColour);
 }
 
@@ -3310,22 +3314,22 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
 		PRectangle rcPattern(0, 0, patternSize, patternSize);
 
 		// Initialize default colours based on the chrome colour scheme.  Typically the highlight is white.
-		ColourAllocated colourFMFill = vs.selbar.allocated;
-		ColourAllocated colourFMStripes = vs.selbarlight.allocated;
+		ColourDesired colourFMFill = vs.selbar;
+		ColourDesired colourFMStripes = vs.selbarlight;
 
-		if (!(vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff))) {
+		if (!(vs.selbarlight == ColourDesired(0xff, 0xff, 0xff))) {
 			// User has chosen an unusual chrome colour scheme so just use the highlight edge colour.
 			// (Typically, the highlight colour is white.)
-			colourFMFill = vs.selbarlight.allocated;
+			colourFMFill = vs.selbarlight;
 		}
 
 		if (vs.foldmarginColourSet) {
 			// override default fold margin colour
-			colourFMFill = vs.foldmarginColour.allocated;
+			colourFMFill = vs.foldmarginColour;
 		}
 		if (vs.foldmarginHighlightColourSet) {
 			// override default fold margin highlight colour
-			colourFMStripes = vs.foldmarginHighlightColour.allocated;
+			colourFMStripes = vs.foldmarginHighlightColour;
 		}
 
 		pixmapSelPattern->FillRectangle(rcPattern, colourFMFill);
@@ -3342,14 +3346,14 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
 		pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
 		pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
 		PRectangle rcIG(0, 0, 1, vs.lineHeight);
-		pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
-		pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
-		pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
-		pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
+		pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back);
+		pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore);
+		pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back);
+		pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore);
 		for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
 			PRectangle rcPixel(0, stripe, 1, stripe+1);
-			pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore.allocated);
-			pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore.allocated);
+			pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore);
+			pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore);
 		}
 	}
 
@@ -3376,10 +3380,10 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 		const bool mainCaret = r == sel.Main();
 		const SelectionPosition posCaret = (drawDrag ? posDrag : sel.Range(r).caret);
 		const int offset = posCaret.Position() - posLineStart;
-		const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
-		const int virtualOffset = posCaret.VirtualSpace() * spaceWidth;
+		const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
+		const XYPOSITION virtualOffset = posCaret.VirtualSpace() * spaceWidth;
 		if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) {
-			int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
+			XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
 			if (ll->wrapIndent != 0) {
 				int lineStart = ll->LineStart(subLine);
 				if (lineStart != 0)	// Wrapped
@@ -3392,7 +3396,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 				bool caretAtEOF = false;
 				bool caretAtEOL = false;
 				bool drawBlockCaret = false;
-				int widthOverstrikeCaret;
+				XYPOSITION widthOverstrikeCaret;
 				int caretWidthOffset = 0;
 				PRectangle rcCaret = rcLine;
 
@@ -3434,7 +3438,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 					rcCaret.left = xposCaret - caretWidthOffset;
 					rcCaret.right = rcCaret.left + vsDraw.caretWidth;
 				}
-				ColourAllocated caretColour = mainCaret ? vsDraw.caretcolour.allocated : vsDraw.additionalCaretColour.allocated;
+				ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
 				if (drawBlockCaret) {
 					DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour);
 				} else {
@@ -3450,6 +3454,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 	//Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n",
 	//	paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
+	AllocateGraphics();
 
 	StyleToPositionInView(PositionAfterArea(rcArea));
 
@@ -3461,9 +3466,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 	//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d)   %d\n",
 	//	rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
 
-	surfaceWindow->SetPalette(&palette, true);
-	pixmapLine->SetPalette(&palette, !hasFocus);
-
 	int screenLinePaintFirst = rcArea.top / vs.lineHeight;
 
 	int xStart = vs.fixedColumnWidth - xOffset;
@@ -3474,17 +3476,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 
 	bool paintAbandonedByStyling = paintState == paintAbandoned;
 	if (needUpdateUI) {
-		// Deselect palette by selecting a temporary palette
-		Palette palTemp;
-		surfaceWindow->SetPalette(&palTemp, true);
-
 		NotifyUpdateUI();
 		needUpdateUI = 0;
 
 		RefreshStyleData();
 		RefreshPixMaps(surfaceWindow);
-		surfaceWindow->SetPalette(&palette, true);
-		pixmapLine->SetPalette(&palette, !hasFocus);
 	}
 
 	// Call priority lines wrap on a window of lines which are likely
@@ -3509,7 +3505,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 		PRectangle rcRightMargin = rcClient;
 		rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
 		if (rcArea.Intersects(rcRightMargin)) {
-			surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated);
+			surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back);
 		}
 	}
 
@@ -3619,7 +3615,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 						(!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) {
 						PRectangle rcFoldLine = rcLine;
 						rcFoldLine.bottom = rcFoldLine.top + 1;
-						surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+						surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore);
 					}
 					// Paint the line below the fold
 					if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED))
@@ -3627,7 +3623,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 						(!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) {
 						PRectangle rcFoldLine = rcLine;
 						rcFoldLine.top = rcFoldLine.bottom - 1;
-						surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+						surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore);
 					}
 				}
 
@@ -3664,12 +3660,12 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 		rcBeyondEOF.right = rcBeyondEOF.right;
 		rcBeyondEOF.top = (cs.LinesDisplayed() - topLine) * vs.lineHeight;
 		if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
-			surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back.allocated);
+			surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back);
 			if (vs.edgeState == EDGE_LINE) {
 				int edgeX = theEdge * vs.spaceWidth;
 				rcBeyondEOF.left = edgeX + xStart;
 				rcBeyondEOF.right = rcBeyondEOF.left + 1;
-				surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour.allocated);
+				surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour);
 			}
 		}
 		//Platform::DebugPrintf(
@@ -3745,21 +3741,21 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 	// Set colours for printing according to users settings
 	for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) {
 		if (printColourMode == SC_PRINT_INVERTLIGHT) {
-			vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
-			vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
+			vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
+			vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
 		} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
-			vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0);
-			vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+			vsPrint.styles[sty].fore = ColourDesired(0, 0, 0);
+			vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
 		} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
-			vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+			vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
 		} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
 			if (sty <= STYLE_DEFAULT) {
-				vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+				vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
 			}
 		}
 	}
 	// White background for the line numbers
-	vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
+	vsPrint.styles[STYLE_LINENUMBER].back = ColourDesired(0xff, 0xff, 0xff);
 
 	vsPrint.Refresh(*surfaceMeasure);
 	// Determining width must hapen after fonts have been realised in Refresh
@@ -3770,9 +3766,6 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 		vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
 		vsPrint.Refresh(*surfaceMeasure);	// Recalculate fixedColumnWidth
 	}
-	// Ensure colours are set up
-	vsPrint.RefreshColourPalette(palette, true);
-	vsPrint.RefreshColourPalette(palette, false);
 
 	int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin);
 	int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
@@ -3852,8 +3845,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
 			surface->FlushCachedState();
 			surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
 			        ypos + vsPrint.maxAscent, number, istrlen(number),
-			        vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
-			        vsPrint.styles[STYLE_LINENUMBER].back.allocated);
+			        vsPrint.styles[STYLE_LINENUMBER].fore,
+			        vsPrint.styles[STYLE_LINENUMBER].back);
 		}
 
 		// Draw the line
@@ -3924,7 +3917,7 @@ void Editor::SetScrollBars() {
 }
 
 void Editor::ChangeSize() {
-	DropGraphics();
+	DropGraphics(false);
 	SetScrollBars();
 	if (wrapState != eWrapNone) {
 		PRectangle rcTextArea = GetClientRectangle();
@@ -4293,7 +4286,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
 	UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty());
 	if (sel.Empty()) {
 		for (size_t r=0; r<sel.Count(); r++) {
-			if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) {
+			if (!RangeContainsProtected(sel.Range(r).caret.Position() - 1, sel.Range(r).caret.Position())) {
 				if (sel.Range(r).caret.VirtualSpace()) {
 					sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1);
 					sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace());
@@ -4498,14 +4491,12 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
 void Editor::CheckModificationForWrap(DocModification mh) {
 	if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
 		llc.Invalidate(LineLayout::llCheckTextAndStyle);
+		int lineDoc = pdoc->LineFromPosition(mh.position);
+		int lines = Platform::Maximum(0, mh.linesAdded);
 		if (wrapState != eWrapNone) {
-			int lineDoc = pdoc->LineFromPosition(mh.position);
-			int lines = Platform::Maximum(0, mh.linesAdded);
 			NeedWrapping(lineDoc, lineDoc + lines + 1);
 		}
 		// Fix up annotation heights
-		int lineDoc = pdoc->LineFromPosition(mh.position);
-		int lines = Platform::Maximum(0, mh.linesAdded);
 		SetAnnotationHeights(lineDoc, lineDoc + lines + 2);
 	}
 }
@@ -4649,10 +4640,10 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
 	}
 
 	if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) {
-		if ((paintState == notPainting) || !PaintContainsMargin()) {
+		if ((!willRedrawAll) && ((paintState == notPainting) || !PaintContainsMargin())) {
 			if (mh.modificationType & SC_MOD_CHANGEFOLD) {
 				// Fold changes can affect the drawing of following lines so redraw whole margin
-				RedrawSelMargin(mh.line-1, true);
+				RedrawSelMargin(highlightDelimiter.isEnabled ? -1 : mh.line-1, true);
 			} else {
 				RedrawSelMargin(mh.line);
 			}
@@ -6709,8 +6700,22 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) {
 
 void Editor::SetAnnotationHeights(int start, int end) {
 	if (vs.annotationVisible) {
-		for (int line=start; line<end; line++) {
-			cs.SetHeight(line, pdoc->AnnotationLines(line) + 1);
+		bool changedHeight = false;
+		for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
+			int linesWrapped = 1;
+			if (wrapState != eWrapNone) {
+				AutoSurface surface(this);
+				AutoLineLayout ll(llc, RetrieveLineLayout(line));
+				if (surface && ll) {
+					LayoutLine(line, surface, vs, ll, wrapWidth);
+					linesWrapped = ll->lines;
+				}
+			}
+			if (cs.SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped))
+				changedHeight = true;
+		}
+		if (changedHeight) {
+			Redraw();
 		}
 	}
 }
@@ -6973,13 +6978,16 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
 	vs.EnsureStyle(wParam);
 	switch (iMessage) {
 	case SCI_STYLESETFORE:
-		vs.styles[wParam].fore.desired = ColourDesired(lParam);
+		vs.styles[wParam].fore = ColourDesired(lParam);
 		break;
 	case SCI_STYLESETBACK:
-		vs.styles[wParam].back.desired = ColourDesired(lParam);
+		vs.styles[wParam].back = ColourDesired(lParam);
 		break;
 	case SCI_STYLESETBOLD:
-		vs.styles[wParam].bold = lParam != 0;
+		vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
+		break;
+	case SCI_STYLESETWEIGHT:
+		vs.styles[wParam].weight = lParam;
 		break;
 	case SCI_STYLESETITALIC:
 		vs.styles[wParam].italic = lParam != 0;
@@ -6988,6 +6996,9 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
 		vs.styles[wParam].eolFilled = lParam != 0;
 		break;
 	case SCI_STYLESETSIZE:
+		vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER;
+		break;
+	case SCI_STYLESETSIZEFRACTIONAL:
 		vs.styles[wParam].size = lParam;
 		break;
 	case SCI_STYLESETFONT:
@@ -7021,16 +7032,20 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
 	vs.EnsureStyle(wParam);
 	switch (iMessage) {
 	case SCI_STYLEGETFORE:
-		return vs.styles[wParam].fore.desired.AsLong();
+		return vs.styles[wParam].fore.AsLong();
 	case SCI_STYLEGETBACK:
-		return vs.styles[wParam].back.desired.AsLong();
+		return vs.styles[wParam].back.AsLong();
 	case SCI_STYLEGETBOLD:
-		return vs.styles[wParam].bold ? 1 : 0;
+		return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
+	case SCI_STYLEGETWEIGHT:
+		return vs.styles[wParam].weight;
 	case SCI_STYLEGETITALIC:
 		return vs.styles[wParam].italic ? 1 : 0;
 	case SCI_STYLEGETEOLFILLED:
 		return vs.styles[wParam].eolFilled ? 1 : 0;
 	case SCI_STYLEGETSIZE:
+		return vs.styles[wParam].size / SC_FONT_SIZE_MULTIPLIER;
+	case SCI_STYLEGETSIZEFRACTIONAL:
 		return vs.styles[wParam].size;
 	case SCI_STYLEGETFONT:
 		if (!vs.styles[wParam].fontName)
@@ -7965,13 +7980,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_GETCODEPAGE:
 		return pdoc->dbcsCodePage;
 
+#ifdef INCLUDE_DEPRECATED_FEATURES
 	case SCI_SETUSEPALETTE:
-		palette.allowRealization = wParam != 0;
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_GETUSEPALETTE:
-		return palette.allowRealization;
+		return 0;
+#endif
 
 		// Marker definition and setting
 	case SCI_MARKERDEFINE:
@@ -7989,13 +8005,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_MARKERSETFORE:
 		if (wParam <= MARKER_MAX)
-			vs.markers[wParam].fore.desired = ColourDesired(lParam);
+			vs.markers[wParam].fore = ColourDesired(lParam);
 		InvalidateStyleData();
 		RedrawSelMargin();
 		break;
 	case SCI_MARKERSETBACKSELECTED:
 		if (wParam <= MARKER_MAX)
-			vs.markers[wParam].backSelected.desired = ColourDesired(lParam);
+			vs.markers[wParam].backSelected = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 	case SCI_MARKERENABLEHIGHLIGHT:
@@ -8004,7 +8020,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		break;
 	case SCI_MARKERSETBACK:
 		if (wParam <= MARKER_MAX)
-			vs.markers[wParam].back.desired = ColourDesired(lParam);
+			vs.markers[wParam].back = ColourDesired(lParam);
 		InvalidateStyleData();
 		RedrawSelMargin();
 		break;
@@ -8033,14 +8049,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_MARKERGET:
 		return pdoc->GetMark(wParam);
 
-	case SCI_MARKERNEXT: {
-			int lt = pdoc->LinesTotal();
-			for (int iLine = wParam; iLine < lt; iLine++) {
-				if ((pdoc->GetMark(iLine) & lParam) != 0)
-					return iLine;
-			}
-		}
-		return -1;
+	case SCI_MARKERNEXT: 
+		return pdoc->MarkerNext(wParam, lParam);
 
 	case SCI_MARKERPREVIOUS: {
 			for (int iLine = wParam; iLine >= 0; iLine--) {
@@ -8148,9 +8158,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_STYLESETFORE:
 	case SCI_STYLESETBACK:
 	case SCI_STYLESETBOLD:
+	case SCI_STYLESETWEIGHT:
 	case SCI_STYLESETITALIC:
 	case SCI_STYLESETEOLFILLED:
 	case SCI_STYLESETSIZE:
+	case SCI_STYLESETSIZEFRACTIONAL:
 	case SCI_STYLESETFONT:
 	case SCI_STYLESETUNDERLINE:
 	case SCI_STYLESETCASE:
@@ -8164,9 +8176,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_STYLEGETFORE:
 	case SCI_STYLEGETBACK:
 	case SCI_STYLEGETBOLD:
+	case SCI_STYLEGETWEIGHT:
 	case SCI_STYLEGETITALIC:
 	case SCI_STYLEGETEOLFILLED:
 	case SCI_STYLEGETSIZE:
+	case SCI_STYLEGETSIZEFRACTIONAL:
 	case SCI_STYLEGETFONT:
 	case SCI_STYLEGETUNDERLINE:
 	case SCI_STYLEGETCASE:
@@ -8204,9 +8218,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		InvalidateStyleRedraw();
 		break;
 	case SCI_GETCARETLINEBACK:
-		return vs.caretLineBackground.desired.AsLong();
+		return vs.caretLineBackground.AsLong();
 	case SCI_SETCARETLINEBACK:
-		vs.caretLineBackground.desired = wParam;
+		vs.caretLineBackground = wParam;
 		InvalidateStyleRedraw();
 		break;
 	case SCI_GETCARETLINEBACKALPHA:
@@ -8259,6 +8273,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_GETLINEVISIBLE:
 		return cs.GetVisible(wParam);
 
+	case SCI_GETALLLINESVISIBLE:
+		return cs.HiddenLines() ? 0 : 1;
+
 	case SCI_SETFOLDEXPANDED:
 		if (cs.SetExpanded(wParam, lParam != 0)) {
 			RedrawSelMargin();
@@ -8316,15 +8333,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_SETSELFORE:
 		vs.selforeset = wParam != 0;
-		vs.selforeground.desired = ColourDesired(lParam);
-		vs.selAdditionalForeground.desired = ColourDesired(lParam);
+		vs.selforeground = ColourDesired(lParam);
+		vs.selAdditionalForeground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETSELBACK:
 		vs.selbackset = wParam != 0;
-		vs.selbackground.desired = ColourDesired(lParam);
-		vs.selAdditionalBackground.desired = ColourDesired(lParam);
+		vs.selbackground = ColourDesired(lParam);
+		vs.selAdditionalBackground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
@@ -8347,23 +8364,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_SETWHITESPACEFORE:
 		vs.whitespaceForegroundSet = wParam != 0;
-		vs.whitespaceForeground.desired = ColourDesired(lParam);
+		vs.whitespaceForeground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETWHITESPACEBACK:
 		vs.whitespaceBackgroundSet = wParam != 0;
-		vs.whitespaceBackground.desired = ColourDesired(lParam);
+		vs.whitespaceBackground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETCARETFORE:
-		vs.caretcolour.desired = ColourDesired(wParam);
+		vs.caretcolour = ColourDesired(wParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_GETCARETFORE:
-		return vs.caretcolour.desired.AsLong();
+		return vs.caretcolour.AsLong();
 
 	case SCI_SETCARETSTYLE:
 		if (wParam <= CARETSTYLE_BLOCK)
@@ -8416,13 +8433,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_INDICSETFORE:
 		if (wParam <= INDIC_MAX) {
-			vs.indicators[wParam].fore.desired = ColourDesired(lParam);
+			vs.indicators[wParam].fore = ColourDesired(lParam);
 			InvalidateStyleRedraw();
 		}
 		break;
 
 	case SCI_INDICGETFORE:
-		return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0;
+		return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.AsLong() : 0;
 
 	case SCI_INDICSETUNDER:
 		if (wParam <= INDIC_MAX) {
@@ -8638,10 +8655,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		break;
 
 	case SCI_GETEDGECOLOUR:
-		return vs.edgecolour.desired.AsLong();
+		return vs.edgecolour.AsLong();
 
 	case SCI_SETEDGECOLOUR:
-		vs.edgecolour.desired = ColourDesired(wParam);
+		vs.edgecolour = ColourDesired(wParam);
 		InvalidateStyleRedraw();
 		break;
 
@@ -8669,6 +8686,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		(reinterpret_cast<Document *>(lParam))->Release();
 		break;
 
+	case SCI_CREATELOADER: {
+			Document *doc = new Document();
+			if (doc) {
+				doc->AddRef();
+				doc->Allocate(wParam);
+				doc->SetUndoCollection(false);
+			}
+			return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
+		}
+
 	case SCI_SETMODEVENTMASK:
 		modEventMask = wParam;
 		return 0;
@@ -8795,33 +8822,33 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_SETFOLDMARGINCOLOUR:
 		vs.foldmarginColourSet = wParam != 0;
-		vs.foldmarginColour.desired = ColourDesired(lParam);
+		vs.foldmarginColour = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETFOLDMARGINHICOLOUR:
 		vs.foldmarginHighlightColourSet = wParam != 0;
-		vs.foldmarginHighlightColour.desired = ColourDesired(lParam);
+		vs.foldmarginHighlightColour = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETHOTSPOTACTIVEFORE:
 		vs.hotspotForegroundSet = wParam != 0;
-		vs.hotspotForeground.desired = ColourDesired(lParam);
+		vs.hotspotForeground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_GETHOTSPOTACTIVEFORE:
-		return vs.hotspotForeground.desired.AsLong();
+		return vs.hotspotForeground.AsLong();
 
 	case SCI_SETHOTSPOTACTIVEBACK:
 		vs.hotspotBackgroundSet = wParam != 0;
-		vs.hotspotBackground.desired = ColourDesired(lParam);
+		vs.hotspotBackground = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_GETHOTSPOTACTIVEBACK:
-		return vs.hotspotBackground.desired.AsLong();
+		return vs.hotspotBackground.AsLong();
 
 	case SCI_SETHOTSPOTACTIVEUNDERLINE:
 		vs.hotspotUnderline = wParam != 0;
@@ -9156,12 +9183,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return virtualSpaceOptions;
 
 	case SCI_SETADDITIONALSELFORE:
-		vs.selAdditionalForeground.desired = ColourDesired(wParam);
+		vs.selAdditionalForeground = ColourDesired(wParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_SETADDITIONALSELBACK:
-		vs.selAdditionalBackground.desired = ColourDesired(wParam);
+		vs.selAdditionalBackground = ColourDesired(wParam);
 		InvalidateStyleRedraw();
 		break;
 
@@ -9174,12 +9201,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return vs.selAdditionalAlpha;
 
 	case SCI_SETADDITIONALCARETFORE:
-		vs.additionalCaretColour.desired = ColourDesired(wParam);
+		vs.additionalCaretColour = ColourDesired(wParam);
 		InvalidateStyleRedraw();
 		break;
 
 	case SCI_GETADDITIONALCARETFORE:
-		return vs.additionalCaretColour.desired.AsLong();
+		return vs.additionalCaretColour.AsLong();
 
 	case SCI_ROTATESELECTION:
 		sel.RotateMain();
@@ -9202,6 +9229,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_GETIDENTIFIER:
 		return GetCtrlID();
 
+	case SCI_SETTECHNOLOGY:
+		// No action by default
+		break;
+	
+	case SCI_GETTECHNOLOGY:
+		return technology;
+
+	case SCI_COUNTCHARACTERS:
+		return pdoc->CountCharacters(wParam, lParam);
+
 	default:
 		return DefWndProc(iMessage, wParam, lParam);
 	}
diff --git a/plugins/scintilla/scintilla/Editor.h b/plugins/scintilla/scintilla/Editor.h
index f1a500b..0923f40 100644
--- a/plugins/scintilla/scintilla/Editor.h
+++ b/plugins/scintilla/scintilla/Editor.h
@@ -131,8 +131,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	 * When a style attribute is changed, this cache is flushed. */
 	bool stylesValid;
 	ViewStyle vs;
+	int technology;
 	Point sizeRGBAImage;
-	Palette palette;
 
 	int printMagnification;
 	int printColourMode;
@@ -226,6 +226,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	enum { notPainting, painting, paintAbandoned } paintState;
 	PRectangle rcPaint;
 	bool paintingAllText;
+	bool willRedrawAll;
 	StyleNeeded styleNeeded;
 
 	int modEventMask;
@@ -263,7 +264,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	int wrapVisualFlags;
 	int wrapVisualFlagsLocation;
 	int wrapVisualStartIndent;
-	int wrapAddIndent; // This will be added to initial indent of line
+	XYPOSITION wrapAddIndent; // This will be added to initial indent of line
 	int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
 
 	bool convertPastes;
@@ -277,9 +278,9 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 
 	void InvalidateStyleData();
 	void InvalidateStyleRedraw();
-	virtual void RefreshColourPalette(Palette &pal, bool want);
 	void RefreshStyleData();
-	void DropGraphics();
+	void DropGraphics(bool freeObjects);
+	void AllocateGraphics();
 
 	virtual PRectangle GetClientRectangle();
 	PRectangle GetTextRectangle();
@@ -367,14 +368,14 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	LineLayout *RetrieveLineLayout(int lineNumber);
 	void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
 		int width=LineLayout::wrapWidthInfinite);
-	ColourAllocated SelectionBackground(ViewStyle &vsDraw, bool main);
-	ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
+	ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main);
+	ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
 	void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
-	void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
+	void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
 	void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
-		int line, int lineEnd, int xStart, int subLine, int subLineStart,
-		bool overrideBackground, ColourAllocated background,
-		bool drawWrapMark, ColourAllocated wrapColour);
+		int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
+		bool overrideBackground, ColourDesired background,
+		bool drawWrapMark, ColourDesired wrapColour);
 	void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
 		int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
 	void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
@@ -384,7 +385,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
 		PRectangle rcLine, LineLayout *ll, int subLine);
 	void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
-		int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour);
+		int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour);
 	void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 		PRectangle rcLine, LineLayout *ll, int subLine);
 	void RefreshPixMaps(Surface *surfaceWindow);
@@ -574,7 +575,7 @@ private:
 public:
 	AutoSurface(Editor *ed) : surf(0) {
 		if (ed->wMain.GetID()) {
-			surf = Surface::Allocate();
+			surf = Surface::Allocate(ed->technology);
 			if (surf) {
 				surf->Init(ed->wMain.GetID());
 				surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
@@ -584,7 +585,7 @@ public:
 	}
 	AutoSurface(SurfaceID sid, Editor *ed) : surf(0) {
 		if (ed->wMain.GetID()) {
-			surf = Surface::Allocate();
+			surf = Surface::Allocate(ed->technology);
 			if (surf) {
 				surf->Init(sid, ed->wMain.GetID());
 				surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
diff --git a/plugins/scintilla/scintilla/Indicator.cxx b/plugins/scintilla/scintilla/Indicator.cxx
index 7059a55..9ea4024 100644
--- a/plugins/scintilla/scintilla/Indicator.cxx
+++ b/plugins/scintilla/scintilla/Indicator.cxx
@@ -8,10 +8,6 @@
 #include <vector>
 #include <map>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include "Platform.h"
 
 #include "Scintilla.h"
@@ -23,7 +19,7 @@ using namespace Scintilla;
 #endif
 
 void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
-	surface->PenColour(fore.allocated);
+	surface->PenColour(fore);
 	int ymid = (rc.bottom + rc.top) / 2;
 	if (style == INDIC_SQUIGGLE) {
 		surface->MoveTo(rc.left, rc.top);
@@ -91,7 +87,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
 		rcBox.top = rcLine.top + 1;
 		rcBox.left = rc.left;
 		rcBox.right = rc.right;
-		surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore.allocated, fillAlpha, fore.allocated, outlineAlpha, 0);
+		surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore, fillAlpha, fore, outlineAlpha, 0);
 	} else if (style == INDIC_DOTBOX) {
 		PRectangle rcBox = rcLine;
 		rcBox.top = rcLine.top + 1;
@@ -103,13 +99,13 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
 		// Draw horizontal lines top and bottom
 		for (int x=0; x<width; x++) {
 			for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) {
-				image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+				image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
 			}
 		}
 		// Draw vertical lines left and right
 		for (int y=1; y<rcBox.Height(); y++) {
 			for (int x=0; x<width; x += width-1) {
-				image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+				image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
 			}
 		}
 		surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
@@ -124,7 +120,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
 		int x = rc.left;
 		while (x < rc.right) {
 			PRectangle rcDot(x, ymid, x+1, ymid+1);
-			surface->FillRectangle(rcDot, fore.allocated);
+			surface->FillRectangle(rcDot, fore);
 			x += 2;
 		}
 	} else {	// Either INDIC_PLAIN or unknown
diff --git a/plugins/scintilla/scintilla/Indicator.h b/plugins/scintilla/scintilla/Indicator.h
index e787b59..0284a85 100644
--- a/plugins/scintilla/scintilla/Indicator.h
+++ b/plugins/scintilla/scintilla/Indicator.h
@@ -18,7 +18,7 @@ class Indicator {
 public:
 	int style;
 	bool under;
-	ColourPair fore;
+	ColourDesired fore;
 	int fillAlpha;
 	int outlineAlpha;
 	Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)), fillAlpha(30), outlineAlpha(50) {
diff --git a/plugins/scintilla/scintilla/LexAVS.cxx b/plugins/scintilla/scintilla/LexAVS.cxx
new file mode 100644
index 0000000..82e4345
--- /dev/null
+++ b/plugins/scintilla/scintilla/LexAVS.cxx
@@ -0,0 +1,293 @@
+// Scintilla source code edit control
+/** @file LexAVS.cxx
+ ** Lexer for AviSynth.
+ **/
+// Copyright 2012 by Bruno Barbieri <brunorex gmail com>
+// Heavily based on LexPOV by Neil Hodgson
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include "ILexer.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#include "WordList.h"
+#include "LexAccessor.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "LexerModule.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(int ch) {
+	return isalpha(ch) || (ch != ' ' && ch != '\n' && ch != '(' && ch != '.' && ch != ',');
+}
+
+static inline bool IsANumberChar(int ch) {
+	// Not exactly following number definition (several dots are seen as OK, etc.)
+	// but probably enough in most cases.
+	return (ch < 0x80) &&
+			(isdigit(ch) || ch == '.' || ch == '-' || ch == '+');
+}
+
+static void ColouriseAvsDoc(
+	unsigned int startPos,
+	int length,
+	int initStyle,
+	WordList *keywordlists[],
+	Accessor &styler) {
+
+	WordList &keywords = *keywordlists[0];
+	WordList &filters = *keywordlists[1];
+	WordList &plugins = *keywordlists[2];
+	WordList &functions = *keywordlists[3];
+	WordList &clipProperties = *keywordlists[4];
+	WordList &userDefined = *keywordlists[5];
+
+	int currentLine = styler.GetLine(startPos);
+	// Initialize the block comment nesting level, if we are inside such a comment.
+	int blockCommentLevel = 0;
+	if (initStyle == SCE_AVS_COMMENTBLOCK || initStyle == SCE_AVS_COMMENTBLOCKN) {
+		blockCommentLevel = styler.GetLineState(currentLine - 1);
+	}
+
+	// Do not leak onto next line
+	if (initStyle == SCE_AVS_COMMENTLINE) {
+		initStyle = SCE_AVS_DEFAULT;
+	}
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+		if (sc.atLineEnd) {
+			// Update the line state, so it can be seen by next line
+			currentLine = styler.GetLine(sc.currentPos);
+			if (sc.state == SCE_AVS_COMMENTBLOCK || sc.state == SCE_AVS_COMMENTBLOCKN) {
+				// Inside a block comment, we set the line state
+				styler.SetLineState(currentLine, blockCommentLevel);
+			} else {
+				// Reset the line state
+				styler.SetLineState(currentLine, 0);
+			}
+		}
+		
+		// Determine if the current state should terminate.
+		if (sc.state == SCE_AVS_OPERATOR) {
+			sc.SetState(SCE_AVS_DEFAULT);
+		} else if (sc.state == SCE_AVS_NUMBER) {
+			// We stop the number definition on non-numerical non-dot non-sign char
+			if (!IsANumberChar(sc.ch)) {
+				sc.SetState(SCE_AVS_DEFAULT);
+			}
+		} else if (sc.state == SCE_AVS_IDENTIFIER) {
+			if (!IsAWordChar(sc.ch)) {
+				char s[100];
+				sc.GetCurrentLowered(s, sizeof(s));
+
+				if (keywords.InList(s)) {
+					sc.ChangeState(SCE_AVS_KEYWORD);
+				} else if (filters.InList(s)) {
+					sc.ChangeState(SCE_AVS_FILTER);
+				} else if (plugins.InList(s)) {
+					sc.ChangeState(SCE_AVS_PLUGIN);
+				} else if (functions.InList(s)) {
+					sc.ChangeState(SCE_AVS_FUNCTION);
+				} else if (clipProperties.InList(s)) {
+					sc.ChangeState(SCE_AVS_CLIPPROP);
+				} else if (userDefined.InList(s)) {
+					sc.ChangeState(SCE_AVS_USERDFN);
+				}
+				sc.SetState(SCE_AVS_DEFAULT);
+			}
+		} else if (sc.state == SCE_AVS_COMMENTBLOCK) {
+			if (sc.Match('/', '*')) {
+				blockCommentLevel++;
+				sc.Forward();
+			} else if (sc.Match('*', '/') && blockCommentLevel > 0) {
+				blockCommentLevel--;
+				sc.Forward();
+				if (blockCommentLevel == 0) {
+					sc.ForwardSetState(SCE_AVS_DEFAULT);
+				}
+			}
+		} else if (sc.state == SCE_AVS_COMMENTBLOCKN) {
+			if (sc.Match('[', '*')) {
+				blockCommentLevel++;
+				sc.Forward();
+			} else if (sc.Match('*', ']') && blockCommentLevel > 0) {
+				blockCommentLevel--;
+				sc.Forward();
+				if (blockCommentLevel == 0) {
+					sc.ForwardSetState(SCE_AVS_DEFAULT);
+				}
+			}
+		} else if (sc.state == SCE_AVS_COMMENTLINE) {
+			if (sc.atLineEnd) {
+				sc.ForwardSetState(SCE_AVS_DEFAULT);
+			}
+		} else if (sc.state == SCE_AVS_STRING) {
+			if (sc.ch == '\"') {
+				sc.ForwardSetState(SCE_AVS_DEFAULT);
+			}
+		} else if (sc.state == SCE_AVS_TRIPLESTRING) {
+			if (sc.Match("\"\"\"")) {
+				sc.Forward();
+				sc.Forward();
+				sc.ForwardSetState(SCE_AVS_DEFAULT);
+			}
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_AVS_DEFAULT) {
+			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_AVS_NUMBER);
+			} else 	if (IsADigit(sc.ch) || (sc.ch == ',' && IsADigit(sc.chNext))) {
+				sc.Forward();
+				sc.SetState(SCE_AVS_NUMBER);
+			} else if (sc.Match('/', '*')) {
+				blockCommentLevel = 1;
+				sc.SetState(SCE_AVS_COMMENTBLOCK);
+				sc.Forward();	// Eat the * so it isn't used for the end of the comment
+			} else if (sc.Match('[', '*')) {
+				blockCommentLevel = 1;
+				sc.SetState(SCE_AVS_COMMENTBLOCKN);
+				sc.Forward();	// Eat the * so it isn't used for the end of the comment
+			} else if (sc.ch == '#') {
+				sc.SetState(SCE_AVS_COMMENTLINE);
+			} else if (sc.ch == '\"') {
+				if (sc.Match("\"\"\"")) {
+					sc.SetState(SCE_AVS_TRIPLESTRING);
+				} else {
+					sc.SetState(SCE_AVS_STRING);
+				}
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_AVS_OPERATOR);
+			} else if (IsAWordStart(sc.ch)) {
+				sc.SetState(SCE_AVS_IDENTIFIER);
+			}
+		}
+	}
+
+	// End of file: complete any pending changeState
+	if (sc.state == SCE_AVS_IDENTIFIER) {
+		if (!IsAWordChar(sc.ch)) {
+			char s[100];
+			sc.GetCurrentLowered(s, sizeof(s));
+
+			if (keywords.InList(s)) {
+				sc.ChangeState(SCE_AVS_KEYWORD);
+			} else if (filters.InList(s)) {
+				sc.ChangeState(SCE_AVS_FILTER);
+			} else if (plugins.InList(s)) {
+				sc.ChangeState(SCE_AVS_PLUGIN);
+			} else if (functions.InList(s)) {
+				sc.ChangeState(SCE_AVS_FUNCTION);
+			} else if (clipProperties.InList(s)) {
+				sc.ChangeState(SCE_AVS_CLIPPROP);
+			} else if (userDefined.InList(s)) {
+				sc.ChangeState(SCE_AVS_USERDFN);
+			}
+			sc.SetState(SCE_AVS_DEFAULT);
+		}
+	}
+
+	sc.Complete();
+}
+
+static void FoldAvsDoc(
+	unsigned int startPos,
+	int length,
+	int initStyle,
+	WordList *[],
+	Accessor &styler) {
+
+	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+	int levelCurrent = levelPrev;
+	char chNext = styler[startPos];
+	int styleNext = styler.StyleAt(startPos);
+	int style = initStyle;
+
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = chNext;
+		chNext = styler.SafeGetCharAt(i + 1);
+		int stylePrev = style;
+		style = styleNext;
+		styleNext = styler.StyleAt(i + 1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		if (foldComment && style == SCE_AVS_COMMENTBLOCK) {
+			if (stylePrev != SCE_AVS_COMMENTBLOCK) {
+				levelCurrent++;
+			} else if ((styleNext != SCE_AVS_COMMENTBLOCK) && !atEOL) {
+				// Comments don't end at end of line and the next character may be unstyled.
+				levelCurrent--;
+			}
+		}
+
+		if (foldComment && style == SCE_AVS_COMMENTBLOCKN) {
+			if (stylePrev != SCE_AVS_COMMENTBLOCKN) {
+				levelCurrent++;
+			} else if ((styleNext != SCE_AVS_COMMENTBLOCKN) && !atEOL) {
+				// Comments don't end at end of line and the next character may be unstyled.
+				levelCurrent--;
+			}
+		}
+
+		if (style == SCE_AVS_OPERATOR) {
+			if (ch == '{') {
+				levelCurrent++;
+			} else if (ch == '}') {
+				levelCurrent--;
+			}
+		}
+
+		if (atEOL) {
+			int lev = levelPrev;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if ((levelCurrent > levelPrev) && (visibleChars > 0))
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelPrev = levelCurrent;
+			visibleChars = 0;
+		}
+
+		if (!isspacechar(ch))
+			visibleChars++;
+	}
+	// Fill in the real level of the next line, keeping the current flags as they will be filled in later
+	int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+	styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const avsWordLists[] = {
+	"Keywords",
+	"Filters",
+	"Plugins",
+	"Functions",
+	"Clip properties",
+	"User defined functions",
+	0,
+};
+
+LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists);
diff --git a/plugins/scintilla/scintilla/LexAda.cxx b/plugins/scintilla/scintilla/LexAda.cxx
index e109514..49eb2c6 100644
--- a/plugins/scintilla/scintilla/LexAda.cxx
+++ b/plugins/scintilla/scintilla/LexAda.cxx
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <string>
 
diff --git a/plugins/scintilla/scintilla/LexAsm.cxx b/plugins/scintilla/scintilla/LexAsm.cxx
index 946d47a..71e24bc 100644
--- a/plugins/scintilla/scintilla/LexAsm.cxx
+++ b/plugins/scintilla/scintilla/LexAsm.cxx
@@ -16,10 +16,6 @@
 #include <assert.h>
 #include <ctype.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <map>
 #include <set>
diff --git a/plugins/scintilla/scintilla/LexBasic.cxx b/plugins/scintilla/scintilla/LexBasic.cxx
index 55641ed..b15ce09 100644
--- a/plugins/scintilla/scintilla/LexBasic.cxx
+++ b/plugins/scintilla/scintilla/LexBasic.cxx
@@ -24,10 +24,6 @@
 #include <assert.h>
 #include <ctype.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <map>
 
diff --git a/plugins/scintilla/scintilla/LexCPP.cxx b/plugins/scintilla/scintilla/LexCPP.cxx
index 51fd192..b92f279 100644
--- a/plugins/scintilla/scintilla/LexCPP.cxx
+++ b/plugins/scintilla/scintilla/LexCPP.cxx
@@ -13,10 +13,6 @@
 #include <stdarg.h>
 #include <assert.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <vector>
 #include <map>
@@ -90,7 +86,7 @@ static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
 static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) {
 	std::string restOfLine;
 	int i =0;
-	char ch = styler.SafeGetCharAt(start + i, '\n');
+	char ch = styler.SafeGetCharAt(start, '\n');
 	while ((ch != '\r') && (ch != '\n')) {
 		if (allowSpace || (ch != ' '))
 			restOfLine += ch;
@@ -209,6 +205,7 @@ struct OptionsCPP {
 	bool trackPreprocessor;
 	bool updatePreprocessor;
 	bool triplequotedStrings;
+	bool hashquotedStrings;
 	bool fold;
 	bool foldSyntaxBased;
 	bool foldComment;
@@ -226,6 +223,7 @@ struct OptionsCPP {
 		trackPreprocessor = true;
 		updatePreprocessor = true;
 		triplequotedStrings = false;
+		hashquotedStrings = false;
 		fold = false;
 		foldSyntaxBased = true;
 		foldComment = false;
@@ -268,6 +266,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
 		DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings,
 			"Set to 1 to enable highlighting of triple-quoted strings.");
 
+		DefineProperty("lexer.cpp.hashquoted.strings", &OptionsCPP::hashquotedStrings,
+			"Set to 1 to enable highlighting of hash-quoted strings.");
+
 		DefineProperty("fold", &OptionsCPP::fold);
 
 		DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased,
@@ -553,6 +554,8 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
 		// Handle line continuation generically.
 		if (sc.ch == '\\') {
 			if (sc.chNext == '\n' || sc.chNext == '\r') {
+				lineCurrent++;
+				vlls.Add(lineCurrent, preproc);
 				sc.Forward();
 				if (sc.ch == '\r' && sc.chNext == '\n') {
 					sc.Forward();
@@ -692,6 +695,15 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
 					sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
 				}
 				break;
+			case SCE_C_HASHQUOTEDSTRING:
+				if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\"') {
+					sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
+				}
+				break;
 			case SCE_C_STRINGRAW:
 				if (sc.Match(rawStringTerminator.c_str())) {
 					for (size_t termPos=rawStringTerminator.size(); termPos; termPos--)
@@ -768,6 +780,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
 			} else if (options.triplequotedStrings && sc.Match("\"\"\"")) {
 				sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet);
 				sc.Forward(2);
+			} else if (options.hashquotedStrings && sc.Match('#', '\"')) {
+				sc.SetState(SCE_C_HASHQUOTEDSTRING|activitySet);
+				sc.Forward();
 			} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
 				if (lastWordWasUUID) {
 					sc.SetState(SCE_C_UUID|activitySet);
@@ -1037,7 +1052,7 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens) {
 			if (tokens[i+2] == ")") {
 				// defined()
 				tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 3);
-			} else if (((i+2)<tokens.size()) && (tokens[i+3] == ")")) {
+			} else if (((i+3)<tokens.size()) && (tokens[i+3] == ")")) {
 				// defined(<int>)
 				tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4);
 				val = "1";
diff --git a/plugins/scintilla/scintilla/LexCSS.cxx b/plugins/scintilla/scintilla/LexCSS.cxx
index 8fbca38..305a1dd 100644
--- a/plugins/scintilla/scintilla/LexCSS.cxx
+++ b/plugins/scintilla/scintilla/LexCSS.cxx
@@ -3,10 +3,16 @@
  ** Lexer for Cascading Style Sheets
  ** Written by Jakub Vrá
  ** Improved by Philippe Lhoste (CSS2)
+ ** Improved by Ross McKay (SCSS mode; see http://sass-lang.com/ )
  **/
 // Copyright 1998-2002 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+// TODO: handle SCSS nested properties like font: { weight: bold; size: 1em; }
+// TODO: handle SCSS interpolation: #{}
+// TODO: add features for Less if somebody feels like contributing; http://lesscss.org/
+// TODO: refactor this monster so that the next poor slob can read it!
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -51,6 +57,22 @@ inline bool IsCssOperator(const int ch) {
 	return false;
 }
 
+// look behind (from start of document to our start position) to determine current nesting level
+inline int NestingLevelLookBehind(unsigned int startPos, Accessor &styler) {
+	int ch;
+	int nestingLevel = 0;
+
+	for (unsigned int i = 0; i < startPos; i++) {
+		ch = styler.SafeGetCharAt(i);
+		if (ch == '{')
+			nestingLevel++;
+		else if (ch == '}')
+			nestingLevel--;
+	}
+
+	return nestingLevel;
+}
+
 static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
 	WordList &css1Props = *keywordlists[0];
 	WordList &pseudoClasses = *keywordlists[1];
@@ -66,11 +88,35 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 	int lastState = -1; // before operator
 	int lastStateC = -1; // before comment
 	int lastStateS = -1; // before single-quoted/double-quoted string
+	int lastStateVar = -1; // before variable (SCSS)
+	int lastStateVal = -1; // before value (SCSS)
 	int op = ' '; // last operator
 	int opPrev = ' '; // last operator
+	bool insideParentheses = false; // true if currently in a CSS url() or similar construct
+
+	// property lexer.css.scss.language
+	//	Set to 1 for Sassy CSS (.scss)
+	bool isScssDocument = styler.GetPropertyInt("lexer.css.scss.language") != 0;
+
+	// TODO: implement Less support
+	bool isLessDocument = false;
 
+	// SCSS and Less both support single-line comments
+	typedef enum _CommentModes { eCommentBlock = 0, eCommentLine = 1} CommentMode;
+	CommentMode comment_mode = eCommentBlock;
+	bool hasSingleLineComments = isScssDocument || isLessDocument;
+
+	// must keep track of nesting level in document types that support it (SCSS, Less)
+	bool hasNesting = false;
+	int nestingLevel = 0;
+	if (isScssDocument || isLessDocument) {
+		hasNesting = true;
+		nestingLevel = NestingLevelLookBehind(startPos, styler);
+	}
+
+	// "the loop"
 	for (; sc.More(); sc.Forward()) {
-		if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) {
+		if (sc.state == SCE_CSS_COMMENT && ((comment_mode == eCommentBlock && sc.Match('*', '/')) || (comment_mode == eCommentLine && sc.atLineEnd))) {
 			if (lastStateC == -1) {
 				// backtrack to get last state:
 				// comments are like whitespace, so we must return to the previous state
@@ -94,8 +140,12 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 				if (i == 0)
 					lastStateC = SCE_CSS_DEFAULT;
 			}
-			sc.Forward();
-			sc.ForwardSetState(lastStateC);
+			if (comment_mode == eCommentBlock) {
+				sc.Forward();
+				sc.ForwardSetState(lastStateC);
+			} else /* eCommentLine */ {
+				sc.SetState(lastStateC);
+			}
 		}
 
 		if (sc.state == SCE_CSS_COMMENT)
@@ -125,7 +175,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 			}
 			switch (op) {
 			case '@':
-				if (lastState == SCE_CSS_DEFAULT)
+				if (lastState == SCE_CSS_DEFAULT || hasNesting)
 					sc.SetState(SCE_CSS_DIRECTIVE);
 				break;
 			case '>':
@@ -144,15 +194,33 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 					sc.SetState(SCE_CSS_TAG);
 				break;
 			case '{':
-				if (lastState == SCE_CSS_MEDIA)
+				nestingLevel++;
+				switch (lastState) {
+				case SCE_CSS_MEDIA:
 					sc.SetState(SCE_CSS_DEFAULT);
-				else if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DIRECTIVE)
+					break;
+				case SCE_CSS_TAG:
+				case SCE_CSS_DIRECTIVE:
 					sc.SetState(SCE_CSS_IDENTIFIER);
+					break;
+				}
 				break;
 			case '}':
-				if (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT ||
-					lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_IDENTIFIER3)
-					sc.SetState(SCE_CSS_DEFAULT);
+				if (--nestingLevel < 0)
+					nestingLevel = 0;
+				switch (lastState) {
+				case SCE_CSS_DEFAULT:
+				case SCE_CSS_VALUE:
+				case SCE_CSS_IMPORTANT:
+				case SCE_CSS_IDENTIFIER:
+				case SCE_CSS_IDENTIFIER2:
+				case SCE_CSS_IDENTIFIER3:
+					if (hasNesting)
+						sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT);
+					else
+						sc.SetState(SCE_CSS_DEFAULT);
+					break;
+				}
 				break;
 			case '(':
 				if (lastState == SCE_CSS_PSEUDOCLASS)
@@ -167,14 +235,28 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 					sc.SetState(SCE_CSS_TAG);
 				break;
 			case ':':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID ||
-					lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS ||
-					lastState == SCE_CSS_PSEUDOELEMENT || lastState == SCE_CSS_EXTENDED_PSEUDOELEMENT)
+				switch (lastState) {
+				case SCE_CSS_TAG:
+				case SCE_CSS_DEFAULT:
+				case SCE_CSS_CLASS:
+				case SCE_CSS_ID:
+				case SCE_CSS_PSEUDOCLASS:
+				case SCE_CSS_EXTENDED_PSEUDOCLASS:
+				case SCE_CSS_UNKNOWN_PSEUDOCLASS:
+				case SCE_CSS_PSEUDOELEMENT:
+				case SCE_CSS_EXTENDED_PSEUDOELEMENT:
 					sc.SetState(SCE_CSS_PSEUDOCLASS);
-				else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 ||
-					lastState == SCE_CSS_IDENTIFIER3 || lastState == SCE_CSS_EXTENDED_IDENTIFIER ||
-					lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
+					break;
+				case SCE_CSS_IDENTIFIER:
+				case SCE_CSS_IDENTIFIER2:
+				case SCE_CSS_IDENTIFIER3:
+				case SCE_CSS_EXTENDED_IDENTIFIER:
+				case SCE_CSS_UNKNOWN_IDENTIFIER:
+				case SCE_CSS_VARIABLE:
 					sc.SetState(SCE_CSS_VALUE);
+					lastStateVal = lastState;
+					break;
+				}
 				break;
 			case '.':
 				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID ||
@@ -193,10 +275,40 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 					sc.SetState(SCE_CSS_DEFAULT);
 				break;
 			case ';':
-				if (lastState == SCE_CSS_DIRECTIVE)
-					sc.SetState(SCE_CSS_DEFAULT);
-				else if (lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT)
-					sc.SetState(SCE_CSS_IDENTIFIER);
+				switch (lastState) {
+				case SCE_CSS_DIRECTIVE:
+					if (hasNesting) {
+						sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT);
+					} else {
+						sc.SetState(SCE_CSS_DEFAULT);
+					}
+					break;
+				case SCE_CSS_VALUE:
+				case SCE_CSS_IMPORTANT:
+					// data URLs can have semicolons; simplistically check for wrapping parentheses and move along
+					if (insideParentheses) {
+						sc.SetState(lastState);
+					} else {
+						if (lastStateVal == SCE_CSS_VARIABLE) {
+							sc.SetState(SCE_CSS_DEFAULT);
+						} else {
+							sc.SetState(SCE_CSS_IDENTIFIER);
+						}
+					}
+					break;
+				case SCE_CSS_VARIABLE:
+					if (lastStateVar == SCE_CSS_VALUE) {
+						// data URLs can have semicolons; simplistically check for wrapping parentheses and move along
+						if (insideParentheses) {
+							sc.SetState(SCE_CSS_VALUE);
+						} else {
+							sc.SetState(SCE_CSS_IDENTIFIER);
+						}
+					} else {
+						sc.SetState(SCE_CSS_DEFAULT);
+					}
+					break;
+				}
 				break;
 			case '!':
 				if (lastState == SCE_CSS_VALUE)
@@ -205,14 +317,75 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 			}
 		}
 
-		if (IsAWordChar(sc.ch)) {
-			if (sc.state == SCE_CSS_DEFAULT)
-				sc.SetState(SCE_CSS_TAG);
+		if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) {
+			sc.SetState(SCE_CSS_TAG);
 			continue;
 		}
 
-		if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) {
-			sc.SetState(SCE_CSS_TAG);
+		// check for inside parentheses (whether part of an "operator" or not)
+		if (sc.ch == '(')
+			insideParentheses = true;
+		else if (sc.ch == ')')
+			insideParentheses = false;
+
+		// SCSS special modes
+		if (isScssDocument) {
+			// variable name
+			if (sc.ch == '$') {
+				switch (sc.state) {
+				case SCE_CSS_DEFAULT:
+				case SCE_CSS_VALUE:
+					lastStateVar = sc.state;
+					sc.SetState(SCE_CSS_VARIABLE);
+					continue;
+				}
+			}
+			if (sc.state == SCE_CSS_VARIABLE) {
+				if (IsAWordChar(sc.ch)) {
+					// still looking at the variable name
+					continue;
+				}
+				if (lastStateVar == SCE_CSS_VALUE) {
+					// not looking at the variable name any more, and it was part of a value
+					sc.SetState(SCE_CSS_VALUE);
+				}
+			}
+
+			// nested rule parent selector
+			if (sc.ch == '&') {
+				switch (sc.state) {
+				case SCE_CSS_DEFAULT:
+				case SCE_CSS_IDENTIFIER:
+					sc.SetState(SCE_CSS_TAG);
+					continue;
+				}
+			}
+		}
+
+		// nesting rules that apply to SCSS and Less
+		if (hasNesting) {
+			// check for nested rule selector
+			if (sc.state == SCE_CSS_IDENTIFIER && (IsAWordChar(sc.ch) || sc.ch == ':' || sc.ch == '.' || sc.ch == '#')) {
+				// look ahead to see whether { comes before next ; and }
+				unsigned int endPos = startPos + length;
+				int ch;
+
+				for (unsigned int i = sc.currentPos; i < endPos; i++) {
+					ch = styler.SafeGetCharAt(i);
+					if (ch == ';' || ch == '}')
+						break;
+					if (ch == '{') {
+						sc.SetState(SCE_CSS_DEFAULT);
+						continue;
+					}
+				}
+			}
+
+		}
+
+		if (IsAWordChar(sc.ch)) {
+			if (sc.state == SCE_CSS_DEFAULT)
+				sc.SetState(SCE_CSS_TAG);
 			continue;
 		}
 
@@ -287,6 +460,13 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
 
 		if (sc.Match('/', '*')) {
 			lastStateC = sc.state;
+			comment_mode = eCommentBlock;
+			sc.SetState(SCE_CSS_COMMENT);
+			sc.Forward();
+		} else if (hasSingleLineComments && sc.Match('/', '/') && !insideParentheses) {
+			// note that we've had to treat ([...]// as the start of a URL not a comment, e.g. url(http://example.com), url(//example.com)
+			lastStateC = sc.state;
+			comment_mode = eCommentLine;
 			sc.SetState(SCE_CSS_COMMENT);
 			sc.Forward();
 		} else if ((sc.state == SCE_CSS_VALUE || sc.state == SCE_CSS_ATTRIBUTE)
diff --git a/plugins/scintilla/scintilla/LexCoffeeScript.cxx b/plugins/scintilla/scintilla/LexCoffeeScript.cxx
new file mode 100644
index 0000000..96d5d2d
--- /dev/null
+++ b/plugins/scintilla/scintilla/LexCoffeeScript.cxx
@@ -0,0 +1,571 @@
+// Scintilla source code edit control
+/** @file LexCoffeeScript.cxx
+ ** Lexer for CoffeeScript.
+ **/
+// Copyright 1998-2011 by Neil Hodgson <neilh scintilla org>
+// Based on the Scintilla C++ Lexer
+// Written by Eric Promislow <ericp activestate com> in 2011 for the Komodo IDE
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include "Platform.h"
+#include "ILexer.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#include "WordList.h"
+#include "LexAccessor.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "LexerModule.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static bool IsSpaceEquiv(int state) {
+	return (state <= SCE_C_COMMENTDOC
+	    // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
+	    || state == SCE_C_COMMENTLINEDOC
+	    || state == SCE_C_COMMENTDOCKEYWORD
+	    || state == SCE_C_COMMENTDOCKEYWORDERROR
+	    || state == SCE_COFFEESCRIPT_COMMENTBLOCK
+	    || state == SCE_COFFEESCRIPT_VERBOSE_REGEX
+	    || state == SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT
+	    || state == SCE_C_WORD
+	    || state == SCE_C_REGEX);
+}
+
+// Preconditions: sc.currentPos points to a character after '+' or '-'.
+// The test for pos reaching 0 should be redundant,
+// and is in only for safety measures.
+// Limitation: this code will give the incorrect answer for code like
+// a = b+++/ptn/...
+// Putting a space between the '++' post-inc operator and the '+' binary op
+// fixes this, and is highly recommended for readability anyway.
+static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) {
+	int pos = (int) sc.currentPos;
+	while (--pos > 0) {
+		char ch = styler[pos];
+		if (ch == '+' || ch == '-') {
+			return styler[pos - 1] == ch;
+		}
+	}
+	return false;
+}
+
+static bool followsReturnKeyword(StyleContext &sc, Accessor &styler) {
+    // Don't look at styles, so no need to flush.
+	int pos = (int) sc.currentPos;
+	int currentLine = styler.GetLine(pos);
+	int lineStartPos = styler.LineStart(currentLine);
+	char ch;
+	while (--pos > lineStartPos) {
+		ch = styler.SafeGetCharAt(pos);
+		if (ch != ' ' && ch != '\t') {
+			break;
+		}
+	}
+	const char *retBack = "nruter";
+	const char *s = retBack;
+	while (*s
+	       && pos >= lineStartPos
+	       && styler.SafeGetCharAt(pos) == *s) {
+		s++;
+		pos--;
+	}
+	return !*s;
+}
+
+static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                            Accessor &styler) {
+
+	WordList &keywords = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+	WordList &keywords3 = *keywordlists[2];
+	WordList &keywords4 = *keywordlists[3];
+
+	// property styling.within.preprocessor
+	//	For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default)
+	//	or only from the initial # to the end of the command word(1).
+	bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
+
+	CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
+	CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
+
+	CharacterSet setDoxygen(CharacterSet::setAlpha, "$ \\&<>#{}[]");
+
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
+
+	// property lexer.cpp.allow.dollars
+	//	Set to 0 to disallow the '$' character in identifiers with the cpp lexer.
+	if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
+		setWordStart.Add('$');
+		setWord.Add('$');
+	}
+
+	int chPrevNonWhite = ' ';
+	int visibleChars = 0;
+	bool lastWordWasUUID = false;
+	int styleBeforeDCKeyword = SCE_C_DEFAULT;
+	bool continuationLine = false;
+	bool isIncludePreprocessor = false;
+
+	if (initStyle == SCE_C_PREPROCESSOR) {
+		// Set continuationLine if last character of previous line is '\'
+		int lineCurrent = styler.GetLine(startPos);
+		if (lineCurrent > 0) {
+			int chBack = styler.SafeGetCharAt(startPos-1, 0);
+			int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
+			int lineEndChar = '!';
+			if (chBack2 == '\r' && chBack == '\n') {
+				lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
+			} else if (chBack == '\n' || chBack == '\r') {
+				lineEndChar = chBack2;
+			}
+			continuationLine = lineEndChar == '\\';
+		}
+	}
+
+	// look back to set chPrevNonWhite properly for better regex colouring
+	int endPos = startPos + length;
+	if (startPos > 0) {
+		unsigned int back = startPos;
+		styler.Flush();
+		while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back)))
+			;
+		if (styler.StyleAt(back) == SCE_C_OPERATOR) {
+			chPrevNonWhite = styler.SafeGetCharAt(back);
+		}
+		if (startPos != back) {
+			initStyle = styler.StyleAt(back);
+		}
+		startPos = back;
+	}
+
+	StyleContext sc(startPos, endPos - startPos, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		if (sc.atLineStart) {
+			// Reset states to begining of colourise so no surprises
+			// if different sets of lines lexed.
+			visibleChars = 0;
+			lastWordWasUUID = false;
+			isIncludePreprocessor = false;
+		}
+
+		// Handle line continuation generically.
+		if (sc.ch == '\\') {
+			if (sc.chNext == '\n' || sc.chNext == '\r') {
+				sc.Forward();
+				if (sc.ch == '\r' && sc.chNext == '\n') {
+					sc.Forward();
+				}
+				continuationLine = true;
+				continue;
+			}
+		}
+
+		// Determine if the current state should terminate.
+		switch (sc.state) {
+			case SCE_C_OPERATOR:
+				sc.SetState(SCE_C_DEFAULT);
+				break;
+			case SCE_C_NUMBER:
+				// We accept almost anything because of hex. and number suffixes
+				if (!setWord.Contains(sc.ch)) {
+					sc.SetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_IDENTIFIER:
+				if (!setWord.Contains(sc.ch) || (sc.ch == '.') || (sc.ch == '$')) {
+					char s[1000];
+					sc.GetCurrent(s, sizeof(s));
+					if (keywords.InList(s)) {
+						lastWordWasUUID = strcmp(s, "uuid") == 0;
+						sc.ChangeState(SCE_C_WORD);
+					} else if (keywords2.InList(s)) {
+						sc.ChangeState(SCE_C_WORD2);
+					} else if (keywords4.InList(s)) {
+						sc.ChangeState(SCE_C_GLOBALCLASS);
+					}
+					sc.SetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_PREPROCESSOR:
+				if (sc.atLineStart && !continuationLine) {
+					sc.SetState(SCE_C_DEFAULT);
+				} else if (stylingWithinPreprocessor) {
+					if (IsASpace(sc.ch)) {
+						sc.SetState(SCE_C_DEFAULT);
+					}
+				} else {
+					if (sc.Match('/', '*') || sc.Match('/', '/')) {
+						sc.SetState(SCE_C_DEFAULT);
+					}
+				}
+				break;
+			case SCE_C_COMMENT:
+				if (sc.Match('*', '/')) {
+					sc.Forward();
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_COMMENTDOC:
+				if (sc.Match('*', '/')) {
+					sc.Forward();
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
+					// Verify that we have the conditions to mark a comment-doc-keyword
+					if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) {
+						styleBeforeDCKeyword = SCE_C_COMMENTDOC;
+						sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+					}
+				}
+				break;
+			case SCE_C_COMMENTLINE:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_COMMENTLINEDOC:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_C_DEFAULT);
+				} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
+					// Verify that we have the conditions to mark a comment-doc-keyword
+					if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) {
+						styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC;
+						sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+					}
+				}
+				break;
+			case SCE_C_COMMENTDOCKEYWORD:
+				if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) {
+					sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+					sc.Forward();
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				} else if (!setDoxygen.Contains(sc.ch)) {
+					char s[100];
+					sc.GetCurrent(s, sizeof(s));
+					if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
+						sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+					}
+					sc.SetState(styleBeforeDCKeyword);
+				}
+				break;
+			case SCE_C_STRING:
+				if (isIncludePreprocessor) {
+					if (sc.ch == '>') {
+						sc.ForwardSetState(SCE_C_DEFAULT);
+						isIncludePreprocessor = false;
+					}
+				} else if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\"') {
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_CHARACTER:
+				if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\'') {
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_REGEX:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_C_DEFAULT);
+				} else if (sc.ch == '/') {
+					sc.Forward();
+					while ((sc.ch < 0x80) && islower(sc.ch))
+						sc.Forward();    // gobble regex flags
+					sc.SetState(SCE_C_DEFAULT);
+				} else if (sc.ch == '\\') {
+					// Gobble up the quoted character
+					if (sc.chNext == '\\' || sc.chNext == '/') {
+						sc.Forward();
+					}
+				}
+				break;
+			case SCE_C_STRINGEOL:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_C_VERBATIM:
+				if (sc.ch == '\"') {
+					if (sc.chNext == '\"') {
+						sc.Forward();
+					} else {
+						sc.ForwardSetState(SCE_C_DEFAULT);
+					}
+				}
+				break;
+			case SCE_C_UUID:
+				if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
+					sc.SetState(SCE_C_DEFAULT);
+				}
+				break;
+			case SCE_COFFEESCRIPT_COMMENTBLOCK:
+				if (sc.Match("###")) {
+					sc.ChangeState(SCE_C_COMMENT);
+					sc.Forward();
+					sc.Forward();
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				} else if (sc.ch == '\\') {
+					sc.Forward();
+				}
+				break;
+			case SCE_COFFEESCRIPT_VERBOSE_REGEX:
+				if (sc.Match("///")) {
+					sc.Forward();
+					sc.Forward();
+					sc.ChangeState(SCE_C_REGEX);
+					sc.ForwardSetState(SCE_C_DEFAULT);
+				} else if (sc.Match('#')) {
+					sc.ChangeState(SCE_C_REGEX);
+					sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT);
+				} else if (sc.ch == '\\') {
+					sc.Forward();
+				}
+				break;
+			case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
+				if (sc.atLineStart) {
+					sc.ChangeState(SCE_C_COMMENT);
+					sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
+				}
+				break;
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_C_DEFAULT) {
+			if (sc.Match('@', '\"')) {
+				sc.SetState(SCE_C_VERBATIM);
+				sc.Forward();
+			} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				if (lastWordWasUUID) {
+					sc.SetState(SCE_C_UUID);
+					lastWordWasUUID = false;
+				} else {
+					sc.SetState(SCE_C_NUMBER);
+				}
+			} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@') || (sc.ch == '$')) {
+				if (lastWordWasUUID) {
+					sc.SetState(SCE_C_UUID);
+					lastWordWasUUID = false;
+				} else {
+					sc.SetState(SCE_C_IDENTIFIER);
+				}
+			} else if (sc.Match('/', '*')) {
+				if (sc.Match("/**") || sc.Match("/*!")) {	// Support of Qt/Doxygen doc. style
+					sc.SetState(SCE_C_COMMENTDOC);
+				} else {
+					sc.SetState(SCE_C_COMMENT);
+				}
+				sc.Forward();	// Eat the * so it isn't used for the end of the comment
+			} else if (sc.Match("///")) {
+				sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
+			} else if (sc.ch == '/'
+				   && (setOKBeforeRE.Contains(chPrevNonWhite)
+				       || followsReturnKeyword(sc, styler))
+				   && (!setCouldBePostOp.Contains(chPrevNonWhite)
+				       || !FollowsPostfixOperator(sc, styler))) {
+				sc.SetState(SCE_C_REGEX);	// JavaScript's RegEx
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_C_STRING);
+				isIncludePreprocessor = false;	// ensure that '>' won't end the string
+			} else if (isIncludePreprocessor && sc.ch == '<') {
+				sc.SetState(SCE_C_STRING);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_C_CHARACTER);
+			} else if (sc.ch == '#') {
+                if (sc.Match("###")) {
+                    sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);
+                } else {
+                    sc.SetState(SCE_C_COMMENTLINE);
+                }
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_C_OPERATOR);
+			}
+		}
+
+		if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
+			chPrevNonWhite = sc.ch;
+			visibleChars++;
+		}
+		continuationLine = false;
+	}
+    // Change temporary coffeescript states into standard C ones.
+    switch (sc.state) {
+        case SCE_COFFEESCRIPT_COMMENTBLOCK:
+            sc.ChangeState(SCE_C_COMMENT);
+            break;
+        case SCE_COFFEESCRIPT_VERBOSE_REGEX:
+            sc.ChangeState(SCE_C_REGEX);
+            break;
+        case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
+            sc.ChangeState(SCE_C_COMMENTLINE);
+            break;
+    }
+	sc.Complete();
+}
+
+static bool IsCommentLine(int line, Accessor &styler) {
+	int pos = styler.LineStart(line);
+	int eol_pos = styler.LineStart(line + 1) - 1;
+	for (int i = pos; i < eol_pos; i++) {
+		char ch = styler[i];
+		if (ch == '#')
+			return true;
+        else if (ch == '/'
+                 && i < eol_pos - 1
+                 && styler[i + 1] == '*')
+			return true;
+		else if (ch != ' ' && ch != '\t')
+			return false;
+	}
+	return false;
+}
+
+static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int,
+				WordList *[], Accessor &styler) {
+	// A simplified version of FoldPyDoc
+	const int maxPos = startPos + length;
+	const int maxLines = styler.GetLine(maxPos - 1);             // Requested last line
+	const int docLines = styler.GetLine(styler.Length() - 1);  // Available last line
+
+	// property fold.coffeescript.comment
+	const bool foldComment = styler.GetPropertyInt("fold.coffeescript.comment") != 0;
+
+	const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0;
+
+	// Backtrack to previous non-blank line so we can determine indent level
+	// for any white space lines
+	// and so we can fix any preceding fold level (which is why we go back
+	// at least one line in all cases)
+	int spaceFlags = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
+	while (lineCurrent > 0) {
+		lineCurrent--;
+		indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
+		if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)
+		    && !IsCommentLine(lineCurrent, styler))
+			break;
+	}
+	int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
+
+	// Set up initial loop state
+	int prevComment = 0;
+	if (lineCurrent >= 1)
+		prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
+
+	// Process all characters to end of requested range
+	// or comment that hangs over the end of the range.  Cap processing in all cases
+	// to end of document (in case of comment at end).
+	while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) {
+
+		// Gather info
+		int lev = indentCurrent;
+		int lineNext = lineCurrent + 1;
+		int indentNext = indentCurrent;
+		if (lineNext <= docLines) {
+			// Information about next line is only available if not at end of document
+			indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
+		}
+		const int comment = foldComment && IsCommentLine(lineCurrent, styler);
+		const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
+		                           IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
+		const int comment_continue = (comment && prevComment);
+		if (!comment)
+			indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
+		if (indentNext & SC_FOLDLEVELWHITEFLAG)
+			indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
+
+		if (comment_start) {
+			// Place fold point at start of a block of comments
+			lev |= SC_FOLDLEVELHEADERFLAG;
+		} else if (comment_continue) {
+			// Add level to rest of lines in the block
+			lev = lev + 1;
+		}
+
+		// Skip past any blank lines for next indent level info; we skip also
+		// comments (all comments, not just those starting in column 0)
+		// which effectively folds them into surrounding code rather
+		// than screwing up folding.
+
+		while ((lineNext < docLines) &&
+		        ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
+		         (lineNext <= docLines && IsCommentLine(lineNext, styler)))) {
+
+			lineNext++;
+			indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
+		}
+
+		const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK;
+		const int levelBeforeComments = Platform::Maximum(indentCurrentLevel,levelAfterComments);
+
+		// Now set all the indent levels on the lines we skipped
+		// Do this from end to start.  Once we encounter one line
+		// which is indented more than the line after the end of
+		// the comment-block, use the level of the block before
+
+		int skipLine = lineNext;
+		int skipLevel = levelAfterComments;
+
+		while (--skipLine > lineCurrent) {
+			int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
+
+			if (foldCompact) {
+				if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
+					skipLevel = levelBeforeComments;
+
+				int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
+
+				styler.SetLevel(skipLine, skipLevel | whiteFlag);
+			} else {
+				if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments &&
+					!(skipLineIndent & SC_FOLDLEVELWHITEFLAG) &&
+					!IsCommentLine(skipLine, styler))
+					skipLevel = levelBeforeComments;
+
+				styler.SetLevel(skipLine, skipLevel);
+			}
+		}
+
+		// Set fold header on non-comment line
+		if (!comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
+			if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
+				lev |= SC_FOLDLEVELHEADERFLAG;
+		}
+
+		// Keep track of block comment state of previous line
+		prevComment = comment_start || comment_continue;
+
+		// Set fold level for this line and move to next line
+		styler.SetLevel(lineCurrent, lev);
+		indentCurrent = indentNext;
+		lineCurrent = lineNext;
+	}
+}
+
+static const char *const csWordLists[] = {
+            "Keywords",
+            0,
+};
+
+LexerModule lmCoffeeScript(SCLEX_COFFEESCRIPT, ColouriseCoffeeScriptDoc, "coffeescript", FoldCoffeeScriptDoc, csWordLists);
diff --git a/plugins/scintilla/scintilla/LexD.cxx b/plugins/scintilla/scintilla/LexD.cxx
index 5b8f9e7..eb76be3 100644
--- a/plugins/scintilla/scintilla/LexD.cxx
+++ b/plugins/scintilla/scintilla/LexD.cxx
@@ -14,10 +14,6 @@
 #include <assert.h>
 #include <ctype.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <map>
 
diff --git a/plugins/scintilla/scintilla/LexGen.py b/plugins/scintilla/scintilla/LexGen.py
index 22cdaae..a414365 100755
--- a/plugins/scintilla/scintilla/LexGen.py
+++ b/plugins/scintilla/scintilla/LexGen.py
@@ -268,7 +268,6 @@ def RegenerateAll():
         for k in documents.keys():
             propertyDocuments[k] = documents[k]
     sortListInsensitive(lexerModules)
-    del lexerProperties["fold.comment.python"]
     lexerProperties = list(lexerProperties.keys())
     sortListInsensitive(lexerProperties)
 
@@ -278,8 +277,8 @@ def RegenerateAll():
     sortListInsensitive(documentProperties)
     propertiesHTML = []
     for k in documentProperties:
-        propertiesHTML.append("\t<tr>\n\t<td>%s</td>\n\t<td>%s</td>\n\t</tr>" %
-            (k, propertyDocuments[k]))
+        propertiesHTML.append("\t<tr id='property-%s'>\n\t<td>%s</td>\n\t<td>%s</td>\n\t</tr>" %
+            (k, k, propertyDocuments[k]))
 
     # Find all the SciTE properties files
     otherProps = ["abbrev.properties", "Embedded.properties", "SciTEGlobal.properties", "SciTE.properties"]
diff --git a/plugins/scintilla/scintilla/LexHTML.cxx b/plugins/scintilla/scintilla/LexHTML.cxx
index a207963..d8d4d2e 100644
--- a/plugins/scintilla/scintilla/LexHTML.cxx
+++ b/plugins/scintilla/scintilla/LexHTML.cxx
@@ -261,28 +261,29 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
 static int classifyTagHTML(unsigned int start, unsigned int end,
                            WordList &keywords, Accessor &styler, bool &tagDontFold,
 			   bool caseSensitive, bool isXml, bool allowScripts) {
-	char s[30 + 2];
+	char withSpace[30 + 2] = " ";
+	const char *s = withSpace + 1;
 	// Copy after the '<'
-	unsigned int i = 0;
+	unsigned int i = 1;
 	for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
 		char ch = styler[cPos];
 		if ((ch != '<') && (ch != '/')) {
-			s[i++] = caseSensitive ? ch : static_cast<char>(MakeLowerCase(ch));
+			withSpace[i++] = caseSensitive ? ch : static_cast<char>(MakeLowerCase(ch));
 		}
 	}
 
 	//The following is only a quick hack, to see if this whole thing would work
 	//we first need the tagname with a trailing space...
-	s[i] = ' ';
-	s[i+1] = '\0';
+	withSpace[i] = ' ';
+	withSpace[i+1] = '\0';
 
 	// if the current language is XML, I can fold any tag
 	// if the current language is HTML, I don't want to fold certain tags (input, meta, etc.)
 	//...to find it in the list of no-container-tags
-	tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ", s));
+	tagDontFold = (!isXml) && (NULL != strstr(" area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr ", withSpace));
 
 	//now we can remove the trailing space
-	s[i] = '\0';
+	withSpace[i] = '\0';
 
 	// No keywords -> all are known
 	char chAttr = SCE_H_TAGUNKNOWN;
diff --git a/plugins/scintilla/scintilla/LexMMIXAL.cxx b/plugins/scintilla/scintilla/LexMMIXAL.cxx
index 59bb9fd..43361d4 100644
--- a/plugins/scintilla/scintilla/LexMMIXAL.cxx
+++ b/plugins/scintilla/scintilla/LexMMIXAL.cxx
@@ -38,7 +38,7 @@ inline bool isMMIXALOperator(char ch) {
 	if (isascii(ch) && isalnum(ch))
 		return false;
 	if (ch == '+' || ch == '-' || ch == '|' || ch == '^' ||
-		ch == '*' || ch == '/' || ch == '/' ||
+		ch == '*' || ch == '/' ||
 		ch == '%' || ch == '<' || ch == '>' || ch == '&' ||
 		ch == '~' || ch == '$' ||
 		ch == ',' || ch == '(' || ch == ')' ||
diff --git a/plugins/scintilla/scintilla/LexMPT.cxx b/plugins/scintilla/scintilla/LexMPT.cxx
index c09ac7a..b3eed34 100644
--- a/plugins/scintilla/scintilla/LexMPT.cxx
+++ b/plugins/scintilla/scintilla/LexMPT.cxx
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <string>
 
diff --git a/plugins/scintilla/scintilla/LexOthers.cxx b/plugins/scintilla/scintilla/LexOthers.cxx
index 720d979..5f4eaed 100644
--- a/plugins/scintilla/scintilla/LexOthers.cxx
+++ b/plugins/scintilla/scintilla/LexOthers.cxx
@@ -1015,7 +1015,7 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
 		bool initialTab = (lineBuffer[0] == '\t');
 		bool initialColonPart = false;
 		enum { stInitial,
-			stGccStart, stGccDigit, stGcc,
+			stGccStart, stGccDigit, stGccColumn, stGcc,
 			stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
 			stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
 			stUnrecognized
@@ -1047,12 +1047,18 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
 				state = Is1To9(ch) ? stGccDigit : stUnrecognized;
 			} else if (state == stGccDigit) {	// <filename>:<line>
 				if (ch == ':') {
-					state = stGcc;	// :9.*: is GCC
+					state = stGccColumn;	// :9.*: is GCC
 					startValue = i + 1;
-					break;
 				} else if (!Is0To9(ch)) {
 					state = stUnrecognized;
 				}
+			} else if (state == stGccColumn) {	// <filename>:<line>:<column>
+				if (!Is0To9(ch)) {
+					state = stGcc;
+					if (ch == ':')
+						startValue = i + 1;
+					break;
+				}
 			} else if (state == stMsStart) {	// <filename>(
 				state = Is0To9(ch) ? stMsDigit : stUnrecognized;
 			} else if (state == stMsDigit) {	// <filename>(<line>
diff --git a/plugins/scintilla/scintilla/LexPerl.cxx b/plugins/scintilla/scintilla/LexPerl.cxx
index 8a0f642..87a06d4 100644
--- a/plugins/scintilla/scintilla/LexPerl.cxx
+++ b/plugins/scintilla/scintilla/LexPerl.cxx
@@ -14,10 +14,6 @@
 #include <assert.h>
 #include <ctype.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <map>
 
diff --git a/plugins/scintilla/scintilla/LexRuby.cxx b/plugins/scintilla/scintilla/LexRuby.cxx
index 4545bfa..d21a3df 100644
--- a/plugins/scintilla/scintilla/LexRuby.cxx
+++ b/plugins/scintilla/scintilla/LexRuby.cxx
@@ -788,13 +788,13 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
 				state = SCE_RB_COMMENTLINE;
 			} else if (ch == '=') {
 				// =begin indicates the start of a comment (doc) block
-                if (i == 0 || (isEOLChar(chPrev)
+                if ((i == 0 || isEOLChar(chPrev))
                     && chNext == 'b'
                     && styler.SafeGetCharAt(i + 2) == 'e'
                     && styler.SafeGetCharAt(i + 3) == 'g'
                     && styler.SafeGetCharAt(i + 4) == 'i'
                     && styler.SafeGetCharAt(i + 5) == 'n'
-                    && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6)))) {
+                    && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
                     styler.ColourTo(i - 1, state);
                     state = SCE_RB_POD;
 				} else {
diff --git a/plugins/scintilla/scintilla/LexSQL.cxx b/plugins/scintilla/scintilla/LexSQL.cxx
index 64a896e..3a8ddec 100644
--- a/plugins/scintilla/scintilla/LexSQL.cxx
+++ b/plugins/scintilla/scintilla/LexSQL.cxx
@@ -12,10 +12,6 @@
 #include <assert.h>
 #include <ctype.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <string>
 #include <vector>
 #include <map>
@@ -297,6 +293,20 @@ private:
 		}
 	}
 
+	bool IsCommentLine (int line, LexAccessor &styler) {
+		int pos = styler.LineStart(line);
+		int eol_pos = styler.LineStart(line + 1) - 1;
+		for (int i = pos; i + 1 < eol_pos; i++) {
+			int style = styler.StyleAt(i);
+			// MySQL needs -- comments to be followed by space or control char
+			if (style == SCE_SQL_COMMENTLINE && styler.Match(i, "--"))
+				return true;
+			else if (!IsASpaceOrTab(styler[i]))
+				return false;
+		}
+		return false;
+	}
+
 	OptionsSQL options;
 	OptionSetSQL osSQL;
 	SQLStates sqlStates;
@@ -512,8 +522,14 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
 	int visibleChars = 0;
 	int lineCurrent = styler.GetLine(startPos);
 	int levelCurrent = SC_FOLDLEVELBASE;
+
 	if (lineCurrent > 0) {
-		levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
+		// Backtrack to previous line in case need to fix its fold status for folding block of single-line comments (i.e. '--').
+		lineCurrent -= 1;
+		startPos = styler.LineStart(lineCurrent);
+
+		if (lineCurrent > 0)
+			levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
 	}
 	int levelNext = levelCurrent;
 	char chNext = styler[startPos];
@@ -564,6 +580,13 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
 				}
 			}
 		}
+		// Fold block of single-line comments (i.e. '--').
+		if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler)) {
+			if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler))
+				levelNext++;
+			else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent + 1, styler))
+				levelNext--;
+		}
 		if (style == SCE_SQL_OPERATOR) {
 			if (ch == '(') {
 				if (levelCurrent > levelNext)
diff --git a/plugins/scintilla/scintilla/LexScriptol.cxx b/plugins/scintilla/scintilla/LexScriptol.cxx
index 17184fc..4b91923 100644
--- a/plugins/scintilla/scintilla/LexScriptol.cxx
+++ b/plugins/scintilla/scintilla/LexScriptol.cxx
@@ -368,7 +368,7 @@ static void FoldSolDoc(unsigned int startPos, int length, int initStyle,
 	int state = initStyle & 31;
 	int spaceFlags = 0;
         int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsSolComment);
-        if ((state == SCE_SCRIPTOL_TRIPLE))
+        if (state == SCE_SCRIPTOL_TRIPLE)
              indentCurrent |= SC_FOLDLEVELWHITEFLAG;
 	char chNext = styler[startPos];
 	for (int i = startPos; i < lengthDoc; i++)
diff --git a/plugins/scintilla/scintilla/LexSpice.cxx b/plugins/scintilla/scintilla/LexSpice.cxx
index cb1e658..5fb5dd7 100644
--- a/plugins/scintilla/scintilla/LexSpice.cxx
+++ b/plugins/scintilla/scintilla/LexSpice.cxx
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <string>
 
diff --git a/plugins/scintilla/scintilla/LexTCL.cxx b/plugins/scintilla/scintilla/LexTCL.cxx
index de309f2..f6924e0 100644
--- a/plugins/scintilla/scintilla/LexTCL.cxx
+++ b/plugins/scintilla/scintilla/LexTCL.cxx
@@ -309,6 +309,7 @@ next:
 					break;
 				case '}':
 					sc.SetState(SCE_TCL_OPERATOR);
+					expected = true;
 					--currentLevel;
 					break;
 				case '[':
diff --git a/plugins/scintilla/scintilla/LexTCMD.cxx b/plugins/scintilla/scintilla/LexTCMD.cxx
new file mode 100644
index 0000000..ed747da
--- /dev/null
+++ b/plugins/scintilla/scintilla/LexTCMD.cxx
@@ -0,0 +1,511 @@
+// Scintilla\ source code edit control
+/** @file LexTCMD.cxx
+ ** Lexer for Take Command / TCC batch scripts (.bat, .btm, .cmd).
+ **/
+// Written by Rex Conn (rconn [at] jpsoft [dot] com)
+// based on the CMD lexer
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include "ILexer.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#include "WordList.h"
+#include "LexAccessor.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "LexerModule.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+
+static bool IsAlphabetic(int ch) {
+	return isascii(ch) && isalpha(ch);
+}
+
+static inline bool AtEOL(Accessor &styler, unsigned int i) {
+	return (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
+}
+
+// Tests for BATCH Operators
+static bool IsBOperator(char ch) {
+	return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') || (ch == '|') || (ch == '&') || (ch == '!') || (ch == '?') || (ch == '*') || (ch == '(') || (ch == ')');
+}
+
+// Tests for BATCH Separators
+static bool IsBSeparator(char ch) {
+	return (ch == '\\') || (ch == '.') || (ch == ';') || (ch == ' ') || (ch == '\t') || (ch == '[') || (ch == ']') || (ch == '\"') || (ch == '\'') || (ch == '/');
+}
+
+// Tests for Environment Variable symbol
+static inline bool IsEnvironmentVar(char ch) {
+	return isalpha(ch) || isdigit(ch) || (ch == '_') || (ch == '$');
+}
+
+// Find length of CMD FOR variable with modifier (%~...) or return 0
+static unsigned int GetBatchVarLen( char *wordBuffer )
+{
+	int nLength = 0;
+	if ( wordBuffer[0] == '%' ) {
+		
+		if ( wordBuffer[1] == '~' )
+			nLength = 2;
+		else if (( wordBuffer[1] == '%' ) && ( wordBuffer[2] == '~' ))
+			nLength++;
+		else
+			return 0;
+
+		for ( ; ( wordBuffer[nLength] ); nLength++ ) {
+
+			switch ( toupper(wordBuffer[nLength]) ) {
+			case 'A':
+				// file attributes
+			case 'D':
+				// drive letter only
+			case 'F':
+				// fully qualified path name
+			case 'N':
+				// filename only
+			case 'P':
+				// path only
+			case 'S':
+				// short name
+			case 'T':
+				// date / time of file
+			case 'X':
+				// file extension only
+			case 'Z':
+				// file size
+				break;
+			default:
+				return nLength;
+			}
+		}
+	}
+
+	return nLength;
+}
+
+
+static void ColouriseTCMDLine( char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, WordList *keywordlists[], Accessor &styler)
+{
+	unsigned int offset = 0;	// Line Buffer Offset
+	char wordBuffer[260];		// Word Buffer - large to catch long paths
+	unsigned int wbl;			// Word Buffer Length
+	unsigned int wbo;			// Word Buffer Offset - also Special Keyword Buffer Length
+	WordList &keywords = *keywordlists[0];      // Internal Commands
+//	WordList &keywords2 = *keywordlists[1];     // Aliases (optional)
+	bool isDelayedExpansion = 1;				// !var!
+
+	bool continueProcessing = true;	// Used to toggle Regular Keyword Checking
+	// Special Keywords are those that allow certain characters without whitespace after the command
+	// Examples are: cd. cd\ echo: echo. path=
+	bool inString = false; // Used for processing while ""
+	// Special Keyword Buffer used to determine if the first n characters is a Keyword
+	char sKeywordBuffer[260];	// Special Keyword Buffer
+	bool sKeywordFound;		// Exit Special Keyword for-loop if found
+
+	// Skip leading whitespace
+	while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
+		offset++;
+	}
+	// Colorize Default Text
+	styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
+
+	if ( offset >= lengthLine )
+		return;
+
+	// Check for Fake Label (Comment) or Real Label - return if found
+	if (lineBuffer[offset] == ':') {
+		if (lineBuffer[offset + 1] == ':') {
+			// Colorize Fake Label (Comment) - :: is the same as REM
+			styler.ColourTo(endPos, SCE_TCMD_COMMENT);
+		} else {
+			// Colorize Real Label
+			styler.ColourTo(endPos, SCE_TCMD_LABEL);
+		}
+		return;
+
+	// Check for Comment - return if found
+	} else if (( CompareNCaseInsensitive(lineBuffer+offset, "rem", 3) == 0 ) && (( lineBuffer[offset+3] == 0 ) || ( isspace(lineBuffer[offset+3] )))) {
+			styler.ColourTo(endPos, SCE_TCMD_COMMENT);
+			return;
+
+	// Check for Drive Change (Drive Change is internal command) - return if found
+	} else if ((IsAlphabetic(lineBuffer[offset])) &&
+		(lineBuffer[offset + 1] == ':') &&
+		((isspacechar(lineBuffer[offset + 2])) ||
+		(((lineBuffer[offset + 2] == '\\')) &&
+		(isspacechar(lineBuffer[offset + 3]))))) {
+		// Colorize Regular Keyword
+		styler.ColourTo(endPos, SCE_TCMD_WORD);
+		return;
+	}
+
+	// Check for Hide Command (@ECHO OFF/ON)
+	if (lineBuffer[offset] == '@') {
+		styler.ColourTo(startLine + offset, SCE_TCMD_HIDE);
+		offset++;
+	}
+	// Skip whitespace
+	while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
+		offset++;
+	}
+
+	// Read remainder of line word-at-a-time or remainder-of-word-at-a-time
+	while (offset < lengthLine) {
+		if (offset > startLine) {
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
+		}
+		// Copy word from Line Buffer into Word Buffer
+		wbl = 0;
+		for (; offset < lengthLine && ( wbl < 260 ) && !isspacechar(lineBuffer[offset]); wbl++, offset++) {
+			wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
+		}
+		wordBuffer[wbl] = '\0';
+		wbo = 0;
+
+		// Check for Separator
+		if (IsBSeparator(wordBuffer[0])) {
+
+			// Reset Offset to re-process remainder of word
+			offset -= (wbl - 1);
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
+
+			if (wordBuffer[0] == '"')
+				inString = !inString;
+
+		// Check for Regular expression
+		} else if (( wordBuffer[0] == ':' ) && ( wordBuffer[1] == ':' ) && (continueProcessing)) {
+
+			// Colorize Regular exoressuin
+			styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
+			// No need to Reset Offset
+
+		// Check for Labels in text (... :label)
+		} else if (wordBuffer[0] == ':' && isspacechar(lineBuffer[offset - wbl - 1])) {
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
+			// Colorize Label
+			styler.ColourTo(startLine + offset - 1, SCE_TCMD_CLABEL);
+			// No need to Reset Offset
+		// Check for delayed expansion Variable (!x...!)
+		} else if (isDelayedExpansion && wordBuffer[0] == '!') {
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
+			wbo++;
+			// Search to end of word for second !
+			while ((wbo < wbl) && (wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
+				wbo++;
+			}
+			if (wordBuffer[wbo] == '!') {
+				wbo++;
+				// Colorize Environment Variable
+				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_EXPANSION);
+			} else {
+				wbo = 1;
+				// Colorize Symbol
+				styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_DEFAULT);
+			}
+
+			// Reset Offset to re-process remainder of word
+			offset -= (wbl - wbo);
+
+		// Check for Regular Keyword in list
+		} else if ((keywords.InList(wordBuffer)) &&	(!inString) && (continueProcessing)) {
+
+			// ECHO, PATH, and PROMPT require no further Regular Keyword Checking
+			if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echos") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echoerr") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) ||
+			  (CompareCaseInsensitive(wordBuffer, "path") == 0) ||
+			  (CompareCaseInsensitive(wordBuffer, "prompt") == 0)) {
+				continueProcessing = false;
+			}
+
+			// Colorize Regular keyword
+			styler.ColourTo(startLine + offset - 1, SCE_TCMD_WORD);
+			// No need to Reset Offset
+
+		} else if ((wordBuffer[0] != '%') && (wordBuffer[0] != '!') && (!IsBOperator(wordBuffer[0])) &&	(!inString) && (continueProcessing)) {
+
+			// a few commands accept "illegal" syntax -- cd\, echo., etc.
+			sscanf( wordBuffer, "%[^.<>|&=\\/]", sKeywordBuffer );
+			sKeywordFound = false;
+
+			if ((CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echos") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echoerr") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) || 
+			  (CompareCaseInsensitive(sKeywordBuffer, "cd") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "path") == 0) ||
+			  (CompareCaseInsensitive(sKeywordBuffer, "prompt") == 0)) {
+
+				// no further Regular Keyword Checking
+				continueProcessing = false;
+				sKeywordFound = true;
+				wbo = (unsigned int)strlen( sKeywordBuffer );
+
+				// Colorize Special Keyword as Regular Keyword
+				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_WORD);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - wbo);
+			}
+
+			// Check for Default Text
+			if (!sKeywordFound) {
+				wbo = 0;
+				// Read up to %, Operator or Separator
+				while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!isDelayedExpansion || wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) &&	(!IsBSeparator(wordBuffer[wbo]))) {
+					wbo++;
+				}
+				// Colorize Default Text
+				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_DEFAULT);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - wbo);
+			}
+
+		// Check for Argument  (%n), Environment Variable (%x...%) or Local Variable (%%a)
+		} else if (wordBuffer[0] == '%') {
+			unsigned int varlen;
+			unsigned int n = 1;
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
+			wbo++;
+
+			// check for %[nn] syntax
+			if ( wordBuffer[1] == '[' ) {
+				n++;
+				while ((n < wbl) && (wordBuffer[n] != ']')) {
+					n++;
+				}
+				if ( wordBuffer[n] == ']' )
+					n++;
+				goto ColorizeArg;
+			}
+
+			// Search to end of word for second % or to the first terminator (can be a long path)
+			while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
+				wbo++;
+			}
+
+			// Check for Argument (%n) or (%*)
+			if (((isdigit(wordBuffer[1])) || (wordBuffer[1] == '*')) && (wordBuffer[wbo] != '%')) {
+				while (( wordBuffer[n] ) && ( strchr( "%0123456789*#$", wordBuffer[n] ) != NULL ))
+					n++;
+ColorizeArg:
+				// Colorize Argument
+				styler.ColourTo(startLine + offset - 1 - (wbl - n), SCE_TCMD_IDENTIFIER);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - n);
+
+			// Check for Variable with modifiers (%~...)
+			} else if ((varlen = GetBatchVarLen(wordBuffer)) != 0) {
+
+				// Colorize Variable
+				styler.ColourTo(startLine + offset - 1 - (wbl - varlen), SCE_TCMD_IDENTIFIER);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - varlen);
+
+			// Check for Environment Variable (%x...%)
+			} else if (( wordBuffer[1] ) && ( wordBuffer[1] != '%')) {
+				if ( wordBuffer[wbo] == '%' )
+					wbo++;
+
+				// Colorize Environment Variable
+				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_ENVIRONMENT);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - wbo);
+
+			// Check for Local Variable (%%a)
+			} else if (	(wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] != '%') && (!IsBOperator(wordBuffer[2])) && (!IsBSeparator(wordBuffer[2]))) {
+
+				n = 2;
+				while (( wordBuffer[n] ) && (!IsBOperator(wordBuffer[n])) && (!IsBSeparator(wordBuffer[n])))
+					n++;
+
+				// Colorize Local Variable
+				styler.ColourTo(startLine + offset - 1 - (wbl - n), SCE_TCMD_IDENTIFIER);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - n);
+
+			// Check for %%
+			} else if ((wbl > 1) && (wordBuffer[1] == '%')) {
+
+				// Colorize Symbols
+				styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_TCMD_DEFAULT);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - 2);
+			} else {
+
+				// Colorize Symbol
+				styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_DEFAULT);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - 1);
+			}
+
+		// Check for Operator
+		} else if (IsBOperator(wordBuffer[0])) {
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
+
+			// Check for Pipe, compound, or conditional Operator
+			if ((wordBuffer[0] == '|') || (wordBuffer[0] == '&')) {
+
+				// Colorize Pipe Operator
+				styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_OPERATOR);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - 1);
+				continueProcessing = true;
+
+			// Check for Other Operator
+			} else {
+				// Check for > Operator
+				if ((wordBuffer[0] == '>') || (wordBuffer[0] == '<')) {
+					// Turn Keyword and External Command / Program checking back on
+					continueProcessing = true;
+				}
+				// Colorize Other Operator
+				if (!inString || !(wordBuffer[0] == '(' || wordBuffer[0] == ')'))
+					styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_OPERATOR);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - 1);
+			}
+
+		// Check for Default Text
+		} else {
+			// Read up to %, Operator or Separator
+			while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!isDelayedExpansion || wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) &&	(!IsBSeparator(wordBuffer[wbo]))) {
+				wbo++;
+			}
+			// Colorize Default Text
+			styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_DEFAULT);
+			// Reset Offset to re-process remainder of word
+			offset -= (wbl - wbo);
+		}
+
+		// Skip whitespace - nothing happens if Offset was Reset
+		while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
+			offset++;
+		}
+	}
+	// Colorize Default Text for remainder of line - currently not lexed
+	styler.ColourTo(endPos, SCE_TCMD_DEFAULT);
+}
+
+static void ColouriseTCMDDoc( unsigned int startPos, int length, int /*initStyle*/, WordList *keywordlists[], Accessor &styler )
+{
+	char lineBuffer[16384];
+
+	styler.StartAt(startPos);
+	styler.StartSegment(startPos);
+	unsigned int linePos = 0;
+	unsigned int startLine = startPos;
+	for (unsigned int i = startPos; i < startPos + length; i++) {
+		lineBuffer[linePos++] = styler[i];
+		if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+			// End of line (or of line buffer) met, colourise it
+			lineBuffer[linePos] = '\0';
+			ColouriseTCMDLine(lineBuffer, linePos, startLine, i, keywordlists, styler);
+			linePos = 0;
+			startLine = i + 1;
+		}
+	}
+	if (linePos > 0) {	// Last line does not have ending characters
+		lineBuffer[linePos] = '\0';
+		ColouriseTCMDLine(lineBuffer, linePos, startLine, startPos + length - 1, keywordlists, styler);
+	}
+}
+
+// Convert string to upper case
+static void StrUpr(char *s) {
+	while (*s) {
+		*s = MakeUpperCase(*s);
+		s++;
+	}
+}
+
+// Folding support (for DO, IFF, SWITCH, TEXT, and command groups)
+static void FoldTCMDDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
+{
+	int line = styler.GetLine(startPos);
+	int level = styler.LevelAt(line);
+	int levelIndent = 0;
+	unsigned int endPos = startPos + length;
+	char s[16];
+
+    char chPrev = styler.SafeGetCharAt(startPos - 1);
+
+	// Scan for ( and )
+	for (unsigned int i = startPos; i < endPos; i++) {
+
+		int c = styler.SafeGetCharAt(i, '\n');
+		int style = styler.StyleAt(i);
+        bool bLineStart = ((chPrev == '\r') || (chPrev == '\n')) || i == 0;
+
+		if (style == SCE_TCMD_OPERATOR) {
+			// CheckFoldPoint
+			if (c == '(') {
+				levelIndent += 1;
+			} else if (c == ')') {
+				levelIndent -= 1;
+			}
+		}
+
+        if (( bLineStart ) && ( style == SCE_TCMD_WORD )) {
+            for (unsigned int j = 0; j < 10; j++) {
+                if (!iswordchar(styler[i + j])) {
+                    break;
+                }
+                s[j] = styler[i + j];
+                s[j + 1] = '\0';
+            }
+
+			StrUpr( s );
+            if ((strcmp(s, "DO") == 0) || (strcmp(s, "IFF") == 0) || (strcmp(s, "SWITCH") == 0) || (strcmp(s, "TEXT") == 0)) {
+                levelIndent++;
+            } else if ((strcmp(s, "ENDDO") == 0) || (strcmp(s, "ENDIFF") == 0) || (strcmp(s, "ENDSWITCH") == 0) || (strcmp(s, "ENDTEXT") == 0)) {
+                levelIndent--;
+            }
+        }
+
+		if (c == '\n') { // line end
+				if (levelIndent > 0) {
+						level |= SC_FOLDLEVELHEADERFLAG;
+				}
+				if (level != styler.LevelAt(line))
+						styler.SetLevel(line, level);
+				level += levelIndent;
+				if ((level & SC_FOLDLEVELNUMBERMASK) < SC_FOLDLEVELBASE)
+						level = SC_FOLDLEVELBASE;
+				line++;
+				// reset state
+				levelIndent = 0;
+				level &= ~SC_FOLDLEVELHEADERFLAG;
+				level &= ~SC_FOLDLEVELWHITEFLAG;
+		}
+
+		chPrev = c;
+	}
+}
+
+static const char *const tcmdWordListDesc[] = {
+	"Internal Commands",
+	"Aliases",
+	0
+};
+
+LexerModule lmTCMD(SCLEX_TCMD, ColouriseTCMDDoc, "tcmd", FoldTCMDDoc, tcmdWordListDesc);
diff --git a/plugins/scintilla/scintilla/LineMarker.cxx b/plugins/scintilla/scintilla/LineMarker.cxx
index b2b7cea..a14e4e4 100644
--- a/plugins/scintilla/scintilla/LineMarker.cxx
+++ b/plugins/scintilla/scintilla/LineMarker.cxx
@@ -20,15 +20,6 @@
 using namespace Scintilla;
 #endif
 
-void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
-	pal.WantFind(fore, want);
-	pal.WantFind(back, want);
-	pal.WantFind(backSelected, want);
-	if (pxpm) {
-		pxpm->RefreshColourPalette(pal, want);
-	}
-}
-
 void LineMarker::SetXPM(const char *textForm) {
 	delete pxpm;
 	pxpm = new XPM(textForm);
@@ -47,7 +38,7 @@ void LineMarker::SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRG
 	markType = SC_MARK_RGBAIMAGE;
 }
 
-static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
+static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
 	PRectangle rc;
 	rc.left = centreX - armSize;
 	rc.top = centreY - armSize;
@@ -56,7 +47,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col
 	surface->RectangleDraw(rc, back, fore);
 }
 
-static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
+static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
 	PRectangle rcCircle;
 	rcCircle.left = centreX - armSize;
 	rcCircle.top = centreY - armSize;
@@ -65,22 +56,22 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize,
 	surface->Ellipse(rcCircle, back, fore);
 }
 
-static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
+static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
 	PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
 	surface->FillRectangle(rcV, fore);
 	PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
 	surface->FillRectangle(rcH, fore);
 }
 
-static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
+static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
 	PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
 	surface->FillRectangle(rcH, fore);
 }
 
 void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold) {
-	ColourPair head = back;
-	ColourPair body = back;
-	ColourPair tail = back;
+	ColourDesired head = back;
+	ColourDesired body = back;
+	ColourDesired tail = back;
 
 	switch (tFold) {
 	case LineMarker::head :
@@ -130,14 +121,14 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 		PRectangle rcRounded = rc;
 		rcRounded.left = rc.left + 1;
 		rcRounded.right = rc.right - 1;
-		surface->RoundedRectangle(rcRounded, fore.allocated, back.allocated);
+		surface->RoundedRectangle(rcRounded, fore, back);
 	} else if (markType == SC_MARK_CIRCLE) {
 		PRectangle rcCircle;
 		rcCircle.left = centreX - dimOn2;
 		rcCircle.top = centreY - dimOn2;
 		rcCircle.right = centreX + dimOn2;
 		rcCircle.bottom = centreY + dimOn2;
-		surface->Ellipse(rcCircle, fore.allocated, back.allocated);
+		surface->Ellipse(rcCircle, fore, back);
 	} else if (markType == SC_MARK_ARROW) {
 		Point pts[] = {
     		Point(centreX - dimOn4, centreY - dimOn2),
@@ -145,7 +136,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
     		Point(centreX + dimOn2 - dimOn4, centreY),
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 		fore.allocated, back.allocated);
+                 		fore, back);
 
 	} else if (markType == SC_MARK_ARROWDOWN) {
 		Point pts[] = {
@@ -154,7 +145,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
     		Point(centreX, centreY + dimOn2 - dimOn4),
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 		fore.allocated, back.allocated);
+                 		fore, back);
 
 	} else if (markType == SC_MARK_PLUS) {
 		Point pts[] = {
@@ -172,7 +163,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
     		Point(centreX - armSize, centreY + 1),
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 		fore.allocated, back.allocated);
+                 		fore, back);
 
 	} else if (markType == SC_MARK_MINUS) {
 		Point pts[] = {
@@ -182,7 +173,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
     		Point(centreX - armSize, centreY + 1),
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-                 		fore.allocated, back.allocated);
+                 		fore, back);
 
 	} else if (markType == SC_MARK_SMALLRECT) {
 		PRectangle rcSmall;
@@ -190,76 +181,76 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 		rcSmall.top = rc.top + 2;
 		rcSmall.right = rc.right - 1;
 		rcSmall.bottom = rc.bottom - 2;
-		surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
+		surface->RectangleDraw(rcSmall, fore, back);
 
 	} else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND ||
 		markType == SC_MARK_UNDERLINE || markType == SC_MARK_AVAILABLE) {
 		// An invisible marker so don't draw anything
 
 	} else if (markType == SC_MARK_VLINE) {
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, rcWhole.bottom);
 
 	} else if (markType == SC_MARK_LCORNER) {
-		surface->PenColour(tail.allocated);
+		surface->PenColour(tail);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, rc.top + dimOn2);
 		surface->LineTo(rc.right - 2, rc.top + dimOn2);
 
 	} else if (markType == SC_MARK_TCORNER) {
-		surface->PenColour(tail.allocated);
+		surface->PenColour(tail);
 		surface->MoveTo(centreX, rc.top + dimOn2);
 		surface->LineTo(rc.right - 2, rc.top + dimOn2);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, rc.top + dimOn2 + 1);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->LineTo(centreX, rcWhole.bottom);
 
 	} else if (markType == SC_MARK_LCORNERCURVE) {
-		surface->PenColour(tail.allocated);
+		surface->PenColour(tail);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, rc.top + dimOn2-3);
 		surface->LineTo(centreX+3, rc.top + dimOn2);
 		surface->LineTo(rc.right - 1, rc.top + dimOn2);
 
 	} else if (markType == SC_MARK_TCORNERCURVE) {
-		surface->PenColour(tail.allocated);
+		surface->PenColour(tail);
 		surface->MoveTo(centreX, rc.top + dimOn2-3);
 		surface->LineTo(centreX+3, rc.top + dimOn2);
 		surface->LineTo(rc.right - 1, rc.top + dimOn2);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, rc.top + dimOn2-2);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->LineTo(centreX, rcWhole.bottom);
 
 	} else if (markType == SC_MARK_BOXPLUS) {
-		DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawBox(surface, centreX, centreY, blobSize, fore, head);
+		DrawPlus(surface, centreX, centreY, blobSize, tail);
 
 	} else if (markType == SC_MARK_BOXPLUSCONNECTED) {
 		if (tFold == LineMarker::headWithTail)
-			surface->PenColour(tail.allocated);
+			surface->PenColour(tail);
 		else
-			surface->PenColour(body.allocated);
+			surface->PenColour(body);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, centreY - blobSize);
 
-		DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawBox(surface, centreX, centreY, blobSize, fore, head);
+		DrawPlus(surface, centreX, centreY, blobSize, tail);
 
 		if (tFold == LineMarker::body) {
-			surface->PenColour(tail.allocated);
+			surface->PenColour(tail);
 			surface->MoveTo(centreX + 1, centreY + blobSize);
 			surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
 
@@ -270,27 +261,27 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 			surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
 		}
 	} else if (markType == SC_MARK_BOXMINUS) {
-		DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawBox(surface, centreX, centreY, blobSize, fore, head);
+		DrawMinus(surface, centreX, centreY, blobSize, tail);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
 	} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
-		DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawBox(surface, centreX, centreY, blobSize, fore, head);
+		DrawMinus(surface, centreX, centreY, blobSize, tail);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, centreY - blobSize);
 
 		if (tFold == LineMarker::body) {
-			surface->PenColour(tail.allocated);
+			surface->PenColour(tail);
 			surface->MoveTo(centreX + 1, centreY + blobSize);
 			surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
 
@@ -301,41 +292,41 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 			surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
 		}
 	} else if (markType == SC_MARK_CIRCLEPLUS) {
-		DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+		DrawPlus(surface, centreX, centreY, blobSize, tail);
 
 	} else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) {
 		if (tFold == LineMarker::headWithTail)
-			surface->PenColour(tail.allocated);
+			surface->PenColour(tail);
 		else
-			surface->PenColour(body.allocated);
+			surface->PenColour(body);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, centreY - blobSize);
 
-		DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+		DrawPlus(surface, centreX, centreY, blobSize, tail);
 
 	} else if (markType == SC_MARK_CIRCLEMINUS) {
-		DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+		DrawMinus(surface, centreX, centreY, blobSize, tail);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
 	} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
-		DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
-		DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+		DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+		DrawMinus(surface, centreX, centreY, blobSize, tail);
 
-		surface->PenColour(head.allocated);
+		surface->PenColour(head);
 		surface->MoveTo(centreX, centreY + blobSize);
 		surface->LineTo(centreX, rcWhole.bottom);
 
-		surface->PenColour(body.allocated);
+		surface->PenColour(body);
 		surface->MoveTo(centreX, rcWhole.top);
 		surface->LineTo(centreX, centreY - blobSize);
 
@@ -346,17 +337,17 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 		rc.left += (rc.Width() - width) / 2;
 		rc.right = rc.left + width;
 		surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2,
-			character, 1, fore.allocated, back.allocated);
+			character, 1, fore, back);
 
 	} else if (markType == SC_MARK_DOTDOTDOT) {
 		int right = centreX - 6;
 		for (int b=0; b<3; b++) {
 			PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2);
-			surface->FillRectangle(rcBlob, fore.allocated);
+			surface->FillRectangle(rcBlob, fore);
 			right += 5;
 		}
 	} else if (markType == SC_MARK_ARROWS) {
-		surface->PenColour(fore.allocated);
+		surface->PenColour(fore);
 		int right = centreX - 2;
 		for (int b=0; b<3; b++) {
 			surface->MoveTo(right - 4, centreY - 4);
@@ -376,12 +367,12 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
 			Point(centreX, centreY + dimOn2),
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
-				fore.allocated, back.allocated);
+				fore, back);
 	} else if (markType == SC_MARK_LEFTRECT) {
 		PRectangle rcLeft = rcWhole;
 		rcLeft.right = rcLeft.left + 4;
-		surface->FillRectangle(rcLeft, back.allocated);
+		surface->FillRectangle(rcLeft, back);
 	} else { // SC_MARK_FULLRECT
-		surface->FillRectangle(rcWhole, back.allocated);
+		surface->FillRectangle(rcWhole, back);
 	}
 }
diff --git a/plugins/scintilla/scintilla/LineMarker.h b/plugins/scintilla/scintilla/LineMarker.h
index 6477a1f..ccf4104 100644
--- a/plugins/scintilla/scintilla/LineMarker.h
+++ b/plugins/scintilla/scintilla/LineMarker.h
@@ -20,9 +20,9 @@ public:
 	enum typeOfFold { undefined, head, body, tail, headWithTail };
 
 	int markType;
-	ColourPair fore;
-	ColourPair back;
-	ColourPair backSelected;
+	ColourDesired fore;
+	ColourDesired back;
+	ColourDesired backSelected;
 	int alpha;
 	XPM *pxpm;
 	RGBAImage *image;
@@ -62,7 +62,6 @@ public:
 		image = NULL;
 		return *this;
 	}
-	void RefreshColourPalette(Palette &pal, bool want);
 	void SetXPM(const char *textForm);
 	void SetXPM(const char *const *linesForm);
 	void SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage);
diff --git a/plugins/scintilla/scintilla/PerLine.cxx b/plugins/scintilla/scintilla/PerLine.cxx
index 7d961a8..7e716cc 100644
--- a/plugins/scintilla/scintilla/PerLine.cxx
+++ b/plugins/scintilla/scintilla/PerLine.cxx
@@ -182,6 +182,19 @@ int LineMarkers::MarkValue(int line) {
 		return 0;
 }
 
+int LineMarkers::MarkerNext(int lineStart, int mask) const {
+	if (lineStart < 0)
+		lineStart = 0;
+	int length = markers.Length();
+	for (int iLine = lineStart; iLine < length; iLine++) {
+		MarkerHandleSet *onLine = markers[iLine];
+		if (onLine && ((onLine->MarkValue() & mask) != 0))
+		//if ((pdoc->GetMark(iLine) & lParam) != 0)
+			return iLine;
+	}
+	return -1;
+}
+
 int LineMarkers::AddMark(int line, int markerNum, int lines) {
 	handleCurrent++;
 	if (!markers.Length()) {
diff --git a/plugins/scintilla/scintilla/PerLine.h b/plugins/scintilla/scintilla/PerLine.h
index df47286..b43c52b 100644
--- a/plugins/scintilla/scintilla/PerLine.h
+++ b/plugins/scintilla/scintilla/PerLine.h
@@ -54,6 +54,7 @@ public:
 	virtual void RemoveLine(int line);
 
 	int MarkValue(int line);
+	int MarkerNext(int lineStart, int mask) const;
 	int AddMark(int line, int marker, int lines);
 	void MergeMarkers(int pos);
 	bool DeleteMark(int line, int markerNum, bool all);
diff --git a/plugins/scintilla/scintilla/PlatGTK.cxx b/plugins/scintilla/scintilla/PlatGTK.cxx
index bbf4126..b7ce385 100644
--- a/plugins/scintilla/scintilla/PlatGTK.cxx
+++ b/plugins/scintilla/scintilla/PlatGTK.cxx
@@ -31,9 +31,6 @@
    to be used to get the glib libraries for linking, otherwise
    g_thread_init will fail */
 #define USE_LOCK defined(G_THREADS_ENABLED) && !defined(G_THREADS_IMPL_NONE)
-/* Use fast way of getting char data on win32 to work around problems
-   with gdk_string_extents. */
-#define FAST_WAY
 
 #include "Converter.h"
 
@@ -43,9 +40,16 @@
 #define IS_WIDGET_FOCUSSED(w) (GTK_WIDGET_HAS_FOCUS(w))
 #endif
 
-#define USE_CAIRO 1
+// The Pango version guard for pango_units_from_double and pango_units_to_double 
+// is more complex than simply implementing these here.
 
-#ifdef USE_CAIRO
+static int pangoUnitsFromDouble(double d) {
+	return static_cast<int>(d * PANGO_SCALE + 0.5);
+}
+
+static double doubleFromPangoUnits(int pu) {
+	return static_cast<double>(pu) / PANGO_SCALE;
+}
 
 static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) {
 #if GTK_CHECK_VERSION(2,22,0)
@@ -65,8 +69,6 @@ static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t
 #endif
 }
 
-#endif
-
 static GdkWindow *WindowFromWidget(GtkWidget *w) {
 #if GTK_CHECK_VERSION(3,0,0)
 	return gtk_widget_get_window(w);
@@ -75,10 +77,6 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) {
 #endif
 }
 
-#ifdef USE_CAIRO
-#define DISABLE_GDK_FONT 1
-#endif
-
 #ifdef _MSC_VER
 // Ignore unreferenced local functions in GTK+ headers
 #pragma warning(disable: 4505)
@@ -92,7 +90,7 @@ enum encodingType { singleByte, UTF8, dbcs};
 
 struct LOGFONT {
 	int size;
-	bool bold;
+	int weight;
 	bool italic;
 	int characterSet;
 	char faceName[300];
@@ -143,45 +141,23 @@ static void FontMutexUnlock() {
 // On GTK+ 1.x holds a GdkFont* but on GTK+ 2.x can hold a GdkFont* or a
 // PangoFontDescription*.
 class FontHandle {
-	int width[128];
+	XYPOSITION width[128];
 	encodingType et;
 public:
 	int ascent;
-#ifndef DISABLE_GDK_FONT
-	GdkFont *pfont;
-#endif
 	PangoFontDescription *pfd;
 	int characterSet;
-#ifdef DISABLE_GDK_FONT
 	FontHandle() : et(singleByte), ascent(0), pfd(0), characterSet(-1) {
 		ResetWidths(et);
 	}
-#else
-	FontHandle(GdkFont *pfont_=0) {
-		et = singleByte;
-		ascent = 0;
-		pfont = pfont_;
-		pfd = 0;
-		characterSet = -1;
-		ResetWidths(et);
-	}
-#endif
 	FontHandle(PangoFontDescription *pfd_, int characterSet_) {
 		et = singleByte;
 		ascent = 0;
-#ifndef DISABLE_GDK_FONT
-		pfont = 0;
-#endif
 		pfd = pfd_;
 		characterSet = characterSet_;
 		ResetWidths(et);
 	}
 	~FontHandle() {
-#ifndef DISABLE_GDK_FONT
-		if (pfont)
-			gdk_font_unref(pfont);
-		pfont = 0;
-#endif
 		if (pfd)
 			pango_font_description_free(pfd);
 		pfd = 0;
@@ -192,8 +168,8 @@ public:
 			width[i] = 0;
 		}
 	}
-	int CharWidth(unsigned char ch, encodingType et_) {
-		int w = 0;
+	XYPOSITION CharWidth(unsigned char ch, encodingType et_) {
+		XYPOSITION w = 0;
 		FontMutexLock();
 		if ((ch <= 127) && (et == et_)) {
 			w = width[ch];
@@ -201,7 +177,7 @@ public:
 		FontMutexUnlock();
 		return w;
 	}
-	void SetCharWidth(unsigned char ch, int w, encodingType et_) {
+	void SetCharWidth(unsigned char ch, XYPOSITION w, encodingType et_) {
 		if (ch <= 127) {
 			FontMutexLock();
 			if (et != et_) {
@@ -224,229 +200,16 @@ static GtkWidget *PWidget(WindowID wid) {
 	return reinterpret_cast<GtkWidget *>(wid);
 }
 
-#if !GTK_CHECK_VERSION(3,0,0)
-static GtkWidget *PWidget(Window &w) {
-	return PWidget(w.GetID());
-}
-#endif
-
 Point Point::FromLong(long lpoint) {
 	return Point(
 	           Platform::LowShortFromLong(lpoint),
 	           Platform::HighShortFromLong(lpoint));
 }
 
-Palette::Palette() {
-	used = 0;
-	allowRealization = false;
-	allocatedPalette = 0;
-	allocatedLen = 0;
-	size = 100;
-	entries = new ColourPair[size];
-}
-
-Palette::~Palette() {
-	Release();
-	delete []entries;
-	entries = 0;
-}
-
-void Palette::Release() {
-	used = 0;
-	delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
-	allocatedPalette = 0;
-	allocatedLen = 0;
-	delete []entries;
-	size = 100;
-	entries = new ColourPair[size];
-}
-
-// This method either adds a colour to the list of wanted colours (want==true)
-// or retrieves the allocated colour back to the ColourPair.
-// This is one method to make it easier to keep the code for wanting and retrieving in sync.
-void Palette::WantFind(ColourPair &cp, bool want) {
-	if (want) {
-		for (int i=0; i < used; i++) {
-			if (entries[i].desired == cp.desired)
-				return;
-		}
-
-		if (used >= size) {
-			int sizeNew = size * 2;
-			ColourPair *entriesNew = new ColourPair[sizeNew];
-			for (int j=0; j<size; j++) {
-				entriesNew[j] = entries[j];
-			}
-			delete []entries;
-			entries = entriesNew;
-			size = sizeNew;
-		}
-
-		entries[used].desired = cp.desired;
-		entries[used].allocated.Set(cp.desired.AsLong());
-		used++;
-	} else {
-		for (int i=0; i < used; i++) {
-			if (entries[i].desired == cp.desired) {
-				cp.allocated = entries[i].allocated;
-				return;
-			}
-		}
-		cp.allocated.Set(cp.desired.AsLong());
-	}
-}
-
-void Palette::Allocate(Window &w) {
-#if !GTK_CHECK_VERSION(3,0,0)
-	// Disable palette on GTK+ 3.
-	if (allocatedPalette) {
-		gdk_colormap_free_colors(gtk_widget_get_colormap(PWidget(w)),
-		                         reinterpret_cast<GdkColor *>(allocatedPalette),
-		                         allocatedLen);
-		delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
-		allocatedPalette = 0;
-		allocatedLen = 0;
-	}
-	GdkColor *paletteNew = new GdkColor[used];
-	allocatedPalette = paletteNew;
-	gboolean *successPalette = new gboolean[used];
-	if (paletteNew) {
-		allocatedLen = used;
-		int iPal = 0;
-		for (iPal = 0; iPal < used; iPal++) {
-			paletteNew[iPal].red = entries[iPal].desired.GetRed() * (65535 / 255);
-			paletteNew[iPal].green = entries[iPal].desired.GetGreen() * (65535 / 255);
-			paletteNew[iPal].blue = entries[iPal].desired.GetBlue() * (65535 / 255);
-			paletteNew[iPal].pixel = entries[iPal].desired.AsLong();
-		}
-#ifndef USE_CAIRO
-		gdk_colormap_alloc_colors(gtk_widget_get_colormap(PWidget(w)),
-		                          paletteNew, allocatedLen, FALSE, TRUE,
-		                          successPalette);
-#endif
-		for (iPal = 0; iPal < used; iPal++) {
-			entries[iPal].allocated.Set(paletteNew[iPal].pixel);
-		}
-	}
-	delete []successPalette;
-#endif
-}
-
-#ifndef DISABLE_GDK_FONT
-
-static const char *CharacterSetName(int characterSet) {
-	switch (characterSet) {
-	case SC_CHARSET_ANSI:
-		return "iso8859-*";
-	case SC_CHARSET_DEFAULT:
-		return "iso8859-*";
-	case SC_CHARSET_BALTIC:
-		return "iso8859-13";
-	case SC_CHARSET_CHINESEBIG5:
-		return "*-*";
-	case SC_CHARSET_EASTEUROPE:
-		return "*-2";
-	case SC_CHARSET_GB2312:
-		return "gb2312.1980-*";
-	case SC_CHARSET_GREEK:
-		return "*-7";
-	case SC_CHARSET_HANGUL:
-		return "ksc5601.1987-*";
-	case SC_CHARSET_MAC:
-		return "*-*";
-	case SC_CHARSET_OEM:
-		return "*-*";
-	case SC_CHARSET_RUSSIAN:
-		return "*-r";
-	case SC_CHARSET_CYRILLIC:
-		return "*-cp1251";
-	case SC_CHARSET_SHIFTJIS:
-		return "jisx0208.1983-*";
-	case SC_CHARSET_SYMBOL:
-		return "*-*";
-	case SC_CHARSET_TURKISH:
-		return "*-9";
-	case SC_CHARSET_JOHAB:
-		return "*-*";
-	case SC_CHARSET_HEBREW:
-		return "*-8";
-	case SC_CHARSET_ARABIC:
-		return "*-6";
-	case SC_CHARSET_VIETNAMESE:
-		return "*-*";
-	case SC_CHARSET_THAI:
-		return "iso8859-11";
-	case SC_CHARSET_8859_15:
-		return "iso8859-15";
-	default:
-		return "*-*";
-	}
-}
-
-static bool IsDBCSCharacterSet(int characterSet) {
-	switch (characterSet) {
-	case SC_CHARSET_GB2312:
-	case SC_CHARSET_HANGUL:
-	case SC_CHARSET_SHIFTJIS:
-	case SC_CHARSET_CHINESEBIG5:
-		return true;
-	default:
-		return false;
-	}
-}
-
-static void GenerateFontSpecStrings(const char *fontName, int characterSet,
-                                    char *foundary, int foundary_len,
-                                    char *faceName, int faceName_len,
-                                    char *charset, int charset_len) {
-	// supported font strings include:
-	// foundary-fontface-isoxxx-x
-	// fontface-isoxxx-x
-	// foundary-fontface
-	// fontface
-	if (strchr(fontName, '-')) {
-		char tmp[300];
-		char *d1 = NULL, *d2 = NULL, *d3 = NULL;
-		strncpy(tmp, fontName, sizeof(tmp) - 1);
-		tmp[sizeof(tmp) - 1] = '\0';
-		d1 = strchr(tmp, '-');
-		// we know the first dash exists
-		d2 = strchr(d1 + 1, '-');
-		if (d2)
-			d3 = strchr(d2 + 1, '-');
-		if (d3 && d2) {
-			// foundary-fontface-isoxxx-x
-			*d2 = '\0';
-			foundary[0] = '-';
-			foundary[1] = '\0';
-			strncpy(faceName, tmp, foundary_len - 1);
-			strncpy(charset, d2 + 1, charset_len - 1);
-		} else if (d2) {
-			// fontface-isoxxx-x
-			*d1 = '\0';
-			strcpy(foundary, "-*-");
-			strncpy(faceName, tmp, faceName_len - 1);
-			strncpy(charset, d1 + 1, charset_len - 1);
-		} else {
-			// foundary-fontface
-			foundary[0] = '-';
-			foundary[1] = '\0';
-			strncpy(faceName, tmp, faceName_len - 1);
-			strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
-		}
-	} else {
-		strncpy(foundary, "-*-", foundary_len);
-		strncpy(faceName, fontName, faceName_len - 1);
-		strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
-	}
-}
-
-#endif
-
-static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, bool bold, bool italic) {
+static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, float size, int weight, bool italic) {
 	memset(&lf, 0, sizeof(lf));
 	lf.size = size;
-	lf.bold = bold;
+	lf.weight = weight;
 	lf.italic = italic;
 	lf.characterSet = characterSet;
 	strncpy(lf.faceName, faceName, sizeof(lf.faceName) - 1);
@@ -457,13 +220,13 @@ static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int
  * If one font is the same as another, its hash will be the same, but if the hash is the
  * same then they may still be different.
  */
-static int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic) {
+static int HashFont(const FontParameters &fp) {
 	return
-	    size ^
-	    (characterSet << 10) ^
-	    (bold ? 0x10000000 : 0) ^
-	    (italic ? 0x20000000 : 0) ^
-	    faceName[0];
+	    static_cast<int>(fp.size+0.5) ^
+	    (fp.characterSet << 10) ^
+	    ((fp.weight / 100) << 12) ^
+	    (fp.italic ? 0x20000000 : 0) ^
+	    fp.faceName[0];
 }
 
 class FontCached : Font {
@@ -471,35 +234,34 @@ class FontCached : Font {
 	int usage;
 	LOGFONT lf;
 	int hash;
-	FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
+	FontCached(const FontParameters &fp);
 	~FontCached() {}
-	bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
+	bool SameAs(const FontParameters &fp);
 	virtual void Release();
-	static FontID CreateNewFont(const char *fontName, int characterSet,
-	                            int size, bool bold, bool italic);
+	static FontID CreateNewFont(const FontParameters &fp);
 	static FontCached *first;
 public:
-	static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
+	static FontID FindOrCreate(const FontParameters &fp);
 	static void ReleaseId(FontID fid_);
 };
 
 FontCached *FontCached::first = 0;
 
-FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) :
+FontCached::FontCached(const FontParameters &fp) :
 next(0), usage(0), hash(0) {
-	::SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_);
-	hash = HashFont(faceName_, characterSet_, size_, bold_, italic_);
-	fid = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_);
+	::SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic);
+	hash = HashFont(fp);
+	fid = CreateNewFont(fp);
 	usage = 1;
 }
 
-bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) {
+bool FontCached::SameAs(const FontParameters &fp) {
 	return
-	    lf.size == size_ &&
-	    lf.bold == bold_ &&
-	    lf.italic == italic_ &&
-	    lf.characterSet == characterSet_ &&
-	    0 == strcmp(lf.faceName, faceName_);
+	    lf.size == fp.size &&
+	    lf.weight == fp.weight &&
+	    lf.italic == fp.italic &&
+	    lf.characterSet == fp.characterSet &&
+	    0 == strcmp(lf.faceName, fp.faceName);
 }
 
 void FontCached::Release() {
@@ -508,19 +270,19 @@ void FontCached::Release() {
 	fid = 0;
 }
 
-FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) {
+FontID FontCached::FindOrCreate(const FontParameters &fp) {
 	FontID ret = 0;
 	FontMutexLock();
-	int hashFind = HashFont(faceName_, characterSet_, size_, bold_, italic_);
+	int hashFind = HashFont(fp);
 	for (FontCached *cur = first; cur; cur = cur->next) {
 		if ((cur->hash == hashFind) &&
-		        cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) {
+		        cur->SameAs(fp)) {
 			cur->usage++;
 			ret = cur->fid;
 		}
 	}
 	if (ret == 0) {
-		FontCached *fc = new FontCached(faceName_, characterSet_, size_, bold_, italic_);
+		FontCached *fc = new FontCached(fp);
 		if (fc) {
 			fc->next = first;
 			first = fc;
@@ -550,197 +312,27 @@ void FontCached::ReleaseId(FontID fid_) {
 	FontMutexUnlock();
 }
 
-#ifndef DISABLE_GDK_FONT
-static GdkFont *LoadFontOrSet(const char *fontspec, int characterSet) {
-	if (IsDBCSCharacterSet(characterSet)) {
-		return gdk_fontset_load(fontspec);
-	} else {
-		return gdk_font_load(fontspec);
-	}
-}
-#endif
-
-FontID FontCached::CreateNewFont(const char *fontName, int characterSet,
-                                 int size, bool bold, bool italic) {
-	if (fontName[0] == '!') {
-		PangoFontDescription *pfd = pango_font_description_new();
-		if (pfd) {
-			pango_font_description_set_family(pfd, fontName+1);
-			pango_font_description_set_size(pfd, size * PANGO_SCALE);
-			pango_font_description_set_weight(pfd, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-			pango_font_description_set_style(pfd, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-			return new FontHandle(pfd, characterSet);
-		}
-	}
-
-#ifndef DISABLE_GDK_FONT
-	char fontset[1024];
-	char fontspec[300];
-	char foundary[50];
-	char faceName[100];
-	char charset[50];
-	fontset[0] = '\0';
-	fontspec[0] = '\0';
-	foundary[0] = '\0';
-	faceName[0] = '\0';
-	charset[0] = '\0';
-
-	GdkFont *newid = 0;
-	// If name of the font begins with a '-', assume, that it is
-	// a full fontspec.
-	if (fontName[0] == '-') {
-		if (strchr(fontName, ',') || IsDBCSCharacterSet(characterSet)) {
-			newid = gdk_fontset_load(fontName);
-		} else {
-			newid = gdk_font_load(fontName);
-		}
-		if (!newid) {
-			// Font not available so substitute a reasonable code font
-			// iso8859 appears to only allow western characters.
-			newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*",
-				characterSet);
-		}
-		return new FontHandle(newid);
-	}
-
-	// it's not a full fontspec, build one.
-
-	// This supports creating a FONT_SET
-	// in a method that allows us to also set size, slant and
-	// weight for the fontset.  The expected input is multiple
-	// partial fontspecs seperated by comma
-	// eg. adobe-courier-iso10646-1,*-courier-iso10646-1,*-*-*-*
-	if (strchr(fontName, ',')) {
-		// build a fontspec and use gdk_fontset_load
-		int remaining = sizeof(fontset);
-		char fontNameCopy[1024];
-		strncpy(fontNameCopy, fontName, sizeof(fontNameCopy) - 1);
-		char *fn = fontNameCopy;
-		char *fp = strchr(fn, ',');
-		for (;;) {
-			const char *spec = "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s";
-			if (fontset[0] != '\0') {
-				// if this is not the first font in the list,
-				// append a comma seperator
-				spec = ",%s%s%s%s-*-*-*-%0d-*-*-*-*-%s";
-			}
-
-			if (fp)
-				*fp = '\0'; // nullify the comma
-			GenerateFontSpecStrings(fn, characterSet,
-			                        foundary, sizeof(foundary),
-			                        faceName, sizeof(faceName),
-			                        charset, sizeof(charset));
-
-			g_snprintf(fontspec,
-			         sizeof(fontspec) - 1,
-			         spec,
-			         foundary, faceName,
-			         bold ? "-bold" : "-medium",
-			         italic ? "-i" : "-r",
-			         size * 10,
-			         charset);
-
-			// if this is the first font in the list, and
-			// we are doing italic, add an oblique font
-			// to the list
-			if (italic && fontset[0] == '\0') {
-				strncat(fontset, fontspec, remaining - 1);
-				remaining -= strlen(fontset);
-
-				g_snprintf(fontspec,
-				         sizeof(fontspec) - 1,
-				         ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s",
-				         foundary, faceName,
-				         bold ? "-bold" : "-medium",
-				         size * 10,
-				         charset);
-			}
-
-			strncat(fontset, fontspec, remaining - 1);
-			remaining -= strlen(fontset);
-
-			if (!fp)
-				break;
-
-			fn = fp + 1;
-			fp = strchr(fn, ',');
-		}
-
-		newid = gdk_fontset_load(fontset);
-		if (newid)
-			return new FontHandle(newid);
-		// if fontset load failed, fall through, we'll use
-		// the last font entry and continue to try and
-		// get something that matches
-	}
-
-	// single fontspec support
-
-	GenerateFontSpecStrings(fontName, characterSet,
-	                        foundary, sizeof(foundary),
-	                        faceName, sizeof(faceName),
-	                        charset, sizeof(charset));
-
-	g_snprintf(fontspec,
-	         sizeof(fontspec) - 1,
-	         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
-	         foundary, faceName,
-	         bold ? "-bold" : "-medium",
-	         italic ? "-i" : "-r",
-	         size * 10,
-	         charset);
-	newid = LoadFontOrSet(fontspec, characterSet);
-	if (!newid) {
-		// some fonts have oblique, not italic
-		g_snprintf(fontspec,
-		         sizeof(fontspec) - 1,
-		         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
-		         foundary, faceName,
-		         bold ? "-bold" : "-medium",
-		         italic ? "-o" : "-r",
-		         size * 10,
-		         charset);
-		newid = LoadFontOrSet(fontspec, characterSet);
-	}
-	if (!newid) {
-		g_snprintf(fontspec,
-		         sizeof(fontspec) - 1,
-		         "-*-*-*-*-*-*-*-%0d-*-*-*-*-%s",
-		         size * 10,
-		         charset);
-		newid = gdk_font_load(fontspec);
-	}
-	if (!newid) {
-		// Font not available so substitute a reasonable code font
-		// iso8859 appears to only allow western characters.
-		newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*",
-			characterSet);
-	}
-	return new FontHandle(newid);
-#else
-	// Try to use pango font even if it's not specified
+FontID FontCached::CreateNewFont(const FontParameters &fp) {
 	PangoFontDescription *pfd = pango_font_description_new();
 	if (pfd) {
-		pango_font_description_set_family(pfd, fontName);
-		pango_font_description_set_size(pfd, size * PANGO_SCALE);
-		pango_font_description_set_weight(pfd, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-		pango_font_description_set_style(pfd, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-		return new FontHandle(pfd, characterSet);
+		pango_font_description_set_family(pfd, 
+			(fp.faceName[0] == '!') ? fp.faceName+1 : fp.faceName);
+		pango_font_description_set_size(pfd, pangoUnitsFromDouble(fp.size));
+		pango_font_description_set_weight(pfd, static_cast<PangoWeight>(fp.weight));
+		pango_font_description_set_style(pfd, fp.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+		return new FontHandle(pfd, fp.characterSet);
 	}
 
 	return new FontHandle();
-#endif
 }
 
 Font::Font() : fid(0) {}
 
 Font::~Font() {}
 
-void Font::Create(const char *faceName, int characterSet, int size,
-	bool bold, bool italic, int) {
+void Font::Create(const FontParameters &fp) {
 	Release();
-	fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic);
+	fid = FontCached::FindOrCreate(fp);
 }
 
 void Font::Release() {
@@ -754,17 +346,11 @@ void Font::Release() {
 namespace Scintilla {
 #endif
 
-// On GTK+ 2.x, SurfaceID is a GdkDrawable* and on GTK+ 3.x, it is a cairo_t*
+// SurfaceID is a cairo_t*
 class SurfaceImpl : public Surface {
 	encodingType et;
-#ifdef USE_CAIRO
 	cairo_t *context;
 	cairo_surface_t *psurf;
-#else
-	GdkDrawable *drawable;
-	GdkGC *gc;
-	GdkPixmap *ppixmap;
-#endif
 	int x;
 	int y;
 	bool inited;
@@ -784,37 +370,36 @@ public:
 
 	void Release();
 	bool Initialised();
-	void PenColour(ColourAllocated fore);
+	void PenColour(ColourDesired fore);
 	int LogPixelsY();
 	int DeviceHeightFont(int points);
 	void MoveTo(int x_, int y_);
 	void LineTo(int x_, int y_);
-	void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
-	void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
-	void FillRectangle(PRectangle rc, ColourAllocated back);
+	void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back);
+	void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back);
+	void FillRectangle(PRectangle rc, ColourDesired back);
 	void FillRectangle(PRectangle rc, Surface &surfacePattern);
-	void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
-	void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
-		ColourAllocated outline, int alphaOutline, int flags);
+	void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back);
+	void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+		ColourDesired outline, int alphaOutline, int flags);
 	void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);
-	void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+	void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back);
 	void Copy(PRectangle rc, Point from, Surface &surfaceSource);
 
-	void DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore);
-	void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
-	void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
-	void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore);
-	void MeasureWidths(Font &font_, const char *s, int len, int *positions);
-	int WidthText(Font &font_, const char *s, int len);
-	int WidthChar(Font &font_, char ch);
-	int Ascent(Font &font_);
-	int Descent(Font &font_);
-	int InternalLeading(Font &font_);
-	int ExternalLeading(Font &font_);
-	int Height(Font &font_);
-	int AverageCharWidth(Font &font_);
-
-	int SetPalette(Palette *pal, bool inBackGround);
+	void DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
+	void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+	void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+	void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
+	void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions);
+	XYPOSITION WidthText(Font &font_, const char *s, int len);
+	XYPOSITION WidthChar(Font &font_, char ch);
+	XYPOSITION Ascent(Font &font_);
+	XYPOSITION Descent(Font &font_);
+	XYPOSITION InternalLeading(Font &font_);
+	XYPOSITION ExternalLeading(Font &font_);
+	XYPOSITION Height(Font &font_);
+	XYPOSITION AverageCharWidth(Font &font_);
+
 	void SetClip(PRectangle rc);
 	void FlushCachedState();
 
@@ -882,14 +467,8 @@ void SurfaceImpl::SetConverter(int characterSet_) {
 }
 
 SurfaceImpl::SurfaceImpl() : et(singleByte),
-#ifdef USE_CAIRO
 context(0),
 psurf(0),
-#else
-drawable(0),
-gc(0),
-ppixmap(0),
-#endif
 x(0), y(0), inited(false), createdGC(false)
 , pcontext(0), layout(0), characterSet(-1) {
 }
@@ -900,28 +479,14 @@ SurfaceImpl::~SurfaceImpl() {
 
 void SurfaceImpl::Release() {
 	et = singleByte;
-#ifndef USE_CAIRO
-	drawable = 0;
-#endif
 	if (createdGC) {
 		createdGC = false;
-#ifdef USE_CAIRO
 		cairo_destroy(context);
-#else
-		g_object_unref(gc);
-#endif
 	}
-#ifdef USE_CAIRO
 	context = 0;
 	if (psurf)
 		cairo_surface_destroy(psurf);
 	psurf = 0;
-#else
-	gc = 0;
-	if (ppixmap)
-		g_object_unref(ppixmap);
-	ppixmap = 0;
-#endif
 	if (layout)
 		g_object_unref(layout);
 	layout = 0;
@@ -943,7 +508,6 @@ bool SurfaceImpl::Initialised() {
 void SurfaceImpl::Init(WindowID wid) {
 	Release();
 	PLATFORM_ASSERT(wid);
-#ifdef USE_CAIRO
 #if GTK_CHECK_VERSION(3,0,0)
 	GdkWindow *drawable_ = gtk_widget_get_window(PWidget(wid));
 #else
@@ -959,7 +523,6 @@ void SurfaceImpl::Init(WindowID wid) {
 		context = cairo_create(psurf);
 	}
 	createdGC = true;
-#endif
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	PLATFORM_ASSERT(pcontext);
 	layout = pango_layout_new(pcontext);
@@ -971,24 +534,10 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) {
 	PLATFORM_ASSERT(sid);
 	Release();
 	PLATFORM_ASSERT(wid);
-#ifdef USE_CAIRO
-#if GTK_CHECK_VERSION(3,0,0)
 	context = cairo_reference(reinterpret_cast<cairo_t *>(sid));
-#else
-	context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(sid));
-#endif
-#else
-	drawable = reinterpret_cast<GdkDrawable *>(sid);
-	gc = gdk_gc_new(drawable);
-#endif
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	layout = pango_layout_new(pcontext);
-#ifdef USE_CAIRO
 	cairo_set_line_width(context, 1);
-#else
-	// Ask for lines that do not paint the last pixel so is like Win32
-	gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
-#endif
 	createdGC = true;
 	inited = true;
 }
@@ -998,27 +547,15 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
 	Release();
 	SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_);
 	PLATFORM_ASSERT(wid);
-#ifdef USE_CAIRO
 	context = cairo_reference(surfImpl->context);
-#else
-	PLATFORM_ASSERT(surfImpl->drawable);
-	gc = gdk_gc_new(surfImpl->drawable);
-#endif
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	PLATFORM_ASSERT(pcontext);
 	layout = pango_layout_new(pcontext);
 	PLATFORM_ASSERT(layout);
-#ifdef USE_CAIRO
 	if (height > 0 && width > 0)
 		psurf = CreateSimilarSurface(
 			WindowFromWidget(PWidget(wid)),
 			CAIRO_CONTENT_COLOR_ALPHA, width, height);
-#else
-	if (height > 0 && width > 0)
-		ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1);
-	drawable = ppixmap;
-#endif
-#ifdef USE_CAIRO
 	cairo_destroy(context);
 	context = cairo_create(psurf);
 	cairo_rectangle(context, 0, 0, width, height);
@@ -1026,19 +563,12 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
 	cairo_fill(context);
 	// This produces sharp drawing more similar to GDK:
 	//cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE);
-#endif
-#ifdef USE_CAIRO
 	cairo_set_line_width(context, 1);
-#else
-	// Ask for lines that do not paint the last pixel so is like Win32
-	gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
-#endif
 	createdGC = true;
 	inited = true;
 }
 
-void SurfaceImpl::PenColour(ColourAllocated fore) {
-#ifdef USE_CAIRO
+void SurfaceImpl::PenColour(ColourDesired fore) {
 	if (context) {
 		ColourDesired cdFore(fore.AsLong());
 		cairo_set_source_rgb(context,
@@ -1046,13 +576,6 @@ void SurfaceImpl::PenColour(ColourAllocated fore) {
 			cdFore.GetGreen() / 255.0,
 			cdFore.GetBlue() / 255.0);
 	}
-#else
-	if (gc) {
-		GdkColor co;
-		co.pixel = fore.AsLong();
-		gdk_gc_set_foreground(gc, &co);
-	}
-#endif
 }
 
 int SurfaceImpl::LogPixelsY() {
@@ -1069,7 +592,6 @@ void SurfaceImpl::MoveTo(int x_, int y_) {
 	y = y_;
 }
 
-#ifdef USE_CAIRO
 static int Delta(int difference) {
 	if (difference < 0)
 		return -1;
@@ -1078,10 +600,8 @@ static int Delta(int difference) {
 	else
 		return 0;
 }
-#endif
 
 void SurfaceImpl::LineTo(int x_, int y_) {
-#ifdef USE_CAIRO
 	// cairo_line_to draws the end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST.
 	// For simple cases, move back one pixel from end.
 	if (context) {
@@ -1110,20 +630,12 @@ void SurfaceImpl::LineTo(int x_, int y_) {
 		}
 		cairo_stroke(context);
 	}
-#else
-	if (drawable && gc) {
-		gdk_draw_line(drawable, gc,
-		              x, y,
-		              x_, y_);
-	}
-#endif
 	x = x_;
 	y = y_;
 }
 
-void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore,
-                          ColourAllocated back) {
-#ifdef USE_CAIRO
+void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore,
+                          ColourDesired back) {
 	PenColour(back);
 	cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5);
 	for (int i = 1;i < npts;i++) {
@@ -1133,73 +645,33 @@ void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore,
 	cairo_fill_preserve(context);
 	PenColour(fore);
 	cairo_stroke(context);
-#else
-	GdkPoint gpts[20];
-	if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) {
-		for (int i = 0;i < npts;i++) {
-			gpts[i].x = pts[i].x;
-			gpts[i].y = pts[i].y;
-		}
-		PenColour(back);
-		gdk_draw_polygon(drawable, gc, 1, gpts, npts);
-		PenColour(fore);
-		gdk_draw_polygon(drawable, gc, 0, gpts, npts);
-	}
-#endif
 }
 
-void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
-#ifdef USE_CAIRO
+void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
 	if (context) {
-#else
-	if (gc && drawable) {
-#endif
-#ifdef USE_CAIRO
 		cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5,
 	                     rc.right - rc.left - 1, rc.bottom - rc.top - 1);
 		PenColour(back);
 		cairo_fill_preserve(context);
 		PenColour(fore);
 		cairo_stroke(context);
-#else
-		PenColour(back);
-		gdk_draw_rectangle(drawable, gc, 1,
-		                   rc.left + 1, rc.top + 1,
-		                   rc.right - rc.left - 2, rc.bottom - rc.top - 2);
-		PenColour(fore);
-		// The subtraction of 1 off the width and height here shouldn't be needed but
-		// otherwise a different rectangle is drawn than would be done if the fill parameter == 1
-		gdk_draw_rectangle(drawable, gc, 0,
-		                   rc.left, rc.top,
-		                   rc.right - rc.left - 1, rc.bottom - rc.top - 1);
-#endif
 	}
 }
 
-void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
+void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) {
 	PenColour(back);
-#ifdef USE_CAIRO
 	if (context && (rc.left < maxCoordinate)) {	// Protect against out of range
+		rc.left = lround(rc.left);
+		rc.right = lround(rc.right);
 		cairo_rectangle(context, rc.left, rc.top,
 	                     rc.right - rc.left, rc.bottom - rc.top);
 		cairo_fill(context);
 	}
-#else
-	if (drawable && (rc.left < maxCoordinate)) {	// Protect against out of range
-		gdk_draw_rectangle(drawable, gc, 1,
-		                   rc.left, rc.top,
-		                   rc.right - rc.left, rc.bottom - rc.top);
-	}
-#endif
 }
 
 void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
 	SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern);
-#ifdef USE_CAIRO
 	bool canDraw = surfi.psurf;
-#else
-	bool canDraw = surfi.drawable;
-#endif
 	if (canDraw) {
 		// Tile pattern over rectangle
 		// Currently assumes 8x8 pattern
@@ -1209,28 +681,19 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
 			int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat;
 			for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) {
 				int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat;
-#ifdef USE_CAIRO
 				cairo_set_source_surface(context, surfi.psurf, xTile, yTile);
 				cairo_rectangle(context, xTile, yTile, widthx, heighty);
 				cairo_fill(context);
-#else
-				gdk_draw_drawable(drawable,
-				                gc,
-				                static_cast<SurfaceImpl &>(surfacePattern).drawable,
-				                0, 0,
-				                xTile, yTile,
-				                widthx, heighty);
-#endif
 			}
 		}
 	} else {
 		// Something is wrong so try to show anyway
 		// Shows up black because colour not allocated
-		FillRectangle(rc, ColourAllocated(0));
+		FillRectangle(rc, ColourDesired(0));
 	}
 }
 
-void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
+void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
 	if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) {
 		// Approximate a round rect with some cut off corners
 		Point pts[] = {
@@ -1249,8 +712,6 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl
 	}
 }
 
-#ifdef USE_CAIRO
-
 static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) {
 	double degrees = M_PI / 180.0;
 
@@ -1267,45 +728,8 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double
 	cairo_close_path(context);
 }
 
-#else
-
-// Plot a point into a guint32 buffer symetrically to all 4 qudrants
-static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) {
-	pixels[y*stride+x] = val;
-	pixels[y*stride+width-1-x] = val;
-	pixels[(height-1-y)*stride+x] = val;
-	pixels[(height-1-y)*stride+width-1-x] = val;
-}
-
-static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) {
-	union {
-		guint8 pixVal[4];
-		guint32 val;
-	} converter;
-	converter.pixVal[0] = r;
-	converter.pixVal[1] = g;
-	converter.pixVal[2] = b;
-	converter.pixVal[3] = a;
-	return converter.val;
-}
-
-static unsigned int GetRValue(unsigned int co) {
-	return (co >> 16) & 0xff;
-}
-
-static unsigned int GetGValue(unsigned int co) {
-	return (co >> 8) & 0xff;
-}
-
-static unsigned int GetBValue(unsigned int co) {
-	return co & 0xff;
-}
-
-#endif
-
-void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
-		ColourAllocated outline, int alphaOutline, int flags) {
-#ifdef USE_CAIRO
+void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+		ColourDesired outline, int alphaOutline, int flags) {
 	if (context && rc.Width() > 0) {
 		ColourDesired cdFill(fill.AsLong());
 		cairo_set_source_rgba(context,
@@ -1331,47 +755,6 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated
 			cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1);
 		cairo_stroke(context);
 	}
-#else
-	if (gc && drawable && rc.Width() > 0) {
-		int width = rc.Width();
-		int height = rc.Height();
-		// Ensure not distorted too much by corners when small
-		cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2);
-		// Make a 32 bit deep pixbuf with alpha
-		GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
-
-		guint32 valEmpty = u32FromRGBA(0,0,0,0);
-		guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()),
-			GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill);
-		guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()),
-			GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline);
-		guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha));
-		int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4;
-		for (int yr=0; yr<height; yr++) {
-			for (int xr=0; xr<width; xr++) {
-				if ((xr==0) || (xr==width-1) || (yr == 0) || (yr == height-1)) {
-					pixels[yr*stride+xr] = valOutline;
-				} else {
-					pixels[yr*stride+xr] = valFill;
-				}
-			}
-		}
-		for (int c=0;c<cornerSize; c++) {
-			for (int xr=0;xr<c+1; xr++) {
-				AllFour(pixels, stride, width, height, xr, c-xr, valEmpty);
-			}
-		}
-		for (int xr=1;xr<cornerSize; xr++) {
-			AllFour(pixels, stride, width, height, xr, cornerSize-xr, valOutline);
-		}
-
-		// Draw with alpha
-		gdk_draw_pixbuf(drawable, gc, pixalpha,
-			0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0);
-
-		g_object_unref(pixalpha);
-	}
-#endif
 }
 
 void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
@@ -1382,8 +765,11 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
 		rc.top += (rc.Height() - height) / 2;
 	rc.bottom = rc.top + height;
 
-#ifdef USE_CAIRO
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,6,0)
 	int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
+#else
+	int stride = width * 4;
+#endif
 	int ucs = stride * height;
 	std::vector<unsigned char> image(ucs);
 	for (int y=0; y<height; y++) {
@@ -1403,81 +789,28 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
 	cairo_fill(context);
 
 	cairo_surface_destroy(psurf);
-#else
-	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(pixelsImage,
-                                                         GDK_COLORSPACE_RGB,
-                                                         TRUE,
-                                                         8,
-                                                         width,
-                                                         height,
-                                                         width * 4,
-                                                         NULL,
-                                                         NULL);
-	gdk_draw_pixbuf(drawable, gc, pixbuf,
-		0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0);
-	g_object_unref(pixbuf);
-#endif
 }
 
-void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
+void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
 	PenColour(back);
-#ifdef USE_CAIRO
 	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);
 	cairo_fill_preserve(context);
 	PenColour(fore);
 	cairo_stroke(context);
-#else
-	gdk_draw_arc(drawable, gc, 1,
-	             rc.left + 1, rc.top + 1,
-	             rc.right - rc.left - 2, rc.bottom - rc.top - 2,
-	             0, 32767);
-
-	// The subtraction of 1 here is similar to the case for RectangleDraw
-	PenColour(fore);
-	gdk_draw_arc(drawable, gc, 0,
-	             rc.left, rc.top,
-	             rc.right - rc.left - 1, rc.bottom - rc.top - 1,
-	             0, 32767);
-#endif
 }
 
 void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
 	SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource);
-#ifdef USE_CAIRO
 	bool canDraw = surfi.psurf;
-#else
-	bool canDraw = surfi.drawable;
-#endif
 	if (canDraw) {
-#ifdef USE_CAIRO
 		cairo_set_source_surface(context, surfi.psurf,
 			rc.left - from.x, rc.top - from.y);
 		cairo_rectangle(context, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
 		cairo_fill(context);
-#else
-		gdk_draw_drawable(drawable,
-		                gc,
-		                static_cast<SurfaceImpl &>(surfaceSource).drawable,
-		                from.x, from.y,
-		                rc.left, rc.top,
-		                rc.right - rc.left, rc.bottom - rc.top);
-#endif
 	}
 }
 
-#ifndef DISABLE_GDK_FONT
-static size_t UTF8Len(char ch) {
-	unsigned char uch = static_cast<unsigned char>(ch);
-	if (uch < 0x80)
-		return 1;
-	else if (uch < (0x80 + 0x40 + 0x20))
-		return 2;
-	else
-		return 3;
-}
-#endif
-
 char *UTF8FromLatin1(const char *s, int &len) {
 	char *utfForm = new char[len*2+1];
 	size_t lenU = 0;
@@ -1530,49 +863,6 @@ static size_t MultiByteLenFromIconv(const Converter &conv, const char *s, size_t
 	return 1;
 }
 
-#ifndef DISABLE_GDK_FONT
-static char *UTF8FromGdkWChar(GdkWChar *wctext, int wclen) {
-	char *utfForm = new char[wclen*3+1];	// Maximum of 3 UTF-8 bytes per character
-	size_t lenU = 0;
-	for (int i = 0; i < wclen && wctext[i]; i++) {
-		unsigned int uch = wctext[i];
-		if (uch < 0x80) {
-			utfForm[lenU++] = static_cast<char>(uch);
-		} else if (uch < 0x800) {
-			utfForm[lenU++] = static_cast<char>(0xC0 | (uch >> 6));
-			utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f));
-		} else {
-			utfForm[lenU++] = static_cast<char>(0xE0 | (uch >> 12));
-			utfForm[lenU++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
-			utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f));
-		}
-	}
-	utfForm[lenU] = '\0';
-	return utfForm;
-}
-#endif
-
-static char *UTF8FromDBCS(const char *s, int &len) {
-#ifndef DISABLE_GDK_FONT
-	GdkWChar *wctext = new GdkWChar[len + 1];
-	GdkWChar *wcp = wctext;
-	int wclen = gdk_mbstowcs(wcp, s, len);
-	if (wclen < 1) {
-		// In the annoying case when non-locale chars in the line.
-		// e.g. latin1 chars in Japanese locale.
-		delete []wctext;
-		return 0;
-	}
-
-	char *utfForm = UTF8FromGdkWChar(wctext, wclen);
-	delete []wctext;
-	len = strlen(utfForm);
-	return utfForm;
-#else
-	return 0;
-#endif
-}
-
 static size_t UTF8CharLength(const char *s) {
 	const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
 	unsigned char ch = *us;
@@ -1585,19 +875,11 @@ static size_t UTF8CharLength(const char *s) {
 	}
 }
 
-// On GTK+, wchar_t is 4 bytes
-
-const int maxLengthTextRun = 10000;
-
-void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                                 ColourAllocated fore) {
+void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+                                 ColourDesired fore) {
 	PenColour(fore);
-#ifdef USE_CAIRO
 	if (context) {
-#else
-	if (gc && drawable) {
-#endif
-		int xText = rc.left;
+		XYPOSITION xText = rc.left;
 		if (PFont(font_)->pfd) {
 			char *utfForm = 0;
 			if (et == UTF8) {
@@ -1607,102 +889,40 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char
 					SetConverter(PFont(font_)->characterSet);
 					utfForm = UTF8FromIconv(conv, s, len);
 				}
-				if (!utfForm) {	// iconv failed so try DBCS if DBCS mode
-					if (et == dbcs) {
-						// Convert to utf8
-						utfForm = UTF8FromDBCS(s, len);
-					}
-				}
-				if (!utfForm) {	// iconv and DBCS failed so treat as Latin1
+				if (!utfForm) {	// iconv failed so treat as Latin1
 					utfForm = UTF8FromLatin1(s, len);
 				}
 				pango_layout_set_text(layout, utfForm, len);
 			}
 			pango_layout_set_font_description(layout, PFont(font_)->pfd);
-#ifdef USE_CAIRO
 			pango_cairo_update_layout(context, layout);
-#endif
 #ifdef PANGO_VERSION
 			PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0);
 #else
 			PangoLayoutLine *pll = pango_layout_get_line(layout,0);
 #endif
-#ifdef USE_CAIRO
 			cairo_move_to(context, xText, ybase);
 			pango_cairo_show_layout_line(context, pll);
-#else
-			gdk_draw_layout_line(drawable, gc, xText, ybase, pll);
-#endif
 			delete []utfForm;
-			return;
 		}
-#ifndef DISABLE_GDK_FONT
-		// Draw text as a series of segments to avoid limitations in X servers
-		const int segmentLength = 1000;
-		bool draw8bit = true;
-		if (et != singleByte) {
-			GdkWChar wctext[maxLengthTextRun];
-			if (len >= maxLengthTextRun)
-				len = maxLengthTextRun-1;
-			int wclen;
-			if (et == UTF8) {
-				wclen = UTF16FromUTF8(s, len,
-					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
-			} else {	// dbcs, so convert using current locale
-				char sMeasure[maxLengthTextRun];
-				memcpy(sMeasure, s, len);
-				sMeasure[len] = '\0';
-				wclen = gdk_mbstowcs(
-					wctext, sMeasure, maxLengthTextRun - 1);
-			}
-			if (wclen > 0) {
-				draw8bit = false;
-				wctext[wclen] = L'\0';
-				GdkWChar *wcp = wctext;
-				while ((wclen > 0) && (xText < maxCoordinate)) {
-					int lenDraw = Platform::Minimum(wclen, segmentLength);
-					gdk_draw_text_wc(drawable, PFont(font_)->pfont, gc,
-							 xText, ybase, wcp, lenDraw);
-					wclen -= lenDraw;
-					if (wclen > 0) {	// Avoid next calculation if possible as may be expensive
-						xText += gdk_text_width_wc(PFont(font_)->pfont,
-								       wcp, lenDraw);
-					}
-					wcp += lenDraw;
-				}
-			}
-		}
-		if (draw8bit) {
-			while ((len > 0) && (xText < maxCoordinate)) {
-				int lenDraw = Platform::Minimum(len, segmentLength);
-				gdk_draw_text(drawable, PFont(font_)->pfont, gc,
-				              xText, ybase, s, lenDraw);
-				len -= lenDraw;
-				if (len > 0) {	// Avoid next calculation if possible as may be expensive
-					xText += gdk_text_width(PFont(font_)->pfont, s, lenDraw);
-				}
-				s += lenDraw;
-			}
-		}
-#endif
 	}
 }
 
-void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                                 ColourAllocated fore, ColourAllocated back) {
+void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+                                 ColourDesired fore, ColourDesired back) {
 	FillRectangle(rc, back);
 	DrawTextBase(rc, font_, ybase, s, len, fore);
 }
 
 // On GTK+, exactly same as DrawTextNoClip
-void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                                  ColourAllocated fore, ColourAllocated back) {
+void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+                                  ColourDesired fore, ColourDesired back) {
 	FillRectangle(rc, back);
 	DrawTextBase(rc, font_, ybase, s, len, fore);
 }
 
-void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                                  ColourAllocated fore) {
+void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+                                  ColourDesired fore) {
 	// Avoid drawing spaces in transparent mode
 	for (int i=0;i<len;i++) {
 		if (s[i] != ' ') {
@@ -1718,9 +938,9 @@ class ClusterIterator {
 	int lenPositions;
 public:
 	bool finished;
-	int positionStart;
-	int position;
-	int distance;
+	XYPOSITION positionStart;
+	XYPOSITION position;
+	XYPOSITION distance;
 	int curIndex;
 	ClusterIterator(PangoLayout *layout, int len) : lenPositions(len), finished(false),
 		positionStart(0), position(0), distance(0), curIndex(0) {
@@ -1735,18 +955,18 @@ public:
 		positionStart = position;
 		if (pango_layout_iter_next_cluster(iter)) {
 			pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-			position = PANGO_PIXELS(pos.x);
+			position = doubleFromPangoUnits(pos.x);
 			curIndex = pango_layout_iter_get_index(iter);
 		} else {
 			finished = true;
-			position = PANGO_PIXELS(pos.x + pos.width);
+			position = doubleFromPangoUnits(pos.x + pos.width);
 			curIndex = lenPositions;
 		}
 		distance = position - positionStart;
 	}
 };
 
-void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
+void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) {
 	if (font_.GetID()) {
 		const int lenPositions = len;
 		if (PFont(font_)->pfd) {
@@ -1841,59 +1061,6 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
 			}
 			return;
 		}
-#ifndef DISABLE_GDK_FONT
-		int totalWidth = 0;
-		GdkFont *gf = PFont(font_)->pfont;
-		bool measure8bit = true;
-		if (et != singleByte) {
-			GdkWChar wctext[maxLengthTextRun];
-			if (len >= maxLengthTextRun)
-				len = maxLengthTextRun-1;
-			int wclen;
-			if (et == UTF8) {
-				wclen = UTF16FromUTF8(s, len,
-					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
-			} else {	// dbcsMode, so convert using current locale
-				char sDraw[maxLengthTextRun];
-				memcpy(sDraw, s, len);
-				sDraw[len] = '\0';
-				wclen = gdk_mbstowcs(
-					wctext, sDraw, maxLengthTextRun - 1);
-			}
-			if (wclen > 0) {
-				measure8bit = false;
-				wctext[wclen] = L'\0';
-				// Map widths back to utf-8 or DBCS input string
-				int i = 0;
-				for (int iU = 0; iU < wclen; iU++) {
-					int width = gdk_char_width_wc(gf, wctext[iU]);
-					totalWidth += width;
-					int lenChar;
-					if (et == UTF8) {
-						lenChar = UTF8Len(s[i]);
-					} else {
-						lenChar = mblen(s+i, MB_CUR_MAX);
-						if (lenChar < 0)
-							lenChar = 1;
-					}
-					while (lenChar--) {
-						positions[i++] = totalWidth;
-					}
-				}
-				while (i < len) {	// In case of problems with lengths
-					positions[i++] = totalWidth;
-				}
-			}
-		}
-		if (measure8bit) {
-			// Either Latin1 or conversion failed so treat as Latin1.
-			for (int i = 0; i < len; i++) {
-				int width = gdk_char_width(gf, s[i]);
-				totalWidth += width;
-				positions[i] = totalWidth;
-			}
-		}
-#endif
 	} else {
 		// No font so return an ascending range of values
 		for (int i = 0; i < len; i++) {
@@ -1902,7 +1069,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
 	}
 }
 
-int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
+XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
 	if (font_.GetID()) {
 		if (PFont(font_)->pfd) {
 			char *utfForm = 0;
@@ -1911,15 +1078,11 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
 			if (et == UTF8) {
 				pango_layout_set_text(layout, s, len);
 			} else {
-				if (et == dbcs) {
-					// Convert to utf8
-					utfForm = UTF8FromDBCS(s, len);
-				}
-				if (!utfForm) {	// DBCS failed so treat as iconv
+				if (!utfForm) {	// use iconv
 					SetConverter(PFont(font_)->characterSet);
 					utfForm = UTF8FromIconv(conv, s, len);
 				}
-				if (!utfForm) {	// g_locale_to_utf8 failed so treat as Latin1
+				if (!utfForm) {	// iconv failed so treat as Latin1
 					utfForm = UTF8FromLatin1(s, len);
 				}
 				pango_layout_set_text(layout, utfForm, len);
@@ -1931,157 +1094,79 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
 #endif
 			pango_layout_line_get_extents(pangoLine, NULL, &pos);
 			delete []utfForm;
-			return PANGO_PIXELS(pos.width);
-		}
-#ifndef DISABLE_GDK_FONT
-		if (et == UTF8) {
-			GdkWChar wctext[maxLengthTextRun];
-			size_t wclen = UTF16FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)),
-				sizeof(wctext) / sizeof(GdkWChar) - 1);
-			wctext[wclen] = L'\0';
-			return gdk_text_width_wc(PFont(font_)->pfont, wctext, wclen);
-		} else {
-			return gdk_text_width(PFont(font_)->pfont, s, len);
+			return doubleFromPangoUnits(pos.width);
 		}
-#else
 		return 1;
-#endif
 	} else {
 		return 1;
 	}
 }
 
-int SurfaceImpl::WidthChar(Font &font_, char ch) {
+XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) {
 	if (font_.GetID()) {
 		if (PFont(font_)->pfd) {
 			return WidthText(font_, &ch, 1);
 		}
-#ifndef DISABLE_GDK_FONT
-		return gdk_char_width(PFont(font_)->pfont, ch);
-#else
 		return 1;
-#endif
 	} else {
 		return 1;
 	}
 }
 
-// Three possible strategies for determining ascent and descent of font:
-// 1) Call gdk_string_extents with string containing all letters, numbers and punctuation.
-// 2) Use the ascent and descent fields of GdkFont.
-// 3) Call gdk_string_extents with string as 1 but also including accented capitals.
-// Smallest values given by 1 and largest by 3 with 2 in between.
-// Techniques 1 and 2 sometimes chop off extreme portions of ascenders and
-// descenders but are mostly OK except for accented characters like Åwhich are
-// rarely used in code.
-
-// This string contains a good range of characters to test for size.
-//const char largeSizeString[] = "ÂÅ `~! #$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890"
-//                               "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#ifndef FAST_WAY
-const char sizeString[] = "`~! #$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890"
-                          "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#endif
+// Ascent and descent determined by Pango font metrics.
 
-int SurfaceImpl::Ascent(Font &font_) {
+XYPOSITION SurfaceImpl::Ascent(Font &font_) {
 	if (!(font_.GetID()))
 		return 1;
-#ifdef FAST_WAY
 	FontMutexLock();
 	int ascent = PFont(font_)->ascent;
 	if ((ascent == 0) && (PFont(font_)->pfd)) {
 		PangoFontMetrics *metrics = pango_context_get_metrics(pcontext,
 			PFont(font_)->pfd, pango_context_get_language(pcontext));
 		PFont(font_)->ascent =
-			PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
+			doubleFromPangoUnits(pango_font_metrics_get_ascent(metrics));
 		pango_font_metrics_unref(metrics);
 		ascent = PFont(font_)->ascent;
 	}
-#ifndef DISABLE_GDK_FONT
-	if ((ascent == 0) && (PFont(font_)->pfont)) {
-		ascent = PFont(font_)->pfont->ascent;
-	}
-#endif
 	if (ascent == 0) {
 		ascent = 1;
 	}
 	FontMutexUnlock();
 	return ascent;
-#else
-
-	gint lbearing;
-	gint rbearing;
-	gint width;
-	gint ascent;
-	gint descent;
-
-	gdk_string_extents(PFont(font_)->pfont, sizeString,
-					   &lbearing, &rbearing, &width, &ascent, &descent);
-	return ascent;
-#endif
 }
 
-int SurfaceImpl::Descent(Font &font_) {
+XYPOSITION SurfaceImpl::Descent(Font &font_) {
 	if (!(font_.GetID()))
 		return 1;
-#ifdef FAST_WAY
-
 	if (PFont(font_)->pfd) {
 		PangoFontMetrics *metrics = pango_context_get_metrics(pcontext,
 			PFont(font_)->pfd, pango_context_get_language(pcontext));
-		int descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
+		int descent = doubleFromPangoUnits(pango_font_metrics_get_descent(metrics));
 		pango_font_metrics_unref(metrics);
 		return descent;
 	}
-#ifndef DISABLE_GDK_FONT
-	return PFont(font_)->pfont->descent;
-#else
 	return 0;
-#endif
-#else
-
-	gint lbearing;
-	gint rbearing;
-	gint width;
-	gint ascent;
-	gint descent;
-
-	gdk_string_extents(PFont(font_)->pfont, sizeString,
-					   &lbearing, &rbearing, &width, &ascent, &descent);
-	return descent;
-#endif
 }
 
-int SurfaceImpl::InternalLeading(Font &) {
+XYPOSITION SurfaceImpl::InternalLeading(Font &) {
 	return 0;
 }
 
-int SurfaceImpl::ExternalLeading(Font &) {
+XYPOSITION SurfaceImpl::ExternalLeading(Font &) {
 	return 0;
 }
 
-int SurfaceImpl::Height(Font &font_) {
+XYPOSITION SurfaceImpl::Height(Font &font_) {
 	return Ascent(font_) + Descent(font_);
 }
 
-int SurfaceImpl::AverageCharWidth(Font &font_) {
+XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) {
 	return WidthChar(font_, 'n');
 }
 
-int SurfaceImpl::SetPalette(Palette *, bool) {
-	// Handled in palette allocation for GTK so this does nothing
-	return 0;
-}
-
 void SurfaceImpl::SetClip(PRectangle rc) {
-#ifdef USE_CAIRO
 	cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom);
 	cairo_clip(context);
-#else
-	GdkRectangle area = {rc.left, rc.top,
-	                     rc.right - rc.left, rc.bottom - rc.top};
-	gdk_gc_set_clip_rectangle(gc, &area);
-#endif
 }
 
 void SurfaceImpl::FlushCachedState() {}
@@ -2096,8 +1181,8 @@ void SurfaceImpl::SetDBCSMode(int codePage) {
 		et = dbcs;
 }
 
-Surface *Surface::Allocate() {
-	return new SurfaceImpl;
+Surface *Surface::Allocate(int) {
+	return new SurfaceImpl();
 }
 
 Window::~Window() {}
@@ -2250,25 +1335,16 @@ PRectangle Window::GetMonitorRect(Point pt) {
 
 	gdk_window_get_origin(WindowFromWidget(PWidget(wid)), &x_offset, &y_offset);
 
-#if GTK_CHECK_VERSION(2,2,0)
-	// GTK+ 2.2+
-	{
-		GdkScreen* screen;
-		gint monitor_num;
-		GdkRectangle rect;
+	GdkScreen* screen;
+	gint monitor_num;
+	GdkRectangle rect;
 
-		screen = gtk_widget_get_screen(PWidget(wid));
-		monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset);
-		gdk_screen_get_monitor_geometry(screen, monitor_num, &rect);
-		rect.x -= x_offset;
-		rect.y -= y_offset;
-		return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
-	}
-#else
-	pt = pt;
-	return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(),
-	                  (-y_offset) + gdk_screen_height());
-#endif
+	screen = gtk_widget_get_screen(PWidget(wid));
+	monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset);
+	gdk_screen_get_monitor_geometry(screen, monitor_num, &rect);
+	rect.x -= x_offset;
+	rect.y -= y_offset;
+	return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
 }
 
 typedef std::map<int, RGBAImage*> ImageMap;
@@ -2321,7 +1397,7 @@ public:
 		}
 	}
 	virtual void SetFont(Font &font);
-	virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_);
+	virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_);
 	virtual void SetAverageCharWidth(int width);
 	virtual void SetVisibleRows(int rows);
 	virtual int GetVisibleRows() const;
@@ -2410,7 +1486,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
 #endif
 }
 
-void ListBoxX::Create(Window &, int, Point, int, bool) {
+void ListBoxX::Create(Window &, int, Point, int, bool, int) {
 	wid = gtk_window_new(GTK_WINDOW_POPUP);
 
 	GtkWidget *frame = gtk_frame_new(NULL);
@@ -2852,7 +1928,7 @@ void Menu::Show(Point pt, Window &) {
 		pt.y = screenHeight - requisition.height;
 	}
 	gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc,
-		reinterpret_cast<void *>((pt.y << 16) | pt.x), 0,
+		reinterpret_cast<void *>((static_cast<int>(pt.y) << 16) | static_cast<int>(pt.x)), 0,
 		gtk_get_current_event_time());
 }
 
diff --git a/plugins/scintilla/scintilla/PositionCache.cxx b/plugins/scintilla/scintilla/PositionCache.cxx
index 2105c29..759558e 100644
--- a/plugins/scintilla/scintilla/PositionCache.cxx
+++ b/plugins/scintilla/scintilla/PositionCache.cxx
@@ -86,7 +86,7 @@ void LineLayout::Resize(int maxLineLength_) {
 		indicators = new char[maxLineLength_ + 1];
 		// Extra position allocated as sometimes the Windows
 		// GetTextExtentExPoint API writes an extra element.
-		positions = new int[maxLineLength_ + 1 + 1];
+		positions = new XYPOSITION[maxLineLength_ + 1 + 1];
 		maxLineLength = maxLineLength_;
 	}
 }
@@ -189,10 +189,10 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[], bool
 	xHighlightGuide = 0;
 }
 
-int LineLayout::FindBefore(int x, int lower, int upper) const {
+int LineLayout::FindBefore(XYPOSITION x, int lower, int upper) const {
 	do {
 		int middle = (upper + lower + 1) / 2; 	// Round high
-		int posMiddle = positions[middle];
+		XYPOSITION posMiddle = positions[middle];
 		if (x < posMiddle) {
 			upper = middle - 1;
 		} else {
@@ -503,15 +503,15 @@ PositionCacheEntry::PositionCacheEntry() :
 }
 
 void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
-	unsigned int len_, int *positions_, unsigned int clock_) {
+	unsigned int len_, XYPOSITION *positions_, unsigned int clock_) {
 	Clear();
 	styleNumber = styleNumber_;
 	len = len_;
 	clock = clock_;
 	if (s_ && positions_) {
-		positions = new short[len + (len + 1) / 2];
+		positions = new XYPOSITION[len + (len + 1) / 2];
 		for (unsigned int i=0; i<len; i++) {
-			positions[i] = static_cast<short>(positions_[i]);
+			positions[i] = static_cast<XYPOSITION>(positions_[i]);
 		}
 		memcpy(reinterpret_cast<char *>(positions + len), s_, len);
 	}
@@ -530,7 +530,7 @@ void PositionCacheEntry::Clear() {
 }
 
 bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
-	unsigned int len_, int *positions_) const {
+	unsigned int len_, XYPOSITION *positions_) const {
 	if ((styleNumber == styleNumber_) && (len == len_) &&
 		(memcmp(reinterpret_cast<char *>(positions + len), s_, len)== 0)) {
 		for (unsigned int i=0; i<len; i++) {
@@ -595,7 +595,7 @@ void PositionCache::SetSize(size_t size_) {
 }
 
 void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
-	const char *s, unsigned int len, int *positions, Document *pdoc) {
+	const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) {
 
 	allClear = false;
 	int probe = -1;
@@ -621,7 +621,7 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
 	if (len > BreakFinder::lengthStartSubdivision) {
 		// Break up into segments
 		unsigned int startSegment = 0;
-		int xStartSegment = 0;
+		XYPOSITION xStartSegment = 0;
 		while (startSegment < len) {
 			unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision);
 			surface->MeasureWidths(vstyle.styles[styleNumber].font, s + startSegment, lenSegment, positions + startSegment);
diff --git a/plugins/scintilla/scintilla/PositionCache.h b/plugins/scintilla/scintilla/PositionCache.h
index c6076ea..08ecee1 100644
--- a/plugins/scintilla/scintilla/PositionCache.h
+++ b/plugins/scintilla/scintilla/PositionCache.h
@@ -41,7 +41,7 @@ public:
 	unsigned char *styles;
 	int styleBitsSet;
 	char *indicators;
-	int *positions;
+	XYPOSITION *positions;
 	char bracePreviousStyles[2];
 
 	// Hotspot support
@@ -51,7 +51,7 @@ public:
 	// Wrapped line support
 	int widthLine;
 	int lines;
-	int wrapIndent; // In pixels
+	XYPOSITION wrapIndent; // In pixels
 
 	LineLayout(int maxLineLength_);
 	virtual ~LineLayout();
@@ -65,7 +65,7 @@ public:
 	void SetBracesHighlight(Range rangeLine, Position braces[],
 		char bracesMatchStyle, int xHighlight, bool ignoreStyle);
 	void RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle);
-	int FindBefore(int x, int lower, int upper) const;
+	int FindBefore(XYPOSITION x, int lower, int upper) const;
 	int EndLineStyle() const;
 };
 
@@ -103,13 +103,13 @@ class PositionCacheEntry {
 	unsigned int styleNumber:8;
 	unsigned int len:8;
 	unsigned int clock:16;
-	short *positions;
+	XYPOSITION *positions;
 public:
 	PositionCacheEntry();
 	~PositionCacheEntry();
-	void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
+	void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock);
 	void Clear();
-	bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
+	bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
 	static int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
 	bool NewerThan(const PositionCacheEntry &other) const;
 	void ResetClock();
@@ -155,7 +155,7 @@ public:
 	void SetSize(size_t size_);
 	size_t GetSize() const { return size; }
 	void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
-		const char *s, unsigned int len, int *positions, Document *pdoc);
+		const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc);
 };
 
 inline bool IsSpaceOrTab(int ch) {
diff --git a/plugins/scintilla/scintilla/PropSetSimple.cxx b/plugins/scintilla/scintilla/PropSetSimple.cxx
index ce2031f..c0ec594 100644
--- a/plugins/scintilla/scintilla/PropSetSimple.cxx
+++ b/plugins/scintilla/scintilla/PropSetSimple.cxx
@@ -12,8 +12,8 @@
 #include <stdio.h>
 
 #ifdef _MSC_VER
-// Visual C++ doesn't like unreachable code or long decorated names in its own headers.
-#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702 4786)
+// Visual C++ doesn't like unreachable code in its own headers.
+#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702)
 #endif
 
 #include <string>
diff --git a/plugins/scintilla/scintilla/ScintillaBase.cxx b/plugins/scintilla/scintilla/ScintillaBase.cxx
index 76db98a..f78d0fb 100644
--- a/plugins/scintilla/scintilla/ScintillaBase.cxx
+++ b/plugins/scintilla/scintilla/ScintillaBase.cxx
@@ -65,11 +65,6 @@ void ScintillaBase::Finalise() {
 	popup.Destroy();
 }
 
-void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
-	Editor::RefreshColourPalette(pal, want);
-	ct.RefreshColourPalette(pal, want);
-}
-
 void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 	bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
 	if (!isFillUp) {
@@ -139,10 +134,10 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
 			AutoCompleteMove(-1);
 			return 0;
 		case SCI_PAGEDOWN:
-			AutoCompleteMove(5);
+			AutoCompleteMove(ac.lb->GetVisibleRows());
 			return 0;
 		case SCI_PAGEUP:
-			AutoCompleteMove(-5);
+			AutoCompleteMove(-ac.lb->GetVisibleRows());
 			return 0;
 		case SCI_VCHOME:
 			AutoCompleteMove(-5000);
@@ -222,7 +217,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
 		}
 	}
 	ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
-				lenEntered, vs.lineHeight, IsUnicodeMode());
+				lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
 
 	PRectangle rcClient = GetClientRectangle();
 	Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
@@ -413,20 +408,28 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
 		ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
 	}
 	PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt,
+		vs.lineHeight,
 		defn,
 		vs.styles[ctStyle].fontName,
 		vs.styles[ctStyle].sizeZoomed,
 		CodePage(),
 		vs.styles[ctStyle].characterSet,
+		vs.technology,
 		wMain);
 	// If the call-tip window would be out of the client
-	// space, adjust so it displays below the text.
+	// space
 	PRectangle rcClient = GetClientRectangle();
+	int offset = vs.lineHeight + rc.Height();
+	// adjust so it displays below the text.
 	if (rc.top < rcClient.top) {
-		int offset = vs.lineHeight + rc.Height();
 		rc.top += offset;
 		rc.bottom += offset;
 	}
+	// adjust so it displays above the text.
+	if (rc.bottom > rcClient.bottom) {
+		rc.top -= offset;
+		rc.bottom -= offset;
+	}
 	// Now display the window.
 	CreateCallTipWindow(rc);
 	ct.wCallTip.SetPositionRelative(rc, wMain);
@@ -817,6 +820,11 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_CALLTIPSETPOSITION:
+		ct.SetPosition(wParam != 0);
+		InvalidateStyleRedraw();
+		break;
+
 	case SCI_USEPOPUP:
 		displayPopupMenu = wParam != 0;
 		break;
diff --git a/plugins/scintilla/scintilla/ScintillaBase.h b/plugins/scintilla/scintilla/ScintillaBase.h
index 2035108..e143f02 100644
--- a/plugins/scintilla/scintilla/ScintillaBase.h
+++ b/plugins/scintilla/scintilla/ScintillaBase.h
@@ -59,8 +59,6 @@ protected:
 	virtual void Initialise() = 0;
 	virtual void Finalise() = 0;
 
-	virtual void RefreshColourPalette(Palette &pal, bool want);
-
 	virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
 	void Command(int cmdId);
 	virtual void CancelModes();
diff --git a/plugins/scintilla/scintilla/ScintillaGTK.cxx b/plugins/scintilla/scintilla/ScintillaGTK.cxx
index 6f1f92f..b7d3fd2 100644
--- a/plugins/scintilla/scintilla/ScintillaGTK.cxx
+++ b/plugins/scintilla/scintilla/ScintillaGTK.cxx
@@ -74,8 +74,6 @@
 #define IS_WIDGET_VISIBLE(w) (GTK_WIDGET_VISIBLE(w))
 #endif
 
-#define USE_CAIRO 1
-
 static GdkWindow *WindowFromWidget(GtkWidget *w) {
 #if GTK_CHECK_VERSION(3,0,0)
 	return gtk_widget_get_window(w);
@@ -100,10 +98,6 @@ static GdkWindow *PWindow(const Window &w) {
 #pragma warning(disable: 4505)
 #endif
 
-#if GTK_CHECK_VERSION(2,6,0)
-#define USE_GTK_CLIPBOARD
-#endif
-
 #define OBJECT_CLASS GObjectClass
 
 #ifdef SCI_NAMESPACE
@@ -122,11 +116,6 @@ class ScintillaGTK : public ScintillaBase {
 	int scrollBarWidth;
 	int scrollBarHeight;
 
-	// Because clipboard access is asynchronous, copyText is created by Copy
-#ifndef USE_GTK_CLIPBOARD
-	SelectionText copyText;
-#endif
-
 	SelectionText primary;
 
 	GdkEventButton evbtn;
@@ -218,11 +207,9 @@ private:
 	void ReceivedSelection(GtkSelectionData *selection_data);
 	void ReceivedDrop(GtkSelectionData *selection_data);
 	static void GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *selected);
-#ifdef USE_GTK_CLIPBOARD
 	void StoreOnClipboard(SelectionText *clipText);
 	static void ClipboardGetSelection(GtkClipboard* clip, GtkSelectionData *selection_data, guint info, void *data);
 	static void ClipboardClearSelection(GtkClipboard* clip, void *data);
-#endif
 
 	void UnclaimSelection(GdkEventSelection *selection_event);
 	void Resize(int width, int height);
@@ -505,10 +492,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
 
 	gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY,
 	                          clipboardCopyTargets, nClipboardCopyTargets);
-#ifndef USE_GTK_CLIPBOARD
-	gtk_selection_add_targets(widget, atomClipboard,
-	                          clipboardPasteTargets, nClipboardPasteTargets);
-#endif
 }
 
 void ScintillaGTK::Realize(GtkWidget *widget) {
@@ -519,9 +502,6 @@ void ScintillaGTK::Realize(GtkWidget *widget) {
 void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
 	try {
 		gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY);
-#ifndef USE_GTK_CLIPBOARD
-		gtk_selection_clear_targets(widget, atomClipboard);
-#endif
 
 		if (IS_WIDGET_MAPPED(widget)) {
 			gtk_widget_unmap(widget);
@@ -594,7 +574,7 @@ void ScintillaGTK::UnMapThis() {
 #else
 		GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED);
 #endif
-		DropGraphics();
+		DropGraphics(false);
 		gdk_window_hide(PWindow(wMain));
 		gtk_widget_unmap(PWidget(wText));
 		gtk_widget_unmap(PWidget(scrollbarh));
@@ -765,7 +745,11 @@ void ScintillaGTK::Initialise() {
 	gtk_widget_set_double_buffered(widtxt, FALSE);
 	gtk_widget_set_size_request(widtxt, 100, 100);
 	adjustmentv = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0));
+#if GTK_CHECK_VERSION(3,0,0)
+	scrollbarv = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(adjustmentv));
+#else
 	scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv));
+#endif
 #if GTK_CHECK_VERSION(2,20,0)
 	gtk_widget_set_can_focus(PWidget(scrollbarv), FALSE);
 #else
@@ -777,7 +761,11 @@ void ScintillaGTK::Initialise() {
 	gtk_widget_show(PWidget(scrollbarv));
 
 	adjustmenth = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 101.0, 1.0, 20.0, 20.0));
+#if GTK_CHECK_VERSION(3,0,0)
+	scrollbarh = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(adjustmenth));
+#else
 	scrollbarh = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustmenth));
+#endif
 #if GTK_CHECK_VERSION(2,20,0)
 	gtk_widget_set_can_focus(PWidget(scrollbarh), FALSE);
 #else
@@ -1122,20 +1110,14 @@ void ScintillaGTK::SyncPaint(PRectangle rc) {
 	PRectangle rcClient = GetClientRectangle();
 	paintingAllText = rcPaint.Contains(rcClient);
 	if (PWindow(wText)) {
-		Surface *sw = Surface::Allocate();
+		Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
 		if (sw) {
-#if GTK_CHECK_VERSION(3,0,0)
 			cairo_t *cr = gdk_cairo_create(PWindow(wText));
 			sw->Init(cr, PWidget(wText));
-#else
-			sw->Init(PWindow(wText), PWidget(wText));
-#endif
 			Paint(sw, rc);
 			sw->Release();
 			delete sw;
-#if GTK_CHECK_VERSION(3,0,0)
 			cairo_destroy(cr);
-#endif
 		}
 	}
 	if (paintState == paintAbandoned) {
@@ -1434,30 +1416,16 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) {
 }
 
 void ScintillaGTK::CopyToClipboard(const SelectionText &selectedText) {
-#ifndef USE_GTK_CLIPBOARD
-	copyText.Copy(selectedText);
-	gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
-				atomClipboard,
-				GDK_CURRENT_TIME);
-#else
 	SelectionText *clipText = new SelectionText();
 	clipText->Copy(selectedText);
 	StoreOnClipboard(clipText);
-#endif
 }
 
 void ScintillaGTK::Copy() {
 	if (!sel.Empty()) {
-#ifndef USE_GTK_CLIPBOARD
-		CopySelectionRange(&copyText);
-		gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
-		                        atomClipboard,
-		                        GDK_CURRENT_TIME);
-#else
 		SelectionText *clipText = new SelectionText();
 		CopySelectionRange(clipText);
 		StoreOnClipboard(clipText);
-#endif
 #if PLAT_GTK_WIN32
 		if (sel.IsRectangular()) {
 			::OpenClipboard(NULL);
@@ -1717,7 +1685,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
 #endif
 }
 
-#ifdef USE_GTK_CLIPBOARD
 void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) {
 	GtkClipboard *clipBoard =
 		gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
@@ -1738,7 +1705,6 @@ void ScintillaGTK::ClipboardClearSelection(GtkClipboard *, void *data) {
 	SelectionText *obj = static_cast<SelectionText*>(data);
 	delete obj;
 }
-#endif
 
 void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) {
 	try {
@@ -2312,28 +2278,10 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose)
 		PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
 		pango_layout_set_attributes(layout, attrs);
 
-#ifdef USE_CAIRO
 		cairo_t *context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(WindowFromWidget(widget)));
 		cairo_move_to(context, 0, 0);
 		pango_cairo_show_layout(context, layout);
 		cairo_destroy(context);
-#else
-		GdkGC *gc = gdk_gc_new(widget->window);
-		GdkColor color[2] = {   {0, 0x0000, 0x0000, 0x0000},
-			{0, 0xffff, 0xffff, 0xffff}
-		};
-		gdk_colormap_alloc_color(gdk_colormap_get_system(), color, FALSE, TRUE);
-		gdk_colormap_alloc_color(gdk_colormap_get_system(), color + 1, FALSE, TRUE);
-
-		gdk_gc_set_foreground(gc, color + 1);
-		gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y,
-		        ose->area.width, ose->area.height);
-
-		gdk_gc_set_foreground(gc, color);
-		gdk_gc_set_background(gc, color + 1);
-		gdk_draw_layout(widget->window, gc, 0, 0, layout);
-		g_object_unref(gc);
-#endif
 		g_free(str);
 		pango_attr_list_unref(attrs);
 		g_object_unref(layout);
@@ -2483,7 +2431,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
 		rcPaint.bottom = y2;
 		PRectangle rcClient = GetClientRectangle();
 		paintingAllText = rcPaint.Contains(rcClient);
-		Surface *surfaceWindow = Surface::Allocate();
+		Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
 		if (surfaceWindow) {
 			surfaceWindow->Init(cr, PWidget(wText));
 			Paint(surfaceWindow, rcPaint);
@@ -2544,12 +2492,14 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
 		rgnUpdate = gdk_region_copy(ose->region);
 		PRectangle rcClient = GetClientRectangle();
 		paintingAllText = rcPaint.Contains(rcClient);
-		Surface *surfaceWindow = Surface::Allocate();
+		Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
 		if (surfaceWindow) {
-			surfaceWindow->Init(PWindow(wText), PWidget(wText));
+			cairo_t *cr = gdk_cairo_create(PWindow(wText));
+			surfaceWindow->Init(cr, PWidget(wText));
 			Paint(surfaceWindow, rcPaint);
 			surfaceWindow->Release();
 			delete surfaceWindow;
+			cairo_destroy(cr);
 		}
 		if (paintState == paintAbandoned) {
 			// Painting area was insufficient to cover new styling or brace highlight positions
@@ -2640,11 +2590,6 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget,
 			}
 			sciThis->GetSelection(selection_data, info, &sciThis->primary);
 		}
-#ifndef USE_GTK_CLIPBOARD
-		else {
-			sciThis->GetSelection(selection_data, info, &sciThis->copyText);
-		}
-#endif
 	} catch (...) {
 		sciThis->errorStatus = SC_STATUS_FAILURE;
 	}
@@ -2841,7 +2786,7 @@ gboolean ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, Scintil
 
 gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
 	try {
-		Surface *surfaceWindow = Surface::Allocate();
+		Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
 		if (surfaceWindow) {
 			surfaceWindow->Init(cr, widget);
 			surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
@@ -2860,14 +2805,16 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
 
 gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) {
 	try {
-		Surface *surfaceWindow = Surface::Allocate();
+		Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
 		if (surfaceWindow) {
-			surfaceWindow->Init(WindowFromWidget(widget), widget);
+			cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget));
+			surfaceWindow->Init(cr, widget);
 			surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
 			surfaceWindow->SetDBCSMode(ctip->codePage);
 			ctip->PaintCT(surfaceWindow);
 			surfaceWindow->Release();
 			delete surfaceWindow;
+			cairo_destroy(cr);
 		}
 	} catch (...) {
 		// No pointer back to Scintilla to save status
diff --git a/plugins/scintilla/scintilla/Style.cxx b/plugins/scintilla/scintilla/Style.cxx
index fc250f0..ed30f55 100644
--- a/plugins/scintilla/scintilla/Style.cxx
+++ b/plugins/scintilla/scintilla/Style.cxx
@@ -33,7 +33,7 @@ void FontAlias::ClearFont() {
 }
 
 bool FontSpecification::EqualTo(const FontSpecification &other) const {
-	return bold == other.bold &&
+	return weight == other.weight &&
 	       italic == other.italic &&
 	       size == other.size &&
 	       characterSet == other.characterSet &&
@@ -56,18 +56,18 @@ void FontMeasurements::Clear() {
 
 Style::Style() : FontSpecification() {
 	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
-	      Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
-	      false, false, false, false, caseMixed, true, true, false);
+	      Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
+	      SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
 }
 
 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
 	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
 	      0, 0, 0,
-	      false, false, false, false, caseMixed, true, true, false);
-	fore.desired = source.fore.desired;
-	back.desired = source.back.desired;
+	      SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
+	fore = source.fore;
+	back = source.back;
 	characterSet = source.characterSet;
-	bold = source.bold;
+	weight = source.weight;
 	italic = source.italic;
 	size = source.size;
 	eolFilled = source.eolFilled;
@@ -86,11 +86,11 @@ Style &Style::operator=(const Style &source) {
 		return * this;
 	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
 	      0, 0, SC_CHARSET_DEFAULT,
-	      false, false, false, false, caseMixed, true, true, false);
-	fore.desired = source.fore.desired;
-	back.desired = source.back.desired;
+	      SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
+	fore = source.fore;
+	back = source.back;
 	characterSet = source.characterSet;
-	bold = source.bold;
+	weight = source.weight;
 	italic = source.italic;
 	size = source.size;
 	eolFilled = source.eolFilled;
@@ -103,13 +103,13 @@ Style &Style::operator=(const Style &source) {
 
 void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
         const char *fontName_, int characterSet_,
-        bool bold_, bool italic_, bool eolFilled_,
+        int weight_, bool italic_, bool eolFilled_,
         bool underline_, ecaseForced caseForce_,
         bool visible_, bool changeable_, bool hotspot_) {
-	fore.desired = fore_;
-	back.desired = back_;
+	fore = fore_;
+	back = back_;
 	characterSet = characterSet_;
-	bold = bold_;
+	weight = weight_;
 	italic = italic_;
 	size = size_;
 	fontName = fontName_;
@@ -125,12 +125,12 @@ void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
 
 void Style::ClearTo(const Style &source) {
 	Clear(
-	    source.fore.desired,
-	    source.back.desired,
+	    source.fore,
+	    source.back,
 	    source.size,
 	    source.fontName,
 	    source.characterSet,
-	    source.bold,
+	    source.weight,
 	    source.italic,
 	    source.eolFilled,
 	    source.underline,
diff --git a/plugins/scintilla/scintilla/Style.h b/plugins/scintilla/scintilla/Style.h
index 29122b0..018ab70 100644
--- a/plugins/scintilla/scintilla/Style.h
+++ b/plugins/scintilla/scintilla/Style.h
@@ -14,16 +14,16 @@ namespace Scintilla {
 
 struct FontSpecification {
 	const char *fontName;
-	bool bold;
+	int weight;
 	bool italic;
 	int size;
 	int characterSet;
 	int extraFontFlag;
 	FontSpecification() :
 		fontName(0),
-		bold(false),
+		weight(SC_WEIGHT_NORMAL),
 		italic(false),
-		size(10),
+		size(10 * SC_FONT_SIZE_MULTIPLIER),
 		characterSet(0),
 		extraFontFlag(0) {
 	}
@@ -48,7 +48,7 @@ struct FontMeasurements {
 	unsigned int descent;
 	unsigned int externalLeading;
 	unsigned int aveCharWidth;
-	unsigned int spaceWidth;
+	XYPOSITION spaceWidth;
 	int sizeZoomed;
 	FontMeasurements();
 	void Clear();
@@ -58,8 +58,8 @@ struct FontMeasurements {
  */
 class Style : public FontSpecification, public FontMeasurements {
 public:
-	ColourPair fore;
-	ColourPair back;
+	ColourDesired fore;
+	ColourDesired back;
 	bool eolFilled;
 	bool underline;
 	enum ecaseForced {caseMixed, caseUpper, caseLower};
@@ -77,7 +77,7 @@ public:
 	void Clear(ColourDesired fore_, ColourDesired back_,
 	           int size_,
 	           const char *fontName_, int characterSet_,
-	           bool bold_, bool italic_, bool eolFilled_,
+	           int weight_, bool italic_, bool eolFilled_,
 	           bool underline_, ecaseForced caseForce_,
 		   bool visible_, bool changeable_, bool hotspot_);
 	void ClearTo(const Style &source);
diff --git a/plugins/scintilla/scintilla/ViewStyle.cxx b/plugins/scintilla/scintilla/ViewStyle.cxx
index 9ba69b1..ab3c689 100644
--- a/plugins/scintilla/scintilla/ViewStyle.cxx
+++ b/plugins/scintilla/scintilla/ViewStyle.cxx
@@ -86,14 +86,15 @@ FontRealised::~FontRealised() {
 	frNext = 0;
 }
 
-void FontRealised::Realise(Surface &surface, int zoomLevel) {
+void FontRealised::Realise(Surface &surface, int zoomLevel, int technology) {
 	PLATFORM_ASSERT(fontName);
-	sizeZoomed = size + zoomLevel;
-	if (sizeZoomed <= 2)	// Hangs if sizeZoomed <= 1
-		sizeZoomed = 2;
+	sizeZoomed = size + zoomLevel * SC_FONT_SIZE_MULTIPLIER;
+	if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER)	// Hangs if sizeZoomed <= 1
+		sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
 
-	int deviceHeight = surface.DeviceHeightFont(sizeZoomed);
-	font.Create(fontName, characterSet, deviceHeight, bold, italic, extraFontFlag);
+	float deviceHeight = surface.DeviceHeightFont(sizeZoomed);
+	FontParameters fp(fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, weight, italic, extraFontFlag, technology, characterSet);
+	font.Create(fp);
 
 	ascent = surface.Ascent(font);
 	descent = surface.Descent(font);
@@ -102,7 +103,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel) {
 	aveCharWidth = surface.AverageCharWidth(font);
 	spaceWidth = surface.WidthChar(font, ' ');
 	if (frNext) {
-		frNext->Realise(surface, zoomLevel);
+		frNext->Realise(surface, zoomLevel, technology);
 	}
 }
 
@@ -149,40 +150,40 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
 	}
 
 	selforeset = source.selforeset;
-	selforeground.desired = source.selforeground.desired;
-	selAdditionalForeground.desired = source.selAdditionalForeground.desired;
+	selforeground = source.selforeground;
+	selAdditionalForeground = source.selAdditionalForeground;
 	selbackset = source.selbackset;
-	selbackground.desired = source.selbackground.desired;
-	selAdditionalBackground.desired = source.selAdditionalBackground.desired;
-	selbackground2.desired = source.selbackground2.desired;
+	selbackground = source.selbackground;
+	selAdditionalBackground = source.selAdditionalBackground;
+	selbackground2 = source.selbackground2;
 	selAlpha = source.selAlpha;
 	selAdditionalAlpha = source.selAdditionalAlpha;
 	selEOLFilled = source.selEOLFilled;
 
 	foldmarginColourSet = source.foldmarginColourSet;
-	foldmarginColour.desired = source.foldmarginColour.desired;
+	foldmarginColour = source.foldmarginColour;
 	foldmarginHighlightColourSet = source.foldmarginHighlightColourSet;
-	foldmarginHighlightColour.desired = source.foldmarginHighlightColour.desired;
+	foldmarginHighlightColour = source.foldmarginHighlightColour;
 
 	hotspotForegroundSet = source.hotspotForegroundSet;
-	hotspotForeground.desired = source.hotspotForeground.desired;
+	hotspotForeground = source.hotspotForeground;
 	hotspotBackgroundSet = source.hotspotBackgroundSet;
-	hotspotBackground.desired = source.hotspotBackground.desired;
+	hotspotBackground = source.hotspotBackground;
 	hotspotUnderline = source.hotspotUnderline;
 	hotspotSingleLine = source.hotspotSingleLine;
 
 	whitespaceForegroundSet = source.whitespaceForegroundSet;
-	whitespaceForeground.desired = source.whitespaceForeground.desired;
+	whitespaceForeground = source.whitespaceForeground;
 	whitespaceBackgroundSet = source.whitespaceBackgroundSet;
-	whitespaceBackground.desired = source.whitespaceBackground.desired;
-	selbar.desired = source.selbar.desired;
-	selbarlight.desired = source.selbarlight.desired;
-	caretcolour.desired = source.caretcolour.desired;
-	additionalCaretColour.desired = source.additionalCaretColour.desired;
+	whitespaceBackground = source.whitespaceBackground;
+	selbar = source.selbar;
+	selbarlight = source.selbarlight;
+	caretcolour = source.caretcolour;
+	additionalCaretColour = source.additionalCaretColour;
 	showCaretLineBackground = source.showCaretLineBackground;
-	caretLineBackground.desired = source.caretLineBackground.desired;
+	caretLineBackground = source.caretLineBackground;
 	caretLineAlpha = source.caretLineAlpha;
-	edgecolour.desired = source.edgecolour.desired;
+	edgecolour = source.edgecolour;
 	edgeState = source.edgeState;
 	caretStyle = source.caretStyle;
 	caretWidth = source.caretWidth;
@@ -239,6 +240,7 @@ void ViewStyle::Init(size_t stylesSize_) {
 	indicators[2].under = false;
 	indicators[2].fore = ColourDesired(0xff, 0, 0);
 
+	technology = SC_TECHNOLOGY_DEFAULT;
 	lineHeight = 1;
 	maxAscent = 1;
 	maxDescent = 1;
@@ -246,35 +248,35 @@ void ViewStyle::Init(size_t stylesSize_) {
 	spaceWidth = 8;
 
 	selforeset = false;
-	selforeground.desired = ColourDesired(0xff, 0, 0);
-	selAdditionalForeground.desired = ColourDesired(0xff, 0, 0);
+	selforeground = ColourDesired(0xff, 0, 0);
+	selAdditionalForeground = ColourDesired(0xff, 0, 0);
 	selbackset = true;
-	selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
-	selAdditionalBackground.desired = ColourDesired(0xd7, 0xd7, 0xd7);
-	selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
+	selbackground = ColourDesired(0xc0, 0xc0, 0xc0);
+	selAdditionalBackground = ColourDesired(0xd7, 0xd7, 0xd7);
+	selbackground2 = ColourDesired(0xb0, 0xb0, 0xb0);
 	selAlpha = SC_ALPHA_NOALPHA;
 	selAdditionalAlpha = SC_ALPHA_NOALPHA;
 	selEOLFilled = false;
 
 	foldmarginColourSet = false;
-	foldmarginColour.desired = ColourDesired(0xff, 0, 0);
+	foldmarginColour = ColourDesired(0xff, 0, 0);
 	foldmarginHighlightColourSet = false;
-	foldmarginHighlightColour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+	foldmarginHighlightColour = ColourDesired(0xc0, 0xc0, 0xc0);
 
 	whitespaceForegroundSet = false;
-	whitespaceForeground.desired = ColourDesired(0, 0, 0);
+	whitespaceForeground = ColourDesired(0, 0, 0);
 	whitespaceBackgroundSet = false;
-	whitespaceBackground.desired = ColourDesired(0xff, 0xff, 0xff);
-	selbar.desired = Platform::Chrome();
-	selbarlight.desired = Platform::ChromeHighlight();
-	styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
-	styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
-	caretcolour.desired = ColourDesired(0, 0, 0);
-	additionalCaretColour.desired = ColourDesired(0x7f, 0x7f, 0x7f);
+	whitespaceBackground = ColourDesired(0xff, 0xff, 0xff);
+	selbar = Platform::Chrome();
+	selbarlight = Platform::ChromeHighlight();
+	styles[STYLE_LINENUMBER].fore = ColourDesired(0, 0, 0);
+	styles[STYLE_LINENUMBER].back = Platform::Chrome();
+	caretcolour = ColourDesired(0, 0, 0);
+	additionalCaretColour = ColourDesired(0x7f, 0x7f, 0x7f);
 	showCaretLineBackground = false;
-	caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
+	caretLineBackground = ColourDesired(0xff, 0xff, 0);
 	caretLineAlpha = SC_ALPHA_NOALPHA;
-	edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+	edgecolour = ColourDesired(0xc0, 0xc0, 0xc0);
 	edgeState = EDGE_NONE;
 	caretStyle = CARETSTYLE_LINE;
 	caretWidth = 1;
@@ -282,9 +284,9 @@ void ViewStyle::Init(size_t stylesSize_) {
 	someStylesForceCase = false;
 
 	hotspotForegroundSet = false;
-	hotspotForeground.desired = ColourDesired(0, 0, 0xff);
+	hotspotForeground = ColourDesired(0, 0, 0xff);
 	hotspotBackgroundSet = false;
-	hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff);
+	hotspotBackground = ColourDesired(0xff, 0xff, 0xff);
 	hotspotUnderline = true;
 	hotspotSingleLine = true;
 
@@ -326,39 +328,6 @@ void ViewStyle::Init(size_t stylesSize_) {
 	braceBadLightIndicator = 0;
 }
 
-void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
-	unsigned int i;
-	for (i=0; i<stylesSize; i++) {
-		pal.WantFind(styles[i].fore, want);
-		pal.WantFind(styles[i].back, want);
-	}
-	for (i=0; i<(sizeof(indicators)/sizeof(indicators[0])); i++) {
-		pal.WantFind(indicators[i].fore, want);
-	}
-	for (i=0; i<(sizeof(markers)/sizeof(markers[0])); i++) {
-		markers[i].RefreshColourPalette(pal, want);
-	}
-	pal.WantFind(selforeground, want);
-	pal.WantFind(selAdditionalForeground, want);
-	pal.WantFind(selbackground, want);
-	pal.WantFind(selAdditionalBackground, want);
-	pal.WantFind(selbackground2, want);
-
-	pal.WantFind(foldmarginColour, want);
-	pal.WantFind(foldmarginHighlightColour, want);
-
-	pal.WantFind(whitespaceForeground, want);
-	pal.WantFind(whitespaceBackground, want);
-	pal.WantFind(selbar, want);
-	pal.WantFind(selbarlight, want);
-	pal.WantFind(caretcolour, want);
-	pal.WantFind(additionalCaretColour, want);
-	pal.WantFind(caretLineBackground, want);
-	pal.WantFind(edgecolour, want);
-	pal.WantFind(hotspotForeground, want);
-	pal.WantFind(hotspotBackground, want);
-}
-
 void ViewStyle::CreateFont(const FontSpecification &fs) {
 	if (fs.fontName) {
 		for (FontRealised *cur=frFirst; cur; cur=cur->frNext) {
@@ -376,8 +345,8 @@ void ViewStyle::CreateFont(const FontSpecification &fs) {
 void ViewStyle::Refresh(Surface &surface) {
 	delete frFirst;
 	frFirst = NULL;
-	selbar.desired = Platform::Chrome();
-	selbarlight.desired = Platform::ChromeHighlight();
+	selbar = Platform::Chrome();
+	selbarlight = Platform::ChromeHighlight();
 
 	for (unsigned int i=0; i<stylesSize; i++) {
 		styles[i].extraFontFlag = extraFontFlag;
@@ -388,7 +357,7 @@ void ViewStyle::Refresh(Surface &surface) {
 		CreateFont(styles[j]);
 	}
 
-	frFirst->Realise(surface, zoomLevel);
+	frFirst->Realise(surface, zoomLevel, technology);
 
 	for (unsigned int k=0; k<stylesSize; k++) {
 		FontRealised *fr = frFirst->Find(styles[k]);
@@ -457,9 +426,9 @@ void ViewStyle::EnsureStyle(size_t index) {
 void ViewStyle::ResetDefaultStyle() {
 	styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
 	        ColourDesired(0xff,0xff,0xff),
-	        Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
+	        Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, fontNames.Save(Platform::DefaultFont()),
 	        SC_CHARSET_DEFAULT,
-	        false, false, false, false, Style::caseMixed, true, true, false);
+	        SC_WEIGHT_NORMAL, false, false, false, Style::caseMixed, true, true, false);
 }
 
 void ViewStyle::ClearStyles() {
@@ -469,11 +438,11 @@ void ViewStyle::ClearStyles() {
 			styles[i].ClearTo(styles[STYLE_DEFAULT]);
 		}
 	}
-	styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
+	styles[STYLE_LINENUMBER].back = Platform::Chrome();
 
 	// Set call tip fore/back to match the values previously set for call tips
-	styles[STYLE_CALLTIP].back.desired = ColourDesired(0xff, 0xff, 0xff);
-	styles[STYLE_CALLTIP].fore.desired = ColourDesired(0x80, 0x80, 0x80);
+	styles[STYLE_CALLTIP].back = ColourDesired(0xff, 0xff, 0xff);
+	styles[STYLE_CALLTIP].fore = ColourDesired(0x80, 0x80, 0x80);
 }
 
 void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
diff --git a/plugins/scintilla/scintilla/ViewStyle.h b/plugins/scintilla/scintilla/ViewStyle.h
index b038a9b..3803a6c 100644
--- a/plugins/scintilla/scintilla/ViewStyle.h
+++ b/plugins/scintilla/scintilla/ViewStyle.h
@@ -48,7 +48,7 @@ public:
 	FontRealised *frNext;
 	FontRealised(const FontSpecification &fs);
 	virtual ~FontRealised();
-	void Realise(Surface &surface, int zoomLevel);
+	void Realise(Surface &surface, int zoomLevel, int technology);
 	FontRealised *Find(const FontSpecification &fs);
 	void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
 };
@@ -67,35 +67,36 @@ public:
 	Style *styles;
 	LineMarker markers[MARKER_MAX + 1];
 	Indicator indicators[INDIC_MAX + 1];
+	int technology;
 	int lineHeight;
 	unsigned int maxAscent;
 	unsigned int maxDescent;
-	unsigned int aveCharWidth;
-	unsigned int spaceWidth;
+	XYPOSITION aveCharWidth;
+	XYPOSITION spaceWidth;
 	bool selforeset;
-	ColourPair selforeground;
-	ColourPair selAdditionalForeground;
+	ColourDesired selforeground;
+	ColourDesired selAdditionalForeground;
 	bool selbackset;
-	ColourPair selbackground;
-	ColourPair selAdditionalBackground;
-	ColourPair selbackground2;
+	ColourDesired selbackground;
+	ColourDesired selAdditionalBackground;
+	ColourDesired selbackground2;
 	int selAlpha;
 	int selAdditionalAlpha;
 	bool selEOLFilled;
 	bool whitespaceForegroundSet;
-	ColourPair whitespaceForeground;
+	ColourDesired whitespaceForeground;
 	bool whitespaceBackgroundSet;
-	ColourPair whitespaceBackground;
-	ColourPair selbar;
-	ColourPair selbarlight;
+	ColourDesired whitespaceBackground;
+	ColourDesired selbar;
+	ColourDesired selbarlight;
 	bool foldmarginColourSet;
-	ColourPair foldmarginColour;
+	ColourDesired foldmarginColour;
 	bool foldmarginHighlightColourSet;
-	ColourPair foldmarginHighlightColour;
+	ColourDesired foldmarginHighlightColour;
 	bool hotspotForegroundSet;
-	ColourPair hotspotForeground;
+	ColourDesired hotspotForeground;
 	bool hotspotBackgroundSet;
-	ColourPair hotspotBackground;
+	ColourDesired hotspotBackground;
 	bool hotspotUnderline;
 	bool hotspotSingleLine;
 	/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
@@ -112,12 +113,12 @@ public:
 	IndentView viewIndentationGuides;
 	bool viewEOL;
 	bool showMarkedLines;
-	ColourPair caretcolour;
-	ColourPair additionalCaretColour;
+	ColourDesired caretcolour;
+	ColourDesired additionalCaretColour;
 	bool showCaretLineBackground;
-	ColourPair caretLineBackground;
+	ColourDesired caretLineBackground;
 	int caretLineAlpha;
-	ColourPair edgecolour;
+	ColourDesired edgecolour;
 	int edgeState;
 	int caretStyle;
 	int caretWidth;
@@ -139,7 +140,6 @@ public:
 	~ViewStyle();
 	void Init(size_t stylesSize_=64);
 	void CreateFont(const FontSpecification &fs);
-	void RefreshColourPalette(Palette &pal, bool want);
 	void Refresh(Surface &surface);
 	void AllocStyles(size_t sizeNew);
 	void EnsureStyle(size_t index);
diff --git a/plugins/scintilla/scintilla/XPM.cxx b/plugins/scintilla/scintilla/XPM.cxx
index f0277c6..b63eb15 100644
--- a/plugins/scintilla/scintilla/XPM.cxx
+++ b/plugins/scintilla/scintilla/XPM.cxx
@@ -8,10 +8,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4786)
-#endif
-
 #include <vector>
 #include <map>
 
@@ -46,11 +42,11 @@ static size_t MeasureLength(const char *s) {
 }
 
 ColourDesired XPM::ColourDesiredFromCode(int ch) const {
-	return colourCodeTable[ch]->desired;
+	return *colourCodeTable[ch];
 }
 
-ColourAllocated XPM::ColourFromCode(int ch) const {
-	return colourCodeTable[ch]->allocated;
+ColourDesired XPM::ColourFromCode(int ch) const {
+	return *colourCodeTable[ch];
 #ifdef SLOW
 	for (int i=0; i<nColours; i++) {
 		if (codes[i] == ch) {
@@ -124,7 +120,7 @@ void XPM::Init(const char *const *linesForm) {
 		return;
 	}
 	codes = new char[nColours];
-	colours = new ColourPair[nColours];
+	colours = new ColourDesired[nColours];
 
 	int strings = 1+height+nColours;
 	lines = new char *[strings];
@@ -151,9 +147,9 @@ void XPM::Init(const char *const *linesForm) {
 		codes[c] = colourDef[0];
 		colourDef += 4;
 		if (*colourDef == '#') {
-			colours[c].desired.Set(colourDef);
+			colours[c].Set(colourDef);
 		} else {
-			colours[c].desired = ColourDesired(0xff, 0xff, 0xff);
+			colours[c] = ColourDesired(0xff, 0xff, 0xff);
 			codeTransparent = codes[c];
 		}
 		colourCodeTable[static_cast<unsigned char>(codes[c])] = &(colours[c]);
@@ -171,24 +167,6 @@ void XPM::Clear() {
 	lines = 0;
 }
 
-void XPM::RefreshColourPalette(Palette &pal, bool want) {
-	if (!data || !codes || !colours || !lines) {
-		return;
-	}
-	for (int i=0; i<nColours; i++) {
-		pal.WantFind(colours[i], want);
-	}
-}
-
-void XPM::CopyDesiredColours() {
-	if (!data || !codes || !colours || !lines) {
-		return;
-	}
-	for (int i=0; i<nColours; i++) {
-		colours[i].Copy();
-	}
-}
-
 void XPM::Draw(Surface *surface, PRectangle &rc) {
 	if (!data || !codes || !colours || !lines) {
 		return;
@@ -296,7 +274,6 @@ void XPMSet::Add(int ident, const char *textForm) {
 	for (int i = 0; i < len; i++) {
 		if (set[i]->GetId() == ident) {
 			set[i]->Init(textForm);
-			set[i]->CopyDesiredColours();
 			return;
 		}
 	}
@@ -305,7 +282,6 @@ void XPMSet::Add(int ident, const char *textForm) {
 	XPM *pxpm = new XPM(textForm);
 	if (pxpm) {
 		pxpm->SetId(ident);
-		pxpm->CopyDesiredColours();
 		if (len == maximum) {
 			maximum += 64;
 			XPM **setNew = new XPM *[maximum];
diff --git a/plugins/scintilla/scintilla/XPM.h b/plugins/scintilla/scintilla/XPM.h
index b9c7308..77ab080 100644
--- a/plugins/scintilla/scintilla/XPM.h
+++ b/plugins/scintilla/scintilla/XPM.h
@@ -23,12 +23,12 @@ class XPM {
 	char *data;
 	char codeTransparent;
 	char *codes;
-	ColourPair *colours;
+	ColourDesired *colours;
 	ColourDesired ColourDesiredFromCode(int ch) const;
-	ColourAllocated ColourFromCode(int ch) const;
+	ColourDesired ColourFromCode(int ch) const;
 	void FillRun(Surface *surface, int code, int startX, int y, int x);
 	char **lines;
-	ColourPair *colourCodeTable[256];
+	ColourDesired *colourCodeTable[256];
 public:
 	XPM(const char *textForm);
 	XPM(const char *const *linesForm);
@@ -36,10 +36,6 @@ public:
 	void Init(const char *textForm);
 	void Init(const char *const *linesForm);
 	void Clear();
-	/// Similar to same named method in ViewStyle:
-	void RefreshColourPalette(Palette &pal, bool want);
-	/// No palette used, so just copy the desired colours to the allocated colours
-	void CopyDesiredColours();
 	/// Decompose image into runs and use FillRectangle for each run
 	void Draw(Surface *surface, PRectangle &rc);
 	char **InLinesForm() { return lines; }
diff --git a/plugins/scintilla/scintilla/include/Face.py b/plugins/scintilla/scintilla/include/Face.py
old mode 100755
new mode 100644
index 52c9b8d..97b700d
--- a/plugins/scintilla/scintilla/include/Face.py
+++ b/plugins/scintilla/scintilla/include/Face.py
@@ -72,7 +72,7 @@ class Face:
 							"Category": currentCategory, "Comment": currentComment
 						}
 						if value in self.values:
-							raise "Duplicate value " + value + " " + name
+							raise Exception("Duplicate value " + value + " " + name)
 						self.values[value] = 1
 						self.order.append(name)
 					elif featureType == "evt":
@@ -84,7 +84,7 @@ class Face:
 							"Category": currentCategory, "Comment": currentComment
 						}
 						if value in self.events:
-							raise "Duplicate event " + value + " " + name
+							raise Exception("Duplicate event " + value + " " + name)
 						self.events[value] = 1
 						self.order.append(name)
 					elif featureType == "cat":
@@ -94,7 +94,7 @@ class Face:
 							name, value = featureVal.split("=", 1)
 						except ValueError:
 							print("Failure %s" % featureVal)
-							raise
+							raise Exception()
 						self.features[name] = { 
 							"FeatureType": featureType, 
 							"Category": currentCategory, 
diff --git a/plugins/scintilla/scintilla/include/ILexer.h b/plugins/scintilla/scintilla/include/ILexer.h
index b119ff6..e08b870 100644
--- a/plugins/scintilla/scintilla/include/ILexer.h
+++ b/plugins/scintilla/scintilla/include/ILexer.h
@@ -62,6 +62,14 @@ public:
 	virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0;
 };
 
+class ILoader {
+public:
+	virtual int SCI_METHOD Release() = 0;
+	// Returns a status code from SC_STATUS_*
+	virtual int SCI_METHOD AddData(char *data, int length) = 0;
+	virtual void * SCI_METHOD ConvertToDocument() = 0;
+};
+
 #ifdef SCI_NAMESPACE
 }
 #endif
diff --git a/plugins/scintilla/scintilla/include/Makefile.am b/plugins/scintilla/scintilla/include/Makefile.am
index d035009..109019b 100644
--- a/plugins/scintilla/scintilla/include/Makefile.am
+++ b/plugins/scintilla/scintilla/include/Makefile.am
@@ -2,16 +2,11 @@
 ## Process this file with automake to produce Makefile.in
 
 scintilla_AM_CPPFLAGS = \
-	Accessor.h \
 	ILexer.h \
-	KeyWords.h \
 	Platform.h \
-	PropSet.h \
 	SciLexer.h \
 	Scintilla.h \
-	ScintillaWidget.h \
-	WindowAccessor.h \
-	SString.h
+	ScintillaWidget.h
 
 EXTRA_DIST = $(scintilla_AM_CPPFLAGS) \
 	Face.py \
diff --git a/plugins/scintilla/scintilla/include/Platform.h b/plugins/scintilla/scintilla/include/Platform.h
index b0f3de0..654c487 100644
--- a/plugins/scintilla/scintilla/include/Platform.h
+++ b/plugins/scintilla/scintilla/include/Platform.h
@@ -59,6 +59,10 @@
 namespace Scintilla {
 #endif
 
+typedef float XYPOSITION;
+typedef double XYACCUMULATOR;
+//#define XYPOSITION int
+
 // Underlying the implementation of the platform classes are platform specific types.
 // Sometimes these need to be passed around by client code so they are defined here
 
@@ -76,10 +80,10 @@ typedef void *IdlerID;
  */
 class Point {
 public:
-	int x;
-	int y;
+	XYPOSITION x;
+	XYPOSITION y;
 
-	explicit Point(int x_=0, int y_=0) : x(x_), y(y_) {
+	explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
 	}
 
 	// Other automatically defined methods (assignment, copy constructor, destructor) are fine
@@ -94,12 +98,12 @@ public:
  */
 class PRectangle {
 public:
-	int left;
-	int top;
-	int right;
-	int bottom;
+	XYPOSITION left;
+	XYPOSITION top;
+	XYPOSITION right;
+	XYPOSITION bottom;
 
-	PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) :
+	PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
 		left(left_), top(top_), right(right_), bottom(bottom_) {
 	}
 
@@ -121,32 +125,20 @@ public:
 		return (right > other.left) && (left < other.right) &&
 			(bottom > other.top) && (top < other.bottom);
 	}
-	void Move(int xDelta, int yDelta) {
+	void Move(XYPOSITION xDelta, XYPOSITION yDelta) {
 		left += xDelta;
 		top += yDelta;
 		right += xDelta;
 		bottom += yDelta;
 	}
-	int Width() { return right - left; }
-	int Height() { return bottom - top; }
+	XYPOSITION Width() { return right - left; }
+	XYPOSITION Height() { return bottom - top; }
 	bool Empty() {
 		return (Height() <= 0) || (Width() <= 0);
 	}
 };
 
 /**
- * In some circumstances, including Win32 in paletted mode and GTK+, each colour
- * must be allocated before use. The desired colours are held in the ColourDesired class,
- * and after allocation the allocation entry is stored in the ColourAllocated class. In other
- * circumstances, such as Win32 in true colour mode, the allocation process just copies
- * the RGB values from the desired to the allocated class.
- * As each desired colour requires allocation before it can be used, the ColourPair class
- * holds both a ColourDesired and a ColourAllocated
- * The Palette class is responsible for managing the palette of colours which contains a
- * list of ColourPair objects and performs the allocation.
- */
-
-/**
  * Holds a desired RGB colour.
  */
 class ColourDesired {
@@ -211,82 +203,39 @@ public:
 };
 
 /**
- * Holds an allocated RGB colour which may be an approximation to the desired colour.
- */
-class ColourAllocated {
-	long coAllocated;
-
-public:
-
-	ColourAllocated(long lcol=0) {
-		coAllocated = lcol;
-	}
-
-	void Set(long lcol) {
-		coAllocated = lcol;
-	}
-
-	long AsLong() const {
-		return coAllocated;
-	}
-};
-
-/**
- * Colour pairs hold a desired colour and an allocated colour.
+ * Font management.
  */
-struct ColourPair {
-	ColourDesired desired;
-	ColourAllocated allocated;
 
-	ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
-		desired = desired_;
-		allocated.Set(desired.AsLong());
-	}
-	void Copy() {
-		allocated.Set(desired.AsLong());
+struct FontParameters {
+	const char *faceName;
+	float size;
+	int weight;
+	bool italic;
+	int extraFontFlag;
+	int technology;
+	int characterSet;
+
+	FontParameters(
+		const char *faceName_,
+		float size_=10,
+		int weight_=400,
+		bool italic_=false,
+		int extraFontFlag_=0,
+		int technology_=0,
+		int characterSet_=0) :
+
+		faceName(faceName_),
+		size(size_),
+		weight(weight_),
+		italic(italic_),
+		extraFontFlag(extraFontFlag_),
+		technology(technology_),
+		characterSet(characterSet_)
+	{
 	}
-};
 
-class Window;	// Forward declaration for Palette
-
-/**
- * Colour palette management.
- */
-class Palette {
-	int used;
-	int size;
-	ColourPair *entries;
-#if PLAT_GTK
-	void *allocatedPalette; // GdkColor *
-	int allocatedLen;
-#endif
-	// Private so Palette objects can not be copied
-	Palette(const Palette &);
-	Palette &operator=(const Palette &);
-public:
-#if PLAT_WIN
-	void *hpal;
-#endif
-	bool allowRealization;
-
-	Palette();
-	~Palette();
-
-	void Release();
-
-	/**
-	 * This method either adds a colour to the list of wanted colours (want==true)
-	 * or retrieves the allocated colour back to the ColourPair.
-	 * This is one method to make it easier to keep the code for wanting and retrieving in sync.
-	 */
-	void WantFind(ColourPair &cp, bool want);
-
-	void Allocate(Window &w);
 };
 
-/**
- * Font management.
- */
 class Font {
 protected:
 	FontID fid;
@@ -300,8 +249,7 @@ public:
 	Font();
 	virtual ~Font();
 
-	virtual void Create(const char *faceName, int characterSet, int size,
-		bool bold, bool italic, int extraFontFlag=0);
+	virtual void Create(const FontParameters &fp);
 	virtual void Release();
 
 	FontID GetID() { return fid; }
@@ -325,7 +273,7 @@ private:
 public:
 	Surface() {}
 	virtual ~Surface() {}
-	static Surface *Allocate();
+	static Surface *Allocate(int technology);
 
 	virtual void Init(WindowID wid)=0;
 	virtual void Init(SurfaceID sid, WindowID wid)=0;
@@ -333,36 +281,35 @@ public:
 
 	virtual void Release()=0;
 	virtual bool Initialised()=0;
-	virtual void PenColour(ColourAllocated fore)=0;
+	virtual void PenColour(ColourDesired fore)=0;
 	virtual int LogPixelsY()=0;
 	virtual int DeviceHeightFont(int points)=0;
 	virtual void MoveTo(int x_, int y_)=0;
 	virtual void LineTo(int x_, int y_)=0;
-	virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
-	virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
-	virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
+	virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0;
+	virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+	virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
 	virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
-	virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
-	virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
-		ColourAllocated outline, int alphaOutline, int flags)=0;
+	virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+	virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+		ColourDesired outline, int alphaOutline, int flags)=0;
 	virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
-	virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+	virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
 	virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
 
-	virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
-	virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
-	virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0;
-	virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
-	virtual int WidthText(Font &font_, const char *s, int len)=0;
-	virtual int WidthChar(Font &font_, char ch)=0;
-	virtual int Ascent(Font &font_)=0;
-	virtual int Descent(Font &font_)=0;
-	virtual int InternalLeading(Font &font_)=0;
-	virtual int ExternalLeading(Font &font_)=0;
-	virtual int Height(Font &font_)=0;
-	virtual int AverageCharWidth(Font &font_)=0;
-
-	virtual int SetPalette(Palette *pal, bool inBackGround)=0;
+	virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+	virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+	virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
+	virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
+	virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;
+	virtual XYPOSITION WidthChar(Font &font_, char ch)=0;
+	virtual XYPOSITION Ascent(Font &font_)=0;
+	virtual XYPOSITION Descent(Font &font_)=0;
+	virtual XYPOSITION InternalLeading(Font &font_)=0;
+	virtual XYPOSITION ExternalLeading(Font &font_)=0;
+	virtual XYPOSITION Height(Font &font_)=0;
+	virtual XYPOSITION AverageCharWidth(Font &font_)=0;
+
 	virtual void SetClip(PRectangle rc)=0;
 	virtual void FlushCachedState()=0;
 
@@ -439,7 +386,7 @@ public:
 	static ListBox *Allocate();
 
 	virtual void SetFont(Font &font)=0;
-	virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0;
+	virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
 	virtual void SetAverageCharWidth(int width)=0;
 	virtual void SetVisibleRows(int rows)=0;
 	virtual int GetVisibleRows() const=0;
diff --git a/plugins/scintilla/scintilla/include/SciLexer.h b/plugins/scintilla/scintilla/include/SciLexer.h
index e8805f2..2758b92 100644
--- a/plugins/scintilla/scintilla/include/SciLexer.h
+++ b/plugins/scintilla/scintilla/include/SciLexer.h
@@ -114,6 +114,9 @@
 #define SCLEX_TXT2TAGS 99
 #define SCLEX_A68K 100
 #define SCLEX_MODULA 101
+#define SCLEX_COFFEESCRIPT 102
+#define SCLEX_TCMD 103
+#define SCLEX_AVS 104
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -153,6 +156,7 @@
 #define SCE_C_GLOBALCLASS 19
 #define SCE_C_STRINGRAW 20
 #define SCE_C_TRIPLEVERBATIM 21
+#define SCE_C_HASHQUOTEDSTRING 22
 #define SCE_D_DEFAULT 0
 #define SCE_D_COMMENT 1
 #define SCE_D_COMMENTLINE 2
@@ -477,6 +481,17 @@
 #define SCE_BAT_COMMAND 5
 #define SCE_BAT_IDENTIFIER 6
 #define SCE_BAT_OPERATOR 7
+#define SCE_TCMD_DEFAULT 0
+#define SCE_TCMD_COMMENT 1
+#define SCE_TCMD_WORD 2
+#define SCE_TCMD_LABEL 3
+#define SCE_TCMD_HIDE 4
+#define SCE_TCMD_COMMAND 5
+#define SCE_TCMD_IDENTIFIER 6
+#define SCE_TCMD_OPERATOR 7
+#define SCE_TCMD_ENVIRONMENT 8
+#define SCE_TCMD_EXPANSION 9
+#define SCE_TCMD_CLABEL 10
 #define SCE_MAKE_DEFAULT 0
 #define SCE_MAKE_COMMENT 1
 #define SCE_MAKE_PREPROCESSOR 2
@@ -663,6 +678,7 @@
 #define SCE_CSS_EXTENDED_PSEUDOCLASS 20
 #define SCE_CSS_EXTENDED_PSEUDOELEMENT 21
 #define SCE_CSS_MEDIA 22
+#define SCE_CSS_VARIABLE 23
 #define SCE_POV_DEFAULT 0
 #define SCE_POV_COMMENT 1
 #define SCE_POV_COMMENTLINE 2
@@ -1476,6 +1492,47 @@
 #define SCE_MODULA_PRGKEY 15
 #define SCE_MODULA_OPERATOR 16
 #define SCE_MODULA_BADSTR 17
+#define SCE_COFFEESCRIPT_DEFAULT 0
+#define SCE_COFFEESCRIPT_COMMENT 1
+#define SCE_COFFEESCRIPT_COMMENTLINE 2
+#define SCE_COFFEESCRIPT_COMMENTDOC 3
+#define SCE_COFFEESCRIPT_NUMBER 4
+#define SCE_COFFEESCRIPT_WORD 5
+#define SCE_COFFEESCRIPT_STRING 6
+#define SCE_COFFEESCRIPT_CHARACTER 7
+#define SCE_COFFEESCRIPT_UUID 8
+#define SCE_COFFEESCRIPT_PREPROCESSOR 9
+#define SCE_COFFEESCRIPT_OPERATOR 10
+#define SCE_COFFEESCRIPT_IDENTIFIER 11
+#define SCE_COFFEESCRIPT_STRINGEOL 12
+#define SCE_COFFEESCRIPT_VERBATIM 13
+#define SCE_COFFEESCRIPT_REGEX 14
+#define SCE_COFFEESCRIPT_COMMENTLINEDOC 15
+#define SCE_COFFEESCRIPT_WORD2 16
+#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORD 17
+#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR 18
+#define SCE_COFFEESCRIPT_GLOBALCLASS 19
+#define SCE_COFFEESCRIPT_STRINGRAW 20
+#define SCE_COFFEESCRIPT_TRIPLEVERBATIM 21
+#define SCE_COFFEESCRIPT_HASHQUOTEDSTRING 22
+#define SCE_COFFEESCRIPT_COMMENTBLOCK 22
+#define SCE_COFFEESCRIPT_VERBOSE_REGEX 23
+#define SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24
+#define SCE_AVS_DEFAULT 0
+#define SCE_AVS_COMMENTBLOCK 1
+#define SCE_AVS_COMMENTBLOCKN 2
+#define SCE_AVS_COMMENTLINE 3
+#define SCE_AVS_NUMBER 4
+#define SCE_AVS_OPERATOR 5
+#define SCE_AVS_IDENTIFIER 6
+#define SCE_AVS_STRING 7
+#define SCE_AVS_TRIPLESTRING 8
+#define SCE_AVS_KEYWORD 9
+#define SCE_AVS_FILTER 10
+#define SCE_AVS_PLUGIN 11
+#define SCE_AVS_FUNCTION 12
+#define SCE_AVS_CLIPPROP 13
+#define SCE_AVS_USERDFN 14
 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
 
 #endif
diff --git a/plugins/scintilla/scintilla/include/Scintilla.h b/plugins/scintilla/scintilla/include/Scintilla.h
index bc4927a..474416c 100644
--- a/plugins/scintilla/scintilla/include/Scintilla.h
+++ b/plugins/scintilla/scintilla/include/Scintilla.h
@@ -98,7 +98,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_GETTABWIDTH 2121
 #define SC_CP_UTF8 65001
 #define SCI_SETCODEPAGE 2037
-#define SCI_SETUSEPALETTE 2039
 #define MARKER_MAX 31
 #define SC_MARK_CIRCLE 0
 #define SC_MARK_ROUNDRECT 1
@@ -227,6 +226,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_STYLEGETCHANGEABLE 2492
 #define SCI_STYLEGETHOTSPOT 2493
 #define SCI_STYLESETCASE 2060
+#define SC_FONT_SIZE_MULTIPLIER 100
+#define SCI_STYLESETSIZEFRACTIONAL 2061
+#define SCI_STYLEGETSIZEFRACTIONAL 2062
+#define SC_WEIGHT_NORMAL 400
+#define SC_WEIGHT_SEMIBOLD 600
+#define SC_WEIGHT_BOLD 700
+#define SCI_STYLESETWEIGHT 2063
+#define SCI_STYLEGETWEIGHT 2064
 #define SCI_STYLESETCHARACTERSET 2066
 #define SCI_STYLESETHOTSPOT 2409
 #define SCI_SETSELFORE 2067
@@ -322,6 +329,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_GETLINEINDENTATION 2127
 #define SCI_GETLINEINDENTPOSITION 2128
 #define SCI_GETCOLUMN 2129
+#define SCI_COUNTCHARACTERS 2633
 #define SCI_SETHSCROLLBAR 2130
 #define SCI_GETHSCROLLBAR 2131
 #define SC_IV_NONE 0
@@ -335,7 +343,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_GETLINEENDPOSITION 2136
 #define SCI_GETCODEPAGE 2137
 #define SCI_GETCARETFORE 2138
-#define SCI_GETUSEPALETTE 2139
 #define SCI_GETREADONLY 2140
 #define SCI_SETCURRENTPOS 2141
 #define SCI_SETSELECTIONSTART 2142
@@ -415,6 +422,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_CALLTIPSETFORE 2206
 #define SCI_CALLTIPSETFOREHLT 2207
 #define SCI_CALLTIPUSESTYLE 2212
+#define SCI_CALLTIPSETPOSITION 2213
 #define SCI_VISIBLEFROMDOCLINE 2220
 #define SCI_DOCLINEFROMVISIBLE 2221
 #define SCI_WRAPCOUNT 2235
@@ -429,6 +437,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_SHOWLINES 2226
 #define SCI_HIDELINES 2227
 #define SCI_GETLINEVISIBLE 2228
+#define SCI_GETALLLINESVISIBLE 2236
 #define SCI_SETFOLDEXPANDED 2229
 #define SCI_GETFOLDEXPANDED 2230
 #define SCI_TOGGLEFOLD 2231
@@ -825,6 +834,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_REGISTERRGBAIMAGE 2627
 #define SCI_SCROLLTOSTART 2628
 #define SCI_SCROLLTOEND 2629
+#define SC_TECHNOLOGY_DEFAULT 0
+#define SC_TECHNOLOGY_DIRECTWRITE 1
+#define SCI_SETTECHNOLOGY 2630
+#define SCI_GETTECHNOLOGY 2631
+#define SCI_CREATELOADER 2632
 #define SCI_STARTRECORD 3001
 #define SCI_STOPRECORD 3002
 #define SCI_SETLEXER 4001
@@ -1034,6 +1048,8 @@ struct SCNotification {
 #ifdef INCLUDE_DEPRECATED_FEATURES
 
 #define SC_CP_DBCS 1
+#define SCI_SETUSEPALETTE 2039
+#define SCI_GETUSEPALETTE 2139
 
 #endif
 
diff --git a/plugins/scintilla/scintilla/include/Scintilla.iface b/plugins/scintilla/scintilla/include/Scintilla.iface
index 9530f42..f70266e 100644
--- a/plugins/scintilla/scintilla/include/Scintilla.iface
+++ b/plugins/scintilla/scintilla/include/Scintilla.iface
@@ -228,10 +228,6 @@ val SC_CP_UTF8=65001
 # The SC_CP_UTF8 value can be used to enter Unicode mode.
 set void SetCodePage=2037(int codePage,)
 
-# In palette mode, Scintilla uses the environment's palette calls to display
-# more colours. This may lead to ugly displays.
-set void SetUsePalette=2039(bool usePalette,)
-
 enu MarkerSymbol=SC_MARK_
 val MARKER_MAX=31
 val SC_MARK_CIRCLE=0
@@ -482,6 +478,25 @@ get bool StyleGetHotSpot=2493(int style,)
 # Set a style to be mixed case, or to force upper or lower case.
 set void StyleSetCase=2060(int style, int caseForce)
 
+val SC_FONT_SIZE_MULTIPLIER=100
+
+# Set the size of characters of a style. Size is in points multiplied by 100.
+set void StyleSetSizeFractional=2061(int style, int caseForce)
+
+# Get the size of characters of a style in points multiplied by 100
+get int StyleGetSizeFractional=2062(int style,)
+
+enu FontWeight=SC_WEIGHT_
+val SC_WEIGHT_NORMAL=400
+val SC_WEIGHT_SEMIBOLD=600
+val SC_WEIGHT_BOLD=700
+
+# Set the weight of characters of a style.
+set void StyleSetWeight=2063(int style, int weight)
+
+# Get the weight of characters of a style.
+get int StyleGetWeight=2064(int style,)
+
 # Set the character set of the font in a style.
 set void StyleSetCharacterSet=2066(int style, int characterSet)
 
@@ -748,9 +763,11 @@ get position GetLineIndentPosition=2128(int line,)
 # Retrieve the column number of a position, taking tab width into account.
 get int GetColumn=2129(position pos,)
 
+# Count characters between two positions.
+fun int CountCharacters=2633(int startPos, int endPos)
+
 # Show or hide the horizontal scroll bar.
 set void SetHScrollBar=2130(bool show,)
-
 # Is the horizontal scroll bar visible?
 get bool GetHScrollBar=2131(,)
 
@@ -782,9 +799,6 @@ get int GetCodePage=2137(,)
 # Get the foreground colour of the caret.
 get colour GetCaretFore=2138(,)
 
-# In palette mode?
-get bool GetUsePalette=2139(,)
-
 # In read-only mode?
 get bool GetReadOnly=2140(,)
 
@@ -1027,6 +1041,9 @@ set void CallTipSetForeHlt=2207(colour fore,)
 # Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
 set void CallTipUseStyle=2212(int tabSize,)
 
+# Set position of calltip, above or below text.
+set void CallTipSetPosition=2213(bool above,)
+
 # Find the display line of a document line taking hidden lines into account.
 fun int VisibleFromDocLine=2220(int line,)
 
@@ -1065,6 +1082,9 @@ fun void HideLines=2227(int lineStart, int lineEnd)
 # Is a line visible?
 get bool GetLineVisible=2228(int line,)
 
+# Are all lines visible?
+get bool GetAllLinesVisible=2236(,)
+
 # Show the children of a header line.
 set void SetFoldExpanded=2229(int line, bool expanded)
 
@@ -2175,6 +2195,18 @@ fun void ScrollToStart=2628(,)
 # Scroll to end of document.
 fun void ScrollToEnd=2629(,)
 
+val SC_TECHNOLOGY_DEFAULT=0
+val SC_TECHNOLOGY_DIRECTWRITE=1
+
+# Set the technolgy used.
+set void SetTechnology=2630(int technology,)
+
+# Get the tech.
+get int GetTechnology=2631(,)
+
+# Create an ILoader*.
+fun int CreateLoader=2632(int bytes,)
+
 # Start notifying the container of all key presses and commands.
 fun void StartRecord=3001(,)
 
@@ -2421,6 +2453,9 @@ val SCLEX_MARKDOWN=98
 val SCLEX_TXT2TAGS=99
 val SCLEX_A68K=100
 val SCLEX_MODULA=101
+val SCLEX_COFFEESCRIPT=102
+val SCLEX_TCMD=103
+val SCLEX_AVS=104
 
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -2469,6 +2504,7 @@ val SCE_C_COMMENTDOCKEYWORDERROR=18
 val SCE_C_GLOBALCLASS=19
 val SCE_C_STRINGRAW=20
 val SCE_C_TRIPLEVERBATIM=21
+val SCE_C_HASHQUOTEDSTRING=22
 # Lexical states for SCLEX_D
 lex D=SCLEX_D SCE_D_
 val SCE_D_DEFAULT=0
@@ -2832,6 +2868,19 @@ val SCE_BAT_HIDE=4
 val SCE_BAT_COMMAND=5
 val SCE_BAT_IDENTIFIER=6
 val SCE_BAT_OPERATOR=7
+# Lexical states for SCLEX_TCMD
+lex TCMD=SCLEX_TCMD SCE_TCMD_
+val SCE_TCMD_DEFAULT=0
+val SCE_TCMD_COMMENT=1
+val SCE_TCMD_WORD=2
+val SCE_TCMD_LABEL=3
+val SCE_TCMD_HIDE=4
+val SCE_TCMD_COMMAND=5
+val SCE_TCMD_IDENTIFIER=6
+val SCE_TCMD_OPERATOR=7
+val SCE_TCMD_ENVIRONMENT=8
+val SCE_TCMD_EXPANSION=9
+val SCE_TCMD_CLABEL=10
 # Lexical states for SCLEX_MAKEFILE
 lex MakeFile=SCLEX_MAKEFILE SCE_MAKE_
 val SCE_MAKE_DEFAULT=0
@@ -3051,6 +3100,7 @@ val SCE_CSS_EXTENDED_IDENTIFIER=19
 val SCE_CSS_EXTENDED_PSEUDOCLASS=20
 val SCE_CSS_EXTENDED_PSEUDOELEMENT=21
 val SCE_CSS_MEDIA=22
+val SCE_CSS_VARIABLE=23
 # Lexical states for SCLEX_POV
 lex POV=SCLEX_POV SCE_POV_
 val SCE_POV_DEFAULT=0
@@ -3968,6 +4018,51 @@ val SCE_MODULA_PRAGMA=14
 val SCE_MODULA_PRGKEY=15
 val SCE_MODULA_OPERATOR=16
 val SCE_MODULA_BADSTR=17
+# Lexical states for SCLEX_COFFEESCRIPT
+lex CoffeeScript=SCLEX_COFFEESCRIPT SCE_COFFEESCRIPT_
+val SCE_COFFEESCRIPT_DEFAULT=0
+val SCE_COFFEESCRIPT_COMMENT=1
+val SCE_COFFEESCRIPT_COMMENTLINE=2
+val SCE_COFFEESCRIPT_COMMENTDOC=3
+val SCE_COFFEESCRIPT_NUMBER=4
+val SCE_COFFEESCRIPT_WORD=5
+val SCE_COFFEESCRIPT_STRING=6
+val SCE_COFFEESCRIPT_CHARACTER=7
+val SCE_COFFEESCRIPT_UUID=8
+val SCE_COFFEESCRIPT_PREPROCESSOR=9
+val SCE_COFFEESCRIPT_OPERATOR=10
+val SCE_COFFEESCRIPT_IDENTIFIER=11
+val SCE_COFFEESCRIPT_STRINGEOL=12
+val SCE_COFFEESCRIPT_VERBATIM=13
+val SCE_COFFEESCRIPT_REGEX=14
+val SCE_COFFEESCRIPT_COMMENTLINEDOC=15
+val SCE_COFFEESCRIPT_WORD2=16
+val SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17
+val SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18
+val SCE_COFFEESCRIPT_GLOBALCLASS=19
+val SCE_COFFEESCRIPT_STRINGRAW=20
+val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21
+val SCE_COFFEESCRIPT_HASHQUOTEDSTRING=22
+val SCE_COFFEESCRIPT_COMMENTBLOCK=22
+val SCE_COFFEESCRIPT_VERBOSE_REGEX=23
+val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24
+# Lexical states for SCLEX_AVS
+lex AVS=SCLEX_AVS SCE_AVS_
+val SCE_AVS_DEFAULT=0
+val SCE_AVS_COMMENTBLOCK=1
+val SCE_AVS_COMMENTBLOCKN=2
+val SCE_AVS_COMMENTLINE=3
+val SCE_AVS_NUMBER=4
+val SCE_AVS_OPERATOR=5
+val SCE_AVS_IDENTIFIER=6
+val SCE_AVS_STRING=7
+val SCE_AVS_TRIPLESTRING=8
+val SCE_AVS_KEYWORD=9
+val SCE_AVS_FILTER=10
+val SCE_AVS_PLUGIN=11
+val SCE_AVS_FUNCTION=12
+val SCE_AVS_CLIPPROP=13
+val SCE_AVS_USERDFN=14
 
 # Events
 
@@ -4005,3 +4100,12 @@ cat Deprecated
 # Deprecated in 2.21
 # The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+.
 val SC_CP_DBCS=1
+
+# Deprecated in 2.30
+
+# In palette mode?
+get bool GetUsePalette=2139(,)
+
+# In palette mode, Scintilla uses the environment's palette calls to display
+# more colours. This may lead to ugly displays.
+set void SetUsePalette=2039(bool usePalette,)
diff --git a/plugins/scintilla/scintilla/lexers.make b/plugins/scintilla/scintilla/lexers.make
index c1cfb5d..bed029f 100644
--- a/plugins/scintilla/scintilla/lexers.make
+++ b/plugins/scintilla/scintilla/lexers.make
@@ -10,6 +10,7 @@ LEXER_OBJS = \
 	LexASY.o\
 	LexAU3.o\
 	LexAVE.o\
+	LexAVS.o\
 	LexBaan.o\
 	LexBash.o\
 	LexBasic.o\
@@ -18,6 +19,7 @@ LEXER_OBJS = \
 	LexCLW.o\
 	LexCmake.o\
 	LexCOBOL.o\
+	LexCoffeeScript.o\
 	LexConf.o\
 	LexCPP.o\
 	LexCrontab.o\
@@ -80,6 +82,7 @@ LEXER_OBJS = \
 	LexTADS3.o\
 	LexTAL.o\
 	LexTCL.o\
+	LexTCMD.o\
 	LexTeX.o\
 	LexTxt2tags.o\
 	LexVB.o\
@@ -98,6 +101,7 @@ LEXER_SRCS = \
 	LexASY.cxx\
 	LexAU3.cxx\
 	LexAVE.cxx\
+	LexAVS.cxx\
 	LexBaan.cxx\
 	LexBash.cxx\
 	LexBasic.cxx\
@@ -106,6 +110,7 @@ LEXER_SRCS = \
 	LexCLW.cxx\
 	LexCmake.cxx\
 	LexCOBOL.cxx\
+	LexCoffeeScript.cxx\
 	LexConf.cxx\
 	LexCPP.cxx\
 	LexCrontab.cxx\
@@ -168,6 +173,7 @@ LEXER_SRCS = \
 	LexTADS3.cxx\
 	LexTAL.cxx\
 	LexTCL.cxx\
+	LexTCMD.cxx\
 	LexTeX.cxx\
 	LexTxt2tags.cxx\
 	LexVB.cxx\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]