anjuta r4392 - in trunk: . plugins/editor plugins/editor/properties plugins/editor/scintilla plugins/editor/scintilla/include plugins/editor/scintilla/patches



Author: sgranjoux
Date: Sat Nov 15 17:50:33 2008
New Revision: 4392
URL: http://svn.gnome.org/viewvc/anjuta?rev=4392&view=rev

Log:
	* plugins/editor/properties.cxx,
	plugins/editor/properties/Embedded.properties,
	plugins/editor/properties/Makefile.am,
	plugins/editor/properties/SciTEGlobal.properties,
	(added) plugins/editor/properties/abaqus.properties,
	(added) plugins/editor/properties/abbrev.properties,
	plugins/editor/properties/ada.properties,
	plugins/editor/properties/asm.properties,
	plugins/editor/properties/au3.properties,
	plugins/editor/properties/ave.properties,
	plugins/editor/properties/baan.properties,
	(added) plugins/editor/properties/blitzbasic.properties,
	(added) plugins/editor/properties/caml.properties,
	(added) plugins/editor/properties/cmake.properties,
	plugins/editor/properties/conf.properties,
	plugins/editor/properties/cpp.properties,
	(added) plugins/editor/properties/csound.properties,
	plugins/editor/properties/css.properties,
	(added) plugins/editor/properties/d.properties,
	(added) plugins/editor/properties/flagship.properties,
	plugins/editor/properties/forth.properties,
	plugins/editor/properties/fortran.properties,
	(added) plugins/editor/properties/freebasic.properties,
	(added) plugins/editor/properties/gap.properties,
	plugins/editor/properties/html.properties,
	(added) plugins/editor/properties/inno.properties,
	plugins/editor/properties/kix.properties,
	plugins/editor/properties/lout.properties,
	plugins/editor/properties/lua.properties,
	plugins/editor/properties/metapost.properties,
	plugins/editor/properties/mmixal.properties,
	plugins/editor/properties/nsis.properties,
	(added) plugins/editor/properties/opal.properties,
	plugins/editor/properties/others.properties,
	plugins/editor/properties/pascal.properties,
	plugins/editor/properties/perl.properties,
	plugins/editor/properties/pov.properties,
	(added) plugins/editor/properties/powershell.properties,
	(added) plugins/editor/properties/purebasic.properties,
	plugins/editor/properties/python.properties,
	(added) plugins/editor/properties/r.properties,
	(added) plugins/editor/properties/rebol.properties,
	plugins/editor/properties/ruby.properties,
	plugins/editor/properties/scriptol.properties,
	(added) plugins/editor/properties/smalltalk.properties,
	plugins/editor/properties/specman.properties,
	(added) plugins/editor/properties/spice.properties,
	plugins/editor/properties/sql.properties,
	plugins/editor/properties/tcl.properties,
	plugins/editor/properties/tex.properties,
	plugins/editor/properties/vb.properties,
	plugins/editor/properties/verilog.properties,
	plugins/editor/properties/vhdl.properties,
	plugins/editor/properties/yaml.properties,
	plugins/editor/properties_cxx.h,
	plugins/editor/scintilla/AutoComplete.cxx,
	plugins/editor/scintilla/AutoComplete.h,
	plugins/editor/scintilla/CallTip.cxx,
	plugins/editor/scintilla/CallTip.h,
	plugins/editor/scintilla/CellBuffer.cxx,
	plugins/editor/scintilla/CellBuffer.h,
	(added) plugins/editor/scintilla/CharacterSet.h,
	plugins/editor/scintilla/ContractionState.cxx,
	plugins/editor/scintilla/ContractionState.h,
	(added) plugins/editor/scintilla/Decoration.cxx,
	(added) plugins/editor/scintilla/Decoration.h,
	plugins/editor/scintilla/Document.cxx,
	plugins/editor/scintilla/Document.hr,
	plugins/editor/scintilla/DocumentAccessor.cxx,
	plugins/editor/scintilla/DocumentAccessor.h,
	plugins/editor/scintilla/Editor.cxx,
	plugins/editor/scintilla/Editor.h,
	plugins/editor/scintilla/ExternalLexer.cxx,
	plugins/editor/scintilla/ExternalLexer.h,
	plugins/editor/scintilla/Indicator.cxx,
	plugins/editor/scintilla/Indicator.h,
	plugins/editor/scintilla/KeyMap.cxx,
	plugins/editor/scintilla/KeyMap.h,
	plugins/editor/scintilla/KeyWords.cxx,
	plugins/editor/scintilla/LexAPDL.cxx,
	(added) plugins/editor/scintilla/LexASY.cxx,
	plugins/editor/scintilla/LexAU3.cxx,
	plugins/editor/scintilla/LexAVE.cxx,
	(added) plugins/editor/scintilla/LexAbaqus.cxx,
	plugins/editor/scintilla/LexAda.cxx,
	plugins/editor/scintilla/LexAsm.cxx,
	plugins/editor/scintilla/LexAsn1.cxx,
	plugins/editor/scintilla/LexBaan.cxx,
	plugins/editor/scintilla/LexBash.cxx,
	plugins/editor/scintilla/LexBasic.cxx,
	plugins/editor/scintilla/LexBullant.cxx,
	plugins/editor/scintilla/LexCLW.cxx,
	plugins/editor/scintilla/LexCPP.cxx,
	plugins/editor/scintilla/LexCSS.cxx,
	plugins/editor/scintilla/LexCaml.cxx,
	(added) plugins/editor/scintilla/LexCmake.cxx,
	plugins/editor/scintilla/LexConf.cxx,
	plugins/editor/scintilla/LexCrontab.cxx,
	plugins/editor/scintilla/LexCsound.cxx,
	(added) plugins/editor/scintilla/LexD.cxx,
	plugins/editor/scintilla/LexEScript.cxx,
	plugins/editor/scintilla/LexEiffel.cxx,
	plugins/editor/scintilla/LexErlang.cxx,
	plugins/editor/scintilla/LexFlagship.cxx,
	plugins/editor/scintilla/LexForth.cxx,
	plugins/editor/scintilla/LexFortran.cxx,
	(added) plugins/editor/scintilla/LexGAP.cxx,
	plugins/editor/scintilla/LexGui4Cli.cxx,
	plugins/editor/scintilla/LexHTML.cxx,
	plugins/editor/scintilla/LexHaskell.cxx,
	plugins/editor/scintilla/LexInno.cxx,
	plugins/editor/scintilla/LexKix.cxx,
	plugins/editor/scintilla/LexLisp.cxx,
	plugins/editor/scintilla/LexLout.cxx,
	plugins/editor/scintilla/LexLua.cxx,
	plugins/editor/scintilla/LexMMIXAL.cxx,
	plugins/editor/scintilla/LexMPT.cxx,
	plugins/editor/scintilla/LexMSSQL.cxx,
	(added) plugins/editor/scintilla/LexMagik.cxx,
	plugins/editor/scintilla/LexMatlab.cxx,
	plugins/editor/scintilla/LexMetapost.cxx,
	(added) plugins/editor/scintilla/LexMySQL.cxx,
	plugins/editor/scintilla/LexNsis.cxx,
	plugins/editor/scintilla/LexOpal.cxx,
	plugins/editor/scintilla/LexOthers.cxx,
	plugins/editor/scintilla/LexPB.cxx,
	(added) plugins/editor/scintilla/LexPLM.cxx,
	plugins/editor/scintilla/LexPOV.cxx,
	plugins/editor/scintilla/LexPS.cxx,
	plugins/editor/scintilla/LexPascal.cxx,
	plugins/editor/scintilla/LexPerl.cxx,
	(added) plugins/editor/scintilla/LexPowerShell.cxx,
	(added) plugins/editor/scintilla/LexProgress.cxx,
	plugins/editor/scintilla/LexPython.cxx,
	(added) plugins/editor/scintilla/LexR.cxx,
	plugins/editor/scintilla/LexRebol.cxx,
	plugins/editor/scintilla/LexRuby.cxx,
	plugins/editor/scintilla/LexSQL.cxx,
	plugins/editor/scintilla/LexScriptol.cxx,
	plugins/editor/scintilla/LexSmalltalk.cxx,
	plugins/editor/scintilla/LexSpecman.cxx,
	plugins/editor/scintilla/LexSpice.cxx,
	plugins/editor/scintilla/LexTADS3.cxx,
	plugins/editor/scintilla/LexTCL.cxx,
	plugins/editor/scintilla/LexTeX.cxx,
	plugins/editor/scintilla/LexVB.cxx,
	plugins/editor/scintilla/LexVHDL.cxx,
	plugins/editor/scintilla/LexVerilog.cxx,
	plugins/editor/scintilla/LexYAML.cxx,
	plugins/editor/scintilla/lexers.make,
	plugins/editor/scintilla/LineMarker.cxx,
	plugins/editor/scintilla/LineMarker.h,
	plugins/editor/scintilla/Makefile.am,
	(added) plugins/editor/scintilla/Partitioning.h,
	plugins/editor/scintilla/PlatGTK.cxx,
	(added) plugins/editor/scintilla/PositionCache.cxx,
	(added) plugins/editor/scintilla/PositionCache.h,
	plugins/editor/scintilla/PropSet.cxx,
	plugins/editor/scintilla/RESearch.cxx,
	plugins/editor/scintilla/RESearch.h,
	(added) plugins/editor/scintilla/RunStyles.cxx,
	(added) plugins/editor/scintilla/RunStyles.h,
	plugins/editor/scintilla/SVector.h,
	plugins/editor/scintilla/ScintillaBase.cxx,
	plugins/editor/scintilla/ScintillaBase.h,
	plugins/editor/scintilla/ScintillaGTK.cxx,
	(added) plugins/editor/scintilla/SplitVector.h,
	plugins/editor/scintilla/Style.cxx,
	plugins/editor/scintilla/Style.h,
	plugins/editor/scintilla/StyleContext.cxx,
	plugins/editor/scintilla/StyleContext.h,
	plugins/editor/scintilla/UniConversion.cxx,
	plugins/editor/scintilla/UniConversion.h,
	plugins/editor/scintilla/ViewStyle.cxx,
	plugins/editor/scintilla/ViewStyle.h,
	plugins/editor/scintilla/WindowAccessor.cxx,
	plugins/editor/scintilla/XPM.cxx,
	plugins/editor/scintilla/XPM.h,
	plugins/editor/scintilla/include/Accessor.h,
	plugins/editor/scintilla/include/HFacer.py,
	plugins/editor/scintilla/include/KeyWords.h,
	plugins/editor/scintilla/include/Platform.h,
	plugins/editor/scintilla/include/PropSet.h,
	plugins/editor/scintilla/include/SString.h,
	plugins/editor/scintilla/include/SciLexer.h,
	plugins/editor/scintilla/include/Scintilla.h,
	plugins/editor/scintilla/include/Scintilla.iface,
	plugins/editor/scintilla/include/WindowAccessor.h,
	plugins/editor/scintilla/patches/scintilla-string-fix.diff,
	plugins/editor/scintilla/patches/scintilla-pango-always.diff,
	plugins/editor/scintilla/patches/scintilla-64-bit.diff:
	Update scintilla to version 1.77


Added:
   trunk/plugins/editor/properties/abaqus.properties
   trunk/plugins/editor/properties/abbrev.properties
   trunk/plugins/editor/properties/blitzbasic.properties
   trunk/plugins/editor/properties/caml.properties
   trunk/plugins/editor/properties/cmake.properties
   trunk/plugins/editor/properties/csound.properties
   trunk/plugins/editor/properties/d.properties
   trunk/plugins/editor/properties/flagship.properties
   trunk/plugins/editor/properties/freebasic.properties
   trunk/plugins/editor/properties/gap.properties
   trunk/plugins/editor/properties/inno.properties
   trunk/plugins/editor/properties/opal.properties
   trunk/plugins/editor/properties/powershell.properties
   trunk/plugins/editor/properties/purebasic.properties
   trunk/plugins/editor/properties/r.properties
   trunk/plugins/editor/properties/rebol.properties
   trunk/plugins/editor/properties/smalltalk.properties
   trunk/plugins/editor/properties/spice.properties
   trunk/plugins/editor/scintilla/CharacterSet.h   (contents, props changed)
   trunk/plugins/editor/scintilla/Decoration.cxx
   trunk/plugins/editor/scintilla/Decoration.h   (contents, props changed)
   trunk/plugins/editor/scintilla/LexASY.cxx
   trunk/plugins/editor/scintilla/LexAbaqus.cxx
   trunk/plugins/editor/scintilla/LexCmake.cxx
   trunk/plugins/editor/scintilla/LexD.cxx
   trunk/plugins/editor/scintilla/LexGAP.cxx
   trunk/plugins/editor/scintilla/LexMagik.cxx
   trunk/plugins/editor/scintilla/LexMySQL.cxx
   trunk/plugins/editor/scintilla/LexPLM.cxx
   trunk/plugins/editor/scintilla/LexPowerShell.cxx
   trunk/plugins/editor/scintilla/LexProgress.cxx
   trunk/plugins/editor/scintilla/LexR.cxx
   trunk/plugins/editor/scintilla/Partitioning.h   (contents, props changed)
   trunk/plugins/editor/scintilla/PositionCache.cxx
   trunk/plugins/editor/scintilla/PositionCache.h   (contents, props changed)
   trunk/plugins/editor/scintilla/RunStyles.cxx
   trunk/plugins/editor/scintilla/RunStyles.h   (contents, props changed)
   trunk/plugins/editor/scintilla/SplitVector.h   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/plugins/editor/properties.cxx
   trunk/plugins/editor/properties/Embedded.properties
   trunk/plugins/editor/properties/Makefile.am
   trunk/plugins/editor/properties/SciTEGlobal.properties
   trunk/plugins/editor/properties/ada.properties
   trunk/plugins/editor/properties/asm.properties
   trunk/plugins/editor/properties/au3.properties
   trunk/plugins/editor/properties/ave.properties
   trunk/plugins/editor/properties/baan.properties
   trunk/plugins/editor/properties/conf.properties
   trunk/plugins/editor/properties/cpp.properties
   trunk/plugins/editor/properties/css.properties
   trunk/plugins/editor/properties/forth.properties
   trunk/plugins/editor/properties/fortran.properties
   trunk/plugins/editor/properties/html.properties
   trunk/plugins/editor/properties/kix.properties
   trunk/plugins/editor/properties/lout.properties
   trunk/plugins/editor/properties/lua.properties
   trunk/plugins/editor/properties/metapost.properties
   trunk/plugins/editor/properties/mmixal.properties
   trunk/plugins/editor/properties/nsis.properties
   trunk/plugins/editor/properties/others.properties
   trunk/plugins/editor/properties/pascal.properties
   trunk/plugins/editor/properties/perl.properties
   trunk/plugins/editor/properties/pov.properties
   trunk/plugins/editor/properties/python.properties
   trunk/plugins/editor/properties/ruby.properties
   trunk/plugins/editor/properties/scriptol.properties
   trunk/plugins/editor/properties/specman.properties
   trunk/plugins/editor/properties/sql.properties
   trunk/plugins/editor/properties/tcl.properties
   trunk/plugins/editor/properties/tex.properties
   trunk/plugins/editor/properties/vb.properties
   trunk/plugins/editor/properties/verilog.properties
   trunk/plugins/editor/properties/vhdl.properties
   trunk/plugins/editor/properties/yaml.properties
   trunk/plugins/editor/properties_cxx.h
   trunk/plugins/editor/scintilla/AutoComplete.cxx
   trunk/plugins/editor/scintilla/AutoComplete.h
   trunk/plugins/editor/scintilla/CallTip.cxx
   trunk/plugins/editor/scintilla/CallTip.h
   trunk/plugins/editor/scintilla/CellBuffer.cxx
   trunk/plugins/editor/scintilla/CellBuffer.h
   trunk/plugins/editor/scintilla/ContractionState.cxx
   trunk/plugins/editor/scintilla/ContractionState.h
   trunk/plugins/editor/scintilla/Document.cxx
   trunk/plugins/editor/scintilla/Document.h
   trunk/plugins/editor/scintilla/DocumentAccessor.cxx
   trunk/plugins/editor/scintilla/DocumentAccessor.h
   trunk/plugins/editor/scintilla/Editor.cxx
   trunk/plugins/editor/scintilla/Editor.h
   trunk/plugins/editor/scintilla/ExternalLexer.cxx
   trunk/plugins/editor/scintilla/ExternalLexer.h
   trunk/plugins/editor/scintilla/Indicator.cxx
   trunk/plugins/editor/scintilla/Indicator.h
   trunk/plugins/editor/scintilla/KeyMap.cxx
   trunk/plugins/editor/scintilla/KeyMap.h
   trunk/plugins/editor/scintilla/KeyWords.cxx
   trunk/plugins/editor/scintilla/LexAPDL.cxx
   trunk/plugins/editor/scintilla/LexAU3.cxx
   trunk/plugins/editor/scintilla/LexAVE.cxx
   trunk/plugins/editor/scintilla/LexAda.cxx
   trunk/plugins/editor/scintilla/LexAsm.cxx
   trunk/plugins/editor/scintilla/LexAsn1.cxx
   trunk/plugins/editor/scintilla/LexBaan.cxx
   trunk/plugins/editor/scintilla/LexBash.cxx
   trunk/plugins/editor/scintilla/LexBasic.cxx
   trunk/plugins/editor/scintilla/LexBullant.cxx
   trunk/plugins/editor/scintilla/LexCLW.cxx
   trunk/plugins/editor/scintilla/LexCPP.cxx
   trunk/plugins/editor/scintilla/LexCSS.cxx
   trunk/plugins/editor/scintilla/LexCaml.cxx
   trunk/plugins/editor/scintilla/LexConf.cxx
   trunk/plugins/editor/scintilla/LexCrontab.cxx
   trunk/plugins/editor/scintilla/LexCsound.cxx
   trunk/plugins/editor/scintilla/LexEScript.cxx
   trunk/plugins/editor/scintilla/LexEiffel.cxx
   trunk/plugins/editor/scintilla/LexErlang.cxx
   trunk/plugins/editor/scintilla/LexFlagship.cxx
   trunk/plugins/editor/scintilla/LexForth.cxx
   trunk/plugins/editor/scintilla/LexFortran.cxx
   trunk/plugins/editor/scintilla/LexGui4Cli.cxx
   trunk/plugins/editor/scintilla/LexHTML.cxx
   trunk/plugins/editor/scintilla/LexHaskell.cxx
   trunk/plugins/editor/scintilla/LexInno.cxx
   trunk/plugins/editor/scintilla/LexKix.cxx
   trunk/plugins/editor/scintilla/LexLisp.cxx
   trunk/plugins/editor/scintilla/LexLout.cxx
   trunk/plugins/editor/scintilla/LexLua.cxx
   trunk/plugins/editor/scintilla/LexMMIXAL.cxx
   trunk/plugins/editor/scintilla/LexMPT.cxx
   trunk/plugins/editor/scintilla/LexMSSQL.cxx
   trunk/plugins/editor/scintilla/LexMatlab.cxx
   trunk/plugins/editor/scintilla/LexMetapost.cxx
   trunk/plugins/editor/scintilla/LexNsis.cxx
   trunk/plugins/editor/scintilla/LexOpal.cxx
   trunk/plugins/editor/scintilla/LexOthers.cxx
   trunk/plugins/editor/scintilla/LexPB.cxx
   trunk/plugins/editor/scintilla/LexPOV.cxx
   trunk/plugins/editor/scintilla/LexPS.cxx
   trunk/plugins/editor/scintilla/LexPascal.cxx
   trunk/plugins/editor/scintilla/LexPerl.cxx
   trunk/plugins/editor/scintilla/LexPython.cxx
   trunk/plugins/editor/scintilla/LexRebol.cxx
   trunk/plugins/editor/scintilla/LexRuby.cxx
   trunk/plugins/editor/scintilla/LexSQL.cxx
   trunk/plugins/editor/scintilla/LexScriptol.cxx
   trunk/plugins/editor/scintilla/LexSmalltalk.cxx
   trunk/plugins/editor/scintilla/LexSpecman.cxx
   trunk/plugins/editor/scintilla/LexSpice.cxx
   trunk/plugins/editor/scintilla/LexTADS3.cxx
   trunk/plugins/editor/scintilla/LexTCL.cxx
   trunk/plugins/editor/scintilla/LexTeX.cxx
   trunk/plugins/editor/scintilla/LexVB.cxx
   trunk/plugins/editor/scintilla/LexVHDL.cxx
   trunk/plugins/editor/scintilla/LexVerilog.cxx
   trunk/plugins/editor/scintilla/LexYAML.cxx
   trunk/plugins/editor/scintilla/LineMarker.cxx
   trunk/plugins/editor/scintilla/LineMarker.h
   trunk/plugins/editor/scintilla/Makefile.am
   trunk/plugins/editor/scintilla/PlatGTK.cxx
   trunk/plugins/editor/scintilla/PropSet.cxx
   trunk/plugins/editor/scintilla/RESearch.cxx
   trunk/plugins/editor/scintilla/RESearch.h
   trunk/plugins/editor/scintilla/SVector.h
   trunk/plugins/editor/scintilla/ScintillaBase.cxx
   trunk/plugins/editor/scintilla/ScintillaBase.h
   trunk/plugins/editor/scintilla/ScintillaGTK.cxx
   trunk/plugins/editor/scintilla/Style.cxx
   trunk/plugins/editor/scintilla/Style.h
   trunk/plugins/editor/scintilla/StyleContext.cxx
   trunk/plugins/editor/scintilla/StyleContext.h
   trunk/plugins/editor/scintilla/UniConversion.cxx
   trunk/plugins/editor/scintilla/UniConversion.h
   trunk/plugins/editor/scintilla/ViewStyle.cxx
   trunk/plugins/editor/scintilla/ViewStyle.h
   trunk/plugins/editor/scintilla/WindowAccessor.cxx
   trunk/plugins/editor/scintilla/XPM.cxx
   trunk/plugins/editor/scintilla/XPM.h
   trunk/plugins/editor/scintilla/include/Accessor.h
   trunk/plugins/editor/scintilla/include/HFacer.py
   trunk/plugins/editor/scintilla/include/KeyWords.h
   trunk/plugins/editor/scintilla/include/Platform.h
   trunk/plugins/editor/scintilla/include/PropSet.h
   trunk/plugins/editor/scintilla/include/SString.h
   trunk/plugins/editor/scintilla/include/SciLexer.h
   trunk/plugins/editor/scintilla/include/Scintilla.h
   trunk/plugins/editor/scintilla/include/Scintilla.iface
   trunk/plugins/editor/scintilla/include/WindowAccessor.h
   trunk/plugins/editor/scintilla/lexers.make
   trunk/plugins/editor/scintilla/patches/scintilla-64-bit.diff
   trunk/plugins/editor/scintilla/patches/scintilla-pango-always.diff
   trunk/plugins/editor/scintilla/patches/scintilla-string-fix.diff

Modified: trunk/plugins/editor/properties.cxx
==============================================================================
--- trunk/plugins/editor/properties.cxx	(original)
+++ trunk/plugins/editor/properties.cxx	Sat Nov 15 17:50:33 2008
@@ -15,6 +15,15 @@
 #include "properties_cxx.h"
 #include "properties.h"
 
+bool PropSetFile::caseSensitiveFilenames = false;
+
+PropSetFile::PropSetFile(bool lowerKeys_) : lowerKeys(lowerKeys_) {}
+
+PropSetFile::~PropSetFile() {}
+
+/**
+ * Get a line of input. If end of line escaped with '\\' then continue reading.
+ */
 static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
 	bool continuation = true;
 	s[0] = '\0';
@@ -34,6 +43,10 @@
 			}
 		} else if ((ch == '\\') && (lenData > 0) && ((*fpc == '\r') || (*fpc == '\n'))) {
 			continuation = true;
+			if ((lenData > 1) && ((*fpc == '\r') && (*(fpc+1) == '\r') || (*fpc == '\n') && (*(fpc+1) == '\n')))
+				continuation = false;
+			else if ((lenData > 2) && ((*fpc == '\r') && (*(fpc+1) == '\n') && (*(fpc+2) == '\n' || *(fpc+2) == '\r')))
+				continuation = false;
 		} else {
 			continuation = false;
 			*s++ = ch;
@@ -44,53 +57,241 @@
 	return false;
 }
 
-bool PropSetFile::ReadLine(char *linebuf, bool ifIsTrue, const char *directoryForImports) {
-	if (isalpha(linebuf[0]))    // If clause ends with first non-indented line
+static bool IsSpaceOrTab(char ch) {
+	return (ch == ' ') || (ch == '\t');
+}
+
+static bool IsCommentLine(const char *line) {
+	while (IsSpaceOrTab(*line)) ++line;
+	return (*line == '#');
+}
+
+bool PropSetFile::ReadLine(const char *lineBuffer, bool ifIsTrue, const char *directoryForImports) {
+	if (!IsSpaceOrTab(lineBuffer[0]))    // If clause ends with first non-indented line
 		ifIsTrue = true;
-	if (isprefix(linebuf, "if ")) {
-		const char *expr = linebuf + strlen("if") + 1;
-		ifIsTrue = GetInt(expr);
-	} else if (isprefix(linebuf, "import ") && directoryForImports) {
+	if (isprefix(lineBuffer, "if ")) {
+		const char *expr = lineBuffer + strlen("if") + 1;
+		ifIsTrue = GetInt(expr) != 0;
+	} else if (isprefix(lineBuffer, "import ") && directoryForImports) {
 		char importPath[1024];
 		strcpy(importPath, directoryForImports);
-		strcat(importPath, linebuf + strlen("import") + 1);
+		strcat(importPath, lineBuffer + strlen("import") + 1);
 		strcat(importPath, ".properties");
 		Read(importPath, directoryForImports);
-	} else if (isalpha(linebuf[0])) {
-		Set(linebuf);
-	} else if (isspace(linebuf[0]) && ifIsTrue) {
-		Set(linebuf);
+	} else if (ifIsTrue && !IsCommentLine(lineBuffer)) {
+		Set(lineBuffer);
 	}
 	return ifIsTrue;
 }
 
 void PropSetFile::ReadFromMemory(const char *data, int len, const char *directoryForImports) {
 	const char *pd = data;
-	char linebuf[60000];
+	char lineBuffer[60000];
 	bool ifIsTrue = true;
 	while (len > 0) {
-		GetFullLine(pd, len, linebuf, sizeof(linebuf));
-		ifIsTrue = ReadLine(linebuf, ifIsTrue, directoryForImports);
+		GetFullLine(pd, len, lineBuffer, sizeof(lineBuffer));
+		if (lowerKeys) {
+			for (int i=0; lineBuffer[i] && (lineBuffer[i] != '='); i++) {
+				if ((lineBuffer[i] >= 'A') && (lineBuffer[i] <= 'Z')) {
+					lineBuffer[i] = static_cast<char>(lineBuffer[i] - 'A' + 'a');
+				}
+			}
+		}
+		ifIsTrue = ReadLine(lineBuffer, ifIsTrue, directoryForImports);
 	}
 }
 
-void PropSetFile::Read(const char *filename, const char *directoryForImports) {
-	char propsData[60000];
+bool PropSetFile::Read(const char *filename, const char *directoryForImports) {
 #ifdef __vms
 	FILE *rcfile = fopen(filename, "r");
 #else
 	FILE *rcfile = fopen(filename, "rb");
 #endif
 	if (rcfile) {
+		char propsData[60000];
 		int lenFile = fread(propsData, 1, sizeof(propsData), rcfile);
 		fclose(rcfile);
 		ReadFromMemory(propsData, lenFile, directoryForImports);
+		return true;
+
 	} else {
 		//printf("Could not open <%s>\n", filename);
+		return false;
+	}
+}
+
+static inline char MakeUpperCase(char ch) {
+	if (ch < 'a' || ch > 'z')
+		return ch;
+	else
+		return static_cast<char>(ch - 'a' + 'A');
+}
+
+static bool StringEqual(const char *a, const char *b, size_t len, bool caseSensitive) {
+	if (caseSensitive) {
+		for (size_t i = 0; i < len; i++) {
+			if (a[i] != b[i])
+				return false;
+		}
+	} else {
+		for (size_t i = 0; i < len; i++) {
+			if (MakeUpperCase(a[i]) != MakeUpperCase(b[i]))
+				return false;
+		}
 	}
+	return true;
+}
 
+// Match file names to patterns allowing for a '*' suffix or prefix.
+static bool MatchWild(const char *pattern, size_t lenPattern, const char *fileName, bool caseSensitive) {
+	size_t lenFileName = strlen(fileName);
+	if (lenFileName == lenPattern) {
+		if (StringEqual(pattern, fileName, lenFileName, caseSensitive)) {
+			return true;
+		}
+	}
+	if (lenFileName >= lenPattern-1) {
+		if (pattern[0] == '*') {
+			// Matching suffixes
+			return StringEqual(pattern+1, fileName + lenFileName - (lenPattern-1), lenPattern-1, caseSensitive);
+		} else if (pattern[lenPattern-1] == '*') {
+			// Matching prefixes
+			return StringEqual(pattern, fileName, lenPattern-1, caseSensitive);
+		}
+	}
+	return false;
 }
 
+SString PropSetFile::GetWildUsingStart(const PropSet &psStart, const char *keybase, const char *filename) {
+
+	for (int root = 0; root < hashRoots; root++) {
+		for (Property *p = props[root]; p; p = p->next) {
+			if (isprefix(p->key, keybase)) {
+				char *orgkeyfile = p->key + strlen(keybase);
+				char *keyfile = NULL;
+
+				if (strncmp(orgkeyfile, "$(", 2) == 0) {
+					const char *cpendvar = strchr(orgkeyfile, ')');
+					if (cpendvar) {
+						SString var(orgkeyfile, 2, cpendvar-orgkeyfile);
+						SString s = psStart.GetExpanded(var.c_str());
+						keyfile = StringDup(s.c_str());
+					}
+				}
+				char *keyptr = keyfile;
+
+				if (keyfile == NULL)
+					keyfile = orgkeyfile;
+
+				for (;;) {
+					char *del = strchr(keyfile, ';');
+					if (del == NULL)
+						del = keyfile + strlen(keyfile);
+					if (MatchWild(keyfile, del - keyfile, filename, caseSensitiveFilenames)) {
+						delete []keyptr;
+						return p->val;
+					}
+					if (*del == '\0')
+						break;
+					keyfile = del + 1;
+				}
+				delete []keyptr;
+
+				if (0 == strcmp(p->key, keybase)) {
+					return p->val;
+				}
+			}
+		}
+	}
+	if (superPS) {
+		// Failed here, so try in super property set
+		return static_cast<PropSetFile *>(superPS)->GetWildUsingStart(psStart, keybase, filename);
+	} else {
+		return "";
+	}
+}
+
+SString PropSetFile::GetWild(const char *keybase, const char *filename) {
+	return GetWildUsingStart(*this, keybase, filename);
+}
+
+// GetNewExpand does not use Expand as it has to use GetWild with the filename for each
+// variable reference found.
+SString PropSetFile::GetNewExpand(const char *keybase, const char *filename) {
+	char *base = StringDup(GetWild(keybase, filename).c_str());
+	char *cpvar = strstr(base, "$(");
+	int maxExpands = 1000;	// Avoid infinite expansion of recursive definitions
+	while (cpvar && (maxExpands > 0)) {
+		const char *cpendvar = strchr(cpvar, ')');
+		if (cpendvar) {
+			int lenvar = cpendvar - cpvar - 2;  	// Subtract the $()
+			char *var = StringDup(cpvar + 2, lenvar);
+			SString val = GetWild(var, filename);
+			if (0 == strcmp(var, keybase))
+				val.clear(); // Self-references evaluate to empty string
+			size_t newlenbase = strlen(base) + val.length() - lenvar;
+			char *newbase = new char[newlenbase];
+			strncpy(newbase, base, cpvar - base);
+			strcpy(newbase + (cpvar - base), val.c_str());
+			strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
+			delete []var;
+			delete []base;
+			base = newbase;
+		}
+		cpvar = strstr(base, "$(");
+		maxExpands--;
+	}
+	SString sret = base;
+	delete []base;
+	return sret;
+}
+
+/**
+ * Initiate enumeration.
+ */
+bool PropSetFile::GetFirst(char **key, char **val) {
+	for (int i = 0; i < hashRoots; i++) {
+		for (Property *p = props[i]; p; p = p->next) {
+			if (p) {
+				*key = p->key;
+				*val = p->val;
+				enumnext = p->next; // GetNext will begin here ...
+				enumhash = i;		  // ... in this block
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+/**
+ * Continue enumeration.
+ */
+bool PropSetFile::GetNext(char ** key, char ** val) {
+	bool firstloop = true;
+
+	// search begins where we left it : in enumhash block
+	for (int i = enumhash; i < hashRoots; i++) {
+		if (!firstloop)
+			enumnext = props[i]; // Begin with first property in block
+		// else : begin where we left
+		firstloop = false;
+
+		for (Property *p = enumnext; p; p = p->next) {
+			if (p) {
+				*key = p->key;
+				*val = p->val;
+				enumnext = p->next; // for GetNext
+				enumhash = i;
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+
+
 // Global property bank for anjuta.
 static GList *anjuta_propset;
 

Modified: trunk/plugins/editor/properties/Embedded.properties
==============================================================================
--- trunk/plugins/editor/properties/Embedded.properties	(original)
+++ trunk/plugins/editor/properties/Embedded.properties	Sat Nov 15 17:50:33 2008
@@ -9,6 +9,7 @@
 position.width=576
 position.height=740
 split.vertical=1
+tabbar.visible=1
 
 line.margin.width=4
 margin.width=16
@@ -25,10 +26,12 @@
 edge.colour=#C0DCC0
 braces.check=1
 braces.sloppy=1
-selection.back=#DADADA
+selection.alpha=30
+selection.back=#000000
 
 are.you.sure=1
 default.file.ext=.cxx
+buffers=10
 
 tabsize=8
 indent.size=8
@@ -42,13 +45,13 @@
 fold.compact=1
 fold.flags=16
 fold.symbols=1
+fold.comment=1
+fold.preprocessor=1
 
-if PLAT_WIN
-	find.command=findstr /n /s $(find.what) $(find.files)
-if PLAT_GTK
-	find.command=grep --line-number "$(find.what)" $(find.files)
+find.command=
 find.files=*.c *.cxx *.h
 
+eol.auto=1
 clear.before.execute=0
 caret.policy.xslop=1
 caret.policy.width=20
@@ -69,7 +72,7 @@
 statusbar.text.3=\
 Now is: Date=$(CurrentDate) Time=$(CurrentTime)
 statusbar.text.4=\
-$(FileNameExt) : $(FileDate) — $(FileTime) | $(FileAttr)
+$(FileNameExt) : $(FileDate) - $(FileTime) | $(FileAttr)
 
 if PLAT_WIN
 	command.scite.help="file://$(SciteDefaultHome)\SciTEDoc.html"
@@ -129,10 +132,12 @@
 $(filter.mmixal)\
 $(filter.nncrontab)\
 $(filter.nsis)\
+$(filter.opal)\
 $(filter.pascal)\
 $(filter.perl)\
 $(filter.php)\
 $(filter.pov)\
+$(filter.prg)\
 $(filter.properties)\
 $(filter.ps)\
 $(filter.python)\
@@ -145,7 +150,8 @@
 $(filter.vb)\
 $(filter.web)\
 $(filter.yaml)\
-$(filter.verilog)
+$(filter.verilog)\
+$(filter.vhdl)
 
 if PLAT_WIN
 	font.base=font:Verdana,size:10
@@ -154,6 +160,7 @@
 	font.code.comment.box=$(font.comment)
 	font.code.comment.line=$(font.comment)
 	font.code.comment.doc=$(font.comment)
+	font.code.comment.nested=$(font.comment)
 	font.text=font:Times New Roman,size:11
 	font.text.comment=font:Verdana,size:9
 	font.embedded.base=font:Verdana,size:9
@@ -161,18 +168,19 @@
 	font.monospace=font:Courier New,size:10
 	font.vbs=font:Lucida Sans Unicode,size:10
 if PLAT_GTK
-	font.base=font:lucidatypewriter,size:12
-	font.small=font:lucidatypewriter,size:10
-	font.comment=font:new century schoolbook,size:12
+	font.base=font:!Bitstream Vera Sans,size:9
+	font.small=font:!Bitstream Vera Sans,size:8
+	font.comment=font:!Bitstream Vera Serif,size:9
 	font.code.comment.box=$(font.comment)
 	font.code.comment.line=$(font.comment)
 	font.code.comment.doc=$(font.comment)
-	font.text=font:times,size:14
-	font.text.comment=font:lucidatypewriter,size:10
-	font.embedded.base=font:lucidatypewriter,size:12
-	font.embedded.comment=font:lucidatypewriter,size:12
-	font.monospace=font:courier,size:12
-	font.vbs=font:new century schoolbook,size:12
+	font.code.comment.nested=$(font.comment)
+	font.text=font:!Bitstream Charter,size:10
+	font.text.comment=font:!Serif,size:9
+	font.embedded.base=font:!Serif,size:9
+	font.embedded.comment=font:!Serif,size:9
+	font.monospace=font:!Bitstream Vera Sans Mono,size:9
+	font.vbs=font:!Bitstream Vera Sans Mono,size:9
 font.js=$(font.comment)
 
 colour.code.comment.box=fore:#007F00
@@ -228,6 +236,7 @@
 &C / C++|c||\
 C&#|cs||\
 CSS|css||\
+D|d||\
 &Difference|diff||\
 &Eiffel|e||\
 Erlang|erl||\
@@ -261,8 +270,7 @@
 &VB|vb||\
 VBScr&ipt|vbs||\
 &XML|xml|Shift+F12|\
-&YAML|yaml||
-
+YAML|yaml||
 
 user.shortcuts=\
 Ctrl+Shift+V|IDM_PASTEANDDOWN|\
@@ -270,12 +278,15 @@
 Ctrl+PageDown|IDM_NEXTFILE|
 
 
+
 import ada
 import asm
 import ave
 import baan
+import caml
 import conf
 import cpp
+import d
 import css
 import eiffel
 import erlang
@@ -339,7 +350,6 @@
 braces.ada.style=4
 
 statement.indent.$(file.patterns.ada)=5 begin declare else elsif exception for if is loop while
-statement.end.$(file.patterns.ada)=10 ;
 statement.lookback.$(file.patterns.ada)=20
 block.start.$(file.patterns.ada)=10 then is
 block.end.$(file.patterns.ada)=10 end
@@ -533,9 +543,85 @@
 
 
 statement.indent.$(file.patterns.asm)=9 .if
-statement.end.$(file.patterns.asm)=9 .endif
 
-autoit3dir=c:\program files\autoit3
+filter.asn1=ASN.1 (asn1)|*.mib|
+
+file.patterns.asn1=*.mib
+
+lexer.$(file.patterns.asn1)=asn1
+
+style.asn1.0=fore:#000000
+style.asn1.1=fore:#007F00,$(font.comment)
+style.asn1.2=fore:#000000,bold
+style.asn1.3=fore:#7F007F
+style.asn1.4=fore:#007F7F,bold
+style.asn1.5=fore:#7F0000
+style.asn1.6=fore:#00007F
+style.asn1.7=fore:#F07800
+style.asn1.8=fore:#00007F
+style.asn1.9=fore:#00007F
+style.asn1.10=fore:#222222
+
+keywords.$(file.patterns.asn1)=\
+ACCESS AGENT AUGMENTS \
+BEGIN BITS \
+CAPABILITIES CHOICE COMPLIANCE CONTACT CONVENTION \
+DEFINITIONS DEFVAL DESCRIPTION DISPLAY \
+END ENTERPRISE EXPORTS \
+FALSE FROM \
+GROUP GROUPS \
+HINT \
+IDENTITY IMPLIED IMPORTS INCLUDES INDEX INFO \
+LAST \
+MANDATORY MAX MIN MODULE \
+NOTATION NOTIFICATION NULL \
+OBJECTS OBJECT-TYPE OF ORGANIZATION \
+PRODUCT \
+RELEASE REFERENCE REQUIRES REVISION \
+SEQUENCE SIZE STATUS SUPPORTS SYNTAX \
+TEXTUAL TRAP TYPE TRAP-TYPE \
+UPDATED \
+VALUE VARIABLES VARIATION \
+WRITE
+
+keywords2.$(file.patterns.asn1)=\
+accessible \
+create current \
+deprecated \
+for \
+mandatory \
+not notify not-accessible \
+obsolete only optional \
+read read-only read-write \
+write
+
+keywords3.$(file.patterns.asn1)=\
+ABSENT ANY APPLICATION \
+BIT BOOLEAN BY \
+COMPONENT COMPONENTS \
+DEFAULT DEFINED \
+ENUMERATED EXPLICIT EXTERNAL \
+IMPLICIT INIFINITY \
+MAX MIN MINUS \
+OPTIONAL \
+PRESENT PRIVATE \
+REAL \
+SET \
+TAGS TRUE
+
+keywords4.$(file.patterns.asn1)=\
+Counter Counter32 Counter64 \
+DisplayString \
+Gauge Gauge32 \
+IDENTIFIER INTEGER Integer32 IpAddress \
+NetworkAddress NsapAddress \
+OBJECT OCTET Opaque \
+PhysAddress \
+STRING \
+TimeTicks \
+UInteger32 UNITS Unsigned32
+
+autoit3dir=C:\program files\autoit3
 
 file.patterns.au3=*.au3
 filter.au3=AutoIt (au3)|*.au3|
@@ -544,87 +630,121 @@
 command.compile.*.au3=$(autoit3dir)\aut2exe\aut2exe.exe /in "$(FilePath)"
 command.build.*.au3=$(autoit3dir)\aut2exe\aut2exe.exe /in "$(FilePath)"
 command.go.*.au3=$(autoit3dir)\autoit3.exe "$(FilePath)"
+command.9.*.au3=tidy\tidy.exe "$(FilePath)"
+command.name.9.*.au3=Tidy AutoIt Source
+command.save.before.9.*.au3=1
+command.shortcut.9.*=Ctrl+9
+extension.*.au3=$(SciteDefaultHome)\AutoIt3.lua
+command.name.11.*.au3=MsgBox(4096,'debug',...)
+command.subsystem.11.*.au3=3
+command.11.*.au3=Debug_MsgBox
+command.shortcut.11.*.au3=Ctrl+Shift+D
+command.save.before.11.*.au3=2
+
+command.name.12.*.au3=Insert Bookmarked Line(s)
+command.subsystem.12.*.au3=3
+command.12.*.au3=Copy_BookMarks
+command.shortcut.12.*.au3=Ctrl+Shift+B
+command.save.before.12.*.au3=2
+
 command.help.*.au3=$(CurrentWord)!$(autoit3dir)\autoit.chm
 command.help.subsystem.*.au3=4
 api.*.au3=$(SciteDefaultHome)\api\au3.api
 calltip.au3.word.characters=$(chars.alpha)$(chars.numeric)
 calltip.au3.ignorecase=1
 autocomplete.au3.ignorecase=1
+autocomplete.au3.start.characters=$(chars.alpha)$(chars.numeric)$@
+word.characters.*.au3=$(chars.alpha)$(chars.numeric)@$_
 indent.size.*.au3=3
-statement.indent.*.au3=5 case if do for else while select
-statement.end.*.au3=
-block.start.*.au3=5 case if do for else while select
-block.end.*.au3=5 else endif endselect next until wend
-
-keywordclass.au3=#ce #cs #comments_end #comments_start #include #include-once \
-and byref case continueloop dim do else elseif endfunc endif \
-endselect exit exitloop for func global if local next not or return select step then to until wend while
+statement.indent.*.au3=
+statement.lookback.*.au3=
+block.start.*.au3=5 case if do for func else elseif while select \
+                    Case If Do For Func Else ElseIf While Select \
+                    CASE IF DO FOR FUNC ELSE ELSEIF WHILE SELECT
+block.end.*.au3=5 case else endif elseif endfunc endselect next until wend \
+                  Case Else EndIf ElseIf EndFunc EndSelect Next Until Wend \
+                  CASE ELSE ENDIF ELSEIF ENDFUNC ENDSELECT NEXT UNTIL WEND
+comment.block.au3=;~
+comment.block.at.line.start.au3=1
+comment.stream.start.au3=#CS
+comment.stream.end.au3=#CE
+comment.box.start.au3=#CS
+comment.box.middle.au3=
+comment.box.end.au3= #CE
+
+keywordclass.au3= \
+ and byref case continueloop dim do else elseif endfunc endif endselect exit exitloop for func \
+  global if local next not or return select step then to until wend while exit
+
 keywords.$(file.patterns.au3)=$(keywordclass.au3)
 
-keywords2.$(file.patterns.au3)=abs acos adlibdisable adlibenable asc asin atan autoitsetoption autoitwingettitle autoitwinsettitle \
-bitand bitnot bitor bitshift bitxor blockinput break call cdtray chr clipget clipput controlclick controlcommand \
-controldisable controlenable controlfocus controlgetfocus controlgetpos controlgettext controlhide controlmove \
-controlsend controlsettext controlshow cos dec dircopy dircreate dirmove dirremove drivegetdrive drivegetfilesystem \
-drivegetlabel drivegetserial drivegettype drivesetlabel drivespacefree drivespacetotal drivestatus envget envset \
-envupdate eval exp filechangedir fileclose filecopy filecreateshortcut filedelete fileexists filefindfirstfile \
-filefindnextfile filegetattrib filegetlongname filegetshortname filegetsize filegettime filegetversion fileinstall \
-filemove fileopen fileopendialog fileread filereadline filerecycle filesavedialog fileselectfolder filesetattrib \
-filesettime filewrite filewriteline hex hotkeyset inidelete iniread iniwrite inputbox int isadmin isarray isdeclared \
-isfloat isint isnumber isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor mousegetpos \
-mousemove mouseup msgbox number pixelgetcolor pixelsearch processclose processexists processwait processwaitclose \
-progressoff progresson progressset random regdelete regread regwrite round run runasset runwait send seterror \
-shutdown sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton sqrt statusbargettext string \
-stringaddcr stringformat stringinstr stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint \
-stringislower stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid stringreplace \
-stringright stringsplit stringstripcr stringstripws stringtrimleft stringtrimright stringupper tan timerstart \
-timerstop tooltip traytip ubound urldownloadtofile winactivate winactive winclose winexists wingetcaretpos \
-wingetclasslist wingetclientsize wingethandle wingetpos wingetstate wingettext wingettitle winkill winmenuselectitem \
-winminimizeall winminimizeallundo winmove winsetontop winsetstate winsettitle winwait winwaitactive winwaitclose \
-winwaitnotactive
-
-keywords3.$(file.patterns.au3)= @appdatacommondir @appdatadir @autoitversion @commonfilesdir @compiled \
- computername @comspec @cr @crlf @desktopcommondir @desktopdir @desktopheight @desktopwidth @documentscommondir @error \
- favoritescommondir @favoritesdir @homedrive @homepath \
- homeshare @hour @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @lf @logondnsdomain \
- logondomain @logonserver @mday @min @mon @mydocumentsdir @osbuild @oslang @osservicepack \
- ostype @osversion @programfilesdir @programscommondir @programsdir @scriptdir @scriptfullpath @scriptname @sec \
- startmenucommondir @startmenudir @startupcommondir @startupdir @sw_hide @sw_maximize @sw_minimize @sw_restore @sw_show \
- systemdir @tab @tempdir @username @userprofiledir @wday @windowsdir @workingdir @yday @year @year
-
-keywords4.$(file.patterns.au3)= {!} {#} {^} {{} {}} {+} {alt} {altdown} {appskey} {asc nnnn} {backspace} {browser_back} {browser_favorites} \
-{browser_forward} {browser_home} {browser_refresh} {browser_search} {browser_stop} {capslock} {ctrlbreak} \
-{ctrldown} {delete} {down} {end} {enter} {escape} {f1} {f10} {f11} {f12} {f2} {f3} {f4} {f5} {f6} {f7} {f8} {f9} \
-{home} {insert} {lalt} {launch_app1} {launch_app2} {launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} \
+keywords2.$(file.patterns.au3)= \
+ abs acos adlibdisable adlibenable asc asin atan autoitsetoption autoitwingettitle autoitwinsettitle \
+  bitand bitnot bitor bitshift bitxor blockinput break call cdtray chr clipget clipput controlclick \
+  controlcommand controldisable controlenable controlfocus controlgetfocus controlgetpos controlgettext \
+  controlhide controlmove controlsend controlsettext controlshow cos dec dircopy dircreate dirmove \
+  dirremove drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype drivesetlabel \
+  drivespacefree drivespacetotal drivestatus envget envset envupdate eval exp filechangedir fileclose \
+  filecopy filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile filegetattrib \
+  filegetlongname filegetshortname filegetsize filegettime filegetversion fileinstall filemove \
+  fileopen fileopendialog fileread filereadline filerecycle filerecycleempty filesavedialog fileselectfolder \
+  filesetattrib filesettime filewrite filewriteline guicreate guicreateex guidefaultfont guidelete \
+  guigetcontrolstate guihide guimsg guiread guirecvmsg guisendmsg guisetcontrol guisetcontroldata \
+  guisetcontrolex guisetcontrolfont guisetcontrolnotify guisetcoord guisetcursor guishow guiwaitclose \
+  guiwrite hex hotkeyset inidelete iniread iniwrite inputbox int isadmin isarray isdeclared isfloat \
+  isint isnumber isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor \
+  mousegetpos mousemove mouseup mousewheel msgbox number pixelchecksum pixelgetcolor pixelsearch \
+  processclose processexists processsetpriority processwait processwaitclose progressoff progresson \
+  progressset random regdelete regenumkey regenumval regread regwrite round run runasset runwait \
+  send seterror shutdown sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton \
+  sqrt statusbargettext string stringaddcr stringformat stringinstr stringisalnum stringisalpha \
+  stringisascii stringisdigit stringisfloat stringisint stringislower stringisspace stringisupper \
+  stringisxdigit stringleft stringlen stringlower stringmid stringreplace stringright stringsplit \
+  stringstripcr stringstripws stringtrimleft stringtrimright stringupper tan timerstart timerstop \
+  tooltip traytip ubound urldownloadtofile winactivate winactive winclose winexists wingetcaretpos \
+  wingetclasslist wingetclientsize wingethandle wingetpos wingetstate wingettext wingettitle \
+  winkill winmenuselectitem winminimizeall winminimizeallundo winmove winsetontop winsetstate \
+  winsettitle winwait winwaitactive winwaitclose winwaitnotactive
+
+keywords3.$(file.patterns.au3)= \
+ @appdatacommondir @appdatadir @autoitversion @commonfilesdir @compiled @computername @comspec \
+  @cr @crlf @desktopcommondir @desktopdir @desktopheight @desktopwidth @documentscommondir @error \
+  @favoritescommondir @favoritesdir @homedrive @homepath @homeshare @hour @ipaddress1 @ipaddress2 \
+  @ipaddress3 @ipaddress4 @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @mydocumentsdir \
+  @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir @programscommondir @programsdir \
+  @scriptdir @scriptfullpath @scriptname @sec @startmenucommondir @startmenudir @startupcommondir \
+  @startupdir @sw_hide @sw_maximize @sw_minimize @sw_restore @sw_show @systemdir @tab @tempdir \
+  @userprofiledir @username @wday @windowsdir @workingdir @yday @year
+
+keywords4.$(file.patterns.au3)= {!} {#} {^} {{} {}} {+} {alt} {altdown} {altup} {appskey} {asc} {backspace} {browser_back} \
+{browser_favorites} {browser_forward} {browser_home} {browser_refresh} {browser_search} {browser_stop} {bs} {capslock} {ctrlbreak} \
+{ctrldown} {ctrlup} {del} {delete} {down} {end} {enter} {esc} {escape} {f1} {f10} {f11} {f12} {f2} {f3} {f4} {f5} {f6} {f7} {f8} {f9} \
+{home} {ins} {insert} {lalt} {launch_app1} {launch_app2} {launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} \
 {lwindown} {media_next} {media_play_pause} {media_prev} {media_stop} {numlock} \
 {numpad0} {numpad1} {numpad2} {numpad3} {numpad4} {numpad5} {numpad6} {numpad7} {numpad8} {numpad9} \
 {numpadadd} {numpaddiv} {numpaddot} {numpadenter} {numpadmult} {numpadsub} {pause} {pgdn} {pgup} \
-{printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {shiftdown} {sleep} {space} {tab} {up} \
+{printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {scrolllock} {shiftdown} {shiftup} {sleep} {space} {tab} {up} \
 {volume_down} {volume_mute} {volume_up}
 
+keywords5.$(file.patterns.au3)= #include #include-once
 
+keywords6.$(file.patterns.au3)= #region #endregion
 
-
-style.au3.0=fore:#000000,$(font.au3s)
-
+style.au3.0=fore:#000000
 style.au3.1=fore:#009933,italics
-
 style.au3.2=fore:#669900,italics
-
-style.au3.3=fore:#CC0099,bold
-
+style.au3.3=fore:#AC00A9,bold,italics
 style.au3.4=fore:#000090,bold,italics
-
 style.au3.5=fore:#0000FF,bold
-
 style.au3.6=fore:#FF33FF,bold
-
 style.au3.7=fore:#9999CC,bold
-
 style.au3.8=fore:#FF0000,bold
-
 style.au3.9=fore:#AA0000,bold
-
 style.au3.10=fore:#FF8800,bold
+style.au3.11=fore:#F000FF,italics
+style.au3.12=fore:#A00FF0,italics
+style.au3.13=fore:#FF0000,bold
+style.au3.14=fore:#0000FF,bold,italics
 
 filter.ave=AVE (ave)|*.ave|
 
@@ -640,7 +760,6 @@
 word.characters.$(file.patterns.ave)=$(word.chars.ave)
 
 statement.indent.$(file.patterns.ave)=1 else for if while then
-statement.end.$(file.patterns.ave)=1 end
 statement.lookback.$(file.patterns.ave)=1 end
 
 
@@ -738,8 +857,79 @@
 read.view  ref.input  ref.display selectdo  selectempty  selecteos \
 when.field.changes  while
 
-statement.end.$(file.patterns.baan)=1 endif endwhile endfor endselect return
 statement.lookback.$(file.patterns.baan)=1 endif endwhile endfor endselect return
+
+file.patterns.blitzbasic=*.bb
+
+filter.blitzbasic=BlitzBasic (bb)|$(file.patterns.blitzbasic)|
+
+lexer.$(file.patterns.blitzbasic)=blitzbasic
+
+
+keywordclass.blitzbasic=abs accepttcpstream acos after and apptitle asc asin atan atan2 \
+automidhandle autosuspend availvidmem backbuffer banksize before bin calldll \
+case ceil changedir channelpan channelpitch channelplaying channelvolume chr \
+closedir closefile closemovie closetcpserver closetcpstream closeudpstream cls \
+clscolor color colorblue colorgreen colorred commandline const copybank copyfile \
+copyimage copypixel copypixelfast copyrect copystream cos countgfxdrivers \
+countgfxmodes counthostips createbank createdir createimage createnetplayer \
+createprocess createtcpserver createtimer createudpstream currentdate currentdir \
+currenttime data debuglog default delay delete deletedir deletefile \
+deletenetplayer desktopbuffer dim dottedip drawblock drawblockrect drawimage \
+drawimagerect drawmovie each else else if elseif end end function end if end \
+select end type endgraphics endif eof execfile exit exp false field filepos \
+filesize filetype first flip float floor flushjoy flushkeys flushmouse \
+fontheight fontname fontsize fontstyle fontwidth for forever freebank freefont \
+freeimage freesound freetimer frontbuffer function gammablue gammagreen gammared \
+getcolor getenv getkey getmouse gfxdrivername gfxmodedepth gfxmodeexists \
+gfxmodeformat gfxmodeheight gfxmodewidth global gosub goto grabimage graphics \
+graphicsbuffer graphicsdepth graphicsformat graphicsheight graphicswidth \
+handleimage hex hidepointer hostip hostnetgame if imagebuffer imageheight \
+imagerectcollide imagerectoverlap imagescollide imagesoverlap imagewidth \
+imagexhandle imageyhandle include input insert instr int joinnetgame joydown \
+joyhat joyhit joypitch joyroll joytype joyu joyudir joyv joyvdir joyx joyxdir \
+joyy joyyaw joyydir joyz joyzdir keydown keyhit keywait last left len line \
+loadanimimage loadbuffer loadfont loadimage loadsound local lockbuffer \
+lockedformat lockedpitch lockedpixels log log10 loopsound lower lset maskimage \
+mid midhandle millisecs mod morefiles mousedown mousehit mousex mousexspeed \
+mousey mouseyspeed mousez mousezspeed movemouse movieheight movieplaying \
+moviewidth netmsgdata netmsgfrom netmsgto netmsgtype netplayerlocal \
+netplayername new next nextfile not null openfile openmovie opentcpstream or \
+origin oval pausechannel pausetimer peekbyte peekfloat peekint peekshort pi \
+playcdtrack playmusic playsound plot pokebyte pokefloat pokeint pokeshort print \
+queryobject rand read readavail readbyte readbytes readdir readfile readfloat \
+readint readline readpixel readpixelfast readshort readstring rect rectsoverlap \
+recvnetmsg recvudpmsg repeat replace resettimer resizebank resizeimage restore \
+resumechannel resumetimer return right rnd rndseed rotateimage rset runtimeerror \
+sar savebuffer saveimage scaleimage scanline seedrnd seekfile select sendnetmsg \
+sendudpmsg setbuffer setenv setfont setgamma setgfxdriver sgn shl showpointer \
+shr sin soundpan soundpitch soundvolume sqr startnetgame step stop stopchannel \
+stopnetgame str string stringheight stringwidth systemproperty tan tcpstreamip \
+tcpstreamport tcptimeouts text tformfilter tformimage then tileblock tileimage \
+timerticks to totalvidmem trim true type udpmsgip udpmsgport udpstreamip \
+udpstreamport udptimeouts unlockbuffer until updategamma upper viewport vwait \
+waitkey waitmouse waittimer wend while write writebyte writebytes writefile \
+writefloat writeint writeline writepixel writepixelfast writeshort writestring \
+xor
+
+keywords.$(file.patterns.blitzbasic)=$(keywordclass.blitzbasic)
+
+style.blitzbasic.0=fore:#000000
+style.blitzbasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+style.blitzbasic.2=$(colour.number)
+style.blitzbasic.3=$(colour.keyword)
+style.blitzbasic.4=$(colour.string)
+style.blitzbasic.6=$(colour.operator)
+style.blitzbasic.7=$(style.blitzbasic.0)
+style.blitzbasic.10=$(colour.keyword)
+style.blitzbasic.11=$(colour.keyword)
+style.blitzbasic.12=$(colour.keyword)
+style.blitzbasic.15=$(colour.preproc)
+style.blitzbasic.16=$(colour.error)
+style.blitzbasic.17=$(colour.number)
+style.blitzbasic.18=$(colour.number)
+
+
 filter.bullant=Bullant (.ant)|*.ant|
 
 file.patterns.bullant=*.ant
@@ -807,65 +997,416 @@
 command.build.subsystem.*.ant=
 
 
-filter.conf=Apache Conf (conf)|*.conf|
-file.patterns.conf=*.conf
+file.patterns.caml=*.ml;*.mli
+
+filter.caml=Objective Caml (ml mli)|$(file.patterns.caml)|
+
+lexer.*.caml=caml
+lexer.$(file.patterns.caml)=caml
+
+
+keywordstandard.caml= \
+and as assert asr begin class \
+constraint do done downto else end \
+exception external false for fun function \
+functor if in include inherit initializer \
+land lazy let lor lsl lsr \
+lxor match method mod module mutable \
+new object of open or private \
+rec sig struct then to true \
+try type val virtual when while \
+with
+keywords.$(file.patterns.caml)=$(keywordstandard.caml)
+
+keywordoptional1.caml= \
+option Some None ignore ref lnot succ pred parser
+keywords2.$(file.patterns.caml)=$(keywordoptional1.caml)
+
+keywordoptional2.caml= \
+array bool char float int list string unit
+keywords3.$(file.patterns.caml)=$(keywordoptional2.caml)
+
+word.characters.$(file.patterns.caml)=$(chars.alpha)$(chars.numeric)_'`
+
+comment.stream.start.caml=(*
+comment.stream.end.caml=*)
+comment.box.start.caml=(*
+comment.box.middle.caml= *
+comment.box.end.caml= *)
+
+
+style.caml.32=$(font.base)
+style.caml.0=fore:#808080
+style.caml.1=
+style.caml.2=fore:#000000,back:#ffe0ff
+style.caml.3=$(colour.keyword),bold
+style.caml.4=fore:#000000,back:#e0e0ff
+style.caml.5=fore:#a0000,bold
+style.caml.6=back:#C0C0C0,$(font.base)
+style.caml.7=$(colour.operator),bold
+style.caml.8=fore:#000000,back:#ffff00
+style.caml.9=fore:#000000,back:#ffff00
+style.caml.11=fore:#000000,back:#ffff00
+style.caml.12=$(colour.code.comment.box),$(font.code.comment.box)
+style.caml.13=$(colour.embedded.comment),$(font.code.comment.box)
+style.caml.14=$(colour.embedded.comment),$(font.code.comment.box)
+style.caml.15=$(colour.embedded.comment),$(font.code.comment.box)
+
+braces.caml.style=7
+
+command.compile.$(file.patterns.caml)=ocamlc -c $(FileNameExt)
+
+filter.cmake=CMake (CMakeLists.txt, *.cmake, *.ctest)|CMakeLists.txt;*.cmake;*.cmake.in;*.ctest;*.ctest.in|
+file.patterns.cmake=CMakeLists.txt;*.cmake;*.cmake.in;*.ctest;*.ctest.in
+lexer.$(file.patterns.cmake)=cmake
+
+keywords.$(file.patterns.cmake)= add_custom_command \
+add_custom_target \
+add_definitions \
+add_dependencies \
+add_executable \
+add_library \
+add_subdirectory \
+add_test \
+aux_source_directory \
+build_command \
+build_name \
+cmake_minimum_required \
+configure_file \
+create_test_sourcelist \
+else \
+elseif \
+enable_language \
+enable_testing \
+endforeach \
+endif \
+endmacro \
+endwhile \
+exec_program \
+execute_process \
+export_library_dependencies \
+file \
+find_file \
+find_library \
+find_package \
+find_path \
+find_program \
+fltk_wrap_ui \
+foreach \
+get_cmake_property \
+get_directory_property \
+get_filename_component \
+get_source_file_property \
+get_target_property \
+get_test_property \
+if \
+include \
+include_directories \
+include_external_msproject \
+include_regular_expression \
+install \
+install_files \
+install_programs \
+install_targets \
+link_directories \
+link_libraries \
+list \
+load_cache \
+load_command \
+macro \
+make_directory \
+mark_as_advanced \
+math \
+message \
+option \
+output_required_files \
+project \
+qt_wrap_cpp \
+qt_wrap_ui \
+remove \
+remove_definitions \
+separate_arguments \
+set \
+set_directory_properties \
+set_source_files_properties \
+set_target_properties \
+set_tests_properties \
+site_name \
+source_group \
+string \
+subdir_depends \
+subdirs \
+target_link_libraries \
+try_compile \
+try_run \
+use_mangled_mesa \
+utility_source \
+variable_requires \
+vtk_make_instantiator \
+vtk_wrap_java \
+vtk_wrap_python \
+vtk_wrap_tcl \
+while \
+write_file
+ 
+keywords2.$(file.patterns.cmake)= ABSOLUTE \
+ABSTRACT \
+ADDITIONAL_MAKE_CLEAN_FILES \
+ALL \
+AND \
+APPEND \
+ARGS \
+ASCII \
+BEFORE \
+CACHE \
+CACHE_VARIABLES \
+CLEAR \
+COMMAND \
+COMMANDS \
+COMMAND_NAME \
+COMMENT \
+COMPARE \
+COMPILE_FLAGS \
+COPYONLY \
+DEFINED \
+DEFINE_SYMBOL \
+DEPENDS \
+DOC \
+EQUAL \
+ESCAPE_QUOTES \
+EXCLUDE \
+EXCLUDE_FROM_ALL \
+EXISTS \
+EXPORT_MACRO \
+EXT \
+EXTRA_INCLUDE \
+FATAL_ERROR \
+FILE \
+FILES \
+FORCE \
+FUNCTION \
+GENERATED \
+GLOB \
+GLOB_RECURSE \
+GREATER \
+GROUP_SIZE \
+HEADER_FILE_ONLY \
+HEADER_LOCATION \
+IMMEDIATE \
+INCLUDES \
+INCLUDE_DIRECTORIES \
+INCLUDE_INTERNALS \
+INCLUDE_REGULAR_EXPRESSION \
+LESS \
+LINK_DIRECTORIES \
+LINK_FLAGS \
+LOCATION \
+MACOSX_BUNDLE \
+MACROS \
+MAIN_DEPENDENCY \
+MAKE_DIRECTORY \
+MATCH \
+MATCHALL \
+MATCHES \
+MODULE \
+NAME \
+NAME_WE \
+NOT \
+NOTEQUAL \
+NO_SYSTEM_PATH \
+OBJECT_DEPENDS \
+OPTIONAL \
+OR \
+OUTPUT \
+OUTPUT_VARIABLE \
+PATH \
+PATHS \
+POST_BUILD \
+POST_INSTALL_SCRIPT \
+PREFIX \
+PREORDER \
+PRE_BUILD \
+PRE_INSTALL_SCRIPT \
+PRE_LINK \
+PROGRAM \
+PROGRAM_ARGS \
+PROPERTIES \
+QUIET \
+RANGE \
+READ \
+REGEX \
+REGULAR_EXPRESSION \
+REPLACE \
+REQUIRED \
+RETURN_VALUE \
+RUNTIME_DIRECTORY \
+SEND_ERROR \
+SHARED \
+SOURCES \
+STATIC \
+STATUS \
+STREQUAL \
+STRGREATER \
+STRLESS \
+SUFFIX \
+TARGET \
+TOLOWER \
+TOUPPER \
+VAR \
+VARIABLES \
+VERSION \
+WIN32 \
+WRAP_EXCLUDE \
+WRITE \
+APPLE  \
+MINGW \
+MSYS \
+CYGWIN  \
+BORLAND \
+WATCOM \
+MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 \
+OFF ON \
+
+
+statement.indent.$(file.patterns.cmake)=5 if while foreach macro
+
+style.cmake.0=fore:#000000,$(font.base)
+style.cmake.1=fore:#007F00,$(font.comment)
+style.cmake.2=fore:#7F007F,back:#EEEEEE
+style.cmake.3=fore:#7F007F,back:#EEEEEE
+style.cmake.4=fore:#7F007F,back:#EEEEEE
+style.cmake.5=fore:#00007F,bold
+style.cmake.6=fore:#800000
+style.cmake.7=fore:#CC3300
+style.cmake.8=fore:#000000
+style.cmake.9=fore:#00007F,bold
+style.cmake.10=fore:#00007F,bold
+style.cmake.11=fore:#00007F,bold
+style.cmake.12=fore:#00007F,bold
+style.cmake.13=fore:#CC3300,back:#EEEEEE
+style.cmake.14=$(colour.number)
+
+file.patterns.conf=*.conf;.htaccess
+filter.conf=Apache Conf (conf)|$(file.patterns.conf)|
 lexer.$(file.patterns.conf)=conf
 
 keywords.$(file.patterns.conf)=\
-accessconfig accessfilename action addalt \
-addaltbyencoding addaltbytype addcharset \
-adddefaultcharset adddescription \
-addencoding addhandler addicon addiconbyencoding \
-addiconbytype addlanguage addmodule addmoduleinfo \
-addtype agentlog alias aliasmatch \
-allow allowconnect allowoverride anonymous \
-anonymous_authoritative anonymous_logemail anonymous_mustgiveemail \
-anonymous_nouserid anonymous_verifyemail authauthoritative \
-authdbauthoritative authdbgroupfile authdbmauthoritative \
-authdbmgroupfile authdbmgroupfile authdbuserfile authdbmuserfile \
-authdigestfile authgroupfile authname authtype \
-authuserfile bindaddress browsermatch browsermatchnocase \
-bs2000account cachedefaultexpire cachedirlength cachedirlevels \
-cacheforcecompletion cachegcinterval cachelastmodifiedfactor cachemaxexpire \
-cachenegotiateddocs cacheroot cachesize checkspelling \
-clearmodulelist contentdigest cookieexpires cookielog \
-cookielog cookietracking coredumpdirectory customlog \
+acceptmutex acceptpathinfo accessconfig accessfilename \
+action addalt addaltbyencoding addaltbytype addcharset \
+adddefaultcharset adddescription addencoding \
+addhandler addicon addiconbyencoding addiconbytype \
+addinputfilter addlanguage addmodule addmoduleinfo \
+addoutputfilter addoutputfilterbytype addtype agentlog \
+alias aliasmatch all allow allowconnect \
+allowencodedslashes allowoverride anonymous \
+anonymous_authoritative anonymous_logemail \
+anonymous_mustgiveemail anonymous_nouserid \
+anonymous_verifyemail assignuserid authauthoritative \
+authdbauthoritative authdbgroupfile \
+authdbmauthoritative authdbmgroupfile authdbmtype \
+authdbmuserfile authdbuserfile authdigestalgorithm \
+authdigestdomain authdigestfile authdigestgroupfile \
+authdigestnccheck authdigestnonceformat \
+authdigestnoncelifetime authdigestqop \
+authdigestshmemsize authgroupfile \
+authldapauthoritative authldapbinddn \
+authldapbindpassword authldapcharsetconfig \
+authldapcomparednonserver authldapdereferencealiases \
+authldapenabled authldapfrontpagehack \
+authldapgroupattribute authldapgroupattributeisdn \
+authldapremoteuserisdn authldapurl authname authtype \
+authuserfile bindaddress browsermatch \
+browsermatchnocase bs2000account bufferedlogs \
+cachedefaultexpire cachedirlength cachedirlevels \
+cachedisable cacheenable cacheexpirycheck cachefile \
+cacheforcecompletion cachegcclean cachegcdaily \
+cachegcinterval cachegcmemusage cachegcunused \
+cacheignorecachecontrol cacheignoreheaders \
+cacheignorenolastmod cachelastmodifiedfactor \
+cachemaxexpire cachemaxfilesize cacheminfilesize \
+cachenegotiateddocs cacheroot cachesize \
+cachetimemargin cgimapextension charsetdefault \
+charsetoptions charsetsourceenc checkspelling \
+childperuserid clearmodulelist contentdigest \
+cookiedomain cookieexpires cookielog cookiename \
+cookiestyle cookietracking coredumpdirectory customlog \
+dav davdepthinfinity davlockdb davmintimeout \
 defaulticon defaultlanguage defaulttype define \
-deny directory directorymatch directoryindex \
-documentroot errordocument errorlog example \
-expiresactive expiresbytype expiresdefault extendedstatus \
-fancyindexing files filesmatch forcetype \
-group header headername hostnamelookups \
-identitycheck ifdefine ifmodule imapbase \
-imapdefault imapmenu include indexignore \
-indexoptions keepalive keepalivetimeout languagepriority \
-limit limitexcept limitrequestbody limitrequestfields \
-limitrequestfieldsize limitrequestline listen listenbacklog \
-loadfile loadmodule location locationmatch \
-lockfile logformat loglevel maxclients \
-maxkeepaliverequests maxrequestsperchild maxspareservers metadir \
-metafiles metasuffix mimemagicfile minspareservers \
-mmapfile namevirtualhost nocache options order \
-passenv pidfile port proxyblock proxydomain \
-proxypass proxypassreverse proxyreceivebuffersize proxyremote \
-proxyrequests proxyvia qsc readmename \
-redirect redirectmatch redirectpermanent redirecttemp \
-refererignore refererlog removehandler require \
-resourceconfig rewritebase rewritecond rewriteengine \
-rewritelock rewritelog rewriteloglevel rewritemap \
-rewriteoptions rewriterule rlimitcpu rlimitmem \
-rlimitnproc satisfy scoreboardfile script \
-scriptalias scriptaliasmatch scriptinterpretersource scriptlog \
-scriptlogbuffer scriptloglength sendbuffersize \
-serveradmin serveralias servername serverpath \
-serverroot serversignature servertokens servertype \
-setenv setenvif setenvifnocase sethandler \
-singlelisten startservers threadsperchild timeout \
-transferlog typesconfig unsetenv usecanonicalname \
-user userdir virtualhost virtualdocumentroot \
-virtualdocumentrootip virtualscriptalias virtualscriptaliasip \
-xbithack from all
-
+deflatebuffersize deflatecompressionlevel \
+deflatefilternote deflatememlevel deflatewindowsize \
+deny directory directoryindex directorymatch \
+directoryslash documentroot dumpioinput dumpiooutput \
+enableexceptionhook enablemmap enablesendfile \
+errordocument errorlog example expiresactive \
+expiresbytype expiresdefault extendedstatus \
+extfilterdefine extfilteroptions fancyindexing \
+fileetag files filesmatch forcelanguagepriority \
+forcetype forensiclog from group header headername \
+hostnamelookups identitycheck ifdefine ifmodule \
+imapbase imapdefault imapmenu include indexignore \
+indexoptions indexorderdefault isapiappendlogtoerrors \
+isapiappendlogtoquery isapicachefile isapifakeasync \
+isapilognotsupported isapireadaheadbuffer keepalive \
+keepalivetimeout languagepriority ldapcacheentries \
+ldapcachettl ldapconnectiontimeout ldapopcacheentries \
+ldapopcachettl ldapsharedcachefile ldapsharedcachesize \
+ldaptrustedca ldaptrustedcatype limit limitexcept \
+limitinternalrecursion limitrequestbody \
+limitrequestfields limitrequestfieldsize \
+limitrequestline limitxmlrequestbody listen \
+listenbacklog loadfile loadmodule location \
+locationmatch lockfile logformat loglevel maxclients \
+maxkeepaliverequests maxmemfree maxrequestsperchild \
+maxrequestsperthread maxspareservers maxsparethreads \
+maxthreads maxthreadsperchild mcachemaxobjectcount \
+mcachemaxobjectsize mcachemaxstreamingbuffer \
+mcacheminobjectsize mcacheremovalalgorithm mcachesize \
+metadir metafiles metasuffix mimemagicfile \
+minspareservers minsparethreads mmapfile \
+modmimeusepathinfo multiviewsmatch namevirtualhost \
+nocache noproxy numservers nwssltrustedcerts \
+nwsslupgradeable options order passenv pidfile port \
+protocolecho proxy proxybadheader proxyblock \
+proxydomain proxyerroroverride proxyiobuffersize \
+proxymatch proxymaxforwards proxypass proxypassreverse \
+proxypreservehost proxyreceivebuffersize proxyremote \
+proxyremotematch proxyrequests proxytimeout proxyvia \
+qsc readmename redirect redirectmatch \
+redirectpermanent redirecttemp refererignore \
+refererlog removecharset removeencoding removehandler \
+removeinputfilter removelanguage removeoutputfilter \
+removetype requestheader require resourceconfig \
+rewritebase rewritecond rewriteengine rewritelock \
+rewritelog rewriteloglevel rewritemap rewriteoptions \
+rewriterule rlimitcpu rlimitmem rlimitnproc satisfy \
+scoreboardfile script scriptalias scriptaliasmatch \
+scriptinterpretersource scriptlog scriptlogbuffer \
+scriptloglength scriptsock securelisten sendbuffersize \
+serveradmin serveralias serverlimit servername \
+serverpath serverroot serversignature servertokens \
+servertype setenv setenvif setenvifnocase sethandler \
+setinputfilter setoutputfilter singlelisten ssiendtag \
+ssierrormsg ssistarttag ssitimeformat ssiundefinedecho \
+sslcacertificatefile sslcacertificatepath \
+sslcarevocationfile sslcarevocationpath \
+sslcertificatechainfile sslcertificatefile \
+sslcertificatekeyfile sslciphersuite sslengine \
+sslmutex ssloptions sslpassphrasedialog sslprotocol \
+sslproxycacertificatefile sslproxycacertificatepath \
+sslproxycarevocationfile sslproxycarevocationpath \
+sslproxyciphersuite sslproxyengine \
+sslproxymachinecertificatefile \
+sslproxymachinecertificatepath sslproxyprotocol \
+sslproxyverify sslproxyverifydepth sslrandomseed \
+sslrequire sslrequiressl sslsessioncache \
+sslsessioncachetimeout sslusername sslverifyclient \
+sslverifydepth startservers startthreads \
+suexecusergroup threadlimit threadsperchild \
+threadstacksize timeout transferlog typesconfig \
+unsetenv usecanonicalname user userdir \
+virtualdocumentroot virtualdocumentrootip virtualhost \
+virtualscriptalias virtualscriptaliasip \
+win32disableacceptex xbithack
 
 keywords2.$(file.patterns.conf)=\
 on off standalone inetd \
@@ -887,27 +1428,24 @@
 command.compile.$(file.patterns.conf)=httpd -t -f $(FilePath)
 command.build.$(file.patterns.conf)=httpd -t -f $(FilePath)
 
-
-
-
-
-file.patterns.cpp=*.c;*.cc;*.cpp;*.cxx;*.cs;*.h;*.hh;*.hpp;*.hxx;*.sma
+file.patterns.cpp=*.c;*.cc;*.cpp;*.cxx;*.h;*.hh;*.hpp;*.hxx;*.sma
+file.patterns.cplusplus=*.cc;*.cpp;*.cxx
 file.patterns.test=*.pln;*.inc;*.t
 file.patterns.cs=*.cs
 file.patterns.rc=*.rc;*.rc2;*.dlg
 file.patterns.idl=*.idl;*.odl
 file.patterns.flash=*.as;*.asc;*.jsfl
-file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash)
+file.patterns.ch=*.ch;*.chf;*.chs
+file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash);$(file.patterns.ch)
 
 filter.cpp=C/C++ (c cc cpp cxx cs h hh hxx hpp dlg rc rc2 mak)|\
-$(file.patterns.cpp);$(file.patterns.rc);*.mak;make*|
+$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.rc);*.mak;make*|
 filter.java=Java (java)|*.java|
 filter.js=JavaScript (js)|*.js|
 filter.idl=IDL (idl odl)|$(file.patterns.idl)|
 filter.test=SilkTest (pln inc t)|$(file.patterns.test)|
 filter.flash=Flash (as asc jsfl)|$(file.patterns.flash)|
-
-file.patterns.braces=$(file.patterns.cpp);$(file.patterns.idl);*.java;$(file.patterns.cs);$(file.patterns.test)
+filter.ch=Ch (ch chf chs)|$(file.patterns.ch)|
 
 lexer.*.java=cpp
 lexer.$(file.patterns.cpp)=cpp
@@ -917,6 +1455,7 @@
 lexer.*.js=cpp
 lexer.$(file.patterns.test)=cpp
 lexer.$(file.patterns.flash)=cpp
+lexer.$(file.patterns.ch)=cpp
 
 keywordclass.cpp=and and_eq asm auto bitand bitor bool break \
 case catch char class compl const const_cast continue \
@@ -933,25 +1472,26 @@
 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
 if image include ingroup internal invariant interface latexonly li line link \
 mainpage name namespace nosubgrouping note overload \
-p page par param post pre ref relates remarks return retval \
+p page par param param[in] param[out] \
+post pre ref relates remarks return retval \
 sa section see showinitializer since skip skipline struct subsection \
 test throw todo typedef union until \
 var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
 
 word.chars.cxx=$(chars.alpha)$(chars.numeric)_#
 word.characters.$(file.patterns.cpp)=$(word.chars.cxx)
+word.characters.$(file.patterns.cs)=$(word.chars.cxx)
+calltip.cpp.word.characters=$(chars.alpha)$(chars.numeric)_
 comment.block.cpp=//~
 comment.stream.start.cpp=/*
 comment.stream.end.cpp=*/
 comment.box.start.cpp=/*
 comment.box.middle.cpp= *
 comment.box.end.cpp= */
-fold.comment=1
-fold.preprocessor=1
 
-statement.indent.$(file.patterns.c.like)=5 case catch class default do else finally \
-for if private protected public struct try union while
-statement.end.$(file.patterns.c.like)=10 ;
+file.patterns.c.except.cpp=$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash);$(file.patterns.ch)
+statement.indent.$(file.patterns.c.except.cpp)=5 case default do else for if while
+statement.indent.$(file.patterns.cpp)=5 case default do else for if private protected public while
 statement.lookback.$(file.patterns.c.like)=20
 block.start.$(file.patterns.c.like)=10 {
 block.end.$(file.patterns.c.like)=10 }
@@ -962,6 +1502,32 @@
 preprocessor.middle.$(file.patterns.cpp)=else elif
 preprocessor.end.$(file.patterns.cpp)=endif
 
+preprocessor.symbol.$(file.patterns.cs)=#
+preprocessor.start.$(file.patterns.cs)=if region
+preprocessor.middle.$(file.patterns.cs)=else elif
+preprocessor.end.$(file.patterns.cs)=endif endregion
+
+keywordclass.ch=\
+auto array bool break case char class complex ComplexInf ComplexNaN \
+const continue default delete \
+do double else enum export extern float for foreach goto if Inf inline int \
+long namespace NaN new NULL private public register restrict return short \
+signed sizeof static string_t struct switch this typedef union unsigned \
+using void volatile wchar_t while __declspec
+keywords.$(file.patterns.ch)=$(keywordclass.ch)
+word.chars.ch=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.ch)=$(word.chars.cxx)
+comment.block.ch=//~
+comment.stream.start.ch=/*
+comment.stream.end.ch=*/
+comment.box.start.ch=/*
+comment.box.middle.ch= *
+comment.box.end.ch= */
+preprocessor.symbol.$(file.patterns.ch)=#
+preprocessor.start.$(file.patterns.ch)=if ifdef ifndef
+preprocessor.middle.$(file.patterns.ch)=else elif
+preprocessor.end.$(file.patterns.ch)=endif
+
 keywordclass.cs=abstract as base bool break byte case catch char checked class \
 const continue decimal default delegate do double else enum \
 event explicit extern false finally fixed float for foreach goto if \
@@ -1083,37 +1649,29 @@
 style.cpp.18=fore:#804020,$(font.code.comment.doc)
 braces.cpp.style=10
 
-cc=g++ -pedantic -Os -fno-exceptions -c $(FileNameExt) -o $(FileName).o
+ccopts=-pedantic -Os
+cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
+ccc=gcc $(ccopts) -c $(FileNameExt) -o $(FileName).o
 
 make.command=make
-command.compile.*.c=$(cc)
+command.compile.*.c=$(ccc) -std=c99
 command.build.*.c=$(make.command)
 command.go.*.c=$(FileName)
 
-command.compile.*.cc=$(cc)
-command.build.*.cc=$(make.command)
-command.go.*.cc=$(FileName)
-
-command.compile.*.cpp=$(cc)
-command.build.*.cpp=$(make.command)
-command.go.*.cpp=$(FileName)
-
-command.compile.*.cxx=$(cc)
-command.build.*.cxx=$(make.command)
-command.go.*.cxx=$(FileName)
+command.compile.$(file.patterns.cplusplus)=$(cc)
+command.build.$(file.patterns.cplusplus)=$(make.command)
+command.go.$(file.patterns.cplusplus)=./$(FileName)
+command.go.needs.$(file.patterns.cplusplus)=g++ $(ccopts) $(FileNameExt) -o $(FileName)
 
 command.build.*.h=$(make.command)
 
-command.name.0.*.cxx=Indent
-command.0.*.cxx=astyle -tapO $(FileNameExt)
-command.is.filter.0.*.cxx=1
-
-command.name.1.*.cxx=Lint
-command.1.*.cxx=g++ -W -Wall -Wshadow -Wwrite-strings -Wold-style-cast \
-	-Woverloaded-virtual  -pedantic -Os -fno-exceptions -c $(FileNameExt)
-
-command.name.2.*.cxx=Execute Selection
-command.2.*.cxx=$(CurrentSelection)
+command.name.0.$(file.patterns.cpp)=Indent
+command.0.$(file.patterns.cpp)=astyle -tapOK -M8 $(FileNameExt)
+command.is.filter.0.$(file.patterns.cpp)=1
+
+command.name.1.$(file.patterns.cplusplus)=Lint
+command.1.$(file.patterns.cplusplus)=g++ -W -Wall -Wshadow -Wwrite-strings -Wold-style-cast \
+	-Woverloaded-virtual -pedantic -Os -fno-exceptions -c $(FileNameExt)
 
 if PLAT_WIN
 	command.compile.*.rc=windres $(FileNameExt) $(FileName).o
@@ -1129,19 +1687,158 @@
 	command.build.*.cs=csc /t:winexe $(FileNameExt) /r:system.dll,system.drawing.dll
 	command.go.*.cs=$(FileName)
 	command.go.subsystem.*.cs=1
+if PLAT_GTK
+	command.build.*.cs=mcs /t:winexe $(FileNameExt) /r:System,System.Drawing
+	command.go.*.cs=mono $(FileName).exe
+	command.go.subsystem.*.cs=1
 
 command.compile.*.java=javac $(FileNameExt)
 command.build.*.java=javac *.java
 command.go.*.java=java $(FileName)
 
+command.compile.*.ch=ch -n $(FileNameExt)
+command.build.*.ch=ch -n  $(FileNameExt)
+command.go.*.ch=ch -u $(FileNameExt)
+
+command.compile.*.as=mtasc -strict $(FileNameExt)
+command.build.*.as=mtasc -strict *.as
+
+file.patterns.csound=*.orc;*.sco;*.csd
+filter.csound=Csound (orc sco csd)|$(file.patterns.csound)|
+
+lexer.$(file.patterns.csound)=csound
+
+
+
+csound_opcodes=\
+	a i db in or zr Add Dec Div Inc Mul Sub abs and cos dam dec div exp \
+	fin fof fog inh ino inq ins int inx inz lfo log mac mod mul not out \
+	pan pow rms rnd shl sin sqr sub sum tab tan tb0 tb1 tb2 tb3 tb4 tb5 \
+	tb6 tb7 tb8 tb9 urd vco xin xor zar zaw zir ziw zkr zkw adsr babo \
+	buzz cent clip comb cosh diff divz fini fink fmb3 fof2 fold fout \
+	frac ftsr gain goto in32 inch init line maca moog mute nrpn outc \
+	outh outo outq outs outx outz peak port pset pvoc rand seed sinh \
+	sqrt stix tabw tanh tb10 tb11 tb12 tb13 tb14 tb15 tone vadd vco2 \
+	vdiv vexp vibr vmap vmul vpow wrap xout xyin zacl zarg zawm ziwm \
+	zkcl zkwm FLbox FLjoy FLrun adsyn ampdb atone birnd bqrez butbp \
+	butbr buthp butlp clear ctrl7 dbamp dconv delay dumpk endin endop \
+	event expon fouti foutk ftgen ftlen gauss gbuzz grain guiro igoto \
+	ihold instr integ kgoto limit linen log10 loopg loopl lpf18 madsr \
+	max_k metro noise nsamp oscil out32 outch outic outkc outq1 outq2 \
+	outq3 outq4 outs1 outs2 pareq pitch pluck portk print pvadd randh \
+	randi rbjeq readk reson rezzy rnd31 scans scanu sense space tab_i \
+	table tbvcf tempo timek times tival tonek tonex vaddv vbap4 vbap8 \
+	vbapz vcomb vcopy vdecr vdivv veloc vexpv vibes vincr vmult voice \
+	vport vpowv vpvoc vsubv vwrap wgbow xadsr zamod zkmod FLhide FLkeyb \
+	FLknob FLpack FLshow FLtabs FLtext active adsynt alpass areson \
+	atonek atonex bamboo bbcutm bbcuts biquad cabasa cauchy cggoto \
+	cigoto ckgoto clfilt cngoto convle cosinv cpsoct cpspch cpstun \
+	cpuprc cross2 crunch ctrl14 ctrl21 delay1 delayk delayr delayw \
+	deltap denorm diskin dumpk2 dumpk3 dumpk4 envlpx expseg filesr \
+	fiopen fmbell follow foscil foutir ftlen2 ftload ftmorf ftsave \
+	grain2 grain3 harmon hrtfer initc7 interp jitter linenr lineto \
+	linseg locsig loopge loople lorenz loscil lowres lpread lpslot \
+	mandel mandol mclock mdelay midic7 midiin midion mirror moscil \
+	mpulse mrtmsg mxadsr nlfilt noteon notnum ntrpol octave octcps \
+	octpch opcode oscbnk oscil1 oscil3 oscili osciln oscils oscilx \
+	outiat outipb outipc outkat outkpb outkpc pchoct phasor planet \
+	poscil printk prints pvread pvsftr pvsftw random readk2 readk3 \
+	readk4 reinit resonk resonr resonx resony resonz reverb rigoto \
+	s16b14 s32b14 sekere sfload sfplay shaker sininv spat3d spdist \
+	spsend strset table3 tablei tablew tabw_i taninv tigoto timout \
+	turnon upsamp vbap16 vcella vco2ft vdel_k vdelay vlimit vmultv \
+	vrandh vrandi wgclar xscans xscanu FLcolor FLcount FLgroup FLlabel \
+	FLpanel FLvalue aftouch ampdbfs ampmidi aresonk balance bexprnd \
+	biquada changed clockon cps2pch cpsmidi cpstmid cpstuni cpsxpch \
+	dbfsamp dcblock deltap3 deltapi deltapn deltapx dispfft display \
+	envlpxr exprand expsega expsegr filelen filter2 flanger fmmetal \
+	fmrhode fmvoice follow2 foscili fprints ftchnls ftloadk ftlptim \
+	ftsavek gogobel granule hilbert initc14 initc21 invalue jitter2 \
+	jspline linrand linsegr locsend logbtwo loopseg loscil3 lowresx \
+	lphasor lposcil lpreson lpshold marimba massign midic14 midic21 \
+	midichn midion2 midiout moogvcf noteoff nreverb nstrnum octmidi \
+	oscil1i outic14 outipat outkc14 outkpat pcauchy pchbend pchmidi \
+	phaser1 phaser2 pinkish poisson polyaft poscil3 printk2 printks \
+	product pvcross pvsanal pvsinfo pvsynth randomh randomi release \
+	repluck reverb2 rspline rtclock seqtime sfilist sfinstr sfplay3 \
+	sfplaym sfplist slider8 sndwarp soundin spat3di spat3dt specsum \
+	streson tableiw tablekt tableng tablera tablewa taninv2 tempest \
+	tlineto transeg trigger trigseq trirand turnoff unirand valpass \
+	vco2ift vdelay3 vdelayk vdelayx vexpseg vibrato vlinseg vlowres \
+	vmirror waveset weibull wgbrass wgflute wgpluck wguide1 wguide2 \
+	xtratim zakinit FLbutton FLcolor2 FLprintk FLroller FLscroll \
+	FLsetBox FLsetVal FLslider FLupdate betarand butterbp butterbr \
+	butterhp butterlp chanctrl clockoff convolve cpsmidib ctrlinit \
+	cuserrnd deltapxw distort1 downsamp duserrnd filepeak fmpercfl \
+	fmwurlie fprintks hsboscil lowpass2 lpfreson lpinterp lposcil3 \
+	maxalloc midictrl multitap nestedap octmidib oscilikt outvalue \
+	pchmidib powoftwo prealloc pvinterp pvsadsyn pvscross pvsfread \
+	pvsmaska rireturn samphold schedule semitone sensekey setksmps \
+	sfinstr3 sfinstrm sfplay3m sfpreset slider16 slider32 slider64 \
+	slider8f soundout specaddm specdiff specdisp specfilt spechist \
+	specptrk specscal spectrum sprintks subinstr svfilter tablegpw \
+	tableikt tablemix tableseg tablewkt tablexkt tb0_init tb1_init \
+	tb2_init tb3_init tb4_init tb5_init tb6_init tb7_init tb8_init \
+	tb9_init tempoval vco2init vdelayxq vdelayxs vdelayxw vecdelay \
+	wgpluck2 wterrain xscanmap zfilter2 FLbutBank FLgetsnap FLpackEnd \
+	FLprintk2 FLsetFont FLsetSize FLsetText FLsetsnap FLslidBnk \
+	FLtabsEnd dripwater eventname ktableseg noteondur osciliktp \
+	oscilikts pgmassign phasorbnk pitchamdf pvbufread readclock \
+	sandpaper scantable schedwhen sfinstr3m sfpassign slider16f \
+	slider32f slider64f sndwarpst soundoutc soundouts tablecopy \
+	tableigpw tableimix tablexseg tb10_init tb11_init tb12_init \
+	tb13_init tb14_init tb15_init timeinstk timeinsts vbap4move \
+	vbap8move vbapzmove vdelayxwq vdelayxws xscansmap FLgroupEnd \
+	FLloadsnap FLpack_end FLpanelEnd FLsavesnap FLsetAlign FLsetColor \
+	FLsetVal_i FLtabs_end filenchnls noteondur2 scanhammer schedkwhen \
+	tableicopy tambourine vbap16move vbaplsinit wgbowedbar FLgroup_end \
+	FLpanel_end FLscrollEnd FLsetColor2 mididefault midinoteoff \
+	sleighbells FLscroll_end subinstrinit FLsetPosition FLsetTextSize \
+	FLsetTextType midinoteoncps midinoteonkey midinoteonoct \
+	midinoteonpch midipitchbend schedwhenname FLsetTextColor \
+	schedkwhenname midicontrolchange midiprogramchange \
+	midipolyaftertouch midichannelaftertouch
+
+csound_header_stmts=sr kr ar ksmps nchnls
+
+csound_other_keywords=
+
+keywords.$(file.patterns.csound)=$(csound_opcodes)
+keywords2.$(file.patterns.csound)=$(csound_header_stmts)
+keywords3.$(file.patterns.csound)=$(csound_other_keywords)
+
+comment.block.csound=;
+
+
+style.csound.0=$(font.monospace)
+style.csound.1=$(font.monospace),fore:#669999
+style.csound.2=$(font.monospace),fore:#339933
+style.csound.3=$(font.monospace)
+style.csound.4=$(font.monospace)
+style.csound.5=
+style.csound.6=$(font.monospace),fore:#0000FF,bold
+style.csound.7=$(font.monospace),fore:#CC2200
+style.csound.8=$(font.monospace)
+style.csound.9=$(font.monospace)
+style.csound.10=$(font.monospace),fore:#660099,bold
+style.csound.11=$(font.monospace),fore:#660099
+style.csound.12=$(font.monospace),fore:#660099
+style.csound.13=$(font.monospace),fore:#660099
+style.csound.14=$(font.monospace),fore:#660099
+style.csound.15=$(font.monospace)
+style.csound.16=$(font.monospace)
+style.csound.17=$(font.monospace),fore:#000000,back:#E0C0E0,eolfilled
 
 filter.css=CSS (css)|*.css|
 lexer.*.css=css
 
+indent.size.*.css=4
+tab.size.*.css=4
+use.tabs.*.css=1
+
 keywordclass.css=\
-left right top bottom position \
-font-family font-style font-variant font-weight font-size font \
 color background-color background-image background-repeat background-attachment background-position background \
+font-family font-style font-variant font-weight font-size font \
 word-spacing letter-spacing text-decoration vertical-align text-transform text-align text-indent line-height \
 margin-top margin-right margin-bottom margin-left margin \
 padding-top padding-right padding-bottom padding-left padding \
@@ -1150,37 +1847,182 @@
 border-color border-style width height float clear \
 display white-space list-style-type list-style-image list-style-position list-style
 
+keywordclass.values=\
+auto none normal italic oblique small-caps bold bolder lighter \
+xx-small x-small small medium large x-large xx-large larger smaller \
+transparent repeat repeat-x repeat-y no-repeat scroll fixed \
+top bottom left center right justify both \
+underline overline line-through blink \
+baseline sub super text-top middle text-bottom \
+capitalize uppercase lowercase thin medium thick \
+dotted dashed solid double groove ridge inset outset \
+block inline list-item pre no-wrap inside outside \
+disc circle square decimal lower-roman upper-roman lower-alpha upper-alpha \
+aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal white yellow
+
+
+
+
+keywordclass.css2=\
+border-top-color border-right-color border-bottom-color border-left-color border-color \
+border-top-style border-right-style border-bottom-style border-left-style border-style \
+top right bottom left position z-index direction unicode-bidi \
+min-width max-width min-height max-height overflow clip visibility content quotes \
+counter-reset counter-increment marker-offset \
+size marks page-break-before page-break-after page-break-inside page orphans widows \
+font-stretch font-size-adjust unicode-range units-per-em src \
+panose-1 stemv stemh slope cap-height x-height ascent descent widths bbox definition-src \
+baseline centerline mathline topline text-shadow \
+caption-side table-layout border-collapse border-spacing empty-cells speak-header \
+cursor outline outline-width outline-style outline-color \
+volume speak pause-before pause-after pause cue-before cue-after cue \
+play-during azimuth elevation speech-rate voice-family pitch pitch-range stress richness \
+speak-punctuation speak-numeral
+
+keywordclass.values2=\
+inherit \
+run-in compact marker table inline-table table-row-group table-header-group table-footer-group \
+table-row table-column-group table-column table-cell table-caption \
+static relative absolute fixed ltr rtl embed bidi-override \
+visible hidden scroll collapse open-quote close-quote no-open-quote no-close-quote \
+decimal-leading-zero lower-greek lower-latin upper-latin hebrew armenian georgian \
+cjk-ideographic hiragana katakana hiragana-iroha katakana-iroha \
+landscape portrait crop cross always avoid \
+wider narrower ultra-condensed extra-condensed condensed semi-condensed \
+semi-expanded expanded extra-expanded ultra-expanded \
+caption icon menu message-box small-caption status-bar \
+separate show hide once crosshair default pointer move text wait help \
+e-resize ne-resize nw-resize n-resize se-resize sw-resize s-resize w-resize \
+ActiveBorder ActiveCaption AppWorkspace Background ButtonFace ButtonHighlight ButtonShadow \
+InactiveCaptionText ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder \
+InactiveCaption InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow \
+ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText \
+silent x-soft soft medium loud x-loud spell-out mix \
+left-side far-left center-left center-right far-right right-side behind leftwards rightwards \
+below level above higher lower x-slow slow medium fast x-fast faster slower \
+male female child x-low low high x-high code digits continous
+
+
+
 keywords.*.css=$(keywordclass.css)
 
-keywordclass.css2=first-letter first-line active link visited
-keywords2.*.css=$(keywordclass.css2)
+keywords2.*.css=first-letter first-line link active visited \
+first-child focus hover lang before after left right first
 
-word.characters.*.css=$(chars.alpha)$(chars.numeric)_-
+keywords3.*.css=$(keywordclass.css2)
+
+word.characters.*.css=$(chars.alpha)$(chars.numeric)-
 
 comment.stream.start.css=/*
 comment.stream.end.css=*/
 
-style.css.0=fore:#000033,eolfilled
-style.css.1=fore:#800000,bold
-style.css.2=fore:#800000
+style.css.32=$(font.code.base)
+style.css.0=fore:#FF0080
+style.css.1=$(colour.keyword),bold
+style.css.2=
 style.css.3=fore:#800000
 style.css.4=fore:#FF0000
-style.css.5=fore:#000080,bold
-style.css.6=fore:#000000
+style.css.5=$(colour.operator)
+style.css.6=fore:#0040E0
 style.css.7=fore:#FF0000
-style.css.8=fore:#800080
-style.css.9=fore:#007F00,$(font.comment)
-style.css.10=fore:#800000
-style.css.11=fore:#0000FF
-style.css.12=fore:#008000,bold
+style.css.8=$(colour.string)
+style.css.9=$(colour.code.comment.box),$(font.code.comment.box)
+style.css.10=$(colour.number),italics
+style.css.11=fore:#FF8000,bold
+style.css.12=$(colour.preproc),bold
 style.css.13=$(colour.string)
 style.css.14=$(colour.string)
+style.css.15=fore:#00A0E0
+style.css.16=fore:#800000
 
 block.start.*.css=5 {
 block.end.*.css=5 }
 
-command.help.*.css="http://www.w3.org/TR/REC-CSS1#$(CurrentWord)"
-command.help.subsystem.*.css=2
+file.patterns.d=*.d
+filter.d=D (d)|$(file.patterns.d)|
+lexer.$(file.patterns.d)=d
+
+word.chars.d=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.d)=$(word.chars.d)
+calltip.d.word.characters=$(chars.alpha)$(chars.numeric)_
+
+
+comment.block.d=//~
+comment.stream.start.d=/+
+comment.stream.end.d=+/
+comment.box.start.d=/*
+comment.box.middle.d= *
+comment.box.end.d= */
+
+statement.indent.$(file.patterns.d)=6 case catch class debug default do else \
+finally for foreach foreach_reverse if private protected public scope struct \
+try union while with
+statement.lookback.$(file.patterns.d)=20
+block.start.$(file.patterns.d)=13 {
+block.end.$(file.patterns.d)=13 }
+
+keywords.$(file.patterns.d)=abstract alias align asm assert auto \
+ body bool break byte \
+ case cast catch cdouble cent cfloat char class const continue creal \
+ dchar debug default delegate delete deprecated do double \
+ else enum export extern \
+ false final finally float for foreach foreach_reverse function \
+ goto \
+ idouble if ifloat import in inout int interface invariant ireal is \
+ lazy long \
+ mixin module \
+ new null \
+ out override \
+ package pragma private protected public \
+ real return \
+ scope short static struct super switch synchronized \
+ template this throw true try typedef typeid typeof \
+ ubyte ucent uint ulong union unittest ushort \
+ version void volatile \
+ wchar while with
+
+
+keywords3.$(file.patterns.d)=a addindex addtogroup anchor arg attention \
+author b brief bug c class code date def defgroup deprecated dontinclude \
+e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
+f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
+if image include ingroup internal invariant interface latexonly li line link \
+mainpage name namespace nosubgrouping note overload \
+p page par param post pre ref relates remarks return retval \
+sa section see showinitializer since skip skipline struct subsection \
+test throw todo typedef union until \
+var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
+
+
+
+
+
+style.d.32=$(font.base)
+style.d.0=fore:#808080
+style.d.1=$(colour.code.comment.box),$(font.code.comment.box)
+style.d.2=$(colour.code.comment.line),$(font.code.comment.line)
+style.d.3=$(colour.code.comment.doc),$(font.code.comment.doc)
+style.d.4=$(colour.code.comment.nested),$(font.code.comment.nested)
+style.d.5=$(colour.number)
+style.d.6=$(colour.keyword),bold
+style.d.7=$(colour.keyword),bold
+style.d.8=$(colour.keyword),bold
+style.d.9=$(colour.keyword),bold
+style.d.10=$(colour.string)
+style.d.11=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.d.12=$(colour.char)
+style.d.13=$(colour.operator),bold
+style.d.14=
+style.d.15=$(colour.code.comment.doc),$(font.code.comment.doc)
+style.d.16=fore:#3060A0,$(font.code.comment.doc)
+style.d.17=fore:#804020,$(font.code.comment.doc)
+braces.d.style=13
+
+
+command.compile.*.d=dmd -O $(FileNameExt)
+command.build.*.d=$(make.command)
+command.go.*.d=$(FileName)
+
 
 filter.eiffel=Eiffel (e)|*.e|
 
@@ -1225,12 +2067,12 @@
 braces.eiffelkw.style=$(braces.eiffel.style)
 
 statement.indent.$(file.patterns.eiffel)=5 do else elsif rescue if is loop
-statement.end.$(file.patterns.eiffel)=10 ;
 statement.lookback.$(file.patterns.eiffel)=20
 block.start.$(file.patterns.eiffel)=10 check debug deferred do from if inspect once
 block.end.$(file.patterns.eiffel)=10 end
 
 command.compile.*.e=compile $(FileName)
+
 file.patterns.erlang=*.erl
 
 filter.erlang=Erlang (erl)|$(file.patterns.erlang)|
@@ -1585,6 +2427,139 @@
 
 
 
+file.patterns.flagship=*.prg
+
+lexer.$(file.patterns.flagship)=flagship
+
+keywordclass.fs6commands=\
+? @ accept access all alternate announce ansi any append as assign autolock average \
+begin bell bitmap blank box \
+call cancel case century charset checkbox clear close cls color combobox commit \
+confirm console constant continue copy count create cursor \
+date dbread dbwrite decimals declare default delete deleted delimiters device dir \
+directory display do draw \
+edit else elseif eject end endcase enddo endif endtext epoch erase error escape eval eventmask \
+exact exclusive extended external extra \
+field file filter find fixed font for form format from \
+get gets global global_extern go goto gotop guialign guicolor guicursor guitransl \
+html htmltext \
+if image index input intensity \
+join \
+key keyboard keytransl \
+label lines list listbox local locate \
+margin memory memvar menu message method multibyte multilocks \
+next nfs nfslock nfs_force note \
+on openerror order outmode \
+pack parameters path pixel pop printer private prompt public push pushbutton \
+quit \
+radiobutton radiogroup read recall refresh reindex relation release rename replace report request restore \
+richtext rowadapt rowalign run \
+save say scoreboard scrcompress screen seek select sequence set setenhanced setstandard setunselected \
+skip softseek sort source static store struct structure sum \
+tag tbrowse text to total type typeahead \
+unique unlock update use \
+wait while with wrap \
+xml zap zerobyteout
+
+keywordclass.fs6libfunc=\
+_displarr _displarrerr _displarrstd _displobj _displobjerr _displobjstd \
+aadd abs achoice aclone acopy adel adir aelemtype aeval afields afill ains alert alias alltrim altd ansi2oem \
+appiomode appmdimode appobject array asc ascan asize asort at atail atanychar autoxlock \
+between bin2i bin2l bin2w binand binlshift binor binrshift binxor bof break browse \
+cdow chr chr2screen cmonth col col2pixel color2rgb colorselect colvisible consoleopen consolesize crc32 ctod curdir \
+date datevalid day dbappend dbclearfilter dbclearindex dbclearrelation dbcloseall dbclosearea dbcommit dbcommitall \
+dbcreate dbcreateindex dbdelete dbedit dbeval dbf dbfilter dbfinfo dbflock dbfused dbgetlocate dbgobottom dbgoto \
+dbgotop dbobject dbrecall dbreindex dbrelation dbrlock dbrlocklist dbrselect dbrunlock dbseek dbselectarea \
+dbsetdriver dbsetfilter dbsetindex dbsetlocate dbsetorder dbsetrelation dbskip dbstruct dbunlock dbunlockall \
+dbusearea default deleted descend devout devoutpict devpos directory diskspace dispbegin dispbox dispcount \
+dispend dispout doserror doserror2str dow drawline dtoc dtos \
+empty eof errorblock errorlevel eval execname execpidnum exp \
+fattrib fclose fcount fcreate ferase ferror ferror2str fieldblock fielddeci fieldget fieldgetarr fieldlen fieldname \
+fieldpos fieldput fieldputarr fieldtype fieldwblock file findexefile fklabel fkmax flagship_dir flock flockf fopen \
+found fread freadstdin freadstr freadtxt frename fs_set fseek fwrite \
+getactive getalign getapplykey getdosetkey getenv getenvarr getfunction getpostvalid getprevalid getreader guidrawline \
+hardcr header hex2num \
+i2bin iif indexcheck indexcount indexdbf indexext indexkey indexnames indexord infobox inkey inkey2read inkey2str inkeytrap \
+instdchar instdstring int int2num isalpha isbegseq iscolor isdbexcl isdbflock isdbmultip isdbmultiple isdbmultipleopen \
+isdbrlock isdigit isfunction isguimode islower isobjclass isobjequiv isobjproperty isprinter isupper \
+l2bin lastkey lastrec left len listbox lock log lower ltrim lupdate \
+macroeval macrosubst max max_col max_row maxcol maxrow mcol mdblck mdiclose mdiopen mdiselect memocode memodecode \
+memoedit memoencode memoline memoread memory memotran memowrit memvarblock mhide min minmax mlcount mlctopos mleftdown \
+mlpos mod month mpostolc mpresent mreststate mrightdown mrow msavestate msetcursor msetpos mshow mstate \
+neterr netname nextkey num2hex num2int \
+objclone oem2ansi onkey ordbagext ordbagname ordcond ordcondset ordcreate orddescend orddestroy ordfor ordisinique \
+ordkey ordkeyadd ordkeycount ordkeydel ordkeygoto ordkeyno ordkeyval ordlistadd ordlistclear ordlistrebui ordname \
+ordnumber ordscope ordsetfocu ordsetrelat ordskipunique os outerr outstd \
+padc padl padr param parameters pcalls pcol pcount pixel2col pixel2row printstatus procfile procline procname procstack proper prow \
+qout qout2 qqout qqout2 \
+rat rddlist rddname rddsetdefault readexit readinsert readkey readkill readmodal readsave readupdated readvar reccount recno recsize \
+replicate restscreen right rlock rlockverify round row row2pixel rowadapt rowvisible rtrim \
+savescreen scrdos2unix screen2chr scroll scrunix2dos seconds secondscpu select serial set setansi setblink setcancel setcol2get \
+setcolor setcolorba setcursor setevent setguicursor setkey setmode setpos setprc setvarempty sleep sleepms soundex space \
+sqrt statbarmsg statusmessage stod str strlen strlen2col strlen2pix strlen2space strpeek strpoke strtran strzero stuff substr \
+tbcolumnnew tbmouse tbrowsearr tbrowsedb tbrowsenew tempfilename time tone transform trim truepath type \
+updated upper used usersactive usersdbf usersmax \
+val valtype version \
+webdate weberrorhandler webgetenvir webgetformdata webhtmlbegin webhtmlend weblogerr webmaildomain weboutdata websendmail word \
+year
+
+keywordclass.fs6funcproc=\
+function procedure return exit
+
+keywordclass.fs6class=\
+class instance export hidden protect prototype
+
+keywords.$(file.patterns.flagship)=$(keywordclass.fs6commands)
+keywords2.$(file.patterns.flagship)=$(keywordclass.fs6libfunc)
+keywords3.$(file.patterns.flagship)=$(keywordclass.fs6funcproc)
+keywords4.$(file.patterns.flagship)=$(keywordclass.fs6class)
+
+comment.block.flagship=//~
+comment.stream.start.flagship=/*
+comment.stream.end.flagship=*/
+comment.box.start.flagship=/*
+comment.box.middle.flagship= *
+comment.box.end.flagship= */
+
+
+
+style.flagship.32=$(font.base)
+style.flagship.0=
+style.flagship.1=$(colour.code.comment.line),$(font.code.comment.line)
+style.flagship.2=$(colour.code.comment.line),$(font.code.comment.line)
+style.flagship.3=$(colour.code.comment.doc),$(font.code.comment.doc)
+style.flagship.4=
+style.flagship.5=fore:#3060A0,$(font.code.comment.doc)
+style.flagship.6=fore:#804020,$(font.code.comment.doc)
+
+style.flagship.7=$(colour.keyword)
+style.flagship.8=$(colour.keyword)
+style.flagship.9=$(colour.keyword),bold
+style.flagship.10=$(colour.keyword),bold
+
+style.flagship.11=$(colour.number)
+style.flagship.12=$(colour.string)
+style.flagship.13=$(colour.preproc)
+style.flagship.14=$(colour.operator)
+style.flagship.15=
+style.flagship.16=$(colour.number)
+style.flagship.17=$(style.stringeol)
+
+
+fsOptObj=-c -q -w1 -w2 -w3
+fsOptExe=-q -w1 -w2 -w3
+
+fsObj=FlagShip $(fsOptObj) $(FileNameExt) -o $(FileName).o
+
+fsExe=FlagShip $(fsOptExe) $(FileNameExt) -o $(FileName)
+
+command.compile.*.prg=$(fsObj)
+command.build.*.prg=$(fsExe)
+command.go.*.prg=$(FileName)
+
+
+command.help.$(file.patterns.flagship)=fsman
+
 file.patterns.forth=*.forth
 
 
@@ -1600,8 +2575,6 @@
 comment.box.start.forth=\
 comment.box.middle.forth=\
 comment.box.end.forth=\
-fold.comment=1
-fold.preprocessor=1
 
 
 keywords.$(file.patterns.forth)=\
@@ -1687,7 +2660,7 @@
 real rec recl recursive result return rewind save select \
 selectcase selecttype sequential sign size stat status stop stream \
 subroutine target then to type unformatted unit use value \
-volatile wait where while write 
+volatile wait where while write
 
 keywords.$(file.patterns.f95)=$(keywordclass.fortran)
 keywords.$(file.patterns.f77)=$(keywordclass.fortran)
@@ -1797,8 +2770,95 @@
 calltip.fortran.ignorecase=1
 calltip.f77.ignorecase=1
 
+file.patterns.freebasic=*.bas;*.bi
+
+filter.freebasic=FreeBasic (bb bi)|$(file.patterns.freebasic)|
+
+lexer.$(file.patterns.freebasic)=freebasic
 
-file.patterns.web=*.html;*.htm;*.asp;*.shtml;*.htd
+
+keywordclass.freebasic=\
+append as asc asin asm atan2 atn beep bin binary bit bitreset bitset bload \
+bsave byref byte byval call callocate case cbyte cdbl cdecl chain chdir chr \
+cint circle clear clng clngint close cls color command common cons const \
+continue cos cshort csign csng csrlin cubyte cuint culngint cunsg curdir \
+cushort custom cvd cvi cvl cvlongint cvs cvshort data date deallocate declare \
+defbyte defdbl defined defint deflng deflngint defshort defsng defstr defubyte \
+defuint defulngint defushort dim dir do double draw dylibload dylibsymbol else \
+elseif end enum environ environ$ eof eqv erase err error exec exepath exit exp \
+export extern field fix flip for fre freefile function get getjoystick getkey \
+getmouse gosub goto hex hibyte hiword if iif imagecreate imagedestroy imp \
+inkey inp input instr int integer is kill lbound lcase left len let lib line \
+lobyte loc local locate lock lof log long longint loop loword lset ltrim \
+mid mkd mkdir mki mkl mklongint mks mkshort mod multikey mutexcreate \
+mutexdestroy mutexlock mutexunlock name next not oct on once open option or out \
+output overload paint palette pascal pcopy peek peeki peeks pipe pmap point \
+pointer poke pokei pokes pos preserve preset print private procptr pset ptr \
+public put random randomize read reallocate redim rem reset restore resume \
+resume next return rgb rgba right rmdir rnd rset rtrim run sadd screen \
+screencopy screeninfo screenlock screenptr screenres screenset screensync \
+screenunlock seek statement seek function selectcase setdate setenviron \
+setmouse settime sgn shared shell shl short shr sin single sizeof sleep space \
+spc sqr static stdcall step stop str string string strptr sub swap system tab \
+tan then threadcreate threadwait time time timer to trans trim type ubound \
+ubyte ucase uinteger ulongint union unlock unsigned until ushort using va_arg \
+va_first va_next val val64 valint varptr view viewprint wait wend while width \
+window windowtitle with write xor zstring
+
+keywordclass.preprocessor=\
+
+keywords.$(file.patterns.freebasic)=$(keywordclass.freebasic)
+keywords2.$(file.patterns.freebasic)=$(keywordclass.preprocessor)
+
+style.freebasic.0=fore:#000000
+style.freebasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+style.freebasic.2=$(colour.number)
+style.freebasic.3=$(colour.keyword),bold
+style.freebasic.4=$(colour.string)
+style.freebasic.5=$(colour.preproc)
+style.freebasic.6=$(colour.operator)
+style.freebasic.7=$(style.freebasic.0)
+style.freebasic.10=$(colour.keyword)
+style.freebasic.11=$(colour.keyword)
+style.freebasic.12=$(colour.keyword)
+style.freebasic.15=$(colour.preproc)
+style.freebasic.16=$(colour.error)
+style.freebasic.17=$(colour.number)
+style.freebasic.18=$(colour.number)
+
+
+file.patterns.gap=*.g;*.gd;*.gi
+
+filter.gap=Gap (g gi gd)|$(file.patterns.gap)|
+
+lexer.$(file.patterns.gap)=gap
+
+keywords.$(file.patterns.gap)=and break continue do elif else end fi for function \
+if in local mod not od or quit rec repeat return then until while QUIT
+
+keywords2.$(file.patterns.gap)=false true IsBound Unbind TryNextMethod \
+Info Assert SaveWorkspace fail
+
+
+comment.block.gap=#~
+
+style.gap.0=fore:#808080
+style.gap.1=
+style.gap.2=$(colour.keyword),bold
+style.gap.3=$(colour.keyword)
+style.gap.4=$(colour.keyword)
+style.gap.5=$(colour.keyword)
+style.gap.6=$(colour.string)
+style.gap.7=$(colour.char)
+style.gap.8=$(colour.operator),bold
+style.gap.9=$(colour.code.comment.line)
+style.gap.10=$(colour.number)
+style.gap.11=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+
+braces.gap.style=8
+
+
+file.patterns.web=*.html;*.htm;*.asp;*.shtml;*.htd;*.jsp
 file.patterns.php=*.php3;*.phtml;*.php
 file.patterns.html=$(file.patterns.web);$(file.patterns.php);*.htt;*.cfm;*.tpl;*.dtd;*.hta
 file.patterns.vxml=*.vxml
@@ -1810,7 +2870,7 @@
 lexer.$(file.patterns.xml)=xml
 lexer.$(file.patterns.docbook)=hypertext
 
-filter.web=Web (html htm asp shtml css xml docbook)|$(file.patterns.web);*.css;*.xml;*.docbook|
+filter.web=Web (html htm asp shtml css xml docbook jsp)|$(file.patterns.web);*.css;*.xml;*.docbook|
 filter.php=PHP (php php3 phtml)|$(file.patterns.php)|
 
 fold.html=1
@@ -1853,8 +2913,15 @@
 text password checkbox radio submit reset \
 file hidden image
 
+html5.elements=\
+article aside calendar canvas card command commandset datagrid datatree \
+footer gauge header m menubar menulabel nav progress section switch tabbox
+
+html5.attributes=\
+active command contenteditable ping
+
 keywordclass.hypertext=\
-$(hypertext.elements) $(hypertext.attributes) public !doctype
+$(hypertext.elements) $(hypertext.attributes) $(html5.elements) $(html5.attributes) public !doctype
 
 vxml.elements=\
 assign audio block break catch choice clear disconnect else elseif \
@@ -1876,14 +2943,15 @@
 $(vxml.elements) $(vxml.attributes) public !doctype
 
 keywordclass.php=\
-and argv as argc break case cfunction class continue declare default do \
-die echo else elseif empty enddeclare endfor endforeach endif endswitch \
-endwhile e_all e_parse e_error e_warning eval exit extends false for \
-foreach function global http_cookie_vars http_get_vars http_post_vars \
-http_post_files http_env_vars http_server_vars if include include_once \
-list new not null old_function or parent php_os php_self php_version \
-print require require_once return static switch stdclass this true var \
-xor virtual while __file__ __line__ __sleep __wakeup
+and array as bool boolean break case cfunction class const continue declare \
+default die directory do double echo else elseif empty enddeclare endfor \
+endforeach endif endswitch endwhile eval exit extends false float for \
+foreach function global if include include_once int integer isset list new \
+null object old_function or parent print real require require_once resource \
+return static stdclass string switch true unset use var while xor \
+abstract catch clone exception final implements interface php_user_filter \
+private protected public this throw try \
+__class__ __file__ __function__ __line__ __method__ __sleep __wakeup
 
 import phpfunctions
 
@@ -1963,6 +3031,7 @@
 word.characters.$(file.patterns.html)=$(chars.alpha)$(chars.numeric)_-
 comment.stream.start.hypertext=<!--
 comment.stream.end.hypertext=-->
+comment.block.hypertext=//~
 
 keywords.$(file.patterns.xml)=
 keywords6.$(file.patterns.xml)=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION
@@ -1976,21 +3045,6 @@
 
 word.characters.$(file.patterns.vxml)=$(chars.alpha)$(chars.numeric)_-
 
-keywords.*.css=\
-background background-attachment background-color background-image background-position background-repeat \
-border-color border-bottom border-bottom-width border-left border-left-width \
-border border-right-width border-right border-style border-top border-top-width border-width \
-clear clip color cursor display float \
-font font-family font-size font-style font-variant font-weight \
-height left letter-spacing line-height \
-list-style list-style-image list-style-position list-style-type \
-margin margin-bottom margin-left margin-right margin-top overflow \
-padding padding-bottom padding-left padding-right padding-top position \
-text-align text-decoration text-indent text-transform top \
-vertical-align visibility width white-space word-spacing z-index
-
-word.characters.*.css=$(chars.alpha)$(chars.numeric)_-
-
 
 style.hypertext.0=fore:#000000,$(font.text)
 style.hypertext.1=fore:#000080
@@ -2087,7 +3141,7 @@
 style.hypertext.101=bold,back:#EFFFEF,eolfilled
 style.hypertext.102=back:#EFFFEF,eolfilled
 
-style.hypertext.104=fore:#00007F,italics,back:#FFF8F8
+style.hypertext.104=fore:#007F00,italics,back:#FFF8F8
 
 style.hypertext.105=fore:#808080
 style.hypertext.106=fore:#808080,back:#CFEFCF,eolfilled
@@ -2111,7 +3165,7 @@
 style.hypertext.123=fore:#00007F,italics,back:#FFF8F8
 style.hypertext.124=fore:#999999,$(font.comment),back:#FFF8F8
 style.hypertext.125=fore:#666666,italics,$(font.comment),back:#FFF8F8
-style.hypertext.126=fore:#00007F,italics,back:#FFF8F8
+style.hypertext.126=fore:#007F00,italics,back:#FFF8F8
 style.hypertext.127=fore:#000000,back:#FFF8F8
 
 
@@ -2147,10 +3201,88 @@
 if PLAT_WIN
 	command.go.$(file.patterns.web)="file://$(FilePath)"
 	command.go.subsystem.$(file.patterns.web)=2
-	command.go.$(file.patterns.php)=php -f $(FileNameExt)
 if PLAT_GTK
 	command.go.$(file.patterns.web)=netscape "file://$(FilePath)"
 
+command.go.$(file.patterns.php)=php -f "$(FileNameExt)"
+command.compile.$(file.patterns.php)=php -l "$(FileNameExt)"
+
+file.patterns.inno=*.iss
+
+filter.inno=Inno Setup (iss)|$(file.patterns.inno)|
+
+lexer.$(file.patterns.inno)=inno
+
+keywords.$(file.patterns.inno)=\
+ code components custommessages dirs files icons ini installdelete langoptions \
+ languages messages registry run setup types tasks uninstalldelete uninstallrun \
+ _istool
+
+keywords2.$(file.patterns.inno)=\
+ allowcancelduringinstall allownoicons allowrootdirectory allowuncpath \
+ alwaysrestart alwaysshowcomponentslist alwaysshowdironreadypage \
+ alwaysshowgrouponreadypage alwaysusepersonalgroup appcomments appcontact \
+ appcopyright appenddefaultdirname appenddefaultgroupname appid appmodifypath \
+ appmutex appname apppublisher apppublisherurl appreadmefile appsupporturl \
+ appupdatesurl appvername appversion architecturesallowed \
+ architecturesinstallin64bitmode backcolor backcolor2 backcolordirection \
+ backsolid changesassociations changesenvironment compression copyrightfontname \
+ copyrightfontsize createappdir createuninstallregkey defaultdirname \
+ defaultgroupname defaultuserinfoname defaultuserinfoorg defaultuserinfoserial \
+ dialogfontname dialogfontsize direxistswarning disabledirpage \
+ disablefinishedpage disableprogramgrouppage disablereadymemo disablereadypage \
+ disablestartupprompt diskclustersize diskslicesize diskspanning \
+ enablesdirdoesntexistwarning encryption extradiskspacerequired \
+ flatcomponentslist infoafterfile infobeforefile internalcompresslevel \
+ languagedetectionmethod languagecodepage languageid languagename licensefile \
+ mergeduplicatefiles minversion onlybelowversion outputbasefilename outputdir \
+ outputmanifestfile password privilegesrequired reservebytes \
+ restartifneededbyrun setupiconfile showcomponentsizes showlanguagedialog \
+ showtaskstreelines slicesperdisk solidcompression sourcedir timestamprounding \
+ timestampsinutc titlefontname titlefontsize touchdate touchtime uninstallable \
+ uninstalldisplayicon uninstalldisplayname uninstallfilesdir uninstalllogmode \
+ uninstallrestartcomputer updateuninstalllogappname usepreviousappdir \
+ usepreviousgroup useprevioussetuptype useprevioustasks useprevioususerinfo \
+ userinfopage usesetupldr versioninfocompany versioninfocopyright \
+ versioninfodescription versioninfotextversion versioninfoversion \
+ welcomefontname welcomefontsize windowshowcaption windowstartmaximized \
+ windowresizable windowvisible wizardimagebackcolor wizardimagefile \
+ wizardimagestretch wizardsmallimagefile
+
+keywords3.$(file.patterns.inno)=\
+ afterinstall attribs beforeinstall check comment components copymode \
+ description destdir destname excludes extradiskspacerequired filename flags \
+ fontinstall groupdescription hotkey infoafterfile infobeforefile iconfilename \
+ iconindex key languages licensefile messagesfile minversion name \
+ onlybelowversion parameters permissions root runonceid section source \
+ statusmsg string subkey tasks type types valuedata valuename valuetype \
+ workingdir
+
+keywords4.$(file.patterns.inno)=\
+ append define dim else emit endif endsub error expr file for if ifdef ifexist \
+ ifndef ifnexist include insert pragma sub undef
+
+keywords5.$(file.patterns.inno)=\
+ begin break case const continue do downto else end except finally for function \
+ if of procedure repeat then to try until uses var while with
+
+keywords6.$(file.patterns.inno)=
+
+
+style.inno.0=
+style.inno.1=fore:#007F7F,$(font.comment)
+style.inno.2=$(colour.keyword)
+style.inno.3=$(colour.string)
+style.inno.4=back:#FFFFC0
+style.inno.5=$(colour.preproc)
+style.inno.6=$(colour.preproc)
+style.inno.7=fore:#007F7F,$(font.comment)
+style.inno.8=$(colour.keyword)
+style.inno.9=$(colour.keyword)
+style.inno.10=$(colour.string)
+style.inno.11=$(colour.char)
+
+
 file.patterns.kix=*.kix
 filter.kix=Kix-Script (kix)|$(file.patterns.kix)|
 
@@ -2175,7 +3307,7 @@
 	setconsole setdefaultprinter setfileattr setfocus setoption setsystemstate \
 	settitle setwallpaper showprogramgroup shutdown sidtoname split srnd substr \
 	trim ubound ucase unloadhive val vartype vartypename writeline \
-	writeprofilestring writevalue 
+	writeprofilestring writevalue
 
 keywords3.$(file.patterns.kix)=address build color comment cpu crlf csd curdir \
 	date day domain dos error fullname homedir homedrive homeshr hostname \
@@ -2206,7 +3338,6 @@
 use.tabs.$(file.patterns.kix)=1
 
 statement.indent.$(file.patterns.kix)=7 if else for do while function case
-statement.end.$(file.patterns.kix)=7 endif next until loop endfunction endselect
 
 file.patterns.latex=*.tex;*.sty
 
@@ -2348,25 +3479,29 @@
 
 lexer.$(file.patterns.lout)=lout
 
-keywords.$(file.patterns.lout)= @OptGall @Filter @FilterIn @FilterOut \
- FilterErr @FontDef @Family @Face @Name @Metrics @ExtraMetrics \
- Mapping @Recode @Common @Rump @Meld @Insert @OneOf @Next @Plus \
- Minus @Wide @High @HShift @VShift @BeginHeaderComponent \
- EndHeaderComponent @SetHeaderComponent @ClearHeaderComponent @OneCol \
- OneRow @HScale @VScale @HCover @VCover @Scale @KernShrink @HContract \
- VContract @HLimited @VLimited @HExpand @VExpand @StartHVSpan \
- StartHSpan @StartVSpan @HSpan @VSpan @PAdjust @HAdjust @VAdjust \
- Rotate @Background @IncludeGraphic @SysIncludeGraphic @Graphic \
- LinkSource @LinkDest @URLLink @PlainGraphic @Verbatim @RawVerbatim \
- Case @Yield @BackEnd @Char @Font @Space @YUnit @ZUnit @Break \
- Underline @SetColour @SetColor @SetTexture @Outline @Language \
- CurrLang @CurrFamily @CurrFace @CurrYUnit @CurrZUnit @LEnv @LClos \
- LUse @LEO @Open @Use @NotRevealed @Tagged @Database @SysDatabase \
- Include @SysInclude @IncludeGraphicRepeated @PrependGraphic \
- SysIncludeGraphicRepeated @SysPrependGraphic @Target @Null \
- PageLabel @Galley @ForceGalley @LInput @Split @Tag @Key @Optimize \
- Merge @Enclose @Begin @End @Moment @Second @Minute @Hour @Day @Month \
- Year @Century @WeekDay @YearDay @DaylightSaving @@A @@B @@C @@D @@E @@V
+keywords.$(file.patterns.lout)= \
+ OptGall @FontDef @Family @Face @Name @Metrics @ExtraMetrics \
+ Mapping @Recode @Filter @FilterIn @FilterOut @FilterErr \
+ Common @Rump @Meld @Insert @OneOf @Next @Plus @Minus @Wide \
+ High @HShift @VShift @BeginHeaderComponent @EndHeaderComponent \
+ SetHeaderComponent @ClearHeaderComponent @OneCol @OneRow \
+ HMirror @VMirror @HScale @VScale @HCover @VCover @Scale \
+ KernShrink @HContract @VContract @HLimited @VLimited @HExpand \
+ VExpand @StartHVSpan @StartHSpan @StartVSpan @HSpan @VSpan \
+ PAdjust @HAdjust @VAdjust @Rotate @Background @IncludeGraphic \
+ SysIncludeGraphic @Graphic @LinkSource @LinkDest @URLLink \
+ PlainGraphic @Verbatim @RawVerbatim @Case @Yield @BackEnd \
+ Char @Font @Space @YUnit @ZUnit @Break @Underline @SetColour \
+ SetColor @SetUnderlineColour @SetUnderlineColor @SetTexture \
+ Outline @Language @CurrLang @CurrFamily @CurrFace @CurrYUnit \
+ CurrZUnit @LEnv @@A @@B @@C @@D @@E @LClos @@V @LUse @LEO \
+ Open @Use @NotRevealed @Tagged @Database @SysDatabase \
+ Include @SysInclude @IncludeGraphicRepeated \
+ SysIncludeGraphicRepeated @PrependGraphic @SysPrependGraphic \
+ Target @Null @PageLabel @Galley @ForceGalley @LInput @Split \
+ Tag @Key @Optimize @Merge @Enclose @Begin @End @Moment \
+ Second @Minute @Hour @Day @Month @Year @Century @WeekDay \
+ YearDay @DaylightSaving @SetContext @GetContext
 
 keywords2.$(file.patterns.lout)= &&& && & ^// ^/ ^|| ^| ^& // / || |
 
@@ -2393,7 +3528,7 @@
 style.lout.10=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
 braces.lout.style=8
 
-command.compile.$(file.patterns.lout)=lout "$(FileNameExt)" > "$(FileName).ps" 
+command.compile.$(file.patterns.lout)=lout "$(FileNameExt)" > "$(FileName).ps"
 command.build.$(file.patterns.lout)=make
 
 if PLAT_WIN
@@ -2405,23 +3540,25 @@
 
 file.patterns.lua=*.lua
 
+shbang.lua=lua
+
 filter.lua=Lua (lua)|$(file.patterns.lua)|
 
 lexer.$(file.patterns.lua)=lua
 
-word.chars.lua=$(chars.alpha)$(chars.numeric)_%
-word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric)_%
+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 if \
 in local nil not or repeat return then true until while
 keywords.$(file.patterns.lua)=$(keywordclass.lua)
 
 keywordclass2.lua=_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring \
-print tonumber tostring type unpack
+print rawget rawset require tonumber tostring type unpack
 
 keywordclass2.lua4=_ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT \
 _STDERR _STDIN _STDOUT call dostring foreach foreachi getn globals newtype \
-rawget rawset require sort tinsert tremove
+sort tinsert tremove
 
 keywordclass3.lua4=abs acos asin atan atan2 ceil cos deg exp \
 floor format frexp gsub ldexp log log10 max min mod rad random randomseed \
@@ -2432,22 +3569,27 @@
 clock date difftime execute exit getenv setlocale time
 
 keywordclass2.lua5=_G getfenv getmetatable ipairs loadlib next pairs pcall \
-rawegal rawget rawset require setfenv setmetatable xpcall \
-string table math coroutine io os debug
+rawequal setfenv setmetatable xpcall \
+string table math coroutine io os debug \
+load module select
 
 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.rad math.random math.randomseed math.sin math.sqrt math.tan
+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
 
 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 \
 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
+os.setlocale os.time os.tmpname \
+coroutine.running package.cpath package.loaded package.loadlib package.path \
+package.preload package.seeall io.popen
 
 
 keywords2.$(file.patterns.lua)=$(keywordclass2.lua) $(keywordclass2.lua4) $(keywordclass2.lua5)
@@ -2566,11 +3708,8 @@
 
 
 
-file.patterns.metapost=
-file.patterns.metafun=
-
-file.patterns.metapost=*.mp;*.mpx;
-file.patterns.metafun=*.mp;*.mpx;*.mpy;
+file.patterns.metapost=*.mp;*.mpx
+file.patterns.metafun=*.mp;*.mpx;*.mpy
 
 filter.metapost=MetaPost|$(file.patterns.metapost)|
 filter.metafun=MetaFun|$(file.patterns.metafun)|
@@ -2768,12 +3907,12 @@
 
 tab.size.$(file.patterns.mmixal)=16
 indent.size.$(file.patterns.mmixal)=16
-backspace.unindents
 
 command.compile.$(file.patterns.mmixal)=mmixal -l $(FileName).map -b 200 $(FilePath)
 command.go.$(file.patterns.mmixal)=mmix $(1) $(FileName).mmo
 command.name.2.$(file.patterns.mmixal)=mmotype
 command.2.$(file.patterns.mmixal)=mmotype $(FileName).mmo $(FileName).out
+
 file.patterns.nncron=*.tab;*.spf
 
 lexer.$(file.patterns.nncron)=nncrontab
@@ -2845,35 +3984,52 @@
 
 nsis.uservars=1
 
-keywords.$(file.patterns.nsis)=What Abort AddSize AllowRootDirInstall AutoCloseWindow \
-BGGradient BrandingText BringToFront CRCCheck Call CallInstDLL Caption ClearErrors \
-CompletedText ComponentText CopyFiles CreateDirectory CreateShortCut Delete \
-DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText \
-DirShow DirText DisabledBitmap EnabledBitmap EnumRegKey EnumRegValue Exch Exec \
-ExecShell ExecWait ExpandEnvStrings File FileClose FileErrorText FileOpen FileRead \
-FileReadByte FileSeek FileWrite FileWriteByte FindClose FindFirst FindNext FindWindow \
-Function FunctionEnd GetCurrentAddress GetDLLVersionLocal GetDllVersion GetFileTime \
-GetFileTimeLocal GetFullPathName GetFunctionAddress GetLabelAddress GetTempFileName \
-Goto HideWindow Icon IfErrors IfFileExists IfRebootFlag InstProgressFlags InstType \
-InstallButtonText InstallColors InstallDir InstallDirRegKey IntCmp IntCmpU IntFmt IntOp \
-IsWindow LicenseData LicenseText MessageBox MiscButtonText Name OutFile Pop Push \
-Quit RMDir ReadEnvStr ReadINIStr ReadRegDword ReadRegStr Reboot RegDLL Rename \
-Return SearchPath Section SectionDivider SectionEnd SectionIn SendMessage SetAutoClose \
-SetCompress SetCompressor SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrors \
-SetFileAttributes SetOutPath SetOverwrite SetRebootFlag ShowInstDetails ShowUninstDetails \
-SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCpy StrLen SubCaption UnRegDLL \
-UninstallButtonText UninstallCaption UninstallEXEName UninstallIcon UninstallSubCaption \
-UninstallText WindowIcon WriteINIStr WriteRegBin WriteRegDword WriteRegDWORD WriteRegExpandStr \
-WriteRegStr WriteUninstaller SectionGetFlags SectionSetFlags SectionSetText SectionGetText \
-LogText LogSet CreateFont SetShellVarContext SetStaticBkColor SetBrandingImage PluginDir \
-SubSectionEnd SubSection CheckBitmap ChangeUI SetFont AddBrandingImage XPStyle Var \
-LangString !define !undef !ifdef !ifndef !endif !else !macro !echo !warning !error !verbose \
-!macroend !insertmacro !system !include !cd !packhdr !addplugindir
+keywords.$(file.patterns.nsis)=!addincludedir !addplugindir MakeNSIS Portions \
+Contributors: Abort AddBrandingImage AddSize AutoCloseWindow BGFont \
+BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI \
+ClearErrors ComponentText GetDLLVersion GetDLLVersionLocal GetFileTime \
+GetFileTimeLocal CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut \
+SetDatablockOptimize DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue \
+Delete DetailPrint DirText DirShow DirVar DirVerify GetInstDirError AllowRootDirInstall \
+CheckBitmap EnableWindow EnumRegKey EnumRegValue Exch Exec ExecWait \
+ExecShell ExpandEnvStrings FindWindow FindClose FindFirst FindNext File FileBufSize \
+FlushINI ReserveFile FileClose FileErrorText FileOpen FileRead FileWrite FileReadByte \
+FileWriteByte FileSeek Function FunctionEnd GetDlgItem GetFullPathName \
+GetTempFileName HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfSilent \
+InstallDirRegKey InstallColors InstallDir InstProgressFlags InstType IntOp IntCmp \
+IntCmpU IntFmt IsWindow Goto LangString LangStringUP LicenseData \
+LicenseForceSelection LicenseLangString LicenseText LicenseBkColor \
+LoadLanguageFile LogSet LogText MessageBox Nop Name OutFile Page \
+PageCallbacks PageEx PageExEnd Pop Push Quit ReadINIStr ReadRegDWORD \
+ReadRegStr ReadEnvStr Reboot RegDLL Rename Return RMDir Section SectionEnd \
+SectionIn SubSection SectionGroup SubSectionEnd SectionGroupEnd SearchPath \
+SectionSetFlags SectionGetFlags SectionSetInstTypes SectionGetInstTypes \
+SectionGetText SectionSetText SectionGetSize SectionSetSize GetCurInstType \
+SetCurInstType InstTypeSetText InstTypeGetText SendMessage SetAutoClose \
+SetCtlColors SetBrandingImage SetCompress SetCompressor SetCompressorDictSize \
+SetCompressionLevel SetDateSave SetDetailsView SetDetailsPrint SetErrors \
+SetErrorLevel GetErrorLevel SetFileAttributes SetFont SetOutPath SetOverwrite \
+SetPluginUnload SetRebootFlag SetShellVarContext SetSilent ShowInstDetails \
+ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep StrCmp StrCpy \
+StrLen SubCaption UninstallExeName UninstallCaption UninstallIcon UninstPage \
+UninstallText UninstallSubCaption UnRegDLL WindowIcon WriteINIStr WriteRegBin \
+WriteRegDWORD WriteRegStr WriteRegExpandStr WriteUninstaller XPStyle !packhdr \
+!system !execute !AddIncludeDir !include !cd !ifdef !ifndef !endif !define !undef !else !echo !warning \
+!error !verbose !macro !macroend !insertmacro !ifmacrodef !ifmacrondef MiscButtonText \
+DetailsButtonText UninstallButtonText InstallButtonText SpaceTexts \
+CompletedText GetFunctionAddress GetLabelAddress GetCurrentAddress \
+!AddPluginDir InitPluginsDir AllowSkipFiles Var VIAddVersionKey VIProductVersion LockWindow
 
+ 
 keywords2.$(file.patterns.nsis)=$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 \
-$R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 $CMDLINE $DESKTOP \
-$EXEDIR $HWNDPARENT $INSTDIR $OUTDIR $PROGRAMFILES ${NSISDIR} $\n $\r \
-$QUICKLAUNCH $SMPROGRAMS $SMSTARTUP $STARTMENU $SYSDIR $TEMP $WINDIR
+$R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 $\t $\" $\' $\` \
+$VARNAME $0, $INSTDIR $OUTDIR $CMDLINE $LANGUAGE $PROGRAMFILES \
+$COMMONFILES $DESKTOP $EXEDIR ${NSISDIR} $WINDIR $SYSDIR $TEMP \
+$STARTMENU $SMPROGRAMS $SMSTARTUP $QUICKLAUNCH $DOCUMENTS \
+$SENDTO $RECENT $FAVORITES $MUSIC $PICTURES $VIDEOS $NETHOOD \
+$FONTS $TEMPLATES $APPDATA $PRINTHOOD $INTERNET_CACHE $COOKIES \
+$HISTORY $PROFILE $ADMINTOOLS $RESOURCES $RESOURCES_LOCALIZED \
+$CDBURN_AREA $HWNDPARENT $PLUGINSDIR $$ $\r $\n
 
 keywords3.$(file.patterns.nsis)=ARCHIVE FILE_ATTRIBUTE_ARCHIVE FILE_ATTRIBUTE_HIDDEN \
 FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_OFFLINE FILE_ATTRIBUTE_READONLY \
@@ -2883,10 +4039,13 @@
 IDCANCEL IDIGNORE IDNO IDOK IDRETRY IDYES MB_ABORTRETRYIGNORE MB_DEFBUTTON1 \
 MB_DEFBUTTON2 MB_DEFBUTTON3 MB_DEFBUTTON4 MB_ICONEXCLAMATION \
 MB_ICONINFORMATION MB_ICONQUESTION MB_ICONSTOP MB_OK MB_OKCANCEL \
-MB_RETRYCANCEL MB_RIGHT MB_SETFOREGROUND MB_TOPMOST MB_YESNO MB_YESNOCANCEL \
-NORMAL OFFLINE READONLY SW_SHOWMAXIMIZED SW_SHOWMINIMIZED SW_SHOWNORMAL \
-SYSTEM TEMPORARY auto colored false force hide ifnewer nevershow normal \
-off on show silent silentlog smooth true try
+MB_RETRYCANCEL MB_RIGHT MB_SETFOREGROUND MB_TOPMOST MB_YESNO \
+MB_YESNOCANCEL NORMAL OFFLINE READONLY SW_SHOWMAXIMIZED SW_SHOWMINIMIZED \
+SW_SHOWNORMAL SYSTEM TEMPORARY auto colored false force hide ifnewer nevershow \
+normal off on show silent silentlog smooth true try lzma zlib bzip2 none listonly textonly \
+both top left bottom right license components directory instfiles uninstConfirm custom \
+all leave current ifdiff lastused LEFT RIGHT CENTER dlg_id ALT CONTROL EXT SHIFT \
+open print manual alwaysoff
 
 
 style.nsis.0=fore:#000000,$(font.base)
@@ -2904,15 +4063,77 @@
 style.nsis.12=fore:#00007F,bold
 style.nsis.13=fore:#CC3300,back:#EEEEEE
 style.nsis.14=fore:#007F7F
+style.nsis.15=fore:#00007F,bold
+style.nsis.16=fore:#00007F,bold
+style.nsis.17=fore:#00007F,bold
+style.nsis.18=fore:#007F00,$(font.comment),bold
+
 
 command.compile.$(file.patterns.nsis)=c:/program files/nsis/makensis.exe "$(FilePath)"
 command.build.$(file.patterns.nsis)=c:/program files/nsis/makensis.exe "$(FilePath)"
-command.go.*.$(file.patterns.nsis)=$(FileName)
 
+command.go.$(file.patterns.nsis)=$(FileName).exe
 
+command.help.$(file.patterns.nsis)=$(CurrentWord)!C:\Program files\NSIS\NSIS.chm
+command.help.subsystem.$(file.patterns.nsis)=4
 
+comment.block.nsis=;
+comment.block.at.line.start.nsis=1
+comment.stream.start.nsis=/*
+comment.stream.end.nsis=*/
+comment.box.start.nsis=/*
+comment.box.middle.nsis=;
+comment.box.end.nsis=*/
+
+filter.opal=OPAL (impl sign)|*.impl;*.sign|
+
+file.patterns.opal=*.impl;*.sign
+lexer.$(file.patterns.opal)=opal
+
+keywordclass.opal_keywords=ALL AND ANDIF ANY AS ASSERT AXM COMPLETELY DATA DEF DERIVE \
+DFD DISCRIMINATORS ELSE EX EXTERNAL FI FIX FUN IF IMPLEMENTATION IMPLIES IMPORT \
+IN INHERIT INJECTIONS INTERFACE INTERNAL LAW LAZY LEFTASSOC LET MODULE NOT ONLY \
+OR ORIF OTHERWISE POST PRE PRED PRIORITY PROPERTIES REALIZES REQUIRE RIGHTASSOC \
+SELECTORS SIGNATURE SORT SPC SPEC SPECIFICATION STRUCTURE THE THEN THEORY THM \
+TYPE UNIQ WHERE
+
+keywordclass.opal_sorts=aEntry agent align anchor ans arg arg1 arg2 array \
+arrowWhere bag bitmap bool bstree byte callback canvasEditor capStyle channel \
+char childstat codom codomFrom codomTo color colorModel com composeOp config \
+configCom cursor dArray data data1 data11 data2 data21 data3 data31 data4 \
+data41 dataFrom dataTo defaultPrio denotation device dist distOut dom domFrom \
+domTo drawing dyn emitter env event eventInfo file filemode filestat filetype \
+first first1 first2 first3 fission fmt font from from1 from2 funct group groupid \
+heap iconfig image in inData index inode input int inter interdom interpreter \
+iseq items joinStyle justifyHow long manager managerRequest map mapEntry mark \
+mid modifier nat natMap OBJECT option orient out outData output packOp pair \
+parser permission point positionRequest process procstat quad range real \
+regulator rel relief res res1 res2 result role sap script scroller scrollView \
+scrollWindow searchOpt second seekMode selector semaphor seq seqEntry set \
+setEntry short sigaction sighandler sigmask signal size sizeRequest some \
+sreal state stateId stateRequest string subrel tag textEditor time to tree \
+triple union user userid version view void wconfig wconfigCom wday widget \
+window wrapStyle 
+
+keywords.$(file.patterns.opal)=$(keywordclass.opal_keywords)
+keywords2.$(file.patterns.opal)=$(keywordclass.opal_sorts)
+
+
+style.opal.0=fore:#000000,$(font.opal)
+style.opal.1=fore:#007F00,italics,$(font.comment)
+style.opal.2=fore:#007F00,italics,$(font.comment)
+style.opal.3=fore:#007F7F
+style.opal.4=fore:#00007F,bold
+style.opal.5=fore:#007F7F
+style.opal.6=fore:#7F007F,italics,$(font.comment)
+style.opal.7=fore:#000000
+style.opal.8=fore:#A00000
+
+style.opal.32=fore:#000000
+style.opal.34=fore:#FF0000,back:#FFFF00,bold
+style.opal.35=fore:#FF0000,back:#00FF00,bold
 
-file.patterns.props=*.properties;*.ini;*.inf;*.reg;*.url;*.cfg;*.cnf;*.aut
+file.patterns.props=*.properties;*.session;*.ini;*.inf;*.reg;*.url;*.cfg;*.cnf;*.aut
 file.patterns.text=*.txt;*.log;*.lst;*.doc;*.diz;*.nfo
 file.patterns.batch=*.bat;*.cmd;*.nt
 file.patterns.diff=*.diff;*.patch
@@ -2940,6 +4161,7 @@
 style.props.2=$(colour.string),back:#E0F0F0,eolfilled
 style.props.3=$(colour.other.operator)
 style.props.4=$(colour.preproc)
+style.props.5=
 style.props.34=fore:#0000FF,notbold
 style.props.35=fore:#FF0000,notbold
 comment.block.props=#~
@@ -2953,17 +4175,19 @@
 break call chcp cd chdir choice cls country ctty date del erase dir echo \
 exit goto loadfix loadhigh mkdir md move path pause prompt rename ren \
 rmdir rd shift time type ver verify vol \
-com con lpt nul
+com con lpt nul \
+color copy defined else not start
 keywords.$(file.patterns.batch)=$(keywordclass.batch)
 
+
 style.batch.0=fore:#000000
 style.batch.1=fore:#007F00,$(font.comment)
-style.batch.2=$(colour.keyword)
+style.batch.2=$(colour.keyword),bold
 style.batch.3=$(colour.string),back:#606060,fore:#FFFF00,eolfilled
 style.batch.4=$(colour.preproc)
-style.batch.5=$(colour.keyword),$(font.monospace),bold
-style.batch.6=back:#FFFFE0
-style.batch.7=$(colour.other.operator)
+style.batch.5=fore:#007090,$(font.monospace),bold
+style.batch.6=fore:#800080
+style.batch.7=fore:#000000
 
 comment.block.batch=REM ~
 
@@ -3001,6 +4225,8 @@
 style.errorlist.16=fore:#FF0000
 style.errorlist.17=fore:#FF0000
 style.errorlist.18=fore:#FF0000
+style.errorlist.19=fore:#FF0000
+style.errorlist.20=fore:#FF0000
 style.errorlist.33=$(font.small)
 
 
@@ -3027,12 +4253,12 @@
 file.patterns.pascal=*.dpr;*.dpk;*.pas;*.dfm;*.inc;*.pp
 lexer.$(file.patterns.pascal)=pascal
 
-keywordclass.pascal=and array asm begin case cdecl class const constructor default \
-destructor div do downto else end end. except exit exports external far file \
-finalization finally for function goto if implementation in index inherited \
+keywordclass.pascal=and array asm begin case cdecl class const constructor contains \
+default destructor div do downto else end end. except exit exports external \
+far file finalization finally for function goto if implementation in index inherited \
 initialization inline interface label library message mod near nil not \
-object of on or out overload override packed pascal private procedure program \
-property protected public published raise read record register repeat resourcestring \
+object of on or out overload override package packed pascal private procedure program \
+property protected public published raise read record register repeat requires resourcestring \
 safecall set shl shr stdcall stored string then threadvar to try type unit \
 until uses var virtual while with write xor
 
@@ -3061,7 +4287,6 @@
 
 statement.indent.$(file.patterns.pascal)=5 case catch class default do else for then \
 private protected public struct try union while type
-statement.end.$(file.patterns.pascal)=10 ;
 statement.lookback.$(file.patterns.pascal)=20
 block.start.$(file.patterns.pascal)=10 begin
 block.end.$(file.patterns.pascal)=10 end
@@ -3092,14 +4317,22 @@
 	command.3.*.pas=ddd "$(FileName)"
 
 
+
 file.patterns.perl=*.pl;*.pm;*.cgi;*.pod
-file.patterns.bash=*.sh;*.bsh
+file.patterns.bash=*.sh;*.bsh;configure
+file.patterns.awk=*.awk
+
+shbang.perl=pl
+shbang.sh=sh
+shbang.bash=sh
 
 filter.perl=Perl (pl pm)|$(file.patterns.perl)|
 filter.bash=Bash (sh bsh)|$(file.patterns.bash)|
+filter.awk=GAWK  (awk)|$(file.patterns.awk)|
 
 lexer.$(file.patterns.perl)=perl
 lexer.$(file.patterns.bash)=bash
+lexer.$(file.patterns.awk)=perl
 
 keywords.$(file.patterns.perl)=\
 NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD \
@@ -3115,27 +4348,51 @@
 getpwent getpwnam getpwuid getservbyname getservbyport getservent \
 getsockname getsockopt glob gmtime goto grep gt hex if index \
 int ioctl join keys kill last lc lcfirst le length link listen \
-local localtime lock log lstat lt m map mkdir msgctl msgget msgrcv \
+local localtime lock log lstat lt map mkdir msgctl msgget msgrcv \
 msgsnd my ne next no not oct open opendir or ord our pack package \
-pipe pop pos print printf prototype push q qq qr quotemeta qu \
-qw qx rand read readdir readline readlink readpipe recv redo \
+pipe pop pos print printf prototype push quotemeta qu \
+rand read readdir readline readlink readpipe recv redo \
 ref rename require reset return reverse rewinddir rindex rmdir \
-s scalar seek seekdir select semctl semget semop send setgrent \
+scalar seek seekdir select semctl semget semop send setgrent \
 sethostent setnetent setpgrp setpriority setprotoent setpwent \
 setservent setsockopt shift shmctl shmget shmread shmwrite shutdown \
 sin sleep socket socketpair sort splice split sprintf sqrt srand \
 stat study sub substr symlink syscall sysopen sysread sysseek \
-system syswrite tell telldir tie tied time times tr truncate \
+system syswrite tell telldir tie tied time times truncate \
 uc ucfirst umask undef unless unlink unpack unshift untie until \
 use utime values vec wait waitpid wantarray warn while write \
-x xor y
+xor
+
+keywords.$(file.patterns.awk)=\
+BEGIN END \
+if else while do for in break continue delete exit function return \
+print printf sprintf \
+system close getline next nextfile fflush \
+atan2 cos exp int log rand sin sqrt srand \
+asort asorti gensub sub gsub index length match split \
+strtonum substr tolower toupper \
+mktime strftime systime \
+and compl lshift or rshift xor \
+bindtextdomain dcgettext dcngettext \
+ARGC ARGIND ARGV BINMODE CONVFMT ENVIRON ERRNO FIELDWIDTHS \
+FILENAME FNR FS IGNORECASE LINT NF NR OFMT OFS ORS PROCINFO \
+RS RT RSTART RLENGTH SUBSEP TEXTDOMAIN
+
+
+comment.block.awk=#~
+block.start.$(file.patterns.awk)=10 {
+block.end.$(file.patterns.awk)=10 }
+
 
 word.characters.$(file.patterns.perl)=$(chars.alpha)$(chars.numeric)_$ %&
 
 comment.block.perl=#~
+block.start.$(file.patterns.perl)=10 {
+block.end.$(file.patterns.perl)=10 }
 
 colour.perl.heredoc=$(colour.embedded.comment)
 
+
 bash_keywords1=alias \
 ar asa awk banner basename bash bc bdiff break \
 bunzip2 bzip2 cal calendar case cat cc cd chmod cksum \
@@ -3202,6 +4459,7 @@
 style.perl.28=$(style.perl.20)
 style.perl.29=$(style.perl.17)
 style.perl.30=$(style.perl.13)
+style.perl.31=fore:#004000,back:#C0FFC0,$(font.monospace),eolfilled
 braces.perl.style=10
 
 style.bash.32=
@@ -3219,7 +4477,9 @@
 style.bash.11=fore:#FFFF00,back:#A08080
 style.bash.12=fore:#000000,back:#DDD0DD
 style.bash.13=fore:#7F007F,back:#DDD0DD,eolfilled,notbold
-braces.bash.style=10
+braces.bash.style=7
+
+command.go.$(file.patterns.awk)=gawk -f $(FileNameExt)
 
 command.go.$(file.patterns.perl)=perl -w $(FileNameExt)
 
@@ -3247,9 +4507,6 @@
 tab.size.*.inc=2
 use.tabs.*.inc=0
 
-
-file.patterns.braces=$(file.patterns.pov)
-
 lexer.$(file.patterns.pov)=pov
 
 word.chars.pov=$(chars.alpha)$(chars.numeric)_#
@@ -3266,8 +4523,6 @@
 comment.box.start.pov=/*
 comment.box.middle.pov= *
 comment.box.end.pov= */
-fold.comment=1
-fold.directive=1
 
 
 preprocessor.symbol.$(file.patterns.pov)=#
@@ -3496,23 +4751,65 @@
     command.go.*.ps=gs "$(FileNameExt)"
 
 
-filter.python=Python (py pyw)|*.py;*.pyw|
+file.patterns.purebasic=*.pb
+
+filter.purebasic=PureBasic (pb)|$(file.patterns.purebasic)|
+
+lexer.$(file.patterns.purebasic)=purebasic
+
+
+keywords.$(file.patterns.purebasic)=and break case continue data \
+datasection declare declarecdll declaredll default deftype dim else \
+elseif end enddatasection endenumeration endif endinterface endprocedure \
+endselect endstructure endstructureunion enumeration extends fakereturn \
+for foreach forever global gosub goto if includebinary includefile \
+includepath interface newlist next or procedure procedurecdll \
+proceduredll procedurereturn protected read repeat restore return select \
+shared static step structure structureunion to until wend while xincludefile
+
+keywords2.$(file.patterns.purebasic)=compilercase compilerdefault \
+compilerelse compilerendif compilerendselect compilerif compilerselect
+
+style.purebasic.0=fore:#000000
+style.purebasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+style.purebasic.2=$(colour.number)
+style.purebasic.3=$(colour.keyword)
+style.purebasic.4=$(colour.string)
+style.purebasic.6=$(colour.operator)
+style.purebasic.7=$(style.purebasic.0)
+style.purebasic.10=$(colour.preproc)
+style.purebasic.11=$(colour.keyword)
+style.purebasic.12=$(colour.keyword)
+style.purebasic.13=$(colour.number)
+style.purebasic.15=$(colour.preproc)
+style.purebasic.16=$(colour.error)
+style.purebasic.17=$(colour.number)
+style.purebasic.18=$(colour.number)
+
 
 file.patterns.py=*.py;*.pyw
+file.patterns.scons=SConstruct;SConscript
+
+shbang.python=py
+
+filter.python=Python (py pyw)|$(file.patterns.py)|
 
 lexer.$(file.patterns.py)=python
+lexer.$(file.patterns.scons)=python
 
-keywordclass.python=and assert break class continue def del elif \
+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 yield
+not or pass print raise return try while with yield
 
 keywords.$(file.patterns.py)=$(keywordclass.python)
+keywords.$(file.patterns.scons)=$(keywordclass.python)
+
+statement.indent.$(file.patterns.py)=5 class def elif else except finally \
+for if try while with
 
-statement.indent.*.py=10 :
-statement.end.*.py=
-statement.lookback.*.py=0
-block.start.*.py=
-block.end.*.py=
+statement.lookback.$(file.patterns.py)=0
+block.start.$(file.patterns.py)=
+block.end.$(file.patterns.py)=
 
 tab.timmy.whinge.level=1
 
@@ -3533,6 +4830,8 @@
 style.python.11=
 style.python.12=fore:#7F7F7F
 style.python.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.python.14=fore:#407090
+style.python.15=fore:#805000
 style.python.34=fore:#0000FF,bold
 style.python.35=fore:#FF0000,bold
 braces.python.style=10
@@ -3542,45 +4841,145 @@
 	command.go.subsystem.*.py=1
 	command.go.*.pyw=pythonw -u "$(FileNameExt)"
 	command.go.subsystem.*.pyw=1
+	command.build.SConscript=scons.bat --up .
+	command.build.SConstruct=scons.bat .
 
 if PLAT_GTK
-	command.go.*.py=python -u $(FileNameExt)
+	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)')"
 
-filter.ruby=Ruby (rb)|*.rb|
+file.patterns.rebol=*.r;*.reb
+
+filter.rebol=REBOL (r)|$(file.patterns.rebol)|
+
+lexer.$(file.patterns.rebol)=rebol
+
+keywords.$(file.patterns.rebol)=about abs absolute add \alert alias all alter and \any any-block? any-function? any-string? any-type? \any-word? append arccosine arcsine arctangent \array as-pair ask at attempt \back binary? bind bitset? block? \break brightness? browse build-tag caret-to-offset \catch center-face change change-dir char? \charset checksum choose clean-path clear \clear-fields close comment complement component? \compose compress confirm connected? construct \context copy cosine datatype? date? \debase decimal? decode-cgi decompress dehex \delete detab difference dir? dirize \disarm dispatch divide do do-events \does dump-face dump-obj echo either \else email? empty? enbase entab \equal? error? even? event? exclude \exists? exit exp extract fifth \file? find first flash focus \for forall foreach forever form \forskip found? fourth free func \function function? get get-modes get-word? \greater-or-equal? greater? halt has hash? \head head? help hide hide-popup 
 \if image? import-email in in-window? \index? info? inform input input? \insert integer? intersect issue? join \last launch layout length? lesser-or-equal? \lesser? library? license link? list-dir \list? lit-path? lit-word? load load-image \log-10 log-2 log-e logic? loop \lowercase make make-dir make-face max \maximum maximum-of min minimum minimum-of \modified? mold money? multiply native? \negate negative? next none? not \not-equal? now number? object? odd? \offset-to-caret offset? op? open or \pair? paren? parse parse-xml path? \pick poke port? positive? power \prin print probe protect protect-system \query quit random read read-io \recycle reduce refinement? reform rejoin \remainder remold remove remove-each rename \repeat repend replace request request-color \request-date request-download request-file request-list request-pass \request-text resend return reverse routine? \same? save script? second secure \select send series? set set-modes \set-net set-path? set-word? sh
 ow show-popup \sign? sine size-text size? skip \sort source span? split-path square-root \strict-equal? strict-not-equal? string? struct? stylize \subtract suffix? switch tag? tail \tail? tangent third throw time? \to to-binary to-bitset to-block to-char \to-date to-decimal to-email to-file to-get-word \to-hash to-hex to-idate to-image to-integer \to-issue to-list to-lit-path to-lit-word to-local-file \to-logic to-money to-pair to-paren to-path \to-rebol-file to-refinement to-set-path to-set-word to-string \to-tag to-time to-tuple to-url to-word \trace trim try tuple? type? \unfocus union unique unprotect unset \unset? until unview update upgrade \uppercase url? usage use value? \view viewed? wait what what-dir \while within? word? write write-io xor zero? 
+
+keywords2.$(file.patterns.rebol)=action? any-block? any-function? any-string? \
+any-type? any-word? binary? bitset? block? char? component? connected? \
+datatype? date? decimal? dir? email? empty? equal? error? even? event? exists? \
+file? found? function? get-word? greater-or-equal greater? hash? head? image? \
+index? info? input? integer? issue? length? lesser-or-equal? lesser? library? \
+link-app? link? list? lit-path? lit-word? logic? modified? money? native? negative? \
+none? not-equal? number? object? odd? offset? op? pair? paren? path? port? \
+positive? rebol-command? rebol-encap? rebol-link? rebol-pro? rebol-view? \
+refinement? routine? same? script? series? set-path? set-word? sign? size? \
+strict-equal? strict-not-equal string? struct? suffix? tag? tail? time? tuple? type? \
+unset? url? value? view? word? zero?
+
+keywords3.$(file.patterns.rebol)=action! any-block! any-function! any-string! any-type! \
+ any-word! binary! bitset! block! char! datatype! date! decimal! email! error! \
+ event! file! function! get-word! hash! image! integer! issue! library! list! lit-path! \
+ lit-word! logic! money! native! none! number! object! op! pair! paren! path! \
+ port! refinement! routine! series! set-path! set-word! string! struct! symbol! tag! \
+ time! tuple! unset! url! word!
+
+word.chars.rebol=$(chars.alpha)$(chars.numeric)?!.’+-*&|=_~
+word.characters.$(file.patterns.rebol)=$(word.chars.rebol)
+
+comment.block.rebol=;
+comment.box.start.rebol=;;
+comment.box.middle.rebol=;;
+comment.box.end.rebol=;;
+
+
+style.rebol.32=$(font.base)
+style.rebol.0=fore:#000000,bold
+style.rebol.1=$(colour.code.comment.box),$(font.code.comment.box)
+style.rebol.2=$(colour.code.comment.box),$(font.code.comment.box)
+style.rebol.3=$(colour.code.comment.box),$(font.code.comment.box),bold
+style.rebol.4=$(colour.operator),bold
+style.rebol.5=$(colour.string)
+style.rebol.6=$(colour.string)
+style.rebol.7=$(colour.string)
+style.rebol.8=$(colour.number)
+style.rebol.9=fore:#005090
+style.rebol.10=fore:#005090
+style.rebol.11=fore:#C000C0
+style.rebol.12=fore:#003070
+style.rebol.13=fore:#800000
+style.rebol.14=fore:#C00000
+style.rebol.15=fore:#0080FF
+style.rebol.16=fore:#0080FF
+style.rebol.17=fore:#0080FF
+style.rebol.18=fore:#8000FF
+style.rebol.19=fore:#8000FF
+
+style.rebol.20=
+style.rebol.21=$(colour.keyword),bold
+style.rebol.22=fore:#8000C0,bold
+style.rebol.23=fore:#800060,bold
+
+style.rebol.34=fore:#0000FF,bold
+style.rebol.35=fore:#FF0000,bold
+braces.rebol.style=0
+
+command.go.$(file.patterns.rebol)=E:\tools\lang\rebol\core\rebol.exe $(FilePath)
+
 
-lexer.*.rb=ruby
+file.patterns.rb=*.rb;*.rbw
 
-file.patterns.rb=*.rb
+shbang.ruby=rb
+
+filter.ruby=Ruby (rb rbw)|$(file.patterns.rb)|
+
+lexer.$(file.patterns.rb)=ruby
 
 keywordclass.ruby=__FILE__ and def end in or self unless __LINE__ begin \
 defined? ensure module redo super until BEGIN break do false next rescue \
-then when END case else for nil require retry true while alias class elsif if \
+then when END case else for nil retry true while alias class elsif if \
 not return undef yield
 keywords.$(file.patterns.rb)=$(keywordclass.ruby)
 
-statement.indent.*.rb=
-statement.end*.rb=
-statement.lookback.*.rb=1
-block.start.*.rb=10
+statement.indent.$(file.patterns.rb)=5 def class if do elsif else case while for
+
+block.start.$(file.patterns.rb)=5 do
+block.end.$(file.patterns.rb)=5 end
+
+indent.opening.$(file.patterns.rb)=1
+indent.closing.$(file.patterns.rb)=1
 
 comment.block.ruby=#~
 
 style.ruby.0=fore:#808080
-style.ruby.1=fore:#007F00,$(font.comment)
-style.ruby.2=fore:#007F7F
-style.ruby.3=fore:#7F007F,$(font.monospace)
-style.ruby.4=fore:#7F007F,$(font.monospace)
+style.ruby.1=back:#FF0000
+style.ruby.2=fore:#007F00,$(font.comment)
+style.ruby.3=fore:#004000,back:#C0FFC0,$(font.monospace),eolfilled
+style.ruby.4=fore:#007F7F
 style.ruby.5=fore:#00007F,bold
-style.ruby.7=fore:#7F0000
+style.ruby.6=fore:#7F007F,$(font.monospace)
+style.ruby.7=fore:#7F007F,$(font.monospace)
 style.ruby.8=fore:#0000FF,bold
 style.ruby.9=fore:#007F7F,bold
 style.ruby.10=bold
-style.ruby.11=fore:#7F7F7F
-style.ruby.12=fore:#7F7F7F
-style.ruby.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.ruby.11=
+style.ruby.12=fore:#000000,back:#A0FFA0
+style.ruby.13=fore:#800080
+style.ruby.14=fore:#C0A030
+style.ruby.15=fore:#A000A0,bold
+style.ruby.16=fore:#B00080
+style.ruby.17=fore:#8000B0
+style.ruby.18=fore:#FFFF00,back:#A08080
+style.ruby.19=fore:#600000,back:#FFF0D8,eolfilled
+style.ruby.20=fore:#000000,back:#DDD0DD
+style.ruby.21=fore:#7F007F,back:#DDD0DD,eolfilled,notbold
+style.ruby.22=fore:#7F007F,back:#DDD0DD,eolfilled,bold
+style.ruby.23=fore:#7F007F,back:#DDD0DD,eolfilled,italics
+style.ruby.24=fore:#7F007F,$(font.monospace),notbold
+style.ruby.25=$(colour.string),$(font.monospace)
+style.ruby.26=fore:#FFFF00,back:#A08080
+style.ruby.27=fore:#000000,back:#A0FFA0
+style.ruby.28=fore:#000000,back:#FFFFE0
+style.ruby.29=$(style.ruby.5)
+style.ruby.30=back:#FF8080
+style.ruby.31=back:#FF8080
+style.ruby.40=back:#FF8080
+
 style.ruby.34=fore:#0000FF,bold
 style.ruby.35=fore:#FF0000,bold
 braces.ruby.style=10
@@ -3588,10 +4987,20 @@
 if PLAT_WIN
 	command.go.*.rb=ruby $(FileNameExt)
 	command.go.subsystem.*.rb=1
+	command.go.*.rbw=rubyw $(FileNameExt)
+	command.go.subsystem.*.rbw=1
+	command.help.*.rb=$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
+	command.help.subsystem.*.rb=4
 
 if PLAT_GTK
 	command.go.*.rb=ruby $(FileNameExt)
 
+	command.name.1.*.rb=Check Syntax
+	command.1.*.rb=ruby -cw $(FileNameExt)
+
+	command.name.2.*.rb=Code Profiler
+	command.2.*.rb=ruby -r profile $(FileNameExt)
+
 filter.scriptol=Scriptol (sol)|*.sol|
 
 lexer.*.sol=scriptol
@@ -3614,7 +5023,6 @@
 keywords.$(file.patterns.sol)=$(keywordclass.scriptol)
 
 statement.indent.*.sol=
-statement.end*.sol=
 statement.lookback.*.sol=1
 block.start.*.sol=10
 
@@ -3642,7 +5050,7 @@
 
 if PLAT_GTK
         command.help.$(file.patterns.sol)=man $(CurrentWord) | col -b
-	
+
 command.compile.*.sol=solc -c $(FileNameExt)
 command.build.*.sol=solc -be $(FileNameExt)
 command.go.*.sol=$(FileName)
@@ -3669,13 +5077,39 @@
 command.is.filter.4.*.sol=1
 
 
+file.patterns.smalltalk=*.st
+
+filter.smalltalk=Smalltalk (.st)|$(file.patterns.smalltalk)|
+
+lexer.$(file.patterns.smalltalk)=smalltalk
+
+keywords.$(file.patterns.smalltalk)=\
+    ifTrue: ifFalse: whileTrue: whileFalse: ifNil: ifNotNil: whileTrue whileFalse repeat isNil notNil
+
+
+style.smalltalk.0=
+style.smalltalk.1=$(colour.string),eolfilled
+style.smalltalk.2=$(colour.number)
+style.smalltalk.3=$(colour.code.comment.box)
+style.smalltalk.4=fore:#800080
+style.smalltalk.5=$(colour.operator)
+style.smalltalk.6=$(colour.keyword),bold
+style.smalltalk.7=$(colour.keyword),bold
+style.smalltalk.8=$(colour.keyword),bold
+style.smalltalk.9=$(colour.keyword),bold
+style.smalltalk.10=bold
+style.smalltalk.11=fore:#A00000,bold
+style.smalltalk.12=bold
+style.smalltalk.13=fore:#008000
+style.smalltalk.14=bold
+style.smalltalk.15=$(colour.char)
+style.smalltalk.16=$(colour.keyword),bold
+
 file.patterns.specman=*.e
 
 filter.specman=Specman (e)|\
 $(file.patterns.specman)|
 
-file.patterns.braces=$(file.patterns.specman)
-
 lexer.$(file.patterns.specman)=specman
 
 keywords.$(file.patterns.specman)= \
@@ -3765,10 +5199,6 @@
 comment.box.middle.specman=
 comment.box.end.specman=
 
-fold.comment=1
-fold.preprocessor=1
-fold.at.else=1
-
 
 indent.maintain.$(file.patterns.specman)=1;
 
@@ -3801,6 +5231,65 @@
 braces.specman.style=10
 
 
+file.patterns.spice=*.scp;*.out
+filter.spice=Spice (out scp)|$(file.patterns.spice)|
+lexer.$(file.patterns.spice)=spice
+
+
+keywordclass.spice.command=\
+ac  alias  alter  alterparam append askvalues assertvalid autoscale \
+break compose copy copytodoc dc  delete  destroy  destroyvec diff  display \
+disto  dowhile  echo  else  end  errorstop  fftinit filter foreach  fourier \
+freqtotime function  functionundef goto  homecursors if isdisplayed label \
+let  linearize listing  load  loadaccumulator makelabel movelabel makesmithplot \
+movecursorleft movecursorright  msgbox nameplot  newplot nextparam noise \
+nopoints  op plot plotf plotref poly print  printcursors  printevent printname \
+printplot printstatus printtext printtol printunits printval printvector \
+pwl  pz  quit  removesmithplot rename repeat  resume  rotate  runs rusage \
+save sendplot sendscript sens  set  setcursor setdoc setlabel setlabeltype \
+setmargins setnthtrigger  setunits setvec setparam setplot  setquery \
+setscaletype settracecolor settracestyle setsource settrigger  setvec \
+setxlimits setylimits show  showmod  sort status  step  stop  switch \
+tf  timetofreq  timetowave tran  unalias  unlet  unset  unalterparam \
+update version view   wavefilter  wavetotime where  while  write
+keywordclass.spice.functions=\
+abs askvalue atan average ceil cos db differentiate differentiatex \
+exp finalvalue floor getcursorx getcursory getcursory0 getcursory1 \
+getparam im ln initialvalue integrate integratex interpolate isdef \
+isdisplayed j log length mag, max maxscale mean meanpts min minscale \
+nextplot  nextvector  norm operatingpoint ph phase phaseextend pk_pk \
+pos pulse re rms rmspts rnd sameplot  sin sqrt stddev stddevpts tan \
+tfall tolerance trise unitvec vector
+keywordclass.spice.params=param nodeset include options dcconv subckt ends model
+
+
+keywordclass.spice=$(keywordclass.spice.command) $(keywordclass.spice.functions) $(keywordclass.spice.params)
+
+keywords.$(file.patterns.spice)=$(keywordclass.spice.command)
+keywords2.$(file.patterns.spice)=$(keywordclass.spice.functions)
+keywords3.$(file.patterns.spice)=$(keywordclass.spice.params)
+
+style.spice.0=fore:#808080
+style.spice.1=
+style.spice.2=$(colour.keyword)
+style.spice.3=$(colour.keyword),bold
+style.spice.4=fore:#0040E0
+style.spice.5=$(colour.number)
+style.spice.6=$(colour.operator),bold
+style.spice.7=$(colour.char)
+style.spice.8=$(colour.code.comment.line),$(font.code.comment.line)
+
+comment.block.spice=*~
+
+braces.spice.style=4
+
+statement.indent.$(file.patterns.spice)=5 begin declare else elsif exception for if is loop while
+statement.lookback.$(file.patterns.spice)=20
+block.start.$(file.patterns.spice)=10 then is
+block.end.$(file.patterns.spice)=10 end
+
+calltip.spice.word.characters=._$(chars.alpha)
+
 filter.sql=SQL (sql)|*.sql|
 
 file.patterns.sql=*.sql
@@ -3817,12 +5306,21 @@
 style.sql.5=fore:#00007F,bold
 style.sql.6=fore:#7F007F,$(font.monospace)
 style.sql.7=fore:#7F007F,$(font.monospace)
-style.sql.8=fore:#007F7F
-style.sql.9=fore:#7F7F00
+style.sql.8=$(colour.preproc)
+style.sql.9=fore:#007F00,$(font.monospace),back:#E0FFE0,eolfilled
 style.sql.10=bold
 style.sql.11=
 style.sql.12=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.sql.13=fore:#007F00,$(font.comment)
 style.sql.15=fore:#007F00,$(font.comment)
+style.sql.16=fore:#B00040
+style.sql.17=fore:#3060A0,$(font.code.comment.doc)
+style.sql.18=fore:#804020,$(font.code.comment.doc)
+style.sql.19=fore:#4B0082
+style.sql.20=fore:#B00040
+style.sql.21=fore:#8B0000
+style.sql.22=fore:#800080
+
 braces.sql.style=10
 
 keywords.$(file.patterns.sql)=\
@@ -3901,116 +5399,163 @@
 varchar2 variance view when whenever where while with work write \
 year zone
 
+keywords3.$(file.patterns.sql)=\
+param author since return see deprecated todo
 
-filter.tcl=Tcl (tcl)|*.tcl|
-
-lexer.*.tcl=tcl
-
-filter.itcl=itcl (.itcl)|*.itcl|
-
-lexer.*.itcl=tcl
-
-preprocessor.symbol.*.tcl=
-preprocessor.start.*.tcl=
-preprocessor.middle.*.tcl=
-preprocessor.end.*.tcl=
-
-keywordclass.tcl=after append array auto_execok auto_import auto_load \
-auto_load_index auto_qualify beep binary break case catch cd clock \
-close concat continue dde default echo else elseif encoding eof \
-error eval exec exit expr fblocked fconfigure fcopy file \
-fileevent flush for foreach format gets glob global history if \
-incr info interp join lappend lindex linsert list llength load \
-lrange lreplace lsearch lsort namespace open package pid \
-pkg_mkIndex proc puts pwd read regexp regsub rename resource \
-return scan seek set socket source split string subst switch \
-tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell time \
-trace unknown unset update uplevel upvar variable vwait while
-
-keywordclass.tk=bell bind bindtags button canvas checkbutton console \
-destroy entry event focus font frame grab grid image label listbox menu \
-menubutton message pack place radiobutton raise scale scrollbar \
-text tk tkwait toplevel winfo wm
+keywords4.$(file.patterns.sql)=\
+acc~ept a~ppend archive log attribute \
+bre~ak bti~tle \
+c~hange cl~ear col~umn comp~ute conn~ect copy \
+def~ine del desc~ribe disc~onnect \
+e~dit exec~ute exit \
+get \
+help ho~st \
+i~nput \
+l~ist \
+passw~ord pau~se pri~nt pro~mpt \
+quit \
+recover rem~ark repf~ooter reph~eader r~un \
+sav~e set sho~w shutdown spo~ol sta~rt startup store \
+timi~ng tti~tle \
+undef~ine \
+var~iable \
+whenever oserror whenever sqlerror \
+
+keywords5.$(file.patterns.sql)=\
+dbms_output.disable dbms_output.enable dbms_output.get_line \
+dbms_output.get_lines dbms_output.new_line dbms_output.put \
+dbms_output.put_line \
+
+file.patterns.tcl=*.tcl;*.exp
+file.patterns.itcl=*.itcl
+file.patterns.tcl.like=$(file.patterns.tcl);$(file.patterns.itcl);
+
+filter.tcl=Tcl (tcl)|$(file.patterns.tcl)|
+filter.itcl=itcl (itcl)|$(file.patterns.itcl)|
+
+lexer.$(file.patterns.tcl)=tcl
+lexer.$(file.patterns.itcl)=tcl
+
+keywordclass.tcl=after append array auto_execok \
+auto_import auto_load auto_load_index auto_qualify \
+beep bgerror binary break case catch cd clock \
+close concat continue dde default echo else elseif \
+encoding eof error eval exec exit expr fblocked \
+fconfigure fcopy file fileevent flush for foreach format \
+gets glob global history http if incr info \
+interp join lappend lindex linsert list llength load \
+loadTk lrange lreplace lsearch lset lsort memory msgcat \
+namespace open package pid pkg::create pkg_mkIndex Platform-specific proc \
+puts pwd re_syntax read regexp registry regsub rename \
+resource return scan seek set socket source split \
+string subst switch tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell \
+time trace unknown unset update uplevel upvar variable \
+vwait while
+
+keywordclass.tk=bell bind bindtags bitmap button canvas checkbutton clipboard \
+colors console cursors destroy entry event focus font \
+frame grab grid image Inter-client keysyms label labelframe \
+listbox lower menu menubutton message option options pack \
+panedwindow photo place radiobutton raise scale scrollbar selection \
+send spinbox text tk tk_chooseColor tk_chooseDirectory tk_dialog tk_focusNext \
+tk_getOpenFile tk_messageBox tk_optionMenu tk_popup tk_setPalette tkerror tkvars tkwait \
+toplevel winfo wish wm
 
 keywordclass itcl= scope body class code common component configbody \
 constructor define destructor hull import inherit itcl itk itk_component \
 itk_initialize itk_interior itk_option iwidgets keep method \
 private protected public
 
-keywordclass.TkCommands=tkButtonDown tkButtonEnter tkButtonInvoke \
-tkButtonLeave tkButtonUp tkCancelRepeat tkCheckRadioInvoke tkDarken \
-tkEntryAutoScan 	tkEntryBackspace tkEntryButton1 tkEntryClosestGap \
-tkEntryInsert tkEntryKeySelect tkEntryMouseSelect tkEntryNextWord \
-tkEntryPaste tkEntryPreviousWord tkEntrySeeInsert tkEntrySetCursor \
-tkEntryTranspose tkEventMotifBindings tkFDGetFileTypes tkFirstMenu \
-tkFocusGroup_Destroy tkFocusGroup_In tkFocusGroup_Out tkFocusOK \
-tkListboxAutoScan tkListboxBeginExtend tkListboxBeginSelect \
-tkListboxBeginToggle tkListboxCancel tkListboxDataExtend \
-tkListboxExtendUpDown tkListboxMotion tkListboxSelectAll \
-tkListboxUpDown tkMbButtonUp tkMbEnter tkMbLeave tkMbMotion \
-tkMbPost tkMenuButtonDown tkMenuDownArrow tkMenuDup tkMenuEscape \
-tkMenuFind tkMenuFindName tkMenuFirstEntry tkMenuInvoke tkMenuLeave \
-tkMenuLeftArrow tkMenuMotion tkMenuNextEntry tkMenuNextMenu \
-tkMenuRightArrow tkMenuUnpost tkMenuUpArrow tkMessageBox \
-tkPostOverPoint tkRecolorTree tkRestoreOldGrab tkSaveGrabInfo \
-tkScaleActivate tkScaleButton2Down tkScaleButtonDown \
-tkScaleControlPress tkScaleDrag tkScaleEndDrag tkScaleIncrement \
-tkScreenChanged tkScrollButton2Down tkScrollButtonDown \
-tkScrollButtonUp tkScrollByPages tkScrollByUnits tkScrollDrag \
-tkScrollEndDrag tkScrollSelect tkScrollStartDrag tkScrollToPos  \
-tkScrollTopBottom tkTabToWindow tkTearOffMenu tkTextAutoScan \
-tkTextButton1 tkTextClosestGap tkTextInsert tkTextKeyExtend \
-tkTextKeySelect tkTextNextPara tkTextNextPos tkTextNextWord \
-tkTextPaste tkTextPrevPara tkTextPrevPos tkTextResetAnchor \
-tkTextScrollPages tkTextSelectTo tkTextSetCursor tkTextTranspose \
-tkTextUpDownLine tkTraverseToMenu tkTraverseWithinMenu tk_bisque \
-tk_chooseColor tk_dialog tk_focusFollowsMouse tk_focusNext \
-tk_focusPrev tk_getOpenFile tk_getSaveFile tk_messageBox \
-tk_optionMenu tk_popup tk_setPalette tk_textCopy tk_textCut \
-tk_textPaste
-
-keywords.*.tcl=$(keywordclass.tcl) $(keywordclass.tk) $(keywordclass.TkCommands)
-
-keywords.*.itcl=$(keywordclass.tcl) $(keywordclass.tk) $(keywordclass.itcl) \
-$(keywordclass.TkCommands)
-
-statement.end.*.tcl=8  ;
-statement.lookback.*.tcl=1
-block.start.*.tcl=4 {
-block.end.*.tcl=4 }
+keywordclass.TkCommands=tk_bisque tk_chooseColor tk_dialog tk_focusFollowsMouse tk_focusNext \
+tk_focusPrev tk_getOpenFile tk_getSaveFile tk_messageBox tk_optionMenu \
+tk_popup tk_setPalette tk_textCopy tk_textCut tk_textPaste \
+tkButtonAutoInvoke tkButtonDown tkButtonEnter tkButtonInvoke tkButtonLeave \
+tkButtonUp tkCancelRepeat tkCheckRadioDown tkCheckRadioEnter tkCheckRadioInvoke \
+tkColorDialog tkColorDialog_BuildDialog tkColorDialog_CancelCmd tkColorDialog_Config tkColorDialog_CreateSelector \
+tkColorDialog_DrawColorScale tkColorDialog_EnterColorBar tkColorDialog_HandleRGBEntry tkColorDialog_HandleSelEntry tkColorDialog_InitValues \
+tkColorDialog_LeaveColorBar tkColorDialog_MoveSelector tkColorDialog_OkCmd tkColorDialog_RedrawColorBars tkColorDialog_RedrawFinalColor \
+tkColorDialog_ReleaseMouse tkColorDialog_ResizeColorBars tkColorDialog_RgbToX tkColorDialog_SetRGBValue tkColorDialog_StartMove \
+tkColorDialog_XToRgb tkConsoleAbout tkConsoleBind tkConsoleExit tkConsoleHistory \
+tkConsoleInit tkConsoleInsert tkConsoleInvoke tkConsoleOutput tkConsolePrompt \
+tkConsoleSource tkDarken tkEntryAutoScan tkEntryBackspace tkEntryButton1 \
+tkEntryClosestGap tkEntryGetSelection tkEntryInsert tkEntryKeySelect tkEntryMouseSelect \
+tkEntryNextWord tkEntryPaste tkEntryPreviousWord tkEntrySeeInsert tkEntrySetCursor \
+tkEntryTranspose tkEventMotifBindings tkFDGetFileTypes tkFirstMenu tkFocusGroup_BindIn \
+tkFocusGroup_BindOut tkFocusGroup_Create tkFocusGroup_Destroy tkFocusGroup_In tkFocusGroup_Out \
+tkFocusOK tkGenerateMenuSelect tkIconList tkIconList_Add tkIconList_Arrange \
+tkIconList_AutoScan tkIconList_Btn1 tkIconList_Config tkIconList_Create tkIconList_CtrlBtn1 \
+tkIconList_Curselection tkIconList_DeleteAll tkIconList_Double1 tkIconList_DrawSelection tkIconList_FocusIn \
+tkIconList_FocusOut tkIconList_Get tkIconList_Goto tkIconList_Index tkIconList_Invoke \
+tkIconList_KeyPress tkIconList_Leave1 tkIconList_LeftRight tkIconList_Motion1 tkIconList_Reset \
+tkIconList_ReturnKey tkIconList_See tkIconList_Select tkIconList_Selection tkIconList_ShiftBtn1 \
+tkIconList_UpDown tkListbox tkListboxAutoScan tkListboxBeginExtend tkListboxBeginSelect \
+tkListboxBeginToggle tkListboxCancel tkListboxDataExtend tkListboxExtendUpDown tkListboxKeyAccel_Goto \
+tkListboxKeyAccel_Key tkListboxKeyAccel_Reset tkListboxKeyAccel_Set tkListboxKeyAccel_Unset tkListboxMotion \
+tkListboxSelectAll tkListboxUpDown tkMbButtonUp tkMbEnter tkMbLeave \
+tkMbMotion tkMbPost tkMenuButtonDown tkMenuDownArrow tkMenuDup \
+tkMenuEscape tkMenuFind tkMenuFindName tkMenuFirstEntry tkMenuInvoke \
+tkMenuLeave tkMenuLeftArrow tkMenuMotion tkMenuNextEntry tkMenuNextMenu \
+tkMenuRightArrow tkMenuUnpost tkMenuUpArrow tkMessageBox tkMotifFDialog \
+tkMotifFDialog_ActivateDList tkMotifFDialog_ActivateFEnt tkMotifFDialog_ActivateFList tkMotifFDialog_ActivateSEnt tkMotifFDialog_BrowseDList \
+tkMotifFDialog_BrowseFList tkMotifFDialog_BuildUI tkMotifFDialog_CancelCmd tkMotifFDialog_Config tkMotifFDialog_Create \
+tkMotifFDialog_FileTypes tkMotifFDialog_FilterCmd tkMotifFDialog_InterpFilter tkMotifFDialog_LoadFiles tkMotifFDialog_MakeSList \
+tkMotifFDialog_OkCmd tkMotifFDialog_SetFilter tkMotifFDialog_SetListMode tkMotifFDialog_Update tkPostOverPoint \
+tkRecolorTree tkRestoreOldGrab tkSaveGrabInfo tkScaleActivate tkScaleButton2Down \
+tkScaleButtonDown tkScaleControlPress tkScaleDrag tkScaleEndDrag tkScaleIncrement \
+tkScreenChanged tkScrollButton2Down tkScrollButtonDown tkScrollButtonDrag tkScrollButtonUp \
+tkScrollByPages tkScrollByUnits tkScrollDrag tkScrollEndDrag tkScrollSelect \
+tkScrollStartDrag tkScrollTopBottom tkScrollToPos tkTabToWindow tkTearOffMenu \
+tkTextAutoScan tkTextButton1 tkTextClosestGap tkTextInsert tkTextKeyExtend \
+tkTextKeySelect tkTextNextPara tkTextNextPos tkTextNextWord tkTextPaste \
+tkTextPrevPara tkTextPrevPos tkTextPrevWord tkTextResetAnchor tkTextScrollPages \
+tkTextSelectTo tkTextSetCursor tkTextTranspose tkTextUpDownLine tkTraverseToMenu \
+tkTraverseWithinMenu
+
+keywords.$(file.patterns.tcl.like)=$(keywordclass.tcl) 
+keywords2.$(file.patterns.tcl.like)=$(keywordclass.tk)
+keywords3.$(file.patterns.tcl.like)= $(keywordclass.TkCommands)
+keywords4.$(file.patterns.itcl)=$(keywordclass.itcl) 
+keywords5.$(file.patterns.tcl.like)=expand
 
 comment.block.tcl=#~
 comment.box.start.tcl=##
 comment.box.middle.tcl= #
 comment.box.end.tcl= ##
 
+style.tcl.32=$(font.base)
 style.tcl.0=fore:#808080
-style.tcl.1=fore:#007F00,$(font.comment)
-style.tcl.2=fore:#007F7F
-style.tcl.3=fore:#7F007F,$(font.monospace)
-style.tcl.4=fore:#7F007F,$(font.monospace)
-style.tcl.5=fore:#00007F,bold
-style.tcl.6=fore:#7F0000
-style.tcl.7=fore:#7F0000
-style.tcl.8=fore:#0000FF,bold
-style.tcl.9=fore:#007F7F,bold
-style.tcl.10=bold
-style.tcl.11=
-style.tcl.12=fore:#7F7F7F
-style.tcl.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
-style.tcl.34=fore:#0000FF,bold
-style.tcl.35=fore:#FF0000,bold
-braces.tcl.style=10
+style.tcl.1=$(colour.code.comment.line),$(font.comment),back:#f0FFE0
+style.tcl.2=$(colour.code.comment.line),$(font.code.comment.line)
+style.tcl.3=$(colour.number)
+style.tcl.4=$(colour.string),bold,back:#FFF0F0
+style.tcl.5=$(colour.string),back:#FFf0f0,eolfilled
+style.tcl.6=$(colour.operator),bold
+style.tcl.7=$(colour.keyword)
+style.tcl.8=$(colour.preproc)
+style.tcl.9=$(colour.preproc),back:#effff0
+style.tcl.10=$(colour.char)
+style.tcl.11=$(colour.keyword),back:#FFFF80,bold
+style.tcl.12=$(colour.keyword),bold
+style.tcl.13=$(colour.keyword),back:#e0ffff,bold
+style.tcl.14=$(colour.keyword),back:#FFf0f0,bold
+style.tcl.15=$(colour.keyword),back:#FFD0D0,bold
+style.tcl.16=$(style.tcl.7),back:#FFD0FF,bold
+style.tcl.17=$(style.tcl.7),back:#FFFFD0,bold
+style.tcl.18=$(style.tcl.7),back:#FFA0A0,bold,
+style.tcl.19=$(style.tcl.7),back:#FFD0D0
+style.tcl.20=$(colour.code.comment.box),$(font.code.comment.box),back:#f0FFf0,eolfilled
+style.tcl.21=$(colour.embedded.comment),$(font.embedded.comment),back:#f0FFf0
+
+style.tcl.34=fore:#f0f0f0,bold,back:#7070ff
+style.tcl.35=fore:#FF0000,bold,back:#FF00FF
+
+braces.tcl.style=6
 
 
 
-file.patterns.tex=
-file.patterns.latex=
-file.patterns.context=
-
-file.patterns.tex=*.tex;*.sty;
-file.patterns.latex=*.tex;*.sty;*.aux;*.toc;*.idx;
-file.patterns.context=*.tex;*.tui;*.tuo;*.sty;
+file.patterns.tex=*.tex;*.sty
+file.patterns.latex=*.tex;*.sty;*.aux;*.toc;*.idx
+file.patterns.context=*.tex;*.tui;*.tuo;*.sty
 
 
 filter.context=TeX|$(file.patterns.tex)|
@@ -4215,7 +5760,7 @@
     pdfvorigin \
     pdfxform pdfximage
 
-keywordclass.primitives.omega=
+keywordclass.primitives.omega=\
     odelimiter omathaccent omathchar oradical omathchardef omathcode odelcode \
     leftghost rightghost \
     charwd charht chardp charit \
@@ -4400,37 +5945,39 @@
 lexer.$(file.patterns.vb)=vb
 lexer.$(file.patterns.wscript)=vbscript
 
-keywordclass.vb=and begin case call continue do each else elseif end erase \
-error event exit false for function get gosub goto if implement in load loop lset \
-me mid new next not nothing on or property raiseevent rem resume return rset \
-select set stop sub then to true unload until wend while with withevents \
-attribute alias as boolean byref byte byval const compare currency date declare dim double \
-enum explicit friend global integer let lib long module object option optional \
-preserve private property public redim single static string type variant
-
-keywordclass.vbnet=addhandler addressof andalso alias and ansi as assembly auto boolean \
-byref byte byval call case catch cbool cbyte cchar cdate cdec cdbl char cint class \
-clng cobj const cshort csng cstr ctype date decimal declare default delegate dim do double \
-each else elseif end enum erase error event exit false finally for friend function get \
-gettype goto  handles if implements imports in inherits integer interface is let lib like long \
-loop me mod module mustinherit mustoverride mybase myclass namespace new \
-next not nothing notinheritable notoverridable object on option optional or \
-orelse overloads overridable overrides paramarray preserve private property protected public \
-raiseevent readonly redim rem removehandler resume return select set shadows \
-shared short single static step stop string structure sub synclock then throw to true try \
-typeof unicode until variant when while with withevents writeonly xor
-
-keywords.$(file.patterns.vb)=$(keywordclass.vbnet)
-keywords.$(file.patterns.wscript)=$(keywordclass.vb)
-
-keywordclass.vbotherstatements=appactivate beep chdir chdrive close \
-deletesetting filecopy get input kill line lock unlock lset mid mkdir name \
-open print put randomize reset rmdir rset savepicture savesetting seek \
-sendkeys setattr time unload width write
+keywordclass.vb6=\
+addressof alias and as attribute base begin binary boolean byref byte byval call case compare \
+const currency date decimal declare defbool defbyte defint deflng defcur defsng defdbl defdec \
+defdate defstr defobj defvar dim do double each else elseif empty end enum eqv erase error \
+event exit explicit false for friend function get gosub goto if imp implements in input integer \
+is len let lib like load lock long loop lset me mid midb mod new next not nothing null object \
+on option optional or paramarray preserve print private property public raiseevent randomize \
+redim rem resume return rset seek select set single static step stop string sub then time to \
+true type typeof unload until variant wend while with withevents xor
+
+keywordclass.vb=$(keywordclass.vb6)
+
+keywordclass.vbotherstatements=\
+appactivate beep chdir chdrive close filecopy get input kill line unlock mkdir name \
+open print put reset rmdir savepicture savesetting seek sendkeys setattr width write
+
+keywordclass.vbnet=\
+addhandler andalso as assembly auto catch cbool cbyte cchar cdate cdbl cdec char cint \
+class clng cobj cshort csng cstr ctype default delegate finally gettype handles imports \
+inherits interface mustinherit mustoverride mybase myclass namespace notinheritable \
+notoverridable orelse overloads overridable overrides protected readonly removehandler \
+shadows shared short structure synclock throw try unicode when writeonly
+
+keywords.$(file.patterns.vb)=$(keywordclass.vb6) $(keywordclass.vbnet)
+keywords.$(file.patterns.wscript)=$(keywordclass.vb6)
+
+keywords2.$(file.patterns.vb)=$(keywordclass.vbotherstatements)
 
 comment.block.vb='~
+comment.block.vbscript='~
 
-style.vb.0=fore:#000000,$(font.vbs)
+style.vb.32=$(font.base)
+style.vb.0=
 style.vb.1=$(colour.code.comment.line),$(font.code.comment.line)
 style.vb.2=$(colour.number)
 style.vb.3=$(colour.keyword)
@@ -4439,6 +5986,10 @@
 style.vb.6=$(colour.operator)
 style.vb.7=
 style.vb.8=$(colour.number)
+style.vb.9=$(style.stringeol)
+style.vb.10=$(style.vb.5),back:#D0FFD0
+style.vb.11=$(style.vb.5),back:#D0D0FF
+style.vb.12=$(style.vb.5),back:#FFD0D0
 
 style.vbscript.0=$(style.vb.0)
 style.vbscript.1=$(style.vb.1)
@@ -4449,6 +6000,10 @@
 style.vbscript.6=$(style.vb.6)
 style.vbscript.7=$(style.vb.7)
 style.vbscript.8=$(style.vb.8)
+style.vbscript.9=$(style.vb.9)
+style.vbscript.10=$(style.vb.10)
+style.vbscript.11=$(style.vb.11)
+style.vbscript.12=$(style.vb.12)
 
 command.go.$(file.patterns.wscript)="$(FilePath)"
 command.go.subsystem.$(file.patterns.wscript)=2
@@ -4456,6 +6011,10 @@
 command.build.$(file.patterns.wscript)=cscript "$(FilePath)"
 command.build.subsystem.$(file.patterns.wscript)=1
 
+command.help.$(file.patterns.wscript)=$(CurrentWord)!C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\MSDN130.COL
+command.help.subsystem.$(file.patterns.wscript)=4
+command.help.$(file.patterns.vb)=$(CurrentWord)!C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\MSDN130.COL
+command.help.subsystem.$(file.patterns.vb)=4
 
 file.patterns.verilog=*.v;*.vh
 filter.verilog=Verilog (verilog)|$(file.patterns.verilog)|
@@ -4474,9 +6033,6 @@
 comment.box.middle.verilog= *
 comment.box.end.verilog= */
 
-fold.comment=1
-fold.preprocessor=1
-fold.at.else=1
 fold.verilog.flags=0
 
 
@@ -4530,6 +6086,71 @@
 braces.verilog.style=10
 
 
+file.patterns.vhdl=*.vhd;*.vhdl
+filter.vhdl=VHDL (vhd vhdl)|$(file.patterns.vhdl)|
+
+lexer.$(file.patterns.vhdl)=vhdl
+
+word.chars.vhdl=$(chars.alpha)$(chars.numeric)_
+word.characters.$(file.patterns.vhdl)=$(word.chars.vhdl)
+
+
+comment.block.vhdl=--
+
+
+
+indent.maintain.$(file.patterns.vhdl)=1;
+
+
+keywords.$(file.patterns.vhdl)=access after alias all architecture array assert attribute begin block \
+body buffer bus case component configuration constant disconnect downto else elsif end entity exit file \
+for function generate generic group guarded if impure in inertial inout is label library linkage literal \
+loop map new next null of on open others out package port postponed procedure process pure range record \
+register reject report return select severity shared signal subtype then to transport type unaffected \
+units until use variable wait when while with
+
+keywords2.$(file.patterns.vhdl)=                                                                            \
+ abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor
+
+keywords3.$(file.patterns.vhdl)=                                                                            \
+ left right low high ascending image value pos val succ pred leftof rightof base range reverse_range        \
+ length delayed stable quiet transaction event active last_event last_active last_value driving             \
+ driving_value simple_name path_name instance_name
+
+keywords4.$(file.patterns.vhdl)=                                                                            \
+ now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector      \
+ to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left \
+ rotate_right resize to_integer to_unsigned to_signed std_match to_01
+
+keywords5.$(file.patterns.vhdl)=                                                                            \
+ std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed               \
+ std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives        \
+ vital_timing
+
+keywords6.$(file.patterns.vhdl)=                                                                            \
+ boolean bit character severity_level integer real time delay_length natural positive string bit_vector     \
+ file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic                \
+ std_logic_vector X01 X01Z UX01 UX01Z unsigned signed
+
+
+style.vhdl.32=$(font.base)
+style.vhdl.0=fore:#800080
+style.vhdl.1=$(colour.code.comment.line),$(font.code.comment.line)
+style.vhdl.2=fore:#3F7F3F,$(font.code.comment.line)
+style.vhdl.3=$(colour.number)
+style.vhdl.4=$(colour.string)
+style.vhdl.6=
+style.vhdl.7=fore:#000000,$(font.string.literal),back:#E0C0E0,eolfilled
+style.vhdl.8=$(colour.keyword)
+style.vhdl.9=fore:#007F7F
+style.vhdl.10=fore:#804020
+style.vhdl.11=fore:#808020
+style.vhdl.12=fore:#208020
+style.vhdl.13=fore:#208080
+style.vhdl.14=fore:#804020,$(font.code.comment.doc)
+braces.vhdl.style=10
+
+
 file.patterns.yaml=*.yaml;*.yml
 filter.yaml=YAML (yaml)|$(file.patterns.yaml)|
 lexer.$(file.patterns.yaml)=yaml
@@ -4537,9 +6158,6 @@
 tabsize.$(file.patterns.yaml)=2
 indent.size.$(file.patterns.yaml)=2
 use.tabs.$(file.patterns.yaml)=0
-indent.automatic.$(file.patterns.yaml)=0
-indent.opening.$(file.patterns.yaml)=0
-indent.closing.$(file.patterns.yaml)=0
 
 comment.block.yaml=#~
 

Modified: trunk/plugins/editor/properties/Makefile.am
==============================================================================
--- trunk/plugins/editor/properties/Makefile.am	(original)
+++ trunk/plugins/editor/properties/Makefile.am	Sat Nov 15 17:50:33 2008
@@ -3,6 +3,8 @@
 properties_datadir = $(anjuta_data_dir)/properties
 
 properties_data_DATA = \
+	abaqus.properties \
+	abbrev.properties \
 	ada.properties \
 	anjuta.properties \
 	asm.properties \
@@ -10,17 +12,26 @@
 	au3.properties \
 	ave.properties \
 	baan.properties \
+	blitzbasic.properties \
 	bullant.properties \
+	caml.properties \
+	cmake.properties \
 	conf.properties \
 	cpp.properties \
+	csound.properties \
 	css.properties \
+	d.properties \
 	eiffel.properties \
 	Embedded.properties \
 	erlang.properties \
 	escript.properties \
+	flagship.properties \
 	forth.properties \
 	fortran.properties \
+	freebasic.properties \
+	gap.properties \
 	html.properties \
+	inno.properties \
 	kix.properties \
 	latex.properties \
 	lisp.properties \
@@ -32,16 +43,23 @@
 	mmixal.properties \
 	nncrontab.properties \
 	nsis.properties \
+	opal.properties \
 	others.properties \
 	pascal.properties \
 	perl.properties \
 	pov.properties \
+	powershell.properties \
 	ps.properties \
+	purebasic.properties \
 	python.properties \
+	rebol.properties \
+	r.properties \
 	ruby.properties \
 	SciTEGlobal.properties \
 	scriptol.properties \
+	smalltalk.properties \
 	specman.properties \
+	spice.properties \
 	sql.properties \
 	styles.properties \
 	tcl.properties \

Modified: trunk/plugins/editor/properties/SciTEGlobal.properties
==============================================================================
--- trunk/plugins/editor/properties/SciTEGlobal.properties	(original)
+++ trunk/plugins/editor/properties/SciTEGlobal.properties	Sat Nov 15 17:50:33 2008
@@ -14,16 +14,20 @@
 	position.top=22
 position.width=576
 position.height=740
+#position.maximize=1
 #position.tile=1
 #full.screen.hides.menu=1
 #minimize.to.tray=1
 split.vertical=1
 #output.horizontal.size=200
 #output.vertical.size=60
+#output.initial.hide=1
 #horizontal.scrollbar=0
 #horizontal.scroll.width=10000
+#horizontal.scroll.width.tracking=0
 #output.horizontal.scrollbar=0
 #output.horizontal.scroll.width=10000
+#output.horizontal.scroll.width.tracking=0
 #output.scroll=0
 #error.select.line=1
 #end.at.last.line=0
@@ -31,10 +35,14 @@
 #tabbar.hide.one=1
 #tabbar.multiline=1
 #toolbar.visible=1
+#toolbar.detachable=1
+#toolbar.usestockicons=1
+#menubar.detachable=1
 #undo.redo.lazy=1
 #statusbar.visible=1
 #fileselector.width=800
 #fileselector.height=600
+#fileselector.show.hidden=1
 #magnification=-1
 #output.magnification=-1
 
@@ -58,11 +66,12 @@
 view.whitespace=0
 view.indentation.whitespace=1
 view.indentation.guides=1
+view.indentation.examine=3
 highlight.indentation.guides=1
 #caret.fore=#FF0000
 #caret.width=2
 #caret.line.back=#FFFED8
-#calltip.back=#FFF0FE
+#caret.line.back.alpha=63
 edge.column=200
 edge.mode=0
 edge.colour=#C0DCC0
@@ -71,17 +80,27 @@
 #selection.fore=#006000
 # DADADA used as background because it yields standard silver C0C0C0
 # on low colour displays and a reasonable light grey on higher bit depths
-selection.back=#DADADA
+if PLAT_WINNT
+	selection.alpha=30
+	selection.back=#000000
+if PLAT_WIN95
+	selection.back=#DADADA
+if PLAT_GTK
+	selection.alpha=30
+	selection.back=#000000
 #whitespace.fore=#FF0000
 #whitespace.back=#FFF0F0
 #error.marker.fore=#0000A0
 #error.marker.back=#DADAFF
 #bookmark.fore=#808000
 #bookmark.back=#FFFFA0
+#bookmark.alpha=
+#find.mark=#0000FF
 
 # Checking
 are.you.sure=1
 #are.you.sure.for.build=1
+#save.all.for.build=1
 #quit.on.close.last=1
 #load.on.activate=1
 #save.on.deactivate=1
@@ -89,18 +108,24 @@
 #reload.preserves.undo=1
 #check.if.already.open=1
 default.file.ext=.cxx
+#source.default.extensions=.h|.cxx|.bat
 #title.full.path=1
 #title.show.buffers=1
 #save.recent=1
 #save.session=1
+#session.bookmarks=1
+#session.folds=1
+#save.position=1
 #open.dialog.in.file.directory=1
 #strip.trailing.spaces=1
 #ensure.final.line.end=1
 #ensure.consistent.line.ends=1
 #save.deletes.first=1
 #buffers=10
+#buffers.zorder.switching=1
 #api.*.cxx=d:\api\w.api
 #win95.death.delay=1000
+#locale.properties=locale.de.properties
 #translation.missing=***
 #read.only=1
 #max.file.size=1
@@ -118,6 +143,7 @@
 
 # Wrapping of long lines
 #wrap=1
+#wrap.style=2
 #cache.layout=3
 #output.wrap=1
 #output.cache.layout=3
@@ -132,9 +158,12 @@
 fold.flags=16
 fold.symbols=1
 #fold.on.open=1
+fold.comment=1
+fold.preprocessor=1
 
 # Find and Replace
-#escapes.in.find.replace=1
+# Internal search always available with recursive capability so use in preference to external tool
+find.command=
 # findstr is available on recent versions of Windows including 2000
 if PLAT_WIN
 	find.command=findstr /n /s $(find.what) $(find.files)
@@ -143,12 +172,15 @@
 	find.command=grep --line-number "$(find.what)" $(find.files)
 find.files=*.c *.cxx *.h
 #find.in.files.close.on.find=0
+#find.in.dot=1
+#find.in.binary=1
 #find.replace.matchcase=1
 #find.replace.escapes=1
 #find.replace.regexp=1
 #find.replace.regexp.posix=1
 #find.replace.wrap=0
 #find.replacewith.focus=0
+#find.replace.advanced=1
 
 # Behaviour
 #eol.mode=LF
@@ -172,6 +204,8 @@
 #visible.policy.slop=1
 #visible.policy.lines=4
 #time.commands=1
+#caret.sticky=1
+#properties.directory.enable=1
 
 # Status Bar
 statusbar.number=4
@@ -182,7 +216,7 @@
 statusbar.text.3=\
 Now is: Date=$(CurrentDate) Time=$(CurrentTime)
 statusbar.text.4=\
-$(FileNameExt) : $(FileDate) — $(FileTime) | $(FileAttr)
+$(FileNameExt) : $(FileDate) - $(FileTime) | $(FileAttr)
 
 if PLAT_WIN
 	command.scite.help="file://$(SciteDefaultHome)\SciTEDoc.html"
@@ -201,6 +235,7 @@
 #character.set=204
 # Required for Unicode to work on GTK+:
 #LC_CTYPE=en_US.UTF-8
+#output.code.page=65001
 
 # Export
 #export.keep.ext=1
@@ -257,12 +292,18 @@
 $(filter.ave)\
 $(filter.baan)\
 $(filter.bash)\
+$(filter.caml)\
+$(filter.cmake)\
 $(filter.cpp)\
+#$(filter.ch)\
 $(filter.css)\
+$(filter.d)\
 $(filter.eiffel)\
 $(filter.erlang)\
 $(filter.fortran)\
+$(filter.gap)\
 $(filter.idl)\
+$(filter.inno)\
 $(filter.java)\
 $(filter.js)\
 $(filter.kix)\
@@ -273,13 +314,17 @@
 $(filter.mmixal)\
 $(filter.nncrontab)\
 $(filter.nsis)\
+$(filter.opal)\
 $(filter.pascal)\
 $(filter.perl)\
 $(filter.php)\
 $(filter.pov)\
+$(filter.powershell)\
+$(filter.prg)\
 $(filter.properties)\
 $(filter.ps)\
 $(filter.python)\
+$(filter.r)\
 $(filter.ruby)\
 $(filter.sql)\
 $(filter.specman)\
@@ -300,6 +345,7 @@
 	font.code.comment.box=$(font.comment)
 	font.code.comment.line=$(font.comment)
 	font.code.comment.doc=$(font.comment)
+	font.code.comment.nested=$(font.comment)
 	font.text=font:Times New Roman,size:11
 	font.text.comment=font:Verdana,size:9
 	font.embedded.base=font:Verdana,size:9
@@ -307,19 +353,33 @@
 	font.monospace=font:Courier New,size:10
 	font.vbs=font:Lucida Sans Unicode,size:10
 if PLAT_GTK
-	font.base=font:lucidatypewriter,size:12
-	font.small=font:lucidatypewriter,size:10
-	font.comment=font:new century schoolbook,size:12
+	font.base=font:!Bitstream Vera Sans,size:9
+	font.small=font:!Bitstream Vera Sans,size:8
+	font.comment=font:!Bitstream Vera Serif,size:9
 	font.code.comment.box=$(font.comment)
 	font.code.comment.line=$(font.comment)
 	font.code.comment.doc=$(font.comment)
-	font.text=font:times,size:14
-	font.text.comment=font:lucidatypewriter,size:10
-	font.embedded.base=font:lucidatypewriter,size:12
-	font.embedded.comment=font:lucidatypewriter,size:12
-	font.monospace=font:courier,size:12
-	font.vbs=font:new century schoolbook,size:12
+	font.code.comment.nested=$(font.comment)
+	font.text=font:!Bitstream Charter,size:10
+	font.text.comment=font:!Serif,size:9
+	font.embedded.base=font:!Serif,size:9
+	font.embedded.comment=font:!Serif,size:9
+	font.monospace=font:!Bitstream Vera Sans Mono,size:9
+	font.vbs=font:!Bitstream Vera Sans Mono,size:9
 font.js=$(font.comment)
+# Old GTK+ font settings are faster but not antialiased
+	#~ font.base=font:lucidatypewriter,size:12
+	#~ font.small=font:lucidatypewriter,size:10
+	#~ font.comment=font:new century schoolbook,size:12
+	#~ font.code.comment.box=$(font.comment)
+	#~ font.code.comment.line=$(font.comment)
+	#~ font.code.comment.doc=$(font.comment)
+	#~ font.text=font:times,size:14
+	#~ font.text.comment=font:lucidatypewriter,size:10
+	#~ font.embedded.base=font:lucidatypewriter,size:12
+	#~ font.embedded.comment=font:lucidatypewriter,size:12
+	#~ font.monospace=font:courier,size:12
+	#~ font.vbs=font:new century schoolbook,size:12
 
 # Give symbolic names to the set of colours used in the standard styles.
 colour.code.comment.box=fore:#007F00
@@ -386,24 +446,32 @@
 # [Ctrl+][Shift+][Fn|a] such as F12 or Ctrl+Shift+D.
 # A '&' may be placed before a letter to be used as an accelerator. This does not work on GTK+.
 menu.language=\
+#FreeBasic|bas||\
 Text|txt|Shift+F11|\
 Ada|ads||\
-Apache Confi&g|conf||\
+#Apache Confi&g|conf||\
 Assembler|asm||\
 #ASN.1|asn1||\
-Avenue|ave||\
-Baan|bc||\
+#Avenue|ave||\
+#Baan|bc||\
 &Batch|bat||\
 #Bullant|ant||\
 &C / C++|c||\
+#CMake|cmake||\
 C&#|cs||\
+#Csound|orc||\
 CSS|css||\
+D|d||\
 &Difference|diff||\
 &Eiffel|e||\
 Erlang|erl||\
 &Errorlist|err||\
+#FlagShip|prg||\
+#Forth|forth||\
 &Fortran|f90||\
+#Gap|g||\
 H&ypertext|html|F12|\
+#&InnoSetup|iss||\
 &Java|java||\
 Java&Script|js||\
 #&Kix|kix||\
@@ -418,15 +486,20 @@
 MMIXAL|mms||\
 #&nnCron crontab|tab||\
 #NSIS|nsis||\
+Objective Caml|ml||\
 Octave|m.octave||\
+Opal|impl||\
 Pascal|pas||\
 Pe&rl|pl||\
 P&HP|php||\
 P&LSQL|spec||\
-&Properties|properties||\
 P&ostScript|ps||\
 P&OV-Ray SDL|pov||\
+PowerShell|ps1||\
+&Properties|properties||\
+P&OV-Ray SDL|pov||\
 Pytho&n|py||\
+R|R||\
 Reso&urce|rc||\
 Ruby|rb||\
 Shell|sh||\
@@ -438,8 +511,7 @@
 #Verilog|v||\
 #VHDL|vhd||\
 &XML|xml|Shift+F12|\
-&YAML|yaml||
-
+YAML|yaml||
 
 # User defined key commands
 user.shortcuts=\
@@ -450,23 +522,38 @@
 #KeypadPlus|IDM_EXPAND|\
 #KeypadMinus|IDM_BLOCK_COMMENT|
 
+#user.context.menu=\
+#||\
+#Next File|IDM_NEXTFILE|\
+#Prev File|IDM_PREVFILE|
+
 # Import all the language specific properties files
+#import abaqus
 import ada
 import asm
 #import asn1
 #import au3
 import ave
 import baan
+#import freebasic
+#import blitzbasic
 #import bullant
+import caml
 import conf
 import cpp
+#import cmake
+import d
+#import csound
 import css
 import eiffel
 import erlang
 import escript
+#import flagship
 #import forth
 import fortran
+#import gap
 import html
+#import inno
 #import kix
 import lisp
 import lot
@@ -477,14 +564,21 @@
 import mmixal
 #import nncrontab
 #import nsis
+#import opal
 import others
 import pascal
 import perl
 import pov
+#import powershell
 import ps
+#import purebasic
 import python
+#import r
+#import rebol
 import ruby
 #import scriptol
+#import smalltalk
+#import spice
 import sql
 #import specman
 import tcl

Added: trunk/plugins/editor/properties/abaqus.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/abaqus.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,77 @@
+# Define SciTE settings for ABAQUS files.
+
+file.patterns.abaqus=*.inp;*.dat;*.msg
+filter.abaqus=ABAQUS input (inp)|$(file.patterns.abaqus)|
+
+#lexer.$(file.patterns.abaqus)=abaqus
+lexer.$(file.patterns.abaqus)=abaqus
+
+# keywords and input/output specifiers
+keywords=*amplitude *assembly \
+*beam *boundary *buckle *bulk \
+*cload *conditions *conductivity *contact \
+*damping *density *dload *dsflux *dsload *dynamic \
+*el *elastic *element *element output *elgen *elset *encastre *end step \
+*expansion *explicit *equation *embedded element \
+*field *freq *frequency *friction \
+*generate \
+*heading *heat transfer *history \
+*imperfectio *import *include *initial *initial conditions *instance *interactio \
+*internal *interval \
+*marks *material *monitor *mpc \
+*ncopy *nfill *ngen *nlgeom *node *node output *node print *nset *number \
+*output \
+*pair *parameter *part *physical constants *plastic *print *preprint \
+*radiate *restart \
+*shell *shell section *solid section *specific heat *sradiate *static *step \
+*surface \
+*temperature *time *type \
+*variable *viscosity 
+
+arguments=elset engineering inc input line material name nset pin tie type write generate field variable history \
+stefan boltzmann absolute zero zero frequency steady state new old set change number shift \
+model position newset oldset host
+
+keywords.$(file.patterns.abaqus)=
+keywords2.$(file.patterns.abaqus)=$(keywords)
+keywords3.$(file.patterns.abaqus)=
+keywords4.$(file.patterns.abaqus)=
+keywords5.$(file.patterns.abaqus)=$(arguments)
+keywords6.$(file.patterns.abaqus)=
+
+comment.block.abaqus=**
+
+# ABAQUS styles
+# Default
+style.abaqus.0=fore:#000000
+# Comment
+style.abaqus.1=fore:#999999,$(font.comment),italics
+# Comment-blocks
+style.abaqus.2=fore:#999999,$(font.comment),italics
+# Number
+style.abaqus.3=$(colour.number)
+# Quoted string
+style.abaqus.4=$(colour.string)
+# Ansys operator
+style.abaqus.5=fore:#990000
+# Ansys word
+style.abaqus.6=fore:#000000
+# Ansys processor
+style.abaqus.7=fore:#008888,bold
+# Ansys command
+style.abaqus.8=fore:#0000CC
+# Ansys slashcommand
+style.abaqus.9=fore:#0000CC,bold
+# Ansys starcommand
+style.abaqus.10=fore:#6600DD,bold
+# Ansys argument
+style.abaqus.11=fore:#0077FF
+# Ansys function
+style.abaqus.12=fore:#0077DD
+
+command.compile.*.inp=
+command.build.*.inp=abaqus job=$(FileName) cpus=4
+command.go.*.inp=
+
+autocomplete.abaqus.ignorecase=1
+calltip.abaqus.ignorecase=1

Added: trunk/plugins/editor/properties/abbrev.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/abbrev.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,9 @@
+# Global abbreviations file for SciTE
+# Place this file in your home directory, that is, the same directory
+# as the user options file.
+# Contains a list of entries of the form abbreviation=expansion
+# Type the abbreviation and press Ctrl+B to insert the expansion
+# The '|' marks the position the caret will be after expansion.
+
+#main=int main(int argc, char *argv[]) {\n|\n}
+#i=if (|) {\n\n}

Modified: trunk/plugins/editor/properties/ada.properties
==============================================================================
--- trunk/plugins/editor/properties/ada.properties	(original)
+++ trunk/plugins/editor/properties/ada.properties	Sat Nov 15 17:50:33 2008
@@ -54,7 +54,6 @@
 braces.ada.style=4
 
 statement.indent.$(file.patterns.ada)=5 begin declare else elsif exception for if is loop while
-statement.end.$(file.patterns.ada)=10 ;
 statement.lookback.$(file.patterns.ada)=20
 block.start.$(file.patterns.ada)=10 then is
 block.end.$(file.patterns.ada)=10 end

Modified: trunk/plugins/editor/properties/asm.properties
==============================================================================
--- trunk/plugins/editor/properties/asm.properties	(original)
+++ trunk/plugins/editor/properties/asm.properties	Sat Nov 15 17:50:33 2008
@@ -207,4 +207,3 @@
 
 
 statement.indent.$(file.patterns.asm)=9 .if
-statement.end.$(file.patterns.asm)=9 .endif

Modified: trunk/plugins/editor/properties/au3.properties
==============================================================================
--- trunk/plugins/editor/properties/au3.properties	(original)
+++ trunk/plugins/editor/properties/au3.properties	Sat Nov 15 17:50:33 2008
@@ -1,8 +1,8 @@
-# SciTE settings for AutoIt v3 
+# SciTE settings for AutoIt v3
 #
 # May, 17  2004 - jos van der Zande  (jvdzande yahoo com)
 # Contains keywords/functions/macros for build 101 & beta 102
-# 
+#
 # *** Specify here your AutoIt program directory  ***
 autoit3dir=C:\program files\autoit3
 
@@ -10,11 +10,11 @@
 filter.au3=AutoIt (au3)|*.au3|
 lexer.$(file.patterns.au3)=au3
 
-# Commands to compile / run your script 
+# Commands to compile / run your script
 command.compile.*.au3=$(autoit3dir)\aut2exe\aut2exe.exe /in "$(FilePath)"
 command.build.*.au3=$(autoit3dir)\aut2exe\aut2exe.exe /in "$(FilePath)"
 command.go.*.au3=$(autoit3dir)\autoit3.exe "$(FilePath)"
-# Tidy is a formatting program for Autoit 3 and can be downloaded from 
+# Tidy is a formatting program for Autoit 3 and can be downloaded from
 #      http://www.hiddensoft.com/fileman/users/jdeb/install_tidy.exe
 command.9.*.au3=tidy\tidy.exe "$(FilePath)"
 command.name.9.*.au3=Tidy AutoIt Source
@@ -47,7 +47,6 @@
 # auto indent stuff
 indent.size.*.au3=3
 statement.indent.*.au3=
-statement.end.*.au3=
 statement.lookback.*.au3=
 block.start.*.au3=5 case if do for func else elseif while select \
                     Case If Do For Func Else ElseIf While Select \
@@ -61,7 +60,7 @@
 comment.stream.start.au3=#CS
 comment.stream.end.au3=#CE
 comment.box.start.au3=#CS
-comment.box.middle.au3=  
+comment.box.middle.au3=
 comment.box.end.au3= #CE
 
 #autoit keywords
@@ -129,40 +128,32 @@
 keywords6.$(file.patterns.au3)= #region #endregion
 
 # White space
-style.au3.0=fore:#000000,$(font.au3)
-
+style.au3.0=fore:#000000
 # Comment line
 style.au3.1=fore:#009933,italics
-
 # Comment block
 style.au3.2=fore:#669900,italics
-
 # Number
 style.au3.3=fore:#AC00A9,bold,italics
-
 # Function
 style.au3.4=fore:#000090,bold,italics
-
-# Keyword 
+# Keyword
 style.au3.5=fore:#0000FF,bold
-
 # Macro
 style.au3.6=fore:#FF33FF,bold
-
 # String
 style.au3.7=fore:#9999CC,bold
-
 # Operator
 style.au3.8=fore:#FF0000,bold
-
 # Variable
 style.au3.9=fore:#AA0000,bold
-
 # Sent keys in string
 style.au3.10=fore:#FF8800,bold
-
 # Pre-Processor
 style.au3.11=fore:#F000FF,italics
-
 # Special
 style.au3.12=fore:#A00FF0,italics
+# Expand abbreviations
+style.au3.13=fore:#FF0000,bold
+# ComObjects
+style.au3.14=fore:#0000FF,bold,italics

Modified: trunk/plugins/editor/properties/ave.properties
==============================================================================
--- trunk/plugins/editor/properties/ave.properties	(original)
+++ trunk/plugins/editor/properties/ave.properties	Sat Nov 15 17:50:33 2008
@@ -21,7 +21,6 @@
 word.characters.$(file.patterns.ave)=$(word.chars.ave)
 
 statement.indent.$(file.patterns.ave)=1 else for if while then
-statement.end.$(file.patterns.ave)=1 end
 statement.lookback.$(file.patterns.ave)=1 end
 
 #Avenue string not support tab symbol, if You use tabs in script all tabs automatic translated to space.
@@ -57,7 +56,7 @@
 style.ave.3=$(colour.keyword),bold
 # String
 style.ave.6=$(colour.string)
-# Enumeration 
+# Enumeration
 style.ave.7=$(colour.preproc),bold
 # End of line where string is not closed
 style.ave.8=back:#E0C0E0,eolfilled

Modified: trunk/plugins/editor/properties/baan.properties
==============================================================================
--- trunk/plugins/editor/properties/baan.properties	(original)
+++ trunk/plugins/editor/properties/baan.properties	Sat Nov 15 17:50:33 2008
@@ -76,5 +76,4 @@
 when.field.changes  while
 
 #Unindent properties
-statement.end.$(file.patterns.baan)=1 endif endwhile endfor endselect return
-statement.lookback.$(file.patterns.baan)=1 endif endwhile endfor endselect return
\ No newline at end of file
+statement.lookback.$(file.patterns.baan)=1 endif endwhile endfor endselect return

Added: trunk/plugins/editor/properties/blitzbasic.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/blitzbasic.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,98 @@
+# Define SciTE settings for BlitzBasic files.
+
+file.patterns.blitzbasic=*.bb
+
+filter.blitzbasic=BlitzBasic (bb)|$(file.patterns.blitzbasic)|
+
+lexer.$(file.patterns.blitzbasic)=blitzbasic
+
+# keywords must be all lowercase
+
+keywordclass.blitzbasic=abs accepttcpstream acos after and apptitle asc asin atan atan2 \
+automidhandle autosuspend availvidmem backbuffer banksize before bin calldll \
+case ceil changedir channelpan channelpitch channelplaying channelvolume chr \
+closedir closefile closemovie closetcpserver closetcpstream closeudpstream cls \
+clscolor color colorblue colorgreen colorred commandline const copybank copyfile \
+copyimage copypixel copypixelfast copyrect copystream cos countgfxdrivers \
+countgfxmodes counthostips createbank createdir createimage createnetplayer \
+createprocess createtcpserver createtimer createudpstream currentdate currentdir \
+currenttime data debuglog default delay delete deletedir deletefile \
+deletenetplayer desktopbuffer dim dottedip drawblock drawblockrect drawimage \
+drawimagerect drawmovie each else else if elseif end end function end if end \
+select end type endgraphics endif eof execfile exit exp false field filepos \
+filesize filetype first flip float floor flushjoy flushkeys flushmouse \
+fontheight fontname fontsize fontstyle fontwidth for forever freebank freefont \
+freeimage freesound freetimer frontbuffer function gammablue gammagreen gammared \
+getcolor getenv getkey getmouse gfxdrivername gfxmodedepth gfxmodeexists \
+gfxmodeformat gfxmodeheight gfxmodewidth global gosub goto grabimage graphics \
+graphicsbuffer graphicsdepth graphicsformat graphicsheight graphicswidth \
+handleimage hex hidepointer hostip hostnetgame if imagebuffer imageheight \
+imagerectcollide imagerectoverlap imagescollide imagesoverlap imagewidth \
+imagexhandle imageyhandle include input insert instr int joinnetgame joydown \
+joyhat joyhit joypitch joyroll joytype joyu joyudir joyv joyvdir joyx joyxdir \
+joyy joyyaw joyydir joyz joyzdir keydown keyhit keywait last left len line \
+loadanimimage loadbuffer loadfont loadimage loadsound local lockbuffer \
+lockedformat lockedpitch lockedpixels log log10 loopsound lower lset maskimage \
+mid midhandle millisecs mod morefiles mousedown mousehit mousex mousexspeed \
+mousey mouseyspeed mousez mousezspeed movemouse movieheight movieplaying \
+moviewidth netmsgdata netmsgfrom netmsgto netmsgtype netplayerlocal \
+netplayername new next nextfile not null openfile openmovie opentcpstream or \
+origin oval pausechannel pausetimer peekbyte peekfloat peekint peekshort pi \
+playcdtrack playmusic playsound plot pokebyte pokefloat pokeint pokeshort print \
+queryobject rand read readavail readbyte readbytes readdir readfile readfloat \
+readint readline readpixel readpixelfast readshort readstring rect rectsoverlap \
+recvnetmsg recvudpmsg repeat replace resettimer resizebank resizeimage restore \
+resumechannel resumetimer return right rnd rndseed rotateimage rset runtimeerror \
+sar savebuffer saveimage scaleimage scanline seedrnd seekfile select sendnetmsg \
+sendudpmsg setbuffer setenv setfont setgamma setgfxdriver sgn shl showpointer \
+shr sin soundpan soundpitch soundvolume sqr startnetgame step stop stopchannel \
+stopnetgame str string stringheight stringwidth systemproperty tan tcpstreamip \
+tcpstreamport tcptimeouts text tformfilter tformimage then tileblock tileimage \
+timerticks to totalvidmem trim true type udpmsgip udpmsgport udpstreamip \
+udpstreamport udptimeouts unlockbuffer until updategamma upper viewport vwait \
+waitkey waitmouse waittimer wend while write writebyte writebytes writefile \
+writefloat writeint writeline writepixel writepixelfast writeshort writestring \
+xor
+
+keywords.$(file.patterns.blitzbasic)=$(keywordclass.blitzbasic)
+
+# BB styles
+# Default
+style.blitzbasic.0=fore:#000000
+# Comment
+style.blitzbasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+# Number
+style.blitzbasic.2=$(colour.number)
+# Keyword1
+style.blitzbasic.3=$(colour.keyword)
+# String
+style.blitzbasic.4=$(colour.string)
+# Preprocessor
+# style.blitzbasic.5=$(colour.error)
+# Operator
+style.blitzbasic.6=$(colour.operator)
+# Identifier
+style.blitzbasic.7=$(style.blitzbasic.0)
+# Date
+# style.blitzbasic.8=$(colour.error)
+# StringEOL
+# style.blitzbasic.9=$(colour.error)
+# Keyword2
+style.blitzbasic.10=$(colour.keyword)
+# Keyword3
+style.blitzbasic.11=$(colour.keyword)
+# Keyword4
+style.blitzbasic.12=$(colour.keyword)
+# Constant
+# style.blitzbasic.13=$(colour.error)
+# Asm
+# style.blitzbasic.14=$(colour.error)
+# Label
+style.blitzbasic.15=$(colour.preproc)
+# Error
+style.blitzbasic.16=$(colour.error)
+# HexNumber
+style.blitzbasic.17=$(colour.number)
+# BinNumber
+style.blitzbasic.18=$(colour.number)
+

Added: trunk/plugins/editor/properties/caml.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/caml.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,102 @@
+# Define SciTE settings for Objective Caml
+
+# OCaml implementation and interface files
+file.patterns.caml=*.ml;*.mli
+
+filter.caml=Objective Caml (ml mli)|$(file.patterns.caml)|
+
+lexer.*.caml=caml
+lexer.$(file.patterns.caml)=caml
+
+# the line below is ONLY used as part of "external" lexer support
+#lexerpath.$(file.patterns.caml)=LexCaml.dll
+
+# the standard Objective Caml 3.09/3.10 language "textual" keywords
+keywordstandard.caml= \
+and as assert asr begin class \
+constraint do done downto else end \
+exception external false for fun function \
+functor if in include inherit initializer \
+land lazy let lor lsl lsr \
+lxor match method mod module mutable \
+new object of open or private \
+rec sig struct then to true \
+try type val virtual when while \
+with
+keywords.$(file.patterns.caml)=$(keywordstandard.caml)
+
+# "optional" Objective Caml / library keywords; some suggested entries are here,
+# more could come from, say, Pervasives ('parser' is from Camlp4)
+keywordoptional1.caml= \
+option Some None ignore ref lnot succ pred parser
+keywords2.$(file.patterns.caml)=$(keywordoptional1.caml)
+
+# "optional" Objective Caml / library keywords; some suggested entries are here,
+# more could come from, say, user-defined types
+keywordoptional2.caml= \
+array bool char float int list string unit
+keywords3.$(file.patterns.caml)=$(keywordoptional2.caml)
+
+word.characters.$(file.patterns.caml)=$(chars.alpha)$(chars.numeric)_'`
+
+comment.stream.start.caml=(*
+comment.stream.end.caml=*)
+comment.box.start.caml=(*
+comment.box.middle.caml= *
+comment.box.end.caml= *)
+
+# "folding" support not currently implemented
+
+# "Out-of-the-box" syntax colors are defined here - I like having
+# my literals (number, char, and string), tag-names, and "optional"
+# keywords stand out - you might not, so adjust accordingly!
+# Default
+style.caml.32=$(font.base)
+# White space
+style.caml.0=fore:#808080
+# Identifiers
+style.caml.1=
+# Tag-names
+#style.caml.2=
+style.caml.2=fore:#000000,back:#ffe0ff
+# Keywords (builtin language-defined keywords)
+style.caml.3=$(colour.keyword),bold
+# Keywords2 (season to taste - use for option, Some, None, etc)
+#style.caml.4=
+style.caml.4=fore:#000000,back:#e0e0ff
+# Keywords3 (season to taste - use for bool, char, float, etc)
+#style.caml.5=
+#style.caml.5=fore:#000000,back:#ffe0e0
+style.caml.5=fore:#a0000,bold
+# Linenum directive
+style.caml.6=back:#C0C0C0,$(font.base)
+# Operators
+style.caml.7=$(colour.operator),bold
+# Number
+#style.caml.8=$(colour.number)
+style.caml.8=fore:#000000,back:#ffff00
+# Single quoted string (character constant)
+#style.caml.9=$(colour.char)
+style.caml.9=fore:#000000,back:#ffff00
+# Double quoted string (string constant)
+#style.caml.11=$(colour.string)
+style.caml.11=fore:#000000,back:#ffff00
+# Comment (NOT nested)
+style.caml.12=$(colour.code.comment.box),$(font.code.comment.box)
+# Comment (SINGLY nested)
+#style.caml.13=$(colour.code.comment.box),$(font.code.comment.box)
+style.caml.13=$(colour.embedded.comment),$(font.code.comment.box)
+# Comment (DOUBLY nested)
+#style.caml.14=$(colour.code.comment.box),$(font.code.comment.box)
+style.caml.14=$(colour.embedded.comment),$(font.code.comment.box)
+# Comment (TRIPLY nested)
+#style.caml.15=$(colour.code.comment.box),$(font.code.comment.box)
+style.caml.15=$(colour.embedded.comment),$(font.code.comment.box)
+
+# Braces are only matched in operator style
+braces.caml.style=7
+
+# The below command(s) can and should be adjusted to reflect your environment;
+# in addition, per-directory overrides are possible, so that project-specific "build"
+# commands may be used for more complex cases - see the SciTE documentation.
+command.compile.$(file.patterns.caml)=ocamlc -c $(FileNameExt)

Added: trunk/plugins/editor/properties/cmake.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/cmake.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,258 @@
+# Define SciTE settings for CMake.
+# contributed by Cristian Adam <cristian dot adam at gmx dot net>
+
+filter.cmake=CMake (CMakeLists.txt, *.cmake, *.ctest)|CMakeLists.txt;*.cmake;*.cmake.in;*.ctest;*.ctest.in|
+file.patterns.cmake=CMakeLists.txt;*.cmake;*.cmake.in;*.ctest;*.ctest.in
+lexer.$(file.patterns.cmake)=cmake
+
+# Commands:
+keywords.$(file.patterns.cmake)= add_custom_command \
+add_custom_target \
+add_definitions \
+add_dependencies \
+add_executable \
+add_library \
+add_subdirectory \
+add_test \
+aux_source_directory \
+build_command \
+build_name \
+cmake_minimum_required \
+configure_file \
+create_test_sourcelist \
+else \
+elseif \
+enable_language \
+enable_testing \
+endforeach \
+endif \
+endmacro \
+endwhile \
+exec_program \
+execute_process \
+export_library_dependencies \
+file \
+find_file \
+find_library \
+find_package \
+find_path \
+find_program \
+fltk_wrap_ui \
+foreach \
+get_cmake_property \
+get_directory_property \
+get_filename_component \
+get_source_file_property \
+get_target_property \
+get_test_property \
+if \
+include \
+include_directories \
+include_external_msproject \
+include_regular_expression \
+install \
+install_files \
+install_programs \
+install_targets \
+link_directories \
+link_libraries \
+list \
+load_cache \
+load_command \
+macro \
+make_directory \
+mark_as_advanced \
+math \
+message \
+option \
+output_required_files \
+project \
+qt_wrap_cpp \
+qt_wrap_ui \
+remove \
+remove_definitions \
+separate_arguments \
+set \
+set_directory_properties \
+set_source_files_properties \
+set_target_properties \
+set_tests_properties \
+site_name \
+source_group \
+string \
+subdir_depends \
+subdirs \
+target_link_libraries \
+try_compile \
+try_run \
+use_mangled_mesa \
+utility_source \
+variable_requires \
+vtk_make_instantiator \
+vtk_wrap_java \
+vtk_wrap_python \
+vtk_wrap_tcl \
+while \
+write_file
+
+# Variables:
+keywords2.$(file.patterns.cmake)= ABSOLUTE \
+ABSTRACT \
+ADDITIONAL_MAKE_CLEAN_FILES \
+ALL \
+AND \
+APPEND \
+ARGS \
+ASCII \
+BEFORE \
+CACHE \
+CACHE_VARIABLES \
+CLEAR \
+COMMAND \
+COMMANDS \
+COMMAND_NAME \
+COMMENT \
+COMPARE \
+COMPILE_FLAGS \
+COPYONLY \
+DEFINED \
+DEFINE_SYMBOL \
+DEPENDS \
+DOC \
+EQUAL \
+ESCAPE_QUOTES \
+EXCLUDE \
+EXCLUDE_FROM_ALL \
+EXISTS \
+EXPORT_MACRO \
+EXT \
+EXTRA_INCLUDE \
+FATAL_ERROR \
+FILE \
+FILES \
+FORCE \
+FUNCTION \
+GENERATED \
+GLOB \
+GLOB_RECURSE \
+GREATER \
+GROUP_SIZE \
+HEADER_FILE_ONLY \
+HEADER_LOCATION \
+IMMEDIATE \
+INCLUDES \
+INCLUDE_DIRECTORIES \
+INCLUDE_INTERNALS \
+INCLUDE_REGULAR_EXPRESSION \
+LESS \
+LINK_DIRECTORIES \
+LINK_FLAGS \
+LOCATION \
+MACOSX_BUNDLE \
+MACROS \
+MAIN_DEPENDENCY \
+MAKE_DIRECTORY \
+MATCH \
+MATCHALL \
+MATCHES \
+MODULE \
+NAME \
+NAME_WE \
+NOT \
+NOTEQUAL \
+NO_SYSTEM_PATH \
+OBJECT_DEPENDS \
+OPTIONAL \
+OR \
+OUTPUT \
+OUTPUT_VARIABLE \
+PATH \
+PATHS \
+POST_BUILD \
+POST_INSTALL_SCRIPT \
+PREFIX \
+PREORDER \
+PRE_BUILD \
+PRE_INSTALL_SCRIPT \
+PRE_LINK \
+PROGRAM \
+PROGRAM_ARGS \
+PROPERTIES \
+QUIET \
+RANGE \
+READ \
+REGEX \
+REGULAR_EXPRESSION \
+REPLACE \
+REQUIRED \
+RETURN_VALUE \
+RUNTIME_DIRECTORY \
+SEND_ERROR \
+SHARED \
+SOURCES \
+STATIC \
+STATUS \
+STREQUAL \
+STRGREATER \
+STRLESS \
+SUFFIX \
+TARGET \
+TOLOWER \
+TOUPPER \
+VAR \
+VARIABLES \
+VERSION \
+WIN32 \
+WRAP_EXCLUDE \
+WRITE \
+APPLE  \
+MINGW \
+MSYS \
+CYGWIN  \
+BORLAND \
+WATCOM \
+MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 \
+OFF ON \
+
+#User defined:
+#keywords3.$(file.patterns.cmake)=MyFunction MySomethingElse
+
+# Block and indenting
+statement.indent.$(file.patterns.cmake)=5 if while foreach macro
+comment.block.cmake=#~
+comment.block.at.line.start.cmake=1
+calltip.cmake.ignorecase=1
+calltip.cmake.parameters.start=(
+calltip.cmake.parameters.separators=,
+calltip.cmake.parameters.end=)
+
+# Whitespace (SCE_CMAKE_DEFAULT)
+style.cmake.0=fore:#000000,$(font.base)
+# Comment (SCE_CMAKE_COMMENT)
+style.cmake.1=fore:#007F00,$(font.comment)
+# String double quote (SCE_CMAKE_STRINGDQ)
+style.cmake.2=fore:#7F007F,back:#EEEEEE
+# String left quote (SCE_CMAKE_STRINGLQ)
+style.cmake.3=fore:#7F007F,back:#EEEEEE
+# String right quote (SCE_CMAKE_STRINGRQ)
+style.cmake.4=fore:#7F007F,back:#EEEEEE
+# Function (SCE_CMAKE_COMMANDS)
+style.cmake.5=fore:#00007F,bold
+# Variable (SCE_CMAKE_ARGUMENTS)
+style.cmake.6=fore:#800000
+# Label (SCE_CMAKE_VARIABLE)
+style.cmake.7=fore:#CC3300
+# User Defined (SCE_CMAKE_USERDEFINED)
+style.cmake.8=fore:#000000
+# Section (SCE_CMAKE_WHILEDEF)
+style.cmake.9=fore:#00007F,bold
+# Sub section (SCE_CMAKE_FOREACHDEF)
+style.cmake.10=fore:#00007F,bold
+# If def (SCE_CMAKE_IFDEFINEDEF)
+style.cmake.11=fore:#00007F,bold
+# Macro def (SCE_CMAKE_MACRODEF)
+style.cmake.12=fore:#00007F,bold
+# Variable within string (SCE_CMAKE_STRINGVAR)
+style.cmake.13=fore:#CC3300,back:#EEEEEE
+# Numbers (SCE_CMAKE_NUMBER)
+style.cmake.14=$(colour.number)
\ No newline at end of file

Modified: trunk/plugins/editor/properties/conf.properties
==============================================================================
--- trunk/plugins/editor/properties/conf.properties	(original)
+++ trunk/plugins/editor/properties/conf.properties	Sat Nov 15 17:50:33 2008
@@ -1,68 +1,130 @@
 # Define SciTE settings for Apache Configuration files.
-# contributed by ahmad Zawawi <zeus_go64 hotmail com>
+# contributed by Ahmad Zawawi <zeus_go64 hotmail com>
 
-filter.conf=Apache Conf (conf)|*.conf|
-file.patterns.conf=*.conf
+file.patterns.conf=*.conf;.htaccess
+filter.conf=Apache Conf (conf)|$(file.patterns.conf)|
 lexer.$(file.patterns.conf)=conf
 # for future implemention...
 #api.$(file.patterns.conf)=conf.api
 
 # Keywords for Apache's Runtime directives
 keywords.$(file.patterns.conf)=\
-accessconfig accessfilename action addalt \
-addaltbyencoding addaltbytype addcharset \
-adddefaultcharset adddescription \
-addencoding addhandler addicon addiconbyencoding \
-addiconbytype addlanguage addmodule addmoduleinfo \
-addtype agentlog alias aliasmatch \
-allow allowconnect allowoverride anonymous \
-anonymous_authoritative anonymous_logemail anonymous_mustgiveemail \
-anonymous_nouserid anonymous_verifyemail authauthoritative \
-authdbauthoritative authdbgroupfile authdbmauthoritative \
-authdbmgroupfile authdbmgroupfile authdbuserfile authdbmuserfile \
-authdigestfile authgroupfile authname authtype \
-authuserfile bindaddress browsermatch browsermatchnocase \
-bs2000account cachedefaultexpire cachedirlength cachedirlevels \
-cacheforcecompletion cachegcinterval cachelastmodifiedfactor cachemaxexpire \
-cachenegotiateddocs cacheroot cachesize checkspelling \
-clearmodulelist contentdigest cookieexpires cookielog \
-cookielog cookietracking coredumpdirectory customlog \
+acceptmutex acceptpathinfo accessconfig accessfilename \
+action addalt addaltbyencoding addaltbytype addcharset \
+adddefaultcharset adddescription addencoding \
+addhandler addicon addiconbyencoding addiconbytype \
+addinputfilter addlanguage addmodule addmoduleinfo \
+addoutputfilter addoutputfilterbytype addtype agentlog \
+alias aliasmatch all allow allowconnect \
+allowencodedslashes allowoverride anonymous \
+anonymous_authoritative anonymous_logemail \
+anonymous_mustgiveemail anonymous_nouserid \
+anonymous_verifyemail assignuserid authauthoritative \
+authdbauthoritative authdbgroupfile \
+authdbmauthoritative authdbmgroupfile authdbmtype \
+authdbmuserfile authdbuserfile authdigestalgorithm \
+authdigestdomain authdigestfile authdigestgroupfile \
+authdigestnccheck authdigestnonceformat \
+authdigestnoncelifetime authdigestqop \
+authdigestshmemsize authgroupfile \
+authldapauthoritative authldapbinddn \
+authldapbindpassword authldapcharsetconfig \
+authldapcomparednonserver authldapdereferencealiases \
+authldapenabled authldapfrontpagehack \
+authldapgroupattribute authldapgroupattributeisdn \
+authldapremoteuserisdn authldapurl authname authtype \
+authuserfile bindaddress browsermatch \
+browsermatchnocase bs2000account bufferedlogs \
+cachedefaultexpire cachedirlength cachedirlevels \
+cachedisable cacheenable cacheexpirycheck cachefile \
+cacheforcecompletion cachegcclean cachegcdaily \
+cachegcinterval cachegcmemusage cachegcunused \
+cacheignorecachecontrol cacheignoreheaders \
+cacheignorenolastmod cachelastmodifiedfactor \
+cachemaxexpire cachemaxfilesize cacheminfilesize \
+cachenegotiateddocs cacheroot cachesize \
+cachetimemargin cgimapextension charsetdefault \
+charsetoptions charsetsourceenc checkspelling \
+childperuserid clearmodulelist contentdigest \
+cookiedomain cookieexpires cookielog cookiename \
+cookiestyle cookietracking coredumpdirectory customlog \
+dav davdepthinfinity davlockdb davmintimeout \
 defaulticon defaultlanguage defaulttype define \
-deny directory directorymatch directoryindex \
-documentroot errordocument errorlog example \
-expiresactive expiresbytype expiresdefault extendedstatus \
-fancyindexing files filesmatch forcetype \
-group header headername hostnamelookups \
-identitycheck ifdefine ifmodule imapbase \
-imapdefault imapmenu include indexignore \
-indexoptions keepalive keepalivetimeout languagepriority \
-limit limitexcept limitrequestbody limitrequestfields \
-limitrequestfieldsize limitrequestline listen listenbacklog \
-loadfile loadmodule location locationmatch \
-lockfile logformat loglevel maxclients \
-maxkeepaliverequests maxrequestsperchild maxspareservers metadir \
-metafiles metasuffix mimemagicfile minspareservers \
-mmapfile namevirtualhost nocache options order \
-passenv pidfile port proxyblock proxydomain \
-proxypass proxypassreverse proxyreceivebuffersize proxyremote \
-proxyrequests proxyvia qsc readmename \
-redirect redirectmatch redirectpermanent redirecttemp \
-refererignore refererlog removehandler require \
-resourceconfig rewritebase rewritecond rewriteengine \
-rewritelock rewritelog rewriteloglevel rewritemap \
-rewriteoptions rewriterule rlimitcpu rlimitmem \
-rlimitnproc satisfy scoreboardfile script \
-scriptalias scriptaliasmatch scriptinterpretersource scriptlog \
-scriptlogbuffer scriptloglength sendbuffersize \
-serveradmin serveralias servername serverpath \
-serverroot serversignature servertokens servertype \
-setenv setenvif setenvifnocase sethandler \
-singlelisten startservers threadsperchild timeout \
-transferlog typesconfig unsetenv usecanonicalname \
-user userdir virtualhost virtualdocumentroot \
-virtualdocumentrootip virtualscriptalias virtualscriptaliasip \
-xbithack from all
-
+deflatebuffersize deflatecompressionlevel \
+deflatefilternote deflatememlevel deflatewindowsize \
+deny directory directoryindex directorymatch \
+directoryslash documentroot dumpioinput dumpiooutput \
+enableexceptionhook enablemmap enablesendfile \
+errordocument errorlog example expiresactive \
+expiresbytype expiresdefault extendedstatus \
+extfilterdefine extfilteroptions fancyindexing \
+fileetag files filesmatch forcelanguagepriority \
+forcetype forensiclog from group header headername \
+hostnamelookups identitycheck ifdefine ifmodule \
+imapbase imapdefault imapmenu include indexignore \
+indexoptions indexorderdefault isapiappendlogtoerrors \
+isapiappendlogtoquery isapicachefile isapifakeasync \
+isapilognotsupported isapireadaheadbuffer keepalive \
+keepalivetimeout languagepriority ldapcacheentries \
+ldapcachettl ldapconnectiontimeout ldapopcacheentries \
+ldapopcachettl ldapsharedcachefile ldapsharedcachesize \
+ldaptrustedca ldaptrustedcatype limit limitexcept \
+limitinternalrecursion limitrequestbody \
+limitrequestfields limitrequestfieldsize \
+limitrequestline limitxmlrequestbody listen \
+listenbacklog loadfile loadmodule location \
+locationmatch lockfile logformat loglevel maxclients \
+maxkeepaliverequests maxmemfree maxrequestsperchild \
+maxrequestsperthread maxspareservers maxsparethreads \
+maxthreads maxthreadsperchild mcachemaxobjectcount \
+mcachemaxobjectsize mcachemaxstreamingbuffer \
+mcacheminobjectsize mcacheremovalalgorithm mcachesize \
+metadir metafiles metasuffix mimemagicfile \
+minspareservers minsparethreads mmapfile \
+modmimeusepathinfo multiviewsmatch namevirtualhost \
+nocache noproxy numservers nwssltrustedcerts \
+nwsslupgradeable options order passenv pidfile port \
+protocolecho proxy proxybadheader proxyblock \
+proxydomain proxyerroroverride proxyiobuffersize \
+proxymatch proxymaxforwards proxypass proxypassreverse \
+proxypreservehost proxyreceivebuffersize proxyremote \
+proxyremotematch proxyrequests proxytimeout proxyvia \
+qsc readmename redirect redirectmatch \
+redirectpermanent redirecttemp refererignore \
+refererlog removecharset removeencoding removehandler \
+removeinputfilter removelanguage removeoutputfilter \
+removetype requestheader require resourceconfig \
+rewritebase rewritecond rewriteengine rewritelock \
+rewritelog rewriteloglevel rewritemap rewriteoptions \
+rewriterule rlimitcpu rlimitmem rlimitnproc satisfy \
+scoreboardfile script scriptalias scriptaliasmatch \
+scriptinterpretersource scriptlog scriptlogbuffer \
+scriptloglength scriptsock securelisten sendbuffersize \
+serveradmin serveralias serverlimit servername \
+serverpath serverroot serversignature servertokens \
+servertype setenv setenvif setenvifnocase sethandler \
+setinputfilter setoutputfilter singlelisten ssiendtag \
+ssierrormsg ssistarttag ssitimeformat ssiundefinedecho \
+sslcacertificatefile sslcacertificatepath \
+sslcarevocationfile sslcarevocationpath \
+sslcertificatechainfile sslcertificatefile \
+sslcertificatekeyfile sslciphersuite sslengine \
+sslmutex ssloptions sslpassphrasedialog sslprotocol \
+sslproxycacertificatefile sslproxycacertificatepath \
+sslproxycarevocationfile sslproxycarevocationpath \
+sslproxyciphersuite sslproxyengine \
+sslproxymachinecertificatefile \
+sslproxymachinecertificatepath sslproxyprotocol \
+sslproxyverify sslproxyverifydepth sslrandomseed \
+sslrequire sslrequiressl sslsessioncache \
+sslsessioncachetimeout sslusername sslverifyclient \
+sslverifydepth startservers startthreads \
+suexecusergroup threadlimit threadsperchild \
+threadstacksize timeout transferlog typesconfig \
+unsetenv usecanonicalname user userdir \
+virtualdocumentroot virtualdocumentrootip virtualhost \
+virtualscriptalias virtualscriptaliasip \
+win32disableacceptex xbithack
 
 #common parameters for Apache runtime configuration
 keywords2.$(file.patterns.conf)=\
@@ -95,7 +157,3 @@
 # compiling/building simply checks for the correct symantics....
 command.compile.$(file.patterns.conf)=httpd -t -f $(FilePath)
 command.build.$(file.patterns.conf)=httpd -t -f $(FilePath)
-
-
-
-

Modified: trunk/plugins/editor/properties/cpp.properties
==============================================================================
--- trunk/plugins/editor/properties/cpp.properties	(original)
+++ trunk/plugins/editor/properties/cpp.properties	Sat Nov 15 17:50:33 2008
@@ -1,24 +1,28 @@
-# Define SciTE settings for C++, C, Java, IDL, JavaScript, Flash (ActionScript 2) files.
+# Define SciTE settings for C++, C, C#, Ch, Java, IDL, JavaScript, Flash (ActionScript 2) files.
 
 # sma files are Small script (C-like)
-file.patterns.cpp=*.c;*.cc;*.cpp;*.cxx;*.c++;*.cs;*.h;*.hh;*.hpp;*.hxx;*.sma
+file.patterns.cpp=*.c;*.cc;*.cpp;*.cxx;*.h;*.hh;*.hpp;*.hxx;*.ipp;*.sma
+file.patterns.cplusplus=*.cc;*.cpp;*.cxx
 # pln, inc and t are SilkTest (4Test) files.
 file.patterns.test=*.pln;*.inc;*.t
 file.patterns.cs=*.cs
 file.patterns.rc=*.rc;*.rc2;*.dlg
 file.patterns.idl=*.idl;*.odl
 file.patterns.flash=*.as;*.asc;*.jsfl
-file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash)
+file.patterns.ch=*.ch;*.chf;*.chs
+file.patterns.c.like=$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash);$(file.patterns.ch)
 
-filter.cpp=C/C++ (c cc cpp cxx cs h hh hxx hpp dlg rc rc2 mak)|\
-$(file.patterns.cpp);$(file.patterns.rc);*.mak;make*|
+shbang.tcc=cpp
+shbang.tinycc=cpp
+
+filter.cpp=C/C++ (c cc cpp cxx cs h hh hxx hpp ipp dlg rc rc2 mak)|\
+$(file.patterns.cpp);$(file.patterns.cs);$(file.patterns.rc);*.mak;make*|
 filter.java=Java (java)|*.java|
 filter.js=JavaScript (js)|*.js|
 filter.idl=IDL (idl odl)|$(file.patterns.idl)|
 filter.test=SilkTest (pln inc t)|$(file.patterns.test)|
 filter.flash=Flash (as asc jsfl)|$(file.patterns.flash)|
-
-file.patterns.braces=$(file.patterns.cpp);$(file.patterns.idl);*.java;$(file.patterns.cs);$(file.patterns.test)
+filter.ch=Ch (ch chf chs)|$(file.patterns.ch)|
 
 lexer.*.java=cpp
 lexer.$(file.patterns.cpp)=cpp
@@ -28,6 +32,7 @@
 lexer.*.js=cpp
 lexer.$(file.patterns.test)=cpp
 lexer.$(file.patterns.flash)=cpp
+lexer.$(file.patterns.ch)=cpp
 
 keywordclass.cpp=and and_eq asm auto bitand bitor bool break \
 case catch char class compl const const_cast continue \
@@ -48,13 +53,16 @@
 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
 if image include ingroup internal invariant interface latexonly li line link \
 mainpage name namespace nosubgrouping note overload \
-p page par param post pre ref relates remarks return retval \
+p page par param param[in] param[out] \
+post pre ref relates remarks return retval \
 sa section see showinitializer since skip skipline struct subsection \
 test throw todo typedef union until \
 var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
 
 word.chars.cxx=$(chars.alpha)$(chars.numeric)_#
 word.characters.$(file.patterns.cpp)=$(word.chars.cxx)
+word.characters.$(file.patterns.cs)=$(word.chars.cxx)
+calltip.cpp.word.characters=$(chars.alpha)$(chars.numeric)_
 comment.block.cpp=//~
 #comment.block.at.line.start.cpp=1
 comment.stream.start.cpp=/*
@@ -62,12 +70,11 @@
 comment.box.start.cpp=/*
 comment.box.middle.cpp= *
 comment.box.end.cpp= */
-fold.comment=1
-fold.preprocessor=1
 #fold.at.else=1
 
-statement.indent.$(file.patterns.c.like)=5 case catch class default do else finally \
-for if private protected public struct try union while
+file.patterns.c.except.cpp=$(file.patterns.cs);$(file.patterns.idl);*.java;$(file.patterns.flash);$(file.patterns.ch)
+statement.indent.$(file.patterns.c.except.cpp)=5 case default do else for if while
+statement.indent.$(file.patterns.cpp)=5 case default do else for if private protected public while
 statement.end.$(file.patterns.c.like)=10 ;
 statement.lookback.$(file.patterns.c.like)=20
 block.start.$(file.patterns.c.like)=10 {
@@ -81,6 +88,33 @@
 preprocessor.middle.$(file.patterns.cpp)=else elif
 preprocessor.end.$(file.patterns.cpp)=endif
 
+preprocessor.symbol.$(file.patterns.cs)=#
+preprocessor.start.$(file.patterns.cs)=if region
+preprocessor.middle.$(file.patterns.cs)=else elif
+preprocessor.end.$(file.patterns.cs)=endif endregion
+
+keywordclass.ch=\
+auto array bool break case char class complex ComplexInf ComplexNaN \
+const continue default delete \
+do double else enum export extern float for foreach goto if Inf inline int \
+long namespace NaN new NULL private public register restrict return short \
+signed sizeof static string_t struct switch this typedef union unsigned \
+using void volatile wchar_t while __declspec
+keywords.$(file.patterns.ch)=$(keywordclass.ch)
+word.chars.ch=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.ch)=$(word.chars.cxx)
+comment.block.ch=//~
+#comment.block.at.line.start.ch=1
+comment.stream.start.ch=/*
+comment.stream.end.ch=*/
+comment.box.start.ch=/*
+comment.box.middle.ch= *
+comment.box.end.ch= */
+preprocessor.symbol.$(file.patterns.ch)=#
+preprocessor.start.$(file.patterns.ch)=if ifdef ifndef
+preprocessor.middle.$(file.patterns.ch)=else elif
+preprocessor.end.$(file.patterns.ch)=endif
+
 keywordclass.cs=abstract as base bool break byte case catch char checked class \
 const continue decimal default delegate do double else enum \
 event explicit extern false finally fixed float for foreach goto if \
@@ -185,11 +219,11 @@
 style.cpp.32=$(font.base)
 # White space
 style.cpp.0=fore:#808080
-# Comment
+# Comment: /* */.
 style.cpp.1=$(colour.code.comment.box),$(font.code.comment.box)
-# Line Comment
+# Line Comment: //.
 style.cpp.2=$(colour.code.comment.line),$(font.code.comment.line)
-# Doc comment
+# Doc comment: block comments beginning with /** or /*!
 style.cpp.3=$(colour.code.comment.doc),$(font.code.comment.doc)
 # Number
 style.cpp.4=$(colour.number)
@@ -213,7 +247,7 @@
 style.cpp.13=fore:#007F00,$(font.monospace),back:#E0FFE0,eolfilled
 # Regular expressions for JavaScript
 style.cpp.14=fore:#3F7F3F,$(font.monospace),back:#E0F0FF,eolfilled
-# Doc Comment Line
+# Doc Comment Line: line comments beginning with /// or //!.
 style.cpp.15=$(colour.code.comment.doc),$(font.code.comment.doc)
 # Keywords2
 style.cpp.16=fore:#B00040
@@ -224,39 +258,31 @@
 # Braces are only matched in operator style
 braces.cpp.style=10
 
-cc=g++ -pedantic -Os -fno-exceptions -c $(FileNameExt) -o $(FileName).o
+ccopts=-pedantic -Os
+cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
+ccc=gcc $(ccopts) -c $(FileNameExt) -o $(FileName).o
 
 make.command=make
-command.compile.*.c=$(cc)
+command.compile.*.c=$(ccc) -std=c99
 command.build.*.c=$(make.command)
-command.go.*.c=$(FileName)
+command.go.*.c=./$(FileName)
 # To make the Go command both compile (if needed) and execute, use this setting:
-#command.go.needs.*.c=g++ $(FileNameExt) -o $(FileName)
+#command.go.needs.*.c=gcc $(ccopts) -std=c99 $(FileNameExt) -o $(FileName)
 
-command.compile.*.cc=$(cc)
-command.build.*.cc=$(make.command)
-command.go.*.cc=$(FileName)
-
-command.compile.*.cpp=$(cc)
-command.build.*.cpp=$(make.command)
-command.go.*.cpp=$(FileName)
-
-command.compile.*.cxx=$(cc)
-command.build.*.cxx=$(make.command)
-command.go.*.cxx=$(FileName)
+command.compile.$(file.patterns.cplusplus)=$(cc)
+command.build.$(file.patterns.cplusplus)=$(make.command)
+command.go.$(file.patterns.cplusplus)=./$(FileName)
+command.go.needs.$(file.patterns.cplusplus)=g++ $(ccopts) $(FileNameExt) -o $(FileName)
 
 command.build.*.h=$(make.command)
 
-command.name.0.*.cxx=Indent
-command.0.*.cxx=astyle -tapO $(FileNameExt)
-command.is.filter.0.*.cxx=1
-
-command.name.1.*.cxx=Lint
-command.1.*.cxx=g++ -W -Wall -Wshadow -Wwrite-strings -Wold-style-cast \
-	-Woverloaded-virtual  -pedantic -Os -fno-exceptions -c $(FileNameExt)
-
-command.name.2.*.cxx=Execute Selection
-command.2.*.cxx=$(CurrentSelection)
+command.name.0.$(file.patterns.cpp)=Indent
+command.0.$(file.patterns.cpp)=astyle -tapOK -M8 $(FileNameExt)
+command.is.filter.0.$(file.patterns.cpp)=1
+
+command.name.1.$(file.patterns.cplusplus)=Lint
+command.1.$(file.patterns.cplusplus)=g++ -W -Wall -Wshadow -Wwrite-strings -Wold-style-cast \
+	-Woverloaded-virtual -pedantic -Os -fno-exceptions -c $(FileNameExt)
 
 if PLAT_WIN
 	command.compile.*.rc=windres $(FileNameExt) $(FileName).o
@@ -276,7 +302,7 @@
 	command.go.*.cs=$(FileName)
 	command.go.subsystem.*.cs=1
 if PLAT_GTK
-	command.build.*.cs=mcs /t:winexe $(FileNameExt) /r:System,System.Drawing                                                                                
+	command.build.*.cs=mcs /t:winexe $(FileNameExt) /r:System,System.Drawing
 	command.go.*.cs=mono $(FileName).exe
 	command.go.subsystem.*.cs=1
 
@@ -284,3 +310,9 @@
 command.build.*.java=javac *.java
 command.go.*.java=java $(FileName)
 
+command.compile.*.ch=ch -n $(FileNameExt)
+command.build.*.ch=ch -n  $(FileNameExt)
+command.go.*.ch=ch -u $(FileNameExt)
+
+command.compile.*.as=mtasc -strict $(FileNameExt)
+command.build.*.as=mtasc -strict *.as

Added: trunk/plugins/editor/properties/csound.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/csound.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,154 @@
+# SciTE settings for Csound files (orchestra and score)
+# Author:  Georg Ritter <ritterfuture A T gmail D O T com>
+# Created: Mai 2005
+
+# Csound files
+file.patterns.csound=*.orc;*.sco;*.csd
+filter.csound=Csound (orc sco csd)|$(file.patterns.csound)|
+
+lexer.$(file.patterns.csound)=csound
+
+# Csound opcodes
+
+# This list was extracted from Csound_opcodes.vim which can be found here:
+# http://csounds.com/istvan/archive/misc/Csound_vim_syntax-4.24.1.tar.gz
+
+csound_opcodes=\
+	a i db in or zr Add Dec Div Inc Mul Sub abs and cos dam dec div exp \
+	fin fof fog inh ino inq ins int inx inz lfo log mac mod mul not out \
+	pan pow rms rnd shl sin sqr sub sum tab tan tb0 tb1 tb2 tb3 tb4 tb5 \
+	tb6 tb7 tb8 tb9 urd vco xin xor zar zaw zir ziw zkr zkw adsr babo \
+	buzz cent clip comb cosh diff divz fini fink fmb3 fof2 fold fout \
+	frac ftsr gain goto in32 inch init line maca moog mute nrpn outc \
+	outh outo outq outs outx outz peak port pset pvoc rand seed sinh \
+	sqrt stix tabw tanh tb10 tb11 tb12 tb13 tb14 tb15 tone vadd vco2 \
+	vdiv vexp vibr vmap vmul vpow wrap xout xyin zacl zarg zawm ziwm \
+	zkcl zkwm FLbox FLjoy FLrun adsyn ampdb atone birnd bqrez butbp \
+	butbr buthp butlp clear ctrl7 dbamp dconv delay dumpk endin endop \
+	event expon fouti foutk ftgen ftlen gauss gbuzz grain guiro igoto \
+	ihold instr integ kgoto limit linen log10 loopg loopl lpf18 madsr \
+	max_k metro noise nsamp oscil out32 outch outic outkc outq1 outq2 \
+	outq3 outq4 outs1 outs2 pareq pitch pluck portk print pvadd randh \
+	randi rbjeq readk reson rezzy rnd31 scans scanu sense space tab_i \
+	table tbvcf tempo timek times tival tonek tonex vaddv vbap4 vbap8 \
+	vbapz vcomb vcopy vdecr vdivv veloc vexpv vibes vincr vmult voice \
+	vport vpowv vpvoc vsubv vwrap wgbow xadsr zamod zkmod FLhide FLkeyb \
+	FLknob FLpack FLshow FLtabs FLtext active adsynt alpass areson \
+	atonek atonex bamboo bbcutm bbcuts biquad cabasa cauchy cggoto \
+	cigoto ckgoto clfilt cngoto convle cosinv cpsoct cpspch cpstun \
+	cpuprc cross2 crunch ctrl14 ctrl21 delay1 delayk delayr delayw \
+	deltap denorm diskin dumpk2 dumpk3 dumpk4 envlpx expseg filesr \
+	fiopen fmbell follow foscil foutir ftlen2 ftload ftmorf ftsave \
+	grain2 grain3 harmon hrtfer initc7 interp jitter linenr lineto \
+	linseg locsig loopge loople lorenz loscil lowres lpread lpslot \
+	mandel mandol mclock mdelay midic7 midiin midion mirror moscil \
+	mpulse mrtmsg mxadsr nlfilt noteon notnum ntrpol octave octcps \
+	octpch opcode oscbnk oscil1 oscil3 oscili osciln oscils oscilx \
+	outiat outipb outipc outkat outkpb outkpc pchoct phasor planet \
+	poscil printk prints pvread pvsftr pvsftw random readk2 readk3 \
+	readk4 reinit resonk resonr resonx resony resonz reverb rigoto \
+	s16b14 s32b14 sekere sfload sfplay shaker sininv spat3d spdist \
+	spsend strset table3 tablei tablew tabw_i taninv tigoto timout \
+	turnon upsamp vbap16 vcella vco2ft vdel_k vdelay vlimit vmultv \
+	vrandh vrandi wgclar xscans xscanu FLcolor FLcount FLgroup FLlabel \
+	FLpanel FLvalue aftouch ampdbfs ampmidi aresonk balance bexprnd \
+	biquada changed clockon cps2pch cpsmidi cpstmid cpstuni cpsxpch \
+	dbfsamp dcblock deltap3 deltapi deltapn deltapx dispfft display \
+	envlpxr exprand expsega expsegr filelen filter2 flanger fmmetal \
+	fmrhode fmvoice follow2 foscili fprints ftchnls ftloadk ftlptim \
+	ftsavek gogobel granule hilbert initc14 initc21 invalue jitter2 \
+	jspline linrand linsegr locsend logbtwo loopseg loscil3 lowresx \
+	lphasor lposcil lpreson lpshold marimba massign midic14 midic21 \
+	midichn midion2 midiout moogvcf noteoff nreverb nstrnum octmidi \
+	oscil1i outic14 outipat outkc14 outkpat pcauchy pchbend pchmidi \
+	phaser1 phaser2 pinkish poisson polyaft poscil3 printk2 printks \
+	product pvcross pvsanal pvsinfo pvsynth randomh randomi release \
+	repluck reverb2 rspline rtclock seqtime sfilist sfinstr sfplay3 \
+	sfplaym sfplist slider8 sndwarp soundin spat3di spat3dt specsum \
+	streson tableiw tablekt tableng tablera tablewa taninv2 tempest \
+	tlineto transeg trigger trigseq trirand turnoff unirand valpass \
+	vco2ift vdelay3 vdelayk vdelayx vexpseg vibrato vlinseg vlowres \
+	vmirror waveset weibull wgbrass wgflute wgpluck wguide1 wguide2 \
+	xtratim zakinit FLbutton FLcolor2 FLprintk FLroller FLscroll \
+	FLsetBox FLsetVal FLslider FLupdate betarand butterbp butterbr \
+	butterhp butterlp chanctrl clockoff convolve cpsmidib ctrlinit \
+	cuserrnd deltapxw distort1 downsamp duserrnd filepeak fmpercfl \
+	fmwurlie fprintks hsboscil lowpass2 lpfreson lpinterp lposcil3 \
+	maxalloc midictrl multitap nestedap octmidib oscilikt outvalue \
+	pchmidib powoftwo prealloc pvinterp pvsadsyn pvscross pvsfread \
+	pvsmaska rireturn samphold schedule semitone sensekey setksmps \
+	sfinstr3 sfinstrm sfplay3m sfpreset slider16 slider32 slider64 \
+	slider8f soundout specaddm specdiff specdisp specfilt spechist \
+	specptrk specscal spectrum sprintks subinstr svfilter tablegpw \
+	tableikt tablemix tableseg tablewkt tablexkt tb0_init tb1_init \
+	tb2_init tb3_init tb4_init tb5_init tb6_init tb7_init tb8_init \
+	tb9_init tempoval vco2init vdelayxq vdelayxs vdelayxw vecdelay \
+	wgpluck2 wterrain xscanmap zfilter2 FLbutBank FLgetsnap FLpackEnd \
+	FLprintk2 FLsetFont FLsetSize FLsetText FLsetsnap FLslidBnk \
+	FLtabsEnd dripwater eventname ktableseg noteondur osciliktp \
+	oscilikts pgmassign phasorbnk pitchamdf pvbufread readclock \
+	sandpaper scantable schedwhen sfinstr3m sfpassign slider16f \
+	slider32f slider64f sndwarpst soundoutc soundouts tablecopy \
+	tableigpw tableimix tablexseg tb10_init tb11_init tb12_init \
+	tb13_init tb14_init tb15_init timeinstk timeinsts vbap4move \
+	vbap8move vbapzmove vdelayxwq vdelayxws xscansmap FLgroupEnd \
+	FLloadsnap FLpack_end FLpanelEnd FLsavesnap FLsetAlign FLsetColor \
+	FLsetVal_i FLtabs_end filenchnls noteondur2 scanhammer schedkwhen \
+	tableicopy tambourine vbap16move vbaplsinit wgbowedbar FLgroup_end \
+	FLpanel_end FLscrollEnd FLsetColor2 mididefault midinoteoff \
+	sleighbells FLscroll_end subinstrinit FLsetPosition FLsetTextSize \
+	FLsetTextType midinoteoncps midinoteonkey midinoteonoct \
+	midinoteonpch midipitchbend schedwhenname FLsetTextColor \
+	schedkwhenname midicontrolchange midiprogramchange \
+	midipolyaftertouch midichannelaftertouch
+
+# Header statements
+csound_header_stmts=sr kr ar ksmps nchnls
+
+# Other keywords
+csound_other_keywords=
+
+keywords.$(file.patterns.csound)=$(csound_opcodes)
+keywords2.$(file.patterns.csound)=$(csound_header_stmts)
+keywords3.$(file.patterns.csound)=$(csound_other_keywords)
+
+comment.block.csound=;
+
+# Styles ...
+
+# Default
+style.csound.0=$(font.monospace)
+# Comment
+style.csound.1=$(font.monospace),fore:#669999
+# Number
+style.csound.2=$(font.monospace),fore:#339933
+# Operator
+style.csound.3=$(font.monospace)
+# Instr
+style.csound.4=$(font.monospace)
+# Identifier (not a real style)
+style.csound.5=
+# Opcode
+style.csound.6=$(font.monospace),fore:#0000FF,bold
+# Header statement
+style.csound.7=$(font.monospace),fore:#CC2200
+# User keywords
+style.csound.8=$(font.monospace)
+# comment block
+style.csound.9=$(font.monospace)
+# Parameter
+style.csound.10=$(font.monospace),fore:#660099,bold
+# A-Rate variable
+style.csound.11=$(font.monospace),fore:#660099
+# K-Rate variable
+style.csound.12=$(font.monospace),fore:#660099
+# I-Rate variable
+style.csound.13=$(font.monospace),fore:#660099
+# Global variable
+style.csound.14=$(font.monospace),fore:#660099
+# F-statement
+style.csound.15=$(font.monospace)
+# I-statement
+style.csound.16=$(font.monospace)
+# End of line where string is not closed
+style.csound.17=$(font.monospace),fore:#000000,back:#E0C0E0,eolfilled

Modified: trunk/plugins/editor/properties/css.properties
==============================================================================
--- trunk/plugins/editor/properties/css.properties	(original)
+++ trunk/plugins/editor/properties/css.properties	Sat Nov 15 17:50:33 2008
@@ -140,6 +140,8 @@
 style.css.14=$(colour.string)
 # CSS2 Property
 style.css.15=fore:#00A0E0
+# Attribute selection ([att='val'])
+style.css.16=fore:#800000
 
 block.start.*.css=5 {
 block.end.*.css=5 }

Added: trunk/plugins/editor/properties/d.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/d.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,107 @@
+# Define SciTE settings for D
+
+file.patterns.d=*.d
+filter.d=D (d)|$(file.patterns.d)|
+lexer.$(file.patterns.d)=d
+
+word.chars.d=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.d)=$(word.chars.d)
+#~ word.characters.$(file.patterns.cs)=$(word.chars.d)
+calltip.d.word.characters=$(chars.alpha)$(chars.numeric)_
+
+
+#comment.block.at.line.start.d=1
+comment.block.d=//~
+comment.stream.start.d=/+
+comment.stream.end.d=+/
+comment.box.start.d=/*
+comment.box.middle.d= *
+comment.box.end.d= */
+#lexer.d.fold.at.else=1
+
+statement.indent.$(file.patterns.d)=6 case catch class debug default do else \
+finally for foreach foreach_reverse if private protected public scope struct \
+try union while with
+statement.end.$(file.patterns.d)=13 ;
+statement.lookback.$(file.patterns.d)=20
+block.start.$(file.patterns.d)=13 {
+block.end.$(file.patterns.d)=13 }
+
+# D keywords
+keywords.$(file.patterns.d)=abstract alias align asm assert auto \
+ body bool break byte \
+ case cast catch cdouble cent cfloat char class const continue creal \
+ dchar debug default delegate delete deprecated do double \
+ else enum export extern \
+ false final finally float for foreach foreach_reverse function \
+ goto \
+ idouble if ifloat import in inout int interface invariant ireal is \
+ lazy long \
+ mixin module \
+ new null \
+ out override \
+ package pragma private protected public \
+ real return \
+ scope short static struct super switch synchronized \
+ template this throw true try typedef typeid typeof \
+ ubyte ucent uint ulong union unittest ushort \
+ version void volatile \
+ wchar while with
+
+# keywords2 are intended for embedded ASM
+
+# keywords3 are intended for doxygen
+keywords3.$(file.patterns.d)=a addindex addtogroup anchor arg attention \
+author b brief bug c class code date def defgroup deprecated dontinclude \
+e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
+f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
+if image include ingroup internal invariant interface latexonly li line link \
+mainpage name namespace nosubgrouping note overload \
+p page par param post pre ref relates remarks return retval \
+sa section see showinitializer since skip skipline struct subsection \
+test throw todo typedef union until \
+var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
+
+# keywords4 are intended for syntax driven or custom highlighting
+
+
+# Styles
+
+# 0 - whitespace
+# 1, 2, 3, 4 - comments:  /* */,  //,  /** */ or /*! */,  /+ +/
+# 5 - number
+# 6, 7, 8, 9 - keywords: standard, secondary, doc keywords, typedefs and aliases
+# 10 - string
+# 11 - string not closed
+# 12 - char
+# 13 - operator
+# 14 - identifier
+# 15, 16, 17 - Doc comments: line doc /// or //!, doc keyword, doc keyword err
+
+style.d.32=$(font.base)
+style.d.0=fore:#808080
+style.d.1=$(colour.code.comment.box),$(font.code.comment.box)
+style.d.2=$(colour.code.comment.line),$(font.code.comment.line)
+style.d.3=$(colour.code.comment.doc),$(font.code.comment.doc)
+style.d.4=$(colour.code.comment.nested),$(font.code.comment.nested)
+style.d.5=$(colour.number)
+style.d.6=$(colour.keyword),bold
+style.d.7=$(colour.keyword),bold
+style.d.8=$(colour.keyword),bold
+style.d.9=$(colour.keyword),bold
+style.d.10=$(colour.string)
+style.d.11=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.d.12=$(colour.char)
+style.d.13=$(colour.operator),bold
+style.d.14=
+style.d.15=$(colour.code.comment.doc),$(font.code.comment.doc)
+style.d.16=fore:#3060A0,$(font.code.comment.doc)
+style.d.17=fore:#804020,$(font.code.comment.doc)
+# breaces must be operator style to allow matching
+braces.d.style=13
+
+
+command.compile.*.d=dmd -O $(FileNameExt)
+command.build.*.d=$(make.command)
+command.go.*.d=$(FileName)
+

Added: trunk/plugins/editor/properties/flagship.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/flagship.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,176 @@
+# Define SciTE settings for FlagShip files.
+# (Syntactically compatible to other XBase dialects, like dBase, Clipper, Fox etc.)
+# Version .02 by Randy Butler
+
+# FlagShip Source code file
+file.patterns.flagship=*.prg
+
+lexer.$(file.patterns.flagship)=flagship
+
+# FlagShip 6 Commands
+keywordclass.fs6commands=\
+? @ accept access all alternate announce ansi any append as assign autolock average \
+begin bell bitmap blank box \
+call cancel case century charset checkbox clear close cls color combobox commit \
+confirm console constant continue copy count create cursor \
+date dbread dbwrite decimals declare default delete deleted delimiters device dir \
+directory display do draw \
+edit else elseif eject end endcase enddo endif endtext epoch erase error escape eval eventmask \
+exact exclusive extended external extra \
+field file filter find fixed font for form format from \
+get gets global global_extern go goto gotop guialign guicolor guicursor guitransl \
+html htmltext \
+if image index input intensity \
+join \
+key keyboard keytransl \
+label lines list listbox local locate \
+margin memory memvar menu message method multibyte multilocks \
+next nfs nfslock nfs_force note \
+on openerror order outmode \
+pack parameters path pixel pop printer private prompt public push pushbutton \
+quit \
+radiobutton radiogroup read recall refresh reindex relation release rename replace report request restore \
+richtext rowadapt rowalign run \
+save say scoreboard scrcompress screen seek select sequence set setenhanced setstandard setunselected \
+skip softseek sort source static store struct structure sum \
+tag tbrowse text to total type typeahead \
+unique unlock update use \
+wait while with wrap \
+xml zap zerobyteout
+
+# FlagShip 6 Std Library Functions
+keywordclass.fs6libfunc=\
+_displarr _displarrerr _displarrstd _displobj _displobjerr _displobjstd \
+aadd abs achoice aclone acopy adel adir aelemtype aeval afields afill ains alert alias alltrim altd ansi2oem \
+appiomode appmdimode appobject array asc ascan asize asort at atail atanychar autoxlock \
+between bin2i bin2l bin2w binand binlshift binor binrshift binxor bof break browse \
+cdow chr chr2screen cmonth col col2pixel color2rgb colorselect colvisible consoleopen consolesize crc32 ctod curdir \
+date datevalid day dbappend dbclearfilter dbclearindex dbclearrelation dbcloseall dbclosearea dbcommit dbcommitall \
+dbcreate dbcreateindex dbdelete dbedit dbeval dbf dbfilter dbfinfo dbflock dbfused dbgetlocate dbgobottom dbgoto \
+dbgotop dbobject dbrecall dbreindex dbrelation dbrlock dbrlocklist dbrselect dbrunlock dbseek dbselectarea \
+dbsetdriver dbsetfilter dbsetindex dbsetlocate dbsetorder dbsetrelation dbskip dbstruct dbunlock dbunlockall \
+dbusearea default deleted descend devout devoutpict devpos directory diskspace dispbegin dispbox dispcount \
+dispend dispout doserror doserror2str dow drawline dtoc dtos \
+empty eof errorblock errorlevel eval execname execpidnum exp \
+fattrib fclose fcount fcreate ferase ferror ferror2str fieldblock fielddeci fieldget fieldgetarr fieldlen fieldname \
+fieldpos fieldput fieldputarr fieldtype fieldwblock file findexefile fklabel fkmax flagship_dir flock flockf fopen \
+found fread freadstdin freadstr freadtxt frename fs_set fseek fwrite \
+getactive getalign getapplykey getdosetkey getenv getenvarr getfunction getpostvalid getprevalid getreader guidrawline \
+hardcr header hex2num \
+i2bin iif indexcheck indexcount indexdbf indexext indexkey indexnames indexord infobox inkey inkey2read inkey2str inkeytrap \
+instdchar instdstring int int2num isalpha isbegseq iscolor isdbexcl isdbflock isdbmultip isdbmultiple isdbmultipleopen \
+isdbrlock isdigit isfunction isguimode islower isobjclass isobjequiv isobjproperty isprinter isupper \
+l2bin lastkey lastrec left len listbox lock log lower ltrim lupdate \
+macroeval macrosubst max max_col max_row maxcol maxrow mcol mdblck mdiclose mdiopen mdiselect memocode memodecode \
+memoedit memoencode memoline memoread memory memotran memowrit memvarblock mhide min minmax mlcount mlctopos mleftdown \
+mlpos mod month mpostolc mpresent mreststate mrightdown mrow msavestate msetcursor msetpos mshow mstate \
+neterr netname nextkey num2hex num2int \
+objclone oem2ansi onkey ordbagext ordbagname ordcond ordcondset ordcreate orddescend orddestroy ordfor ordisinique \
+ordkey ordkeyadd ordkeycount ordkeydel ordkeygoto ordkeyno ordkeyval ordlistadd ordlistclear ordlistrebui ordname \
+ordnumber ordscope ordsetfocu ordsetrelat ordskipunique os outerr outstd \
+padc padl padr param parameters pcalls pcol pcount pixel2col pixel2row printstatus procfile procline procname procstack proper prow \
+qout qout2 qqout qqout2 \
+rat rddlist rddname rddsetdefault readexit readinsert readkey readkill readmodal readsave readupdated readvar reccount recno recsize \
+replicate restscreen right rlock rlockverify round row row2pixel rowadapt rowvisible rtrim \
+savescreen scrdos2unix screen2chr scroll scrunix2dos seconds secondscpu select serial set setansi setblink setcancel setcol2get \
+setcolor setcolorba setcursor setevent setguicursor setkey setmode setpos setprc setvarempty sleep sleepms soundex space \
+sqrt statbarmsg statusmessage stod str strlen strlen2col strlen2pix strlen2space strpeek strpoke strtran strzero stuff substr \
+tbcolumnnew tbmouse tbrowsearr tbrowsedb tbrowsenew tempfilename time tone transform trim truepath type \
+updated upper used usersactive usersdbf usersmax \
+val valtype version \
+webdate weberrorhandler webgetenvir webgetformdata webhtmlbegin webhtmlend weblogerr webmaildomain weboutdata websendmail word \
+year
+
+# FlagShip 6 function and procedure
+keywordclass.fs6funcproc=\
+function procedure return exit
+
+# FlagShip 6 Class (OOP)
+keywordclass.fs6class=\
+class instance export hidden protect prototype
+
+keywords.$(file.patterns.flagship)=$(keywordclass.fs6commands)
+keywords2.$(file.patterns.flagship)=$(keywordclass.fs6libfunc)
+keywords3.$(file.patterns.flagship)=$(keywordclass.fs6funcproc)
+keywords4.$(file.patterns.flagship)=$(keywordclass.fs6class)
+
+#FlagShip Comments
+#comment.block.flagship='/
+comment.block.flagship=//~
+comment.stream.start.flagship=/*
+comment.stream.end.flagship=*/
+comment.box.start.flagship=/*
+comment.box.middle.flagship= *
+comment.box.end.flagship= */
+
+
+# FlagShip styles
+
+# Default
+style.flagship.32=$(font.base)
+# White space
+style.flagship.0=
+# Comment
+style.flagship.1=$(colour.code.comment.line),$(font.code.comment.line)
+# Comment Line
+style.flagship.2=$(colour.code.comment.line),$(font.code.comment.line)
+# Comment Doc
+style.flagship.3=$(colour.code.comment.doc),$(font.code.comment.doc)
+# Comment Line Doc
+style.flagship.4=
+# Comment keyword
+style.flagship.5=fore:#3060A0,$(font.code.comment.doc)
+# Comment keyword error
+style.flagship.6=fore:#804020,$(font.code.comment.doc)
+
+# Keyword - Commands
+style.flagship.7=$(colour.keyword)
+# keywords 2 - Std Library Functions
+style.flagship.8=$(colour.keyword)
+# keywords 3 - function, procedure, return, exit
+style.flagship.9=$(colour.keyword),bold
+# keywords 4 - Class (oop)
+style.flagship.10=$(colour.keyword),bold
+#style.flagship.10=$(colour.keyword),$(font.monospace),bold
+
+# Number
+style.flagship.11=$(colour.number)
+# String
+style.flagship.12=$(colour.string)
+# Preprocessor (directives)
+style.flagship.13=$(colour.preproc)
+# Operator
+style.flagship.14=$(colour.operator)
+# Identifier
+style.flagship.15=
+# Date
+style.flagship.16=$(colour.number)
+# STRINGEOL - End of line where string is not closed
+style.flagship.17=$(style.stringeol)
+
+
+#FlagShip Compiler Option
+fsOptObj=-c -q -w1 -w2 -w3
+fsOptExe=-q -w1 -w2 -w3
+
+#Command for obj file
+fsObj=FlagShip $(fsOptObj) $(FileNameExt) -o $(FileName).o
+
+#Command for exe file
+fsExe=FlagShip $(fsOptExe) $(FileNameExt) -o $(FileName)
+
+# Use flagship without make file
+command.compile.*.prg=$(fsObj)
+command.build.*.prg=$(fsExe)
+command.go.*.prg=$(FileName)
+
+# Use flagship with a make file
+#make.command=make
+#command.compile.*.prg=$(make.command)
+#command.build.*.prg=$(make.command)
+#command.go.*.prg=$(FileName)
+#command.build.*.ch=$(make.command)
+#command.build.*.fh=$(make.command)
+
+# help from fsman
+command.help.$(file.patterns.flagship)=fsman

Modified: trunk/plugins/editor/properties/forth.properties
==============================================================================
--- trunk/plugins/editor/properties/forth.properties	(original)
+++ trunk/plugins/editor/properties/forth.properties	Sat Nov 15 17:50:33 2008
@@ -21,8 +21,6 @@
 comment.box.start.forth=\
 comment.box.middle.forth=\
 comment.box.end.forth=\
-fold.comment=1
-fold.preprocessor=1
 
 # Forth styles
 

Modified: trunk/plugins/editor/properties/fortran.properties
==============================================================================
--- trunk/plugins/editor/properties/fortran.properties	(original)
+++ trunk/plugins/editor/properties/fortran.properties	Sat Nov 15 17:50:33 2008
@@ -28,7 +28,7 @@
 real rec recl recursive result return rewind save select \
 selectcase selecttype sequential sign size stat status stop stream \
 subroutine target then to type unformatted unit use value \
-volatile wait where while write 
+volatile wait where while write
 
 keywords.$(file.patterns.f95)=$(keywordclass.fortran)
 keywords.$(file.patterns.f77)=$(keywordclass.fortran)
@@ -79,7 +79,6 @@
 # These setting do not work very well for FORTRAN, uncoment to use it
 # statement.indent.$(file.patterns.fortran)=8 associate block blockdata case do enum \
 # 	function interface module program subroutine then type where
-# statement.end.$(file.patterns.fortran)=10 end
 
 # Fortran styles
 # Default

Added: trunk/plugins/editor/properties/freebasic.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/freebasic.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,85 @@
+# Define SciTE settings for FreeBasic files.
+
+file.patterns.freebasic=*.bas;*.bi
+
+filter.freebasic=FreeBasic (bb bi)|$(file.patterns.freebasic)|
+
+lexer.$(file.patterns.freebasic)=freebasic
+
+# keywords must be all lowercase
+
+keywordclass.freebasic=\
+append as asc asin asm atan2 atn beep bin binary bit bitreset bitset bload \
+bsave byref byte byval call callocate case cbyte cdbl cdecl chain chdir chr \
+cint circle clear clng clngint close cls color command common cons const \
+continue cos cshort csign csng csrlin cubyte cuint culngint cunsg curdir \
+cushort custom cvd cvi cvl cvlongint cvs cvshort data date deallocate declare \
+defbyte defdbl defined defint deflng deflngint defshort defsng defstr defubyte \
+defuint defulngint defushort dim dir do double draw dylibload dylibsymbol else \
+elseif end enum environ environ$ eof eqv erase err error exec exepath exit exp \
+export extern field fix flip for fre freefile function get getjoystick getkey \
+getmouse gosub goto hex hibyte hiword if iif imagecreate imagedestroy imp \
+inkey inp input instr int integer is kill lbound lcase left len let lib line \
+lobyte loc local locate lock lof log long longint loop loword lset ltrim \
+mid mkd mkdir mki mkl mklongint mks mkshort mod multikey mutexcreate \
+mutexdestroy mutexlock mutexunlock name next not oct on once open option or out \
+output overload paint palette pascal pcopy peek peeki peeks pipe pmap point \
+pointer poke pokei pokes pos preserve preset print private procptr pset ptr \
+public put random randomize read reallocate redim rem reset restore resume \
+resume next return rgb rgba right rmdir rnd rset rtrim run sadd screen \
+screencopy screeninfo screenlock screenptr screenres screenset screensync \
+screenunlock seek statement seek function selectcase setdate setenviron \
+setmouse settime sgn shared shell shl short shr sin single sizeof sleep space \
+spc sqr static stdcall step stop str string string strptr sub swap system tab \
+tan then threadcreate threadwait time time timer to trans trim type ubound \
+ubyte ucase uinteger ulongint union unlock unsigned until ushort using va_arg \
+va_first va_next val val64 valint varptr view viewprint wait wend while width \
+window windowtitle with write xor zstring
+
+keywordclass.preprocessor=\
+#define #dynamic #else #endif #error #if #ifdef #ifndef #inclib #include \
+#print #static #undef
+
+keywords.$(file.patterns.freebasic)=$(keywordclass.freebasic)
+keywords2.$(file.patterns.freebasic)=$(keywordclass.preprocessor)
+
+# FB styles
+# Default
+style.freebasic.0=fore:#000000
+# Comment
+style.freebasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+# Number
+style.freebasic.2=$(colour.number)
+# Keyword1
+style.freebasic.3=$(colour.keyword),bold
+# String
+style.freebasic.4=$(colour.string)
+# Preprocessor
+style.freebasic.5=$(colour.preproc)
+# Operator
+style.freebasic.6=$(colour.operator)
+# Identifier
+style.freebasic.7=$(style.freebasic.0)
+# Date
+# style.freebasic.8=$(colour.error)
+# StringEOL
+# style.freebasic.9=$(colour.error)
+# Keyword2
+style.freebasic.10=$(colour.keyword)
+# Keyword3
+style.freebasic.11=$(colour.keyword)
+# Keyword4
+style.freebasic.12=$(colour.keyword)
+# Constant
+# style.freebasic.13=$(colour.error)
+# Asm
+# style.freebasic.14=$(colour.error)
+# Label
+style.freebasic.15=$(colour.preproc)
+# Error
+style.freebasic.16=$(colour.error)
+# HexNumber
+style.freebasic.17=$(colour.number)
+# BinNumber
+style.freebasic.18=$(colour.number)
+

Added: trunk/plugins/editor/properties/gap.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/gap.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,47 @@
+# Define SciTE settings for GAP files.
+
+file.patterns.gap=*.g;*.gd;*.gi
+
+# GAP files
+filter.gap=Gap (g gi gd)|$(file.patterns.gap)|
+
+lexer.$(file.patterns.gap)=gap
+
+keywords.$(file.patterns.gap)=and break continue do elif else end fi for function \
+if in local mod not od or quit rec repeat return then until while QUIT
+
+keywords2.$(file.patterns.gap)=false true IsBound Unbind TryNextMethod \
+Info Assert SaveWorkspace fail
+
+#keywords3.$(file.patterns.gap)
+
+comment.block.gap=#~
+
+# GAP styles
+# White space
+style.gap.0=fore:#808080
+# Identifiers
+style.gap.1=
+# Keywords
+style.gap.2=$(colour.keyword),bold
+# Keywords 2
+style.gap.3=$(colour.keyword)
+# Keywords 3
+style.gap.4=$(colour.keyword)
+# Keywords 4
+style.gap.5=$(colour.keyword)
+# Strings
+style.gap.6=$(colour.string)
+# Characters
+style.gap.7=$(colour.char)
+# Operators
+style.gap.8=$(colour.operator),bold
+# Comment
+style.gap.9=$(colour.code.comment.line)
+# Numbers
+style.gap.10=$(colour.number)
+# End of line where string is not closed
+style.gap.11=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+
+# Braces are only matched in operator style
+braces.gap.style=8
\ No newline at end of file

Modified: trunk/plugins/editor/properties/html.properties
==============================================================================
--- trunk/plugins/editor/properties/html.properties	(original)
+++ trunk/plugins/editor/properties/html.properties	Sat Nov 15 17:50:33 2008
@@ -3,7 +3,7 @@
 # vxml added by lseredi
 
 # tpl is X and Mail specific
-file.patterns.web=*.html;*.htm;*.asp;*.shtml;*.htd
+file.patterns.web=*.html;*.htm;*.asp;*.shtml;*.htd;*.jsp
 file.patterns.php=*.php3;*.phtml;*.php
 file.patterns.html=$(file.patterns.web);$(file.patterns.php);*.htt;*.cfm;*.tpl;*.dtd;*.hta
 file.patterns.vxml=*.vxml
@@ -15,17 +15,20 @@
 lexer.$(file.patterns.xml)=xml
 lexer.$(file.patterns.docbook)=hypertext
 
-filter.web=Web (html htm asp shtml css xml docbook)|$(file.patterns.web);*.css;*.xml;*.docbook|
+filter.web=Web (html htm asp shtml css xml docbook jsp)|$(file.patterns.web);*.css;*.xml;*.docbook|
 filter.php=PHP (php php3 phtml)|$(file.patterns.php)|
 
 fold.html=1
 #fold.html.preprocessor=0
+#fold.hypertext.comment=1
+#fold.hypertext.heredoc=1
 
 #Default Language=1 for JS, 2 for VBS.
 #asp.default.language=2
 #html.tags.case.sensitive=1
 
 #xml.auto.close.tags=1
+#lexer.xml.allow.scripts=0
 
 # All hypertext elements and attributes must be listed in lower case
 hypertext.elements=\
@@ -64,8 +67,17 @@
 text password checkbox radio submit reset \
 file hidden image
 
+# As defined in "Web Applications 1.0" Working Draft
+# http://www.whatwg.org/specs/web-apps/current-work/
+html5.elements=\
+article aside calendar canvas card command commandset datagrid datatree \
+footer gauge header m menubar menulabel nav progress section switch tabbox
+
+html5.attributes=\
+active command contenteditable ping
+
 keywordclass.hypertext=\
-$(hypertext.elements) $(hypertext.attributes) public !doctype
+$(hypertext.elements) $(hypertext.attributes) $(html5.elements) $(html5.attributes) public !doctype
 
 vxml.elements=\
 assign audio block break catch choice clear disconnect else elseif \
@@ -86,18 +98,19 @@
 keywordclass.vxml=\
 $(vxml.elements) $(vxml.attributes) public !doctype
 
-# List from http://www.php.net/manual/en/reserved.php
-# For a list with functions http://www.scintilla.org/SciTEExtras.html
+# List from http://www.php.net/manual/en/reserved.php (updated for PHP 5)
+# For a list with functions http://groups.google.com/group/scite-interest/web/extras
 # All words should be lower case to ensure case insensitivity when comparing
 keywordclass.php=\
-and argv as argc break case cfunction class continue declare default do \
-die echo else elseif empty enddeclare endfor endforeach endif endswitch \
-endwhile e_all e_parse e_error e_warning eval exit extends false for \
-foreach function global http_cookie_vars http_get_vars http_post_vars \
-http_post_files http_env_vars http_server_vars if include include_once \
-list new not null old_function or parent php_os php_self php_version \
-print require require_once return static switch stdclass this true var \
-xor virtual while __file__ __line__ __sleep __wakeup
+and array as bool boolean break case cfunction class const continue declare \
+default die directory do double echo else elseif empty enddeclare endfor \
+endforeach endif endswitch endwhile eval exit extends false float for \
+foreach function global if include include_once int integer isset list new \
+null object old_function or parent print real require require_once resource \
+return static stdclass string switch true unset use var while xor \
+abstract catch clone exception final implements interface php_user_filter \
+private protected public this throw try \
+__class__ __file__ __function__ __line__ __method__ __sleep __wakeup
 
 # Override keywordclass.php with another file if present
 import phpfunctions
@@ -185,6 +198,7 @@
 word.characters.$(file.patterns.html)=$(chars.alpha)$(chars.numeric)_-
 comment.stream.start.hypertext=<!--
 comment.stream.end.hypertext=-->
+comment.block.hypertext=//~
 
 # No keyword for xml, as it accepts any keyword
 keywords.$(file.patterns.xml)=
@@ -391,7 +405,7 @@
 style.hypertext.102=back:#EFFFEF,eolfilled
 
 # PHP complex variable
-style.hypertext.104=fore:#00007F,italics,back:#FFF8F8
+style.hypertext.104=fore:#007F00,italics,back:#FFF8F8
 
 # ASP Python
 style.hypertext.105=fore:#808080
@@ -437,7 +451,7 @@
 # One line comment
 style.hypertext.125=fore:#666666,italics,$(font.comment),back:#FFF8F8
 # PHP variable in double quoted string
-style.hypertext.126=fore:#00007F,italics,back:#FFF8F8
+style.hypertext.126=fore:#007F00,italics,back:#FFF8F8
 # PHP operator
 style.hypertext.127=fore:#000000,back:#FFF8F8
 
@@ -504,6 +518,8 @@
 if PLAT_WIN
 	command.go.$(file.patterns.web)="file://$(FilePath)"
 	command.go.subsystem.$(file.patterns.web)=2
-	command.go.$(file.patterns.php)=php -f $(FileNameExt)
 if PLAT_GTK
 	command.go.$(file.patterns.web)=netscape "file://$(FilePath)"
+
+command.go.$(file.patterns.php)=php -f "$(FileNameExt)"
+command.compile.$(file.patterns.php)=php -l "$(FileNameExt)"

Added: trunk/plugins/editor/properties/inno.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/inno.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,107 @@
+# Define SciTE settings for Inno Setup script files.
+
+file.patterns.inno=*.iss;*.isl
+
+filter.inno=Inno Setup (iss isl)|$(file.patterns.inno)|
+
+lexer.$(file.patterns.inno)=inno
+
+comment.block.inno=;~
+
+# Sections
+keywords.$(file.patterns.inno)=\
+ code components custommessages dirs files icons ini installdelete \
+ langoptions languages messages registry run setup types tasks \
+ uninstalldelete uninstallrun _istool
+
+# Keywords
+keywords2.$(file.patterns.inno)=\
+ allowcancelduringinstall allownoicons allowrootdirectory allowuncpath \
+ alwaysrestart alwaysshowcomponentslist alwaysshowdironreadypage \
+ alwaysshowgrouponreadypage alwaysusepersonalgroup appcomments appcontact \
+ appcopyright appid appmodifypath appmutex appname apppublisher \
+ apppublisherurl appreadmefile appsupportphone appsupporturl appupdatesurl \
+ appvername appversion appenddefaultdirname appenddefaultgroupname \
+ architecturesallowed architecturesinstallin64bitmode backcolor backcolor2 \
+ backcolordirection backsolid changesassociations changesenvironment \
+ compression compressionthreads copyrightfontname copyrightfontsize \
+ createappdir createuninstallregkey defaultdirname defaultgroupname \
+ defaultuserinfoname defaultuserinfoorg defaultuserinfoserial dialogfontname \
+ dialogfontsize dialogfontstandardheight direxistswarning disabledirpage \
+ disablefinishedpage disableprogramgrouppage disablereadymemo \
+ disablereadypage disablestartupprompt diskclustersize diskslicesize \
+ diskspanning dontmergeduplicatefiles enabledirdoesntexistwarning encryption \
+ extradiskspacerequired flatcomponentslist infoafterfile infobeforefile \
+ internalcompresslevel languagecodepage languagedetectionmethod languageid \
+ languagename licensefile mergeduplicatefiles messagesfile minversion \
+ onlybelowversion outputbasefilename outputdir outputmanifestfile password \
+ privilegesrequired reservebytes restartifneededbyrun righttoleft \
+ setupiconfile setuplogging showcomponentsizes showlanguagedialog \
+ showtaskstreelines showundisplayablelanguages signtool signeduninstaller \
+ signeduninstallerdir slicesperdisk solidcompression sourcedir \
+ terminalservicesaware timestamprounding timestampsinutc titlefontname \
+ titlefontsize touchdate touchtime uninstalldisplayicon uninstalldisplayname \
+ uninstallfilesdir uninstalliconfile uninstalllogmode \
+ uninstallrestartcomputer uninstallstyle uninstallable \
+ updateuninstalllogappname usepreviousappdir usepreviousgroup \
+ useprevioussetuptype useprevioustasks useprevioususerinfo usesetupldr \
+ userinfopage versioninfocompany versioninfocopyright versioninfodescription \
+ versioninfoproductname versioninfoproductversion versioninfotextversion \
+ versioninfoversion welcomefontname welcomefontsize windowresizable \
+ windowshowcaption windowstartmaximized windowvisible wizardimagebackcolor \
+ wizardimagefile wizardimagestretch wizardsmallimagebackcolor \
+ wizardsmallimagefile wizardstyle
+
+# Parameters
+keywords3.$(file.patterns.inno)=\
+ afterinstall attribs beforeinstall check comment components copymode \
+ description destdir destname excludes externalsize extradiskspacerequired \
+ filename flags fontinstall groupdescription hotkey iconfilename iconindex \
+ key languages minversion name onlybelowversion parameters permissions root \
+ runonceid section source statusmsg string subkey tasks type types valuedata \
+ valuename valuetype verb workingdir
+
+# Preprocessor directives
+keywords4.$(file.patterns.inno)=\
+ append define dim elif else emit endif endsub error expr file for if ifdef \
+ ifexist ifndef ifnexist include insert pragma sub undef
+
+# Pascal keywords
+keywords5.$(file.patterns.inno)=\
+ begin break case const continue do downto else end except finally for \
+ function if of procedure repeat then to try until uses var while with
+
+# User defined keywords
+keywords6.$(file.patterns.inno)=
+
+# Properties styles
+
+# Default
+style.inno.0=
+# Comment
+style.inno.1=fore:#007F7F,$(font.comment)
+# Keyword
+style.inno.2=$(colour.keyword)
+# Parameter
+style.inno.3=$(colour.string)
+# Section
+style.inno.4=back:#FFFFC0
+# Preprocessor
+style.inno.5=$(colour.preproc)
+# Preprocessor (inline)
+style.inno.6=$(colour.preproc)
+# Pascal comment
+style.inno.7=fore:#007F7F,$(font.comment)
+# Pascal keyword
+style.inno.8=$(colour.keyword)
+# User defined keyword
+style.inno.9=$(colour.keyword)
+# Double quoted string
+style.inno.10=$(colour.string)
+# Single quoted string
+style.inno.11=$(colour.char)
+
+#if PLAT_WIN
+#	# Replace PATH_TO_INNOSETUP by the path to your InnoSetup installation
+#	command.compile.$(file.patterns.inno)="PATH_TO_INNOSETUP\iscc.exe" $(FileNameExt)
+#	command.go.$(file.patterns.inno)="PATH_TO_INNOSETUP\Compil32.exe" $(FileNameExt)

Modified: trunk/plugins/editor/properties/kix.properties
==============================================================================
--- trunk/plugins/editor/properties/kix.properties	(original)
+++ trunk/plugins/editor/properties/kix.properties	Sat Nov 15 17:50:33 2008
@@ -29,7 +29,7 @@
 	setconsole setdefaultprinter setfileattr setfocus setoption setsystemstate \
 	settitle setwallpaper showprogramgroup shutdown sidtoname split srnd substr \
 	trim ubound ucase unloadhive val vartype vartypename writeline \
-	writeprofilestring writevalue 
+	writeprofilestring writevalue
 
 # This keywords are macros if preceeded by @
 keywords3.$(file.patterns.kix)=address build color comment cpu crlf csd curdir \
@@ -74,4 +74,3 @@
 use.tabs.$(file.patterns.kix)=1
 
 statement.indent.$(file.patterns.kix)=7 if else for do while function case
-statement.end.$(file.patterns.kix)=7 endif next until loop endfunction endselect

Modified: trunk/plugins/editor/properties/lout.properties
==============================================================================
--- trunk/plugins/editor/properties/lout.properties	(original)
+++ trunk/plugins/editor/properties/lout.properties	Sat Nov 15 17:50:33 2008
@@ -1,4 +1,6 @@
 # Define SciTE settings for Basser Lout files.
+# Based on Lout 3.35 [April 2007]
+# * to update keywords, see or diff externs.h
 
 file.patterns.lout=*.lt
 
@@ -6,28 +8,35 @@
 
 lexer.$(file.patterns.lout)=lout
 
-keywords.$(file.patterns.lout)= @OptGall @Filter @FilterIn @FilterOut \
- FilterErr @FontDef @Family @Face @Name @Metrics @ExtraMetrics \
- Mapping @Recode @Common @Rump @Meld @Insert @OneOf @Next @Plus \
- Minus @Wide @High @HShift @VShift @BeginHeaderComponent \
- EndHeaderComponent @SetHeaderComponent @ClearHeaderComponent @OneCol \
- OneRow @HScale @VScale @HCover @VCover @Scale @KernShrink @HContract \
- VContract @HLimited @VLimited @HExpand @VExpand @StartHVSpan \
- StartHSpan @StartVSpan @HSpan @VSpan @PAdjust @HAdjust @VAdjust \
- Rotate @Background @IncludeGraphic @SysIncludeGraphic @Graphic \
- LinkSource @LinkDest @URLLink @PlainGraphic @Verbatim @RawVerbatim \
- Case @Yield @BackEnd @Char @Font @Space @YUnit @ZUnit @Break \
- Underline @SetColour @SetColor @SetTexture @Outline @Language \
- CurrLang @CurrFamily @CurrFace @CurrYUnit @CurrZUnit @LEnv @LClos \
- LUse @LEO @Open @Use @NotRevealed @Tagged @Database @SysDatabase \
- Include @SysInclude @IncludeGraphicRepeated @PrependGraphic \
- SysIncludeGraphicRepeated @SysPrependGraphic @Target @Null \
- PageLabel @Galley @ForceGalley @LInput @Split @Tag @Key @Optimize \
- Merge @Enclose @Begin @End @Moment @Second @Minute @Hour @Day @Month \
- Year @Century @WeekDay @YearDay @DaylightSaving @@A @@B @@C @@D @@E @@V
+# @-prefixed keywords
+keywords.$(file.patterns.lout)= \
+ OptGall @FontDef @Family @Face @Name @Metrics @ExtraMetrics \
+ Mapping @Recode @Filter @FilterIn @FilterOut @FilterErr \
+ Common @Rump @Meld @Insert @OneOf @Next @Plus @Minus @Wide \
+ High @HShift @VShift @BeginHeaderComponent @EndHeaderComponent \
+ SetHeaderComponent @ClearHeaderComponent @OneCol @OneRow \
+ HMirror @VMirror @HScale @VScale @HCover @VCover @Scale \
+ KernShrink @HContract @VContract @HLimited @VLimited @HExpand \
+ VExpand @StartHVSpan @StartHSpan @StartVSpan @HSpan @VSpan \
+ PAdjust @HAdjust @VAdjust @Rotate @Background @IncludeGraphic \
+ SysIncludeGraphic @Graphic @LinkSource @LinkDest @URLLink \
+ PlainGraphic @Verbatim @RawVerbatim @Case @Yield @BackEnd \
+ Char @Font @Space @YUnit @ZUnit @Break @Underline @SetColour \
+ SetColor @SetUnderlineColour @SetUnderlineColor @SetTexture \
+ Outline @Language @CurrLang @CurrFamily @CurrFace @CurrYUnit \
+ CurrZUnit @LEnv @@A @@B @@C @@D @@E @LClos @@V @LUse @LEO \
+ Open @Use @NotRevealed @Tagged @Database @SysDatabase \
+ Include @SysInclude @IncludeGraphicRepeated \
+ SysIncludeGraphicRepeated @PrependGraphic @SysPrependGraphic \
+ Target @Null @PageLabel @Galley @ForceGalley @LInput @Split \
+ Tag @Key @Optimize @Merge @Enclose @Begin @End @Moment \
+ Second @Minute @Hour @Day @Month @Year @Century @WeekDay \
+ YearDay @DaylightSaving @SetContext @GetContext
 
+# symbols that are keywords (excluding braces)
 keywords2.$(file.patterns.lout)= &&& && & ^// ^/ ^|| ^| ^& // / || |
 
+# non- -prefixed keywords
 keywords3.$(file.patterns.lout)= def langdef force horizontally into \
 extend import export precedence associativity left right body macro \
 named compulsory following preceding foll_or_prec now
@@ -46,13 +55,13 @@
 style.lout.1=$(colour.code.comment.line),$(font.code.comment.line)
 # Number
 style.lout.2=$(colour.number)
-# Keyword
+# Keyword (@-prefixed keywords)
 style.lout.3=$(colour.keyword),bold
-# Keyword2
+# Keyword2 (symbol keywords)
 style.lout.4=$(colour.keyword),bold
-# Keyword3
+# Keyword3 (non-@ keywords)
 style.lout.5=$(colour.keyword),bold
-# Keyword4
+# Keyword4 (user or library symbols)
 style.lout.6=$(colour.keyword)
 # Double quoted string
 style.lout.7=$(colour.string)
@@ -65,7 +74,7 @@
 # Braces are only matched in operator style
 braces.lout.style=8
 
-command.compile.$(file.patterns.lout)=lout "$(FileNameExt)" > "$(FileName).ps" 
+command.compile.$(file.patterns.lout)=lout "$(FileNameExt)" > "$(FileName).ps"
 command.build.$(file.patterns.lout)=make
 
 if PLAT_WIN

Modified: trunk/plugins/editor/properties/lua.properties
==============================================================================
--- trunk/plugins/editor/properties/lua.properties	(original)
+++ trunk/plugins/editor/properties/lua.properties	Sat Nov 15 17:50:33 2008
@@ -2,26 +2,28 @@
 
 file.patterns.lua=*.lua
 
+shbang.lua=lua
+
 filter.lua=Lua (lua)|$(file.patterns.lua)|
 
 lexer.$(file.patterns.lua)=lua
 
-word.chars.lua=$(chars.alpha)$(chars.numeric)_%
-word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric)_%
+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 if \
 in local nil not or repeat return then true until while
 keywords.$(file.patterns.lua)=$(keywordclass.lua)
 
-# Basic Functions
+# Basic Functions (in both versions of Lua)
 keywordclass2.lua=_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring \
-print tonumber tostring type unpack
+print rawget rawset require tonumber tostring type unpack
 
 #### Lua 4.0
 # Basic Functions
 keywordclass2.lua4=_ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT \
 _STDERR _STDIN _STDOUT call dostring foreach foreachi getn globals newtype \
-rawget rawset require sort tinsert tremove
+sort tinsert tremove
 
 # String Manipulation & Mathematical Functions
 keywordclass3.lua4=abs acos asin atan atan2 ceil cos deg exp \
@@ -36,9 +38,11 @@
 #### Lua 5.0
 # Basic Functions
 keywordclass2.lua5=_G getfenv getmetatable ipairs loadlib next pairs pcall \
-rawegal rawget rawset require setfenv setmetatable xpcall \
-string table math coroutine io os debug
+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 \
@@ -46,7 +50,10 @@
 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.rad math.random math.randomseed math.sin math.sqrt math.tan
+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 \
@@ -54,7 +61,13 @@
 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
+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
@@ -69,7 +82,6 @@
 keywords4.$(file.patterns.lua)=$(keywordclass4.lua4) $(keywordclass4.lua5)
 
 #~ statement.indent.$(file.patterns.lua)=5 do else function then
-#~ statement.end.$(file.patterns.lua)=5 end until
 #~ statement.lookback.$(file.patterns.lua)=20
 indent.maintain.$(file.patterns.lua)=1
 
@@ -92,9 +104,9 @@
 style.lua.4=$(colour.number)
 # Keyword
 style.lua.5=$(colour.keyword)
-# String
+# (Double quoted) String
 style.lua.6=$(colour.string)
-# Character
+# Character (Single quoted string)
 style.lua.7=$(colour.char)
 # Literal string
 style.lua.8=$(colour.string),$(font.code.comment.box),back:#E0FFFF
@@ -106,19 +118,20 @@
 style.lua.11=
 # End of line where string is not closed
 style.lua.12=back:#E0C0E0,eolfilled
-# Other keywords (bozo test colors :-)
-style.lua.13=$(style.lua.5),back:#D0FFD0
-style.lua.14=$(style.lua.5),back:#D0D0FF
-style.lua.15=$(style.lua.5),back:#FFD0D0
-style.lua.16=$(style.lua.5),back:#FFD0FF
-style.lua.17=$(style.lua.5),back:#FFFFD0
+# Other keywords (bozo test colors, but toned down ;)
+style.lua.13=$(style.lua.5),back:#F5FFF5
+style.lua.14=$(style.lua.5),back:#F5F5FF
+style.lua.15=$(style.lua.5),back:#FFF5F5
+style.lua.16=$(style.lua.5),back:#FFF5FF
+style.lua.17=$(style.lua.5),back:#FFFFF5
 style.lua.18=$(style.lua.5),back:#FFA0A0
-style.lua.19=$(style.lua.5),back:#FFD0D0
+style.lua.19=$(style.lua.5),back:#FFF5F5
 # Braces are only matched in operator style
 braces.lua.style=10
 
-command.compile.*.lua=LuaC-5.0.exe -o "$(FileName).luc" "$(FileNameExt)"
-# Lua 5.0
-command.go.*.lua=Lua-5.0.exe "$(FileNameExt)"
+# compatible with LuaBinaries for Lua 5.1; will work on both platforms.
+command.compile.*.lua=luac5.1 -o "$(FileName).luc" "$(FileNameExt)"
+# Lua 5.1
+command.go.*.lua=lua5.1 "$(FileNameExt)"
 # Lua 4.0
 #command.go.*.lua=Lua-4.0.exe -c -f "$(FileNameExt)"

Modified: trunk/plugins/editor/properties/metapost.properties
==============================================================================
--- trunk/plugins/editor/properties/metapost.properties	(original)
+++ trunk/plugins/editor/properties/metapost.properties	Sat Nov 15 17:50:33 2008
@@ -4,11 +4,8 @@
 
 # Metapost: patterns
 
-file.patterns.metapost=
-file.patterns.metafun=
-
-file.patterns.metapost=*.mp;*.mpx;
-file.patterns.metafun=*.mp;*.mpx;*.mpy;
+file.patterns.metapost=*.mp;*.mpx
+file.patterns.metafun=*.mp;*.mpx;*.mpy
 
 filter.metapost=MetaPost|$(file.patterns.metapost)|
 filter.metafun=MetaFun|$(file.patterns.metafun)|
@@ -177,6 +174,14 @@
 keywords.$(file.patterns.metafun)=$(keywordclass.metapost.all)
 keywords2.$(file.patterns.metafun)=$(keywordclass.metafun.all)
 
+##  Metapost fold points
+## keywords4  = fold beginning; keywords5 = fold ending.
+keywords4.$(file.patterns.metapost)=beginfig for verbatimtex def begingroup
+if btex forsuffixes \
+ vardef primarydef
+keywords5.$(file.patterns.metapost)=etex fi endfig endgroup end endfor endif
+enddef
+
 import metafun-scite.properties
 
-# Metapost: end of file
\ No newline at end of file
+# Metapost: end of file

Modified: trunk/plugins/editor/properties/mmixal.properties
==============================================================================
--- trunk/plugins/editor/properties/mmixal.properties	(original)
+++ trunk/plugins/editor/properties/mmixal.properties	Sat Nov 15 17:50:33 2008
@@ -70,10 +70,9 @@
 
 tab.size.$(file.patterns.mmixal)=16
 indent.size.$(file.patterns.mmixal)=16
-backspace.unindents
 
 command.compile.$(file.patterns.mmixal)=mmixal -l $(FileName).map -b 200 $(FilePath)
 command.go.$(file.patterns.mmixal)=mmix $(1) $(FileName).mmo
 #~ mmotype
 command.name.2.$(file.patterns.mmixal)=mmotype
-command.2.$(file.patterns.mmixal)=mmotype $(FileName).mmo $(FileName).out
\ No newline at end of file
+command.2.$(file.patterns.mmixal)=mmotype $(FileName).mmo $(FileName).out

Modified: trunk/plugins/editor/properties/nsis.properties
==============================================================================
--- trunk/plugins/editor/properties/nsis.properties	(original)
+++ trunk/plugins/editor/properties/nsis.properties	Sat Nov 15 17:50:33 2008
@@ -1,6 +1,8 @@
 # Define SciTE settings for NSIS.
 # contributed by Angelo Mandato <angelo at spaceblue dot com>
 # Updated for NSIS v.2.02 / 2004-10-25 by flizebogen <flizebogen at gmx dot de>
+# Updated /2004-28-2 by Robert Roessler <robertr at rftp dot com>
+# Updated for NSIS v.2.05 and latest lexer / 2005-3-10 by Angelo Mandato <angelo at spaceblue dot com>
 
 filter.nsis=NSIS (nsi nsh)|*.nsi;*.nsh|
 file.patterns.nsis=*.nsi;*.nsh
@@ -12,58 +14,55 @@
 # Note: keywords below must all be lowercase in order for ignorecase=1 to function correctly
 
 # Functions:
-keywords.$(file.patterns.nsis)=!AddIncludeDir !AddPluginDir !cd !define !echo \
-!else !endif !error !execute !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro \
-!macro !macroend !packhdr !system !undef !verbose !warning Abort \
-AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow \
-BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI \
-CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck \
-CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr \
-DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirShow DirText \
-DirVar DirVerify DisabledBitmap EnabledBitmap EnableWindow EnumRegKey \
-EnumRegValue Exch Exec ExecShell ExecWait ExpandEnvStrings File \
-FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileSeek \
-FileWrite FileWriteByte FindClose FindFirst FindNext FindWindow FlushINI \
-Function FunctionEnd GetCurInstType GetCurrentAddress GetDlgItem \
-GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal \
-GetFullPathName GetFunctionAddress GetInstDirError GetLabelAddress \
-GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists \
-IfRebootFlag IfSilent InitPluginsDir InstallButtonText InstallColors \
-InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText \
-InstTypeSetText IntCmp IntCmpU IntFmt IntOp IsWindow LangString \
-LangStringUP LicenseBkColor LicenseData LicenseForceSelection \
-LicenseLangString LicenseText LoadLanguageFile LockWindow LogSet \
-LogText MessageBox MiscButtonText Name OutFile Page PageEx \
-PageExEnd PluginDir Pop Push Quit ReadEnvStr ReadINIStr \
-ReadRegDword ReadRegDWORD ReadRegStr Reboot RegDLL Rename \
-ReserveFile Return RMDir SearchPath Section SectionDivider SectionEnd \
-SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText \
-SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize \
-SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress \
-SetCompressionLevel SetCompressor SetCompressorDictSize SetCtlColors \
-SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView \
-SetErrors SetErrorLevel SetFileAttributes SetFont SetOutPath SetOverwrite SetPluginUnload \
-SetRebootFlag SetShellVarContext SetSilent SetStaticBkColor ShowInstDetails \
-ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts \
-StrCmp StrCpy StrLen SubCaption SubSection SubSectionEnd UninstallButtonText \
-UninstallCaption UninstallEXEName UninstallIcon UninstallSubCaption UninstallText \
-UninstPage UnRegDLL Var VIAddVersionKey VIProductVersion WindowIcon \
-WriteINIStr WriteRegBin WriteRegDword WriteRegDWORD WriteRegExpandStr \
-WriteRegStr WriteUninstaller XPStyle
+keywords.$(file.patterns.nsis)=!addincludedir !addplugindir MakeNSIS Portions \
+Contributors: Abort AddBrandingImage AddSize AutoCloseWindow BGFont \
+BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI \
+ClearErrors ComponentText GetDLLVersion GetDLLVersionLocal GetFileTime \
+GetFileTimeLocal CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut \
+SetDatablockOptimize DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue \
+Delete DetailPrint DirText DirShow DirVar DirVerify GetInstDirError AllowRootDirInstall \
+CheckBitmap EnableWindow EnumRegKey EnumRegValue Exch Exec ExecWait \
+ExecShell ExpandEnvStrings FindWindow FindClose FindFirst FindNext File FileBufSize \
+FlushINI ReserveFile FileClose FileErrorText FileOpen FileRead FileWrite FileReadByte \
+FileWriteByte FileSeek Function FunctionEnd GetDlgItem GetFullPathName \
+GetTempFileName HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfSilent \
+InstallDirRegKey InstallColors InstallDir InstProgressFlags InstType IntOp IntCmp \
+IntCmpU IntFmt IsWindow Goto LangString LangStringUP LicenseData \
+LicenseForceSelection LicenseLangString LicenseText LicenseBkColor \
+LoadLanguageFile LogSet LogText MessageBox Nop Name OutFile Page \
+PageCallbacks PageEx PageExEnd Pop Push Quit ReadINIStr ReadRegDWORD \
+ReadRegStr ReadEnvStr Reboot RegDLL Rename Return RMDir Section SectionEnd \
+SectionIn SubSection SectionGroup SubSectionEnd SectionGroupEnd SearchPath \
+SectionSetFlags SectionGetFlags SectionSetInstTypes SectionGetInstTypes \
+SectionGetText SectionSetText SectionGetSize SectionSetSize GetCurInstType \
+SetCurInstType InstTypeSetText InstTypeGetText SendMessage SetAutoClose \
+SetCtlColors SetBrandingImage SetCompress SetCompressor SetCompressorDictSize \
+SetCompressionLevel SetDateSave SetDetailsView SetDetailsPrint SetErrors \
+SetErrorLevel GetErrorLevel SetFileAttributes SetFont SetOutPath SetOverwrite \
+SetPluginUnload SetRebootFlag SetShellVarContext SetSilent ShowInstDetails \
+ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep StrCmp StrCpy \
+StrLen SubCaption UninstallExeName UninstallCaption UninstallIcon UninstPage \
+UninstallText UninstallSubCaption UnRegDLL WindowIcon WriteINIStr WriteRegBin \
+WriteRegDWORD WriteRegStr WriteRegExpandStr WriteUninstaller XPStyle !packhdr \
+!system !execute !AddIncludeDir !include !cd !ifdef !ifndef !endif !define !undef !else !echo !warning \
+!error !verbose !macro !macroend !insertmacro !ifmacrodef !ifmacrondef MiscButtonText \
+DetailsButtonText UninstallButtonText InstallButtonText SpaceTexts \
+CompletedText GetFunctionAddress GetLabelAddress GetCurrentAddress \
+!AddPluginDir InitPluginsDir AllowSkipFiles Var VIAddVersionKey VIProductVersion LockWindow
 
  
 # Variables:
 keywords2.$(file.patterns.nsis)=$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 \
-$R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 $CMDLINE $DESKTOP \
-$EXEDIR $HWNDPARENT $INSTDIR $OUTDIR $PROGRAMFILES ${NSISDIR} $\n $\r \
-$QUICKLAUNCH $SMPROGRAMS $SMSTARTUP $STARTMENU $SYSDIR $TEMP $WINDIR \
-$COMMONFILES $DOCUMENTS $SENDTO $RECENT $FAVORITES $MUSIC $PICTURES \
-$VIDEOS $NETHOOD $FONTS $TEMPLATES $APPDATA $PRINTHOOD $INTERNET_CACHE \
-$COOKIES $HISTORY $PROFILE $ADMINTOOLS $RESOURCES $RESOURCES_LOCALIZED \
-$CDBURN_AREA $PLUGINSDIR
+$R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 $\t $\" $\' $\` \
+$VARNAME $0, $INSTDIR $OUTDIR $CMDLINE $LANGUAGE $PROGRAMFILES \
+$COMMONFILES $DESKTOP $EXEDIR ${NSISDIR} $WINDIR $SYSDIR $TEMP \
+$STARTMENU $SMPROGRAMS $SMSTARTUP $QUICKLAUNCH $DOCUMENTS \
+$SENDTO $RECENT $FAVORITES $MUSIC $PICTURES $VIDEOS $NETHOOD \
+$FONTS $TEMPLATES $APPDATA $PRINTHOOD $INTERNET_CACHE $COOKIES \
+$HISTORY $PROFILE $ADMINTOOLS $RESOURCES $RESOURCES_LOCALIZED \
+$CDBURN_AREA $HWNDPARENT $PLUGINSDIR $$ $\r $\n
 
-
-# Lables:
+# Labels:
 keywords3.$(file.patterns.nsis)=ARCHIVE FILE_ATTRIBUTE_ARCHIVE FILE_ATTRIBUTE_HIDDEN \
 FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_OFFLINE FILE_ATTRIBUTE_READONLY \
 FILE_ATTRIBUTE_SYSTEM FILE_ATTRIBUTE_TEMPORARY HIDDEN HKCC HKCR HKCU \
@@ -72,12 +71,13 @@
 IDCANCEL IDIGNORE IDNO IDOK IDRETRY IDYES MB_ABORTRETRYIGNORE MB_DEFBUTTON1 \
 MB_DEFBUTTON2 MB_DEFBUTTON3 MB_DEFBUTTON4 MB_ICONEXCLAMATION \
 MB_ICONINFORMATION MB_ICONQUESTION MB_ICONSTOP MB_OK MB_OKCANCEL \
-MB_RETRYCANCEL MB_RIGHT MB_SETFOREGROUND MB_TOPMOST MB_YESNO MB_YESNOCANCEL \
-NORMAL OFFLINE READONLY SW_SHOWMAXIMIZED SW_SHOWMINIMIZED SW_SHOWNORMAL \
-SYSTEM TEMPORARY auto colored false force hide ifnewer nevershow normal \
-off on show silent silentlog smooth true try lzma zlib bzip2 none listonly textonly both \
-top left bottom right colored license components directory instfiles uninstConfirm \
-custom all leave current ifdiff lastused
+MB_RETRYCANCEL MB_RIGHT MB_SETFOREGROUND MB_TOPMOST MB_YESNO \
+MB_YESNOCANCEL NORMAL OFFLINE READONLY SW_SHOWMAXIMIZED SW_SHOWMINIMIZED \
+SW_SHOWNORMAL SYSTEM TEMPORARY auto colored false force hide ifnewer nevershow \
+normal off on show silent silentlog smooth true try lzma zlib bzip2 none listonly textonly \
+both top left bottom right license components directory instfiles uninstConfirm custom \
+all leave current ifdiff lastused LEFT RIGHT CENTER dlg_id ALT CONTROL EXT SHIFT \
+open print manual alwaysoff
 
 #User defined:
 #keywords4.$(file.patterns.nsis)=MyFunction MySomethingElse
@@ -94,7 +94,7 @@
 style.nsis.4=fore:#999999,back:#EEEEEE
 # Function (SCE_NSIS_FUNCTION)
 style.nsis.5=fore:#00007F,bold
-# fore:#0033CC,bold
+#style.nsis.5=fore:#0033CC,bold
 # Variable (SCE_NSIS_VARIABLE)
 style.nsis.6=fore:#CC3300
 # Label (SCE_NSIS_LABEL)
@@ -113,17 +113,25 @@
 style.nsis.13=fore:#CC3300,back:#EEEEEE
 # Numbers (SCE_NSIS_NUMBER)
 style.nsis.14=fore:#007F7F
-
+# Section Group SCE_NSIS_SECTIONGROUP)
+style.nsis.15=fore:#00007F,bold
+# Page Ex SCE_NSIS_PAGEEX)
+style.nsis.16=fore:#00007F,bold
+# Function Definition SCE_NSIS_FUNCTIONDEF)
+style.nsis.17=fore:#00007F,bold
+# Comment Box SCE_NSIS_COMMENTBOX)
+style.nsis.18=fore:#007F00,$(font.comment),bold
 
 
 # compiling/building simply checks for the correct symantics....
 command.compile.$(file.patterns.nsis)=c:/program files/nsis/makensis.exe "$(FilePath)"
 command.build.$(file.patterns.nsis)=c:/program files/nsis/makensis.exe "$(FilePath)"
 
+command.go.$(file.patterns.nsis)=$(FileName).exe
+
 command.help.$(file.patterns.nsis)=$(CurrentWord)!C:\Program files\NSIS\NSIS.chm
 command.help.subsystem.$(file.patterns.nsis)=4
 
-
 comment.block.nsis=;
 comment.block.at.line.start.nsis=1
 comment.stream.start.nsis=/*

Added: trunk/plugins/editor/properties/opal.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/opal.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,62 @@
+# Define SciTE settings for Opal files.
+
+filter.opal=OPAL (impl sign)|*.impl;*.sign|
+
+file.patterns.opal=*.impl;*.sign
+lexer.$(file.patterns.opal)=opal
+
+keywordclass.opal_keywords=ALL AND ANDIF ANY AS ASSERT AXM COMPLETELY DATA DEF DERIVE \
+DFD DISCRIMINATORS ELSE EX EXTERNAL FI FIX FUN IF IMPLEMENTATION IMPLIES IMPORT \
+IN INHERIT INJECTIONS INTERFACE INTERNAL LAW LAZY LEFTASSOC LET MODULE NOT ONLY \
+OR ORIF OTHERWISE POST PRE PRED PRIORITY PROPERTIES REALIZES REQUIRE RIGHTASSOC \
+SELECTORS SIGNATURE SORT SPC SPEC SPECIFICATION STRUCTURE THE THEN THEORY THM \
+TYPE UNIQ WHERE
+
+keywordclass.opal_sorts=aEntry agent align anchor ans arg arg1 arg2 array \
+arrowWhere bag bitmap bool bstree byte callback canvasEditor capStyle channel \
+char childstat codom codomFrom codomTo color colorModel com composeOp config \
+configCom cursor dArray data data1 data11 data2 data21 data3 data31 data4 \
+data41 dataFrom dataTo defaultPrio denotation device dist distOut dom domFrom \
+domTo drawing dyn emitter env event eventInfo file filemode filestat filetype \
+first first1 first2 first3 fission fmt font from from1 from2 funct group groupid \
+heap iconfig image in inData index inode input int inter interdom interpreter \
+iseq items joinStyle justifyHow long manager managerRequest map mapEntry mark \
+mid modifier nat natMap OBJECT option orient out outData output packOp pair \
+parser permission point positionRequest process procstat quad range real \
+regulator rel relief res res1 res2 result role sap script scroller scrollView \
+scrollWindow searchOpt second seekMode selector semaphor seq seqEntry set \
+setEntry short sigaction sighandler sigmask signal size sizeRequest some \
+sreal state stateId stateRequest string subrel tag textEditor time to tree \
+triple union user userid version view void wconfig wconfigCom wday widget \
+window wrapStyle 
+
+keywords.$(file.patterns.opal)=$(keywordclass.opal_keywords)
+keywords2.$(file.patterns.opal)=$(keywordclass.opal_sorts)
+
+
+# Opal styles
+# White space
+style.opal.0=fore:#000000,$(font.opal)
+# Comment block
+style.opal.1=fore:#007F00,italics,$(font.comment)
+# Comment line
+style.opal.2=fore:#007F00,italics,$(font.comment)
+# Integer
+style.opal.3=fore:#007F7F
+# Keyword
+style.opal.4=fore:#00007F,bold
+# Sort
+style.opal.5=fore:#007F7F
+# Double quoted string
+style.opal.6=fore:#7F007F,italics,$(font.comment)
+# Brace normal
+style.opal.7=fore:#000000
+# Bool const
+style.opal.8=fore:#A00000
+
+# Default/Identifiers
+style.opal.32=fore:#000000
+# Brace highlight
+style.opal.34=fore:#FF0000,back:#FFFF00,bold
+# Brace incomplete highlight
+style.opal.35=fore:#FF0000,back:#00FF00,bold

Modified: trunk/plugins/editor/properties/others.properties
==============================================================================
--- trunk/plugins/editor/properties/others.properties	(original)
+++ trunk/plugins/editor/properties/others.properties	Sat Nov 15 17:50:33 2008
@@ -1,10 +1,10 @@
 # Define SciTE settings for other simple files.
 
-file.patterns.props=*.properties;*.ini;*.inf;*.reg;*.url;*.cfg;*.cnf;*.aut
+file.patterns.props=*.properties;*.session;*.ini;*.inf;*.reg;*.url;*.cfg;*.cnf;*.aut
 file.patterns.text=*.txt;*.log;*.lst;*.doc;*.diz;*.nfo
 file.patterns.batch=*.bat;*.cmd;*.nt
 file.patterns.diff=*.diff;*.patch
-file.patterns.make=makefile;Makefile;*.mak;configure*
+file.patterns.make=makefile;Makefile;*.mak;configure
 
 filter.properties=Properties (ini inf reg url cfg cnf)|$(file.patterns.props)|
 filter.text=Text (txt log lst doc diz nfo)|$(file.patterns.text);make*|
@@ -34,6 +34,8 @@
 style.props.3=$(colour.other.operator)
 # Default value (@)
 style.props.4=$(colour.preproc)
+# Key
+style.props.5=
 # Matched Operators
 style.props.34=fore:#0000FF,notbold
 style.props.35=fore:#FF0000,notbold
@@ -53,25 +55,30 @@
 break call chcp cd chdir choice cls country ctty date del erase dir echo \
 exit goto loadfix loadhigh mkdir md move path pause prompt rename ren \
 rmdir rd shift time type ver verify vol \
-com con lpt nul
+com con lpt nul \
+color copy defined else not start
 keywords.$(file.patterns.batch)=$(keywordclass.batch)
 
+# Optional list of external commands to highlight in style 5.
+# If not set all commands are highlighted in style 5.
+#keywords2.$(file.patterns.batch)=append attrib chkdsk comp diskcomp
+
 # Default
 style.batch.0=fore:#000000
 # Comment (rem or ::)
 style.batch.1=fore:#007F00,$(font.comment)
 # Keywords
-style.batch.2=$(colour.keyword)
+style.batch.2=$(colour.keyword),bold
 # Label (line beginning with ':')
 style.batch.3=$(colour.string),back:#606060,fore:#FFFF00,eolfilled
 # Hide command character ('@')
 style.batch.4=$(colour.preproc)
 # External commands
-style.batch.5=$(colour.keyword),$(font.monospace),bold
+style.batch.5=fore:#007090,$(font.monospace),bold
 # Variable: %%x (x is almost whatever, except space and %), %n (n in [0-9]), %EnvironmentVar%
-style.batch.6=back:#FFFFE0
+style.batch.6=fore:#800080
 # Operator: * ? < > |
-style.batch.7=$(colour.other.operator)
+style.batch.7=fore:#000000
 
 comment.block.batch=REM ~
 
@@ -142,9 +149,13 @@
 style.errorlist.19=fore:#FF0000
 # Java runtime stack trace
 style.errorlist.20=fore:#FF0000
+# Text matched with find in files and message part of GCC errors
+style.errorlist.21=fore:#000000
 # Ensures that spacing is not affected by line number styles
 style.errorlist.33=$(font.small)
 
+lexer.errorlist.value.separate=1
+
 # Difference styles
 
 # Default
@@ -161,6 +172,8 @@
 style.diff.5=fore:#007F7F
 # Line addition (+...)
 style.diff.6=fore:#00007F
+# Line change (!...)
+style.diff.7=fore:#7F7F7F
 
 command.build.makefile=make
 command.build.*.mak=make

Modified: trunk/plugins/editor/properties/pascal.properties
==============================================================================
--- trunk/plugins/editor/properties/pascal.properties	(original)
+++ trunk/plugins/editor/properties/pascal.properties	Sat Nov 15 17:50:33 2008
@@ -7,12 +7,12 @@
 file.patterns.pascal=*.dpr;*.dpk;*.pas;*.dfm;*.inc;*.pp
 lexer.$(file.patterns.pascal)=pascal
 
-keywordclass.pascal=and array asm begin case cdecl class const constructor default \
-destructor div do downto else end end. except exit exports external far file \
-finalization finally for function goto if implementation in index inherited \
+keywordclass.pascal=and array asm begin case cdecl class const constructor contains \
+default destructor div do downto else end end. except exit exports external \
+far file finalization finally for function goto if implementation in index inherited \
 initialization inline interface label library message mod near nil not \
-object of on or out overload override packed pascal private procedure program \
-property protected public published raise read record register repeat resourcestring \
+object of on or out overload override package packed pascal private procedure program \
+property protected public published raise read record register repeat requires resourcestring \
 safecall set shl shr stdcall stored string then threadvar to try type unit \
 until uses var virtual while with write xor
 
@@ -56,9 +56,15 @@
 # Braces are only matched in operator style
 braces.pascal.style=10
 
+comment.block.pascal=//~
+comment.stream.start.pascal=(*
+comment.stream.end.pascal=*)
+comment.box.start.pascal={
+comment.box.middle.pascal=
+comment.box.end.pascal=}
+
 statement.indent.$(file.patterns.pascal)=5 case catch class default do else for then \
 private protected public struct try union while type
-statement.end.$(file.patterns.pascal)=10 ;
 statement.lookback.$(file.patterns.pascal)=20
 block.start.$(file.patterns.pascal)=10 begin
 block.end.$(file.patterns.pascal)=10 end

Modified: trunk/plugins/editor/properties/perl.properties
==============================================================================
--- trunk/plugins/editor/properties/perl.properties	(original)
+++ trunk/plugins/editor/properties/perl.properties	Sat Nov 15 17:50:33 2008
@@ -1,13 +1,25 @@
-# Define SciTE settings for Perl and Bash files.
+# Define SciTE settings for Perl, Bash, and AWK files.
 
-file.patterns.perl=*.pl;*.pm;*.cgi;*.pod
+
+file.patterns.perl=*.pl;*.pm;*.pod
 file.patterns.bash=*.sh;*.bsh;configure
+file.patterns.awk=*.awk
+
+shbang.perl=pl
+shbang.sh=sh
+shbang.bash=sh
+
+shbang.gawk=awk
+shbang.nawk=awk
+shbang.mawk=awk
 
 filter.perl=Perl (pl pm)|$(file.patterns.perl)|
 filter.bash=Bash (sh bsh)|$(file.patterns.bash)|
+filter.awk=GAWK  (awk)|$(file.patterns.awk)|
 
 lexer.$(file.patterns.perl)=perl
 lexer.$(file.patterns.bash)=bash
+lexer.$(file.patterns.awk)=perl
 
 keywords.$(file.patterns.perl)=\
 NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD \
@@ -23,27 +35,54 @@
 getpwent getpwnam getpwuid getservbyname getservbyport getservent \
 getsockname getsockopt glob gmtime goto grep gt hex if index \
 int ioctl join keys kill last lc lcfirst le length link listen \
-local localtime lock log lstat lt m map mkdir msgctl msgget msgrcv \
+local localtime lock log lstat lt map mkdir msgctl msgget msgrcv \
 msgsnd my ne next no not oct open opendir or ord our pack package \
-pipe pop pos print printf prototype push q qq qr quotemeta qu \
-qw qx rand read readdir readline readlink readpipe recv redo \
+pipe pop pos print printf prototype push quotemeta qu \
+rand read readdir readline readlink readpipe recv redo \
 ref rename require reset return reverse rewinddir rindex rmdir \
-s scalar seek seekdir select semctl semget semop send setgrent \
+scalar seek seekdir select semctl semget semop send setgrent \
 sethostent setnetent setpgrp setpriority setprotoent setpwent \
 setservent setsockopt shift shmctl shmget shmread shmwrite shutdown \
 sin sleep socket socketpair sort splice split sprintf sqrt srand \
 stat study sub substr symlink syscall sysopen sysread sysseek \
-system syswrite tell telldir tie tied time times tr truncate \
+system syswrite tell telldir tie tied time times truncate \
 uc ucfirst umask undef unless unlink unpack unshift untie until \
 use utime values vec wait waitpid wantarray warn while write \
-x xor y
+xor \
+given when default say state UNITCHECK
+
+keywords.$(file.patterns.awk)=\
+BEGIN END \
+if else while do for in break continue delete exit function return \
+print printf sprintf \
+system close getline next nextfile fflush \
+atan2 cos exp int log rand sin sqrt srand \
+asort asorti gensub sub gsub index length match split \
+strtonum substr tolower toupper \
+mktime strftime systime \
+and compl lshift or rshift xor \
+bindtextdomain dcgettext dcngettext \
+ARGC ARGIND ARGV BINMODE CONVFMT ENVIRON ERRNO FIELDWIDTHS \
+FILENAME FNR FS IGNORECASE LINT NF NR OFMT OFS ORS PROCINFO \
+RS RT RSTART RLENGTH SUBSEP TEXTDOMAIN
+
+
+comment.block.awk=#~
+block.start.$(file.patterns.awk)=10 {
+block.end.$(file.patterns.awk)=10 }
+
 
 word.characters.$(file.patterns.perl)=$(chars.alpha)$(chars.numeric)_$ %&
 
 comment.block.perl=#~
+block.start.$(file.patterns.perl)=10 {
+block.end.$(file.patterns.perl)=10 }
 
 colour.perl.heredoc=$(colour.embedded.comment)
 
+#fold.perl.package=1
+#fold.perl.pod=1
+
 # generic keywords
 bash_keywords1=alias \
 ar asa awk banner basename bash bc bdiff break \
@@ -145,6 +184,14 @@
 style.perl.29=$(style.perl.17)
 # qw = Array
 style.perl.30=$(style.perl.13)
+# POD: verbatim paragraphs
+style.perl.31=fore:#004000,back:#C0FFC0,$(font.monospace),eolfilled
+# subroutine prototype
+style.perl.40=$(style.perl.10),italics
+# format identifier
+style.perl.41=fore:#C000C0,bold
+# format body
+style.perl.42=fore:#C000C0,back:#FFF0FF,eolfilled
 # Braces are only matched in operator style
 braces.perl.style=10
 
@@ -183,6 +230,8 @@
 # Braces are only matched in operator style
 braces.bash.style=7
 
+command.go.$(file.patterns.awk)=gawk -f $(FileNameExt)
+
 command.go.$(file.patterns.perl)=perl -w $(FileNameExt)
 
 command.compile.$(file.patterns.perl)=perl -c -w $(FileNameExt)

Modified: trunk/plugins/editor/properties/pov.properties
==============================================================================
--- trunk/plugins/editor/properties/pov.properties	(original)
+++ trunk/plugins/editor/properties/pov.properties	Sat Nov 15 17:50:33 2008
@@ -11,20 +11,12 @@
 tab.size.*.inc=2
 use.tabs.*.inc=0
 
-#indent.automatic=1
-#tab.indents=1
-#backspace.unindents=1
-
-file.patterns.braces=$(file.patterns.pov)
-
 lexer.$(file.patterns.pov)=pov
 
 word.chars.pov=$(chars.alpha)$(chars.numeric)_#
 word.characters.$(file.patterns.pov)=$(word.chars.pov)
 
 api.*.pov=POV-Ray_SDL.api
-#autocomplete.choose.single=1
-#autocompleteword.automatic=1
 #autocomplete.pov.ignorecase=1
 autocomplete.pov.start.characters=.
 #autocomplete.pov.fillups=(
@@ -40,12 +32,9 @@
 comment.box.start.pov=/*
 comment.box.middle.pov= *
 comment.box.end.pov= */
-fold.comment=1
-fold.directive=1
 
 #~ statement.indent.$(file.patterns.pov)=5 case catch class default do else for if \
 #~ private protected public struct try union while
-#~ statement.end.$(file.patterns.pov)=10 ;
 #~ statement.lookback.$(file.patterns.pov)=20
 #~ block.start.$(file.patterns.pov)=10 {
 #~ block.end.$(file.patterns.pov)=10 }
@@ -173,13 +162,13 @@
 # Directive keyword error
 style.pov.9=fore:#804020,$(font.code.comment.doc),italics
 # Keywords (bozo test colors :-)
-# Keyword 2
+# Keyword 2: Objects & CSG & Appearance (xxx {})
 style.pov.10=$(colour.keyword),back:#FFD0D0
-# Keyword 3
+# Keyword 3: Types & Modifiers & Items
 style.pov.11=$(colour.keyword),back:#FFFFD0
-# Keyword 4
+# Keyword 4: Predefined Identifiers
 style.pov.12=$(colour.keyword),bold
-# Keyword 5
+# Keyword 5: Predefined Functions
 style.pov.13=$(colour.keyword),back:#D0D0FF
 # Keyword 6
 style.pov.14=$(colour.keyword),back:#D0FFD0

Added: trunk/plugins/editor/properties/powershell.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/powershell.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,75 @@
+# Define SciTE settings for PowerShell files
+
+file.patterns.powershell=*.ps1
+
+filter.powershell=PowerShell (ps1)|$(file.patterns.powershell)|
+
+lexer.$(file.patterns.powershell)=powershell
+
+# These keywords are commands
+keywords.$(file.patterns.powershell)=\
+break continue do else elseif filter for foreach function if in return switch \
+until where while
+
+# This keywords are cmdlets
+keywords2.$(file.patterns.powershell)=\
+add-content add-history add-member add-pssnapin clear-content clear-item \
+clear-itemproperty clear-variable compare-object convertfrom-securestring \
+convert-path convertto-html convertto-securestring copy-item copy-itemproperty \
+export-alias export-clixml export-console export-csv foreach-object format-custom \
+format-list format-table format-wide get-acl get-alias get-authenticodesignature \
+get-childitem get-command get-content get-credential get-culture get-date \
+get-eventlog get-executionpolicy get-help get-history get-host get-item \
+get-itemproperty get-location get-member get-pfxcertificate get-process get-psdrive \
+get-psprovider get-pssnapin get-service get-tracesource get-uiculture get-unique \
+get-variable get-wmiobject group-object import-alias import-clixml import-csv \
+invoke-expression invoke-history invoke-item join-path measure-command \
+measure-object move-item move-itemproperty new-alias new-item new-itemproperty \
+new-object new-psdrive new-service new-timespan new-variable out-default out-file \
+out-host out-null out-printer out-string pop-location push-location read-host \
+remove-item remove-itemproperty remove-psdrive remove-pssnapin remove-variable \
+rename-item rename-itemproperty resolve-path restart-service resume-service \
+select-object select-string set-acl set-alias set-authenticodesignature \
+set-content set-date set-executionpolicy set-item set-itemproperty set-location \
+set-psdebug set-service set-tracesource set-variable sort-object split-path \
+start-service start-sleep start-transcript stop-process stop-service \
+stop-transcript suspend-service tee-object test-path trace-command \
+update-formatdata update-typedata where-object write-debug write-error write-host \
+write-output write-progress write-verbose write-warning
+
+# This keywords are aliases
+keywords3.$(file.patterns.powershell)=\
+ac asnp clc cli clp clv cpi cpp cvpa diff epal epcsv fc fl foreach ft fw gal gc \
+gci gcm gdr ghy gi gl gm gp gps group gsv gsnp gu gv gwmi iex ihy ii ipal ipcsv \
+mi mp nal ndr ni nv oh rdr ri rni rnp rp rsnp rv rvpa sal sasv sc select si sl \
+sleep sort sp spps spsv sv tee where write cat cd clear cp h history kill lp ls \
+mount mv popd ps pushd pwd r rm rmdir echo cls chdir copy del dir erase move rd \
+ren set type
+
+# Comments
+comment.block.powershell=;
+comment.block.at.line.start.powershell=1
+
+# PowerShell Styles
+# White space
+style.powershell.0=fore:#000000
+# Comment
+style.powershell.1=fore:#008000
+# String
+style.powershell.2=fore:#800000
+# Character
+style.powershell.3=fore:#800000
+# Number
+style.powershell.4=fore:#FF0000
+# Variable
+style.powershell.5=fore:#800080
+# Operator
+style.powershell.6=fore:#000000,bold
+# Identifier
+style.powershell.7=$(style.powershell.0)
+# Keyword
+style.powershell.8=fore:#000080,bold
+# Cmdlet
+style.powershell.9=fore:#008080,bold
+# Alias
+style.powershell.10=fore:#008080,italics

Added: trunk/plugins/editor/properties/purebasic.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/purebasic.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,64 @@
+# Define SciTE settings for PureBasic files.
+
+file.patterns.purebasic=*.pb
+
+filter.purebasic=PureBasic (pb)|$(file.patterns.purebasic)|
+
+lexer.$(file.patterns.purebasic)=purebasic
+
+# keywords must be all lowercase
+
+#Language
+keywords.$(file.patterns.purebasic)=and break case continue data \
+datasection declare declarecdll declaredll default deftype dim else \
+elseif end enddatasection endenumeration endif endinterface endprocedure \
+endselect endstructure endstructureunion enumeration extends fakereturn \
+for foreach forever global gosub goto if includebinary includefile \
+includepath interface newlist next or procedure procedurecdll \
+proceduredll procedurereturn protected read repeat restore return select \
+shared static step structure structureunion to until wend while xincludefile
+
+#preprocessor
+keywords2.$(file.patterns.purebasic)=compilercase compilerdefault \
+compilerelse compilerendif compilerendselect compilerif compilerselect
+
+# PB styles
+# Default
+style.purebasic.0=fore:#000000
+# Comment
+style.purebasic.1=$(colour.code.comment.line),$(font.code.comment.line)
+# Number
+style.purebasic.2=$(colour.number)
+# Keyword1
+style.purebasic.3=$(colour.keyword)
+# String
+style.purebasic.4=$(colour.string)
+# Preprocessor
+# style.purebasic.5=$(colour.error)
+# Operator
+style.purebasic.6=$(colour.operator)
+# Identifier
+style.purebasic.7=$(style.purebasic.0)
+# Date
+# style.purebasic.8=$(colour.error)
+# StringEOL
+# style.purebasic.9=$(colour.error)
+# Keyword2
+style.purebasic.10=$(colour.preproc)
+# Keyword3
+style.purebasic.11=$(colour.keyword)
+# Keyword4
+style.purebasic.12=$(colour.keyword)
+# Constant
+style.purebasic.13=$(colour.number)
+# Asm
+# style.purebasic.14=$(colour.error)
+# Label
+style.purebasic.15=$(colour.preproc)
+# Error
+style.purebasic.16=$(colour.error)
+# HexNumber
+style.purebasic.17=$(colour.number)
+# BinNumber
+style.purebasic.18=$(colour.number)
+

Modified: trunk/plugins/editor/properties/python.properties
==============================================================================
--- trunk/plugins/editor/properties/python.properties	(original)
+++ trunk/plugins/editor/properties/python.properties	Sat Nov 15 17:50:33 2008
@@ -1,26 +1,42 @@
 # Define SciTE settings for Python files.
 
-filter.python=Python (py pyw)|*.py;*.pyw|
-
 file.patterns.py=*.py;*.pyw
+file.patterns.scons=SConstruct;SConscript
+
+shbang.python=py
+
+filter.python=Python (py pyw)|$(file.patterns.py)|
 
 lexer.$(file.patterns.py)=python
+lexer.$(file.patterns.scons)=python
 
-keywordclass.python=and assert break class continue def del elif \
+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 yield
+not or pass print raise return try while with yield
 
 keywords.$(file.patterns.py)=$(keywordclass.python)
+keywords.$(file.patterns.scons)=$(keywordclass.python)
+
+# If you uncomment the 3 lines below,
+# and put some words after "keywordclass2.python=",
+# those words will be styled by style.python.14
+
+#keywordclass2.python=
+#keywords2.$(file.patterns.py)=$(keywordclass2.python)
+#keywords2.$(file.patterns.scons)=$(keywordclass2.python)
+
+#~ statement.indent.$(file.patterns.py)=10 :
+statement.indent.$(file.patterns.py)=5 class def elif else except finally \
+for if try while with
+
+statement.lookback.$(file.patterns.py)=0
+block.start.$(file.patterns.py)=
+block.end.$(file.patterns.py)=
 
-statement.indent.*.py=10 :
-statement.end.*.py=
-statement.lookback.*.py=0
-block.start.*.py=
-block.end.*.py=
+view.indentation.examine.*.py=2
 
 tab.timmy.whinge.level=1
 
-#fold.comment.python=1
 #fold.quotes.python=1
 
 comment.block.python=#~
@@ -54,6 +70,10 @@
 style.python.12=fore:#7F7F7F
 # End of line where string is not closed
 style.python.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+# Highlighted identifiers
+style.python.14=fore:#407090
+# Decorators
+style.python.15=fore:#805000
 # Matched Operators
 style.python.34=fore:#0000FF,bold
 style.python.35=fore:#FF0000,bold
@@ -65,9 +85,13 @@
 	command.go.subsystem.*.py=1
 	command.go.*.pyw=pythonw -u "$(FileNameExt)"
 	command.go.subsystem.*.pyw=1
+	command.build.SConscript=scons.bat --up .
+	command.build.SConstruct=scons.bat .
 
 if PLAT_GTK
-	command.go.*.py=python -u $(FileNameExt)
+	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)')"

Added: trunk/plugins/editor/properties/r.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/r.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,59 @@
+# Define SciTE settings for R and S source files
+
+file.patterns.r=*.R;*.rsource;*.S;
+file.patterns.r.like=$(file.patterns.r)
+
+filter.r=R and S+ (R S rsouce)|$(file.patterns.r)|
+
+lexer.$(file.patterns.r)=r
+
+keywordclass.r=if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN
+
+keywords.$(file.patterns.r)=$(keywordclass.r)
+
+keywords2.$(file.patterns.r)=abbreviate abline abs acf acos acosh addmargins aggregate agrep alarm alias alist all anova any aov aperm append apply approx approxfun apropos ar args arima array arrows asin asinh assign assocplot atan atanh attach attr attributes autoload autoloader ave axis backsolve barplot basename beta bindtextdomain binomial biplot bitmap bmp body box boxplot bquote break browser builtins bxp by bzfile c call cancor capabilities casefold cat category cbind ccf ceiling character charmatch chartr chol choose chull citation class close cm cmdscale codes coef coefficients col colnames colors colorspaces colours comment complex confint conflicts contour contrasts contributors convolve cophenetic coplot cor cos cosh cov covratio cpgram crossprod cummax cummin cumprod cumsum curve cut cutree cycle data dataentry date dbeta dbinom dcauchy dchisq de debug debugger decompose delay deltat demo dendrapply density deparse deriv det detach determinant deviance dexp df 
 dfbeta dfbetas dffits dgamma dgeom dget dhyper diag diff diffinv difftime digamma dim dimnames dir dirname dist dlnorm dlogis dmultinom dnbinom dnorm dotchart double dpois dput drop dsignrank dt dump dunif duplicated dweibull dwilcox eapply ecdf edit effects eigen emacs embed end environment eval evalq example exists exp expression factanal factor factorial family fft fifo file filter find fitted fivenum fix floor flush for force formals format formula forwardsolve fourfoldplot frame frequency ftable function gamma gaussian gc gcinfo gctorture get getenv geterrmessage gettext gettextf getwd gl glm globalenv gray grep grey grid gsub gzcon gzfile hat hatvalues hcl hclust head heatmap help hist history hsv httpclient iconv iconvlist identical identify if ifelse image influence inherits integer integrate interaction interactive intersect invisible isoreg jitter jpeg julian kappa kernapply kernel kmeans knots kronecker ksmooth labels lag lapply layout lbeta lchoose lcm legend len
 gth letters levels lfactorial lgamma library licence license line lines list lm load loadhistory loadings local locator loess log logb logical loglin lowess ls lsfit machine mad mahalanobis makepredictcall manova mapply match matlines matplot matpoints matrix max mean median medpolish menu merge message methods mget min missing mode monthplot months mosaicplot mtext mvfft names napredict naprint naresid nargs nchar ncol next nextn ngettext nlevels nlm nls noquote nrow numeric objects offset open optim optimise optimize options order ordered outer pacf page pairlist pairs palette par parse paste pbeta pbinom pbirthday pcauchy pchisq pdf pentagamma person persp pexp pf pgamma pgeom phyper pi pico pictex pie piechart pipe plclust plnorm plogis plot pmatch pmax pmin pnbinom png pnorm points poisson poly polygon polym polyroot postscript power ppoints ppois ppr prcomp predict preplot pretty princomp print prmatrix prod profile profiler proj promax prompt provide psigamma psignran
 k pt ptukey punif pweibull pwilcox q qbeta qbinom qbirthday qcauchy qchisq qexp qf qgamma qgeom qhyper qlnorm qlogis qnbinom qnorm qpois qqline qqnorm qqplot qr qsignrank qt qtukey quantile quarters quasi quasibinomial quasipoisson quit qunif quote qweibull qwilcox rainbow range rank raw rbeta rbind rbinom rcauchy rchisq readline real recover rect reformulate regexpr relevel remove reorder rep repeat replace replicate replications require reshape resid residuals restart return rev rexp rf rgamma rgb rgeom rhyper rle rlnorm rlogis rm rmultinom rnbinom rnorm round row rownames rowsum rpois rsignrank rstandard rstudent rt rug runif runmed rweibull rwilcox sample sapply save savehistory scale scan screen screeplot sd search searchpaths seek segments seq sequence serialize setdiff setequal setwd shell sign signif sin single sinh sink smooth solve sort source spectrum spline splinefun split sprintf sqrt stack stars start stderr stdin stdout stem step stepfun stl stop stopifnot str
  strftime strheight stripchart strptime strsplit strtrim structure strwidth strwrap sub subset substitute substr substring sum summary sunflowerplot supsmu svd sweep switch symbols symnum system t table tabulate tail tan tanh tapply tempdir tempfile termplot terms tetragamma text time title toeplitz tolower topenv toupper trace traceback transform trigamma trunc truncate try ts tsdiag tsp typeof unclass undebug union unique uniroot unix unlink unlist unname unserialize unsplit unstack untrace unz update upgrade url var varimax vcov vector version vi vignette warning warnings weekdays weights which while window windows with write wsbrowser xedit xemacs xfig xinch xor xtabs xyinch yinch zapsmall
+
+keywords3.$(file.patterns.r)=acme aids aircondit amis aml banking barchart barley beaver bigcity boot brambles breslow bs bwplot calcium cane capability cav censboot channing city claridge cloth cloud coal condense contourplot control corr darwin densityplot dogs dotplot ducks empinf envelope environmental ethanol fir frets gpar grav gravity grob hirose histogram islay knn larrows levelplot llines logit lpoints lsegments lset ltext lvqinit lvqtest manaus melanoma melanoma motor multiedit neuro nitrofen nodal ns nuclear oneway parallel paulsen poisons polar qq qqmath remission rfs saddle salinity shingle simplex singer somgrid splom stripplot survival tau tmd tsboot tuna unit urine viewport wireframe wool xyplot
+
+
+word.chars.r=$(chars.alpha)$(chars.numeric)_#
+word.characters.$(file.patterns.r)=$(word.chars.r)
+comment.block.r=#~
+
+statement.indent.$(file.patterns.r.like)=5 for if
+statement.end.$(file.patterns.r.like)=10 ;
+statement.lookback.$(file.patterns.r.like)=20
+block.start.$(file.patterns.r.like)=10 {
+block.end.$(file.patterns.r.like)=10 }
+
+# R styles
+
+# Default
+style.r.32=$(font.base)
+# White space
+style.r.0=fore:#808080
+# Comment
+style.r.1=$(colour.code.comment.box),$(font.code.comment.box)
+#Keyword
+style.r.2=$(colour.keyword),bold
+# Base Package Function
+style.r.3=fore:#7f0000,bold
+# Other Package Function
+style.r.4=fore:#7f007F,bold
+# Number
+style.r.5=$(colour.number)
+# " Delimited String
+style.r.6=$(colour.string)
+# ' Delimited String
+style.r.7=$(colour.string)
+# Operator
+style.r.8=$(colour.operator),bold
+# Identifier
+style.r.9=$(colour.identifier)
+# INFIX highlight
+style.r.10=$(colour.operator),bold
+# INFIX End of Line error
+style.r.11=$(colour.operator),$(font.monospace),back:#E0C0E0,eolfilled
+
+# Braces are only matched in operator style
+braces.r.style=8

Added: trunk/plugins/editor/properties/rebol.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/rebol.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,169 @@
+# Define SciTE settings for REBOL files.
+
+file.patterns.rebol=*.r;*.reb
+
+filter.rebol=REBOL (r)|$(file.patterns.rebol)|
+
+lexer.$(file.patterns.rebol)=rebol
+
+# keywords. Found at http://www.rebol.com/docs/dictionary.html
+keywords.$(file.patterns.rebol)=about abs absolute add \
+alert alias all alter and \
+any any-block? any-function? any-string? any-type? \
+any-word? append arccosine arcsine arctangent \
+array as-pair ask at attempt \
+back binary? bind bitset? block? \
+break brightness? browse build-tag caret-to-offset \
+catch center-face change change-dir char? \
+charset checksum choose clean-path clear \
+clear-fields close comment complement component? \
+compose compress confirm connected? construct \
+context copy cosine datatype? date? \
+debase decimal? decode-cgi decompress dehex \
+delete detab difference dir? dirize \
+disarm dispatch divide do do-events \
+does dump-face dump-obj echo either \
+else email? empty? enbase entab \
+equal? error? even? event? exclude \
+exists? exit exp extract fifth \
+file? find first flash focus \
+for forall foreach forever form \
+forskip found? fourth free func \
+function function? get get-modes get-word? \
+greater-or-equal? greater? halt has hash? \
+head head? help hide hide-popup \
+if image? import-email in in-window? \
+index? info? inform input input? \
+insert integer? intersect issue? join \
+last launch layout length? lesser-or-equal? \
+lesser? library? license link? list-dir \
+list? lit-path? lit-word? load load-image \
+log-10 log-2 log-e logic? loop \
+lowercase make make-dir make-face max \
+maximum maximum-of min minimum minimum-of \
+modified? mold money? multiply native? \
+negate negative? next none? not \
+not-equal? now number? object? odd? \
+offset-to-caret offset? op? open or \
+pair? paren? parse parse-xml path? \
+pick poke port? positive? power \
+prin print probe protect protect-system \
+query quit random read read-io \
+recycle reduce refinement? reform rejoin \
+remainder remold remove remove-each rename \
+repeat repend replace request request-color \
+request-date request-download request-file request-list request-pass \
+request-text resend return reverse routine? \
+same? save script? second secure \
+select send series? set set-modes \
+set-net set-path? set-word? show show-popup \
+sign? sine size-text size? skip \
+sort source span? split-path square-root \
+strict-equal? strict-not-equal? string? struct? stylize \
+subtract suffix? switch tag? tail \
+tail? tangent third throw time? \
+to to-binary to-bitset to-block to-char \
+to-date to-decimal to-email to-file to-get-word \
+to-hash to-hex to-idate to-image to-integer \
+to-issue to-list to-lit-path to-lit-word to-local-file \
+to-logic to-money to-pair to-paren to-path \
+to-rebol-file to-refinement to-set-path to-set-word to-string \
+to-tag to-time to-tuple to-url to-word \
+trace trim try tuple? type? \
+unfocus union unique unprotect unset \
+unset? until unview update upgrade \
+uppercase url? usage use value? \
+view viewed? wait what what-dir \
+while within? word? write write-io xor zero? 
+
+# test functions
+keywords2.$(file.patterns.rebol)=action? any-block? any-function? any-string? \
+any-type? any-word? binary? bitset? block? char? component? connected? \
+datatype? date? decimal? dir? email? empty? equal? error? even? event? exists? \
+file? found? function? get-word? greater-or-equal greater? hash? head? image? \
+index? info? input? integer? issue? length? lesser-or-equal? lesser? library? \
+link-app? link? list? lit-path? lit-word? logic? modified? money? native? negative? \
+none? not-equal? number? object? odd? offset? op? pair? paren? path? port? \
+positive? rebol-command? rebol-encap? rebol-link? rebol-pro? rebol-view? \
+refinement? routine? same? script? series? set-path? set-word? sign? size? \
+strict-equal? strict-not-equal string? struct? suffix? tag? tail? time? tuple? type? \
+unset? url? value? view? word? zero?
+
+# types
+keywords3.$(file.patterns.rebol)=action! any-block! any-function! any-string! any-type! \
+ any-word! binary! bitset! block! char! datatype! date! decimal! email! error! \
+ event! file! function! get-word! hash! image! integer! issue! library! list! lit-path! \
+ lit-word! logic! money! native! none! number! object! op! pair! paren! path! \
+ port! refinement! routine! series! set-path! set-word! string! struct! symbol! tag! \
+ time! tuple! unset! url! word!
+
+word.chars.rebol=$(chars.alpha)$(chars.numeric)?!.’+-*&|=_~
+word.characters.$(file.patterns.rebol)=$(word.chars.rebol)
+
+comment.block.rebol=;
+comment.box.start.rebol=;;
+comment.box.middle.rebol=;;
+comment.box.end.rebol=;;
+
+# REBOL styles
+
+# Default
+style.rebol.32=$(font.base)
+# Any other text
+style.rebol.0=fore:#000000,bold
+# Line Comment
+style.rebol.1=$(colour.code.comment.box),$(font.code.comment.box)
+# Block Comment ( comment {the text} )
+style.rebol.2=$(colour.code.comment.box),$(font.code.comment.box)
+# Preface (text before the REBOL header)
+style.rebol.3=$(colour.code.comment.box),$(font.code.comment.box),bold
+# Operators
+style.rebol.4=$(colour.operator),bold
+# Characters ( #"a" )
+style.rebol.5=$(colour.string)
+# String with quotes
+style.rebol.6=$(colour.string)
+# String with braces
+style.rebol.7=$(colour.string)
+# Number
+style.rebol.8=$(colour.number)
+# Pair ( 800x600 )
+style.rebol.9=fore:#005090
+# Tuple ( 127.0.0.1 )
+style.rebol.10=fore:#005090
+# Binary ( 16#{1A803F59} )
+style.rebol.11=fore:#C000C0
+# Money
+style.rebol.12=fore:#003070
+# Issue { #123-CD-456 }
+style.rebol.13=fore:#800000
+# Tag { <TITLE height=100> }
+style.rebol.14=fore:#C00000
+# File { %/C/Winnt/some.dll }
+style.rebol.15=fore:#0080FF
+# Email { joe mail dom }
+style.rebol.16=fore:#0080FF
+# URL { ftp://there.dom }
+style.rebol.17=fore:#0080FF
+# Date { 17-Feb-2004 1/3/99 }
+style.rebol.18=fore:#8000FF
+# Time { 12:30 11:22:59 01:59:59.123 }
+style.rebol.19=fore:#8000FF
+
+# Identifiers
+style.rebol.20=
+# Keyword (all)
+style.rebol.21=$(colour.keyword),bold
+# Keyword (test functions)
+style.rebol.22=fore:#8000C0,bold
+# Keyword (datatypes)
+style.rebol.23=fore:#800060,bold
+
+# Matched Operators
+style.rebol.34=fore:#0000FF,bold
+style.rebol.35=fore:#FF0000,bold
+# Braces are only matched in default style
+braces.rebol.style=0
+
+command.go.$(file.patterns.rebol)=E:\tools\lang\rebol\core\rebol.exe $(FilePath)
+

Modified: trunk/plugins/editor/properties/ruby.properties
==============================================================================
--- trunk/plugins/editor/properties/ruby.properties	(original)
+++ trunk/plugins/editor/properties/ruby.properties	Sat Nov 15 17:50:33 2008
@@ -1,53 +1,97 @@
 # Define SciTE settings for Ruby files.
 
-filter.ruby=Ruby (rb)|*.rb|
+file.patterns.rb=*.rb;*.rbw;*.rake;Rakefile
 
-lexer.*.rb=ruby
+shbang.ruby=rb
 
-file.patterns.rb=*.rb
+filter.ruby=Ruby (rb rbw)|$(file.patterns.rb)|
+
+lexer.$(file.patterns.rb)=ruby
 
 keywordclass.ruby=__FILE__ and def end in or self unless __LINE__ begin \
 defined? ensure module redo super until BEGIN break do false next rescue \
-then when END case else for nil require retry true while alias class elsif if \
+then when END case else for nil retry true while alias class elsif if \
 not return undef yield
 keywords.$(file.patterns.rb)=$(keywordclass.ruby)
 
-statement.indent.*.rb=
-statement.end*.rb=
-statement.lookback.*.rb=1
-block.start.*.rb=10
+statement.indent.$(file.patterns.rb)=5 def class if do elsif else case while for
+
+block.start.$(file.patterns.rb)=5 do
+block.end.$(file.patterns.rb)=5 end
+
+indent.opening.$(file.patterns.rb)=1
+indent.closing.$(file.patterns.rb)=1
 
 comment.block.ruby=#~
 
 # ruby styles
 # White space
 style.ruby.0=fore:#808080
-# Comment
-style.ruby.1=fore:#007F00,$(font.comment)
+# Error
+style.ruby.1=back:#FF0000
+# Comment line
+style.ruby.2=fore:#007F00,$(font.comment)
+# POD
+style.ruby.3=fore:#004000,back:#C0FFC0,$(font.monospace),eolfilled
 # Number
-style.ruby.2=fore:#007F7F
-# String
-style.ruby.3=fore:#7F007F,$(font.monospace)
-# Single quoted string
-style.ruby.4=fore:#7F007F,$(font.monospace)
-# Keyword
+style.ruby.4=fore:#007F7F
+# Word
 style.ruby.5=fore:#00007F,bold
-# Triple quotes
-# style.ruby.6=fore:#7F0000
-# Triple double quotes
-style.ruby.7=fore:#7F0000
-# Class name definition
+# String
+style.ruby.6=fore:#7F007F,$(font.monospace)
+# Character
+style.ruby.7=fore:#7F007F,$(font.monospace)
+# Class name
 style.ruby.8=fore:#0000FF,bold
-# Function or method name definition
+# Def name
 style.ruby.9=fore:#007F7F,bold
-# Operators
+# Operator
 style.ruby.10=bold
-# Identifiers
-style.ruby.11=fore:#7F7F7F
-# Comment-blocks
-style.ruby.12=fore:#7F7F7F
-# End of line where string is not closed
-style.ruby.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+# Identifier
+style.ruby.11=
+# Regex
+style.ruby.12=fore:#000000,back:#A0FFA0
+# Global
+style.ruby.13=fore:#800080
+# Symbol
+style.ruby.14=fore:#C0A030
+# MODULE_NAME
+style.ruby.15=fore:#A000A0,bold
+# INSTANCE_VAR
+style.ruby.16=fore:#B00080
+# CLASS_VAR
+style.ruby.17=fore:#8000B0
+# BACKTICKS
+style.ruby.18=fore:#FFFF00,back:#A08080
+# DATASECTION
+style.ruby.19=fore:#600000,back:#FFF0D8,eolfilled
+# HERE_DELIM
+style.ruby.20=fore:#000000,back:#DDD0DD
+# HERE_Q
+style.ruby.21=fore:#7F007F,back:#DDD0DD,eolfilled,notbold
+# HERE_QQ
+style.ruby.22=fore:#7F007F,back:#DDD0DD,eolfilled,bold
+# HERE_QX
+style.ruby.23=fore:#7F007F,back:#DDD0DD,eolfilled,italics
+# STRING_Q
+style.ruby.24=fore:#7F007F,$(font.monospace),notbold
+# STRING_QQ
+style.ruby.25=$(colour.string),$(font.monospace)
+# STRING_QX
+style.ruby.26=fore:#FFFF00,back:#A08080
+# STRING_QR
+style.ruby.27=fore:#000000,back:#A0FFA0
+# STRING_QW
+style.ruby.28=fore:#000000,back:#FFFFE0
+# Demoted Keyword
+style.ruby.29=$(style.ruby.5)
+# STDIN
+style.ruby.30=back:#FF8080
+# STDOUT
+style.ruby.31=back:#FF8080
+# STDERR
+style.ruby.40=back:#FF8080
+
 # Matched Operators
 style.ruby.34=fore:#0000FF,bold
 style.ruby.35=fore:#FF0000,bold
@@ -57,6 +101,16 @@
 if PLAT_WIN
 	command.go.*.rb=ruby $(FileNameExt)
 	command.go.subsystem.*.rb=1
+	command.go.*.rbw=rubyw $(FileNameExt)
+	command.go.subsystem.*.rbw=1
+	command.help.*.rb=$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
+	command.help.subsystem.*.rb=4
 
 if PLAT_GTK
 	command.go.*.rb=ruby $(FileNameExt)
+
+	command.name.1.*.rb=Check Syntax
+	command.1.*.rb=ruby -cw $(FileNameExt)
+
+	command.name.2.*.rb=Code Profiler
+	command.2.*.rb=ruby -r profile $(FileNameExt)

Modified: trunk/plugins/editor/properties/scriptol.properties
==============================================================================
--- trunk/plugins/editor/properties/scriptol.properties	(original)
+++ trunk/plugins/editor/properties/scriptol.properties	Sat Nov 15 17:50:33 2008
@@ -22,22 +22,21 @@
 keywords.$(file.patterns.sol)=$(keywordclass.scriptol)
 
 statement.indent.*.sol=
-statement.end*.sol=
 statement.lookback.*.sol=1
 block.start.*.sol=10
 
 comment.block.scriptol=`~
 
 # scriptol styles
-# Default 
+# Default
 style.scriptol.0=fore:#000000
 # White space
 style.scriptol.1=fore:#808080
-# Scriptol style comment line 
+# Scriptol style comment line
 style.scriptol.2=fore:#007F00,$(font.comment)
-# Persistent comment line 
+# Persistent comment line
 style.scriptol.3=fore:#007F00,$(font.comment)
-# C style comment line 
+# C style comment line
 style.scriptol.4=fore:#007F00
 # Comment-blocks
 style.scriptol.5=fore:#007F00,$(font.comment)
@@ -69,7 +68,7 @@
 
 if PLAT_GTK
         command.help.$(file.patterns.sol)=man $(CurrentWord) | col -b
-	
+
 command.compile.*.sol=solc -c $(FileNameExt)
 command.build.*.sol=solc -be $(FileNameExt)
 command.go.*.sol=$(FileName)

Added: trunk/plugins/editor/properties/smalltalk.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/smalltalk.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,47 @@
+# Define SciTE settings for Smalltalk files.
+
+file.patterns.smalltalk=*.st
+
+filter.smalltalk=Smalltalk (.st)|$(file.patterns.smalltalk)|
+
+lexer.$(file.patterns.smalltalk)=smalltalk
+
+keywords.$(file.patterns.smalltalk)=\
+    ifTrue: ifFalse: whileTrue: whileFalse: ifNil: ifNotNil: whileTrue whileFalse repeat isNil notNil
+
+# Styles
+
+# Default
+style.smalltalk.0=
+# String
+style.smalltalk.1=$(colour.string),eolfilled
+# Number
+style.smalltalk.2=$(colour.number)
+# Comment
+style.smalltalk.3=$(colour.code.comment.box)
+# Symbol
+style.smalltalk.4=fore:#800080
+# Binary
+style.smalltalk.5=$(colour.operator)
+# Boolean
+style.smalltalk.6=$(colour.keyword),bold
+# self
+style.smalltalk.7=$(colour.keyword),bold
+# super
+style.smalltalk.8=$(colour.keyword),bold
+# nil
+style.smalltalk.9=$(colour.keyword),bold
+# Global
+style.smalltalk.10=bold
+# Return
+style.smalltalk.11=fore:#A00000,bold
+# Special
+style.smalltalk.12=bold
+# KwSend
+style.smalltalk.13=fore:#008000
+# Assignment
+style.smalltalk.14=bold
+# Character
+style.smalltalk.15=$(colour.char)
+# Special selector
+style.smalltalk.16=$(colour.keyword),bold
\ No newline at end of file

Modified: trunk/plugins/editor/properties/specman.properties
==============================================================================
--- trunk/plugins/editor/properties/specman.properties	(original)
+++ trunk/plugins/editor/properties/specman.properties	Sat Nov 15 17:50:33 2008
@@ -6,8 +6,6 @@
 filter.specman=Specman (e)|\
 $(file.patterns.specman)|
 
-file.patterns.braces=$(file.patterns.specman)
-
 lexer.$(file.patterns.specman)=specman
 
 keywords.$(file.patterns.specman)= \
@@ -100,15 +98,10 @@
 comment.box.middle.specman=
 comment.box.end.specman=
 
-fold.comment=1
-fold.preprocessor=1
-fold.at.else=1
-
 #~ statement.indent.$(file.patterns.specman)=5  if else try \
 #~ case casex casez default \
 #~ until repeat while for do \
 #~ struct unit extend when
-#~ statement.end.$(file.patterns.specman)=10 ;
 #~ statement.lookback.$(file.patterns.specman)=20
 #~ block.start.$(file.patterns.specman)=10 {
 #~ block.end.$(file.patterns.specman)=10 }

Added: trunk/plugins/editor/properties/spice.properties
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/properties/spice.properties	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,76 @@
+# Define SciTE settings for spice files.
+
+file.patterns.spice=*.scp;*.out
+filter.spice=Spice (out scp)|$(file.patterns.spice)|
+lexer.$(file.patterns.spice)=spice
+
+#indent.size.$(file.patterns.spice)=3
+#use.tabs.$(file.patterns.spice)=0
+
+# Keyword for script commands
+keywordclass.spice.command=\
+ac  alias  alter  alterparam append askvalues assertvalid autoscale \
+break compose copy copytodoc dc  delete  destroy  destroyvec diff  display \
+disto  dowhile  echo  else  end  errorstop  fftinit filter foreach  fourier \
+freqtotime function  functionundef goto  homecursors if isdisplayed label \
+let  linearize listing  load  loadaccumulator makelabel movelabel makesmithplot \
+movecursorleft movecursorright  msgbox nameplot  newplot nextparam noise \
+nopoints  op plot plotf plotref poly print  printcursors  printevent printname \
+printplot printstatus printtext printtol printunits printval printvector \
+pwl  pz  quit  removesmithplot rename repeat  resume  rotate  runs rusage \
+save sendplot sendscript sens  set  setcursor setdoc setlabel setlabeltype \
+setmargins setnthtrigger  setunits setvec setparam setplot  setquery \
+setscaletype settracecolor settracestyle setsource settrigger  setvec \
+setxlimits setylimits show  showmod  sort status  step  stop  switch \
+tf  timetofreq  timetowave tran  unalias  unlet  unset  unalterparam \
+update version view   wavefilter  wavetotime where  while  write
+# Keywords for script functions
+keywordclass.spice.functions=\
+abs askvalue atan average ceil cos db differentiate differentiatex \
+exp finalvalue floor getcursorx getcursory getcursory0 getcursory1 \
+getparam im ln initialvalue integrate integratex interpolate isdef \
+isdisplayed j log length mag, max maxscale mean meanpts min minscale \
+nextplot  nextvector  norm operatingpoint ph phase phaseextend pk_pk \
+pos pulse re rms rmspts rnd sameplot  sin sqrt stddev stddevpts tan \
+tfall tolerance trise unitvec vector
+# Keywords for spice parameters
+keywordclass.spice.params=param nodeset include options dcconv subckt ends model
+
+
+keywordclass.spice=$(keywordclass.spice.command) $(keywordclass.spice.functions) $(keywordclass.spice.params)
+
+keywords.$(file.patterns.spice)=$(keywordclass.spice.command)
+keywords2.$(file.patterns.spice)=$(keywordclass.spice.functions)
+keywords3.$(file.patterns.spice)=$(keywordclass.spice.params)
+
+# spice styles
+# Default
+style.spice.0=fore:#808080
+# Identifiers
+style.spice.1=
+# Keyword
+style.spice.2=$(colour.keyword)
+# Keyword2
+style.spice.3=$(colour.keyword),bold
+# Keyword3
+style.spice.4=fore:#0040E0
+# Number
+style.spice.5=$(colour.number)
+# Operators (delimiters)
+style.spice.6=$(colour.operator),bold
+# Value
+style.spice.7=$(colour.char)
+# Comment
+style.spice.8=$(colour.code.comment.line),$(font.code.comment.line)
+
+# Comments
+comment.block.spice=*~
+
+braces.spice.style=4
+
+statement.indent.$(file.patterns.spice)=5 begin declare else elsif exception for if is loop while
+statement.lookback.$(file.patterns.spice)=20
+block.start.$(file.patterns.spice)=10 then is
+block.end.$(file.patterns.spice)=10 end
+
+calltip.spice.word.characters=._$(chars.alpha)

Modified: trunk/plugins/editor/properties/sql.properties
==============================================================================
--- trunk/plugins/editor/properties/sql.properties	(original)
+++ trunk/plugins/editor/properties/sql.properties	Sat Nov 15 17:50:33 2008
@@ -25,18 +25,37 @@
 style.sql.6=fore:#7F007F,$(font.monospace)
 # Single quoted string
 style.sql.7=fore:#7F007F,$(font.monospace)
-# Symbols
-style.sql.8=fore:#007F7F
-# Preprocessor
-style.sql.9=fore:#7F7F00
+# SQL*Plus
+style.sql.8=$(colour.preproc)
+# SQL*Plus PROMPT
+style.sql.9=fore:#007F00,$(font.monospace),back:#E0FFE0,eolfilled
 # Operators
 style.sql.10=bold
 # Identifiers
 style.sql.11=
-# End of line where string is not closed
+# End of line where string is not closed / not used
 style.sql.12=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+# SQL*Plus Comment
+style.sql.13=fore:#007F00,$(font.comment)
+# not used
+# style.sql.14=
 # Hash Line Comment
 style.sql.15=fore:#007F00,$(font.comment)
+# Keywords2: Database objects
+style.sql.16=fore:#B00040
+# Comment Doc Keyword
+style.sql.17=fore:#3060A0,$(font.code.comment.doc)
+# Comment Doc Keyword Error
+style.sql.18=fore:#804020,$(font.code.comment.doc)
+# Keywords5: User Keywords 1
+style.sql.19=fore:#4B0082
+# Keywords6: User Keywords 2
+style.sql.20=fore:#B00040
+# Keywords7: User Keywords 3
+style.sql.21=fore:#8B0000
+# Keywords8: User Keywords 4
+style.sql.22=fore:#800080
+
 # Braces are only matched in operator style
 braces.sql.style=10
 # Enables backslash as an escape character
@@ -118,3 +137,33 @@
 varchar2 variance view when whenever where while with work write \
 year zone
 
+# Keywords for PlDoc comments
+keywords3.$(file.patterns.sql)=\
+param author since return see deprecated todo
+
+# Keywords for SQL*Plus
+keywords4.$(file.patterns.sql)=\
+acc~ept a~ppend archive log attribute \
+bre~ak bti~tle \
+c~hange cl~ear col~umn comp~ute conn~ect copy \
+def~ine del desc~ribe disc~onnect \
+e~dit exec~ute exit \
+get \
+help ho~st \
+i~nput \
+l~ist \
+passw~ord pau~se pri~nt pro~mpt \
+quit \
+recover rem~ark repf~ooter reph~eader r~un \
+sav~e set sho~w shutdown spo~ol sta~rt startup store \
+timi~ng tti~tle \
+undef~ine \
+var~iable \
+whenever oserror whenever sqlerror \
+
+# User keywords 1
+# Keywords for Standard packages
+keywords5.$(file.patterns.sql)=\
+dbms_output.disable dbms_output.enable dbms_output.get_line \
+dbms_output.get_lines dbms_output.new_line dbms_output.put \
+dbms_output.put_line \

Modified: trunk/plugins/editor/properties/tcl.properties
==============================================================================
--- trunk/plugins/editor/properties/tcl.properties	(original)
+++ trunk/plugins/editor/properties/tcl.properties	Sat Nov 15 17:50:33 2008
@@ -1,123 +1,154 @@
 # Define SciTE settings for tcl and itcl files.
-# The tcl lexer is currently just an alias of the cpp lexer and does not really
-# understand TCL syntax
 
-filter.tcl=Tcl (tcl)|*.tcl|
-
-lexer.*.tcl=tcl
-
-filter.itcl=itcl (.itcl)|*.itcl|
-
-lexer.*.itcl=tcl
-
-preprocessor.symbol.*.tcl=
-preprocessor.start.*.tcl=
-preprocessor.middle.*.tcl=
-preprocessor.end.*.tcl=
-
-keywordclass.tcl=after append array auto_execok auto_import auto_load \
-auto_load_index auto_qualify beep binary break case catch cd clock \
-close concat continue dde default echo else elseif encoding eof \
-error eval exec exit expr fblocked fconfigure fcopy file \
-fileevent flush for foreach format gets glob global history if \
-incr info interp join lappend lindex linsert list llength load \
-lrange lreplace lsearch lsort namespace open package pid \
-pkg_mkIndex proc puts pwd read regexp regsub rename resource \
-return scan seek set socket source split string subst switch \
-tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell time \
-trace unknown unset update uplevel upvar variable vwait while
-
-keywordclass.tk=bell bind bindtags button canvas checkbutton console \
-destroy entry event focus font frame grab grid image label listbox menu \
-menubutton message pack place radiobutton raise scale scrollbar \
-text tk tkwait toplevel winfo wm
+file.patterns.tcl=*.tcl;*.exp
+file.patterns.itcl=*.itcl
+file.patterns.tcl.like=$(file.patterns.tcl);$(file.patterns.itcl);
+
+filter.tcl=Tcl (tcl)|$(file.patterns.tcl)|
+filter.itcl=itcl (itcl)|$(file.patterns.itcl)|
+
+lexer.$(file.patterns.tcl)=tcl
+lexer.$(file.patterns.itcl)=tcl
+
+keywordclass.tcl=after append array auto_execok \
+auto_import auto_load auto_load_index auto_qualify \
+beep bgerror binary break case catch cd clock \
+close concat continue dde default echo else elseif \
+encoding eof error eval exec exit expr fblocked \
+fconfigure fcopy file fileevent flush for foreach format \
+gets glob global history http if incr info \
+interp join lappend lindex linsert list llength load \
+loadTk lrange lreplace lsearch lset lsort memory msgcat \
+namespace open package pid pkg::create pkg_mkIndex Platform-specific proc \
+puts pwd re_syntax read regexp registry regsub rename \
+resource return scan seek set socket source split \
+string subst switch tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell \
+time trace unknown unset update uplevel upvar variable \
+vwait while
+
+keywordclass.tk=bell bind bindtags bitmap button canvas checkbutton clipboard \
+colors console cursors destroy entry event focus font \
+frame grab grid image Inter-client keysyms label labelframe \
+listbox lower menu menubutton message option options pack \
+panedwindow photo place radiobutton raise scale scrollbar selection \
+send spinbox text tk tk_chooseColor tk_chooseDirectory tk_dialog tk_focusNext \
+tk_getOpenFile tk_messageBox tk_optionMenu tk_popup tk_setPalette tkerror tkvars tkwait \
+toplevel winfo wish wm
 
 keywordclass itcl= scope body class code common component configbody \
 constructor define destructor hull import inherit itcl itk itk_component \
 itk_initialize itk_interior itk_option iwidgets keep method \
 private protected public
 
-keywordclass.TkCommands=tkButtonDown tkButtonEnter tkButtonInvoke \
-tkButtonLeave tkButtonUp tkCancelRepeat tkCheckRadioInvoke tkDarken \
-tkEntryAutoScan 	tkEntryBackspace tkEntryButton1 tkEntryClosestGap \
-tkEntryInsert tkEntryKeySelect tkEntryMouseSelect tkEntryNextWord \
-tkEntryPaste tkEntryPreviousWord tkEntrySeeInsert tkEntrySetCursor \
-tkEntryTranspose tkEventMotifBindings tkFDGetFileTypes tkFirstMenu \
-tkFocusGroup_Destroy tkFocusGroup_In tkFocusGroup_Out tkFocusOK \
-tkListboxAutoScan tkListboxBeginExtend tkListboxBeginSelect \
-tkListboxBeginToggle tkListboxCancel tkListboxDataExtend \
-tkListboxExtendUpDown tkListboxMotion tkListboxSelectAll \
-tkListboxUpDown tkMbButtonUp tkMbEnter tkMbLeave tkMbMotion \
-tkMbPost tkMenuButtonDown tkMenuDownArrow tkMenuDup tkMenuEscape \
-tkMenuFind tkMenuFindName tkMenuFirstEntry tkMenuInvoke tkMenuLeave \
-tkMenuLeftArrow tkMenuMotion tkMenuNextEntry tkMenuNextMenu \
-tkMenuRightArrow tkMenuUnpost tkMenuUpArrow tkMessageBox \
-tkPostOverPoint tkRecolorTree tkRestoreOldGrab tkSaveGrabInfo \
-tkScaleActivate tkScaleButton2Down tkScaleButtonDown \
-tkScaleControlPress tkScaleDrag tkScaleEndDrag tkScaleIncrement \
-tkScreenChanged tkScrollButton2Down tkScrollButtonDown \
-tkScrollButtonUp tkScrollByPages tkScrollByUnits tkScrollDrag \
-tkScrollEndDrag tkScrollSelect tkScrollStartDrag tkScrollToPos  \
-tkScrollTopBottom tkTabToWindow tkTearOffMenu tkTextAutoScan \
-tkTextButton1 tkTextClosestGap tkTextInsert tkTextKeyExtend \
-tkTextKeySelect tkTextNextPara tkTextNextPos tkTextNextWord \
-tkTextPaste tkTextPrevPara tkTextPrevPos tkTextResetAnchor \
-tkTextScrollPages tkTextSelectTo tkTextSetCursor tkTextTranspose \
-tkTextUpDownLine tkTraverseToMenu tkTraverseWithinMenu tk_bisque \
-tk_chooseColor tk_dialog tk_focusFollowsMouse tk_focusNext \
-tk_focusPrev tk_getOpenFile tk_getSaveFile tk_messageBox \
-tk_optionMenu tk_popup tk_setPalette tk_textCopy tk_textCut \
-tk_textPaste
-
-keywords.*.tcl=$(keywordclass.tcl) $(keywordclass.tk) $(keywordclass.TkCommands)
-
-keywords.*.itcl=$(keywordclass.tcl) $(keywordclass.tk) $(keywordclass.itcl) \
-$(keywordclass.TkCommands)
-
-#statement.indent.*.tcl=4 switch catch class default do else for if \
-#try while
-statement.end.*.tcl=8  ;
-statement.lookback.*.tcl=1
-block.start.*.tcl=4 {
-block.end.*.tcl=4 }
+keywordclass.TkCommands=tk_bisque tk_chooseColor tk_dialog tk_focusFollowsMouse tk_focusNext \
+tk_focusPrev tk_getOpenFile tk_getSaveFile tk_messageBox tk_optionMenu \
+tk_popup tk_setPalette tk_textCopy tk_textCut tk_textPaste \
+tkButtonAutoInvoke tkButtonDown tkButtonEnter tkButtonInvoke tkButtonLeave \
+tkButtonUp tkCancelRepeat tkCheckRadioDown tkCheckRadioEnter tkCheckRadioInvoke \
+tkColorDialog tkColorDialog_BuildDialog tkColorDialog_CancelCmd tkColorDialog_Config tkColorDialog_CreateSelector \
+tkColorDialog_DrawColorScale tkColorDialog_EnterColorBar tkColorDialog_HandleRGBEntry tkColorDialog_HandleSelEntry tkColorDialog_InitValues \
+tkColorDialog_LeaveColorBar tkColorDialog_MoveSelector tkColorDialog_OkCmd tkColorDialog_RedrawColorBars tkColorDialog_RedrawFinalColor \
+tkColorDialog_ReleaseMouse tkColorDialog_ResizeColorBars tkColorDialog_RgbToX tkColorDialog_SetRGBValue tkColorDialog_StartMove \
+tkColorDialog_XToRgb tkConsoleAbout tkConsoleBind tkConsoleExit tkConsoleHistory \
+tkConsoleInit tkConsoleInsert tkConsoleInvoke tkConsoleOutput tkConsolePrompt \
+tkConsoleSource tkDarken tkEntryAutoScan tkEntryBackspace tkEntryButton1 \
+tkEntryClosestGap tkEntryGetSelection tkEntryInsert tkEntryKeySelect tkEntryMouseSelect \
+tkEntryNextWord tkEntryPaste tkEntryPreviousWord tkEntrySeeInsert tkEntrySetCursor \
+tkEntryTranspose tkEventMotifBindings tkFDGetFileTypes tkFirstMenu tkFocusGroup_BindIn \
+tkFocusGroup_BindOut tkFocusGroup_Create tkFocusGroup_Destroy tkFocusGroup_In tkFocusGroup_Out \
+tkFocusOK tkGenerateMenuSelect tkIconList tkIconList_Add tkIconList_Arrange \
+tkIconList_AutoScan tkIconList_Btn1 tkIconList_Config tkIconList_Create tkIconList_CtrlBtn1 \
+tkIconList_Curselection tkIconList_DeleteAll tkIconList_Double1 tkIconList_DrawSelection tkIconList_FocusIn \
+tkIconList_FocusOut tkIconList_Get tkIconList_Goto tkIconList_Index tkIconList_Invoke \
+tkIconList_KeyPress tkIconList_Leave1 tkIconList_LeftRight tkIconList_Motion1 tkIconList_Reset \
+tkIconList_ReturnKey tkIconList_See tkIconList_Select tkIconList_Selection tkIconList_ShiftBtn1 \
+tkIconList_UpDown tkListbox tkListboxAutoScan tkListboxBeginExtend tkListboxBeginSelect \
+tkListboxBeginToggle tkListboxCancel tkListboxDataExtend tkListboxExtendUpDown tkListboxKeyAccel_Goto \
+tkListboxKeyAccel_Key tkListboxKeyAccel_Reset tkListboxKeyAccel_Set tkListboxKeyAccel_Unset tkListboxMotion \
+tkListboxSelectAll tkListboxUpDown tkMbButtonUp tkMbEnter tkMbLeave \
+tkMbMotion tkMbPost tkMenuButtonDown tkMenuDownArrow tkMenuDup \
+tkMenuEscape tkMenuFind tkMenuFindName tkMenuFirstEntry tkMenuInvoke \
+tkMenuLeave tkMenuLeftArrow tkMenuMotion tkMenuNextEntry tkMenuNextMenu \
+tkMenuRightArrow tkMenuUnpost tkMenuUpArrow tkMessageBox tkMotifFDialog \
+tkMotifFDialog_ActivateDList tkMotifFDialog_ActivateFEnt tkMotifFDialog_ActivateFList tkMotifFDialog_ActivateSEnt tkMotifFDialog_BrowseDList \
+tkMotifFDialog_BrowseFList tkMotifFDialog_BuildUI tkMotifFDialog_CancelCmd tkMotifFDialog_Config tkMotifFDialog_Create \
+tkMotifFDialog_FileTypes tkMotifFDialog_FilterCmd tkMotifFDialog_InterpFilter tkMotifFDialog_LoadFiles tkMotifFDialog_MakeSList \
+tkMotifFDialog_OkCmd tkMotifFDialog_SetFilter tkMotifFDialog_SetListMode tkMotifFDialog_Update tkPostOverPoint \
+tkRecolorTree tkRestoreOldGrab tkSaveGrabInfo tkScaleActivate tkScaleButton2Down \
+tkScaleButtonDown tkScaleControlPress tkScaleDrag tkScaleEndDrag tkScaleIncrement \
+tkScreenChanged tkScrollButton2Down tkScrollButtonDown tkScrollButtonDrag tkScrollButtonUp \
+tkScrollByPages tkScrollByUnits tkScrollDrag tkScrollEndDrag tkScrollSelect \
+tkScrollStartDrag tkScrollTopBottom tkScrollToPos tkTabToWindow tkTearOffMenu \
+tkTextAutoScan tkTextButton1 tkTextClosestGap tkTextInsert tkTextKeyExtend \
+tkTextKeySelect tkTextNextPara tkTextNextPos tkTextNextWord tkTextPaste \
+tkTextPrevPara tkTextPrevPos tkTextPrevWord tkTextResetAnchor tkTextScrollPages \
+tkTextSelectTo tkTextSetCursor tkTextTranspose tkTextUpDownLine tkTraverseToMenu \
+tkTraverseWithinMenu
+
+keywords.$(file.patterns.tcl.like)=$(keywordclass.tcl) 
+keywords2.$(file.patterns.tcl.like)=$(keywordclass.tk)
+keywords3.$(file.patterns.tcl.like)= $(keywordclass.TkCommands)
+keywords4.$(file.patterns.itcl)=$(keywordclass.itcl) 
+keywords5.$(file.patterns.tcl.like)=expand
 
-#none of this has any effect, I guess a custom lexer would be needed
 comment.block.tcl=#~
+# also suported is #- for start/end of box, box.middle # can be in column 1
 comment.box.start.tcl=##
 comment.box.middle.tcl= #
 comment.box.end.tcl= ##
 
 # tcl styles
+# Default
+style.tcl.32=$(font.base)
 # White space
 style.tcl.0=fore:#808080
-# Comment
-style.tcl.1=fore:#007F00,$(font.comment)
-# Number
-style.tcl.2=fore:#007F7F
-# String
-style.tcl.3=fore:#7F007F,$(font.monospace)
-# Single quoted string
-style.tcl.4=fore:#7F007F,$(font.monospace)
-# Keyword
-style.tcl.5=fore:#00007F,bold
-# Triple quotes
-style.tcl.6=fore:#7F0000
-# Triple double quotes
-style.tcl.7=fore:#7F0000
-# Class name definition
-style.tcl.8=fore:#0000FF,bold
-# Function or method name definition
-style.tcl.9=fore:#007F7F,bold
-# Operators
-style.tcl.10=bold
+# Comment:.....; #comment
+style.tcl.1=$(colour.code.comment.line),$(font.comment),back:#f0FFE0
+# Line Comment:  #comment
+style.tcl.2=$(colour.code.comment.line),$(font.code.comment.line)
+# Number and hex number (syntax #[0-f]+)
+style.tcl.3=$(colour.number)
+# Keyword in quote
+style.tcl.4=$(colour.string),bold,back:#FFF0F0
+# In quote
+style.tcl.5=$(colour.string),back:#FFf0f0,eolfilled
+# operator
+style.tcl.6=$(colour.operator),bold
 # Identifiers
-style.tcl.11=
-# Comment-blocks
-style.tcl.12=fore:#7F7F7F
-# End of line where string is not closed
-style.tcl.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
+style.tcl.7=$(colour.keyword)
+# Substitution
+style.tcl.8=$(colour.preproc)
+# Substitution starts with a brace ${woow}
+style.tcl.9=$(colour.preproc),back:#effff0
+# Modifier -xxx
+style.tcl.10=$(colour.char)
+# Expand (what and odd syntax)
+style.tcl.11=$(colour.keyword),back:#FFFF80,bold
+# Keywords
+style.tcl.12=$(colour.keyword),bold
+# Keywords 2
+style.tcl.13=$(colour.keyword),back:#e0ffff,bold
+# Keywords 3
+style.tcl.14=$(colour.keyword),back:#FFf0f0,bold
+# Keywords 4
+style.tcl.15=$(colour.keyword),back:#FFD0D0,bold
+# Other keywords (bozo test colors :-)
+# Keywords 5
+style.tcl.16=$(style.tcl.7),back:#FFD0FF,bold
+# Keywords 6
+style.tcl.17=$(style.tcl.7),back:#FFFFD0,bold
+# Keywords 7
+style.tcl.18=$(style.tcl.7),back:#FFA0A0,bold,
+# Keywords 8
+style.tcl.19=$(style.tcl.7),back:#FFD0D0
+#comment box
+style.tcl.20=$(colour.code.comment.box),$(font.code.comment.box),back:#f0FFf0,eolfilled
+#comment block
+style.tcl.21=$(colour.embedded.comment),$(font.embedded.comment),back:#f0FFf0
+
 # Matched Operators
-style.tcl.34=fore:#0000FF,bold
-style.tcl.35=fore:#FF0000,bold
+style.tcl.34=fore:#f0f0f0,bold,back:#7070ff
+style.tcl.35=fore:#FF0000,bold,back:#FF00FF
+
 # Braces are only matched in operator style
-braces.tcl.style=10
+braces.tcl.style=6

Modified: trunk/plugins/editor/properties/tex.properties
==============================================================================
--- trunk/plugins/editor/properties/tex.properties	(original)
+++ trunk/plugins/editor/properties/tex.properties	Sat Nov 15 17:50:33 2008
@@ -4,7 +4,6 @@
 
 # TeX users may want to use the Latin Modern Typewriter font:
 #
-#   use.monospaced=1
 #   font.monospace=font:LMTypewriter10,size:16.5
 #   font.errorfont=font:LMTypewriter10,size:11.5
 #
@@ -12,13 +11,9 @@
 
 # TeX: patterns
 
-file.patterns.tex=
-file.patterns.latex=
-file.patterns.context=
-
-file.patterns.tex=*.tex;*.sty;
-file.patterns.latex=*.tex;*.sty;*.aux;*.toc;*.idx;
-file.patterns.context=*.tex;*.tui;*.tuo;*.sty;
+file.patterns.tex=*.tex;*.sty
+file.patterns.latex=*.tex;*.sty;*.aux;*.toc;*.idx
+file.patterns.context=*.tex;*.tui;*.tuo;*.sty
 
 # filter to be checked/tested:
 
@@ -262,7 +257,7 @@
     pdfvorigin \
     pdfxform pdfximage
 
-keywordclass.primitives.omega=
+keywordclass.primitives.omega=\
     odelimiter omathaccent omathchar oradical omathchardef omathcode odelcode \
     leftghost rightghost \
     charwd charht chardp charit \
@@ -452,8 +447,8 @@
 
 # TeX: words
 
-word.characters.$(file.patterns.tex)=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\@
-word.characters.$(file.patterns.latex)=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\@
-word.characters.$(file.patterns.context)=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\ !?
+word.characters.$(file.patterns.tex)=$(chars.alpha)$(chars.numeric)$(chars.accented)\@
+word.characters.$(file.patterns.latex)=$(chars.alpha)$(chars.numeric)$(chars.accented)\@
+word.characters.$(file.patterns.context)=$(chars.alpha)$(chars.numeric)$(chars.accented)\ !?
 
-# TeX: end of file
\ No newline at end of file
+# TeX: end of file

Modified: trunk/plugins/editor/properties/vb.properties
==============================================================================
--- trunk/plugins/editor/properties/vb.properties	(original)
+++ trunk/plugins/editor/properties/vb.properties	Sat Nov 15 17:50:33 2008
@@ -12,41 +12,50 @@
 lexer.$(file.patterns.vb)=vb
 lexer.$(file.patterns.wscript)=vbscript
 
-keywordclass.vb=and begin case call continue do each else elseif end erase \
-error event exit false for function get gosub goto if implement in load loop lset \
-me mid new next not nothing on or property raiseevent rem resume return rset \
-select set stop sub then to true unload until wend while with withevents \
-attribute alias as boolean byref byte byval const compare currency date declare dim double \
-enum explicit friend global integer let lib long module object option optional \
-preserve private property public redim single static string type variant
-
-keywordclass.vbnet=addhandler addressof andalso alias and ansi as assembly auto boolean \
-byref byte byval call case catch cbool cbyte cchar cdate cdec cdbl char cint class \
-clng cobj const cshort csng cstr ctype date decimal declare default delegate dim do double \
-each else elseif end enum erase error event exit false finally for friend function get \
-gettype goto  handles if implements imports in inherits integer interface is let lib like long \
-loop me mod module mustinherit mustoverride mybase myclass namespace new \
-next not nothing notinheritable notoverridable object on option optional or \
-orelse overloads overridable overrides paramarray preserve private property protected public \
-raiseevent readonly redim rem removehandler resume return select set shadows \
-shared short single static step stop string structure sub synclock then throw to true try \
-typeof unicode until variant when while with withevents writeonly xor
-
-keywords.$(file.patterns.vb)=$(keywordclass.vbnet)
-keywords.$(file.patterns.wscript)=$(keywordclass.vb)
-
-# Not used here, mostly system statements (files, registry, I/O...),
-# I am not sure I should include them in the regular statements.
-keywordclass.vbotherstatements=appactivate beep chdir chdrive close \
-deletesetting filecopy get input kill line lock unlock lset mid mkdir name \
-open print put randomize reset rmdir rset savepicture savesetting seek \
-sendkeys setattr time unload width write
+# Keywords, operators, statements, data types and some words in .frm files
+keywordclass.vb6=\
+addressof alias and as attribute base begin binary boolean byref byte byval call case cdbl \
+cint clng compare const csng cstr currency date decimal declare defbool defbyte defcur \
+defdate defdbl defdec defint deflng defobj defsng defstr defvar dim do double each else \
+elseif empty end enum eqv erase error event exit explicit false for friend function get \
+global gosub goto if imp implements in input integer is len let lib like load lock long \
+loop lset me mid midb mod new next not nothing null object on option optional or paramarray \
+preserve print private property public raiseevent randomize redim rem resume return rset \
+seek select set single static step stop string sub text then time to true type typeof \
+unload until variant wend while with withevents xor
+
+# html.properties picks up VB keywords from keywordclass.vb
+keywordclass.vb=$(keywordclass.vb6)
+
+# Mostly system statements (files, registry, I/O...) that
+# I am not sure to include with the regular statements.
+keywordclass.vbotherstatements=\
+appactivate beep chdir chdrive close filecopy get input kill line unlock mkdir name \
+open print put reset rmdir savepicture savesetting seek sendkeys setattr width write
+
+# VBNet specific keywords
+keywordclass.vbnet=\
+addhandler andalso ansi assembly auto catch cbool cbyte cchar cdate cdec char class \
+cobj continue csbyte cshort ctype cuint culng cushort custom default delegate directcast \
+endif externalsource finally gettype handles imports inherits interface isfalse isnot \
+istrue module mustinherit mustoverride my mybase myclass namespace narrowing notinheritable \
+notoverridable of off operator orelse overloads overridable overrides partial protected \
+readonly region removehandler sbyte shadows shared short strict structure synclock \
+throw try trycast uinteger ulong unicode ushort using when widening writeonly
 
-comment.block.vb='~
+keywords.$(file.patterns.vb)=$(keywordclass.vb6) $(keywordclass.vbnet)
+keywords.$(file.patterns.wscript)=$(keywordclass.vb6)
+
+keywords2.$(file.patterns.vb)=$(keywordclass.vbotherstatements)
 
+comment.block.vb='~
+comment.block.vbscript='~
 # VB styles
+
+# Default
+style.vb.32=$(font.base)
 # White space
-style.vb.0=fore:#000000,$(font.vbs)
+style.vb.0=
 # Comment
 style.vb.1=$(colour.code.comment.line),$(font.code.comment.line)
 # Number
@@ -55,7 +64,7 @@
 style.vb.3=$(colour.keyword)
 # String
 style.vb.4=$(colour.string)
-# Preprocessor
+# Preprocessor (directives)
 style.vb.5=$(colour.preproc)
 # Operator
 style.vb.6=$(colour.operator)
@@ -63,6 +72,12 @@
 style.vb.7=
 # Date
 style.vb.8=$(colour.number)
+# End of line where string is not closed
+style.vb.9=$(style.stringeol)
+# Other keywords (bozo test colors :-)
+style.vb.10=$(style.vb.5),back:#D0FFD0
+style.vb.11=$(style.vb.5),back:#D0D0FF
+style.vb.12=$(style.vb.5),back:#FFD0D0
 
 # VBScript styles same as VB styles
 style.vbscript.0=$(style.vb.0)
@@ -74,6 +89,10 @@
 style.vbscript.6=$(style.vb.6)
 style.vbscript.7=$(style.vb.7)
 style.vbscript.8=$(style.vb.8)
+style.vbscript.9=$(style.vb.9)
+style.vbscript.10=$(style.vb.10)
+style.vbscript.11=$(style.vb.11)
+style.vbscript.12=$(style.vb.12)
 
 # wscript
 # normal execute
@@ -85,3 +104,7 @@
 command.build.$(file.patterns.wscript)=cscript "$(FilePath)"
 command.build.subsystem.$(file.patterns.wscript)=1
 
+command.help.$(file.patterns.wscript)=$(CurrentWord)!C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\MSDN130.COL
+command.help.subsystem.$(file.patterns.wscript)=4
+command.help.$(file.patterns.vb)=$(CurrentWord)!C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\MSDN130.COL
+command.help.subsystem.$(file.patterns.vb)=4

Modified: trunk/plugins/editor/properties/verilog.properties
==============================================================================
--- trunk/plugins/editor/properties/verilog.properties	(original)
+++ trunk/plugins/editor/properties/verilog.properties	Sat Nov 15 17:50:33 2008
@@ -19,49 +19,71 @@
 comment.box.middle.verilog= *
 comment.box.end.verilog= */
 
-fold.comment=1
-fold.preprocessor=1
-fold.at.else=1
 fold.verilog.flags=0
 
 #statement.lookback.$(file.patterns.verilog)=20
-#block.start.$(file.patterns.verilog)=5 begin 
-#block.end.$(file.patterns.verilog)=5 end 
+#block.start.$(file.patterns.verilog)=5 begin
+#block.end.$(file.patterns.verilog)=5 end
 #statement.indent.$(file.patterns.verilog)=5 always case casex casez else for if while \
 #module function task
-#statement.end.$(file.patterns.verilog)=10 ;
 
 indent.maintain.$(file.patterns.verilog)=1;
 
 preprocessor.symbol.$(file.patterns.verilog)=`
-preprocessor.start.$(file.patterns.verilog)=ifdef
+preprocessor.start.$(file.patterns.verilog)=ifdef ifndef
 preprocessor.middle.$(file.patterns.verilog)=else
 preprocessor.end.$(file.patterns.verilog)=endif
 
-keywordclass.verilog=always and assign begin \
-xbuf buf bufif0 bufif1 case casex casez cmos \
-default defparam else end endcase \
-endfunction endmodule endprimitive endspecify \
-endtable endtask event for force forever \
-fork function if initial inout input \
-integer join macromodule makefile module \
-nand negedge nmos nor not notif0 notif1 \
-or output parameter pmos posedge primitive \
-pulldown pullup rcmos real realtime reg \
-repeat rnmos rpmos rtran rtranif0 rtranif1 \
-signed specify specparam supply supply0 supply1 table \
-task time tran tranif0 tranif1 tri tri0 \
-tri1 triand trior trireg vectored wait \
-wand while wire wor xnor xor
+keywordclass.verilog= \
+always and assign automatic \
+begin buf bufif0 bufif1 \
+case casex casez cell cmos config \
+deassign default defparam design disable \
+edge else end endcase endconfig endfunction endgenerate endmodule endprimitive endspecify endtable endtask event \
+for force forever fork function \
+generate genvar \
+highz0 highz1 \
+if ifnone incdir include initial inout input instance integer \
+join \
+large liblist library localparam \
+macromodule medium module \
+nand negedge nmos nor noshowcancelled not notif0 notif1 \
+or output \
+parameter pmos posedge primitive pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent \
+rcmos real realtime reg release repeat rnmos rpmos rtran rtranif0 rtranif1 \
+scalared showcancelled signed small specify specparam strong0 strong1 supply0 supply1 \
+table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg \
+unsigned use \
+vectored \
+wait wand weak0 weak1 while wire wor \
+xnor xor
 
 keywords.$(file.patterns.verilog)=$(keywordclass.verilog)
 
-keywords3.$(file.patterns.verilog)=$readmemb $readmemh $sreadmemb $sreadmemh $display $write $strobe $monitor $fdisplay $fwrite $fstrobe \
-$fmonitor $fopen $fclose $time $stime $realtime $scale $printtimescale $timeformat $stop $finish $save \
-$incsave $restart $input $log $nolog $key $nokey $scope $showscopes $showscopes $showvars $showvars \
-$countdrivers $list $monitoron $monitoroff $dumpon $dumpoff $dumpfile $dumplimit $dumpflush $dumpvars \
-$dumpall $reset $reset $reset $reset $reset $random $getpattern $rtoi $itor $realtobits $bitstoreal \
-$setup $hold $setuphold $period $width $skew $recovery
+keywords3.$(file.patterns.verilog)= \
+$async$and$array $async$and$plane $async$nand$array $async$nand$plane $async$nor$array $async$nor$plane $async$or$array $async$or$plane \
+$bitstoreal \
+$countdrivers \
+$display $displayb $displayh $displayo \
+$dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform \
+$dumpall $dumpfile $dumpflush $dumplimit $dumpoff $dumpon $dumpportsall $dumpportsflush $dumpportslimit $dumpportsoff $dumpportson $dumpvars \
+$fclose $fdisplayh $fdisplay $fdisplayf $fdisplayb $ferror $fflush $fgetc $fgets $finish $fmonitorb $fmonitor $fmonitorf $fmonitorh $fopen $fread $fscanf $fseek $fsscanf $fstrobe $fstrobebb $fstrobef $fstrobeh $ftel $fullskew $fwriteb $fwritef $fwriteh $fwrite \
+$getpattern \
+$history $hold \
+$incsave $input $itor \
+$key \
+$list $log \
+$monitorb $monitorh $monitoroff $monitoron $monitor $monitoro \
+$nochange $nokey $nolog \
+$period $printtimescale \
+$q_add $q_exam $q_full $q_initialize $q_remove \
+$random $readmemb $readmemh $readmemh $realtime $realtobits $recovery $recrem $removal $reset_count $reset $reset_value $restart $rewind $rtoi \
+$save $scale $scope $sdf_annotate $setup $setuphold $sformat $showscopes $showvariables $showvars $signed $skew $sreadmemb $sreadmemh $stime $stop $strobeb $strobe $strobeh $strobeo $swriteb $swriteh $swriteo $swrite $sync$and$array $sync$and$plane $sync$nand$array $sync$nand$plane $sync$nor$array $sync$nor$plane $sync$or$array $sync$or$plane \
+$test$plusargs $time $timeformat $timeskew \
+$ungetc $unsigned \
+$value$plusargs \
+$width $writeb $writeh $write $writeo
+
 # Verilog styles
 
 # Default

Modified: trunk/plugins/editor/properties/vhdl.properties
==============================================================================
--- trunk/plugins/editor/properties/vhdl.properties	(original)
+++ trunk/plugins/editor/properties/vhdl.properties	Sat Nov 15 17:50:33 2008
@@ -19,17 +19,14 @@
 #comment.box.middle.vhdl= *
 #comment.box.end.vhdl= */
 
-#~ fold.comment=1
-#~ fold.compact=1
 #~ fold.at.Begin=1
 #~ fold.at.Parenthese=1
 
 #statement.lookback.$(file.patterns.vhdl)=20
-#block.start.$(file.patterns.vhdl)=5 begin 
-#block.end.$(file.patterns.vhdl)=5 end 
+#block.start.$(file.patterns.vhdl)=5 begin
+#block.end.$(file.patterns.vhdl)=5 end
 #statement.indent.$(file.patterns.vhdl)=5 always case casex casez else for if while \
 #module function task
-#statement.end.$(file.patterns.vhdl)=10 ;
 
 indent.maintain.$(file.patterns.vhdl)=1;
 
@@ -39,30 +36,30 @@
 for function generate generic group guarded if impure in inertial inout is label library linkage literal \
 loop map new next null of on open others out package port postponed procedure process pure range record \
 register reject report return select severity shared signal subtype then to transport type unaffected \
-units until use variable wait when while with                                                                                       
-                                                                                                            
+units until use variable wait when while with
+
 keywords2.$(file.patterns.vhdl)=                                                                            \
- abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor                                           
-                                                                                                            
+ abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor
+
 keywords3.$(file.patterns.vhdl)=                                                                            \
  left right low high ascending image value pos val succ pred leftof rightof base range reverse_range        \
  length delayed stable quiet transaction event active last_event last_active last_value driving             \
- driving_value simple_name path_name instance_name                                                       
+ driving_value simple_name path_name instance_name
 
 keywords4.$(file.patterns.vhdl)=                                                                            \
  now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector      \
  to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left \
- rotate_right resize to_integer to_unsigned to_signed std_match to_01                                       
+ rotate_right resize to_integer to_unsigned to_signed std_match to_01
 
 keywords5.$(file.patterns.vhdl)=                                                                            \
  std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed               \
  std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives        \
- vital_timing                                                                                        
+ vital_timing
 
 keywords6.$(file.patterns.vhdl)=                                                                            \
  boolean bit character severity_level integer real time delay_length natural positive string bit_vector     \
  file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic                \
- std_logic_vector X01 X01Z UX01 UX01Z unsigned signed                                                   
+ std_logic_vector X01 X01Z UX01 UX01Z unsigned signed
 
 # vhdl styles
 
@@ -99,5 +96,4 @@
 # User defined identifiers and tasks
 style.vhdl.14=fore:#804020,$(font.code.comment.doc)
 # Braces are only matched in operator style
-braces.vhdl.style=10
-
+braces.vhdl.style=5

Modified: trunk/plugins/editor/properties/yaml.properties
==============================================================================
--- trunk/plugins/editor/properties/yaml.properties	(original)
+++ trunk/plugins/editor/properties/yaml.properties	Sat Nov 15 17:50:33 2008
@@ -9,9 +9,6 @@
 tabsize.$(file.patterns.yaml)=2
 indent.size.$(file.patterns.yaml)=2
 use.tabs.$(file.patterns.yaml)=0
-indent.automatic.$(file.patterns.yaml)=0
-indent.opening.$(file.patterns.yaml)=0
-indent.closing.$(file.patterns.yaml)=0
 
 # YAML comment character
 comment.block.yaml=#~

Modified: trunk/plugins/editor/properties_cxx.h
==============================================================================
--- trunk/plugins/editor/properties_cxx.h	(original)
+++ trunk/plugins/editor/properties_cxx.h	Sat Nov 15 17:50:33 2008
@@ -25,12 +25,23 @@
 #include "PropSet.h"
 
 class PropSetFile : public PropSet {
+	bool lowerKeys;
+	SString GetWildUsingStart(const PropSet &psStart, const char *keybase, const char *filename);
+protected:
+	static bool caseSensitiveFilenames;
 public:
-	PropSetFile() {};
-	~PropSetFile() {};
-	bool ReadLine(char *data, bool ifIsTrue, const char *directoryForImports=0);
+	PropSetFile(bool lowerKeys_=false);
+	~PropSetFile();
+	bool ReadLine(const char *data, bool ifIsTrue, const char *directoryForImports=0);
 	void ReadFromMemory(const char *data, int len, const char *directoryForImports=0);
-	void Read(const char *filename, const char *directoryForImports);
+	bool Read(const char *filename, const char *directoryForImports);
+	SString GetWild(const char *keybase, const char *filename);
+	SString GetNewExpand(const char *keybase, const char *filename="");
+	bool GetFirst(char **key, char **val);
+	bool GetNext(char **key, char **val);
+	static void SetCaseSensitiveFilenames(bool caseSensitiveFilenames_) {
+		caseSensitiveFilenames = caseSensitiveFilenames_;
+	}
 };
 
 #endif

Modified: trunk/plugins/editor/scintilla/AutoComplete.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/AutoComplete.cxx	(original)
+++ trunk/plugins/editor/scintilla/AutoComplete.cxx	Sat Nov 15 17:50:33 2008
@@ -14,6 +14,10 @@
 #include "PropSet.h"
 #include "AutoComplete.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 AutoComplete::AutoComplete() :
 	active(false),
 	separator(' '),

Modified: trunk/plugins/editor/scintilla/AutoComplete.h
==============================================================================
--- trunk/plugins/editor/scintilla/AutoComplete.h	(original)
+++ trunk/plugins/editor/scintilla/AutoComplete.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef AUTOCOMPLETE_H
 #define AUTOCOMPLETE_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class AutoComplete {
@@ -67,4 +71,8 @@
 	void Select(const char *word);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/CallTip.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/CallTip.cxx	(original)
+++ trunk/plugins/editor/scintilla/CallTip.cxx	Sat Nov 15 17:50:33 2008
@@ -12,6 +12,11 @@
 
 #include "Scintilla.h"
 #include "CallTip.h"
+#include <stdio.h>
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static const int insetX = 5;    // text inset in x from calltip border
 static const int widthArrow = 14;
@@ -29,8 +34,14 @@
 	tabSize = 0;
 	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);
+#else
 	colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
 	colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+#endif
 	colourSel.desired = ColourDesired(0, 0, 0x80);
 	colourShade.desired = ColourDesired(0, 0, 0);
 	colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
@@ -170,6 +181,7 @@
 	char *chunkVal = val;
 	bool moreChunks = true;
 	int maxWidth = 0;
+
 	while (moreChunks) {
 		char *chunkEnd = strchr(chunkVal, '\n');
 		if (chunkEnd == NULL) {
@@ -217,6 +229,8 @@
 	offsetMain = insetX;    // initial alignment assuming no arrows
 	PaintContents(surfaceWindow, true);
 
+#ifndef __APPLE__
+	// 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);
@@ -225,6 +239,7 @@
 	surfaceWindow->PenColour(colourLight.allocated);
 	surfaceWindow->LineTo(0, 0);
 	surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
+#endif
 }
 
 void CallTip::MouseClick(Point pt) {

Modified: trunk/plugins/editor/scintilla/CallTip.h
==============================================================================
--- trunk/plugins/editor/scintilla/CallTip.h	(original)
+++ trunk/plugins/editor/scintilla/CallTip.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef CALLTIP_H
 #define CALLTIP_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class CallTip {
@@ -76,4 +80,8 @@
 	void SetForeBack(const ColourPair &fore, const ColourPair &back);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/CellBuffer.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/CellBuffer.cxx	(original)
+++ trunk/plugins/editor/scintilla/CellBuffer.cxx	Sat Nov 15 17:50:33 2008
@@ -13,9 +13,14 @@
 #include "Platform.h"
 
 #include "Scintilla.h"
-#include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 MarkerHandleSet::MarkerHandleSet() {
 	root = 0;
 }
@@ -30,7 +35,7 @@
 	root = 0;
 }
 
-int MarkerHandleSet::Length() {
+int MarkerHandleSet::Length() const {
 	int c = 0;
 	MarkerHandleNumber *mhn = root;
 	while (mhn) {
@@ -40,7 +45,7 @@
 	return c;
 }
 
-int MarkerHandleSet::NumberFromHandle(int handle) {
+int MarkerHandleSet::NumberFromHandle(int handle) const {
 	MarkerHandleNumber *mhn = root;
 	while (mhn) {
 		if (mhn->handle == handle) {
@@ -51,7 +56,7 @@
 	return - 1;
 }
 
-int MarkerHandleSet::MarkValue() {
+int MarkerHandleSet::MarkValue() const {
 	unsigned int m = 0;
 	MarkerHandleNumber *mhn = root;
 	while (mhn) {
@@ -61,7 +66,7 @@
 	return m;
 }
 
-bool MarkerHandleSet::Contains(int handle) {
+bool MarkerHandleSet::Contains(int handle) const {
 	MarkerHandleNumber *mhn = root;
 	while (mhn) {
 		if (mhn->handle == handle) {
@@ -90,7 +95,7 @@
 		if (mhn->handle == handle) {
 			*pmhn = mhn->next;
 			delete mhn;
-			return ;
+			return;
 		}
 		pmhn = &((*pmhn)->next);
 	}
@@ -121,210 +126,154 @@
 	other->root = 0;
 }
 
-LineVector::LineVector() {
-	linesData = 0;
-	lines = 0;
-	size = 0;
-	levels = 0;
-	sizeLevels = 0;
+LineVector::LineVector() : starts(256) {
 	handleCurrent = 1;
-	growSize = 1000;
 
 	Init();
 }
 
 LineVector::~LineVector() {
-	for (int line = 0; line < lines; line++) {
-		delete linesData[line].handleSet;
-		linesData[line].handleSet = 0;
-	}
-	delete []linesData;
-	linesData = 0;
-	delete []levels;
-	levels = 0;
+	starts.DeleteAll();
+	for (int line = 0; line < markers.Length(); line++) {
+		delete markers[line];
+		markers[line] = 0;
+	}
+	markers.DeleteAll();
+	levels.DeleteAll();
 }
 
 void LineVector::Init() {
-	for (int line = 0; line < lines; line++) {
-		delete linesData[line].handleSet;
-		linesData[line].handleSet = 0;
-	}
-	delete []linesData;
-	linesData = new LineData[static_cast<int>(growSize)];
-	size = growSize;
-	lines = 1;
-	delete []levels;
-	levels = 0;
-	sizeLevels = 0;
-}
-
-void LineVector::Expand(int sizeNew) {
-	LineData *linesDataNew = new LineData[sizeNew];
-	if (linesDataNew) {
-		for (int i = 0; i < size; i++)
-			linesDataNew[i] = linesData[i];
-		// Do not delete handleSets here as they are transferred to new linesData
-		delete []linesData;
-		linesData = linesDataNew;
-		size = sizeNew;
-	} else {
-		Platform::DebugPrintf("No memory available\n");
-		// TODO: Blow up
+	starts.DeleteAll();
+	for (int line = 0; line < markers.Length(); line++) {
+		delete markers[line];
+		markers[line] = 0;
 	}
-
+	markers.DeleteAll();
+	levels.DeleteAll();
 }
 
 void LineVector::ExpandLevels(int sizeNew) {
-	if (sizeNew == -1)
-		sizeNew = size;
-	int *levelsNew = new int[sizeNew];
-	if (levelsNew) {
-		int i = 0;
-		for (; i < sizeLevels; i++)
-			levelsNew[i] = levels[i];
-		for (; i < sizeNew; i++)
-			levelsNew[i] = SC_FOLDLEVELBASE;
-		delete []levels;
-		levels = levelsNew;
-		sizeLevels = sizeNew;
-	} else {
-		Platform::DebugPrintf("No memory available\n");
-		// TODO: Blow up
-	}
-
+	levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
 }
 
 void LineVector::ClearLevels() {
-	delete []levels;
-	levels = 0;
-	sizeLevels = 0;
-}
-
-void LineVector::InsertValue(int pos, int value) {
-	//Platform::DebugPrintf("InsertValue[%d] = %d\n", pos, value);
-	if ((lines + 2) >= size) {
-		if (growSize * 6 < size)
-			growSize *= 2;
-		Expand(size + growSize);
-		if (levels) {
-			ExpandLevels(size + growSize);
-		}
-	}
-	lines++;
-	for (int i = lines; i > pos; i--) {
-		linesData[i] = linesData[i - 1];
-	}
-	linesData[pos].startPosition = value;
-	linesData[pos].handleSet = 0;
-	if (levels) {
-		for (int j = lines; j > pos; j--) {
-			levels[j] = levels[j - 1];
-		}
-		if (pos == 0) {
-			levels[pos] = SC_FOLDLEVELBASE;
-		} else if (pos == (lines - 1)) {	// Last line will not be a folder
-			levels[pos] = SC_FOLDLEVELBASE;
-		} else {
-			levels[pos] = levels[pos - 1];
+	levels.DeleteAll();
+}
+
+int LineVector::SetLevel(int line, int level) {
+	int prev = 0;
+	if ((line >= 0) && (line < Lines())) {
+		if (!levels.Length()) {
+			ExpandLevels(Lines() + 1);
+		}
+		prev = levels[line];
+		if (prev != level) {
+			levels[line] = level;
 		}
 	}
+	return prev;
+}
+
+int LineVector::GetLevel(int line) {
+	if (levels.Length() && (line >= 0) && (line < Lines())) {
+		return levels[line];
+	} else {
+		return SC_FOLDLEVELBASE;
+	}
+}
+
+void LineVector::InsertText(int line, int delta) {
+	starts.InsertText(line, delta);
 }
 
-void LineVector::SetValue(int pos, int value) {
-	//Platform::DebugPrintf("SetValue[%d] = %d\n", pos, value);
-	if ((pos + 2) >= size) {
-		//Platform::DebugPrintf("Resize %d %d\n", size,pos);
-		Expand(pos + growSize);
-		//Platform::DebugPrintf("end Resize %d %d\n", size,pos);
-		lines = pos;
-		if (levels) {
-			ExpandLevels(pos + growSize);
+void LineVector::InsertLine(int line, int position) {
+	starts.InsertPartition(line, position);
+	if (markers.Length()) {
+		markers.Insert(line, 0);
+	}
+	if (levels.Length()) {
+		int level = SC_FOLDLEVELBASE;
+		if ((line > 0) && (line < Lines())) {
+			level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG;
 		}
+		levels.InsertValue(line, 1, level);
 	}
-	linesData[pos].startPosition = value;
 }
 
-void LineVector::Remove(int pos) {
-	//Platform::DebugPrintf("Remove %d\n", pos);
+void LineVector::SetLineStart(int line, int position) {
+	starts.SetPartitionStartPosition(line, position);
+}
+
+void LineVector::RemoveLine(int line) {
+	starts.RemovePartition(line);
 	// Retain the markers from the deleted line by oring them into the previous line
-	if (pos > 0) {
-		MergeMarkers(pos - 1);
-	}
-	for (int i = pos; i < lines; i++) {
-		linesData[i] = linesData[i + 1];
+	if (markers.Length()) {
+		if (line > 0) {
+			MergeMarkers(line - 1);
+		}
+		markers.Delete(line);
 	}
-	if (levels) {
+	if (levels.Length()) {
 		// Move up following lines but merge header flag from this line
 		// to line before to avoid a temporary disappearence causing expansion.
-		int firstHeader = levels[pos] & SC_FOLDLEVELHEADERFLAG;
-		for (int j = pos; j < lines; j++) {
-			levels[j] = levels[j + 1];
-		}
-		if (pos > 0)
-			levels[pos-1] |= firstHeader;
+		int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG;
+		levels.Delete(line);
+		if (line > 0)
+			levels[line-1] |= firstHeader;
 	}
-	lines--;
 }
 
 int LineVector::LineFromPosition(int pos) {
-	//Platform::DebugPrintf("LineFromPostion %d lines=%d end = %d\n", pos, lines, linesData[lines].startPosition);
-	if (lines == 0)
+	return starts.PartitionFromPosition(pos);
+}
+
+int LineVector::MarkValue(int line) {
+	if (markers.Length() && markers[line])
+		return markers[line]->MarkValue();
+	else
 		return 0;
-	//Platform::DebugPrintf("LineFromPosition %d\n", pos);
-	if (pos >= linesData[lines].startPosition)
-		return lines - 1;
-	int lower = 0;
-	int upper = lines;
-	do {
-		int middle = (upper + lower + 1) / 2; 	// Round high
-		if (pos < linesData[middle].startPosition) {
-			upper = middle - 1;
-		} else {
-			lower = middle;
-		}
-	} while (lower < upper);
-	//Platform::DebugPrintf("LineFromPostion %d %d %d\n", pos, lower, linesData[lower].startPosition, linesData[lower > 1 ? lower - 1 : 0].startPosition);
-	return lower;
 }
 
 int LineVector::AddMark(int line, int markerNum) {
 	handleCurrent++;
-	if (!linesData[line].handleSet) {
+	if (!markers.Length()) {
+		// No existing markers so allocate one element per line
+		markers.InsertValue(0, Lines(), 0);
+	}
+	if (!markers[line]) {
 		// Need new structure to hold marker handle
-		linesData[line].handleSet = new MarkerHandleSet;
-		if (!linesData[line].handleSet)
+		markers[line] = new MarkerHandleSet();
+		if (!markers[line])
 			return - 1;
 	}
-	linesData[line].handleSet->InsertHandle(handleCurrent, markerNum);
+	markers[line]->InsertHandle(handleCurrent, markerNum);
 
 	return handleCurrent;
 }
 
 void LineVector::MergeMarkers(int pos) {
-	if (linesData[pos + 1].handleSet != NULL) {
-		if (linesData[pos].handleSet == NULL )
-			linesData[pos].handleSet = new MarkerHandleSet;
-		linesData[pos].handleSet->CombineWith(linesData[pos + 1].handleSet);
-		delete linesData[pos + 1].handleSet;
-		linesData[pos + 1].handleSet = NULL;
+	if (markers[pos + 1] != NULL) {
+		if (markers[pos] == NULL)
+			markers[pos] = new MarkerHandleSet;
+		markers[pos]->CombineWith(markers[pos + 1]);
+		delete markers[pos + 1];
+		markers[pos + 1] = NULL;
 	}
 }
 
 void LineVector::DeleteMark(int line, int markerNum, bool all) {
-	if (linesData[line].handleSet) {
+	if (markers.Length() && markers[line]) {
 		if (markerNum == -1) {
-			delete linesData[line].handleSet;
-			linesData[line].handleSet = 0;
+			delete markers[line];
+			markers[line] = NULL;
 		} else {
-			bool performedDeletion = 
-				linesData[line].handleSet->RemoveNumber(markerNum);
+			bool performedDeletion = markers[line]->RemoveNumber(markerNum);
 			while (all && performedDeletion) {
-				performedDeletion = 
-					linesData[line].handleSet->RemoveNumber(markerNum);
+				performedDeletion = markers[line]->RemoveNumber(markerNum);
 			}
-			if (linesData[line].handleSet->Length() == 0) {
-				delete linesData[line].handleSet;
-				linesData[line].handleSet = 0;
+			if (markers[line]->Length() == 0) {
+				delete markers[line];
+				markers[line] = NULL;
 			}
 		}
 	}
@@ -333,23 +282,25 @@
 void LineVector::DeleteMarkFromHandle(int markerHandle) {
 	int line = LineFromHandle(markerHandle);
 	if (line >= 0) {
-		linesData[line].handleSet->RemoveHandle(markerHandle);
-		if (linesData[line].handleSet->Length() == 0) {
-			delete linesData[line].handleSet;
-			linesData[line].handleSet = 0;
+		markers[line]->RemoveHandle(markerHandle);
+		if (markers[line]->Length() == 0) {
+			delete markers[line];
+			markers[line] = NULL;
 		}
 	}
 }
 
 int LineVector::LineFromHandle(int markerHandle) {
-	for (int line = 0; line < lines; line++) {
-		if (linesData[line].handleSet) {
-			if (linesData[line].handleSet->Contains(markerHandle)) {
-				return line;
+	if (markers.Length()) {
+		for (int line = 0; line < Lines(); line++) {
+			if (markers[line]) {
+				if (markers[line]->Contains(markerHandle)) {
+					return line;
+				}
 			}
 		}
 	}
-	return - 1;
+	return -1;
 }
 
 Action::Action() {
@@ -437,7 +388,7 @@
 		int lenActionsNew = lenActions * 2;
 		Action *actionsNew = new Action[lenActionsNew];
 		if (!actionsNew)
-			return ;
+			return;
 		for (int act = 0; act <= currentAction; act++)
 			actionsNew[act].Grab(&actions[act]);
 		delete []actions;
@@ -446,7 +397,8 @@
 	}
 }
 
-void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
+void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData,
+	bool &startSequence) {
 	EnsureUndoRoom();
 	//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
 	//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
@@ -454,6 +406,7 @@
 	if (currentAction < savePoint) {
 		savePoint = -1;
 	}
+	int oldCurrentAction = currentAction;
 	if (currentAction >= 1) {
 		if (0 == undoSequenceDepth) {
 			// Top level actions may not always be coalesced
@@ -486,7 +439,7 @@
 					currentAction++;
 				}
 			} else {
-				//Platform::DebugPrintf("action coalesced\n");
+				// Action coalesced.
 			}
 
 		} else {
@@ -497,6 +450,7 @@
 	} else {
 		currentAction++;
 	}
+	startSequence = oldCurrentAction != currentAction;
 	actions[currentAction].Create(at, position, data, lengthData);
 	currentAction++;
 	actions[currentAction].Create(startAction);
@@ -517,6 +471,7 @@
 }
 
 void UndoHistory::EndUndoAction() {
+	PLATFORM_ASSERT(undoSequenceDepth > 0);
 	EnsureUndoRoom();
 	undoSequenceDepth--;
 	if (0 == undoSequenceDepth) {
@@ -600,132 +555,55 @@
 	currentAction++;
 }
 
-CellBuffer::CellBuffer(int initialLength) {
-	body = new char[initialLength];
-	size = initialLength;
-	length = 0;
-	part1len = 0;
-	gaplen = initialLength;
-	part2body = body + gaplen;
+CellBuffer::CellBuffer() {
 	readOnly = false;
 	collectingUndo = true;
-	growSize = 4000;
 }
 
 CellBuffer::~CellBuffer() {
-	delete []body;
-	body = 0;
-}
-
-void CellBuffer::GapTo(int position) {
-	if (position == part1len)
-		return ;
-	if (position < part1len) {
-		int diff = part1len - position;
-		//Platform::DebugPrintf("Move gap backwards to %d diff = %d part1len=%d length=%d \n", position,diff, part1len, length);
-		for (int i = 0; i < diff; i++)
-			body[part1len + gaplen - i - 1] = body[part1len - i - 1];
-	} else {	// position > part1len
-		int diff = position - part1len;
-		//Platform::DebugPrintf("Move gap forwards to %d diff =%d\n", position,diff);
-		for (int i = 0; i < diff; i++)
-			body[part1len + i] = body[part1len + gaplen + i];
-	}
-	part1len = position;
-	part2body = body + gaplen;
-}
-
-void CellBuffer::RoomFor(int insertionLength) {
-	//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
-	if (gaplen <= insertionLength) {
-		//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
-		if (growSize * 6 < size)
-			growSize *= 2;
-		int newSize = size + insertionLength + growSize;
-		Allocate(newSize);
-	}
-}
-
-// To make it easier to write code that uses ByteAt, a position outside the range of the buffer
-// can be retrieved. All characters outside the range have the value '\0'.
-char CellBuffer::ByteAt(int position) {
-	if (position < part1len) {
-		if (position < 0) {
-			return '\0';
-		} else {
-			return body[position];
-		}
-	} else {
-		if (position >= length) {
-			return '\0';
-		} else {
-			return part2body[position];
-		}
-	}
 }
 
-void CellBuffer::SetByteAt(int position, char ch) {
-
-	if (position < 0) {
-		//Platform::DebugPrintf("Bad position %d\n",position);
-		return ;
-	}
-	if (position >= length + 11) {
-		Platform::DebugPrintf("Very Bad position %d of %d\n", position, length);
-		//exit(2);
-		return ;
-	}
-	if (position >= length) {
-		//Platform::DebugPrintf("Bad position %d of %d\n",position,length);
-		return ;
-	}
-
-	if (position < part1len) {
-		body[position] = ch;
-	} else {
-		part2body[position] = ch;
-	}
-}
-
-char CellBuffer::CharAt(int position) {
-	return ByteAt(position*2);
+char CellBuffer::CharAt(int position) const {
+	return substance.ValueAt(position);
 }
 
 void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) {
 	if (lengthRetrieve < 0)
-		return ;
+		return;
 	if (position < 0)
-		return ;
-	int bytePos = position * 2;
-	if ((bytePos + lengthRetrieve * 2) > length) {
-		Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", bytePos,
-		                      lengthRetrieve, length);
-		return ;
-	}
-	GapTo(0); 	// Move the buffer so its easy to subscript into it
-	char *pb = part2body + bytePos;
-	while (lengthRetrieve--) {
-		*buffer++ = *pb;
-		pb += 2;
+		return;
+	if ((position + lengthRetrieve) > substance.Length()) {
+		Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position,
+		                      lengthRetrieve, substance.Length());
+		return;
+	}
+	
+	for (int i=0; i<lengthRetrieve; i++) {
+		*buffer++ = substance.ValueAt(position + i);
 	}
 }
 
 char CellBuffer::StyleAt(int position) {
-	return ByteAt(position*2 + 1);
+	return style.ValueAt(position);
+}
+
+const char *CellBuffer::BufferPointer() { 
+	return substance.BufferPointer();
 }
 
-const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
+// The char* returned is to an allocation owned by the undo history
+const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) {
 	char *data = 0;
 	// InsertString and DeleteChars are the bottleneck though which all changes occur
 	if (!readOnly) {
 		if (collectingUndo) {
 			// Save into the undo/redo stack, but only the characters - not the formatting
 			// This takes up about half load time
-			data = new char[insertLength / 2];
-			for (int i = 0; i < insertLength / 2; i++) {
-				data[i] = s[i * 2];
+			data = new char[insertLength];
+			for (int i = 0; i < insertLength; i++) {
+				data[i] = s[i];
 			}
-			uh.AppendAction(insertAction, position / 2, data, insertLength / 2);
+			uh.AppendAction(insertAction, position, data, insertLength, startSequence);
 		}
 
 		BasicInsertString(position, s, insertLength);
@@ -733,45 +611,45 @@
 	return data;
 }
 
-bool CellBuffer::SetStyleAt(int position, char style, char mask) {
-	style &= mask;
-	char curVal = ByteAt(position * 2 + 1);
-	if ((curVal & mask) != style) {
-		SetByteAt(position*2 + 1, static_cast<char>((curVal & ~mask) | style));
+bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) {
+	styleValue &= mask;
+	char curVal = style.ValueAt(position);
+	if ((curVal & mask) != styleValue) {
+		style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
 		return true;
 	} else {
 		return false;
 	}
 }
 
-bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) {
-	int bytePos = position * 2 + 1;
+bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) {
 	bool changed = false;
 	PLATFORM_ASSERT(lengthStyle == 0 ||
-		(lengthStyle > 0 && lengthStyle + position < length));
+		(lengthStyle > 0 && lengthStyle + position <= style.Length()));
 	while (lengthStyle--) {
-		char curVal = ByteAt(bytePos);
-		if ((curVal & mask) != style) {
-			SetByteAt(bytePos, static_cast<char>((curVal & ~mask) | style));
+		char curVal = style.ValueAt(position);
+		if ((curVal & mask) != styleValue) {
+			style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
 			changed = true;
 		}
-		bytePos += 2;
+		position++;
 	}
 	return changed;
 }
 
-const char *CellBuffer::DeleteChars(int position, int deleteLength) {
+// The char* returned is to an allocation owned by the undo history
+const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) {
 	// InsertString and DeleteChars are the bottleneck though which all changes occur
 	PLATFORM_ASSERT(deleteLength > 0);
 	char *data = 0;
 	if (!readOnly) {
 		if (collectingUndo) {
 			// Save into the undo/redo stack, but only the characters - not the formatting
-			data = new char[deleteLength / 2];
-			for (int i = 0; i < deleteLength / 2; i++) {
-				data[i] = ByteAt(position + i * 2);
+			data = new char[deleteLength];
+			for (int i = 0; i < deleteLength; i++) {
+				data[i] = substance.ValueAt(position + i);
 			}
-			uh.AppendAction(removeAction, position / 2, data, deleteLength / 2);
+			uh.AppendAction(removeAction, position, data, deleteLength, startSequence);
 		}
 
 		BasicDeleteChars(position, deleteLength);
@@ -779,39 +657,26 @@
 	return data;
 }
 
-int CellBuffer::ByteLength() {
-	return length;
-}
-
-int CellBuffer::Length() {
-	return ByteLength() / 2;
+int CellBuffer::Length() const {
+	return substance.Length();
 }
 
 void CellBuffer::Allocate(int newSize) {
-	if (newSize > length) {
-		GapTo(length);
-		char *newBody = new char[newSize];
-		memcpy(newBody, body, length);
-		delete []body;
-		body = newBody;
-		gaplen += newSize - size;
-		part2body = body + gaplen;
-		size = newSize;
-	}
+	substance.ReAllocate(newSize);
+	style.ReAllocate(newSize);
 }
 
-int CellBuffer::Lines() {
-	//Platform::DebugPrintf("Lines = %d\n", lv.lines);
-	return lv.lines;
+int CellBuffer::Lines() const {
+	return lv.Lines();
 }
 
-int CellBuffer::LineStart(int line) {
+int CellBuffer::LineStart(int line) const {
 	if (line < 0)
 		return 0;
-	else if (line > lv.lines)
+	else if (line >= Lines())
 		return Length();
 	else
-		return lv.linesData[line].startPosition;
+		return lv.LineStart(line);
 }
 
 bool CellBuffer::IsReadOnly() {
@@ -831,14 +696,14 @@
 }
 
 int CellBuffer::AddMark(int line, int markerNum) {
-	if ((line >= 0) && (line < lv.lines)) {
+	if ((line >= 0) && (line < Lines())) {
 		return lv.AddMark(line, markerNum);
 	}
 	return - 1;
 }
 
 void CellBuffer::DeleteMark(int line, int markerNum) {
-	if ((line >= 0) && (line < lv.lines)) {
+	if ((line >= 0) && (line < Lines())) {
 		lv.DeleteMark(line, markerNum, false);
 	}
 }
@@ -848,13 +713,13 @@
 }
 
 int CellBuffer::GetMark(int line) {
-	if ((line >= 0) && (line < lv.lines) && (lv.linesData[line].handleSet))
-		return lv.linesData[line].handleSet->MarkValue();
+	if ((line >= 0) && (line < Lines()))
+		return lv.MarkValue(line);
 	return 0;
 }
 
 void CellBuffer::DeleteAllMarks(int markerNum) {
-	for (int line = 0; line < lv.lines; line++) {
+	for (int line = 0; line < Lines(); line++) {
 		lv.DeleteMark(line, markerNum, true);
 	}
 }
@@ -865,119 +730,102 @@
 
 // Without undo
 
-void CellBuffer::BasicInsertString(int position, char *s, int insertLength) {
-	//Platform::DebugPrintf("Inserting at %d for %d\n", position, insertLength);
+void CellBuffer::InsertLine(int line, int position) {
+	lv.InsertLine(line, position);
+	if (lineStates.Length()) {
+		lineStates.EnsureLength(line);
+		lineStates.Insert(line, 0);
+	}
+}
+
+void CellBuffer::RemoveLine(int line) {
+	lv.RemoveLine(line);
+	if (lineStates.Length() > line) {
+		lineStates.Delete(line);
+	}
+}
+
+void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) {
 	if (insertLength == 0)
-		return ;
+		return;
 	PLATFORM_ASSERT(insertLength > 0);
-	RoomFor(insertLength);
-	GapTo(position);
 
-	memcpy(body + part1len, s, insertLength);
-	length += insertLength;
-	part1len += insertLength;
-	gaplen -= insertLength;
-	part2body = body + gaplen;
+	substance.InsertFromArray(position, s, 0, insertLength);
+	style.InsertValue(position, insertLength, 0);
 
-	int lineInsert = lv.LineFromPosition(position / 2) + 1;
+	int lineInsert = lv.LineFromPosition(position) + 1;
 	// Point all the lines after the insertion point further along in the buffer
-	for (int lineAfter = lineInsert; lineAfter <= lv.lines; lineAfter++) {
-		lv.linesData[lineAfter].startPosition += insertLength / 2;
-	}
-	char chPrev = ' ';
-	if ((position - 2) >= 0)
-		chPrev = ByteAt(position - 2);
-	char chAfter = ' ';
-	if ((position + insertLength) < length)
-		chAfter = ByteAt(position + insertLength);
+	lv.InsertText(lineInsert-1, insertLength);
+	char chPrev = substance.ValueAt(position - 1);
+	char chAfter = substance.ValueAt(position + insertLength);
 	if (chPrev == '\r' && chAfter == '\n') {
-		//Platform::DebugPrintf("Splitting a crlf pair at %d\n", lineInsert);
 		// Splitting up a crlf pair at position
-		lv.InsertValue(lineInsert, position / 2);
+		InsertLine(lineInsert, position);
 		lineInsert++;
 	}
 	char ch = ' ';
-	for (int i = 0; i < insertLength; i += 2) {
+	for (int i = 0; i < insertLength; i++) {
 		ch = s[i];
 		if (ch == '\r') {
-			//Platform::DebugPrintf("Inserting cr at %d\n", lineInsert);
-			lv.InsertValue(lineInsert, (position + i) / 2 + 1);
+			InsertLine(lineInsert, (position + i) + 1);
 			lineInsert++;
 		} else if (ch == '\n') {
 			if (chPrev == '\r') {
-				//Platform::DebugPrintf("Patching cr before lf at %d\n", lineInsert-1);
 				// Patch up what was end of line
-				lv.SetValue(lineInsert - 1, (position + i) / 2 + 1);
+				lv.SetLineStart(lineInsert - 1, (position + i) + 1);
 			} else {
-				//Platform::DebugPrintf("Inserting lf at %d\n", lineInsert);
-				lv.InsertValue(lineInsert, (position + i) / 2 + 1);
+				InsertLine(lineInsert, (position + i) + 1);
 				lineInsert++;
 			}
 		}
 		chPrev = ch;
 	}
-	// Joining two lines where last insertion is cr and following text starts with lf
+	// Joining two lines where last insertion is cr and following substance starts with lf
 	if (chAfter == '\n') {
 		if (ch == '\r') {
-			//Platform::DebugPrintf("Joining cr before lf at %d\n", lineInsert-1);
 			// End of line already in buffer so drop the newly created one
-			lv.Remove(lineInsert - 1);
+			RemoveLine(lineInsert - 1);
 		}
 	}
 }
 
 void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
-	//Platform::DebugPrintf("Deleting at %d for %d\n", position, deleteLength);
 	if (deleteLength == 0)
-		return ;
+		return;
 
-	if ((position == 0) && (deleteLength == length)) {
+	if ((position == 0) && (deleteLength == substance.Length())) {
 		// If whole buffer is being deleted, faster to reinitialise lines data
 		// than to delete each line.
-		//printf("Whole buffer being deleted\n");
 		lv.Init();
 	} else {
 		// Have to fix up line positions before doing deletion as looking at text in buffer
 		// to work out which lines have been removed
 
-		int lineRemove = lv.LineFromPosition(position / 2) + 1;
-		// Point all the lines after the insertion point further along in the buffer
-		for (int lineAfter = lineRemove; lineAfter <= lv.lines; lineAfter++) {
-			lv.linesData[lineAfter].startPosition -= deleteLength / 2;
-		}
-		char chPrev = ' ';
-		if (position >= 2)
-			chPrev = ByteAt(position - 2);
+		int lineRemove = lv.LineFromPosition(position) + 1;
+		lv.InsertText(lineRemove-1, - (deleteLength));
+		char chPrev = substance.ValueAt(position - 1);
 		char chBefore = chPrev;
-		char chNext = ' ';
-		if (position < length)
-			chNext = ByteAt(position);
+		char chNext = substance.ValueAt(position);
 		bool ignoreNL = false;
 		if (chPrev == '\r' && chNext == '\n') {
-			//Platform::DebugPrintf("Deleting lf after cr, move line end to cr at %d\n", lineRemove);
 			// Move back one
-			lv.SetValue(lineRemove, position / 2);
+			lv.SetLineStart(lineRemove, position);
 			lineRemove++;
 			ignoreNL = true; 	// First \n is not real deletion
 		}
 
 		char ch = chNext;
-		for (int i = 0; i < deleteLength; i += 2) {
-			chNext = ' ';
-			if ((position + i + 2) < length)
-				chNext = ByteAt(position + i + 2);
-			//Platform::DebugPrintf("Deleting %d %x\n", i, ch);
+		for (int i = 0; i < deleteLength; i++) {
+			chNext = substance.ValueAt(position + i + 1);
 			if (ch == '\r') {
 				if (chNext != '\n') {
-					//Platform::DebugPrintf("Removing cr end of line\n");
-					lv.Remove(lineRemove);
+					RemoveLine(lineRemove);
 				}
 			} else if (ch == '\n') {
 				if (ignoreNL) {
 					ignoreNL = false; 	// Further \n are real deletions
 				} else {
-					//Platform::DebugPrintf("Removing lf end of line\n");
-					lv.Remove(lineRemove);
+					RemoveLine(lineRemove);
 				}
 			}
 
@@ -985,20 +833,15 @@
 		}
 		// May have to fix up end if last deletion causes cr to be next to lf
 		// or removes one of a crlf pair
-		char chAfter = ' ';
-		if ((position + deleteLength) < length)
-			chAfter = ByteAt(position + deleteLength);
+		char chAfter = substance.ValueAt(position + deleteLength);
 		if (chBefore == '\r' && chAfter == '\n') {
-			//d.printf("Joining cr before lf at %d\n", lineRemove);
 			// Using lineRemove-1 as cr ended line before start of deletion
-			lv.Remove(lineRemove - 1);
-			lv.SetValue(lineRemove - 1, position / 2 + 1);
+			RemoveLine(lineRemove - 1);
+			lv.SetLineStart(lineRemove - 1, position + 1);
 		}
 	}
-	GapTo(position);
-	length -= deleteLength;
-	gaplen += deleteLength;
-	part2body = body + gaplen;
+	substance.DeleteRange(position, deleteLength);
+	style.DeleteRange(position, deleteLength);
 }
 
 bool CellBuffer::SetUndoCollection(bool collectUndo) {
@@ -1038,15 +881,9 @@
 void CellBuffer::PerformUndoStep() {
 	const Action &actionStep = uh.GetUndoStep();
 	if (actionStep.at == insertAction) {
-		BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);
+		BasicDeleteChars(actionStep.position, actionStep.lenData);
 	} else if (actionStep.at == removeAction) {
-		char *styledData = new char[actionStep.lenData * 2];
-		for (int i = 0; i < actionStep.lenData; i++) {
-			styledData[i*2] = actionStep.data[i];
-			styledData[i*2 + 1] = 0;
-		}
-		BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);
-		delete []styledData;
+		BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
 	}
 	uh.CompletedUndoStep();
 }
@@ -1066,26 +903,22 @@
 void CellBuffer::PerformRedoStep() {
 	const Action &actionStep = uh.GetRedoStep();
 	if (actionStep.at == insertAction) {
-		char *styledData = new char[actionStep.lenData * 2];
-		for (int i = 0; i < actionStep.lenData; i++) {
-			styledData[i*2] = actionStep.data[i];
-			styledData[i*2 + 1] = 0;
-		}
-		BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);
-		delete []styledData;
+		BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
 	} else if (actionStep.at == removeAction) {
-		BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);
+		BasicDeleteChars(actionStep.position, actionStep.lenData);
 	}
 	uh.CompletedRedoStep();
 }
 
 int CellBuffer::SetLineState(int line, int state) {
+	lineStates.EnsureLength(line + 1);
 	int stateOld = lineStates[line];
 	lineStates[line] = state;
 	return stateOld;
 }
 
 int CellBuffer::GetLineState(int line) {
+	lineStates.EnsureLength(line + 1);
 	return lineStates[line];
 }
 
@@ -1094,25 +927,11 @@
 }
 
 int CellBuffer::SetLevel(int line, int level) {
-	int prev = 0;
-	if ((line >= 0) && (line < lv.lines)) {
-		if (!lv.levels) {
-			lv.ExpandLevels();
-		}
-		prev = lv.levels[line];
-		if (lv.levels[line] != level) {
-			lv.levels[line] = level;
-		}
-	}
-	return prev;
+	return lv.SetLevel(line, level);
 }
 
 int CellBuffer::GetLevel(int line) {
-	if (lv.levels && (line >= 0) && (line < lv.lines)) {
-		return lv.levels[line];
-	} else {
-		return SC_FOLDLEVELBASE;
-	}
+	return lv.GetLevel(line);
 }
 
 void CellBuffer::ClearLevels() {

Modified: trunk/plugins/editor/scintilla/CellBuffer.h
==============================================================================
--- trunk/plugins/editor/scintilla/CellBuffer.h	(original)
+++ trunk/plugins/editor/scintilla/CellBuffer.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef CELLBUFFER_H
 #define CELLBUFFER_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  * This holds the marker identifier and the marker type to display.
  * MarkerHandleNumbers are members of lists.
@@ -27,10 +31,10 @@
 public:
 	MarkerHandleSet();
 	~MarkerHandleSet();
-	int Length();
-	int NumberFromHandle(int handle);
-	int MarkValue();	///< Bit set of marker numbers.
-	bool Contains(int handle);
+	int Length() const;
+	int NumberFromHandle(int handle) const;
+	int MarkValue() const;	///< Bit set of marker numbers.
+	bool Contains(int handle) const;
 	bool InsertHandle(int handle, int markerNum);
 	void RemoveHandle(int handle);
 	bool RemoveNumber(int markerNum);
@@ -38,43 +42,40 @@
 };
 
 /**
- * Each line stores the starting position of the first character of the line in the cell buffer
- * and potentially a marker handle set. Often a line will not have any attached markers.
- */
-struct LineData {
-	int startPosition;
-	MarkerHandleSet *handleSet;
-	LineData() : startPosition(0), handleSet(0) {
-	}
-};
-
-/**
  * The line vector contains information about each of the lines in a cell buffer.
  */
 class LineVector {
-public:
-	int growSize;
-	int lines;
-	LineData *linesData;
-	int size;
-	int *levels;
-	int sizeLevels;
 
+	Partitioning starts;
+	SplitVector<MarkerHandleSet *> markers;
+	SplitVector<int> levels;
 	/// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
 	int handleCurrent;
 
+public:
+
 	LineVector();
 	~LineVector();
 	void Init();
 
-	void Expand(int sizeNew);
 	void ExpandLevels(int sizeNew=-1);
 	void ClearLevels();
-	void InsertValue(int pos, int value);
-	void SetValue(int pos, int value);
-	void Remove(int pos);
+	int SetLevel(int line, int level);
+	int GetLevel(int line);
+
+	void InsertText(int line, int delta);
+	void InsertLine(int line, int position);
+	void SetLineStart(int line, int position);
+	void RemoveLine(int line);
+	int Lines() const {
+		return starts.Partitions();
+	}
 	int LineFromPosition(int pos);
+	int LineStart(int line) const {
+		return starts.PositionFromPartition(line);
+	}
 
+	int MarkValue(int line);
 	int AddMark(int line, int marker);
 	void MergeMarkers(int pos);
 	void DeleteMark(int line, int markerNum, bool all);
@@ -119,7 +120,7 @@
 	UndoHistory();
 	~UndoHistory();
 
-	void AppendAction(actionType at, int position, char *data, int length);
+	void AppendAction(actionType at, int position, char *data, int length, bool &startSequence);
 
 	void BeginUndoAction();
 	void EndUndoAction();
@@ -150,54 +151,43 @@
  */
 class CellBuffer {
 private:
-	char *body;		///< The cell buffer itself.
-	int size;		///< Allocated size of the buffer.
-	int length;		///< Total length of the data.
-	int part1len;	///< Length of the first part.
-	int gaplen;		///< Length of the gap between the two parts.
-	char *part2body;	///< The second part of the cell buffer.
-						///< Doesn't point after the gap but set so that
-						///< part2body[position] is consistent with body[position].
+	SplitVector<char> substance;
+	SplitVector<char> style;
 	bool readOnly;
-	int growSize;
 
 	bool collectingUndo;
 	UndoHistory uh;
 
 	LineVector lv;
 
-	SVector lineStates;
-
-	void GapTo(int position);
-	void RoomFor(int insertionLength);
-
-	inline char ByteAt(int position);
-	void SetByteAt(int position, char ch);
+	SplitVector<int> lineStates;
 
 public:
 
-	CellBuffer(int initialLength = 4000);
+	CellBuffer();
 	~CellBuffer();
 
 	/// Retrieving positions outside the range of the buffer works and returns 0
-	char CharAt(int position);
+	char CharAt(int position) const;
 	void GetCharRange(char *buffer, int position, int lengthRetrieve);
 	char StyleAt(int position);
+	const char *BufferPointer();
 
-	int ByteLength();
-	int Length();
+	int Length() const;
 	void Allocate(int newSize);
-	int Lines();
-	int LineStart(int line);
+	int Lines() const;
+	int LineStart(int line) const;
 	int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
-	const char *InsertString(int position, char *s, int insertLength);
+	void InsertLine(int line, int position);
+	void RemoveLine(int line);
+	const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);
 
 	/// Setting styles for positions outside the range of the buffer is safe and has no effect.
 	/// @return true if the style of a character is changed.
-	bool SetStyleAt(int position, char style, char mask='\377');
-	bool SetStyleFor(int position, int length, char style, char mask);
+	bool SetStyleAt(int position, char styleValue, char mask='\377');
+	bool SetStyleFor(int position, int length, char styleValue, char mask);
 
-	const char *DeleteChars(int position, int deleteLength);
+	const char *DeleteChars(int position, int deleteLength, bool &startSequence);
 
 	bool IsReadOnly();
 	void SetReadOnly(bool set);
@@ -216,7 +206,7 @@
 	int LineFromHandle(int markerHandle);
 
 	/// Actions without undo
-	void BasicInsertString(int position, char *s, int insertLength);
+	void BasicInsertString(int position, const char *s, int insertLength);
 	void BasicDeleteChars(int position, int deleteLength);
 
 	bool SetUndoCollection(bool collectUndo);
@@ -245,6 +235,8 @@
 	void ClearLevels();
 };
 
-#define CELL_SIZE	2
+#ifdef SCI_NAMESPACE
+}
+#endif
 
 #endif

Added: trunk/plugins/editor/scintilla/CharacterSet.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/CharacterSet.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,58 @@
+// Scintilla source code edit control
+/** @file CharacterSet.h
+ ** Encapsulates a set of characters. Used to test if a character is within a set.
+ **/
+// Copyright 2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+class CharacterSet {
+	int size;
+	bool valueAfter;
+	bool *bset;
+public:
+	enum setBase {
+		setNone=0,
+		setLower=1,
+		setUpper=2,
+		setDigits=4,
+		setAlpha=setLower|setUpper,
+		setAlphaNum=setAlpha|setDigits
+	};
+	CharacterSet(setBase base=setNone, const char *initialSet="", int size_=0x80, bool valueAfter_=false) {
+		size = size_;
+		valueAfter = valueAfter_;
+		bset = new bool[size];
+		for (int i=0; i < size; i++) {
+			bset[i] = false;
+		}
+		AddString(initialSet);
+		if (base & setLower)
+			AddString("abcdefghijklmnopqrstuvwxyz");
+		if (base & setUpper)
+			AddString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+		if (base & setDigits)
+			AddString("0123456789");
+	}
+	~CharacterSet() {
+		delete []bset;
+		bset = 0;
+		size = 0;
+	}
+	void Add(int val) {
+		PLATFORM_ASSERT(val >= 0);
+		PLATFORM_ASSERT(val < size);
+		bset[val] = true;
+	}
+	void AddString(const char *CharacterSet) {
+		for (const char *cp=CharacterSet; *cp; cp++) {
+			int val = static_cast<unsigned char>(*cp);
+			PLATFORM_ASSERT(val >= 0);
+			PLATFORM_ASSERT(val < size);
+			bset[val] = true;
+		}
+	}
+	bool Contains(int val) const {
+		PLATFORM_ASSERT(val >= 0);
+		return (val < size) ? bset[val] : valueAfter;
+	}
+};

Modified: trunk/plugins/editor/scintilla/ContractionState.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/ContractionState.cxx	(original)
+++ trunk/plugins/editor/scintilla/ContractionState.cxx	Sat Nov 15 17:50:33 2008
@@ -1,289 +1,251 @@
 // Scintilla source code edit control
 /** @file ContractionState.cxx
- ** Manages visibility of lines for folding.
+ ** Manages visibility of lines for folding and wrapping.
  **/
-// Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#include <string.h>
+
 #include "Platform.h"
 
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "ContractionState.h"
 
-OneLine::OneLine() {
-	displayLine = 0;
-	//docLine = 0;
-	visible = true;
-	height = 1;
-	expanded = true;
-}
-
-ContractionState::ContractionState() {
-	lines = 0;
-	size = 0;
-	linesInDoc = 1;
-	linesInDisplay = 1;
-	valid = false;
-	docLines = 0;
-	sizeDocLines = 0;
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) {
+	//InsertLine(0);
 }
 
 ContractionState::~ContractionState() {
 	Clear();
 }
 
-void ContractionState::MakeValid() const {
-	if (!valid) {
-		// Could be cleverer by keeping the index of the last still valid entry
-		// rather than invalidating all.
-		linesInDisplay = 0;
-		for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
-			lines[lineInDoc].displayLine = linesInDisplay;
-			if (lines[lineInDoc].visible) {
-				linesInDisplay += lines[lineInDoc].height;
-			}
-		}
-		if (sizeDocLines < linesInDisplay) {
-			delete []docLines;
-			int *docLinesNew = new int[linesInDisplay + growSize];
-			if (!docLinesNew) {
-				docLines = 0;
-				sizeDocLines = 0;
-				return;
-			}
-			docLines = docLinesNew;
-			sizeDocLines = linesInDisplay + growSize;
-		}
-
-		int lineInDisplay=0;
-		for (int line=0; line<linesInDoc; line++) {
-			if (lines[line].visible) {
-				for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
-					docLines[lineInDisplay] = line;
-					lineInDisplay++;
-				}
-			}
-		}
-		valid = true;
+void ContractionState::EnsureData() {
+	if (OneToOne()) {
+		visible = new RunStyles();
+		expanded = new RunStyles();
+		heights = new RunStyles();
+		displayLines = new Partitioning(4);
+		InsertLines(0, linesInDocument);
 	}
 }
 
 void ContractionState::Clear() {
-	delete []lines;
-	lines = 0;
-	size = 0;
-	linesInDoc = 1;
-	linesInDisplay = 1;
-	delete []docLines;
-	docLines = 0;
-	sizeDocLines = 0;
+	delete visible;
+	visible = 0;
+	delete expanded;
+	expanded = 0;
+	delete heights;
+	heights = 0;
+	delete displayLines;
+	displayLines = 0;
+	linesInDocument = 1;
 }
 
 int ContractionState::LinesInDoc() const {
-	return linesInDoc;
+	if (OneToOne()) {
+		return linesInDocument;
+	} else {
+		return displayLines->Partitions() - 1;
+	}
 }
 
 int ContractionState::LinesDisplayed() const {
-	if (size != 0) {
-		MakeValid();
+	if (OneToOne()) {
+		return linesInDocument;
+	} else {
+		return displayLines->PositionFromPartition(LinesInDoc());
 	}
-	return linesInDisplay;
 }
 
 int ContractionState::DisplayFromDoc(int lineDoc) const {
-	if (size == 0) {
+	if (OneToOne()) {
 		return lineDoc;
+	} else {
+		if (lineDoc > displayLines->Partitions())
+			lineDoc = displayLines->Partitions();
+		return displayLines->PositionFromPartition(lineDoc);
 	}
-	MakeValid();
-	if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
-		return lines[lineDoc].displayLine;
-	}
-	return -1;
 }
 
 int ContractionState::DocFromDisplay(int lineDisplay) const {
-	if (lineDisplay <= 0)
-		return 0;
-	if (lineDisplay >= linesInDisplay)
-		return linesInDoc;
-	if (size == 0)
+	if (OneToOne()) {
 		return lineDisplay;
-	MakeValid();
-	if (docLines) {	// Valid allocation
-		return docLines[lineDisplay];
 	} else {
-		return 0;
+		if (lineDisplay <= 0) {
+			return 0;
+		}
+		if (lineDisplay > LinesDisplayed()) {
+			return displayLines->PartitionFromPosition(LinesDisplayed());
+		}
+		int lineDoc = displayLines->PartitionFromPosition(lineDisplay);
+		PLATFORM_ASSERT(GetVisible(lineDoc));
+		return lineDoc;
 	}
 }
 
-void ContractionState::Grow(int sizeNew) {
-	OneLine *linesNew = new OneLine[sizeNew];
-	if (linesNew) {
-		int i = 0;
-		for (; i < size; i++) {
-			linesNew[i] = lines[i];
-		}
-		for (; i < sizeNew; i++) {
-			linesNew[i].displayLine = i;
-		}
-		delete []lines;
-		lines = linesNew;
-		size = sizeNew;
-		valid = false;
-	} else {
-		Platform::DebugPrintf("No memory available\n");
-		// TODO: Blow up
+void ContractionState::InsertLine(int lineDoc) {
+	if (OneToOne()) {
+		linesInDocument++;
+	} else {
+		visible->InsertSpace(lineDoc, 1);
+		visible->SetValueAt(lineDoc, 1);
+		expanded->InsertSpace(lineDoc, 1);
+		expanded->SetValueAt(lineDoc, 1);
+		heights->InsertSpace(lineDoc, 1);
+		heights->SetValueAt(lineDoc, 1);
+		int lineDisplay = DisplayFromDoc(lineDoc);
+		displayLines->InsertPartition(lineDoc, lineDisplay);
+		displayLines->InsertText(lineDoc, 1);
 	}
 }
 
 void ContractionState::InsertLines(int lineDoc, int lineCount) {
-	if (size == 0) {
-		linesInDoc += lineCount;
-		linesInDisplay += lineCount;
-		return;
-	}
-	//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
-	if ((linesInDoc + lineCount + 2) >= size) {
-		Grow(linesInDoc + lineCount + growSize);
-	}
-	linesInDoc += lineCount;
-	for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
-		lines[i].visible = lines[i - lineCount].visible;
-		lines[i].height = lines[i - lineCount].height;
-		linesInDisplay += lines[i].height;
-		lines[i].expanded = lines[i - lineCount].expanded;
-	}
-	for (int d=0;d<lineCount;d++) {
-		lines[lineDoc+d].visible = true;	// Should inherit visibility from context ?
-		lines[lineDoc+d].height = 1;
-		lines[lineDoc+d].expanded = true;
+	for (int l = 0; l < lineCount; l++) {
+		InsertLine(lineDoc + l);
+	}
+	Check();
+}
+
+void ContractionState::DeleteLine(int lineDoc) {
+	if (OneToOne()) {
+		linesInDocument--;
+	} else {
+		if (GetVisible(lineDoc)) {
+			displayLines->InsertText(lineDoc, -heights->ValueAt(lineDoc));
+		}
+		displayLines->RemovePartition(lineDoc);
+		visible->DeleteRange(lineDoc, 1);
+		expanded->DeleteRange(lineDoc, 1);
+		heights->DeleteRange(lineDoc, 1);
 	}
-	valid = false;
 }
 
 void ContractionState::DeleteLines(int lineDoc, int lineCount) {
-	if (size == 0) {
-		linesInDoc -= lineCount;
-		linesInDisplay -= lineCount;
-		return;
-	}
-	int deltaDisplayed = 0;
-	for (int d=0;d<lineCount;d++) {
-		if (lines[lineDoc+d].visible)
-			deltaDisplayed -= lines[lineDoc+d].height;
-	}
-	for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
-		if (i != 0) // Line zero is always visible
-			lines[i].visible = lines[i + lineCount].visible;
-		lines[i].expanded = lines[i + lineCount].expanded;
-		lines[i].height = lines[i + lineCount].height;
-	}
-	linesInDoc -= lineCount;
-	linesInDisplay += deltaDisplayed;
-	valid = false;
+	for (int l = 0; l < lineCount; l++) {
+		DeleteLine(lineDoc);
+	}
+	Check();
 }
 
 bool ContractionState::GetVisible(int lineDoc) const {
-	if (size == 0)
+	if (OneToOne()) {
 		return true;
-	if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
-		return lines[lineDoc].visible;
 	} else {
-		return false;
+		if (lineDoc >= visible->Length())
+			return true;
+		return visible->ValueAt(lineDoc) == 1;
 	}
 }
 
-bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
-	if (lineDocStart == 0)
-		lineDocStart++;
-	if (lineDocStart > lineDocEnd)
+bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible_) {
+	if (OneToOne() && visible_) {
 		return false;
-	if (size == 0) {
-		Grow(linesInDoc + growSize);
-	}
-	// TODO: modify docLine members to mirror displayLine
-	int delta = 0;
-	// Change lineDocs
-	if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
-		for (int line=lineDocStart; line <= lineDocEnd; line++) {
-			if (lines[line].visible != visible) {
-				delta += visible ? lines[line].height : -lines[line].height;
-				lines[line].visible = visible;
+	} else {
+		EnsureData();
+		int delta = 0;
+		Check();
+		if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
+			for (int line = lineDocStart; line <= lineDocEnd; line++) {
+				if (GetVisible(line) != visible_) {
+					int difference = visible_ ? heights->ValueAt(line) : -heights->ValueAt(line);
+					visible->SetValueAt(line, visible_ ? 1 : 0);
+					displayLines->InsertText(line, difference);
+					delta += difference;
+				}
 			}
+		} else {
+			return false;
 		}
+		Check();
+		return delta != 0;
 	}
-	linesInDisplay += delta;
-	valid = false;
-	return delta != 0;
 }
 
 bool ContractionState::GetExpanded(int lineDoc) const {
-	if (size == 0)
+	if (OneToOne()) {
 		return true;
-	if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
-		return lines[lineDoc].expanded;
 	} else {
-		return false;
+		Check();
+		return expanded->ValueAt(lineDoc) == 1;
 	}
 }
 
-bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
-	if (size == 0) {
-		if (expanded) {
-			// If in completely expanded state then setting
-			// one line to expanded has no effect.
-			return false;
-		}
-		Grow(linesInDoc + growSize);
-	}
-	if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
-		if (lines[lineDoc].expanded != expanded) {
-			lines[lineDoc].expanded = expanded;
+bool ContractionState::SetExpanded(int lineDoc, bool expanded_) {
+	if (OneToOne() && expanded_) {
+		return false;
+	} else {
+		EnsureData();
+		if (expanded_ != (expanded->ValueAt(lineDoc) == 1)) {
+			expanded->SetValueAt(lineDoc, expanded_ ? 1 : 0);
+			Check();
 			return true;
+		} else {
+			Check();
+			return false;
 		}
 	}
-	return false;
 }
 
 int ContractionState::GetHeight(int lineDoc) const {
-	if (size == 0)
+	if (OneToOne()) {
 		return 1;
-	if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
-		return lines[lineDoc].height;
 	} else {
-		return 1;
+		return heights->ValueAt(lineDoc);
 	}
 }
 
 // Set the number of display lines needed for this line.
 // Return true if this is a change.
 bool ContractionState::SetHeight(int lineDoc, int height) {
-	if (lineDoc > linesInDoc)
+	if (OneToOne() && (height == 1)) {
 		return false;
-	if (size == 0) {
-		if (height == 1) {
-			// If in completely expanded state then all lines
-			// assumed to have height of one so no effect here.
+	} else {
+		EnsureData();
+		if (GetHeight(lineDoc) != height) {
+			if (GetVisible(lineDoc)) {
+				displayLines->InsertText(lineDoc, height - GetHeight(lineDoc));
+			}
+			heights->SetValueAt(lineDoc, height);
+			Check();
+			return true;
+		} else {
+			Check();
 			return false;
 		}
-		Grow(linesInDoc + growSize);
-	}
-	if (lines[lineDoc].height != height) {
-		lines[lineDoc].height = height;
-		valid = false;
-		return true;
-	} else {
-		return false;
 	}
 }
 
 void ContractionState::ShowAll() {
-	delete []lines;
-	lines = 0;
-	size = 0;
-
-	delete []docLines;
-	docLines = 0;
-	sizeDocLines = 0;
+	int lines = LinesInDoc();
+	Clear();
+	linesInDocument = lines;
+}
+
+// Debugging checks
 
-	linesInDisplay = linesInDoc;
+void ContractionState::Check() const {
+#ifdef CHECK_CORRECTNESS
+	for (int vline = 0;vline < LinesDisplayed(); vline++) {
+		const int lineDoc = DocFromDisplay(vline);
+		PLATFORM_ASSERT(GetVisible(lineDoc));
+	}
+	for (int lineDoc = 0;lineDoc < LinesInDoc(); lineDoc++) {
+		const int displayThis = DisplayFromDoc(lineDoc);
+		const int displayNext = DisplayFromDoc(lineDoc + 1);
+		const int height = displayNext - displayThis;
+		PLATFORM_ASSERT(height >= 0);
+		if (GetVisible(lineDoc)) {
+			PLATFORM_ASSERT(GetHeight(lineDoc) == height);
+		} else {
+			PLATFORM_ASSERT(0 == height);
+		}
+	}
+#endif
 }

Modified: trunk/plugins/editor/scintilla/ContractionState.h
==============================================================================
--- trunk/plugins/editor/scintilla/ContractionState.h	(original)
+++ trunk/plugins/editor/scintilla/ContractionState.h	Sat Nov 15 17:50:33 2008
@@ -1,40 +1,34 @@
 // Scintilla source code edit control
 /** @file ContractionState.h
- ** Manages visibility of lines for folding.
+ ** Manages visibility of lines for folding and wrapping.
  **/
-// Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 #ifndef CONTRACTIONSTATE_H
 #define CONTRACTIONSTATE_H
 
-/**
- */
-class OneLine {
-public:
-	int displayLine;	///< Position within set of visible lines
-	//int docLine;		///< Inverse of @a displayLine
-	int height;	///< Number of display lines needed to show all of the line
-	bool visible;
-	bool expanded;
-
-	OneLine();
-	virtual ~OneLine() {}
-};
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
 
 /**
  */
 class ContractionState {
-	void Grow(int sizeNew);
-	enum { growSize = 4000 };
-	int linesInDoc;
-	mutable int linesInDisplay;
-	mutable OneLine *lines;
-	int size;
-	mutable int *docLines;
-	mutable int sizeDocLines;
-	mutable bool valid;
-	void MakeValid() const;
+	// These contain 1 element for every document line.
+	RunStyles *visible;
+	RunStyles *expanded;
+	RunStyles *heights;
+	Partitioning *displayLines;
+	int linesInDocument;
+
+	void EnsureData();
+
+	bool OneToOne() const {
+		// True when each document line is exactly one display line so need for
+		// complex data structures.
+		return visible == 0;
+	}
 
 public:
 	ContractionState();
@@ -47,7 +41,9 @@
 	int DisplayFromDoc(int lineDoc) const;
 	int DocFromDisplay(int lineDisplay) const;
 
+	void InsertLine(int lineDoc);
 	void InsertLines(int lineDoc, int lineCount);
+	void DeleteLine(int lineDoc);
 	void DeleteLines(int lineDoc, int lineCount);
 
 	bool GetVisible(int lineDoc) const;
@@ -60,6 +56,11 @@
 	bool SetHeight(int lineDoc, int height);
 
 	void ShowAll();
+	void Check() const;
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Added: trunk/plugins/editor/scintilla/Decoration.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/Decoration.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,188 @@
+/** @file Decoration.cxx
+ ** Visual elements added over text.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+#include "Decoration.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) {
+}
+
+Decoration::~Decoration() {
+}
+
+bool Decoration::Empty() {
+	return rs.starts->Partitions() == 1;
+}
+
+DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0),
+	lengthDocument(0), root(0), clickNotified(false) {
+}
+
+DecorationList::~DecorationList() {
+	Decoration *deco = root;
+	while (deco) {
+		Decoration *decoNext = deco->next;
+		delete deco;
+		deco = decoNext;
+	}
+	root = 0;
+	current = 0;
+}
+
+Decoration *DecorationList::DecorationFromIndicator(int indicator) {
+	for (Decoration *deco=root; deco; deco = deco->next) {
+		if (deco->indicator == indicator) {
+			return deco;
+		}
+	}
+	return 0;
+}
+
+Decoration *DecorationList::Create(int indicator, int length) {
+	currentIndicator = indicator;
+	Decoration *decoNew = new Decoration(indicator);
+	decoNew->rs.InsertSpace(0, length);
+
+	Decoration *decoPrev = 0;
+	Decoration *deco = root;
+
+	while (deco && (deco->indicator < indicator)) {
+		decoPrev = deco;
+		deco = deco->next;
+	}
+	if (decoPrev == 0) {
+		decoNew->next = root;
+		root = decoNew;
+	} else {
+		decoNew->next = deco;
+		decoPrev->next = decoNew;
+	}
+	return decoNew;
+}
+
+void DecorationList::Delete(int indicator) {
+	Decoration *decoToDelete = 0;
+	if (root) {
+		if (root->indicator == indicator) {
+			decoToDelete = root;
+			root = root->next;
+		} else {
+			Decoration *deco=root;
+			while (deco->next && !decoToDelete) {
+				if (deco->next && deco->next->indicator == indicator) {
+					decoToDelete = deco->next;
+					deco->next = decoToDelete->next;
+				} else {
+					deco = deco->next;
+				}
+			}
+		}
+	}
+	if (decoToDelete) {
+		delete decoToDelete;
+		current = 0;
+	}
+}
+
+void DecorationList::SetCurrentIndicator(int indicator) {
+	currentIndicator = indicator;
+	current = DecorationFromIndicator(indicator);
+	currentValue = 1;
+}
+
+void DecorationList::SetCurrentValue(int value) {
+	currentValue = value ? value : 1;
+}
+
+bool DecorationList::FillRange(int &position, int value, int &fillLength) {
+	if (!current) {
+		current = DecorationFromIndicator(currentIndicator);
+		if (!current) {
+			current = Create(currentIndicator, lengthDocument);
+		}
+	}
+	bool changed = current->rs.FillRange(position, value, fillLength);
+	if (current->Empty()) {
+		Delete(currentIndicator);
+	}
+	return changed;
+}
+
+void DecorationList::InsertSpace(int position, int insertLength) {
+	lengthDocument += insertLength;
+	for (Decoration *deco=root; deco; deco = deco->next) {
+		deco->rs.InsertSpace(position, insertLength);
+	}
+}
+
+void DecorationList::DeleteRange(int position, int deleteLength) {
+	lengthDocument -= deleteLength;
+	Decoration *deco;
+	for (deco=root; deco; deco = deco->next) {
+		deco->rs.DeleteRange(position, deleteLength);
+	}
+	DeleteAnyEmpty();
+}
+
+void DecorationList::DeleteAnyEmpty() {
+	Decoration *deco = root;
+	while (deco) {
+		if (deco->Empty()) {
+			Delete(deco->indicator);
+			deco = root;
+		} else {
+			deco = deco->next;
+		}
+	}
+}
+
+int DecorationList::AllOnFor(int position) {
+	int mask = 0;
+	for (Decoration *deco=root; deco; deco = deco->next) {
+		if (deco->rs.ValueAt(position)) {
+			mask |= 1 << deco->indicator;
+		}
+	}
+	return mask;
+}
+
+int DecorationList::ValueAt(int indicator, int position) {
+	Decoration *deco = DecorationFromIndicator(indicator);
+	if (deco) {
+		return deco->rs.ValueAt(position);
+	}
+	return 0;
+}
+
+int DecorationList::Start(int indicator, int position) {
+	Decoration *deco = DecorationFromIndicator(indicator);
+	if (deco) {
+		return deco->rs.StartRun(position);
+	}
+	return 0;
+}
+
+int DecorationList::End(int indicator, int position) {
+	Decoration *deco = DecorationFromIndicator(indicator);
+	if (deco) {
+		return deco->rs.EndRun(position);
+	}
+	return 0;
+}

Added: trunk/plugins/editor/scintilla/Decoration.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/Decoration.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,64 @@
+/** @file Decoration.h
+ ** Visual elements added over text.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef DECORATION_H
+#define DECORATION_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+class Decoration {
+public:
+	Decoration *next;
+	RunStyles rs;
+	int indicator;
+
+	Decoration(int indicator_);
+	~Decoration();
+
+	bool Empty();
+};
+
+class DecorationList {
+	int currentIndicator;
+	int currentValue;
+	Decoration *current;
+	int lengthDocument;
+	Decoration *DecorationFromIndicator(int indicator);
+	Decoration *Create(int indicator, int length);
+	void Delete(int indicator);
+	void DeleteAnyEmpty();
+public:
+	Decoration *root;
+	bool clickNotified;
+
+	DecorationList();
+	~DecorationList();
+
+	void SetCurrentIndicator(int indicator);
+	int GetCurrentIndicator() { return currentIndicator; }
+
+	void SetCurrentValue(int value);
+	int GetCurrentValue() { return currentValue; }
+
+	// Returns true if some values may have changed
+	bool FillRange(int &position, int value, int &fillLength);
+
+	void InsertSpace(int position, int insertLength);
+	void DeleteRange(int position, int deleteLength);
+
+	int AllOnFor(int position);
+	int ValueAt(int indicator, int position);
+	int Start(int indicator, int position);
+	int End(int indicator, int position);
+};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif

Modified: trunk/plugins/editor/scintilla/Document.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/Document.cxx	(original)
+++ trunk/plugins/editor/scintilla/Document.cxx	Sat Nov 15 17:50:33 2008
@@ -13,12 +13,19 @@
 #include "Platform.h"
 
 #include "Scintilla.h"
-#include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "CellBuffer.h"
 #include "CharClassify.h"
+#include "Decoration.h"
 #include "Document.h"
 #include "RESearch.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // This is ASCII specific but is safe with chars >= 0x80
 static inline bool isspacechar(unsigned char ch) {
 	return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
@@ -53,7 +60,8 @@
 	stylingMask = 0;
 	endStyled = 0;
 	styleClock = 0;
-	enteredCount = 0;
+	enteredModification = 0;
+	enteredStyling = 0;
 	enteredReadOnlyCount = 0;
 	tabInChars = 8;
 	indentInChars = 0;
@@ -65,8 +73,7 @@
 	lenWatchers = 0;
 
 	matchesValid = false;
-	pre = 0;
-	substituted = 0;
+	regex = 0;
 }
 
 Document::~Document() {
@@ -76,10 +83,8 @@
 	delete []watchers;
 	watchers = 0;
 	lenWatchers = 0;
-	delete pre;
-	pre = 0;
-	delete []substituted;
-	substituted = 0;
+	delete regex;
+	regex = 0;
 }
 
 // Increase reference count and return its previous value.
@@ -104,7 +109,6 @@
 int Document::AddMark(int line, int markerNum) {
 	int prev = cb.AddMark(line, markerNum);
 	DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
-	mh.line = line;
 	NotifyModified(mh);
 	return prev;
 }
@@ -115,14 +119,12 @@
 		if (m & 1)
 			cb.AddMark(line, i);
 	DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
-	mh.line = line;
 	NotifyModified(mh);
 }
 
 void Document::DeleteMark(int line, int markerNum) {
 	cb.DeleteMark(line, markerNum);
 	DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
-	mh.line = line;
 	NotifyModified(mh);
 }
 
@@ -140,11 +142,11 @@
 	NotifyModified(mh);
 }
 
-int Document::LineStart(int line) {
+int Document::LineStart(int line) const {
 	return cb.LineStart(line);
 }
 
-int Document::LineEnd(int line) {
+int Document::LineEnd(int line) const {
 	if (line == LinesTotal() - 1) {
 		return LineStart(line + 1);
 	} else {
@@ -168,7 +170,7 @@
 int Document::VCHomePosition(int position) {
 	int line = LineFromPosition(position);
 	int startPosition = LineStart(line);
-	int endLine = LineStart(line + 1) - 1;
+	int endLine = LineEnd(line);
 	int startText = startPosition;
 	while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t' ) )
 		startText++;
@@ -182,8 +184,7 @@
 	int prev = cb.SetLevel(line, level);
 	if (prev != level) {
 		DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
-		                   LineStart(line), 0, 0, 0);
-		mh.line = line;
+		                   LineStart(line), 0, 0, 0, line);
 		mh.foldLevelNow = level;
 		mh.foldLevelPrev = prev;
 		NotifyModified(mh);
@@ -261,7 +262,9 @@
 		if (ch < 0x80)
 			return 1;
 		int len = 2;
-		if (ch >= (0x80 + 0x40 + 0x20))
+		if (ch >= (0x80 + 0x40 + 0x20 + 0x10))
+			len = 4;
+		else if (ch >= (0x80 + 0x40 + 0x20))
 			len = 3;
 		int lengthDoc = Length();
 		if ((pos + len) > lengthDoc)
@@ -281,6 +284,55 @@
 	}
 }
 
+static bool IsTrailByte(int ch) {
+	return (ch >= 0x80) && (ch < (0x80 + 0x40));
+}
+
+static int BytesFromLead(int leadByte) {
+	if (leadByte > 0xF4) {
+		// Characters longer than 4 bytes not possible in current UTF-8
+		return 0;
+	} else if (leadByte >= 0xF0) {
+		return 4;
+	} else if (leadByte >= 0xE0) {
+		return 3;
+	} else if (leadByte >= 0xC2) {
+		return 2;
+	}
+	return 0;
+}
+
+bool Document::InGoodUTF8(int pos, int &start, int &end) {
+	int lead = pos;
+	while ((lead>0) && (pos-lead < 4) && IsTrailByte(static_cast<unsigned char>(cb.CharAt(lead-1))))
+		lead--;
+	start = 0;
+	if (lead > 0) {
+		start = lead-1;
+	}
+	int leadByte = static_cast<unsigned char>(cb.CharAt(start));
+	int bytes = BytesFromLead(leadByte);
+	if (bytes == 0) {
+		return false;
+	} else {
+		int trailBytes = bytes - 1;
+		int len = pos - lead + 1;
+		if (len > trailBytes)
+			// pos too far from lead
+			return false;
+		// Check that there are enough trails for this lead
+		int trail = pos + 1;
+		while ((trail-lead<trailBytes) && (trail < Length())) {
+			if (!IsTrailByte(static_cast<unsigned char>(cb.CharAt(trail)))) {
+				return false;
+			}
+			trail++;
+		}
+		end = start + bytes;
+		return true;
+	}
+}
+
 // Normalise a position so that it is not halfway through a two byte character.
 // This can occur in two situations -
 // When lines are terminated with \r\n pairs which should be treated as one character.
@@ -307,13 +359,14 @@
 	if (dbcsCodePage) {
 		if (SC_CP_UTF8 == dbcsCodePage) {
 			unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
-			while ((pos > 0) && (pos < Length()) && (ch >= 0x80) && (ch < (0x80 + 0x40))) {
-				// ch is a trail byte
+			int startUTF = pos;
+			int endUTF = pos;
+			if (IsTrailByte(ch) && InGoodUTF8(pos, startUTF, endUTF)) {
+				// ch is a trail byte within a UTF-8 character
 				if (moveDir > 0)
-					pos++;
+					pos = endUTF;
 				else
-					pos--;
-				ch = static_cast<unsigned char>(cb.CharAt(pos));
+					pos = startUTF;
 			}
 		} else {
 			// Anchor DBCS calculations at start of line because start of line can
@@ -358,20 +411,19 @@
 	}
 }
 
-// Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt.
+// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt.
 // SetStyleAt does not change the persistent state of a document
 
-// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 bool Document::DeleteChars(int pos, int len) {
 	if (len == 0)
 		return false;
 	if ((pos + len) > Length())
 		return false;
 	CheckReadOnly();
-	if (enteredCount != 0) {
+	if (enteredModification != 0) {
 		return false;
 	} else {
-		enteredCount++;
+		enteredModification++;
 		if (!cb.IsReadOnly()) {
 			NotifyModified(
 			    DocModification(
@@ -380,7 +432,8 @@
 			        0, 0));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			const char *text = cb.DeleteChars(pos * 2, len * 2);
+			bool startSequence = false;
+			const char *text = cb.DeleteChars(pos, len, startSequence);
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
 			if ((pos < Length()) || (pos == 0))
@@ -389,43 +442,47 @@
 				ModifiedAt(pos-1);
 			NotifyModified(
 			    DocModification(
-			        SC_MOD_DELETETEXT | SC_PERFORMED_USER,
+			        SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
 			        pos, len,
 			        LinesTotal() - prevLinesTotal, text));
 		}
-		enteredCount--;
+		enteredModification--;
 	}
 	return !cb.IsReadOnly();
 }
 
 /**
- * Insert a styled string (char/style pairs) with a length.
+ * Insert a string with a length.
  */
-bool Document::InsertStyledString(int position, char *s, int insertLength) {
+bool Document::InsertString(int position, const char *s, int insertLength) {
+	if (insertLength <= 0) {
+		return false;
+	}
 	CheckReadOnly();
-	if (enteredCount != 0) {
+	if (enteredModification != 0) {
 		return false;
 	} else {
-		enteredCount++;
+		enteredModification++;
 		if (!cb.IsReadOnly()) {
 			NotifyModified(
 			    DocModification(
 			        SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
-			        position / 2, insertLength / 2,
+			        position, insertLength,
 			        0, s));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			const char *text = cb.InsertString(position, s, insertLength);
+			bool startSequence = false;
+			const char *text = cb.InsertString(position, s, insertLength, startSequence);
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
-			ModifiedAt(position / 2);
+			ModifiedAt(position);
 			NotifyModified(
 			    DocModification(
-			        SC_MOD_INSERTTEXT | SC_PERFORMED_USER,
-			        position / 2, insertLength / 2,
+			        SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+			        position, insertLength,
 			        LinesTotal() - prevLinesTotal, text));
 		}
-		enteredCount--;
+		enteredModification--;
 	}
 	return !cb.IsReadOnly();
 }
@@ -433,8 +490,8 @@
 int Document::Undo() {
 	int newPos = -1;
 	CheckReadOnly();
-	if (enteredCount == 0) {
-		enteredCount++;
+	if (enteredModification == 0) {
+		enteredModification++;
 		if (!cb.IsReadOnly()) {
 			bool startSavePoint = cb.IsSavePoint();
 			bool multiLine = false;
@@ -481,7 +538,7 @@
 			if (startSavePoint != endSavePoint)
 				NotifySavePoint(endSavePoint);
 		}
-		enteredCount--;
+		enteredModification--;
 	}
 	return newPos;
 }
@@ -489,8 +546,8 @@
 int Document::Redo() {
 	int newPos = -1;
 	CheckReadOnly();
-	if (enteredCount == 0) {
-		enteredCount++;
+	if (enteredModification == 0) {
+		enteredModification++;
 		if (!cb.IsReadOnly()) {
 			bool startSavePoint = cb.IsSavePoint();
 			bool multiLine = false;
@@ -535,7 +592,7 @@
 			if (startSavePoint != endSavePoint)
 				NotifySavePoint(endSavePoint);
 		}
-		enteredCount--;
+		enteredModification--;
 	}
 	return newPos;
 }
@@ -544,39 +601,18 @@
  * Insert a single character.
  */
 bool Document::InsertChar(int pos, char ch) {
-	char chs[2];
+	char chs[1];
 	chs[0] = ch;
-	chs[1] = 0;
-	return InsertStyledString(pos*2, chs, 2);
+	return InsertString(pos, chs, 1);
 }
 
 /**
  * Insert a null terminated string.
  */
-bool Document::InsertString(int position, const char *s) {
+bool Document::InsertCString(int position, const char *s) {
 	return InsertString(position, s, strlen(s));
 }
 
-/**
- * Insert a string with a length.
- */
-bool Document::InsertString(int position, const char *s, size_t insertLength) {
-	bool changed = false;
-	if (insertLength > 0) {
-		char *sWithStyle = new char[insertLength * 2];
-		if (sWithStyle) {
-			for (size_t i = 0; i < insertLength; i++) {
-				sWithStyle[i*2] = s[i];
-				sWithStyle[i*2 + 1] = 0;
-			}
-			changed = InsertStyledString(position*2, sWithStyle,
-				static_cast<int>(insertLength*2));
-			delete []sWithStyle;
-		}
-	}
-	return changed;
-}
-
 void Document::ChangeChar(int pos, char ch) {
 	DeleteChars(pos, 1);
 	InsertChar(pos, ch);
@@ -653,12 +689,12 @@
 		int indentPos = GetLineIndentPosition(line);
 		BeginUndoAction();
 		DeleteChars(thisLineStart, indentPos - thisLineStart);
-		InsertString(thisLineStart, linebuf);
+		InsertCString(thisLineStart, linebuf);
 		EndUndoAction();
 	}
 }
 
-int Document::GetLineIndentPosition(int line) {
+int Document::GetLineIndentPosition(int line) const {
 	if (line < 0)
 		return 0;
 	int pos = LineStart(line);
@@ -682,9 +718,11 @@
 				return column;
 			} else if (ch == '\n') {
 				return column;
+			} else if (i >= Length()) {
+				return column;
 			} else {
 				column++;
-				i = MovePositionOutsideChar(i + 1, 1);
+				i = MovePositionOutsideChar(i + 1, 1, false);
 			}
 		}
 	}
@@ -706,7 +744,7 @@
 				return position;
 			} else {
 				columnCurrent++;
-				position = MovePositionOutsideChar(position + 1, 1);
+				position = MovePositionOutsideChar(position + 1, 1, false);
 			}
 		}
 	}
@@ -797,7 +835,7 @@
 	EndUndoAction();
 }
 
-bool Document::IsWhiteLine(int line) {
+bool Document::IsWhiteLine(int line) const {
 	int currentChar = LineStart(line);
 	int endLine = LineEnd(line);
 	while (currentChar < endLine) {
@@ -854,7 +892,7 @@
 		while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
 			pos--;
 	} else {
-		if (!onlyWordCharacters)
+		if (!onlyWordCharacters && pos < Length())
 			ccStart = WordCharClass(cb.CharAt(pos));
 		while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
 			pos++;
@@ -974,123 +1012,18 @@
 		return static_cast<char>(ch - 'A' + 'a');
 }
 
-// Define a way for the Regular Expression code to access the document
-class DocumentIndexer : public CharacterIndexer {
-	Document *pdoc;
-	int end;
-public:
-	DocumentIndexer(Document *pdoc_, int end_) :
-		pdoc(pdoc_), end(end_) {
-	}
-
-	virtual ~DocumentIndexer() {
-	}
-
-	virtual char CharAt(int index) {
-		if (index < 0 || index >= end)
-			return 0;
-		else
-			return pdoc->CharAt(index);
-	}
-};
-
 /**
  * Find text in document, supporting both forward and backward
  * searches (just pass minPos > maxPos to do a backward search)
  * Has not been tested with backwards DBCS searches yet.
  */
 long Document::FindText(int minPos, int maxPos, const char *s,
-                        bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix,
+                        bool caseSensitive, bool word, bool wordStart, bool regExp, int flags,
                         int *length) {
 	if (regExp) {
-		if (!pre)
-			pre = new RESearch(&charClass);
-		if (!pre)
-			return -1;
-
-		int increment = (minPos <= maxPos) ? 1 : -1;
-
-		int startPos = minPos;
-		int endPos = maxPos;
-
-		// Range endpoints should not be inside DBCS characters, but just in case, move them.
-		startPos = MovePositionOutsideChar(startPos, 1, false);
-		endPos = MovePositionOutsideChar(endPos, 1, false);
-
-		const char *errmsg = pre->Compile(s, *length, caseSensitive, posix);
-		if (errmsg) {
-			return -1;
-		}
-		// Find a variable in a property file: \$(\([A-Za-z0-9_.]+\))
-		// Replace first '.' with '-' in each property file variable reference:
-		//     Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\))
-		//     Replace: $(\1-\2)
-		int lineRangeStart = LineFromPosition(startPos);
-		int lineRangeEnd = LineFromPosition(endPos);
-		if ((increment == 1) &&
-			(startPos >= LineEnd(lineRangeStart)) &&
-			(lineRangeStart < lineRangeEnd)) {
-			// the start position is at end of line or between line end characters.
-			lineRangeStart++;
-			startPos = LineStart(lineRangeStart);
-		}
-		int pos = -1;
-		int lenRet = 0;
-		char searchEnd = s[*length - 1];
-		int lineRangeBreak = lineRangeEnd + increment;
-		for (int line = lineRangeStart; line != lineRangeBreak; line += increment) {
-			int startOfLine = LineStart(line);
-			int endOfLine = LineEnd(line);
-			if (increment == 1) {
-				if (line == lineRangeStart) {
-					if ((startPos != startOfLine) && (s[0] == '^'))
-						continue;	// Can't match start of line if start position after start of line
-					startOfLine = startPos;
-				}
-				if (line == lineRangeEnd) {
-					if ((endPos != endOfLine) && (searchEnd == '$'))
-						continue;	// Can't match end of line if end position before end of line
-					endOfLine = endPos;
-				}
-			} else {
-				if (line == lineRangeEnd) {
-					if ((endPos != startOfLine) && (s[0] == '^'))
-						continue;	// Can't match start of line if end position after start of line
-					startOfLine = endPos;
-				}
-				if (line == lineRangeStart) {
-					if ((startPos != endOfLine) && (searchEnd == '$'))
-						continue;	// Can't match end of line if start position before end of line
-					endOfLine = startPos;
-				}
-			}
-
-			DocumentIndexer di(this, endOfLine);
-			int success = pre->Execute(di, startOfLine, endOfLine);
-			if (success) {
-				pos = pre->bopat[0];
-				lenRet = pre->eopat[0] - pre->bopat[0];
-				if (increment == -1) {
-					// Check for the last match on this line.
-					int repetitions = 1000;	// Break out of infinite loop
-					while (success && (pre->eopat[0] <= endOfLine) && (repetitions--)) {
-						success = pre->Execute(di, pos+1, endOfLine);
-						if (success) {
-							if (pre->eopat[0] <= minPos) {
-								pos = pre->bopat[0];
-								lenRet = pre->eopat[0] - pre->bopat[0];
-							} else {
-								success = 0;
-							}
-						}
-					}
-				}
-				break;
-			}
-		}
-		*length = lenRet;
-		return pos;
-
+		if (!regex)
+			regex = CreateRegexSearch(&charClass);
+		return regex->FindText(this, minPos, maxPos, s, caseSensitive, word, wordStart, flags, length);
 	} else {
 
 		bool forward = minPos <= maxPos;
@@ -1160,89 +1093,10 @@
 }
 
 const char *Document::SubstituteByPosition(const char *text, int *length) {
-	if (!pre)
-		return 0;
-	delete []substituted;
-	substituted = 0;
-	DocumentIndexer di(this, Length());
-	if (!pre->GrabMatches(di))
-		return 0;
-	unsigned int lenResult = 0;
-	for (int i = 0; i < *length; i++) {
-		if (text[i] == '\\') {
-			if (text[i + 1] >= '1' && text[i + 1] <= '9') {
-				unsigned int patNum = text[i + 1] - '0';
-				lenResult += pre->eopat[patNum] - pre->bopat[patNum];
-				i++;
-			} else {
-				switch (text[i + 1]) {
-				case 'a':
-				case 'b':
-				case 'f':
-				case 'n':
-				case 'r':
-				case 't':
-				case 'v':
-					i++;
-				}
-				lenResult++;
-			}
-		} else {
-			lenResult++;
-		}
-	}
-	substituted = new char[lenResult + 1];
-	if (!substituted)
-		return 0;
-	char *o = substituted;
-	for (int j = 0; j < *length; j++) {
-		if (text[j] == '\\') {
-			if (text[j + 1] >= '1' && text[j + 1] <= '9') {
-				unsigned int patNum = text[j + 1] - '0';
-				unsigned int len = pre->eopat[patNum] - pre->bopat[patNum];
-				if (pre->pat[patNum])	// Will be null if try for a match that did not occur
-					memcpy(o, pre->pat[patNum], len);
-				o += len;
-				j++;
-			} else {
-				j++;
-				switch (text[j]) {
-				case 'a':
-					*o++ = '\a';
-					break;
-				case 'b':
-					*o++ = '\b';
-					break;
-				case 'f':
-					*o++ = '\f';
-					break;
-				case 'n':
-					*o++ = '\n';
-					break;
-				case 'r':
-					*o++ = '\r';
-					break;
-				case 't':
-					*o++ = '\t';
-					break;
-				case 'v':
-					*o++ = '\v';
-					break;
-				default:
-					*o++ = '\\';
-					j--;
-				}
-			}
-		} else {
-			*o++ = text[j];
-		}
-	}
-	*o = '\0';
-	*length = lenResult;
-	return substituted;
+	return regex->SubstituteByPosition(this, text, length);
 }
 
-int Document::LinesTotal() {
+int Document::LinesTotal() const {
 	return cb.Lines();
 }
 
@@ -1275,11 +1129,7 @@
 
 void Document::SetStylingBits(int bits) {
 	stylingBits = bits;
-	stylingBitsMask = 0;
-	for (int bit = 0; bit < stylingBits; bit++) {
-		stylingBitsMask <<= 1;
-		stylingBitsMask |= 1;
-	}
+	stylingBitsMask = (1 << stylingBits) - 1;
 }
 
 void Document::StartStyling(int position, char mask) {
@@ -1288,10 +1138,10 @@
 }
 
 bool Document::SetStyleFor(int length, char style) {
-	if (enteredCount != 0) {
+	if (enteredStyling != 0) {
 		return false;
 	} else {
-		enteredCount++;
+		enteredStyling++;
 		style &= stylingMask;
 		int prevEndStyled = endStyled;
 		if (cb.SetStyleFor(endStyled, length, style, stylingMask)) {
@@ -1300,16 +1150,16 @@
 			NotifyModified(mh);
 		}
 		endStyled += length;
-		enteredCount--;
+		enteredStyling--;
 		return true;
 	}
 }
 
 bool Document::SetStyles(int length, char *styles) {
-	if (enteredCount != 0) {
+	if (enteredStyling != 0) {
 		return false;
 	} else {
-		enteredCount++;
+		enteredStyling++;
 		bool didChange = false;
 		int startMod = 0;
 		int endMod = 0;
@@ -1328,26 +1178,39 @@
 			                   startMod, endMod - startMod + 1);
 			NotifyModified(mh);
 		}
-		enteredCount--;
+		enteredStyling--;
 		return true;
 	}
 }
 
-bool Document::EnsureStyledTo(int pos) {
-	if (pos > GetEndStyled()) {
+void Document::EnsureStyledTo(int pos) {
+	if ((enteredStyling == 0) && (pos > GetEndStyled())) {
 		IncrementStyleClock();
 		// Ask the watchers to style, and stop as soon as one responds.
 		for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) {
 			watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
 		}
 	}
-	return pos <= GetEndStyled();
+}
+
+int Document::SetLineState(int line, int state) {
+	int statePrevious = cb.SetLineState(line, state);
+	if (state != statePrevious) {
+		DocModification mh(SC_MOD_CHANGELINESTATE, 0, 0, 0, 0, line);
+		NotifyModified(mh);
+	}
+	return statePrevious;
 }
 
 void Document::IncrementStyleClock() {
-	styleClock++;
-	if (styleClock > 0x100000) {
-		styleClock = 0;
+	styleClock = (styleClock + 1) % 0x100000;
+}
+
+void Document::DecorationFillRange(int position, int value, int fillLength) {
+	if (decorations.FillRange(position, value, fillLength)) {
+		DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
+							position, fillLength);
+		NotifyModified(mh);
 	}
 }
 
@@ -1408,6 +1271,11 @@
 }
 
 void Document::NotifyModified(DocModification mh) {
+	if (mh.modificationType & SC_MOD_INSERTTEXT) {
+		decorations.InsertSpace(mh.position, mh.length);
+	} else if (mh.modificationType & SC_MOD_DELETETEXT) {
+		decorations.DeleteRange(mh.position, mh.length);
+	}
 	for (int i = 0; i < lenWatchers; i++) {
 		watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
 	}
@@ -1575,3 +1443,222 @@
 	}
 	return - 1;
 }
+
+/**
+ * Implementation of RegexSearchBase for the default built-in regular expression engine
+ */
+class BuiltinRegex : public RegexSearchBase {
+public:
+	BuiltinRegex(CharClassify *charClassTable) : search(charClassTable), substituted(NULL) {}
+
+	virtual ~BuiltinRegex() {
+		delete substituted;
+	}
+
+	virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
+                        bool caseSensitive, bool word, bool wordStart, int flags,
+                        int *length);
+
+	virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length);
+
+private:
+	RESearch search;
+	char *substituted;
+};
+
+// Define a way for the Regular Expression code to access the document
+class DocumentIndexer : public CharacterIndexer {
+	Document *pdoc;
+	int end;
+public:
+	DocumentIndexer(Document *pdoc_, int end_) :
+		pdoc(pdoc_), end(end_) {
+	}
+
+	virtual ~DocumentIndexer() {
+	}
+
+	virtual char CharAt(int index) {
+		if (index < 0 || index >= end)
+			return 0;
+		else
+			return pdoc->CharAt(index);
+	}
+};
+
+long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s,
+                        bool caseSensitive, bool, bool, int flags,
+                        int *length) {
+	bool posix = (flags & SCFIND_POSIX) != 0;
+	int increment = (minPos <= maxPos) ? 1 : -1;
+
+	int startPos = minPos;
+	int endPos = maxPos;
+
+	// Range endpoints should not be inside DBCS characters, but just in case, move them.
+	startPos = doc->MovePositionOutsideChar(startPos, 1, false);
+	endPos = doc->MovePositionOutsideChar(endPos, 1, false);
+
+	const char *errmsg = search.Compile(s, *length, caseSensitive, posix);
+	if (errmsg) {
+		return -1;
+	}
+	// Find a variable in a property file: \$(\([A-Za-z0-9_.]+\))
+	// Replace first '.' with '-' in each property file variable reference:
+	//     Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\))
+	//     Replace: $(\1-\2)
+	int lineRangeStart = doc->LineFromPosition(startPos);
+	int lineRangeEnd = doc->LineFromPosition(endPos);
+	if ((increment == 1) &&
+		(startPos >= doc->LineEnd(lineRangeStart)) &&
+		(lineRangeStart < lineRangeEnd)) {
+		// the start position is at end of line or between line end characters.
+		lineRangeStart++;
+		startPos = doc->LineStart(lineRangeStart);
+	}
+	int pos = -1;
+	int lenRet = 0;
+	char searchEnd = s[*length - 1];
+	int lineRangeBreak = lineRangeEnd + increment;
+	for (int line = lineRangeStart; line != lineRangeBreak; line += increment) {
+		int startOfLine = doc->LineStart(line);
+		int endOfLine = doc->LineEnd(line);
+		if (increment == 1) {
+			if (line == lineRangeStart) {
+				if ((startPos != startOfLine) && (s[0] == '^'))
+					continue;	// Can't match start of line if start position after start of line
+				startOfLine = startPos;
+			}
+			if (line == lineRangeEnd) {
+				if ((endPos != endOfLine) && (searchEnd == '$'))
+					continue;	// Can't match end of line if end position before end of line
+				endOfLine = endPos;
+			}
+		} else {
+			if (line == lineRangeEnd) {
+				if ((endPos != startOfLine) && (s[0] == '^'))
+					continue;	// Can't match start of line if end position after start of line
+				startOfLine = endPos;
+			}
+			if (line == lineRangeStart) {
+				if ((startPos != endOfLine) && (searchEnd == '$'))
+					continue;	// Can't match end of line if start position before end of line
+				endOfLine = startPos;
+			}
+		}
+
+		DocumentIndexer di(doc, endOfLine);
+		int success = search.Execute(di, startOfLine, endOfLine);
+		if (success) {
+			pos = search.bopat[0];
+			lenRet = search.eopat[0] - search.bopat[0];
+			if (increment == -1) {
+				// Check for the last match on this line.
+				int repetitions = 1000;	// Break out of infinite loop
+				while (success && (search.eopat[0] <= endOfLine) && (repetitions--)) {
+					success = search.Execute(di, pos+1, endOfLine);
+					if (success) {
+						if (search.eopat[0] <= minPos) {
+							pos = search.bopat[0];
+							lenRet = search.eopat[0] - search.bopat[0];
+						} else {
+							success = 0;
+						}
+					}
+				}
+			}
+			break;
+		}
+	}
+	*length = lenRet;
+	return pos;
+}
+
+const char *BuiltinRegex::SubstituteByPosition(Document* doc, const char *text, int *length) {
+	delete []substituted;
+	substituted = 0;
+	DocumentIndexer di(doc, doc->Length());
+	if (!search.GrabMatches(di))
+		return 0;
+	unsigned int lenResult = 0;
+	for (int i = 0; i < *length; i++) {
+		if (text[i] == '\\') {
+			if (text[i + 1] >= '1' && text[i + 1] <= '9') {
+				unsigned int patNum = text[i + 1] - '0';
+				lenResult += search.eopat[patNum] - search.bopat[patNum];
+				i++;
+			} else {
+				switch (text[i + 1]) {
+				case 'a':
+				case 'b':
+				case 'f':
+				case 'n':
+				case 'r':
+				case 't':
+				case 'v':
+					i++;
+				}
+				lenResult++;
+			}
+		} else {
+			lenResult++;
+		}
+	}
+	substituted = new char[lenResult + 1];
+	if (!substituted)
+		return 0;
+	char *o = substituted;
+	for (int j = 0; j < *length; j++) {
+		if (text[j] == '\\') {
+			if (text[j + 1] >= '1' && text[j + 1] <= '9') {
+				unsigned int patNum = text[j + 1] - '0';
+				unsigned int len = search.eopat[patNum] - search.bopat[patNum];
+				if (search.pat[patNum])	// Will be null if try for a match that did not occur
+					memcpy(o, search.pat[patNum], len);
+				o += len;
+				j++;
+			} else {
+				j++;
+				switch (text[j]) {
+				case 'a':
+					*o++ = '\a';
+					break;
+				case 'b':
+					*o++ = '\b';
+					break;
+				case 'f':
+					*o++ = '\f';
+					break;
+				case 'n':
+					*o++ = '\n';
+					break;
+				case 'r':
+					*o++ = '\r';
+					break;
+				case 't':
+					*o++ = '\t';
+					break;
+				case 'v':
+					*o++ = '\v';
+					break;
+				default:
+					*o++ = '\\';
+					j--;
+				}
+			}
+		} else {
+			*o++ = text[j];
+		}
+	}
+	*o = '\0';
+	*length = lenResult;
+	return substituted;
+}
+
+#ifndef SCI_OWNREGEX
+
+RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable) {
+	return new BuiltinRegex(charClassTable);
+}
+
+#endif

Modified: trunk/plugins/editor/scintilla/Document.h
==============================================================================
--- trunk/plugins/editor/scintilla/Document.h	(original)
+++ trunk/plugins/editor/scintilla/Document.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef DOCUMENT_H
 #define DOCUMENT_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  * A Position is a position within a document between two characters or at the beginning or end.
  * Sometimes used as a character index where it identifies the character after the position.
@@ -70,7 +74,24 @@
 
 class DocWatcher;
 class DocModification;
-class RESearch;
+class Document;
+
+/**
+ * Interface class for regular expression searching
+ */
+class RegexSearchBase {
+public:
+	virtual ~RegexSearchBase(){}
+
+	virtual long FindText(Document* doc, int minPos, int maxPos, const char *s,
+                        bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
+
+	///@return String with the substitutions, must remain valid until the next call or destruction
+	virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length) = 0;
+};
+
+/// Factory function for RegexSearchBase
+extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable);
 
 /**
  */
@@ -97,15 +118,15 @@
 	char stylingMask;
 	int endStyled;
 	int styleClock;
-	int enteredCount;
+	int enteredModification;
+	int enteredStyling;
 	int enteredReadOnlyCount;
 
 	WatcherWithUserData *watchers;
 	int lenWatchers;
 
 	bool matchesValid;
-	RESearch *pre;
-	char *substituted;
+	RegexSearchBase* regex;
 
 public:
 	int stylingBits;
@@ -121,6 +142,8 @@
 	bool tabIndents;
 	bool backspaceUnindents;
 
+	DecorationList decorations;
+
 	Document();
 	virtual ~Document();
 
@@ -131,12 +154,14 @@
 	int ClampPositionIntoDocument(int pos);
 	bool IsCrLf(int pos);
 	int LenChar(int pos);
+	bool InGoodUTF8(int pos, int &start, int &end);
 	int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
 
 	// Gateways to modifying document
 	void ModifiedAt(int pos);
+	void CheckReadOnly();
 	bool DeleteChars(int pos, int len);
-	bool InsertStyledString(int position, char *s, int insertLength);
+	bool InsertString(int position, const char *s, int insertLength);
 	int Undo();
 	int Redo();
 	bool CanUndo() { return cb.CanUndo(); }
@@ -150,10 +175,11 @@
 	void EndUndoAction() { cb.EndUndoAction(); }
 	void SetSavePoint();
 	bool IsSavePoint() { return cb.IsSavePoint(); }
+	const char *BufferPointer() { return cb.BufferPointer(); }
 
 	int GetLineIndentation(int line);
 	void SetLineIndentation(int line, int indent);
-	int GetLineIndentPosition(int line);
+	int GetLineIndentPosition(int line) const;
 	int GetColumn(int position);
 	int FindColumn(int line, int column);
 	void Indent(bool forwards, int lineBottom, int lineTop);
@@ -163,8 +189,7 @@
 	bool IsReadOnly() { return cb.IsReadOnly(); }
 
 	bool InsertChar(int pos, char ch);
-	bool InsertString(int position, const char *s);
-	bool InsertString(int position, const char *s, size_t insertLength);
+	bool InsertCString(int position, const char *s);
 	void ChangeChar(int pos, char ch);
 	void DelChar(int pos);
 	void DelCharBack(int pos);
@@ -181,8 +206,8 @@
 	void DeleteMarkFromHandle(int markerHandle);
 	void DeleteAllMarks(int markerNum);
 	int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
-	int LineStart(int line);
-	int LineEnd(int line);
+	int LineStart(int line) const;
+	int LineEnd(int line) const;
 	int LineEndPosition(int position);
 	int VCHomePosition(int position);
 
@@ -196,13 +221,13 @@
 	int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
 	int NextWordStart(int pos, int delta);
 	int NextWordEnd(int pos, int delta);
-	int Length() { return cb.Length(); }
-	void Allocate(int newSize) { cb.Allocate(newSize*2); }
+	int Length() const { return cb.Length(); }
+	void Allocate(int newSize) { cb.Allocate(newSize); }
 	long FindText(int minPos, int maxPos, const char *s,
-		bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length);
+		bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length);
 	long FindText(int iMessage, unsigned long wParam, long lParam);
 	const char *SubstituteByPosition(const char *text, int *length);
-	int LinesTotal();
+	int LinesTotal() const;
 
 	void ChangeCase(Range r, bool makeUpperCase);
 
@@ -213,11 +238,12 @@
 	bool SetStyleFor(int length, char style);
 	bool SetStyles(int length, char *styles);
 	int GetEndStyled() { return endStyled; }
-	bool EnsureStyledTo(int pos);
+	void EnsureStyledTo(int pos);
 	int GetStyleClock() { return styleClock; }
 	void IncrementStyleClock();
+	void DecorationFillRange(int position, int value, int fillLength);
 
-	int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
+	int SetLineState(int line, int state);
 	int GetLineState(int line) { return cb.GetLineState(line); }
 	int GetMaxLineState() { return cb.GetMaxLineState(); }
 
@@ -230,15 +256,13 @@
 	int WordPartLeft(int pos);
 	int WordPartRight(int pos);
 	int ExtendStyleRange(int pos, int delta, bool singleLine = false);
-	bool IsWhiteLine(int line);
+	bool IsWhiteLine(int line) const;
 	int ParaUp(int pos);
 	int ParaDown(int pos);
 	int IndentSize() { return actualIndentInChars; }
 	int BraceMatch(int position, int maxReStyle);
 
 private:
-	void CheckReadOnly();
-
 	CharClassify::cc WordCharClass(unsigned char ch);
 	bool IsWordStartAt(int pos);
 	bool IsWordEndAt(int pos);
@@ -302,4 +326,8 @@
 	virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/DocumentAccessor.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/DocumentAccessor.cxx	(original)
+++ trunk/plugins/editor/scintilla/DocumentAccessor.cxx	Sat Nov 15 17:50:33 2008
@@ -13,14 +13,21 @@
 #include "Platform.h"
 
 #include "PropSet.h"
-#include "SVector.h"
 #include "Accessor.h"
 #include "DocumentAccessor.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "CellBuffer.h"
 #include "Scintilla.h"
 #include "CharClassify.h"
+#include "Decoration.h"
 #include "Document.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 DocumentAccessor::~DocumentAccessor() {
 }
 
@@ -103,8 +110,9 @@
 void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
 	// Only perform styling if non empty range
 	if (pos != startSeg - 1) {
+		PLATFORM_ASSERT(pos >= startSeg);
 		if (pos < startSeg) {
-			Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
+			return;
 		}
 
 		if (validLen + (pos - startSeg + 1) >= bufferSize)
@@ -185,3 +193,7 @@
 		return indent;
 }
 
+void DocumentAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+	pdoc->decorations.SetCurrentIndicator(indicator);
+	pdoc->DecorationFillRange(start, value, end - start);
+}

Modified: trunk/plugins/editor/scintilla/DocumentAccessor.h
==============================================================================
--- trunk/plugins/editor/scintilla/DocumentAccessor.h	(original)
+++ trunk/plugins/editor/scintilla/DocumentAccessor.h	Sat Nov 15 17:50:33 2008
@@ -6,6 +6,10 @@
 // Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 class Document;
 
 /**
@@ -64,4 +68,9 @@
 	void ColourTo(unsigned int pos, int chAttr);
 	void SetLevel(int line, int level);
 	int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+	void IndicatorFill(int start, int end, int indicator, int value);
 };
+
+#ifdef SCI_NAMESPACE
+}
+#endif

Modified: trunk/plugins/editor/scintilla/Editor.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/Editor.cxx	(original)
+++ trunk/plugins/editor/scintilla/Editor.cxx	Sat Nov 15 17:50:33 2008
@@ -17,8 +17,10 @@
 #endif
 #include "Scintilla.h"
 
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "ContractionState.h"
-#include "SVector.h"
 #include "CellBuffer.h"
 #include "KeyMap.h"
 #include "Indicator.h"
@@ -27,17 +29,23 @@
 #include "Style.h"
 #include "ViewStyle.h"
 #include "CharClassify.h"
+#include "Decoration.h"
 #include "Document.h"
+#include "PositionCache.h"
 #include "Editor.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
 	return whether this modification represents an operation that
 	may reasonably be deferred (not done now OR [possibly] at all)
 */
 static bool CanDeferToLastStep(const DocModification& mh) {
-	if (mh.modificationType & (SC_MOD_BEFOREINSERT|SC_MOD_BEFOREDELETE))
+	if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
 		return true;	// CAN skip
-	if (!(mh.modificationType & (SC_PERFORMED_UNDO|SC_PERFORMED_REDO)))
+	if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)))
 		return false;	// MUST do
 	if (mh.modificationType & SC_MULTISTEPUNDOREDO)
 		return true;	// CAN skip
@@ -46,7 +54,7 @@
 
 static bool CanEliminate(const DocModification& mh) {
 	return
-		(mh.modificationType & (SC_MOD_BEFOREINSERT|SC_MOD_BEFOREDELETE)) != 0;
+	    (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0;
 }
 
 /*
@@ -55,281 +63,24 @@
 */
 static bool IsLastStep(const DocModification& mh) {
 	return
-		(mh.modificationType & (SC_PERFORMED_UNDO|SC_PERFORMED_REDO)) != 0
-		&& (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
-		&& (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
-		&& (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
+	    (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0
+	    && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
+	    && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
+	    && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
 }
 
 Caret::Caret() :
-active(false), on(false), period(500) {}
+		active(false), on(false), period(500) {}
 
 Timer::Timer() :
-ticking(false), ticksToWait(0), tickerID(0) {}
+		ticking(false), ticksToWait(0), tickerID(0) {}
 
 Idler::Idler() :
-state(false), idlerID(0) {}
-
-LineLayout::LineLayout(int maxLineLength_) :
-	lineStarts(0),
-	lenLineStarts(0),
-	lineNumber(-1),
-	inCache(false),
-	maxLineLength(-1),
-	numCharsInLine(0),
-	validity(llInvalid),
-	xHighlightGuide(0),
-	highlightColumn(0),
-	selStart(0),
-	selEnd(0),
-	containsCaret(false),
-	edgeColumn(0),
-	chars(0),
-	styles(0),
-	styleBitsSet(0),
-	indicators(0),
-	positions(0),
-	hsStart(0),
-	hsEnd(0),
-	widthLine(wrapWidthInfinite),
-	lines(1) {
-	Resize(maxLineLength_);
-}
-
-LineLayout::~LineLayout() {
-	Free();
-}
-
-void LineLayout::Resize(int maxLineLength_) {
-	if (maxLineLength_ > maxLineLength) {
-		Free();
-		chars = new char[maxLineLength_ + 1];
-		styles = new unsigned char[maxLineLength_ + 1];
-		indicators = new char[maxLineLength_ + 1];
-		// Extra position allocated as sometimes the Windows
-		// GetTextExtentExPoint API writes an extra element.
-		positions = new int[maxLineLength_ + 1 + 1];
-		maxLineLength = maxLineLength_;
-	}
-}
-
-void LineLayout::Free() {
-	delete []chars;
-	chars = 0;
-	delete []styles;
-	styles = 0;
-	delete []indicators;
-	indicators = 0;
-	delete []positions;
-	positions = 0;
-	delete []lineStarts;
-	lineStarts = 0;
-}
-
-void LineLayout::Invalidate(validLevel validity_) {
-	if (validity > validity_)
-		validity = validity_;
-}
-
-void LineLayout::SetLineStart(int line, int start) {
-	if ((line >= lenLineStarts) && (line != 0)) {
-		int newMaxLines = line + 20;
-		int *newLineStarts = new int[newMaxLines];
-		if (!newLineStarts)
-			return;
-		for (int i = 0; i < newMaxLines; i++) {
-			if (i < lenLineStarts)
-				newLineStarts[i] = lineStarts[i];
-			else
-				newLineStarts[i] = 0;
-		}
-		delete []lineStarts;
-		lineStarts = newLineStarts;
-		lenLineStarts = newMaxLines;
-	}
-	lineStarts[line] = start;
-}
-
-void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
-                                    char bracesMatchStyle, int xHighlight) {
-	if (rangeLine.ContainsCharacter(braces[0])) {
-		int braceOffset = braces[0] - rangeLine.start;
-		if (braceOffset < numCharsInLine) {
-			bracePreviousStyles[0] = styles[braceOffset];
-			styles[braceOffset] = bracesMatchStyle;
-		}
-	}
-	if (rangeLine.ContainsCharacter(braces[1])) {
-		int braceOffset = braces[1] - rangeLine.start;
-		if (braceOffset < numCharsInLine) {
-			bracePreviousStyles[1] = styles[braceOffset];
-			styles[braceOffset] = bracesMatchStyle;
-		}
-	}
-	if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
-	        (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
-		xHighlightGuide = xHighlight;
-	}
-}
-
-void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
-	if (rangeLine.ContainsCharacter(braces[0])) {
-		int braceOffset = braces[0] - rangeLine.start;
-		if (braceOffset < numCharsInLine) {
-			styles[braceOffset] = bracePreviousStyles[0];
-		}
-	}
-	if (rangeLine.ContainsCharacter(braces[1])) {
-		int braceOffset = braces[1] - rangeLine.start;
-		if (braceOffset < numCharsInLine) {
-			styles[braceOffset] = bracePreviousStyles[1];
-		}
-	}
-	xHighlightGuide = 0;
-}
-
-LineLayoutCache::LineLayoutCache() :
-	level(0), length(0), size(0), cache(0),
-	allInvalidated(false), styleClock(-1), useCount(0) {
-	Allocate(0);
-}
-
-LineLayoutCache::~LineLayoutCache() {
-	Deallocate();
-}
-
-void LineLayoutCache::Allocate(int length_) {
-	PLATFORM_ASSERT(cache == NULL);
-	allInvalidated = false;
-	length = length_;
-	size = length;
-	if (size > 1) {
-		size = (size / 16 + 1) * 16;
-	}
-	if (size > 0) {
-		cache = new LineLayout * [size];
-	}
-	for (int i = 0; i < size; i++)
-		cache[i] = 0;
-}
-
-void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
-	PLATFORM_ASSERT(useCount == 0);
-	int lengthForLevel = 0;
-	if (level == llcCaret) {
-		lengthForLevel = 1;
-	} else if (level == llcPage) {
-		lengthForLevel = linesOnScreen + 1;
-	} else if (level == llcDocument) {
-		lengthForLevel = linesInDoc;
-	}
-	if (lengthForLevel > size) {
-		Deallocate();
-		Allocate(lengthForLevel);
-	} else {
-		if (lengthForLevel < length) {
-			for (int i = lengthForLevel; i < length; i++) {
-				delete cache[i];
-				cache[i] = 0;
-			}
-		}
-		length = lengthForLevel;
-	}
-	PLATFORM_ASSERT(length == lengthForLevel);
-	PLATFORM_ASSERT(cache != NULL || length == 0);
-}
-
-void LineLayoutCache::Deallocate() {
-	PLATFORM_ASSERT(useCount == 0);
-	for (int i = 0; i < length; i++)
-		delete cache[i];
-	delete []cache;
-	cache = 0;
-	length = 0;
-	size = 0;
-}
-
-void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
-	if (cache && !allInvalidated) {
-		for (int i = 0; i < length; i++) {
-			if (cache[i]) {
-				cache[i]->Invalidate(validity_);
-			}
-		}
-		if (validity_ == LineLayout::llInvalid) {
-			allInvalidated = true;
-		}
-	}
-}
-
-void LineLayoutCache::SetLevel(int level_) {
-	allInvalidated = false;
-	if ((level_ != -1) && (level != level_)) {
-		level = level_;
-		Deallocate();
-	}
-}
-
-LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
-                                      int linesOnScreen, int linesInDoc) {
-	AllocateForLevel(linesOnScreen, linesInDoc);
-	if (styleClock != styleClock_) {
-		Invalidate(LineLayout::llCheckTextAndStyle);
-		styleClock = styleClock_;
-	}
-	allInvalidated = false;
-	int pos = -1;
-	LineLayout *ret = 0;
-	if (level == llcCaret) {
-		pos = 0;
-	} else if (level == llcPage) {
-		if (lineNumber == lineCaret) {
-			pos = 0;
-		} else if (length > 1) {
-			pos = 1 + (lineNumber % (length - 1));
-		}
-	} else if (level == llcDocument) {
-		pos = lineNumber;
-	}
-	if (pos >= 0) {
-		PLATFORM_ASSERT(useCount == 0);
-		if (cache && (pos < length)) {
-			if (cache[pos]) {
-				if ((cache[pos]->lineNumber != lineNumber) ||
-				        (cache[pos]->maxLineLength < maxChars)) {
-					delete cache[pos];
-					cache[pos] = 0;
-				}
-			}
-			if (!cache[pos]) {
-				cache[pos] = new LineLayout(maxChars);
-			}
-			if (cache[pos]) {
-				cache[pos]->lineNumber = lineNumber;
-				cache[pos]->inCache = true;
-				ret = cache[pos];
-				useCount++;
-			}
-		}
-	}
-
-	if (!ret) {
-		ret = new LineLayout(maxChars);
-		ret->lineNumber = lineNumber;
-	}
+		state(false), idlerID(0) {}
 
-	return ret;
-}
-
-void LineLayoutCache::Dispose(LineLayout *ll) {
-	allInvalidated = false;
-	if (ll) {
-		if (!ll->inCache) {
-			delete ll;
-		} else {
-			useCount--;
-		}
-	}
+static inline bool IsControlCharacter(int ch) {
+	// iscntrl returns true for lots of chars > 127 which are displayable
+	return ch >= 0 && ch < ' ';
 }
 
 Editor::Editor() {
@@ -358,7 +109,7 @@
 	dwelling = false;
 	ptMouseLast.x = 0;
 	ptMouseLast.y = 0;
-	inDragDrop = false;
+	inDragDrop = ddNone;
 	dropWentOutside = false;
 	posDrag = invalidPosition;
 	posDrop = invalidPosition;
@@ -386,6 +137,8 @@
 	xCaretMargin = 50;
 	horizontalScrollBarVisible = true;
 	scrollWidth = 2000;
+	trackLineWidth = false;
+	lineWidthMaxSeen = 0;
 	verticalScrollBarVisible = true;
 	endAtLastLine = true;
 	caretSticky = false;
@@ -442,6 +195,7 @@
 	hsEnd = -1;
 
 	llc.SetLevel(LineLayoutCache::llcCaret);
+	posCache.SetSize(0x400);
 }
 
 Editor::~Editor() {
@@ -471,9 +225,10 @@
 
 void Editor::InvalidateStyleData() {
 	stylesValid = false;
-	palette.Release();
 	DropGraphics();
+	palette.Release();
 	llc.Invalidate(LineLayout::llInvalid);
+	posCache.Clear();
 	if (selType == selRectangle) {
 		xStartSelect = XFromPosition(anchor);
 		xEndSelect = XFromPosition(currentPos);
@@ -546,11 +301,6 @@
 	}
 }
 
-static inline bool IsControlCharacter(int ch) {
-	// iscntrl returns true for lots of chars > 127 which are displayable
-	return ch >= 0 && ch < ' ';
-}
-
 const char *ControlCharacterString(unsigned char ch) {
 	const char *reps[] = {
 		"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
@@ -590,6 +340,10 @@
 	}
 };
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  * Allows to iterate through the lines of a selection.
  * Althought it can be called for a stream selection, in most cases
@@ -668,6 +422,10 @@
 	}
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 Point Editor::LocationFromPosition(int pos) {
 	Point pt;
 	RefreshStyleData();
@@ -722,10 +480,6 @@
 	posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine));
 }
 
-static inline bool IsEOLChar(char ch) {
-	return (ch == '\r') || (ch == '\n');
-}
-
 int Editor::PositionFromLocation(Point pt) {
 	RefreshStyleData();
 	pt.x = pt.x - vs.fixedColumnWidth + xOffset;
@@ -748,18 +502,19 @@
 		int subLine = visibleLine - lineStartSet;
 		if (subLine < ll->lines) {
 			int lineStart = ll->LineStart(subLine);
-			int lineEnd = ll->LineStart(subLine + 1);
+			int lineEnd = ll->LineLastVisible(subLine);
 			int subLineStart = ll->positions[lineStart];
 
 			if (actualWrapVisualStartIndent != 0) {
 				if (lineStart != 0)	// Wrapped
 					pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
 			}
-			for (int i = lineStart; i < lineEnd; i++) {
-				if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
-				        IsEOLChar(ll->chars[i])) {
+			int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd);
+			while (i < lineEnd) {
+				if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) {
 					return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
 				}
+				i++;
 			}
 			return lineEnd + posLineStart;
 		}
@@ -797,18 +552,19 @@
 		int subLine = visibleLine - lineStartSet;
 		if (subLine < ll->lines) {
 			int lineStart = ll->LineStart(subLine);
-			int lineEnd = ll->LineStart(subLine + 1);
+			int lineEnd = ll->LineLastVisible(subLine);
 			int subLineStart = ll->positions[lineStart];
 
 			if (actualWrapVisualStartIndent != 0) {
 				if (lineStart != 0)	// Wrapped
 					pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
 			}
-			for (int i = lineStart; i < lineEnd; i++) {
-				if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
-				        IsEOLChar(ll->chars[i])) {
+			int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd);
+			while (i < lineEnd) {
+				if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) {
 					return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
 				}
+				i++;
 			}
 			if (pt.x < (ll->positions[lineEnd] - subLineStart)) {
 				return pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1);
@@ -837,19 +593,20 @@
 		retVal = ll->numCharsInLine + posLineStart;
 		int subLine = 0;
 		int lineStart = ll->LineStart(subLine);
-		int lineEnd = ll->LineStart(subLine + 1);
+		int lineEnd = ll->LineLastVisible(subLine);
 		int subLineStart = ll->positions[lineStart];
 
 		if (actualWrapVisualStartIndent != 0) {
 			if (lineStart != 0)	// Wrapped
 				x -= actualWrapVisualStartIndent * vs.aveCharWidth;
 		}
-		for (int i = lineStart; i < lineEnd; i++) {
-			if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
-			        IsEOLChar(ll->chars[i])) {
+		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;
@@ -962,19 +719,26 @@
 	}
 }
 
-void Editor::InvalidateSelection(int currentPos_, int anchor_) {
-	int firstAffected = anchor;
-	if (firstAffected > currentPos)
-		firstAffected = currentPos;
-	if (firstAffected > anchor_)
-		firstAffected = anchor_;
+void Editor::InvalidateSelection(int currentPos_, int anchor_, bool invalidateWholeSelection) {
+	if (anchor != anchor_ || selType == selRectangle) {
+		invalidateWholeSelection = true;
+	}
+	int firstAffected = currentPos;
+	if (invalidateWholeSelection) {
+		if (firstAffected > anchor)
+			firstAffected = anchor;
+		if (firstAffected > anchor_)
+			firstAffected = anchor_;
+	}
 	if (firstAffected > currentPos_)
 		firstAffected = currentPos_;
-	int lastAffected = anchor;
-	if (lastAffected < currentPos)
-		lastAffected = currentPos;
-	if (lastAffected < anchor_)
-		lastAffected = anchor_;
+	int lastAffected = currentPos;
+	if (invalidateWholeSelection) {
+		if (lastAffected < anchor)
+			lastAffected = anchor;
+		if (lastAffected < anchor_)
+			lastAffected = anchor_;
+	}
 	if (lastAffected < (currentPos_ + 1))	// +1 ensures caret repainted
 		lastAffected = (currentPos_ + 1);
 	needUpdateUI = true;
@@ -985,7 +749,7 @@
 	currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_);
 	anchor_ = pdoc->ClampPositionIntoDocument(anchor_);
 	if ((currentPos != currentPos_) || (anchor != anchor_)) {
-		InvalidateSelection(currentPos_, anchor_);
+		InvalidateSelection(currentPos_, anchor_, true);
 		currentPos = currentPos_;
 		anchor = anchor_;
 	}
@@ -996,7 +760,7 @@
 void Editor::SetSelection(int currentPos_) {
 	currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_);
 	if (currentPos != currentPos_) {
-		InvalidateSelection(currentPos_, currentPos_);
+		InvalidateSelection(currentPos_, anchor, false);
 		currentPos = currentPos_;
 	}
 	SetRectangularRange();
@@ -1123,7 +887,7 @@
 		ShowCaretAtCurrentPosition();
 		// Perform redraw rather than scroll if many lines would be redrawn anyway.
 #ifndef UNDER_CE
-		if (abs(linesToMove) <= 10) {
+		if ((abs(linesToMove) <= 10) && (paintState == notPainting)) {
 			ScrollText(linesToMove);
 		} else {
 			Redraw();
@@ -1158,13 +922,13 @@
 	Point pt = LocationFromPosition(currentPos);
 	if (pt.y < rcClient.top) {
 		MovePositionTo(PositionFromLocation(
-		                   Point(lastXChosen, rcClient.top)),
-		               noSel, ensureVisible);
+		            Point(lastXChosen, rcClient.top)),
+		        noSel, ensureVisible);
 	} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
 		int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight;
 		MovePositionTo(PositionFromLocation(
-		                   Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)),
-		               noSel, ensureVisible);
+		            Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)),
+		        noSel, ensureVisible);
 	}
 }
 
@@ -1437,6 +1201,10 @@
 			xOffsetNew = pt.x + xOffset - rcClient.left;
 		} else if (pt.x + xOffset >= rcClient.right + xOffsetNew) {
 			xOffsetNew = pt.x + xOffset - rcClient.right + 1;
+			if (vs.caretStyle == CARETSTYLE_BLOCK) {
+				// Ensure we can see a good portion of the block caret
+				xOffsetNew += vs.aveCharWidth;
+			}
 		}
 		if (xOffsetNew < 0) {
 			xOffsetNew = 0;
@@ -1445,7 +1213,7 @@
 			xOffset = xOffsetNew;
 			if (xOffsetNew > 0) {
 				PRectangle rcText = GetTextRectangle();
-				if (horizontalScrollBarVisible == true &&
+				if (horizontalScrollBarVisible &&
 				        rcText.Width() + xOffset > scrollWidth) {
 					scrollWidth = xOffset + rcText.Width();
 					SetScrollBars();
@@ -1502,6 +1270,16 @@
 	}
 }
 
+bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
+	AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
+	int linesWrapped = 1;
+	if (ll) {
+		LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
+		linesWrapped = ll->lines;
+	}
+	return cs.SetHeight(lineToWrap, linesWrapped);
+}
+
 // Check if wrapping needed and perform any needed wrapping.
 // fullwrap: if true, all lines which need wrapping will be done,
 //           in this single call.
@@ -1523,9 +1301,9 @@
 			}
 		}
 		if (!fullWrap && priorityWrapLineStart >= 0 &&
-			// .. and if the paint window is outside pending wraps
-			(((priorityWrapLineStart + linesInOneCall) < wrapStart) ||
-			 (priorityWrapLineStart > wrapEnd))) {
+		        // .. and if the paint window is outside pending wraps
+		        (((priorityWrapLineStart + linesInOneCall) < wrapStart) ||
+		         (priorityWrapLineStart > wrapEnd))) {
 			// No priority wrap pending
 			return false;
 		}
@@ -1578,13 +1356,7 @@
 				// Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap);
 				// Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd);
 				while (lineToWrap < lastLineToWrap) {
-					AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
-					int linesWrapped = 1;
-					if (ll) {
-						LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
-						linesWrapped = ll->lines;
-					}
-					if (cs.SetHeight(lineToWrap, linesWrapped)) {
+					if (WrapOneLine(surface, lineToWrap)) {
 						wrapOccurred = true;
 					}
 					lineToWrap++;
@@ -1625,6 +1397,7 @@
 				if (prevNonWS) {
 					// Ensure at least one space separating previous lines
 					pdoc->InsertChar(pos, ' ');
+					targetEnd++;
 				}
 			} else {
 				prevNonWS = pdoc->CharAt(pos) != ' ';
@@ -1634,7 +1407,7 @@
 	}
 }
 
-const char *StringFromEOLMode(int eolMode) {
+const char *Editor::StringFromEOLMode(int eolMode) {
 	if (eolMode == SC_EOL_CRLF) {
 		return "\r\n";
 	} else if (eolMode == SC_EOL_CR) {
@@ -1661,8 +1434,8 @@
 				unsigned int posLineStart = pdoc->LineStart(line);
 				LayoutLine(line, surface, vs, ll, pixelWidth);
 				for (int subLine = 1; subLine < ll->lines; subLine++) {
-					pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) +
-						ll->LineStart(subLine), eol);
+					pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) +
+					        ll->LineStart(subLine), eol);
 					targetEnd += static_cast<int>(strlen(eol));
 				}
 			}
@@ -1763,9 +1536,9 @@
 
 			// Old code does not know about new markers needed to distinguish all cases
 			int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
-			                    SC_MARKNUM_FOLDEROPEN);
+			        SC_MARKNUM_FOLDEROPEN);
 			int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
-			                                        SC_MARKNUM_FOLDER);
+			        SC_MARKNUM_FOLDER);
 
 			while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
 
@@ -1850,11 +1623,11 @@
 					if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
 						int lev = pdoc->GetLevel(lineDoc);
 						sprintf(number, "%c%c %03X %03X",
-							(lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
-							(lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
-							lev & SC_FOLDLEVELNUMBERMASK,
-							lev >> 16
-						);
+						        (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
+						        (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
+						        lev & SC_FOLDLEVELNUMBERMASK,
+						        lev >> 16
+						       );
 					}
 					PRectangle rcNumber = rcMarker;
 					// Right justify
@@ -1862,9 +1635,9 @@
 					int xpos = rcNumber.right - width - 3;
 					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);
+					        rcNumber.top + vs.maxAscent, number, istrlen(number),
+					        vs.styles[STYLE_LINENUMBER].fore.allocated,
+					        vs.styles[STYLE_LINENUMBER].back.allocated);
 				}
 
 				if (marks) {
@@ -1908,17 +1681,69 @@
 	surface->LineTo(xhead, ymid + ydiff);
 }
 
-static bool IsSpaceOrTab(char ch) {
-	return ch == ' ' || ch == '\t';
-}
-
 LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
 	int posLineStart = pdoc->LineStart(lineNumber);
 	int posLineEnd = pdoc->LineStart(lineNumber + 1);
+	PLATFORM_ASSERT(posLineEnd >= posLineStart);
 	int lineCaret = pdoc->LineFromPosition(currentPos);
 	return llc.Retrieve(lineNumber, lineCaret,
-	                    posLineEnd - posLineStart, pdoc->GetStyleClock(),
-	                    LinesOnScreen() + 1, pdoc->LinesTotal());
+	        posLineEnd - posLineStart, pdoc->GetStyleClock(),
+	        LinesOnScreen() + 1, pdoc->LinesTotal());
+}
+
+static bool GoodTrailByte(int v) {
+	return (v >= 0x80) && (v < 0xc0);
+}
+
+bool BadUTF(const char *s, int len, int &trailBytes) {
+	if (trailBytes) {
+		trailBytes--;
+		return false;
+	}
+	const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
+	if (*us < 0x80) {
+		// Single bytes easy
+		return false;
+	} else if (*us > 0xF4) {
+		// Characters longer than 4 bytes not possible in current UTF-8
+		return true;
+	} else if (*us >= 0xF0) {
+		// 4 bytes
+		if (len < 4)
+			return true;
+		if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) {
+			trailBytes = 3;
+			return false;
+		} else {
+			return true;
+		}
+	} else if (*us >= 0xE0) {
+		// 3 bytes
+		if (len < 3)
+			return true;
+		if (GoodTrailByte(us[1]) && GoodTrailByte(us[2])) {
+			trailBytes = 2;
+			return false;
+		} else {
+			return true;
+		}
+	} else if (*us >= 0xC2) {
+		// 2 bytes
+		if (len < 2)
+			return true;
+		if (GoodTrailByte(us[1])) {
+			trailBytes = 1;
+			return false;
+		} else {
+			return true;
+		}
+	} else if (*us >= 0xC0) {
+		// Overlong encoding
+		return true;
+	} else {
+		// Trail byte
+		return true;
+	}
 }
 
 /**
@@ -1929,7 +1754,9 @@
 void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
 	if (!ll)
 		return;
+
 	PLATFORM_ASSERT(line < pdoc->LinesTotal());
+	PLATFORM_ASSERT(ll->chars != NULL);
 	int posLineStart = pdoc->LineStart(line);
 	int posLineEnd = pdoc->LineStart(line + 1);
 	// If the line is very long, limit the treatment to a length that should fit in the viewport
@@ -1957,18 +1784,18 @@
 				char chDoc = pdoc->CharAt(charInDoc);
 				styleByte = pdoc->StyleAt(charInDoc);
 				allSame = allSame &&
-					        (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask));
+				        (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask));
 				allSame = allSame &&
-					        (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask));
+				        (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask));
 				if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed)
 					allSame = allSame &&
-						        (ll->chars[numCharsInLine] == chDoc);
+					        (ll->chars[numCharsInLine] == chDoc);
 				else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower)
 					allSame = allSame &&
-						        (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc)));
+					        (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc)));
 				else	// Style::caseUpper
 					allSame = allSame &&
-						        (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc)));
+					        (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc)));
 				numCharsInLine++;
 			}
 			allSame = allSame && (ll->styles[numCharsInLine] == styleByte);	// For eolFilled
@@ -2030,31 +1857,40 @@
 
 		int ctrlCharWidth[32] = {0};
 		bool isControlNext = IsControlCharacter(ll->chars[0]);
+		int trailBytes = 0;
+		bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes);
 		for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
 			bool isControl = isControlNext;
 			isControlNext = IsControlCharacter(ll->chars[charInLine + 1]);
+			bool isBadUTF = isBadUTFNext;
+			isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes);
 			if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
-			        isControl || isControlNext) {
+			        isControl || isControlNext || isBadUTF || isBadUTFNext) {
 				ll->positions[startseg] = 0;
 				if (vstyle.styles[ll->styles[charInLine]].visible) {
 					if (isControl) {
 						if (ll->chars[charInLine] == '\t') {
 							ll->positions[charInLine + 1] = ((((startsegx + 2) /
-							                                   tabWidth) + 1) * tabWidth) - startsegx;
+							        tabWidth) + 1) * tabWidth) - startsegx;
 						} else if (controlCharSymbol < 32) {
 							if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
 								const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
 								// +3 For a blank on front and rounded edge each side:
 								ctrlCharWidth[ll->chars[charInLine]] =
-									surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3;
+								    surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3;
 							}
 							ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]];
 						} else {
 							char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
 							surface->MeasureWidths(ctrlCharsFont, cc, 1,
-							                       ll->positions + startseg + 1);
+							        ll->positions + startseg + 1);
 						}
 						lastSegItalics = false;
+					} else if (isBadUTF) {
+						char hexits[3];
+						sprintf(hexits, "%2X", ll->chars[charInLine] & 0xff);
+						ll->positions[charInLine + 1] =
+						    surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3;
 					} else {	// Regular character
 						int lenSeg = charInLine - startseg + 1;
 						if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
@@ -2063,8 +1899,8 @@
 							ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
 						} else {
 							lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
-							surface->MeasureWidths(vstyle.styles[ll->styles[charInLine]].font, ll->chars + startseg,
-							                       lenSeg, ll->positions + startseg + 1);
+							posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg,
+							        lenSeg, ll->positions + startseg + 1);
 						}
 					}
 				} else {    // invisible
@@ -2103,8 +1939,6 @@
 			}
 			ll->lines = 0;
 			// Calculate line start positions based upon width.
-			// For now this is simplistic - wraps on byte rather than character and
-			// in the middle of words. Should search for spaces or style changes.
 			int lastGoodBreak = 0;
 			int lastLineStart = 0;
 			int startOffset = 0;
@@ -2115,12 +1949,12 @@
 						// Try moving to start of last character
 						if (p > 0) {
 							lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
-							                - posLineStart;
+							        - posLineStart;
 						}
 						if (lastGoodBreak == lastLineStart) {
 							// Ensure at least one character on line.
 							lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart + 1, 1)
-							                - posLineStart;
+							        - posLineStart;
 						}
 					}
 					lastLineStart = lastGoodBreak;
@@ -2135,7 +1969,7 @@
 				if (p > 0) {
 					if (wrapState == eWrapChar) {
 						lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
-												- posLineStart;
+						        - posLineStart;
 						p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
 						continue;
 					} else if (ll->styles[p] != ll->styles[p - 1]) {
@@ -2157,7 +1991,7 @@
 }
 
 ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
-                                       ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
+        ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
 	if (inSelection) {
 		if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
 			return SelectionBackground(vsDraw);
@@ -2169,7 +2003,7 @@
 			return vsDraw.edgecolour.allocated;
 		if (inHotspot && vsDraw.hotspotBackgroundSet)
 			return vsDraw.hotspotBackground.allocated;
-		if (overrideBackground)
+		if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD))
 			return background;
 	}
 	return vsDraw.styles[styleMain].back.allocated;
@@ -2179,11 +2013,11 @@
 	Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
 	PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom);
 	surface->Copy(rcCopyArea, from,
-	              highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
+	        highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
 }
 
 void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
-                            bool isEndMarker, ColourAllocated wrapColour) {
+        bool isEndMarker, ColourAllocated wrapColour) {
 	surface->PenColour(wrapColour);
 
 	enum { xa = 1 }; // gap before start
@@ -2206,10 +2040,10 @@
 		int yBase;
 		int yDir;
 		void MoveTo(int xRelative, int yRelative) {
-		    surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
+			surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
 		}
 		void LineTo(int xRelative, int yRelative) {
-		    surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
+			surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
 		}
 	};
 	Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1};
@@ -2225,7 +2059,7 @@
 	rel.LineTo(xa + w, y);
 	rel.LineTo(xa + w, y - 2 * dy);
 	rel.LineTo(xa - 1,   // on windows lineto is exclusive endpoint, perhaps GTK not...
-	                y - 2 * dy);
+	        y - 2 * dy);
 }
 
 static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) {
@@ -2235,9 +2069,9 @@
 }
 
 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, int subLineStart,
+        bool overrideBackground, ColourAllocated background,
+        bool drawWrapMarkEnd, ColourAllocated wrapColour) {
 
 	int styleMask = pdoc->stylingBitsMask;
 	PRectangle rcSegment = rcLine;
@@ -2248,7 +2082,7 @@
 	rcSegment.right = xEol + vsDraw.aveCharWidth + xStart;
 	int posLineEnd = pdoc->LineStart(line + 1);
 	bool eolInSelection = (subLine == (ll->lines - 1)) &&
-	                      (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
+	        (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
 
 	if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
 		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
@@ -2265,12 +2099,20 @@
 
 	rcSegment.left = xEol + vsDraw.aveCharWidth + xStart;
 	rcSegment.right = rcLine.right;
-	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);
+
+	if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
 	} else {
-		surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+		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);
+		} else {
+			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+		}
+		if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) {
+			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+		}
 	}
 
 	if (drawWrapMarkEnd) {
@@ -2288,8 +2130,99 @@
 	}
 }
 
+void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
+        PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) {
+	// Draw decorators
+	const int posLineStart = pdoc->LineStart(line);
+	const int lineStart = ll->LineStart(subLine);
+	const int subLineStart = ll->positions[lineStart];
+	const int posLineEnd = posLineStart + lineEnd;
+
+	if (!under) {
+		// Draw indicators
+		// foreach indicator...
+		for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) {
+			if (!(mask & ll->styleBitsSet)) {
+				mask <<= 1;
+				continue;
+			}
+			int startPos = -1;
+			// foreach style pos in line...
+			for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) {
+				// look for starts...
+				if (startPos < 0) {
+					// NOT in indicator run, looking for START
+					if (indicPos < lineEnd && (ll->indicators[indicPos] & mask))
+						startPos = indicPos;
+				}
+				// ... or ends
+				if (startPos >= 0) {
+					// IN indicator run, looking for END
+					if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) {
+						// AT end of indicator run, DRAW it!
+						PRectangle rcIndic(
+						    ll->positions[startPos] + xStart - subLineStart,
+						    rcLine.top + vsDraw.maxAscent,
+						    ll->positions[indicPos] + xStart - subLineStart,
+						    rcLine.top + vsDraw.maxAscent + 3);
+						vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine);
+						// RESET control var
+						startPos = -1;
+					}
+				}
+			}
+			mask <<= 1;
+		}
+	}
+
+	for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
+		if (under == vsDraw.indicators[deco->indicator].under) {
+			int startPos = posLineStart + lineStart;
+			if (!deco->rs.ValueAt(startPos)) {
+				startPos = deco->rs.EndRun(startPos);
+			}
+			while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) {
+				int endPos = deco->rs.EndRun(startPos);
+				if (endPos > posLineEnd)
+					endPos = posLineEnd;
+				PRectangle rcIndic(
+				    ll->positions[startPos - posLineStart] + xStart - subLineStart,
+				    rcLine.top + vsDraw.maxAscent,
+				    ll->positions[endPos - posLineStart] + xStart - subLineStart,
+				    rcLine.top + vsDraw.maxAscent + 3);
+				vsDraw.indicators[deco->indicator].Draw(surface, rcIndic, rcLine);
+				startPos = deco->rs.EndRun(endPos);
+			}
+		}
+	}
+}
+
+void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
+				  const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) {
+	if (!twoPhaseDraw) {
+		surface->FillRectangle(rcSegment, textBack);
+	}
+	Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
+	int normalCharHeight = surface->Ascent(ctrlCharsFont) -
+	        surface->InternalLeading(ctrlCharsFont);
+	PRectangle rcCChar = rcSegment;
+	rcCChar.left = rcCChar.left + 1;
+	rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
+	rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
+	PRectangle rcCentral = rcCChar;
+	rcCentral.top++;
+	rcCentral.bottom--;
+	surface->FillRectangle(rcCentral, textFore);
+	PRectangle rcChar = rcCChar;
+	rcChar.left++;
+	rcChar.right--;
+	surface->DrawTextClipped(rcChar, ctrlCharsFont,
+	        rcSegment.top + vsDraw.maxAscent, s, istrlen(s),
+	        textBack, textFore);
+}
+
 void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
-                      PRectangle rcLine, LineLayout *ll, int subLine) {
+        PRectangle rcLine, LineLayout *ll, int subLine) {
 
 	PRectangle rcSegment = rcLine;
 
@@ -2314,7 +2247,7 @@
 		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)) {
+			        (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 				background = vsDraw.markers[markBit].back.allocated;
 				overrideBackground = true;
 			}
@@ -2327,7 +2260,7 @@
 			if (marksMasked) {
 				for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
 					if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) &&
-						(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
+					        (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 						overrideBackground = true;
 						background = vsDraw.markers[markBit].back.allocated;
 					}
@@ -2338,7 +2271,7 @@
 	}
 
 	bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
-	                                (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
+	        (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
 
 	bool inIndentation = subLine == 0;	// Do not handle indentation except on first subline.
 	int indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth;
@@ -2354,6 +2287,10 @@
 		lineEnd = ll->LineStart(subLine + 1);
 	}
 
+	ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated;
+	if (vsDraw.whitespaceForegroundSet)
+		wrapColour = vsDraw.whitespaceForeground.allocated;
+
 	bool drawWrapMarkEnd = false;
 
 	if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
@@ -2377,7 +2314,8 @@
 			rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth;
 
 			// default bgnd here..
-			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+			surface->FillRectangle(rcSegment, overrideBackground ? background :
+			        vsDraw.styles[STYLE_DEFAULT].back.allocated);
 
 			// main line style would be below but this would be inconsistent with end markers
 			// also would possibly not be the style at wrap point
@@ -2391,273 +2329,288 @@
 				else
 					rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
 
-				DrawWrapMarker(surface, rcPlace, false, vsDraw.whitespaceForeground.allocated);
+				DrawWrapMarker(surface, rcPlace, false, wrapColour);
 			}
 
 			xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth;
 		}
 	}
 
-	int i;
+	// Does not take margin into account but not significant
+	int xStartVisible = subLineStart - xStart;
+
+	BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+	int next = bfBack.First();
 
 	// Background drawing loop
-	for (i = lineStart; twoPhaseDraw && (i < lineEnd); i++) {
+	while (twoPhaseDraw && (next < lineEnd)) {
 
+		startseg = next;
+		next = bfBack.Next();
+		int i = next - 1;
 		int iDoc = i + posLineStart;
-		// If there is the end of a style run for any reason
-		if ((ll->styles[i] != ll->styles[i + 1]) ||
-		        i == (lineEnd - 1) ||
-		        IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
-		        ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
-		        (i == (ll->edgeColumn - 1))) {
-			rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
-			rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
-			// Only try to draw if really visible - enhances performance by not calling environment to
-			// draw strings that are completely past the right side of the window.
-			if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
-				int styleMain = ll->styles[i];
-				bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
-				bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
-				ColourAllocated 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;
-					surface->FillRectangle(rcSegment, textBack);
-				} else if (IsControlCharacter(ll->chars[i])) {
-					// Control character display
-					inIndentation = false;
-					surface->FillRectangle(rcSegment, textBack);
-				} else {
-					// Normal text display
-					surface->FillRectangle(rcSegment, textBack);
-					if (vsDraw.viewWhitespace != wsInvisible ||
-					        (inIndentation && vsDraw.viewIndentationGuides)) {
-						for (int cpos = 0; cpos <= i - startseg; cpos++) {
-							if (ll->chars[cpos + startseg] == ' ') {
-								if (drawWhitespaceBackground &&
-								        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
-									PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top,
-									                   ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom);
-									surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
-								}
-							} else {
-								inIndentation = false;
+
+		rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+		rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+		// Only try to draw if really visible - enhances performance by not calling environment to
+		// draw strings that are completely past the right side of the window.
+		if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+			// Clip to line rectangle, since may have a huge position which will not work with some platforms
+			rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
+			rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+
+			int styleMain = ll->styles[i];
+			bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
+			bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+			ColourAllocated 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;
+				surface->FillRectangle(rcSegment, textBack);
+			} else if (IsControlCharacter(ll->chars[i])) {
+				// Control character display
+				inIndentation = false;
+				surface->FillRectangle(rcSegment, textBack);
+			} else {
+				// Normal text display
+				surface->FillRectangle(rcSegment, textBack);
+				if (vsDraw.viewWhitespace != wsInvisible ||
+				        (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
+					for (int cpos = 0; cpos <= i - startseg; cpos++) {
+						if (ll->chars[cpos + startseg] == ' ') {
+							if (drawWhitespaceBackground &&
+							        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+								PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
+									rcSegment.top,
+									ll->positions[cpos + startseg + 1] + xStart - subLineStart,
+									rcSegment.bottom);
+								surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
 							}
+						} else {
+							inIndentation = false;
 						}
 					}
 				}
-			} else if (rcSegment.left > rcLine.right) {
-				break;
 			}
-			startseg = i + 1;
+		} else if (rcSegment.left > rcLine.right) {
+			break;
 		}
 	}
 
 	if (twoPhaseDraw) {
 		DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
 		        xStart, subLine, subLineStart, overrideBackground, background,
-		        drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
+		        drawWrapMarkEnd, wrapColour);
+	}
+
+	DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true);
+
+	if (vsDraw.edgeState == EDGE_LINE) {
+		int edgeX = theEdge * vsDraw.spaceWidth;
+		rcSegment.left = edgeX + xStart;
+		rcSegment.right = rcSegment.left + 1;
+		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
 	}
 
 	inIndentation = subLine == 0;	// Do not handle indentation except on first subline.
-	startseg = ll->LineStart(subLine);
 	// Foreground drawing loop
-	for (i = lineStart; i < lineEnd; i++) {
+	BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+	next = bfFore.First();
+
+	while (next < lineEnd) {
+
+		startseg = next;
+		next = bfFore.Next();
+		int i = next - 1;
 
 		int iDoc = i + posLineStart;
-		// If there is the end of a style run for any reason
-		if ((ll->styles[i] != ll->styles[i + 1]) ||
-		        i == (lineEnd - 1) ||
-		        IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
-		        ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
-		        (i == (ll->edgeColumn - 1))) {
-			rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
-			rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
-			// Only try to draw if really visible - enhances performance by not calling environment to
-			// draw strings that are completely past the right side of the window.
-			if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
-				int styleMain = ll->styles[i];
-				ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
-				Font &textFont = vsDraw.styles[styleMain].font;
-				//hotspot foreground
-				if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
-					if (vsDraw.hotspotForegroundSet)
-						textFore = vsDraw.hotspotForeground.allocated;
-				}
-				bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
-				if (inSelection && (vsDraw.selforeset)) {
-					textFore = vsDraw.selforeground.allocated;
-				}
-				bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
-				ColourAllocated 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;
-						surface->FillRectangle(rcSegment, textBack);
-					}
-					if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
-						if (vsDraw.whitespaceForegroundSet)
-							textFore = vsDraw.whitespaceForeground.allocated;
-						surface->PenColour(textFore);
-					}
-					if (inIndentation && vsDraw.viewIndentationGuides) {
-						for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
-							if (xIG >= ll->positions[i] && xIG > 0) {
-								DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment,
-								                (ll->xHighlightGuide == xIG));
-							}
-						}
-					}
-					if (vsDraw.viewWhitespace != wsInvisible) {
-						if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
-							PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
-							                 rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
-							DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+
+		rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+		rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+		// Only try to draw if really visible - enhances performance by not calling environment to
+		// draw strings that are completely past the right side of the window.
+		if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+			int styleMain = ll->styles[i];
+			ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+			Font &textFont = vsDraw.styles[styleMain].font;
+			//hotspot foreground
+			if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
+				if (vsDraw.hotspotForegroundSet)
+					textFore = vsDraw.hotspotForeground.allocated;
+			}
+			bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
+			if (inSelection && (vsDraw.selforeset)) {
+				textFore = vsDraw.selforeground.allocated;
+			}
+			bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+			ColourAllocated 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;
+					surface->FillRectangle(rcSegment, textBack);
+				}
+				if ((vsDraw.viewWhitespace != wsInvisible) ||
+				        (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
+					if (vsDraw.whitespaceForegroundSet)
+						textFore = vsDraw.whitespaceForeground.allocated;
+					surface->PenColour(textFore);
+				}
+				if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+					for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
+						if (xIG >= ll->positions[i] && xIG > 0) {
+							DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment,
+							        (ll->xHighlightGuide == xIG));
 						}
 					}
-				} else if (IsControlCharacter(ll->chars[i])) {
-					// Control character display
-					inIndentation = false;
-					if (controlCharSymbol < 32) {
-						// Draw the character
-						const char *ctrlChar = ControlCharacterString(ll->chars[i]);
-						if (!twoPhaseDraw) {
-							surface->FillRectangle(rcSegment, textBack);
-						}
-						int normalCharHeight = surface->Ascent(ctrlCharsFont) -
-						                       surface->InternalLeading(ctrlCharsFont);
-						PRectangle rcCChar = rcSegment;
-						rcCChar.left = rcCChar.left + 1;
-						rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
-						rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
-						PRectangle rcCentral = rcCChar;
-						rcCentral.top++;
-						rcCentral.bottom--;
-						surface->FillRectangle(rcCentral, textFore);
-						PRectangle rcChar = rcCChar;
-						rcChar.left++;
-						rcChar.right--;
-						surface->DrawTextClipped(rcChar, ctrlCharsFont,
-						                         rcSegment.top + vsDraw.maxAscent, ctrlChar, istrlen(ctrlChar),
-						                         textBack, textFore);
-					} else {
-						char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
-						surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
-						                        rcSegment.top + vsDraw.maxAscent,
-						                        cc, 1, textBack, textFore);
+				}
+				if (vsDraw.viewWhitespace != wsInvisible) {
+					if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+						PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+						        rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+						DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
 					}
+				}
+			} else if (IsControlCharacter(ll->chars[i])) {
+				// Control character display
+				inIndentation = false;
+				if (controlCharSymbol < 32) {
+					// Draw the character
+					const char *ctrlChar = ControlCharacterString(ll->chars[i]);
+					DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
 				} else {
-					// Normal text display
-					if (vsDraw.styles[styleMain].visible) {
-						if (twoPhaseDraw) {
-							surface->DrawTextTransparent(rcSegment, textFont,
-							                             rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
-							                             i - startseg + 1, textFore);
-						} else {
-							surface->DrawTextNoClip(rcSegment, textFont,
-							                        rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
-							                        i - startseg + 1, textFore, textBack);
-						}
-					}
-					if (vsDraw.viewWhitespace != wsInvisible ||
-					        (inIndentation && vsDraw.viewIndentationGuides)) {
-						for (int cpos = 0; cpos <= i - startseg; cpos++) {
-							if (ll->chars[cpos + startseg] == ' ') {
-								if (vsDraw.viewWhitespace != wsInvisible) {
-									if (vsDraw.whitespaceForegroundSet)
-										textFore = vsDraw.whitespaceForeground.allocated;
-									if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
-										int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
-										if (!twoPhaseDraw && drawWhitespaceBackground &&
-										        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
-											textBack = vsDraw.whitespaceBackground.allocated;
-											PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom);
-											surface->FillRectangle(rcSpace, textBack);
-										}
-										PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
-										rcDot.right = rcDot.left + 1;
-										rcDot.bottom = rcDot.top + 1;
-										surface->FillRectangle(rcDot, textFore);
+					char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+					surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+					        rcSegment.top + vsDraw.maxAscent,
+					        cc, 1, textBack, textFore);
+				}
+			} else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
+				char hexits[3];
+				sprintf(hexits, "%2X", ll->chars[i] & 0xff);
+				DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
+			} else {
+				// Normal text display
+				if (vsDraw.styles[styleMain].visible) {
+					if (twoPhaseDraw) {
+						surface->DrawTextTransparent(rcSegment, textFont,
+						        rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
+						        i - startseg + 1, textFore);
+					} else {
+						surface->DrawTextNoClip(rcSegment, textFont,
+						        rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
+						        i - startseg + 1, textFore, textBack);
+					}
+				}
+				if (vsDraw.viewWhitespace != wsInvisible ||
+				        (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
+					for (int cpos = 0; cpos <= i - startseg; cpos++) {
+						if (ll->chars[cpos + startseg] == ' ') {
+							if (vsDraw.viewWhitespace != wsInvisible) {
+								if (vsDraw.whitespaceForegroundSet)
+									textFore = vsDraw.whitespaceForeground.allocated;
+								if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+									int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+									if (!twoPhaseDraw && drawWhitespaceBackground &&
+									        (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+										textBack = vsDraw.whitespaceBackground.allocated;
+										PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
+											rcSegment.top,
+											ll->positions[cpos + startseg + 1] + xStart - subLineStart,
+											rcSegment.bottom);
+										surface->FillRectangle(rcSpace, textBack);
 									}
+									PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
+									rcDot.right = rcDot.left + 1;
+									rcDot.bottom = rcDot.top + 1;
+									surface->FillRectangle(rcDot, textFore);
 								}
-								if (inIndentation && vsDraw.viewIndentationGuides) {
-									int startSpace = ll->positions[cpos + startseg];
-									if (startSpace > 0 && (startSpace % indentWidth == 0)) {
-										DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
-										                (ll->xHighlightGuide == ll->positions[cpos + startseg]));
-									}
+							}
+							if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+								int startSpace = ll->positions[cpos + startseg];
+								if (startSpace > 0 && (startSpace % indentWidth == 0)) {
+									DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
+									        (ll->xHighlightGuide == ll->positions[cpos + startseg]));
 								}
-							} else {
-								inIndentation = false;
 							}
+						} else {
+							inIndentation = false;
 						}
 					}
 				}
-				if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) {
-					PRectangle rcUL = rcSegment;
-					rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
-					rcUL.bottom = rcUL.top + 1;
-					if (vsDraw.hotspotForegroundSet)
-						surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
-					else
-						surface->FillRectangle(rcUL, textFore);
-				} else if (vsDraw.styles[styleMain].underline) {
-					PRectangle rcUL = rcSegment;
-					rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
-					rcUL.bottom = rcUL.top + 1;
+			}
+			if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) {
+				PRectangle rcUL = rcSegment;
+				rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
+				rcUL.bottom = rcUL.top + 1;
+				if (vsDraw.hotspotForegroundSet)
+					surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
+				else
 					surface->FillRectangle(rcUL, textFore);
-				}
-			} else if (rcSegment.left > rcLine.right) {
-				break;
+			} else if (vsDraw.styles[styleMain].underline) {
+				PRectangle rcUL = rcSegment;
+				rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
+				rcUL.bottom = rcUL.top + 1;
+				surface->FillRectangle(rcUL, textFore);
 			}
-			startseg = i + 1;
+		} else if (rcSegment.left > rcLine.right) {
+			break;
 		}
 	}
+	if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth)
+	        && (subLine == 0)) {
+		int indentSpace = pdoc->GetLineIndentation(line);
+		// Find the most recent line with some text
 
-	// Draw indicators
-	// foreach indicator...
-	for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) {
-		if (!(mask & ll->styleBitsSet)) {
-			mask <<= 1;
-			continue;
+		int lineLastWithText = line;
+		while (lineLastWithText > Platform::Maximum(line-20, 0) && pdoc->IsWhiteLine(lineLastWithText)) {
+			lineLastWithText--;
 		}
-		int startPos = -1;
-		// foreach style pos in line...
-		for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) {
-			// look for starts...
-			if (startPos < 0) {
-				// NOT in indicator run, looking for START
-				if (indicPos < lineEnd && (ll->indicators[indicPos] & mask))
-					startPos = indicPos;
-			}
-			// ... or ends
-			if (startPos >= 0) {
-				// IN indicator run, looking for END
-				if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) {
-					// AT end of indicator run, DRAW it!
-					PRectangle rcIndic(
-						ll->positions[startPos] + xStart - subLineStart,
-						rcLine.top + vsDraw.maxAscent,
-						ll->positions[indicPos] + xStart - subLineStart,
-						rcLine.top + vsDraw.maxAscent + 3);
-					vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine);
-					// RESET control var
-					startPos = -1;
+		if (lineLastWithText < line) {
+			// This line is empty, so use indentation of last line with text
+			int indentLastWithText = pdoc->GetLineIndentation(lineLastWithText);
+			int isFoldHeader = pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG;
+			if (isFoldHeader) {
+				// Level is one more level than parent
+				indentLastWithText += pdoc->IndentSize();
+			}
+			if (vsDraw.viewIndentationGuides == ivLookForward) {
+				// In viLookForward mode, previous line only used if it is a fold header
+				if (isFoldHeader) {
+					indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
 				}
+			} else {	// viLookBoth
+				indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
 			}
 		}
-		mask <<= 1;
+
+		int lineNextWithText = line;
+		while (lineNextWithText < Platform::Minimum(line+20, pdoc->LinesTotal()) && pdoc->IsWhiteLine(lineNextWithText)) {
+			lineNextWithText++;
+		}
+		if (lineNextWithText > line) {
+			// This line is empty, so use indentation of last line with text
+			indentSpace = Platform::Maximum(indentSpace,
+			        pdoc->GetLineIndentation(lineNextWithText));
+		}
+
+		for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) {
+			int xIndent = indentPos * vsDraw.spaceWidth;
+			DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
+			        (ll->xHighlightGuide == xIndent));
+		}
 	}
+
+	DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false);
+
 	// End of the drawing of the current line
 	if (!twoPhaseDraw) {
 		DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
 		        xStart, subLine, subLineStart, overrideBackground, background,
-		        drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
+		        drawWrapMarkEnd, wrapColour);
 	}
 	if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) {
 		int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart;
@@ -2665,17 +2618,12 @@
 		if (startPosSel < endPosSel) {
 			rcSegment.left = xStart + ll->positions[startPosSel - posLineStart] - subLineStart;
 			rcSegment.right = xStart + ll->positions[endPosSel - posLineStart] - subLineStart;
+			rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
+			rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
 			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
 		}
 	}
 
-	if (vsDraw.edgeState == EDGE_LINE) {
-		int edgeX = theEdge * vsDraw.spaceWidth;
-		rcSegment.left = edgeX + xStart;
-		rcSegment.right = rcSegment.left + 1;
-		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
-	}
-
 	// Draw any translucent whole line states
 	rcSegment.left = xStart;
 	rcSegment.right = rcLine.right - 1;
@@ -2702,6 +2650,61 @@
 	}
 }
 
+void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret) {
+
+	int lineStart = ll->LineStart(subLine);
+	int posBefore = posCaret;
+	int posAfter = MovePositionOutsideChar(posCaret + 1, 1);
+	int numCharsToDraw = posAfter - posCaret;
+
+	// Work out where the starting and ending offsets are. We need to
+	// see if the previous character shares horizontal space, such as a
+	// glyph / combining character. If so we'll need to draw that too.
+	int offsetFirstChar = offset;
+	int offsetLastChar = offset + (posAfter - posCaret);
+	while ((offsetLastChar - numCharsToDraw) >= lineStart) {
+		if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) {
+			// The char does not share horizontal space
+			break;
+		}
+		// Char shares horizontal space, update the numChars to draw
+		// Update posBefore to point to the prev char
+		posBefore = MovePositionOutsideChar(posBefore - 1, -1);
+		numCharsToDraw = posAfter - posBefore;
+		offsetFirstChar = offset - (posCaret - posBefore);
+	}
+
+	// See if the next character shares horizontal space, if so we'll
+	// need to draw that too.
+	numCharsToDraw = offsetLastChar - offsetFirstChar;
+	while ((offsetLastChar < ll->LineStart(subLine + 1)) && (offsetLastChar <= ll->numCharsInLine)) {
+		// Update posAfter to point to the 2nd next char, this is where
+		// the next character ends, and 2nd next begins. We'll need
+		// to compare these two
+		posBefore = posAfter;
+		posAfter = MovePositionOutsideChar(posAfter + 1, 1);
+		offsetLastChar = offset + (posAfter - posCaret);
+		if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - (posAfter - posBefore)]) > 0) {
+			// The char does not share horizontal space
+			break;
+		}
+		// Char shares horizontal space, update the numChars to draw
+		numCharsToDraw = offsetLastChar - offsetFirstChar;
+	}
+
+	// We now know what to draw, update the caret drawing rectangle
+	rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[ll->LineStart(subLine)] + xStart;
+	rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[ll->LineStart(subLine)] + xStart;
+
+	// This character is where the caret block is, we override the colours
+	// (inversed) for drawing the caret here.
+	int styleMain = ll->styles[offsetFirstChar];
+	surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font,
+	        rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar,
+	        numCharsToDraw, vsDraw.styles[styleMain].back.allocated,
+	        vsDraw.caretcolour.allocated);
+}
+
 void Editor::RefreshPixMaps(Surface *surfaceWindow) {
 	if (!pixmapSelPattern->Initialised()) {
 		const int patternSize = 8;
@@ -2761,9 +2764,9 @@
 		if (!pixmapLine->Initialised()) {
 			PRectangle rcClient = GetClientRectangle();
 			pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight,
-			                       surfaceWindow, wMain.GetID());
+			        surfaceWindow, wMain.GetID());
 			pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
-			                            rcClient.Height(), surfaceWindow, wMain.GetID());
+			        rcClient.Height(), surfaceWindow, wMain.GetID());
 		}
 	}
 }
@@ -2772,6 +2775,7 @@
 	//Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n",
 	//	paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
 
+	pixmapLine->Release();
 	RefreshStyleData();
 	RefreshPixMaps(surfaceWindow);
 
@@ -2801,10 +2805,17 @@
 	pdoc->EnsureStyledTo(endPosPaint);
 	bool paintAbandonedByStyling = paintState == paintAbandoned;
 	if (needUpdateUI) {
+		// Deselect palette by selecting a temporary palette
+		Palette palTemp;
+		surfaceWindow->SetPalette(&palTemp, true);
+
 		NotifyUpdateUI();
 		needUpdateUI = false;
+
 		RefreshStyleData();
 		RefreshPixMaps(surfaceWindow);
+		surfaceWindow->SetPalette(&palette, true);
+		pixmapLine->SetPalette(&palette, !hasFocus);
 	}
 
 	// Call priority lines wrap on a window of lines which are likely
@@ -2924,7 +2935,7 @@
 				Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
 				// Highlight the current braces if any
 				ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
-				                       highlightGuideColumn * vs.spaceWidth);
+				        highlightGuideColumn * vs.spaceWidth);
 
 				// Draw the line
 				DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine);
@@ -2994,8 +3005,7 @@
 				// Draw the Caret
 				if (lineDoc == lineCaret) {
 					int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength);
-					if ((offset >= ll->LineStart(subLine)) &&
-					        ((offset < ll->LineStart(subLine + 1)) || offset == ll->numCharsInLine)) {
+					if (ll->InLine(offset, subLine)) {
 						int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
 
 						if (actualWrapVisualStartIndent != 0) {
@@ -3003,35 +3013,57 @@
 							if (lineStart != 0)	// Wrapped
 								xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth;
 						}
-						int widthOverstrikeCaret;
-						if (posCaret == pdoc->Length())	{   // At end of document
-							widthOverstrikeCaret = vs.aveCharWidth;
-						} else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) {	// At end of line
-							widthOverstrikeCaret = vs.aveCharWidth;
-						} else {
-							widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset];
-						}
-						if (widthOverstrikeCaret < 3)	// Make sure its visible
-							widthOverstrikeCaret = 3;
-						if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
-							PRectangle rcCaret = rcLine;
+						if ((xposCaret >= 0) && (vs.caretWidth > 0) && (vs.caretStyle != CARETSTYLE_INVISIBLE) &&
+						        ((posDrag >= 0) || (caret.active && caret.on))) {
+							bool caretAtEOF = false;
+							bool caretAtEOL = false;
+							bool drawBlockCaret = false;
+							int widthOverstrikeCaret;
 							int caretWidthOffset = 0;
-							if ((offset > 0) && (vs.caretWidth > 1))
+							PRectangle rcCaret = rcLine;
+
+							if (posCaret == pdoc->Length())	{   // At end of document
+								caretAtEOF = true;
+								widthOverstrikeCaret = vs.aveCharWidth;
+							} else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) {	// At end of line
+								caretAtEOL = true;
+								widthOverstrikeCaret = vs.aveCharWidth;
+							} else {
+								widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset];
+							}
+							if (widthOverstrikeCaret < 3)	// Make sure its visible
+								widthOverstrikeCaret = 3;
+
+							if (offset > ll->LineStart(subLine))
 								caretWidthOffset = 1;	// Move back so overlaps both character cells.
 							if (posDrag >= 0) {
+								/* Dragging text, use a line caret */
 								rcCaret.left = xposCaret - caretWidthOffset;
 								rcCaret.right = rcCaret.left + vs.caretWidth;
-							} else {
-								if (inOverstrike) {
-									rcCaret.top = rcCaret.bottom - 2;
-									rcCaret.left = xposCaret + 1;
-									rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+							} else if (inOverstrike) {
+								/* Overstrike (insert mode), use a modified bar caret */
+								rcCaret.top = rcCaret.bottom - 2;
+								rcCaret.left = xposCaret + 1;
+								rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+							} else if (vs.caretStyle == CARETSTYLE_BLOCK) {
+								/* Block caret */
+								rcCaret.left = xposCaret;
+								if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) {
+									drawBlockCaret = true;
+									rcCaret.right = xposCaret + widthOverstrikeCaret;
 								} else {
-									rcCaret.left = xposCaret - caretWidthOffset;
-									rcCaret.right = rcCaret.left + vs.caretWidth;
+									rcCaret.right = xposCaret + vs.aveCharWidth;
 								}
+							} else {
+								/* Line caret */
+								rcCaret.left = xposCaret - caretWidthOffset;
+								rcCaret.right = rcCaret.left + vs.caretWidth;
+							}
+							if (drawBlockCaret) {
+								DrawBlockCaret(surface, vs, ll, subLine, xStart, offset, posCaret, rcCaret);
+							} else {
+								surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
 							}
-							surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
 						}
 					}
 				}
@@ -3039,7 +3071,7 @@
 				if (bufferedDraw) {
 					Point from(vs.fixedColumnWidth, 0);
 					PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen,
-					                      rcClient.right, yposScreen + vs.lineHeight);
+					        rcClient.right, yposScreen + vs.lineHeight);
 					surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
 				}
 				//durCopy += et.Duration(true);
@@ -3051,6 +3083,9 @@
 
 			yposScreen += vs.lineHeight;
 			visibleLine++;
+
+			lineWidthMaxSeen = Platform::Maximum(
+			            lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
 			//gdk_flush();
 		}
 		ll.Set(0);
@@ -3110,6 +3145,9 @@
 		return 0;
 	}
 
+	// Can't use measurements cached for screen
+	posCache.Clear();
+
 	ViewStyle vsPrint(vs);
 
 	// Modify the view style for printing as do not normally want any of the transient features to be printed
@@ -3125,7 +3163,7 @@
 	vsPrint.showMarkedLines = false;
 	vsPrint.fixedColumnWidth = 0;
 	vsPrint.zoomLevel = printMagnification;
-	vsPrint.viewIndentationGuides = false;
+	vsPrint.viewIndentationGuides = ivNone;
 	// Don't show the selection when printing
 	vsPrint.selbackset = false;
 	vsPrint.selforeset = false;
@@ -3135,7 +3173,7 @@
 	vsPrint.showCaretLineBackground = false;
 
 	// Set colours for printing according to users settings
-	for (int sty = 0;sty <= STYLE_MAX;sty++) {
+	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);
@@ -3154,16 +3192,17 @@
 	vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
 
 	vsPrint.Refresh(*surfaceMeasure);
-	// Ensure colours are set up
-	vsPrint.RefreshColourPalette(palette, true);
-	vsPrint.RefreshColourPalette(palette, false);
 	// Determining width must hapen after fonts have been realised in Refresh
 	int lineNumberWidth = 0;
 	if (lineNumberIndex >= 0) {
 		lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
-		                  "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
+		        "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
 		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;
@@ -3182,14 +3221,14 @@
 	// Ensure we are styled to where we are formatting.
 	pdoc->EnsureStyledTo(endPosPrint);
 
-	int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
+	int xStart = vsPrint.fixedColumnWidth + pfr->rc.left;
 	int ypos = pfr->rc.top;
 
 	int lineDoc = linePrintStart;
 
 	int nPrintPos = pfr->chrg.cpMin;
 	int visibleLine = 0;
-	int widthPrint = pfr->rc.Width() - lineNumberWidth;
+	int widthPrint = pfr->rc.Width() - vsPrint.fixedColumnWidth;
 	if (printWrapState == eWrapNone)
 		widthPrint = LineLayout::wrapWidthInfinite;
 
@@ -3211,7 +3250,7 @@
 		ll.containsCaret = false;
 
 		PRectangle rcLine;
-		rcLine.left = pfr->rc.left + lineNumberWidth;
+		rcLine.left = pfr->rc.left;
 		rcLine.top = ypos;
 		rcLine.right = pfr->rc.right - 1;
 		rcLine.bottom = ypos + vsPrint.lineHeight;
@@ -3240,13 +3279,13 @@
 			PRectangle rcNumber = rcLine;
 			rcNumber.right = rcNumber.left + lineNumberWidth;
 			// Right justify
-			rcNumber.left -= surfaceMeasure->WidthText(
-			                     vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
+			rcNumber.left = rcNumber.right - surfaceMeasure->WidthText(
+			            vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
 			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);
+			        ypos + vsPrint.maxAscent, number, istrlen(number),
+			        vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
+			        vsPrint.styles[STYLE_LINENUMBER].back.allocated);
 		}
 
 		// Draw the line
@@ -3273,6 +3312,9 @@
 		++lineDoc;
 	}
 
+	// Clear cache so measurements are not used for screen
+	posCache.Clear();
+
 	return nPrintPos;
 }
 
@@ -3334,6 +3376,7 @@
 	AddCharUTF(s, 1);
 }
 
+// AddCharUTF inserts an array of bytes which may or may not be in UTF-8.
 void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 	bool wasSelection = currentPos != anchor;
 	ClearSelection();
@@ -3353,6 +3396,14 @@
 	if (charReplaceAction) {
 		pdoc->EndUndoAction();
 	}
+	// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
+	if (wrapState != eWrapNone) {
+		AutoSurface surface(this);
+		if (surface) {
+			WrapOneLine(surface, pdoc->LineFromPosition(currentPos));
+		}
+		SetScrollBars();
+	}
 	EnsureCaretVisible();
 	// Avoid blinking during rapid typing:
 	ShowCaretAtCurrentPosition();
@@ -3362,7 +3413,7 @@
 
 	if (treatAsDBCS) {
 		NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
-		           static_cast<unsigned char>(s[1]));
+		        static_cast<unsigned char>(s[1]));
 	} else {
 		int byte = static_cast<unsigned char>(s[0]);
 		if ((byte < 0xC0) || (1 == len)) {
@@ -3442,13 +3493,30 @@
 }
 
 void Editor::ClearDocumentStyle() {
+	Decoration *deco = pdoc->decorations.root;
+	while (deco) {
+		// Save next in case deco deleted
+		Decoration *decoNext = deco->next;
+		if (deco->indicator < INDIC_CONTAINER) {
+			pdoc->decorations.SetCurrentIndicator(deco->indicator);
+			pdoc->DecorationFillRange(0, 0, pdoc->Length());
+		}
+		deco = decoNext;
+	}
 	pdoc->StartStyling(0, '\377');
 	pdoc->SetStyleFor(pdoc->Length(), 0);
 	cs.ShowAll();
 	pdoc->ClearLevels();
 }
 
+void Editor::CopyAllowLine() {
+	SelectionText selectedText;
+	CopySelectionRange(&selectedText, true);
+	CopyToClipboard(selectedText);
+}
+
 void Editor::Cut() {
+	pdoc->CheckReadOnly();
 	if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) {
 		Copy();
 		ClearSelection();
@@ -3612,11 +3680,13 @@
 	NotifyParent(scn);
 }
 
-void Editor::NotifyDoubleClick(Point pt, bool) {
+void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) {
 	SCNotification scn = {0};
 	scn.nmhdr.code = SCN_DOUBLECLICK;
 	scn.line = LineFromLocation(pt);
 	scn.position = PositionFromLocationClose(pt);
+	scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
+	        (alt ? SCI_ALT : 0);
 	NotifyParent(scn);
 }
 
@@ -3625,7 +3695,7 @@
 	scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
 	scn.position = position;
 	scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
-	                (alt ? SCI_ALT : 0);
+	        (alt ? SCI_ALT : 0);
 	NotifyParent(scn);
 }
 
@@ -3634,7 +3704,7 @@
 	scn.nmhdr.code = SCN_HOTSPOTCLICK;
 	scn.position = position;
 	scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
-	                (alt ? SCI_ALT : 0);
+	        (alt ? SCI_ALT : 0);
 	NotifyParent(scn);
 }
 
@@ -3650,6 +3720,18 @@
 	NotifyParent(scn);
 }
 
+void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) {
+	int mask = pdoc->decorations.AllOnFor(position);
+	if ((click && mask) || pdoc->decorations.clickNotified) {
+		SCNotification scn = {0};
+		pdoc->decorations.clickNotified = click;
+		scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
+		scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0);
+		scn.position = position;
+		NotifyParent(scn);
+	}
+}
+
 bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {
 	int marginClicked = -1;
 	int x = 0;
@@ -3662,7 +3744,7 @@
 		SCNotification scn = {0};
 		scn.nmhdr.code = SCN_MARGINCLICK;
 		scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
-		                (alt ? SCI_ALT : 0);
+		        (alt ? SCI_ALT : 0);
 		scn.position = pdoc->LineStart(LineFromLocation(pt));
 		scn.margin = marginClicked;
 		NotifyParent(scn);
@@ -3714,7 +3796,7 @@
 }
 
 void Editor::CheckModificationForWrap(DocModification mh) {
-	if (mh.modificationType & (SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT)) {
+	if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
 		llc.Invalidate(LineLayout::llCheckTextAndStyle);
 		if (wrapState != eWrapNone) {
 			int lineDoc = pdoc->LineFromPosition(mh.position);
@@ -3752,8 +3834,19 @@
 	if (paintState == painting) {
 		CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
 	}
-	if (mh.modificationType & SC_MOD_CHANGESTYLE) {
-		pdoc->IncrementStyleClock();
+	if (mh.modificationType & SC_MOD_CHANGELINESTATE) {
+		if (paintState == painting) {
+			CheckForChangeOutsidePaint(
+			    Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1)));
+		} else {
+			// Could check that change is before last visible line.
+			Redraw();
+		}
+	}
+	if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) {
+		if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+			pdoc->IncrementStyleClock();
+		}
 		if (paintState == notPainting) {
 			if (mh.position < pdoc->LineStart(topLine)) {
 				// Styling performed before this view
@@ -3762,7 +3855,9 @@
 				InvalidateRange(mh.position, mh.position + mh.length);
 			}
 		}
-		llc.Invalidate(LineLayout::llCheckTextAndStyle);
+		if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+			llc.Invalidate(LineLayout::llCheckTextAndStyle);
+		}
 	} else {
 		// Move selection and brace highlights
 		if (mh.modificationType & SC_MOD_INSERTTEXT) {
@@ -3844,7 +3939,7 @@
 
 	// If client wants to see this modification
 	if (mh.modificationType & modEventMask) {
-		if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
+		if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
 			// Real modification made to text of document.
 			NotifyChange();	// Send EN_CHANGE
 		}
@@ -3942,6 +4037,7 @@
 	case SCI_VCHOMEWRAPEXTEND:
 	case SCI_DELWORDLEFT:
 	case SCI_DELWORDRIGHT:
+	case SCI_DELWORDRIGHTEND:
 	case SCI_DELLINELEFT:
 	case SCI_DELLINERIGHT:
 	case SCI_LINECOPY:
@@ -3969,10 +4065,11 @@
 	case SCI_PAGEUPRECTEXTEND:
 	case SCI_PAGEDOWNRECTEXTEND:
 	case SCI_SELECTIONDUPLICATE:
+	case SCI_COPYALLOWLINE:
 		break;
 
-	// Filter out all others like display changes. Also, newlines are redundant
-	// with char insert messages.
+		// Filter out all others like display changes. Also, newlines are redundant
+		// with char insert messages.
 	case SCI_NEWLINE:
 	default:
 		//		printf("Filtered out %ld of macro recording\n", iMessage);
@@ -4000,7 +4097,10 @@
 	// I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem?
 	int currentLine = pdoc->LineFromPosition(currentPos);
 	int topStutterLine = topLine + caretYSlop;
-	int bottomStutterLine = topLine + LinesToScroll() - caretYSlop;
+	int bottomStutterLine =
+	    pdoc->LineFromPosition(PositionFromLocation(
+	                Point(lastXChosen, direction * vs.lineHeight * LinesToScroll())))
+	    - caretYSlop - 1;
 
 	if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
 		topLineNew = topLine;
@@ -4014,9 +4114,9 @@
 		Point pt = LocationFromPosition(currentPos);
 
 		topLineNew = Platform::Clamp(
-	                     topLine + direction * LinesToScroll(), 0, MaxScrollPos());
+		            topLine + direction * LinesToScroll(), 0, MaxScrollPos());
 		newPos = PositionFromLocation(
-	                 Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll())));
+		            Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll())));
 	}
 
 	if (topLineNew != topLine) {
@@ -4035,7 +4135,7 @@
 	int startAnchor = anchor;
 	if (selType == selStream) {
 		pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
-		                 makeUpperCase);
+		        makeUpperCase);
 		SetSelection(startCurrent, startAnchor);
 	} else {
 		SelectionLineIterator lineIterator(this, false);
@@ -4053,32 +4153,23 @@
 void Editor::LineTranspose() {
 	int line = pdoc->LineFromPosition(currentPos);
 	if (line > 0) {
+		pdoc->BeginUndoAction();
 		int startPrev = pdoc->LineStart(line - 1);
 		int endPrev = pdoc->LineEnd(line - 1);
 		int start = pdoc->LineStart(line);
 		int end = pdoc->LineEnd(line);
-		int startNext = pdoc->LineStart(line + 1);
-		if (end < pdoc->Length()) {
-			end = startNext;
-			char *thisLine = CopyRange(start, end);
-			pdoc->DeleteChars(start, end - start);
-			if (pdoc->InsertString(startPrev, thisLine, end - start)) {
-				MovePositionTo(startPrev + end - start);
-			}
-			delete []thisLine;
-		} else {
-			// Last line so line has no line end
-			char *thisLine = CopyRange(start, end);
-			char *prevEnd = CopyRange(endPrev, start);
-			pdoc->DeleteChars(endPrev, end - endPrev);
-			pdoc->InsertString(startPrev, thisLine, end - start);
-			if (pdoc->InsertString(startPrev + end - start, prevEnd, start - endPrev)) {
-				MovePositionTo(startPrev + end - endPrev);
-			}
-			delete []thisLine;
-			delete []prevEnd;
-		}
-
+		char *line1 = CopyRange(startPrev, endPrev);
+		int len1 = endPrev - startPrev;
+		char *line2 = CopyRange(start, end);
+		int len2 = end - start;
+		pdoc->DeleteChars(start, len2);
+		pdoc->DeleteChars(startPrev, len1);
+		pdoc->InsertString(startPrev, line2, len2);
+		pdoc->InsertString(start - len1 + len2, line1, len1);
+		MovePositionTo(start - len1 + len2);
+		delete []line1;
+		delete []line2;
+		pdoc->EndUndoAction();
 	}
 }
 
@@ -4096,7 +4187,7 @@
 	char *text = CopyRange(start, end);
 	if (forLine) {
 		const char *eol = StringFromEOLMode(pdoc->eolMode);
-		pdoc->InsertString(end, eol);
+		pdoc->InsertCString(end, eol);
 		pdoc->InsertString(end + istrlen(eol), text, end - start);
 	} else {
 		pdoc->InsertString(end, text, end - start);
@@ -4116,7 +4207,7 @@
 	} else if (pdoc->eolMode == SC_EOL_CR) {
 		eol = "\r";
 	} // else SC_EOL_LF -> "\n" already set
-	if (pdoc->InsertString(currentPos, eol)) {
+	if (pdoc->InsertCString(currentPos, eol)) {
 		SetEmptySelection(currentPos + istrlen(eol));
 		while (*eol) {
 			NotifyChar(*eol);
@@ -4124,6 +4215,7 @@
 		}
 	}
 	SetLastXChosen();
+	SetScrollBars();
 	EnsureCaretVisible();
 	// Avoid blinking during rapid typing:
 	ShowCaretAtCurrentPosition();
@@ -4132,7 +4224,7 @@
 void Editor::CursorUpOrDown(int direction, selTypes sel) {
 	Point pt = LocationFromPosition(currentPos);
 	int posNew = PositionFromLocation(
-	                 Point(lastXChosen, pt.y + direction * vs.lineHeight));
+	            Point(lastXChosen, pt.y + direction * vs.lineHeight));
 	if (direction < 0) {
 		// Line wrapping may lead to a location on the same line, so
 		// seek back if that is the case.
@@ -4345,7 +4437,7 @@
 			int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
 			int realEndPos = pdoc->LineEndPosition(currentPos);
 			if (endPos > realEndPos      // if moved past visible EOLs
-				|| currentPos >= endPos) // if at end of display line already
+			        || currentPos >= endPos) // if at end of display line already
 				endPos = realEndPos;
 			MovePositionTo(endPos);
 			SetLastXChosen();
@@ -4355,7 +4447,7 @@
 			int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
 			int realEndPos = pdoc->LineEndPosition(currentPos);
 			if (endPos > realEndPos      // if moved past visible EOLs
-				|| currentPos >= endPos) // if at end of display line already
+			        || currentPos >= endPos) // if at end of display line already
 				endPos = realEndPos;
 			MovePositionTo(endPos, selStream);
 			SetLastXChosen();
@@ -4508,6 +4600,11 @@
 			pdoc->DeleteChars(currentPos, endWord - currentPos);
 		}
 		break;
+	case SCI_DELWORDRIGHTEND: {
+			int endWord = pdoc->NextWordEnd(currentPos, 1);
+			pdoc->DeleteChars(currentPos, endWord - currentPos);
+		}
+		break;
 	case SCI_DELLINELEFT: {
 			int line = pdoc->LineFromPosition(currentPos);
 			int start = pdoc->LineStart(line);
@@ -4525,7 +4622,7 @@
 			int lineStart = pdoc->LineFromPosition(SelectionStart());
 			int lineEnd = pdoc->LineFromPosition(SelectionEnd());
 			CopyRangeToClipboard(pdoc->LineStart(lineStart),
-				pdoc->LineStart(lineEnd + 1));
+			        pdoc->LineStart(lineEnd + 1));
 		}
 		break;
 	case SCI_LINECUT: {
@@ -4578,22 +4675,22 @@
 		break;
 	case SCI_HOMEDISPLAY:
 		MovePositionTo(MovePositionSoVisible(
-		                   StartEndDisplayLine(currentPos, true), -1));
+		            StartEndDisplayLine(currentPos, true), -1));
 		SetLastXChosen();
 		break;
 	case SCI_HOMEDISPLAYEXTEND:
 		MovePositionTo(MovePositionSoVisible(
-		                   StartEndDisplayLine(currentPos, true), -1), selStream);
+		            StartEndDisplayLine(currentPos, true), -1), selStream);
 		SetLastXChosen();
 		break;
 	case SCI_LINEENDDISPLAY:
 		MovePositionTo(MovePositionSoVisible(
-		                   StartEndDisplayLine(currentPos, false), 1));
+		            StartEndDisplayLine(currentPos, false), 1));
 		SetLastXChosen();
 		break;
 	case SCI_LINEENDDISPLAYEXTEND:
 		MovePositionTo(MovePositionSoVisible(
-		                   StartEndDisplayLine(currentPos, false), 1), selStream);
+		            StartEndDisplayLine(currentPos, false), 1), selStream);
 		SetLastXChosen();
 		break;
 	}
@@ -4607,7 +4704,7 @@
 int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
 	DwellEnd(false);
 	int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
-	                (alt ? SCI_ALT : 0);
+	        (alt ? SCI_ALT : 0);
 	int msg = kmap.Find(key, modifiers);
 	if (msg) {
 		if (consumed)
@@ -4648,7 +4745,7 @@
 					SetEmptySelection(currentPos + 1);
 				} else {
 					int numSpaces = (pdoc->tabInChars) -
-					                (pdoc->GetColumn(currentPos) % (pdoc->tabInChars));
+					        (pdoc->GetColumn(currentPos) % (pdoc->tabInChars));
 					if (numSpaces < 1)
 						numSpaces = pdoc->tabInChars;
 					for (int i = 0; i < numSpaces; i++) {
@@ -4669,7 +4766,7 @@
 				pdoc->EndUndoAction();
 			} else {
 				int newColumn = ((pdoc->GetColumn(currentPos) - 1) / pdoc->tabInChars) *
-				                pdoc->tabInChars;
+				        pdoc->tabInChars;
 				if (newColumn < 0)
 					newColumn = 0;
 				int newPos = currentPos;
@@ -4708,19 +4805,19 @@
  * @return The position of the found text, -1 if not found.
  */
 long Editor::FindText(
-	uptr_t wParam,		///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
-						///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
-	sptr_t lParam) {	///< @c TextToFind structure: The text to search for in the given range.
+    uptr_t wParam,		///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
+    ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
+    sptr_t lParam) {	///< @c TextToFind structure: The text to search for in the given range.
 
 	TextToFind *ft = reinterpret_cast<TextToFind *>(lParam);
 	int lengthFound = istrlen(ft->lpstrText);
 	int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
-	                         (wParam & SCFIND_MATCHCASE) != 0,
-	                         (wParam & SCFIND_WHOLEWORD) != 0,
-	                         (wParam & SCFIND_WORDSTART) != 0,
-	                         (wParam & SCFIND_REGEXP) != 0,
-	                         (wParam & SCFIND_POSIX) != 0,
-	                         &lengthFound);
+	        (wParam & SCFIND_MATCHCASE) != 0,
+	        (wParam & SCFIND_WHOLEWORD) != 0,
+	        (wParam & SCFIND_WORDSTART) != 0,
+	        (wParam & SCFIND_REGEXP) != 0,
+	        wParam,
+	        &lengthFound);
 	if (pos != -1) {
 		ft->chrgText.cpMin = pos;
 		ft->chrgText.cpMax = pos + lengthFound;
@@ -4751,7 +4848,7 @@
 long Editor::SearchText(
     unsigned int iMessage,		///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV.
     uptr_t wParam,				///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
-								///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
+    ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
     sptr_t lParam) {			///< The text to search for.
 
 	const char *txt = reinterpret_cast<char *>(lParam);
@@ -4759,20 +4856,20 @@
 	int lengthFound = istrlen(txt);
 	if (iMessage == SCI_SEARCHNEXT) {
 		pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
-		                     (wParam & SCFIND_MATCHCASE) != 0,
-		                     (wParam & SCFIND_WHOLEWORD) != 0,
-		                     (wParam & SCFIND_WORDSTART) != 0,
-		                     (wParam & SCFIND_REGEXP) != 0,
-		                     (wParam & SCFIND_POSIX) != 0,
-		                     &lengthFound);
+		        (wParam & SCFIND_MATCHCASE) != 0,
+		        (wParam & SCFIND_WHOLEWORD) != 0,
+		        (wParam & SCFIND_WORDSTART) != 0,
+		        (wParam & SCFIND_REGEXP) != 0,
+		        wParam,
+		        &lengthFound);
 	} else {
 		pos = pdoc->FindText(searchAnchor, 0, txt,
-		                     (wParam & SCFIND_MATCHCASE) != 0,
-		                     (wParam & SCFIND_WHOLEWORD) != 0,
-		                     (wParam & SCFIND_WORDSTART) != 0,
-		                     (wParam & SCFIND_REGEXP) != 0,
-		                     (wParam & SCFIND_POSIX) != 0,
-		                     &lengthFound);
+		        (wParam & SCFIND_MATCHCASE) != 0,
+		        (wParam & SCFIND_WHOLEWORD) != 0,
+		        (wParam & SCFIND_WORDSTART) != 0,
+		        (wParam & SCFIND_REGEXP) != 0,
+		        wParam,
+		        &lengthFound);
 	}
 
 	if (pos != -1) {
@@ -4789,12 +4886,12 @@
 long Editor::SearchInTarget(const char *text, int length) {
 	int lengthFound = length;
 	int pos = pdoc->FindText(targetStart, targetEnd, text,
-	                         (searchFlags & SCFIND_MATCHCASE) != 0,
-	                         (searchFlags & SCFIND_WHOLEWORD) != 0,
-	                         (searchFlags & SCFIND_WORDSTART) != 0,
-	                         (searchFlags & SCFIND_REGEXP) != 0,
-	                         (searchFlags & SCFIND_POSIX) != 0,
-	                         &lengthFound);
+	        (searchFlags & SCFIND_MATCHCASE) != 0,
+	        (searchFlags & SCFIND_WHOLEWORD) != 0,
+	        (searchFlags & SCFIND_WORDSTART) != 0,
+	        (searchFlags & SCFIND_REGEXP) != 0,
+	        searchFlags,
+	        &lengthFound);
 	if (pos != -1) {
 		targetStart = pos;
 		targetEnd = pos + lengthFound;
@@ -4835,14 +4932,37 @@
 	return text;
 }
 
-void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) {
-	ss->Set(CopyRange(start, end), end - start + 1,
-		pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
+void Editor::CopySelectionFromRange(SelectionText *ss, bool allowLineCopy, int start, int end) {
+	bool isLine = allowLineCopy && (start == end);
+	if (isLine) {
+		int currentLine = pdoc->LineFromPosition(currentPos);
+		start = pdoc->LineStart(currentLine);
+		end = pdoc->LineEnd(currentLine);
+
+		char *text = CopyRange(start, end);
+		int textLen = text ? strlen(text) : 0;
+		// include room for \r\n\0
+		textLen += 3;
+		char *textWithEndl = new char[textLen];
+		textWithEndl[0] = '\0';
+		if (text)
+			strncat(textWithEndl, text, textLen);
+		if (pdoc->eolMode != SC_EOL_LF)
+			strncat(textWithEndl, "\r", textLen);
+		if (pdoc->eolMode != SC_EOL_CR)
+			strncat(textWithEndl, "\n", textLen);
+		ss->Set(textWithEndl, strlen(textWithEndl),
+			pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true);
+		delete []text;
+	} else {
+		ss->Set(CopyRange(start, end), end - start + 1,
+			pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
+	}
 }
 
-void Editor::CopySelectionRange(SelectionText *ss) {
+void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
 	if (selType == selStream) {
-		CopySelectionFromRange(ss, SelectionStart(), SelectionEnd());
+		CopySelectionFromRange(ss, allowLineCopy, SelectionStart(), SelectionEnd());
 	} else {
 		char *text = 0;
 		int size = 0;
@@ -4863,8 +4983,8 @@
 				lineIterator.Reset();
 				while (lineIterator.Iterate()) {
 					for (int i = lineIterator.startPos;
-						 i < lineIterator.endPos;
-						 i++) {
+					        i < lineIterator.endPos;
+					        i++) {
 						text[j++] = pdoc->CharAt(i);
 					}
 					if (selType != selLines) {
@@ -4880,7 +5000,7 @@
 			}
 		}
 		ss->Set(text, size + 1, pdoc->dbcsCodePage,
-			vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle);
+			vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle, selType == selLines);
 	}
 }
 
@@ -4889,14 +5009,14 @@
 	end = pdoc->ClampPositionIntoDocument(end);
 	SelectionText selectedText;
 	selectedText.Set(CopyRange(start, end), end - start + 1,
-		pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
+		pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
 	CopyToClipboard(selectedText);
 }
 
 void Editor::CopyText(int length, const char *text) {
 	SelectionText selectedText;
 	selectedText.Copy(text, length + 1,
-		pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
+		pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
 	CopyToClipboard(selectedText);
 }
 
@@ -4921,6 +5041,13 @@
 		wMain.SetCursor(static_cast<Window::Cursor>(cursorMode));
 }
 
+bool Editor::DragThreshold(Point ptStart, Point ptNow) {
+	int xMove = ptStart.x - ptNow.x;
+	int yMove = ptStart.y - ptNow.y;
+	int distanceSquared = xMove * xMove + yMove * yMove;
+	return distanceSquared > 16;
+}
+
 void Editor::StartDrag() {
 	// Always handled by subclasses
 	//SetMouseCapture(true);
@@ -4928,8 +5055,8 @@
 }
 
 void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
-	//Platform::DebugPrintf("DropAt %d\n", inDragDrop);
-	if (inDragDrop)
+	//Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
+	if (inDragDrop == ddDragging)
 		dropWentOutside = false;
 
 	int positionWasInSelection = PositionInSelection(position);
@@ -4937,7 +5064,7 @@
 	bool positionOnEdgeOfSelection =
 	    (position == SelectionStart()) || (position == SelectionEnd());
 
-	if ((!inDragDrop) || !(0 == positionWasInSelection) ||
+	if ((inDragDrop != ddDragging) || !(0 == positionWasInSelection) ||
 	        (positionOnEdgeOfSelection && !moving)) {
 
 		int selStart = SelectionStart();
@@ -4946,7 +5073,7 @@
 		pdoc->BeginUndoAction();
 
 		int positionAfterDeletion = position;
-		if (inDragDrop && moving) {
+		if ((inDragDrop == ddDragging) && moving) {
 			// Remove dragged out text
 			if (rectangular || selType == selLines) {
 				SelectionLineIterator lineIterator(this);
@@ -4975,12 +5102,12 @@
 			SetEmptySelection(position);
 		} else {
 			position = MovePositionOutsideChar(position, currentPos - position);
-			if (pdoc->InsertString(position, value)) {
+			if (pdoc->InsertCString(position, value)) {
 				SetSelection(position + istrlen(value), position);
 			}
 			pdoc->EndUndoAction();
 		}
-	} else if (inDragDrop) {
+	} else if (inDragDrop == ddDragging) {
 		SetEmptySelection(position);
 	}
 }
@@ -5060,13 +5187,13 @@
 void Editor::LineSelection(int lineCurrent_, int lineAnchor_) {
 	if (lineAnchor_ < lineCurrent_) {
 		SetSelection(pdoc->LineStart(lineCurrent_ + 1),
-		             pdoc->LineStart(lineAnchor_));
+		        pdoc->LineStart(lineAnchor_));
 	} else if (lineAnchor_ > lineCurrent_) {
 		SetSelection(pdoc->LineStart(lineCurrent_),
-		             pdoc->LineStart(lineAnchor_ + 1));
+		        pdoc->LineStart(lineAnchor_ + 1));
 	} else { // Same line, select it
 		SetSelection(pdoc->LineStart(lineAnchor_ + 1),
-		             pdoc->LineStart(lineAnchor_));
+		        pdoc->LineStart(lineAnchor_));
 	}
 }
 
@@ -5082,17 +5209,19 @@
 }
 
 void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
-	//Platform::DebugPrintf("Scintilla:ButtonDown %d %d = %d alt=%d\n", curTime, lastClickTime, curTime - lastClickTime, alt);
+	//Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop);
 	ptMouseLast = pt;
 	int newPos = PositionFromLocation(pt);
 	newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
-	inDragDrop = false;
+	inDragDrop = ddNone;
 	moveExtendsSelection = false;
 
 	bool processed = NotifyMarginClick(pt, shift, ctrl, alt);
 	if (processed)
 		return;
 
+	NotifyIndicatorClick(true, newPos, shift, ctrl, alt);
+
 	bool inSelMargin = PointInSelMargin(pt);
 	if (shift & !inSelMargin) {
 		SetSelection(newPos);
@@ -5118,10 +5247,10 @@
 		if (selectionType == selWord) {
 			if (currentPos >= originalAnchorPos) {	// Moved forward
 				SetSelection(pdoc->ExtendWordSelect(currentPos, 1),
-				             pdoc->ExtendWordSelect(originalAnchorPos, -1));
+				        pdoc->ExtendWordSelect(originalAnchorPos, -1));
 			} else {	// Moved backward
 				SetSelection(pdoc->ExtendWordSelect(currentPos, -1),
-				             pdoc->ExtendWordSelect(originalAnchorPos, 1));
+				        pdoc->ExtendWordSelect(originalAnchorPos, 1));
 			}
 		} else if (selectionType == selLine) {
 			lineAnchor = LineFromLocation(pt);
@@ -5132,7 +5261,7 @@
 		}
 		//Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos);
 		if (doubleClick) {
-			NotifyDoubleClick(pt, shift);
+			NotifyDoubleClick(pt, shift, ctrl, alt);
 			if (PositionIsHotspot(newPos))
 				NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt);
 		}
@@ -5149,7 +5278,7 @@
 				// Single click in margin: select whole line
 				LineSelection(lineAnchor, lineAnchor);
 				SetSelection(pdoc->LineStart(lineAnchor + 1),
-				             pdoc->LineStart(lineAnchor));
+				        pdoc->LineStart(lineAnchor));
 			} else {
 				// Single shift+click in margin: select from line anchor to clicked line
 				if (anchor > currentPos)
@@ -5169,16 +5298,14 @@
 				NotifyHotSpotClicked(newPos, shift, ctrl, alt);
 			}
 			if (!shift) {
-				inDragDrop = PointInSelection(pt) && !SelectionEmpty();
+				if (PointInSelection(pt) && !SelectionEmpty())
+					inDragDrop = ddInitial;
+				else
+					inDragDrop = ddNone;
 			}
-			if (inDragDrop) {
-				SetMouseCapture(false);
-				SetDragPosition(newPos);
-				CopySelectionRange(&drag);
-				StartDrag();
-			} else {
+			SetMouseCapture(true);
+			if (inDragDrop != ddInitial) {
 				SetDragPosition(invalidPosition);
-				SetMouseCapture(true);
 				if (!shift) {
 					SetEmptySelection(newPos);
 				}
@@ -5247,6 +5374,20 @@
 	if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {
 		DwellEnd(true);
 	}
+
+	int movePos = PositionFromLocation(pt);
+	movePos = MovePositionOutsideChar(movePos, currentPos - movePos);
+
+	if (inDragDrop == ddInitial) {
+		if (DragThreshold(ptMouseLast, pt)) {
+			SetMouseCapture(false);
+			SetDragPosition(movePos);
+			CopySelectionRange(&drag);
+			StartDrag();
+		}
+		return;
+	}
+
 	ptMouseLast = pt;
 	//Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y);
 	if (HaveMouseCapture()) {
@@ -5258,8 +5399,6 @@
 		autoScrollTimer.ticksToWait = autoScrollDelay;
 
 		// Adjust selection
-		int movePos = PositionFromLocation(pt);
-		movePos = MovePositionOutsideChar(movePos, currentPos - movePos);
 		if (posDrag >= 0) {
 			SetDragPosition(movePos);
 		} else {
@@ -5279,10 +5418,10 @@
 					// being unmade.
 				} else if (movePos > originalAnchorPos) {	// Moved forward
 					SetSelection(pdoc->ExtendWordSelect(movePos, 1),
-					             pdoc->ExtendWordSelect(originalAnchorPos, -1));
+					        pdoc->ExtendWordSelect(originalAnchorPos, -1));
 				} else {	// Moved backward
 					SetSelection(pdoc->ExtendWordSelect(movePos, -1),
-					             pdoc->ExtendWordSelect(originalAnchorPos, 1));
+					        pdoc->ExtendWordSelect(originalAnchorPos, 1));
 				}
 			} else {
 				// Continue selecting by line
@@ -5302,11 +5441,11 @@
 			if (lineMove < 0) {
 				lineMove = cs.DisplayFromDoc(pdoc->LinesTotal() - 1);
 			}
-			ScrollTo(lineMove - LinesOnScreen() + 5);
+			ScrollTo(lineMove - LinesOnScreen() + 1);
 			Redraw();
 		} else if (pt.y < rcClient.top) {
 			int lineMove = cs.DisplayFromDoc(LineFromLocation(pt));
-			ScrollTo(lineMove - 5);
+			ScrollTo(lineMove - 1);
 			Redraw();
 		}
 		EnsureCaretVisible(false, false, true);
@@ -5335,7 +5474,13 @@
 }
 
 void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
-	//Platform::DebugPrintf("ButtonUp %d\n", HaveMouseCapture());
+	//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
+	int newPos = PositionFromLocation(pt);
+	newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
+	if (inDragDrop == ddInitial) {
+		inDragDrop = ddNone;
+		SetEmptySelection(newPos);
+	}
 	if (HaveMouseCapture()) {
 		if (PointInSelMargin(pt)) {
 			DisplayCursor(Window::cursorReverseArrow);
@@ -5347,7 +5492,8 @@
 		SetMouseCapture(false);
 		int newPos = PositionFromLocation(pt);
 		newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
-		if (inDragDrop) {
+		NotifyIndicatorClick(false, newPos, false, false, false);
+		if (inDragDrop == ddDragging) {
 			int selStart = SelectionStart();
 			int selEnd = SelectionEnd();
 			if (selStart < selEnd) {
@@ -5386,7 +5532,7 @@
 		if (selType == selStream) {
 			SetLastXChosen();
 		}
-		inDragDrop = false;
+		inDragDrop = ddNone;
 		EnsureCaretVisible(false);
 	}
 }
@@ -5408,6 +5554,10 @@
 			}
 		}
 	}
+	if (horizontalScrollBarVisible && trackLineWidth && (lineWidthMaxSeen > scrollWidth)) {
+		scrollWidth = lineWidthMaxSeen;
+		SetScrollBars();
+	}
 	if ((dwellDelay < SC_TIME_FOREVER) &&
 	        (ticksToDwell > 0) &&
 	        (!HaveMouseCapture())) {
@@ -5455,7 +5605,11 @@
 }
 
 bool Editor::PaintContains(PRectangle rc) {
-	return rcPaint.Contains(rc);
+	if (rc.Empty()) {
+		return true;
+	} else {
+		return rcPaint.Contains(rc);
+	}
 }
 
 bool Editor::PaintContainsMargin() {
@@ -5625,7 +5779,7 @@
 				SetVerticalScrollPos();
 				Redraw();
 			} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
-			           ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
+			        ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
 				SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
 				SetVerticalScrollPos();
 				Redraw();
@@ -5646,8 +5800,10 @@
 		length = istrlen(text);
 	if (replacePatterns) {
 		text = pdoc->SubstituteByPosition(text, &length);
-		if (!text)
+		if (!text) {
+			pdoc->EndUndoAction();
 			return 0;
+		}
 	}
 	if (targetStart != targetEnd)
 		pdoc->DeleteChars(targetStart, targetEnd - targetStart);
@@ -5681,6 +5837,26 @@
 	}
 }
 
+void Editor::AddStyledText(char *buffer, int appendLength) {
+	// The buffer consists of alternating character bytes and style bytes
+	size_t textLength = appendLength / 2;
+	char *text = new char[textLength];
+	if (text) {
+		size_t i;
+		for (i = 0;i < textLength;i++) {
+			text[i] = buffer[i*2];
+		}
+		pdoc->InsertString(CurrentPosition(), text, textLength);
+		for (i = 0;i < textLength;i++) {
+			text[i] = buffer[i*2+1];
+		}
+		pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
+		pdoc->SetStyles(textLength, text);
+		delete []text;
+	}
+	SetEmptySelection(currentPos + textLength);
+}
+
 static bool ValidMargin(unsigned long wParam) {
 	return wParam < ViewStyle::margins;
 }
@@ -5689,6 +5865,89 @@
 	return reinterpret_cast<char *>(lParam);
 }
 
+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);
+		break;
+	case SCI_STYLESETBACK:
+		vs.styles[wParam].back.desired = ColourDesired(lParam);
+		break;
+	case SCI_STYLESETBOLD:
+		vs.styles[wParam].bold = lParam != 0;
+		break;
+	case SCI_STYLESETITALIC:
+		vs.styles[wParam].italic = lParam != 0;
+		break;
+	case SCI_STYLESETEOLFILLED:
+		vs.styles[wParam].eolFilled = lParam != 0;
+		break;
+	case SCI_STYLESETSIZE:
+		vs.styles[wParam].size = lParam;
+		break;
+	case SCI_STYLESETFONT:
+		if (lParam != 0) {
+			vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam));
+		}
+		break;
+	case SCI_STYLESETUNDERLINE:
+		vs.styles[wParam].underline = lParam != 0;
+		break;
+	case SCI_STYLESETCASE:
+		vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
+		break;
+	case SCI_STYLESETCHARACTERSET:
+		vs.styles[wParam].characterSet = lParam;
+		break;
+	case SCI_STYLESETVISIBLE:
+		vs.styles[wParam].visible = lParam != 0;
+		break;
+	case SCI_STYLESETCHANGEABLE:
+		vs.styles[wParam].changeable = lParam != 0;
+		break;
+	case SCI_STYLESETHOTSPOT:
+		vs.styles[wParam].hotspot = lParam != 0;
+		break;
+	}
+	InvalidateStyleRedraw();
+}
+
+sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+	vs.EnsureStyle(wParam);
+	switch (iMessage) {
+	case SCI_STYLEGETFORE:
+		return vs.styles[wParam].fore.desired.AsLong();
+	case SCI_STYLEGETBACK:
+		return vs.styles[wParam].back.desired.AsLong();
+	case SCI_STYLEGETBOLD:
+		return vs.styles[wParam].bold ? 1 : 0;
+	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;
+	case SCI_STYLEGETFONT:
+		if (lParam != 0)
+			strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName);
+		return strlen(vs.styles[wParam].fontName);
+	case SCI_STYLEGETUNDERLINE:
+		return vs.styles[wParam].underline ? 1 : 0;
+	case SCI_STYLEGETCASE:
+		return static_cast<int>(vs.styles[wParam].caseForce);
+	case SCI_STYLEGETCHARACTERSET:
+		return vs.styles[wParam].characterSet;
+	case SCI_STYLEGETVISIBLE:
+		return vs.styles[wParam].visible ? 1 : 0;
+	case SCI_STYLEGETCHANGEABLE:
+		return vs.styles[wParam].changeable ? 1 : 0;
+	case SCI_STYLEGETHOTSPOT:
+		return vs.styles[wParam].hotspot ? 1 : 0;
+	}
+	return 0;
+}
+
 sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	//Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
@@ -5717,7 +5976,7 @@
 			pdoc->BeginUndoAction();
 			pdoc->DeleteChars(0, pdoc->Length());
 			SetEmptySelection(0);
-			pdoc->InsertString(0, CharPtrFromSPtr(lParam));
+			pdoc->InsertCString(0, CharPtrFromSPtr(lParam));
 			pdoc->EndUndoAction();
 			return 1;
 		}
@@ -5734,6 +5993,10 @@
 		Copy();
 		break;
 
+	case SCI_COPYALLOWLINE:
+		CopyAllowLine();
+		break;
+
 	case SCI_COPYRANGE:
 		CopyRangeToClipboard(wParam, lParam);
 		break;
@@ -5867,7 +6130,7 @@
 			pdoc->BeginUndoAction();
 			ClearSelection();
 			char *replacement = CharPtrFromSPtr(lParam);
-			pdoc->InsertString(currentPos, replacement);
+			pdoc->InsertCString(currentPos, replacement);
 			pdoc->EndUndoAction();
 			SetEmptySelection(currentPos + istrlen(replacement));
 			EnsureCaretVisible();
@@ -5918,10 +6181,10 @@
 		return searchFlags;
 
 	case SCI_POSITIONBEFORE:
-		return pdoc->MovePositionOutsideChar(wParam-1, -1, true);
+		return pdoc->MovePositionOutsideChar(wParam - 1, -1, true);
 
 	case SCI_POSITIONAFTER:
-		return pdoc->MovePositionOutsideChar(wParam+1, 1, true);
+		return pdoc->MovePositionOutsideChar(wParam + 1, 1, true);
 
 	case SCI_LINESCROLL:
 		ScrollTo(topLine + lParam);
@@ -6023,13 +6286,10 @@
 			return 0;
 		}
 
-	case SCI_ADDSTYLEDTEXT: {
-			if (lParam == 0)
-				return 0;
-			pdoc->InsertStyledString(CurrentPosition() * 2, CharPtrFromSPtr(lParam), wParam);
-			SetEmptySelection(currentPos + wParam / 2);
-			return 0;
-		}
+	case SCI_ADDSTYLEDTEXT:
+		if (lParam)
+			AddStyledText(CharPtrFromSPtr(lParam), wParam);
+		return 0;
 
 	case SCI_INSERTTEXT: {
 			if (lParam == 0)
@@ -6039,7 +6299,7 @@
 				insertPos = CurrentPosition();
 			int newCurrent = CurrentPosition();
 			char *sz = CharPtrFromSPtr(lParam);
-			pdoc->InsertString(insertPos, sz);
+			pdoc->InsertCString(insertPos, sz);
 			if (newCurrent > insertPos)
 				newCurrent += istrlen(sz);
 			SetEmptySelection(newCurrent);
@@ -6409,9 +6669,17 @@
 	case SCI_GETLAYOUTCACHE:
 		return llc.GetLevel();
 
+	case SCI_SETPOSITIONCACHE:
+		posCache.SetSize(wParam);
+		break;
+
+	case SCI_GETPOSITIONCACHE:
+		return posCache.GetSize();
+
 	case SCI_SETSCROLLWIDTH:
 		PLATFORM_ASSERT(wParam > 0);
 		if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) {
+			lineWidthMaxSeen = 0;
 			scrollWidth = wParam;
 			SetScrollBars();
 		}
@@ -6420,6 +6688,13 @@
 	case SCI_GETSCROLLWIDTH:
 		return scrollWidth;
 
+	case SCI_SETSCROLLWIDTHTRACKING:
+		trackLineWidth = wParam != 0;
+		break;
+
+	case SCI_GETSCROLLWIDTHTRACKING:
+		return trackLineWidth;
+
 	case SCI_LINESJOIN:
 		LinesJoin();
 		break;
@@ -6429,7 +6704,7 @@
 		break;
 
 	case SCI_TEXTWIDTH:
-		PLATFORM_ASSERT(wParam <= STYLE_MAX);
+		PLATFORM_ASSERT(wParam < vs.stylesSize);
 		PLATFORM_ASSERT(lParam);
 		return TextWidth(wParam, CharPtrFromSPtr(lParam));
 
@@ -6490,7 +6765,7 @@
 		return verticalScrollBarVisible;
 
 	case SCI_SETINDENTATIONGUIDES:
-		vs.viewIndentationGuides = wParam != 0;
+		vs.viewIndentationGuides = IndentView(wParam);
 		Redraw();
 		break;
 
@@ -6658,91 +6933,42 @@
 		break;
 
 	case SCI_STYLESETFORE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].fore.desired = ColourDesired(lParam);
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETBACK:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].back.desired = ColourDesired(lParam);
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETBOLD:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].bold = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETITALIC:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].italic = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETEOLFILLED:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].eolFilled = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETSIZE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].size = lParam;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETFONT:
-		if (lParam == 0)
-			return 0;
-		if (wParam <= STYLE_MAX) {
-			vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam));
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETUNDERLINE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].underline = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETCASE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETCHARACTERSET:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].characterSet = lParam;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETVISIBLE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].visible = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETCHANGEABLE:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].changeable = lParam != 0;
-			InvalidateStyleRedraw();
-		}
-		break;
 	case SCI_STYLESETHOTSPOT:
-		if (wParam <= STYLE_MAX) {
-			vs.styles[wParam].hotspot = lParam != 0;
-			InvalidateStyleRedraw();
-		}
+		StyleSetMessage(iMessage, wParam, lParam);
 		break;
 
+	case SCI_STYLEGETFORE:
+	case SCI_STYLEGETBACK:
+	case SCI_STYLEGETBOLD:
+	case SCI_STYLEGETITALIC:
+	case SCI_STYLEGETEOLFILLED:
+	case SCI_STYLEGETSIZE:
+	case SCI_STYLEGETFONT:
+	case SCI_STYLEGETUNDERLINE:
+	case SCI_STYLEGETCASE:
+	case SCI_STYLEGETCHARACTERSET:
+	case SCI_STYLEGETVISIBLE:
+	case SCI_STYLEGETCHANGEABLE:
+	case SCI_STYLEGETHOTSPOT:
+		return StyleGetMessage(iMessage, wParam, lParam);
+
 	case SCI_STYLERESETDEFAULT:
 		vs.ResetDefaultStyle();
 		InvalidateStyleRedraw();
 		break;
 	case SCI_SETSTYLEBITS:
+		vs.EnsureStyle((1 << wParam) - 1);
 		pdoc->SetStylingBits(wParam);
 		break;
 
@@ -6811,7 +7037,8 @@
 		break;
 
 	case SCI_HIDELINES:
-		cs.SetVisible(wParam, lParam, false);
+		if (wParam > 0)
+			cs.SetVisible(wParam, lParam, false);
 		SetScrollBars();
 		Redraw();
 		break;
@@ -6898,6 +7125,14 @@
 	case SCI_GETSELALPHA:
 		return vs.selAlpha;
 
+	case SCI_GETSELEOLFILLED:
+		return vs.selEOLFilled;
+
+	case SCI_SETSELEOLFILLED:
+		vs.selEOLFilled = wParam != 0;
+		InvalidateStyleRedraw();
+		break;
+
 	case SCI_SETWHITESPACEFORE:
 		vs.whitespaceForegroundSet = wParam != 0;
 		vs.whitespaceForeground.desired = ColourDesired(lParam);
@@ -6918,6 +7153,18 @@
 	case SCI_GETCARETFORE:
 		return vs.caretcolour.desired.AsLong();
 
+	case SCI_SETCARETSTYLE:
+		if (wParam >= CARETSTYLE_INVISIBLE && wParam <= CARETSTYLE_BLOCK)
+			vs.caretStyle = wParam;
+		else
+			/* Default to the line caret */
+			vs.caretStyle = CARETSTYLE_LINE;
+		InvalidateStyleRedraw();
+		break;
+
+	case SCI_GETCARETSTYLE:
+		return vs.caretStyle;
+
 	case SCI_SETCARETWIDTH:
 		if (wParam <= 0)
 			vs.caretWidth = 0;
@@ -6933,12 +7180,12 @@
 
 	case SCI_ASSIGNCMDKEY:
 		kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
-		                  Platform::HighShortFromLong(wParam), lParam);
+		        Platform::HighShortFromLong(wParam), lParam);
 		break;
 
 	case SCI_CLEARCMDKEY:
 		kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
-		                  Platform::HighShortFromLong(wParam), SCI_NULL);
+		        Platform::HighShortFromLong(wParam), SCI_NULL);
 		break;
 
 	case SCI_CLEARALLCMDKEYS:
@@ -6965,6 +7212,47 @@
 	case SCI_INDICGETFORE:
 		return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0;
 
+	case SCI_INDICSETUNDER:
+		if (wParam <= INDIC_MAX) {
+			vs.indicators[wParam].under = lParam != 0;
+			InvalidateStyleRedraw();
+		}
+		break;
+
+	case SCI_INDICGETUNDER:
+		return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0;
+
+	case SCI_SETINDICATORCURRENT:
+		pdoc->decorations.SetCurrentIndicator(wParam);
+		break;
+	case SCI_GETINDICATORCURRENT:
+		return pdoc->decorations.GetCurrentIndicator();
+	case SCI_SETINDICATORVALUE:
+		pdoc->decorations.SetCurrentValue(wParam);
+		break;
+	case SCI_GETINDICATORVALUE:
+		return pdoc->decorations.GetCurrentValue();
+
+	case SCI_INDICATORFILLRANGE:
+		pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam);
+		break;
+
+	case SCI_INDICATORCLEARRANGE:
+		pdoc->DecorationFillRange(wParam, 0, lParam);
+		break;
+
+	case SCI_INDICATORALLONFOR:
+		return pdoc->decorations.AllOnFor(wParam);
+
+	case SCI_INDICATORVALUEAT:
+		return pdoc->decorations.ValueAt(wParam, lParam);
+
+	case SCI_INDICATORSTART:
+		return pdoc->decorations.Start(wParam, lParam);
+
+	case SCI_INDICATOREND:
+		return pdoc->decorations.End(wParam, lParam);
+
 	case SCI_LINEDOWN:
 	case SCI_LINEDOWNEXTEND:
 	case SCI_PARADOWN:
@@ -7022,6 +7310,7 @@
 	case SCI_ZOOMOUT:
 	case SCI_DELWORDLEFT:
 	case SCI_DELWORDRIGHT:
+	case SCI_DELWORDRIGHTEND:
 	case SCI_DELLINELEFT:
 	case SCI_DELLINERIGHT:
 	case SCI_LINECOPY:
@@ -7169,7 +7458,7 @@
 				moveExtendsSelection = !moveExtendsSelection || (selType != selStream);
 				selType = selStream;
 			}
-			InvalidateSelection(currentPos, anchor);
+			InvalidateSelection(currentPos, anchor, true);
 		}
 	case SCI_GETSELECTIONMODE:
 		switch (selType) {
@@ -7266,22 +7555,34 @@
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_GETHOTSPOTACTIVEFORE:
+		return vs.hotspotForeground.desired.AsLong();
+
 	case SCI_SETHOTSPOTACTIVEBACK:
 		vs.hotspotBackgroundSet = wParam != 0;
 		vs.hotspotBackground.desired = ColourDesired(lParam);
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_GETHOTSPOTACTIVEBACK:
+		return vs.hotspotBackground.desired.AsLong();
+
 	case SCI_SETHOTSPOTACTIVEUNDERLINE:
 		vs.hotspotUnderline = wParam != 0;
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_GETHOTSPOTACTIVEUNDERLINE:
+		return vs.hotspotUnderline ? 1 : 0;
+
 	case SCI_SETHOTSPOTSINGLELINE:
 		vs.hotspotSingleLine = wParam != 0;
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_GETHOTSPOTSINGLELINE:
+		return vs.hotspotSingleLine ? 1 : 0;
+
 	case SCI_SETPASTECONVERTENDINGS:
 		convertPastes = wParam != 0;
 		break;
@@ -7289,6 +7590,9 @@
 	case SCI_GETPASTECONVERTENDINGS:
 		return convertPastes ? 1 : 0;
 
+	case SCI_GETCHARACTERPOINTER:
+		return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
+
 	default:
 		return DefWndProc(iMessage, wParam, lParam);
 	}

Modified: trunk/plugins/editor/scintilla/Editor.h
==============================================================================
--- trunk/plugins/editor/scintilla/Editor.h	(original)
+++ trunk/plugins/editor/scintilla/Editor.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef EDITOR_H
 #define EDITOR_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class Caret {
@@ -42,92 +46,6 @@
 };
 
 /**
- */
-class LineLayout {
-private:
-	friend class LineLayoutCache;
-	int *lineStarts;
-	int lenLineStarts;
-	/// Drawing is only performed for @a maxLineLength characters on each line.
-	int lineNumber;
-	bool inCache;
-public:
-	enum { wrapWidthInfinite = 0x7ffffff };
-	int maxLineLength;
-	int numCharsInLine;
-	enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
-	int xHighlightGuide;
-	bool highlightColumn;
-	int selStart;
-	int selEnd;
-	bool containsCaret;
-	int edgeColumn;
-	char *chars;
-	unsigned char *styles;
-	int styleBitsSet;
-	char *indicators;
-	int *positions;
-	char bracePreviousStyles[2];
-
-	// Hotspot support
-	int hsStart;
-	int hsEnd;
-
-	// Wrapped line support
-	int widthLine;
-	int lines;
-
-	LineLayout(int maxLineLength_);
-	virtual ~LineLayout();
-	void Resize(int maxLineLength_);
-	void Free();
-	void Invalidate(validLevel validity_);
-	int LineStart(int line) {
-		if (line <= 0) {
-			return 0;
-		} else if ((line >= lines) || !lineStarts) {
-			return numCharsInLine;
-		} else {
-			return lineStarts[line];
-		}
-	}
-	void SetLineStart(int line, int start);
-	void SetBracesHighlight(Range rangeLine, Position braces[],
-		char bracesMatchStyle, int xHighlight);
-	void RestoreBracesHighlight(Range rangeLine, Position braces[]);
-};
-
-/**
- */
-class LineLayoutCache {
-	int level;
-	int length;
-	int size;
-	LineLayout **cache;
-	bool allInvalidated;
-	int styleClock;
-	int useCount;
-	void Allocate(int length_);
-	void AllocateForLevel(int linesOnScreen, int linesInDoc);
-public:
-	LineLayoutCache();
-	virtual ~LineLayoutCache();
-	void Deallocate();
-	enum {
-		llcNone=SC_CACHE_NONE,
-		llcCaret=SC_CACHE_CARET,
-		llcPage=SC_CACHE_PAGE,
-		llcDocument=SC_CACHE_DOCUMENT
-	};
-	void Invalidate(LineLayout::validLevel validity_);
-	void SetLevel(int level_);
-	int GetLevel() { return level; }
-	LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
-		int linesOnScreen, int linesInDoc);
-	void Dispose(LineLayout *ll);
-};
-
-/**
  * Hold a piece of text selected for copying or dragging.
  * The text is expected to hold a terminating '\0' and this is counted in len.
  */
@@ -136,16 +54,17 @@
 	char *s;
 	int len;
 	bool rectangular;
+	bool lineCopy;
 	int codePage;
 	int characterSet;
-	SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {}
+	SelectionText() : s(0), len(0), rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
 	~SelectionText() {
 		Free();
 	}
 	void Free() {
-		Set(0, 0, 0, 0, false);
+		Set(0, 0, 0, 0, false, false);
 	}
-	void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
+	void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
 		delete []s;
 		s = s_;
 		if (s)
@@ -155,8 +74,9 @@
 		codePage = codePage_;
 		characterSet = characterSet_;
 		rectangular = rectangular_;
+		lineCopy = lineCopy_;
 	}
-	void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
+	void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
 		delete []s;
 		s = new char[len_];
 		if (s) {
@@ -170,9 +90,10 @@
 		codePage = codePage_;
 		characterSet = characterSet_;
 		rectangular = rectangular_;
+		lineCopy = lineCopy_;
 	}
 	void Copy(const SelectionText &other) {
-		Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular);
+		Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
 	}
 };
 
@@ -218,6 +139,8 @@
 	int xCaretMargin;	///< Ensure this many pixels visible on both sides of caret
 	bool horizontalScrollBarVisible;
 	int scrollWidth;
+	bool trackLineWidth;
+	int lineWidthMaxSeen;
 	bool verticalScrollBarVisible;
 	bool endAtLastLine;
 	bool caretSticky;
@@ -229,6 +152,7 @@
 	Surface *pixmapIndentGuideHighlight;
 
 	LineLayoutCache llc;
+	PositionCache posCache;
 
 	KeyMap kmap;
 
@@ -246,7 +170,7 @@
 	bool dwelling;
 	enum { selChar, selWord, selLine } selectionType;
 	Point ptMouseLast;
-	bool inDragDrop;
+	enum { ddNone, ddInitial, ddDragging } inDragDrop;
 	bool dropWentOutside;
 	int posDrag;
 	int posDrop;
@@ -355,7 +279,7 @@
 	int SelectionStart();
 	int SelectionEnd();
 	void SetRectangularRange();
-	void InvalidateSelection(int currentPos_, int anchor_);
+	void InvalidateSelection(int currentPos_, int anchor_, bool invalidateWholeSelection);
 	void SetSelection(int currentPos_, int anchor_);
 	void SetSelection(int currentPos_);
 	void SetEmptySelection(int currentPos_);
@@ -378,6 +302,7 @@
 	virtual void UpdateSystemCaret();
 
 	void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
+	bool WrapOneLine(Surface *surface, int lineToWrap);
 	bool WrapLines(bool fullWrap, int priorityWrapLineStart);
 	void LinesJoin();
 	void LinesSplit(int pixelWidth);
@@ -395,8 +320,11 @@
 		int line, int lineEnd, int xStart, int subLine, int subLineStart,
 		bool overrideBackground, ColourAllocated background,
 		bool drawWrapMark, ColourAllocated wrapColour);
+	void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
+		PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
 	void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
 		PRectangle rcLine, LineLayout *ll, int subLine=0);
+	void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret);
 	void RefreshPixMaps(Surface *surfaceWindow);
 	void Paint(Surface *surfaceWindow, PRectangle rcArea);
 	long FormatRange(bool draw, RangeToFormat *pfr);
@@ -413,10 +341,11 @@
 	virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
 	void ClearSelection();
 	void ClearAll();
-    	void ClearDocumentStyle();
+	void ClearDocumentStyle();
 	void Cut();
 	void PasteRectangular(int pos, const char *ptr, int len);
 	virtual void Copy() = 0;
+	virtual void CopyAllowLine();
 	virtual bool CanPaste();
 	virtual void Paste() = 0;
 	void Clear();
@@ -436,11 +365,12 @@
 	void NotifyMove(int position);
 	void NotifySavePoint(bool isSavePoint);
 	void NotifyModifyAttempt();
-	virtual void NotifyDoubleClick(Point pt, bool shift);
+	virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
 	void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
 	void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
 	void NotifyUpdateUI();
 	void NotifyPainted();
+	void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
 	bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
 	void NotifyNeedShown(int pos, int len);
 	void NotifyDwelling(Point pt, bool state);
@@ -480,12 +410,13 @@
 
 	virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
 	char *CopyRange(int start, int end);
-	void CopySelectionFromRange(SelectionText *ss, int start, int end);
-	void CopySelectionRange(SelectionText *ss);
+	void CopySelectionFromRange(SelectionText *ss, bool allowLineCopy, int start, int end);
+	void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
 	void CopyRangeToClipboard(int start, int end);
 	void CopyText(int length, const char *text);
 	void SetDragPosition(int newPos);
 	virtual void DisplayCursor(Window::Cursor c);
+	virtual bool DragThreshold(Point ptStart, Point ptNow);
 	virtual void StartDrag();
 	void DropAt(int position, const char *value, bool moving, bool rectangular);
 	/** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
@@ -527,8 +458,13 @@
 	int CodePage() const;
 	virtual bool ValidCodePage(int /* codePage */) const { return true; }
 	int WrapCount(int line);
+	void AddStyledText(char *buffer, int appendLength);
 
 	virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
+	void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+	sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+
+	static const char *StringFromEOLMode(int eolMode);
 
 public:
 	// Public so the COM thunks can access it.
@@ -579,4 +515,8 @@
 	}
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/ExternalLexer.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/ExternalLexer.cxx	(original)
+++ trunk/plugins/editor/scintilla/ExternalLexer.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "KeyWords.h"
 #include "ExternalLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 LexerManager *LexerManager::theInstance = NULL;
 
 //------------------------------------------
@@ -168,13 +172,13 @@
 void LexerLibrary::Release() {
 	//TODO maintain a list of lexers created, and delete them!
 	LexerMinder *lm;
-	LexerMinder *next;
+	LexerMinder *lmNext;
 	lm = first;
 	while (NULL != lm) {
-		next = lm->next;
+		lmNext = lm->next;
 		delete lm->self;
 		delete lm;
-		lm = next;
+		lm = lmNext;
 	}
 
 	first = NULL;

Modified: trunk/plugins/editor/scintilla/ExternalLexer.h
==============================================================================
--- trunk/plugins/editor/scintilla/ExternalLexer.h	(original)
+++ trunk/plugins/editor/scintilla/ExternalLexer.h	Sat Nov 15 17:50:33 2008
@@ -10,8 +10,12 @@
 
 #if PLAT_WIN
 #define EXT_LEXER_DECL __stdcall
-#elif PLAT_GTK
-#define EXT_LEXER_DECL 
+#else
+#define EXT_LEXER_DECL
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
 #endif
 
 // External Lexer function definitions...
@@ -92,4 +96,8 @@
 	~LMMinder();
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/Indicator.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/Indicator.cxx	(original)
+++ trunk/plugins/editor/scintilla/Indicator.cxx	Sat Nov 15 17:50:33 2008
@@ -10,6 +10,10 @@
 #include "Scintilla.h"
 #include "Indicator.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
 	surface->PenColour(fore.allocated);
 	int ymid = (rc.bottom + rc.top) / 2;

Modified: trunk/plugins/editor/scintilla/Indicator.h
==============================================================================
--- trunk/plugins/editor/scintilla/Indicator.h	(original)
+++ trunk/plugins/editor/scintilla/Indicator.h	Sat Nov 15 17:50:33 2008
@@ -8,15 +8,24 @@
 #ifndef INDICATOR_H
 #define INDICATOR_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class Indicator {
 public:
 	int style;
+	bool under;
 	ColourPair fore;
-	Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
+	Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)) {
 	}
 	void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/KeyMap.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/KeyMap.cxx	(original)
+++ trunk/plugins/editor/scintilla/KeyMap.cxx	Sat Nov 15 17:50:33 2008
@@ -11,6 +11,10 @@
 
 #include "KeyMap.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {
 	for (int i = 0; MapDefault[i].key; i++) {
 		AssignCmdKey(MapDefault[i].key,

Modified: trunk/plugins/editor/scintilla/KeyMap.h
==============================================================================
--- trunk/plugins/editor/scintilla/KeyMap.h	(original)
+++ trunk/plugins/editor/scintilla/KeyMap.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef KEYTOCOMMAND_H
 #define KEYTOCOMMAND_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 #define SCI_NORM 0
 #define SCI_SHIFT SCMOD_SHIFT
 #define SCI_CTRL SCMOD_CTRL
@@ -40,4 +44,8 @@
 	unsigned int Find(int key, int modifiers);	// 0 returned on failure
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/KeyWords.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/KeyWords.cxx	(original)
+++ trunk/plugins/editor/scintilla/KeyWords.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 const LexerModule *LexerModule::base = 0;
 int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
 
@@ -137,11 +141,13 @@
 
 //++Autogenerated -- run src/LexGen.py to regenerate
 //**\(\tLINK_LEXER(\*);\n\)
+	LINK_LEXER(lmAbaqus);
 	LINK_LEXER(lmAda);
 	LINK_LEXER(lmAns1);
 	LINK_LEXER(lmAPDL);
 	LINK_LEXER(lmAsm);
 	LINK_LEXER(lmASP);
+	LINK_LEXER(lmASY);
 	LINK_LEXER(lmAU3);
 	LINK_LEXER(lmAVE);
 	LINK_LEXER(lmBaan);
@@ -152,11 +158,13 @@
 	LINK_LEXER(lmCaml);
 	LINK_LEXER(lmClw);
 	LINK_LEXER(lmClwNoCase);
+	LINK_LEXER(lmCmake);
 	LINK_LEXER(lmConf);
 	LINK_LEXER(lmCPP);
 	LINK_LEXER(lmCPPNoCase);
 	LINK_LEXER(lmCsound);
 	LINK_LEXER(lmCss);
+	LINK_LEXER(lmD);
 	LINK_LEXER(lmDiff);
 	LINK_LEXER(lmEiffel);
 	LINK_LEXER(lmEiffelkw);
@@ -168,6 +176,7 @@
 	LINK_LEXER(lmForth);
 	LINK_LEXER(lmFortran);
 	LINK_LEXER(lmFreeBasic);
+	LINK_LEXER(lmGAP);
 	LINK_LEXER(lmGui4Cli);
 	LINK_LEXER(lmHaskell);
 	LINK_LEXER(lmHTML);
@@ -178,11 +187,13 @@
 	LINK_LEXER(lmLot);
 	LINK_LEXER(lmLout);
 	LINK_LEXER(lmLua);
+	LINK_LEXER(lmMagikSF);
 	LINK_LEXER(lmMake);
 	LINK_LEXER(lmMatlab);
 	LINK_LEXER(lmMETAPOST);
 	LINK_LEXER(lmMMIXAL);
 	LINK_LEXER(lmMSSQL);
+	LINK_LEXER(lmMySQL);
 	LINK_LEXER(lmNncrontab);
 	LINK_LEXER(lmNsis);
 	LINK_LEXER(lmNull);
@@ -193,11 +204,16 @@
 	LINK_LEXER(lmPerl);
 	LINK_LEXER(lmPHP);
 	LINK_LEXER(lmPHPSCRIPT);
+	LINK_LEXER(lmPLM);
+	LINK_LEXER(lmPo);
 	LINK_LEXER(lmPOV);
+	LINK_LEXER(lmPowerShell);
+	LINK_LEXER(lmProgress);
 	LINK_LEXER(lmProps);
 	LINK_LEXER(lmPS);
 	LINK_LEXER(lmPureBasic);
 	LINK_LEXER(lmPython);
+	LINK_LEXER(lmR);
 	LINK_LEXER(lmREBOL);
 	LINK_LEXER(lmRuby);
 	LINK_LEXER(lmScriptol);

Modified: trunk/plugins/editor/scintilla/LexAPDL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAPDL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAPDL.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80 && (isalnum(ch) || ch == '_'));
@@ -123,6 +126,123 @@
 	sc.Complete();
 }
 
+//------------------------------------------------------------------------------
+// 06-27-07 Sergio Lucato
+// - Included code folding for Ansys APDL lexer
+// - Copyied from LexBasic.cxx and modified for APDL
+//------------------------------------------------------------------------------
+
+/* Bits:
+ * 1  - whitespace
+ * 2  - operator
+ * 4  - identifier
+ * 8  - decimal digit
+ * 16 - hex digit
+ * 32 - bin digit
+ */
+static int character_classification[128] =
+{
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    1,  2,  0,  2,  2,  2,  2,  2,  2,  2,  6,  2,  2,  2,  10, 6,
+    60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2,  2,  2,  2,  2,  2,
+    2,  20, 20, 20, 20, 20, 20, 4,  4,  4,  4,  4,  4,  4,  4,  4,
+    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  4,
+    2,  20, 20, 20, 20, 20, 20, 4,  4,  4,  4,  4,  4,  4,  4,  4,
+    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  0
+};
+
+static bool IsSpace(int c) {
+	return c < 128 && (character_classification[c] & 1);
+}
+
+static bool IsIdentifier(int c) {
+	return c < 128 && (character_classification[c] & 4);
+}
+
+static int LowerCase(int c)
+{
+	if (c >= 'A' && c <= 'Z')
+		return 'a' + c - 'A';
+	return c;
+}
+
+static int CheckAPDLFoldPoint(char const *token, int &level) {
+	if (!strcmp(token, "*if") ||
+		!strcmp(token, "*do") ||
+		!strcmp(token, "*dowhile") ) {
+		level |= SC_FOLDLEVELHEADERFLAG;
+		return 1;
+	}
+	if (!strcmp(token, "*endif") ||
+		!strcmp(token, "*enddo") ) {
+		return -1;
+	}
+	return 0;
+}
+
+static void FoldAPDLDoc(unsigned int startPos, int length, int,
+	WordList *[], Accessor &styler) {
+
+	int line = styler.GetLine(startPos);
+	int level = styler.LevelAt(line);
+	int go = 0, done = 0;
+	int endPos = startPos + length;
+	char word[256];
+	int wordlen = 0;
+	int i;
+    bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	// Scan for tokens at the start of the line (they may include
+	// whitespace, for tokens like "End Function"
+	for (i = startPos; i < endPos; i++) {
+		int c = styler.SafeGetCharAt(i);
+		if (!done && !go) {
+			if (wordlen) { // are we scanning a token already?
+				word[wordlen] = static_cast<char>(LowerCase(c));
+				if (!IsIdentifier(c)) { // done with token
+					word[wordlen] = '\0';
+					go = CheckAPDLFoldPoint(word, level);
+					if (!go) {
+						// Treat any whitespace as single blank, for
+						// things like "End   Function".
+						if (IsSpace(c) && IsIdentifier(word[wordlen - 1])) {
+							word[wordlen] = ' ';
+							if (wordlen < 255)
+								wordlen++;
+						}
+						else // done with this line
+							done = 1;
+					}
+				} else if (wordlen < 255) {
+					wordlen++;
+				}
+			} else { // start scanning at first non-whitespace character
+				if (!IsSpace(c)) {
+					if (IsIdentifier(c)) {
+						word[0] = static_cast<char>(LowerCase(c));
+						wordlen = 1;
+					} else // done with this line
+						done = 1;
+				}
+			}
+		}
+		if (c == '\n') { // line end
+			if (!done && wordlen == 0 && foldCompact) // line was only space
+				level |= SC_FOLDLEVELWHITEFLAG;
+			if (level != styler.LevelAt(line))
+				styler.SetLevel(line, level);
+			level += go;
+			line++;
+			// reset state
+			wordlen = 0;
+			level &= ~SC_FOLDLEVELHEADERFLAG;
+			level &= ~SC_FOLDLEVELWHITEFLAG;
+			go = 0;
+			done = 0;
+		}
+	}
+}
+
 static const char * const apdlWordListDesc[] = {
     "processors",
     "commands",
@@ -133,4 +253,4 @@
     0
 };
 
-LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", 0, apdlWordListDesc);
+LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", FoldAPDLDoc, apdlWordListDesc);

Added: trunk/plugins/editor/scintilla/LexASY.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexASY.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,270 @@
+// Scintilla source code edit control
+//Author: instanton (email: soft_share<at>126<dot>com)
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "CharacterSet.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static void ColouriseAsyDoc(unsigned int startPos, int length, int initStyle, 
+		WordList *keywordlists[], Accessor &styler) {
+
+	WordList &keywords = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
+
+	int visibleChars = 0;
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		if (sc.atLineStart) {
+			if (sc.state == SCE_ASY_STRING) {
+				sc.SetState(SCE_ASY_STRING);
+			}
+			visibleChars = 0;
+		}
+
+		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_ASY_OPERATOR:
+				sc.SetState(SCE_ASY_DEFAULT);
+				break;
+			case SCE_ASY_NUMBER:
+				if (!setWord.Contains(sc.ch)) {
+					sc.SetState(SCE_ASY_DEFAULT);
+				}
+				break;
+			case SCE_ASY_IDENTIFIER:
+				if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
+					char s[1000];
+					sc.GetCurrentLowered(s, sizeof(s));
+					if (keywords.InList(s)) {
+						sc.ChangeState(SCE_ASY_WORD);
+					} else if (keywords2.InList(s)) {
+						sc.ChangeState(SCE_ASY_WORD2);
+					}
+					sc.SetState(SCE_ASY_DEFAULT);
+				}
+				break;
+			case SCE_ASY_COMMENT:
+				if (sc.Match('*', '/')) {
+					sc.Forward();
+					sc.ForwardSetState(SCE_ASY_DEFAULT);
+				}
+				break;
+			case SCE_ASY_COMMENTLINE:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_ASY_DEFAULT);
+				}
+				break;
+			case SCE_ASY_STRING:
+				if (sc.atLineEnd) {
+					sc.ChangeState(SCE_ASY_STRINGEOL);
+				} else if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\"') {
+					sc.ForwardSetState(SCE_ASY_DEFAULT);
+				}
+				break;
+			case SCE_ASY_CHARACTER:
+				if (sc.atLineEnd) {
+					sc.ChangeState(SCE_ASY_STRINGEOL);
+				} else 	if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\'') {
+					sc.ForwardSetState(SCE_ASY_DEFAULT);
+				}
+				break;
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_ASY_DEFAULT) {
+			if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
+				sc.SetState(SCE_ASY_IDENTIFIER);
+			} else if (sc.Match('/', '*')) {
+				sc.SetState(SCE_ASY_COMMENT);
+				sc.Forward();	// 
+			} else if (sc.Match('/', '/')) {
+				sc.SetState(SCE_ASY_COMMENTLINE);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_ASY_STRING);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_ASY_CHARACTER);
+			} else if (sc.ch == '#' && visibleChars == 0) {
+				do {
+					sc.Forward();
+				} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
+				if (sc.atLineEnd) {
+					sc.SetState(SCE_ASY_DEFAULT);
+				}
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_ASY_OPERATOR);
+			}
+		}
+
+	}
+	sc.Complete();
+}
+
+static bool IsAsyCommentStyle(int style) {
+	return style == SCE_ASY_COMMENT;
+}
+
+
+static inline bool isASYidentifier(int ch) {
+	return
+      ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) ;
+}
+
+static int ParseASYWord(unsigned int pos, Accessor &styler, char *word)
+{
+  int length=0;
+  char ch=styler.SafeGetCharAt(pos);
+  *word=0;
+
+  while(isASYidentifier(ch) && length<100){
+          word[length]=ch;
+          length++;
+          ch=styler.SafeGetCharAt(pos+length);
+  }
+  word[length]=0;   
+  return length;
+}
+
+static bool IsASYDrawingLine(int line, Accessor &styler) {
+	int pos = styler.LineStart(line);
+	int eol_pos = styler.LineStart(line + 1) - 1;
+	
+	int startpos = pos;
+	char buffer[100]="";
+
+	while (startpos<eol_pos){
+		char ch = styler[startpos];
+		ParseASYWord(startpos,styler,buffer);
+		bool drawcommands = strncmp(buffer,"draw",4)==0||
+			strncmp(buffer,"pair",4)==0||strncmp(buffer,"label",5)==0;
+		if (!drawcommands && ch!=' ') return false;
+		else if (drawcommands) return true;
+		startpos++;
+	}		
+	return false;
+}
+
+static void FoldAsyDoc(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;
+	bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0)
+		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+	int levelMinCurrent = levelCurrent;
+	int levelNext = levelCurrent;
+	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 && IsAsyCommentStyle(style)) {
+			if (!IsAsyCommentStyle(stylePrev) && (stylePrev != SCE_ASY_COMMENTLINEDOC)) {
+				levelNext++;
+			} else if (!IsAsyCommentStyle(styleNext) && (styleNext != SCE_ASY_COMMENTLINEDOC) && !atEOL) {
+				levelNext--;
+			}
+		}
+		if (style == SCE_ASY_OPERATOR) {
+			if (ch == '{') {
+				if (levelMinCurrent > levelNext) {
+					levelMinCurrent = levelNext;
+				}
+				levelNext++;
+			} else if (ch == '}') {
+				levelNext--;
+			}
+		}
+
+		if (atEOL && IsASYDrawingLine(lineCurrent, styler)){
+			if (lineCurrent==0 && IsASYDrawingLine(lineCurrent + 1, styler))
+				levelNext++;
+			else if (lineCurrent!=0 && !IsASYDrawingLine(lineCurrent - 1, styler)
+				&& IsASYDrawingLine(lineCurrent + 1, styler)
+				)
+				levelNext++;
+			else if (lineCurrent!=0 && IsASYDrawingLine(lineCurrent - 1, styler) &&
+				!IsASYDrawingLine(lineCurrent+1, styler))
+				levelNext--;
+		}	
+
+		if (atEOL) {
+			int levelUse = levelCurrent;
+			if (foldAtElse) {
+				levelUse = levelMinCurrent;
+			}
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			levelMinCurrent = levelCurrent;
+			visibleChars = 0;
+		}
+		if (!IsASpace(ch))
+			visibleChars++;
+	}
+}
+
+static const char * const asyWordLists[] = {
+            "Primary keywords and identifiers",
+            "Secondary keywords and identifiers",
+            0,
+        };
+
+LexerModule lmASY(SCLEX_ASYMPTOTE, ColouriseAsyDoc, "asy", FoldAsyDoc, asyWordLists);

Modified: trunk/plugins/editor/scintilla/LexAU3.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAU3.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAU3.cxx	Sat Nov 15 17:50:33 2008
@@ -42,6 +42,9 @@
 // Sep 27, 2005   - Fixed the SentKey lexing logic in case of multiple sentkeys.
 // Mar 12, 2006   - Fixed issue with <> coloring as String in stead of Operator in rare occasions.
 // Apr  8, 2006   - Added support for AutoIt3 Standard UDF library (SCE_AU3_UDF)
+// Mar  9, 2007   - Fixed bug with + following a String getting the wrong Color.
+// Jun 20, 2007   - Fixed Commentblock issue when LF's are used as EOL.
+// Jul 26, 2007   - Fixed #endregion undetected bug.
 //
 // Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
@@ -62,6 +65,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsTypeCharacter(const int ch)
 {
     return ch == '$';
@@ -246,7 +253,12 @@
 				//Reset at line end
 				if (sc.atLineEnd) {
 					ci=0;
-					sc.SetState(SCE_AU3_COMMENTBLOCK);
+					if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0))
+						if (sc.atLineEnd) 
+							sc.SetState(SCE_AU3_DEFAULT);
+						else	
+							sc.SetState(SCE_AU3_COMMENTBLOCK);
+					break;
 				}
 				//skip rest of line when a ; is encountered
 				if (sc.chPrev == ';') {
@@ -265,12 +277,12 @@
 					break;
 				}
 				if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) {
-					if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) 
-						sc.SetState(SCE_AU3_COMMENT);  // set to comment line for the rest of the line
+					if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0))
+							sc.SetState(SCE_AU3_COMMENT);  // set to comment line for the rest of the line
 					else
 						ci=2;  // line doesn't begin with #CE so skip the rest of the line
 				}
-                break;
+				break;
 			}
             case SCE_AU3_COMMENT:
             {
@@ -304,6 +316,7 @@
 						{
 							sc.ChangeState(SCE_AU3_COMMENTBLOCK);
 							sc.SetState(SCE_AU3_COMMENTBLOCK);
+							break;
 						}
 						else if (keywords.InList(s)) {
 							sc.ChangeState(SCE_AU3_KEYWORD);
@@ -424,6 +437,7 @@
 				{
 					sc.ForwardSetState(SCE_AU3_DEFAULT);
 					si=0;
+					break;
 				}
                 if (sc.atLineEnd)
 				{
@@ -433,6 +447,7 @@
 					if (!IsContinuationLine(lineCurrent,styler)) 
 					{
 						sc.SetState(SCE_AU3_DEFAULT);
+						break;
 					}
 				}
 				// find Sendkeys in a STRING
@@ -686,7 +701,7 @@
 	// vars for getting first word to check for keywords
 	bool FirstWordStart = false;
 	bool FirstWordEnd = false;
-	char szKeyword[10]="";
+	char szKeyword[11]="";
 	int	 szKeywordlen = 0;
 	char szThen[5]="";
 	int	 szThenlen = 0;

Modified: trunk/plugins/editor/scintilla/LexAVE.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAVE.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAVE.cxx	Sat Nov 15 17:50:33 2008
@@ -22,6 +22,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 
 static inline bool IsAWordChar(const int ch) {

Added: trunk/plugins/editor/scintilla/LexAbaqus.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexAbaqus.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,617 @@
+// Scintilla source code edit control
+/** @file LexABAQUS.cxx
+ ** Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz.
+ ** By Sergio Lucato.
+ ** Sort of completely rewritten by Gertjan Kloosterman
+ **/
+// The License.txt file describes the conditions under which this software may be distributed.
+
+// Code folding copyied and modified from LexBasic.cxx
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+	return (ch < 0x80 && (isalnum(ch) || (ch == '_')));
+}
+
+static inline bool IsAKeywordChar(const int ch) {
+	return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' ')));
+}
+
+static inline bool IsASetChar(const int ch) {
+	return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == '.') || (ch == '-')));
+}
+
+static inline bool IsAnOperator(char ch) {
+	// '.' left out as it is used to make up numbers
+	if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
+		ch == '(' || ch == ')' || ch == '=' || ch == '^' ||
+		ch == '[' || ch == ']' || ch == '<' || ch == '&' ||
+		ch == '>' || ch == ',' || ch == '|' || ch == '~' ||
+		ch == '$' || ch == ':' || ch == '%')
+		return true;
+	return false;
+}
+
+static void ColouriseABAQUSDoc(unsigned int startPos, int length, int initStyle, WordList*[] /* *keywordlists[] */,
+                            Accessor &styler) {
+	enum localState { KW_LINE_KW, KW_LINE_COMMA, KW_LINE_PAR, KW_LINE_EQ, KW_LINE_VAL, \
+					  DAT_LINE_VAL, DAT_LINE_COMMA,\
+					  COMMENT_LINE,\
+					  ST_ERROR, LINE_END } state ;
+
+	// Do not leak onto next line
+	state = LINE_END ;
+	initStyle = SCE_ABAQUS_DEFAULT;
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	// Things are actually quite simple
+	// we have commentlines
+	// keywordlines and datalines
+	// On a data line there will only be colouring of numbers
+	// a keyword line is constructed as
+	// *word,[ paramname[=paramvalue]]*
+	// if the line ends with a , the keyword line continues onto the new line
+
+	for (; sc.More(); sc.Forward()) {
+		switch ( state ) {
+        case KW_LINE_KW :
+            if ( sc.atLineEnd ) {
+                // finished the line in keyword state, switch to LINE_END
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            } else if ( IsAKeywordChar(sc.ch) ) {
+                // nothing changes
+                state = KW_LINE_KW ;
+            } else if ( sc.ch == ',' ) {
+                // Well well we say a comma, arguments *MUST* follow
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = KW_LINE_COMMA ;
+            } else {
+                // Flag an error
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            // Done with processing
+            break ;
+        case KW_LINE_COMMA :
+            // acomma on a keywordline was seen
+            if ( IsAKeywordChar(sc.ch)) {
+                sc.SetState(SCE_ABAQUS_ARGUMENT) ;
+                state = KW_LINE_PAR ;
+            } else if ( sc.atLineEnd || (sc.ch == ',') ) {
+                // we remain in keyword mode
+                state = KW_LINE_COMMA ;
+            } else if ( sc.ch == ' ' ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = KW_LINE_COMMA ;
+            } else {
+                // Anything else constitutes an error
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case KW_LINE_PAR :
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            } else if ( IsAKeywordChar(sc.ch) || (sc.ch == '-') ) {
+                // remain in this state
+                state = KW_LINE_PAR ;
+            } else if ( sc.ch == ',' ) {
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = KW_LINE_COMMA ;
+            } else if ( sc.ch == '=' ) {
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = KW_LINE_EQ ;
+            } else {
+                // Anything else constitutes an error
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case KW_LINE_EQ :
+            if ( sc.ch == ' ' ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                // remain in this state
+                state = KW_LINE_EQ ;
+            } else if ( IsADigit(sc.ch) || (sc.ch == '-') || (sc.ch == '.' && IsADigit(sc.chNext)) ) {
+                sc.SetState(SCE_ABAQUS_NUMBER) ;
+                state = KW_LINE_VAL ;
+            } else if ( IsAKeywordChar(sc.ch) ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = KW_LINE_VAL ;
+            } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) {
+                sc.SetState(SCE_ABAQUS_STRING) ;
+                state = KW_LINE_VAL ;
+            } else {
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case KW_LINE_VAL :
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            } else if ( IsASetChar(sc.ch) && (sc.state == SCE_ABAQUS_DEFAULT) ) {
+                // nothing changes
+                state = KW_LINE_VAL ;
+            } else if (( (IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') ||
+                    ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) &&
+                    (sc.state == SCE_ABAQUS_NUMBER)) {
+                // remain in number mode
+                state = KW_LINE_VAL ;
+            } else if (sc.state == SCE_ABAQUS_STRING) {
+                // accept everything until a closing quote
+                if ( sc.ch == '\'' || sc.ch == '\"' ) {
+                    sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                    state = KW_LINE_VAL ;
+                }
+            } else if ( sc.ch == ',' ) {
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = KW_LINE_COMMA ;
+            } else {
+                // anything else is an error
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case DAT_LINE_VAL :
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            } else if ( IsASetChar(sc.ch) && (sc.state == SCE_ABAQUS_DEFAULT) ) {
+                // nothing changes
+                state = DAT_LINE_VAL ;
+            } else if (( (IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') ||
+                    ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) &&
+                    (sc.state == SCE_ABAQUS_NUMBER)) {
+                // remain in number mode
+                state = DAT_LINE_VAL ;
+            } else if (sc.state == SCE_ABAQUS_STRING) {
+                // accept everything until a closing quote
+                if ( sc.ch == '\'' || sc.ch == '\"' ) {
+                    sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                    state = DAT_LINE_VAL ;
+                }
+            } else if ( sc.ch == ',' ) {
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = DAT_LINE_COMMA ;
+            } else {
+                // anything else is an error
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case DAT_LINE_COMMA :
+            // a comma on a data line was seen
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            } else if ( sc.ch == ' ' ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = DAT_LINE_COMMA ;
+            } else if (sc.ch == ',')  {
+                sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                state = DAT_LINE_COMMA ;
+            } else if ( IsADigit(sc.ch) || (sc.ch == '-')|| (sc.ch == '.' && IsADigit(sc.chNext)) ) {
+                sc.SetState(SCE_ABAQUS_NUMBER) ;
+                state = DAT_LINE_VAL ;
+            } else if ( IsAKeywordChar(sc.ch) ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = DAT_LINE_VAL ;
+            } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) {
+                sc.SetState(SCE_ABAQUS_STRING) ;
+                state = DAT_LINE_VAL ;
+            } else {
+                sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                state = ST_ERROR ;
+            }
+            break ;
+        case COMMENT_LINE :
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            }
+            break ;
+        case ST_ERROR :
+            if ( sc.atLineEnd ) {
+                sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                state = LINE_END ;
+            }
+            break ;
+        case LINE_END :
+            if ( sc.atLineEnd || sc.ch == ' ' ) {
+                // nothing changes
+                state = LINE_END ;
+            } else if ( sc.ch == '*' ) {
+                if ( sc.chNext == '*' ) {
+                    state = COMMENT_LINE ;
+                    sc.SetState(SCE_ABAQUS_COMMENT) ;
+                } else {
+                    state = KW_LINE_KW ;
+                    sc.SetState(SCE_ABAQUS_STARCOMMAND) ;
+                }
+            } else {
+                // it must be a data line, things are as if we are in DAT_LINE_COMMA
+                if ( sc.ch == ',' ) {
+                    sc.SetState(SCE_ABAQUS_OPERATOR) ;
+                    state = DAT_LINE_COMMA ;
+                } else if ( IsADigit(sc.ch) || (sc.ch == '-')|| (sc.ch == '.' && IsADigit(sc.chNext)) ) {
+                    sc.SetState(SCE_ABAQUS_NUMBER) ;
+                    state = DAT_LINE_VAL ;
+                } else if ( IsAKeywordChar(sc.ch) ) {
+                    sc.SetState(SCE_ABAQUS_DEFAULT) ;
+                    state = DAT_LINE_VAL ;
+                } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) {
+                    sc.SetState(SCE_ABAQUS_STRING) ;
+                    state = DAT_LINE_VAL ;
+                } else {
+                    sc.SetState(SCE_ABAQUS_PROCESSOR) ;
+                    state = ST_ERROR ;
+                }
+            }
+            break ;
+		  }
+   }
+   sc.Complete();
+}
+
+//------------------------------------------------------------------------------
+// This copyied and modified from LexBasic.cxx
+//------------------------------------------------------------------------------
+
+/* Bits:
+ * 1  - whitespace
+ * 2  - operator
+ * 4  - identifier
+ * 8  - decimal digit
+ * 16 - hex digit
+ * 32 - bin digit
+ */
+static int character_classification[128] =
+{
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    1,  2,  0,  2,  2,  2,  2,  2,  2,  2,  6,  2,  2,  2,  10, 6,
+    60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2,  2,  2,  2,  2,  2,
+    2,  20, 20, 20, 20, 20, 20, 4,  4,  4,  4,  4,  4,  4,  4,  4,
+    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  4,
+    2,  20, 20, 20, 20, 20, 20, 4,  4,  4,  4,  4,  4,  4,  4,  4,
+    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  0
+};
+
+static bool IsSpace(int c) {
+	return c < 128 && (character_classification[c] & 1);
+}
+
+static bool IsIdentifier(int c) {
+	return c < 128 && (character_classification[c] & 4);
+}
+
+static int LowerCase(int c)
+{
+	if (c >= 'A' && c <= 'Z')
+		return 'a' + c - 'A';
+	return c;
+}
+
+static int LineEnd(int line, Accessor &styler)
+{
+    const int docLines = styler.GetLine(styler.Length() - 1);  // Available last line
+    int eol_pos ;
+    // if the line is the last line, the eol_pos is styler.Length()
+    // eol will contain a new line, or a virtual new line
+    if ( docLines == line )
+        eol_pos = styler.Length() ;
+    else
+        eol_pos = styler.LineStart(line + 1) - 1;
+    return eol_pos ;
+}
+
+static int LineStart(int line, Accessor &styler)
+{
+    return styler.LineStart(line) ;
+}
+
+// LineType
+//
+// bits determines the line type
+// 1  : data line
+// 2  : only whitespace
+// 3  : data line with only whitespace
+// 4  : keyword line
+// 5  : block open keyword line
+// 6  : block close keyword line
+// 7  : keyword line in error
+// 8  : comment line
+static int LineType(int line, Accessor &styler) {
+    int pos = LineStart(line, styler) ;
+    int eol_pos = LineEnd(line, styler) ;
+
+    int c ;
+    char ch = ' ';
+
+    int i = pos ;
+    while ( i < eol_pos ) {
+        c = styler.SafeGetCharAt(i);
+        ch = static_cast<char>(LowerCase(c));
+        // We can say something as soon as no whitespace
+        // was encountered
+        if ( !IsSpace(c) )
+            break ;
+        i++ ;
+    }
+
+    if ( i >= eol_pos ) {
+        // This is a whitespace line, currently
+        // classifies as data line
+        return 3 ;
+    }
+
+    if ( ch != '*' ) {
+        // This is a data line
+        return 1 ;
+    }
+
+    if ( i == eol_pos - 1 ) {
+        // Only a single *, error but make keyword line
+        return 4+3 ;
+    }
+
+    // This means we can have a second character
+    // if that is also a * this means a comment
+    // otherwise it is a keyword.
+    c = styler.SafeGetCharAt(i+1);
+    ch = static_cast<char>(LowerCase(c));
+    if ( ch == '*' ) {
+        return 8 ;
+    }
+
+    // At this point we know this is a keyword line
+    // the character at position i is a *
+    // it is not a comment line
+    char word[256] ;
+    int  wlen = 0;
+
+    word[wlen] = '*' ;
+	wlen++ ;
+
+    i++ ;
+    while ( (i < eol_pos) && (wlen < 255) ) {
+        c = styler.SafeGetCharAt(i);
+        ch = static_cast<char>(LowerCase(c));
+
+        if ( (!IsSpace(c)) && (!IsIdentifier(c)) )
+            break ;
+
+        if ( IsIdentifier(c) ) {
+            word[wlen] = ch ;
+			wlen++ ;
+		}
+
+        i++ ;
+    }
+
+    word[wlen] = 0 ;
+
+    // Make a comparison
+	if ( !strcmp(word, "*step") ||
+         !strcmp(word, "*part") ||
+         !strcmp(word, "*instance") ||
+         !strcmp(word, "*assembly")) {
+       return 4+1 ;
+    }
+
+	if ( !strcmp(word, "*endstep") ||
+         !strcmp(word, "*endpart") ||
+         !strcmp(word, "*endinstance") ||
+         !strcmp(word, "*endassembly")) {
+       return 4+2 ;
+    }
+
+    return 4 ;
+}
+
+static void SafeSetLevel(int line, int level, Accessor &styler)
+{
+    if ( line < 0 )
+        return ;
+
+    int mask = ((~SC_FOLDLEVELHEADERFLAG) | (~SC_FOLDLEVELWHITEFLAG));
+
+    if ( (level & mask) < 0 )
+        return ;
+
+    if ( styler.LevelAt(line) != level )
+        styler.SetLevel(line, level) ;
+}
+
+static void FoldABAQUSDoc(unsigned int startPos, int length, int,
+WordList *[], Accessor &styler) {
+    int startLine = styler.GetLine(startPos) ;
+    int endLine   = styler.GetLine(startPos+length-1) ;
+
+    // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+    // We want to deal with all the cases
+    // To know the correct indentlevel, we need to look back to the
+    // previous command line indentation level
+	// order of formatting keyline datalines commentlines
+    int beginData    = -1 ;
+    int beginComment = -1 ;
+    int prvKeyLine   = startLine ;
+    int prvKeyLineTp =  0 ;
+
+    // Scan until we find the previous keyword line
+    // this will give us the level reference that we need
+    while ( prvKeyLine > 0 ) {
+        prvKeyLine-- ;
+        prvKeyLineTp = LineType(prvKeyLine, styler) ;
+        if ( prvKeyLineTp & 4 )
+            break ;
+    }
+
+    // Determine the base line level of all lines following
+    // the previous keyword
+    // new keyword lines are placed on this level
+    //if ( prvKeyLineTp & 4 ) {
+    int level = styler.LevelAt(prvKeyLine) & ~SC_FOLDLEVELHEADERFLAG ;
+    //}
+
+    // uncomment line below if weird behaviour continues
+    prvKeyLine = -1 ;
+
+    // Now start scanning over the lines.
+    for ( int line = startLine; line <= endLine; line++ ) {
+        int lineType = LineType(line, styler) ;
+
+        // Check for comment line
+        if ( lineType == 8 ) {
+            if ( beginComment < 0 ) {
+                beginComment = line ;
+			}
+        }
+
+        // Check for data line
+        if ( (lineType == 1) || (lineType == 3) ) {
+            if ( beginData < 0 ) {
+                if ( beginComment >= 0 ) {
+                    beginData = beginComment ;
+                } else {
+                    beginData = line ;
+                }
+            }
+			beginComment = -1 ;
+		}
+
+        // Check for keywordline.
+        // As soon as a keyword line is encountered, we can set the
+        // levels of everything from the previous keyword line to this one
+        if ( lineType & 4 ) {
+            // this is a keyword, we can now place the previous keyword
+            // all its data lines and the remainder
+
+            // Write comments and data line
+            if ( beginComment < 0 ) {
+                beginComment = line ;
+			}
+
+            if ( beginData < 0 ) {
+                beginData = beginComment ;
+				if ( prvKeyLineTp != 5 )
+					SafeSetLevel(prvKeyLine, level, styler) ;
+				else
+					SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ;
+            } else {
+                SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ;
+            }
+
+            int datLevel = level + 1 ;
+			if ( !(prvKeyLineTp & 4) ) {
+				datLevel = level ;
+			}
+
+            for ( int ll = beginData; ll < beginComment; ll++ )
+                SafeSetLevel(ll, datLevel, styler) ;
+
+            // The keyword we just found is going to be written at another level
+            // if we have a type 5 and type 6
+            if ( prvKeyLineTp == 5 ) {
+                level += 1 ;
+			}
+
+            if ( prvKeyLineTp == 6 ) {
+                level -= 1 ;
+				if ( level < 0 ) {
+					level = 0 ;
+				}
+            }
+
+            for ( int lll = beginComment; lll < line; lll++ )
+                SafeSetLevel(lll, level, styler) ;
+
+            // wrap and reset
+            beginComment = -1 ;
+            beginData    = -1 ;
+            prvKeyLine   = line ;
+            prvKeyLineTp = lineType ;
+        }
+
+    }
+
+    if ( beginComment < 0 ) {
+        beginComment = endLine + 1 ;
+    } else {
+        // We need to find out whether this comment block is followed by
+        // a data line or a keyword line
+        const int docLines = styler.GetLine(styler.Length() - 1);
+
+        for ( int line = endLine + 1; line <= docLines; line++ ) {
+            int lineType = LineType(line, styler) ;
+
+            if ( lineType != 8 ) {
+				if ( !(lineType & 4) )  {
+					beginComment = endLine + 1 ;
+				}
+                break ;
+			}
+        }
+    }
+
+    if ( beginData < 0 ) {
+        beginData = beginComment ;
+		if ( prvKeyLineTp != 5 )
+			SafeSetLevel(prvKeyLine, level, styler) ;
+		else
+			SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ;
+    } else {
+        SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ;
+    }
+
+    int datLevel = level + 1 ;
+	if ( !(prvKeyLineTp & 4) ) {
+		datLevel = level ;
+	}
+
+    for ( int ll = beginData; ll < beginComment; ll++ )
+        SafeSetLevel(ll, datLevel, styler) ;
+
+	if ( prvKeyLineTp == 5 ) {
+		level += 1 ;
+	}
+
+	if ( prvKeyLineTp == 6 ) {
+		level -= 1 ;
+	}
+	for ( int m = beginComment; m <= endLine; m++ )
+        SafeSetLevel(m, level, styler) ;
+}
+
+static const char * const abaqusWordListDesc[] = {
+    "processors",
+    "commands",
+    "slashommands",
+    "starcommands",
+    "arguments",
+    "functions",
+    0
+};
+
+LexerModule lmAbaqus(SCLEX_ABAQUS, ColouriseABAQUSDoc, "abaqus", FoldABAQUSDoc, abaqusWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexAda.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAda.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAda.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "SciLexer.h"
 #include "SString.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
  * Interface
  */

Modified: trunk/plugins/editor/scintilla/LexAsm.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAsm.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAsm.cxx	Sat Nov 15 17:50:33 2008
@@ -23,6 +23,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '.' ||
@@ -34,8 +37,8 @@
 		ch == '%' || ch == '@' || ch == '$' || ch == '?');
 }
 
-static inline bool IsAsmOperator(char ch) {
-	if (isalnum(ch))
+static inline bool IsAsmOperator(const int ch) {
+	if ((ch < 0x80) && (isalnum(ch)))
 		return false;
 	// '.' left out as it is used to make up numbers
 	if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
@@ -86,7 +89,7 @@
 
 		// Determine if the current state should terminate.
 		if (sc.state == SCE_ASM_OPERATOR) {
-			if (!IsAsmOperator(static_cast<char>(sc.ch))) {
+			if (!IsAsmOperator(sc.ch)) {
 			    sc.SetState(SCE_ASM_DEFAULT);
 			}
 		}else if (sc.state == SCE_ASM_NUMBER) {
@@ -146,7 +149,7 @@
 		if (sc.state == SCE_ASM_DEFAULT) {
 			if (sc.ch == ';'){
 				sc.SetState(SCE_ASM_COMMENT);
-			} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
+			} else if (isascii(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && isascii(sc.chNext) && isdigit(sc.chNext)))) {
 				sc.SetState(SCE_ASM_NUMBER);
 			} else if (IsAWordStart(sc.ch)) {
 				sc.SetState(SCE_ASM_IDENTIFIER);
@@ -154,7 +157,7 @@
 				sc.SetState(SCE_ASM_STRING);
 			} else if (sc.ch == '\'') {
 				sc.SetState(SCE_ASM_CHARACTER);
-			} else if (IsAsmOperator(static_cast<char>(sc.ch))) {
+			} else if (IsAsmOperator(sc.ch)) {
 				sc.SetState(SCE_ASM_OPERATOR);
 			}
 		}

Modified: trunk/plugins/editor/scintilla/LexAsn1.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexAsn1.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexAsn1.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // Some char test functions
 static bool isAsn1Number(int ch)
 {

Modified: trunk/plugins/editor/scintilla/LexBaan.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexBaan.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexBaan.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsAWordChar(const int  ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$' || ch == ':');
 }

Modified: trunk/plugins/editor/scintilla/LexBash.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexBash.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexBash.cxx	Sat Nov 15 17:50:33 2008
@@ -2,8 +2,8 @@
 /** @file LexBash.cxx
  ** Lexer for Bash.
  **/
-// Copyright 2004-2005 by Neil Hodgson <neilh scintilla org>
-// Adapted from LexPerl by Kein-Hong Man <mkh pl jaring my> 2004
+// Copyright 2004-2008 by Neil Hodgson <neilh scintilla org>
+// Adapted from LexPerl by Kein-Hong Man 2004
 // The License.txt file describes the conditions under which this software may be distributed.
 
 #include <stdlib.h>
@@ -16,19 +16,31 @@
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+#include "CharacterSet.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#define HERE_DELIM_MAX 256
+
+// define this if you want 'invalid octals' to be marked as errors
+// usually, this is not a good idea, permissive lexing is better
+#undef PEDANTIC_OCTAL
 
 #define BASH_BASE_ERROR		65
 #define BASH_BASE_DECIMAL	66
 #define BASH_BASE_HEX		67
+#ifdef PEDANTIC_OCTAL
 #define BASH_BASE_OCTAL		68
 #define BASH_BASE_OCTAL_ERROR	69
+#endif
 
-#define HERE_DELIM_MAX 256
-
-static inline int translateBashDigit(char ch) {
+static inline int translateBashDigit(int ch) {
 	if (ch >= '0' && ch <= '9') {
 		return ch - '0';
 	} else if (ch >= 'a' && ch <= 'z') {
@@ -43,397 +55,210 @@
 	return BASH_BASE_ERROR;
 }
 
-static inline bool isEOLChar(char ch) {
-	return (ch == '\r') || (ch == '\n');
-}
-
-static bool isSingleCharOp(char ch) {
-	char strCharSet[2];
-	strCharSet[0] = ch;
-	strCharSet[1] = '\0';
-	return (NULL != strstr("rwxoRWXOezsfdlpSbctugkTBMACahGLNn", strCharSet));
-}
-
-static inline bool isBashOperator(char ch) {
-	if (ch == '^' || ch == '&' || ch == '\\' || ch == '%' ||
-	        ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
-	        ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
-	        ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
-	        ch == '>' || ch == ',' || ch == '/' || ch == '<' ||
-	        ch == '?' || ch == '!' || ch == '.' || ch == '~' ||
-		ch == '@')
-		return true;
-	return false;
-}
-
-static int classifyWordBash(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
-	char s[100];
-	for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
-		s[i] = styler[start + i];
-		s[i + 1] = '\0';
-	}
-	char chAttr = SCE_SH_IDENTIFIER;
-	if (keywords.InList(s))
-		chAttr = SCE_SH_WORD;
-	styler.ColourTo(end, chAttr);
-	return chAttr;
-}
-
-static inline int getBashNumberBase(unsigned int start, unsigned int end, Accessor &styler) {
+static inline int getBashNumberBase(char *s) {
+	int i = 0;
 	int base = 0;
-	for (unsigned int i = 0; i < end - start + 1 && i < 10; i++) {
-		base = base * 10 + (styler[start + i] - '0');
+	while (*s) {
+		base = base * 10 + (*s++ - '0');
+		i++;
 	}
-	if (base > 64 || (end - start) > 1) {
+	if (base > 64 || i > 2) {
 		return BASH_BASE_ERROR;
 	}
 	return base;
 }
 
-static inline bool isEndVar(char ch) {
-	return !isalnum(ch) && ch != '$' && ch != '_';
-}
-
-static inline bool isNonQuote(char ch) {
-	return isalnum(ch) || ch == '_';
-}
-
-static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
-	if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
-		return false;
-	}
-	while (*val) {
-		if (*val != styler[pos++]) {
-			return false;
-		}
-		val++;
-	}
-	return true;
-}
-
-static char opposite(char ch) {
-	if (ch == '(')
-		return ')';
-	if (ch == '[')
-		return ']';
-	if (ch == '{')
-		return '}';
-	if (ch == '<')
-		return '>';
+static int opposite(int ch) {
+	if (ch == '(') return ')';
+	if (ch == '[') return ']';
+	if (ch == '{') return '}';
+	if (ch == '<') return '>';
 	return ch;
 }
 
 static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
-                             WordList *keywordlists[], Accessor &styler) {
-
-	// Lexer for bash often has to backtrack to start of current style to determine
-	// which characters are being used as quotes, how deeply nested is the
-	// start position and what the termination string is for here documents
+							 WordList *keywordlists[], Accessor &styler) {
 
 	WordList &keywords = *keywordlists[0];
 
-	class HereDocCls {
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_");
+	// note that [+-] are often parts of identifiers in shell scripts
+	CharacterSet setWord(CharacterSet::setAlphaNum, "._+-");
+	CharacterSet setBashOperator(CharacterSet::setNone, "^&\\%()-+=|{}[]:;>,*/<?!.~@");
+	CharacterSet setSingleCharOp(CharacterSet::setNone, "rwxoRWXOezsfdlpSbctugkTBMACahGLNn");
+	CharacterSet setParam(CharacterSet::setAlphaNum, "$_");
+	CharacterSet setHereDoc(CharacterSet::setAlpha, "_\\-+!");
+	CharacterSet setHereDoc2(CharacterSet::setAlphaNum, "_-+!");
+	CharacterSet setLeftShift(CharacterSet::setDigits, "=$");
+
+	class HereDocCls {	// Class to manage HERE document elements
 	public:
 		int State;		// 0: '<<' encountered
 		// 1: collect the delimiter
 		// 2: here doc text (lines after the delimiter)
-		char Quote;		// the char after '<<'
+		int Quote;		// the char after '<<'
 		bool Quoted;		// true if Quote in ('\'','"','`')
 		bool Indent;		// indented delimiter (for <<-)
 		int DelimiterLength;	// strlen(Delimiter)
 		char *Delimiter;	// the Delimiter, 256: sizeof PL_tokenbuf
 		HereDocCls() {
 			State = 0;
-            Quote = 0;
-            Quoted = false;
-            Indent = 0;
+			Quote = 0;
+			Quoted = false;
+			Indent = 0;
 			DelimiterLength = 0;
 			Delimiter = new char[HERE_DELIM_MAX];
 			Delimiter[0] = '\0';
 		}
+		void Append(int ch) {
+			Delimiter[DelimiterLength++] = static_cast<char>(ch);
+			Delimiter[DelimiterLength] = '\0';
+		}
 		~HereDocCls() {
 			delete []Delimiter;
 		}
 	};
 	HereDocCls HereDoc;
 
-	class QuoteCls {
+	class QuoteCls {	// Class to manage quote pairs (simplified vs LexPerl)
 		public:
-		int  Rep;
-		int  Count;
-		char Up;
-		char Down;
+		int Count;
+		int Up, Down;
 		QuoteCls() {
-			this->New(1);
-		}
-		void New(int r) {
-			Rep   = r;
 			Count = 0;
 			Up    = '\0';
 			Down  = '\0';
 		}
-		void Open(char u) {
+		void Open(int u) {
 			Count++;
 			Up    = u;
 			Down  = opposite(Up);
 		}
+		void Start(int u) {
+			Count = 0;
+			Open(u);
+		}
 	};
 	QuoteCls Quote;
 
-	int state = initStyle;
 	int numBase = 0;
-	unsigned int lengthDoc = startPos + length;
+	int digit;
+	unsigned int endPos = startPos + length;
 
-	// If in a long distance lexical state, seek to the beginning to find quote characters
-	// Bash strings can be multi-line with embedded newlines, so backtrack.
-	// Bash numbers have additional state during lexing, so backtrack too.
-	if (state == SCE_SH_HERE_Q) {
+	// Backtrack to beginning of style if required...
+	// If in a long distance lexical state, backtrack to find quote characters
+	if (initStyle == SCE_SH_HERE_Q) {
 		while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_SH_HERE_DELIM)) {
 			startPos--;
 		}
 		startPos = styler.LineStart(styler.GetLine(startPos));
-		state = styler.StyleAt(startPos - 1);
+		initStyle = styler.StyleAt(startPos - 1);
 	}
-	if (state == SCE_SH_STRING
-	 || state == SCE_SH_BACKTICKS
-	 || state == SCE_SH_CHARACTER
-	 || state == SCE_SH_NUMBER
-	 || state == SCE_SH_IDENTIFIER
-	 || state == SCE_SH_COMMENTLINE
-	) {
-		while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
+	// Bash strings can be multi-line with embedded newlines, so backtrack.
+	// Bash numbers have additional state during lexing, so backtrack too.
+	if (initStyle == SCE_SH_STRING
+	 || initStyle == SCE_SH_BACKTICKS
+	 || initStyle == SCE_SH_CHARACTER
+	 || initStyle == SCE_SH_NUMBER
+	 || initStyle == SCE_SH_IDENTIFIER
+	 || initStyle == SCE_SH_COMMENTLINE) {
+		while ((startPos > 1) && (styler.StyleAt(startPos - 1) == initStyle)) {
 			startPos--;
 		}
-		state = SCE_SH_DEFAULT;
+		initStyle = SCE_SH_DEFAULT;
 	}
 
-	styler.StartAt(startPos);
-	char chPrev = styler.SafeGetCharAt(startPos - 1);
-	if (startPos == 0)
-		chPrev = '\n';
-	char chNext = styler[startPos];
-	styler.StartSegment(startPos);
-
-	for (unsigned int i = startPos; i < lengthDoc; i++) {
-		char ch = chNext;
-		// if the current character is not consumed due to the completion of an
-		// earlier style, lexing can be restarted via a simple goto
-	restartLexer:
-		chNext = styler.SafeGetCharAt(i + 1);
-		char chNext2 = styler.SafeGetCharAt(i + 2);
+	StyleContext sc(startPos, endPos - startPos, initStyle, styler);
 
-		if (styler.IsLeadByte(ch)) {
-			chNext = styler.SafeGetCharAt(i + 2);
-			chPrev = ' ';
-			i += 1;
-			continue;
-		}
-
-		if ((chPrev == '\r' && ch == '\n')) {	// skip on DOS/Windows
-			styler.ColourTo(i, state);
-			chPrev = ch;
-			continue;
-		}
+	for (; sc.More(); sc.Forward()) {
 
-		if (HereDoc.State == 1 && isEOLChar(ch)) {
-			// Begin of here-doc (the line after the here-doc delimiter):
-			// Lexically, the here-doc starts from the next line after the >>, but the
-			// first line of here-doc seem to follow the style of the last EOL sequence
-			HereDoc.State = 2;
-			if (HereDoc.Quoted) {
-				if (state == SCE_SH_HERE_DELIM) {
-					// Missing quote at end of string! We are stricter than bash.
-					// Colour here-doc anyway while marking this bit as an error.
-					state = SCE_SH_ERROR;
-				}
-				styler.ColourTo(i - 1, state);
-				// HereDoc.Quote always == '\''
-				state = SCE_SH_HERE_Q;
-			} else {
-				styler.ColourTo(i - 1, state);
-				// always switch
-				state = SCE_SH_HERE_Q;
-			}
-		}
-
-		if (state == SCE_SH_DEFAULT) {
-			if (ch == '\\') {	// escaped character
-				if (i < lengthDoc - 1)
-					i++;
-				ch = chNext;
-				chNext = chNext2;
-				styler.ColourTo(i, SCE_SH_IDENTIFIER);
-			} else if (isdigit(ch)) {
-				state = SCE_SH_NUMBER;
-				numBase = BASH_BASE_DECIMAL;
-				if (ch == '0') {	// hex,octal
-					if (chNext == 'x' || chNext == 'X') {
-						numBase = BASH_BASE_HEX;
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-					} else if (isdigit(chNext)) {
-						numBase = BASH_BASE_OCTAL;
+		// Determine if the current state should terminate.
+		switch (sc.state) {
+			case SCE_SH_OPERATOR:
+				sc.SetState(SCE_SH_DEFAULT);
+				break;
+			case SCE_SH_WORD:
+				// "." never used in Bash variable names but used in file names
+				if (!setWord.Contains(sc.ch)) {
+					char s[1000];
+					sc.GetCurrent(s, sizeof(s));
+					if (s[0] != '-' &&	// for file operators
+						!keywords.InList(s)) {
+						sc.ChangeState(SCE_SH_IDENTIFIER);
 					}
+					sc.SetState(SCE_SH_DEFAULT);
 				}
-			} else if (iswordstart(ch)) {
-				state = SCE_SH_WORD;
-				if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
-					// We need that if length of word == 1!
-					// This test is copied from the SCE_SH_WORD handler.
-					classifyWordBash(styler.GetStartSegment(), i, keywords, styler);
-					state = SCE_SH_DEFAULT;
-				}
-			} else if (ch == '#') {
-				state = SCE_SH_COMMENTLINE;
-			} else if (ch == '\"') {
-				state = SCE_SH_STRING;
-				Quote.New(1);
-				Quote.Open(ch);
-			} else if (ch == '\'') {
-				state = SCE_SH_CHARACTER;
-				Quote.New(1);
-				Quote.Open(ch);
-			} else if (ch == '`') {
-				state = SCE_SH_BACKTICKS;
-				Quote.New(1);
-				Quote.Open(ch);
-			} else if (ch == '$') {
-				if (chNext == '{') {
-					state = SCE_SH_PARAM;
-					goto startQuote;
-				} else if (chNext == '\'') {
-					state = SCE_SH_CHARACTER;
-					goto startQuote;
-				} else if (chNext == '"') {
-					state = SCE_SH_STRING;
-					goto startQuote;
-				} else if (chNext == '(' && chNext2 == '(') {
-					styler.ColourTo(i, SCE_SH_OPERATOR);
-					state = SCE_SH_DEFAULT;
-					goto skipChar;
-				} else if (chNext == '(' || chNext == '`') {
-					state = SCE_SH_BACKTICKS;
-				startQuote:
-					Quote.New(1);
-					Quote.Open(chNext);
-					goto skipChar;
-				} else {
-					state = SCE_SH_SCALAR;
-				skipChar:
-					i++;
-					ch = chNext;
-					chNext = chNext2;
-				}
-			} else if (ch == '*') {
-				if (chNext == '*') {	// exponentiation
-					i++;
-					ch = chNext;
-					chNext = chNext2;
-				}
-				styler.ColourTo(i, SCE_SH_OPERATOR);
-			} else if (ch == '<' && chNext == '<') {
-				state = SCE_SH_HERE_DELIM;
-				HereDoc.State = 0;
-				HereDoc.Indent = false;
-			} else if (ch == '-'	// file test operators
-			           && isSingleCharOp(chNext)
-			           && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) {
-				styler.ColourTo(i + 1, SCE_SH_WORD);
-				state = SCE_SH_DEFAULT;
-				i++;
-				ch = chNext;
-				chNext = chNext2;
-			} else if (isBashOperator(ch)) {
-				styler.ColourTo(i, SCE_SH_OPERATOR);
-			} else {
-				// keep colouring defaults to make restart easier
-				styler.ColourTo(i, SCE_SH_DEFAULT);
-			}
-		} else if (state == SCE_SH_NUMBER) {
-			int digit = translateBashDigit(ch);
-			if (numBase == BASH_BASE_DECIMAL) {
-				if (ch == '#') {
-					numBase = getBashNumberBase(styler.GetStartSegment(), i - 1, styler);
-					if (numBase == BASH_BASE_ERROR)	// take the rest as comment
-						goto numAtEnd;
-				} else if (!isdigit(ch))
-					goto numAtEnd;
-			} else if (numBase == BASH_BASE_HEX) {
-				if ((digit < 16) || (digit >= 36 && digit <= 41)) {
-					// hex digit 0-9a-fA-F
-				} else
-					goto numAtEnd;
-			} else if (numBase == BASH_BASE_OCTAL ||
-				   numBase == BASH_BASE_OCTAL_ERROR) {
-				if (digit > 7) {
+				break;
+			case SCE_SH_IDENTIFIER:
+				if (sc.chPrev == '\\') {	// for escaped chars
+					sc.ForwardSetState(SCE_SH_DEFAULT);
+				} else if (!setWord.Contains(sc.ch)) {
+					sc.SetState(SCE_SH_DEFAULT);
+				}
+				break;
+			case SCE_SH_NUMBER:
+				digit = translateBashDigit(sc.ch);
+				if (numBase == BASH_BASE_DECIMAL) {
+					if (sc.ch == '#') {
+						char s[10];
+						sc.GetCurrent(s, sizeof(s));
+						numBase = getBashNumberBase(s);
+						if (numBase != BASH_BASE_ERROR)
+							break;
+					} else if (IsADigit(sc.ch))
+						break;
+				} else if (numBase == BASH_BASE_HEX) {
+					if (IsADigit(sc.ch, 16))
+						break;
+#ifdef PEDANTIC_OCTAL
+				} else if (numBase == BASH_BASE_OCTAL ||
+						   numBase == BASH_BASE_OCTAL_ERROR) {
+					if (digit <= 7)
+						break;
 					if (digit <= 9) {
 						numBase = BASH_BASE_OCTAL_ERROR;
-					} else
-						goto numAtEnd;
-				}
-			} else if (numBase == BASH_BASE_ERROR) {
-				if (digit > 9)
-					goto numAtEnd;
-			} else {	// DD#DDDD number style handling
-				if (digit != BASH_BASE_ERROR) {
-					if (numBase <= 36) {
-						// case-insensitive if base<=36
-						if (digit >= 36) digit -= 26;
+						break;
 					}
-					if (digit >= numBase) {
+#endif
+				} else if (numBase == BASH_BASE_ERROR) {
+					if (digit <= 9)
+						break;
+				} else {	// DD#DDDD number style handling
+					if (digit != BASH_BASE_ERROR) {
+						if (numBase <= 36) {
+							// case-insensitive if base<=36
+							if (digit >= 36) digit -= 26;
+						}
+						if (digit < numBase)
+							break;
 						if (digit <= 9) {
 							numBase = BASH_BASE_ERROR;
-						} else
-							goto numAtEnd;
+							break;
+						}
 					}
-				} else {
-			numAtEnd:
-					if (numBase == BASH_BASE_ERROR ||
-					    numBase == BASH_BASE_OCTAL_ERROR)
-						state = SCE_SH_ERROR;
-					styler.ColourTo(i - 1, state);
-					state = SCE_SH_DEFAULT;
-					goto restartLexer;
 				}
-			}
-		} else if (state == SCE_SH_WORD) {
-			if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
-				// "." never used in Bash variable names
-				// but used in file names
-				classifyWordBash(styler.GetStartSegment(), i, keywords, styler);
-				state = SCE_SH_DEFAULT;
-				ch = ' ';
-			}
-		} else if (state == SCE_SH_IDENTIFIER) {
-			if (!iswordchar(chNext) && chNext != '+' && chNext != '-') {
-				styler.ColourTo(i, SCE_SH_IDENTIFIER);
-				state = SCE_SH_DEFAULT;
-				ch = ' ';
-			}
-		} else {
-			if (state == SCE_SH_COMMENTLINE) {
-				if (ch == '\\' && isEOLChar(chNext)) {
+				// fallthrough when number is at an end or error
+				if (numBase == BASH_BASE_ERROR
+#ifdef PEDANTIC_OCTAL
+					|| numBase == BASH_BASE_OCTAL_ERROR
+#endif
+				) {
+					sc.ChangeState(SCE_SH_ERROR);
+				}
+				sc.SetState(SCE_SH_DEFAULT);
+				break;
+			case SCE_SH_COMMENTLINE:
+				if (sc.ch == '\\' && (sc.chNext == '\r' || sc.chNext == '\n')) {
 					// comment continuation
-					if (chNext == '\r' && chNext2 == '\n') {
-						i += 2;
-						ch = styler.SafeGetCharAt(i);
-						chNext = styler.SafeGetCharAt(i + 1);
-					} else {
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-					}
-				} else if (isEOLChar(ch)) {
-					styler.ColourTo(i - 1, state);
-					state = SCE_SH_DEFAULT;
-					goto restartLexer;
-				} else if (isEOLChar(chNext)) {
-					styler.ColourTo(i, state);
-					state = SCE_SH_DEFAULT;
+					sc.Forward();
+					if (sc.ch == '\r' && sc.chNext == '\n') {
+						sc.Forward();
+					}
+				} else if (sc.atLineEnd) {
+					sc.ForwardSetState(SCE_SH_DEFAULT);
 				}
-			} else if (state == SCE_SH_HERE_DELIM) {
-				//
+				break;
+			case SCE_SH_HERE_DELIM:
 				// From Bash info:
 				// ---------------
 				// Specifier format is: <<[-]WORD
@@ -441,150 +266,194 @@
 				// Whitespace acceptable after <<[-] operator
 				//
 				if (HereDoc.State == 0) { // '<<' encountered
-					HereDoc.State = 1;
-					HereDoc.Quote = chNext;
+					HereDoc.Quote = sc.chNext;
 					HereDoc.Quoted = false;
 					HereDoc.DelimiterLength = 0;
 					HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
-					if (chNext == '\'' || chNext == '\"') {	// a quoted here-doc delimiter (' or ")
-						i++;
-						ch = chNext;
-						chNext = chNext2;
+					if (sc.chNext == '\'' || sc.chNext == '\"') {	// a quoted here-doc delimiter (' or ")
+						sc.Forward();
 						HereDoc.Quoted = true;
-					} else if (!HereDoc.Indent && chNext == '-') {	// <<- indent case
+						HereDoc.State = 1;
+					} else if (!HereDoc.Indent && sc.chNext == '-') {	// <<- indent case
 						HereDoc.Indent = true;
-						HereDoc.State = 0;
-					} else if (isalpha(chNext) || chNext == '_' || chNext == '\\'
-						|| chNext == '-' || chNext == '+' || chNext == '!') {
+					} else if (setHereDoc.Contains(sc.chNext)) {
 						// an unquoted here-doc delimiter, no special handling
-                        // TODO check what exactly bash considers part of the delim
-					} else if (chNext == '<') {	// HERE string <<<
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-						styler.ColourTo(i, SCE_SH_HERE_DELIM);
-						state = SCE_SH_DEFAULT;
-						HereDoc.State = 0;
-					} else if (isspacechar(chNext)) {
+						// TODO check what exactly bash considers part of the delim
+						HereDoc.State = 1;
+					} else if (sc.chNext == '<') {	// HERE string <<<
+						sc.Forward();
+						sc.ForwardSetState(SCE_SH_DEFAULT);
+					} else if (IsASpace(sc.chNext)) {
 						// eat whitespace
-						HereDoc.State = 0;
-					} else if (isdigit(chNext) || chNext == '=' || chNext == '$') {
+					} else if (setLeftShift.Contains(sc.chNext)) {
 						// left shift << or <<= operator cases
-						styler.ColourTo(i, SCE_SH_OPERATOR);
-						state = SCE_SH_DEFAULT;
-						HereDoc.State = 0;
+						sc.ChangeState(SCE_SH_OPERATOR);
+						sc.ForwardSetState(SCE_SH_DEFAULT);
 					} else {
 						// symbols terminates; deprecated zero-length delimiter
+						HereDoc.State = 1;
 					}
 				} else if (HereDoc.State == 1) { // collect the delimiter
 					if (HereDoc.Quoted) { // a quoted here-doc delimiter
-						if (ch == HereDoc.Quote) { // closing quote => end of delimiter
-							styler.ColourTo(i, state);
-							state = SCE_SH_DEFAULT;
+						if (sc.ch == HereDoc.Quote) { // closing quote => end of delimiter
+							sc.ForwardSetState(SCE_SH_DEFAULT);
 						} else {
-							if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote
-								i++;
-								ch = chNext;
-								chNext = chNext2;
+							if (sc.ch == '\\' && sc.chNext == HereDoc.Quote) { // escaped quote
+								sc.Forward();
 							}
-							HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
-							HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+							HereDoc.Append(sc.ch);
 						}
 					} else { // an unquoted here-doc delimiter
-						if (isalnum(ch) || ch == '_' || ch == '-' || ch == '+' || ch == '!') {
-							HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
-							HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
-						} else if (ch == '\\') {
+						if (setHereDoc2.Contains(sc.ch)) {
+							HereDoc.Append(sc.ch);
+						} else if (sc.ch == '\\') {
 							// skip escape prefix
 						} else {
-							styler.ColourTo(i - 1, state);
-							state = SCE_SH_DEFAULT;
-							goto restartLexer;
+							sc.SetState(SCE_SH_DEFAULT);
 						}
 					}
-					if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) {
-						styler.ColourTo(i - 1, state);
-						state = SCE_SH_ERROR;
-						goto restartLexer;
-					}
-				}
-			} else if (HereDoc.State == 2) {
-				// state == SCE_SH_HERE_Q
-				if (isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
-					if (!HereDoc.Indent && isEOLChar(chPrev)) {
-					endHereDoc:
-						// standard HERE delimiter
-						i += HereDoc.DelimiterLength;
-						chPrev = styler.SafeGetCharAt(i - 1);
-						ch = styler.SafeGetCharAt(i);
-						if (isEOLChar(ch)) {
-							styler.ColourTo(i - 1, state);
-							state = SCE_SH_DEFAULT;
-							HereDoc.State = 0;
-							goto restartLexer;
-						}
-						chNext = styler.SafeGetCharAt(i + 1);
-					} else if (HereDoc.Indent) {
-						// indented HERE delimiter
-						unsigned int bk = (i > 0)? i - 1: 0;
-						while (i > 0) {
-							ch = styler.SafeGetCharAt(bk--);
-							if (isEOLChar(ch)) {
-								goto endHereDoc;
-							} else if (!isspacechar(ch)) {
-								break;	// got leading non-whitespace
-							}
+					if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) {	// force blowup
+						sc.SetState(SCE_SH_ERROR);
+						HereDoc.State = 0;
+					}
+				}
+				break;
+			case SCE_SH_HERE_Q:
+				// HereDoc.State == 2
+				if (sc.atLineStart) {
+					sc.SetState(SCE_SH_HERE_Q);
+					int prefixws = 0;
+					while (IsASpace(sc.ch) && !sc.atLineEnd) {	// whitespace prefix
+						sc.Forward();
+						prefixws++;
+					}
+					if (prefixws > 0)
+						sc.SetState(SCE_SH_HERE_Q);
+					while (!sc.atLineEnd) {
+						sc.Forward();
+					}
+					char s[HERE_DELIM_MAX];
+					sc.GetCurrent(s, sizeof(s));
+					if (strcmp(HereDoc.Delimiter, s) == 0) {
+						if ((prefixws > 0 && HereDoc.Indent) ||	// indentation rule
+							(prefixws == 0 && !HereDoc.Indent)) {
+							sc.SetState(SCE_SH_DEFAULT);
+							break;
 						}
 					}
 				}
-			} else if (state == SCE_SH_SCALAR) {	// variable names
-				if (isEndVar(ch)) {
-					if ((state == SCE_SH_SCALAR)
-					    && i == (styler.GetStartSegment() + 1)) {
+				break;
+			case SCE_SH_SCALAR:	// variable names
+				if (!setParam.Contains(sc.ch)) {
+					if (sc.LengthCurrent() == 1) {
 						// Special variable: $(, $_ etc.
-						styler.ColourTo(i, state);
-						state = SCE_SH_DEFAULT;
+						sc.ForwardSetState(SCE_SH_DEFAULT);
 					} else {
-						styler.ColourTo(i - 1, state);
-						state = SCE_SH_DEFAULT;
-						goto restartLexer;
+						sc.SetState(SCE_SH_DEFAULT);
 					}
 				}
-			} else if (state == SCE_SH_STRING
-				|| state == SCE_SH_CHARACTER
-				|| state == SCE_SH_BACKTICKS
-				|| state == SCE_SH_PARAM
-				) {
-				if (!Quote.Down && !isspacechar(ch)) {
-					Quote.Open(ch);
-				} else if (ch == '\\' && Quote.Up != '\\') {
-					i++;
-					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
-				} else if (ch == Quote.Down) {
+				break;
+			case SCE_SH_STRING:	// delimited styles
+			case SCE_SH_CHARACTER:
+			case SCE_SH_BACKTICKS:
+			case SCE_SH_PARAM:
+				if (sc.ch == '\\' && Quote.Up != '\\') {
+					sc.Forward();
+				} else if (sc.ch == Quote.Down) {
 					Quote.Count--;
 					if (Quote.Count == 0) {
-						Quote.Rep--;
-						if (Quote.Rep <= 0) {
-							styler.ColourTo(i, state);
-							state = SCE_SH_DEFAULT;
-							ch = ' ';
-						}
-						if (Quote.Up == Quote.Down) {
-							Quote.Count++;
-						}
+						sc.ForwardSetState(SCE_SH_DEFAULT);
 					}
-				} else if (ch == Quote.Up) {
+				} else if (sc.ch == Quote.Up) {
 					Quote.Count++;
 				}
+				break;
+		}
+
+		// Must check end of HereDoc state 1 before default state is handled
+		if (HereDoc.State == 1 && sc.atLineEnd) {
+			// Begin of here-doc (the line after the here-doc delimiter):
+			// Lexically, the here-doc starts from the next line after the >>, but the
+			// first line of here-doc seem to follow the style of the last EOL sequence
+			HereDoc.State = 2;
+			if (HereDoc.Quoted) {
+				if (sc.state == SCE_SH_HERE_DELIM) {
+					// Missing quote at end of string! We are stricter than bash.
+					// Colour here-doc anyway while marking this bit as an error.
+					sc.ChangeState(SCE_SH_ERROR);
+				}
+				// HereDoc.Quote always == '\''
 			}
+			sc.SetState(SCE_SH_HERE_Q);
 		}
-		if (state == SCE_SH_ERROR) {
-			break;
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_SH_DEFAULT) {
+			if (sc.ch == '\\') {	// escaped character
+				sc.SetState(SCE_SH_IDENTIFIER);
+			} else if (IsADigit(sc.ch)) {
+				sc.SetState(SCE_SH_NUMBER);
+				numBase = BASH_BASE_DECIMAL;
+				if (sc.ch == '0') {	// hex,octal
+					if (sc.chNext == 'x' || sc.chNext == 'X') {
+						numBase = BASH_BASE_HEX;
+						sc.Forward();
+					} else if (IsADigit(sc.chNext)) {
+#ifdef PEDANTIC_OCTAL
+						numBase = BASH_BASE_OCTAL;
+#else
+						numBase = BASH_BASE_HEX;
+#endif
+					}
+				}
+			} else if (setWordStart.Contains(sc.ch)) {
+				sc.SetState(SCE_SH_WORD);
+			} else if (sc.ch == '#') {
+				sc.SetState(SCE_SH_COMMENTLINE);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_SH_STRING);
+				Quote.Start(sc.ch);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_SH_CHARACTER);
+				Quote.Start(sc.ch);
+			} else if (sc.ch == '`') {
+				sc.SetState(SCE_SH_BACKTICKS);
+				Quote.Start(sc.ch);
+			} else if (sc.ch == '$') {
+				sc.SetState(SCE_SH_SCALAR);
+				sc.Forward();
+				if (sc.ch == '{') {
+					sc.ChangeState(SCE_SH_PARAM);
+				} else if (sc.ch == '\'') {
+					sc.ChangeState(SCE_SH_CHARACTER);
+				} else if (sc.ch == '"') {
+					sc.ChangeState(SCE_SH_STRING);
+				} else if (sc.ch == '(' || sc.ch == '`') {
+					sc.ChangeState(SCE_SH_BACKTICKS);
+					if (sc.chNext == '(') {	// $(( is lexed as operator
+						sc.ChangeState(SCE_SH_OPERATOR);
+					}
+				} else {
+					continue;	// scalar has no delimiter pair
+				}
+				// fallthrough, open delim for $[{'"(`]
+				Quote.Start(sc.ch);
+			} else if (sc.Match('<', '<')) {
+				sc.SetState(SCE_SH_HERE_DELIM);
+				HereDoc.State = 0;
+				HereDoc.Indent = false;
+			} else if (sc.ch == '-'	&&	// one-char file test operators
+					   setSingleCharOp.Contains(sc.chNext) &&
+					   !setWord.Contains(sc.GetRelative(2)) &&
+					   IsASpace(sc.chPrev)) {
+				sc.SetState(SCE_SH_WORD);
+				sc.Forward();
+			} else if (setBashOperator.Contains(sc.ch)) {
+				sc.SetState(SCE_SH_OPERATOR);
+			}
 		}
-		chPrev = ch;
 	}
-	styler.ColourTo(lengthDoc - 1, state);
+	sc.Complete();
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
@@ -601,7 +470,7 @@
 }
 
 static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[],
-                            Accessor &styler) {
+						Accessor &styler) {
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
 	unsigned int endPos = startPos + length;
@@ -617,16 +486,16 @@
 		int style = styleNext;
 		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-        // Comment folding
+		// Comment folding
 		if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
-        {
-            if (!IsCommentLine(lineCurrent - 1, styler)
-                && IsCommentLine(lineCurrent + 1, styler))
-                levelCurrent++;
-            else if (IsCommentLine(lineCurrent - 1, styler)
-                     && !IsCommentLine(lineCurrent+1, styler))
-                levelCurrent--;
-        }
+		{
+			if (!IsCommentLine(lineCurrent - 1, styler)
+				&& IsCommentLine(lineCurrent + 1, styler))
+				levelCurrent++;
+			else if (IsCommentLine(lineCurrent - 1, styler)
+					 && !IsCommentLine(lineCurrent + 1, styler))
+				levelCurrent--;
+		}
 		if (style == SCE_SH_OPERATOR) {
 			if (ch == '{') {
 				levelCurrent++;

Modified: trunk/plugins/editor/scintilla/LexBasic.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexBasic.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexBasic.cxx	Sat Nov 15 17:50:33 2008
@@ -31,6 +31,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /* Bits:
  * 1  - whitespace
  * 2  - operator

Modified: trunk/plugins/editor/scintilla/LexBullant.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexBullant.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexBullant.cxx	Sat Nov 15 17:50:33 2008
@@ -15,6 +15,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
 	char s[100];

Modified: trunk/plugins/editor/scintilla/LexCLW.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCLW.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCLW.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // Is an end of line character
 inline bool IsEOL(const int ch) {
 

Modified: trunk/plugins/editor/scintilla/LexCPP.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCPP.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCPP.cxx	Sat Nov 15 17:50:33 2008
@@ -19,45 +19,11 @@
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+#include "CharacterSet.h"
 
-#define SET_LOWER "abcdefghijklmnopqrstuvwxyz"
-#define SET_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define SET_DIGITS "0123456789"
-
-class SetOfCharacters {
-	int size;
-	bool valueAfter;
-	bool *bset;
-public:
-	SetOfCharacters(const char *setOfCharacters, int size_=0x80, bool valueAfter_=false) {
-		size = size_;
-		valueAfter = valueAfter_;
-		bset = new bool[size];
-		for (int i=0; i < size; i++) {
-			bset[i] = false;
-		}
-		for (const char *cp=setOfCharacters; *cp; cp++) {
-			int val = static_cast<unsigned char>(*cp);
-			PLATFORM_ASSERT(val >= 0);
-			PLATFORM_ASSERT(val < size);
-			bset[val] = true;
-		}
-	}
-	~SetOfCharacters() {
-		delete []bset;
-		bset = 0;
-		size = 0;
-	}
-	void Add(int val) {
-		PLATFORM_ASSERT(val >= 0);
-		PLATFORM_ASSERT(val < size);
-		bset[val] = true;
-	}
-	bool Contains(int val) {
-		PLATFORM_ASSERT(val >= 0);
-		return (val < size) ? bset[val] : valueAfter;
-	}
-};
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static bool IsSpaceEquiv(int state) {
 	return (state <= SCE_C_COMMENTDOC) ||
@@ -66,6 +32,24 @@
 		(state == SCE_C_COMMENTDOCKEYWORDERROR);
 }
 
+// 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 void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler, bool caseSensitive) {
 
@@ -76,12 +60,13 @@
 
 	bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
 
-	SetOfCharacters setOKBeforeRE("(=,");
+	CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
+	CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
 
-	SetOfCharacters setDoxygen("$ \\&<>#{}[]" SET_LOWER);
+	CharacterSet setDoxygen(CharacterSet::setAlpha, "$ \\&<>#{}[]");
 
-	SetOfCharacters setWordStart("_" SET_LOWER SET_UPPER, 0x80, true);
-	SetOfCharacters setWord("._" SET_LOWER SET_UPPER SET_DIGITS, 0x80, true);
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
 	if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
 		setWordStart.Add('$');
 		setWord.Add('$');
@@ -331,7 +316,8 @@
 					sc.SetState(SCE_C_COMMENTLINEDOC);
 				else
 					sc.SetState(SCE_C_COMMENTLINE);
-			} else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite)) {
+			} else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite) &&
+				(!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) {
 				sc.SetState(SCE_C_REGEX);	// JavaScript's RegEx
 			} else if (sc.ch == '\"') {
 				sc.SetState(SCE_C_STRING);
@@ -371,8 +357,8 @@
 // Store both the current line's fold level and the next lines in the
 // level store to make it easy to pick up with each increment
 // and to make it possible to fiddle the current level for "} else {".
-static void FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
-                            Accessor &styler) {
+static void FoldCppDoc(unsigned int startPos, int length, int initStyle,
+					   WordList *[], Accessor &styler) {
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
@@ -396,9 +382,9 @@
 		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
 		if (foldComment && IsStreamCommentStyle(style)) {
-			if (!IsStreamCommentStyle(stylePrev)) {
+			if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) {
 				levelNext++;
-			} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+			} else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) {
 				// Comments don't end at end of line and the next character may be unstyled.
 				levelNext--;
 			}
@@ -438,7 +424,9 @@
 				levelNext--;
 			}
 		}
-		if (atEOL) {
+		if (!IsASpace(ch))
+			visibleChars++;
+		if (atEOL || (i == endPos-1)) {
 			int levelUse = levelCurrent;
 			if (foldAtElse) {
 				levelUse = levelMinCurrent;
@@ -456,16 +444,9 @@
 			levelMinCurrent = levelCurrent;
 			visibleChars = 0;
 		}
-		if (!IsASpace(ch))
-			visibleChars++;
 	}
 }
 
-static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
-                       Accessor &styler) {
-	FoldNoBoxCppDoc(startPos, length, initStyle, styler);
-}
-
 static const char * const cppWordLists[] = {
             "Primary keywords and identifiers",
             "Secondary keywords and identifiers",

Modified: trunk/plugins/editor/scintilla/LexCSS.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCSS.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCSS.cxx	Sat Nov 15 17:50:33 2008
@@ -22,13 +22,22 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 
 static inline bool IsAWordChar(const unsigned int ch) {
-	return (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); // _ is not in fact correct CSS word-character
+	/* FIXME:
+	 * The CSS spec allows "ISO 10646 characters U+00A1 and higher" to be treated as word chars.
+	 * Unfortunately, we are only getting string bytes here, and not full unicode characters. We cannot guarantee
+	 * that our byte is between U+0080 - U+00A0 (to return false), so we have to allow all characters U+0080 and higher
+	 */
+	return ch >= 0x80 || isalnum(ch) || ch == '-' || ch == '_';
 }
 
-inline bool IsCssOperator(const char ch) {
-	if (!isalnum(ch) &&
+inline bool IsCssOperator(const int ch) {
+	if (!((ch < 0x80) && isalnum(ch)) &&
 		(ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' ||
 		 ch == '.' || ch == '#' || ch == '!' || ch == '@' ||
 		 /* CSS2 */
@@ -40,15 +49,21 @@
 }
 
 static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
-	WordList &keywords = *keywordlists[0];
+	WordList &css1Props = *keywordlists[0];
 	WordList &pseudoClasses = *keywordlists[1];
-	WordList &keywords2 = *keywordlists[2];
+	WordList &css2Props = *keywordlists[2];
+	WordList &css3Props = *keywordlists[3];
+	WordList &pseudoElements = *keywordlists[4];
+	WordList &exProps = *keywordlists[5];
+	WordList &exPseudoClasses = *keywordlists[6];
+	WordList &exPseudoElements = *keywordlists[7];
 
 	StyleContext sc(startPos, length, initStyle, styler);
 
 	int lastState = -1; // before operator
 	int lastStateC = -1; // before comment
 	int op = ' '; // last operator
+	int opPrev = ' '; // last operator
 
 	for (; sc.More(); sc.Forward()) {
 		if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) {
@@ -60,6 +75,7 @@
 					if ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) {
 						if (lastStateC == SCE_CSS_OPERATOR) {
 							op = styler.SafeGetCharAt(i-1);
+							opPrev = styler.SafeGetCharAt(i-2);
 							while (--i) {
 								lastState = styler.StyleAt(i-1);
 								if (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)
@@ -96,6 +112,7 @@
 			if (op == ' ') {
 				unsigned int i = startPos;
 				op = styler.SafeGetCharAt(i-1);
+				opPrev = styler.SafeGetCharAt(i-2);
 				while (--i) {
 					lastState = styler.StyleAt(i-1);
 					if (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)
@@ -107,19 +124,15 @@
 				if (lastState == SCE_CSS_DEFAULT)
 					sc.SetState(SCE_CSS_DIRECTIVE);
 				break;
-			case '*':
-				if (lastState == SCE_CSS_DEFAULT)
-					sc.SetState(SCE_CSS_TAG);
-				break;
 			case '>':
 			case '+':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_CLASS
-					|| lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
+				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID ||
+					lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
 					sc.SetState(SCE_CSS_DEFAULT);
 				break;
 			case '[':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||
-					lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
+				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)
 					sc.SetState(SCE_CSS_ATTRIBUTE);
 				break;
 			case ']':
@@ -134,27 +147,44 @@
 				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_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_IDENTIFIER3)
 					sc.SetState(SCE_CSS_DEFAULT);
 				break;
+			case '(':
+				if (lastState == SCE_CSS_PSEUDOCLASS)
+					sc.SetState(SCE_CSS_TAG);
+				else if (lastState == SCE_CSS_EXTENDED_PSEUDOCLASS)
+					sc.SetState(SCE_CSS_EXTENDED_PSEUDOCLASS);
+				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)
+					sc.SetState(SCE_CSS_TAG);
+				break;
 			case ':':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||
-					lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
+				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)
 					sc.SetState(SCE_CSS_PSEUDOCLASS);
-				else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
+				else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 ||
+					lastState == SCE_CSS_IDENTIFIER3 || lastState == SCE_CSS_EXTENDED_IDENTIFIER ||
+					lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
 					sc.SetState(SCE_CSS_VALUE);
 				break;
 			case '.':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||
-					lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
+				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)
 					sc.SetState(SCE_CSS_CLASS);
 				break;
 			case '#':
-				if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||
-					lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)
+				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)
 					sc.SetState(SCE_CSS_ID);
 				break;
 			case ',':
+			case '|':
+			case '~':
 				if (lastState == SCE_CSS_TAG)
 					sc.SetState(SCE_CSS_DEFAULT);
 				break;
@@ -177,11 +207,19 @@
 			continue;
 		}
 
+		if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) {
+			sc.SetState(SCE_CSS_TAG);
+			continue;
+		}
+
 		if (IsAWordChar(sc.chPrev) && (
-			sc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_IDENTIFIER2
-			|| sc.state == SCE_CSS_UNKNOWN_IDENTIFIER
-			|| sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS
-			|| sc.state == SCE_CSS_IMPORTANT
+			sc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_IDENTIFIER2 ||
+			sc.state == SCE_CSS_IDENTIFIER3 || sc.state == SCE_CSS_EXTENDED_IDENTIFIER ||
+			sc.state == SCE_CSS_UNKNOWN_IDENTIFIER ||
+			sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT ||
+			sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT ||
+			sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS ||
+			sc.state == SCE_CSS_IMPORTANT
 		)) {
 			char s[100];
 			sc.GetCurrentLowered(s, sizeof(s));
@@ -190,27 +228,36 @@
 				s2++;
 			switch (sc.state) {
 			case SCE_CSS_IDENTIFIER:
-				if (!keywords.InList(s2)) {
-					if (keywords2.InList(s2)) {
-						sc.ChangeState(SCE_CSS_IDENTIFIER2);
-					} else {
-						sc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER);
-					}
-				}
-				break;
+			case SCE_CSS_IDENTIFIER2:
+			case SCE_CSS_IDENTIFIER3:
+			case SCE_CSS_EXTENDED_IDENTIFIER:
 			case SCE_CSS_UNKNOWN_IDENTIFIER:
-				if (keywords.InList(s2))
+				if (css1Props.InList(s2))
 					sc.ChangeState(SCE_CSS_IDENTIFIER);
-				else if (keywords2.InList(s2))
+				else if (css2Props.InList(s2))
 					sc.ChangeState(SCE_CSS_IDENTIFIER2);
+				else if (css3Props.InList(s2))
+					sc.ChangeState(SCE_CSS_IDENTIFIER3);
+				else if (exProps.InList(s2))
+					sc.ChangeState(SCE_CSS_EXTENDED_IDENTIFIER);
+				else
+					sc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER);
 				break;
 			case SCE_CSS_PSEUDOCLASS:
-				if (!pseudoClasses.InList(s2))
-					sc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS);
-				break;
+			case SCE_CSS_PSEUDOELEMENT:
+			case SCE_CSS_EXTENDED_PSEUDOCLASS:
+			case SCE_CSS_EXTENDED_PSEUDOELEMENT:
 			case SCE_CSS_UNKNOWN_PSEUDOCLASS:
-				if (pseudoClasses.InList(s2))
+				if (op == ':' && opPrev != ':' && pseudoClasses.InList(s2))
 					sc.ChangeState(SCE_CSS_PSEUDOCLASS);
+				else if (opPrev == ':' && pseudoElements.InList(s2))
+					sc.ChangeState(SCE_CSS_PSEUDOELEMENT);
+				else if ((op == ':' || (op == '(' && lastState == SCE_CSS_EXTENDED_PSEUDOCLASS)) && opPrev != ':' && exPseudoClasses.InList(s2))
+					sc.ChangeState(SCE_CSS_EXTENDED_PSEUDOCLASS);
+				else if (opPrev == ':' && exPseudoElements.InList(s2))
+					sc.ChangeState(SCE_CSS_EXTENDED_PSEUDOELEMENT);
+				else
+					sc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS);
 				break;
 			case SCE_CSS_IMPORTANT:
 				if (strcmp(s2, "important") != 0)
@@ -219,7 +266,14 @@
 			}
 		}
 
-		if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID))
+		if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (
+			sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_ID ||
+			(sc.ch != '(' && sc.ch != ')' && ( /* This line of the condition makes it possible to extend pseudo-classes with parentheses */
+				sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT ||
+				sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT ||
+				sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS
+			))
+		))
 			sc.SetState(SCE_CSS_TAG);
 
 		if (sc.Match('/', '*')) {
@@ -228,7 +282,7 @@
 			sc.Forward();
 		} else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) {
 			sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING));
-		} else if (IsCssOperator(static_cast<char>(sc.ch))
+		} else if (IsCssOperator(sc.ch)
 			&& (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']')
 			&& (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!')
 			&& (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{')
@@ -237,6 +291,7 @@
 				lastState = sc.state;
 			sc.SetState(SCE_CSS_OPERATOR);
 			op = sc.ch;
+			opPrev = sc.chPrev;
 		}
 	}
 
@@ -294,9 +349,14 @@
 }
 
 static const char * const cssWordListDesc[] = {
-	"CSS1 Keywords",
-	"Pseudo classes",
-	"CSS2 Keywords",
+	"CSS1 Properties",
+	"Pseudo-classes",
+	"CSS2 Properties",
+	"CSS3 Properties",
+	"Pseudo-elements",
+	"Browser-Specific CSS Properties",
+	"Browser-Specific Pseudo-classes",
+	"Browser-Specific Pseudo-elements",
 	0
 };
 

Modified: trunk/plugins/editor/scintilla/LexCaml.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCaml.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCaml.cxx	Sat Nov 15 17:50:33 2008
@@ -42,6 +42,10 @@
 	0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16	/* M - X */
 };
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #ifdef BUILD_AS_EXTERNAL_LEXER
 /*
 	(actually seems to work!)

Added: trunk/plugins/editor/scintilla/LexCmake.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexCmake.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,456 @@
+// Scintilla source code edit control
+/** @file LexCmake.cxx
+ ** Lexer for Cmake
+ **/
+// Copyright 2007 by Cristian Adam <cristian [dot] adam [at] gmx [dot] net>
+// based on the NSIS lexer
+// The License.txt file describes the conditions under which this software may be distributed.
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static bool isCmakeNumber(char ch)
+{
+    return(ch >= '0' && ch <= '9');
+}
+
+static bool isCmakeChar(char ch)
+{
+    return(ch == '.' ) || (ch == '_' ) || isCmakeNumber(ch) || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
+}
+
+static bool isCmakeLetter(char ch)
+{
+    return(ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
+}
+
+static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler)
+{
+    int nNextLine = -1;
+    for ( unsigned int i = start; i < end; i++ ) {
+        char cNext = styler.SafeGetCharAt( i );
+        if ( cNext == '\n' ) {
+            nNextLine = i+1;
+            break;
+        }
+    }
+
+    if ( nNextLine == -1 ) // We never foudn the next line...
+        return false;
+
+    for ( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ ) {
+        char cNext = styler.SafeGetCharAt( firstChar );
+        if ( cNext == ' ' )
+            continue;
+        if ( cNext == '\t' )
+            continue;
+        if ( styler.Match(firstChar, "ELSE")  || styler.Match(firstChar, "else"))
+            return true;
+        break;
+    }
+
+    return false;
+}
+
+static int calculateFoldCmake(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse)
+{
+    // If the word is too long, it is not what we are looking for
+    if ( end - start > 20 )
+        return foldlevel;
+
+    int newFoldlevel = foldlevel;
+
+    char s[20]; // The key word we are looking for has atmost 13 characters
+    for (unsigned int i = 0; i < end - start + 1 && i < 19; i++) {
+        s[i] = static_cast<char>( styler[ start + i ] );
+        s[i + 1] = '\0';
+    }
+
+    if ( CompareCaseInsensitive(s, "IF") == 0 || CompareCaseInsensitive(s, "WHILE") == 0
+         || CompareCaseInsensitive(s, "MACRO") == 0 || CompareCaseInsensitive(s, "FOREACH") == 0
+         || CompareCaseInsensitive(s, "ELSEIF") == 0 )
+        newFoldlevel++;
+    else if ( CompareCaseInsensitive(s, "ENDIF") == 0 || CompareCaseInsensitive(s, "ENDWHILE") == 0
+              || CompareCaseInsensitive(s, "ENDMACRO") == 0 || CompareCaseInsensitive(s, "ENDFOREACH") == 0)
+        newFoldlevel--;
+    else if ( bElse && CompareCaseInsensitive(s, "ELSEIF") == 0 )
+        newFoldlevel++;
+    else if ( bElse && CompareCaseInsensitive(s, "ELSE") == 0 )
+        newFoldlevel++;
+
+    return newFoldlevel;
+}
+
+static int classifyWordCmake(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler )
+{
+    char word[100] = {0};
+    char lowercaseWord[100] = {0};
+
+    WordList &Commands = *keywordLists[0];
+    WordList &Parameters = *keywordLists[1];
+    WordList &UserDefined = *keywordLists[2];
+
+    for (unsigned int i = 0; i < end - start + 1 && i < 99; i++) {
+        word[i] = static_cast<char>( styler[ start + i ] );
+        lowercaseWord[i] = static_cast<char>(tolower(word[i]));
+    }
+
+    // Check for special words...
+    if ( CompareCaseInsensitive(word, "MACRO") == 0 || CompareCaseInsensitive(word, "ENDMACRO") == 0 )
+        return SCE_CMAKE_MACRODEF;
+
+    if ( CompareCaseInsensitive(word, "IF") == 0 ||  CompareCaseInsensitive(word, "ENDIF") == 0 )
+        return SCE_CMAKE_IFDEFINEDEF;
+
+    if ( CompareCaseInsensitive(word, "ELSEIF") == 0  || CompareCaseInsensitive(word, "ELSE") == 0 )
+        return SCE_CMAKE_IFDEFINEDEF;
+
+    if ( CompareCaseInsensitive(word, "WHILE") == 0 || CompareCaseInsensitive(word, "ENDWHILE") == 0)
+        return SCE_CMAKE_WHILEDEF;
+
+    if ( CompareCaseInsensitive(word, "FOREACH") == 0 || CompareCaseInsensitive(word, "ENDFOREACH") == 0)
+        return SCE_CMAKE_FOREACHDEF;
+
+    if ( Commands.InList(lowercaseWord) )
+        return SCE_CMAKE_COMMANDS;
+
+    if ( Parameters.InList(word) )
+        return SCE_CMAKE_PARAMETERS;
+
+
+    if ( UserDefined.InList(word) )
+        return SCE_CMAKE_USERDEFINED;
+
+    if ( strlen(word) > 3 ) {
+        if ( word[1] == '{' && word[strlen(word)-1] == '}' )
+            return SCE_CMAKE_VARIABLE;
+    }
+
+    // To check for numbers
+    if ( isCmakeNumber( word[0] ) ) {
+        bool bHasSimpleCmakeNumber = true;
+        for (unsigned int j = 1; j < end - start + 1 && j < 99; j++) {
+            if ( !isCmakeNumber( word[j] ) ) {
+                bHasSimpleCmakeNumber = false;
+                break;
+            }
+        }
+
+        if ( bHasSimpleCmakeNumber )
+            return SCE_CMAKE_NUMBER;
+    }
+
+    return SCE_CMAKE_DEFAULT;
+}
+
+static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
+{
+    int state = SCE_CMAKE_DEFAULT;
+    if ( startPos > 0 )
+        state = styler.StyleAt(startPos-1); // Use the style from the previous line, usually default, but could be commentbox
+
+    styler.StartAt( startPos );
+    styler.GetLine( startPos );
+
+    unsigned int nLengthDoc = startPos + length;
+    styler.StartSegment( startPos );
+
+    char cCurrChar;
+    bool bVarInString = false;
+    bool bClassicVarInString = false;
+
+    unsigned int i;
+    for ( i = startPos; i < nLengthDoc; i++ ) {
+        cCurrChar = styler.SafeGetCharAt( i );
+        char cNextChar = styler.SafeGetCharAt(i+1);
+
+        switch (state) {
+        case SCE_CMAKE_DEFAULT:
+            if ( cCurrChar == '#' ) { // we have a comment line
+                styler.ColourTo(i-1, state );
+                state = SCE_CMAKE_COMMENT;
+                break;
+            }
+            if ( cCurrChar == '"' ) {
+                styler.ColourTo(i-1, state );
+                state = SCE_CMAKE_STRINGDQ;
+                bVarInString = false;
+                bClassicVarInString = false;
+                break;
+            }
+            if ( cCurrChar == '\'' ) {
+                styler.ColourTo(i-1, state );
+                state = SCE_CMAKE_STRINGRQ;
+                bVarInString = false;
+                bClassicVarInString = false;
+                break;
+            }
+            if ( cCurrChar == '`' ) {
+                styler.ColourTo(i-1, state );
+                state = SCE_CMAKE_STRINGLQ;
+                bVarInString = false;
+                bClassicVarInString = false;
+                break;
+            }
+
+            // CMake Variable
+            if ( cCurrChar == '$' || isCmakeChar(cCurrChar)) {
+                styler.ColourTo(i-1,state);
+                state = SCE_CMAKE_VARIABLE;
+
+                // If it is a number, we must check and set style here first...
+                if ( isCmakeNumber(cCurrChar) && (cNextChar == '\t' || cNextChar == ' ' || cNextChar == '\r' || cNextChar == '\n' ) )
+                    styler.ColourTo( i, SCE_CMAKE_NUMBER);
+
+                break;
+            }
+
+            break;
+        case SCE_CMAKE_COMMENT:
+            if ( cNextChar == '\n' || cNextChar == '\r' ) {
+                // Special case:
+                if ( cCurrChar == '\\' ) {
+                    styler.ColourTo(i-2,state);
+                    styler.ColourTo(i,SCE_CMAKE_DEFAULT);
+                }
+                else {
+                    styler.ColourTo(i,state);
+                    state = SCE_CMAKE_DEFAULT;
+                }
+            }
+            break;
+        case SCE_CMAKE_STRINGDQ:
+        case SCE_CMAKE_STRINGLQ:
+        case SCE_CMAKE_STRINGRQ:
+
+            if ( styler.SafeGetCharAt(i-1) == '\\' && styler.SafeGetCharAt(i-2) == '$' )
+                break; // Ignore the next character, even if it is a quote of some sort
+
+            if ( cCurrChar == '"' && state == SCE_CMAKE_STRINGDQ ) {
+                styler.ColourTo(i,state);
+                state = SCE_CMAKE_DEFAULT;
+                break;
+            }
+
+            if ( cCurrChar == '`' && state == SCE_CMAKE_STRINGLQ ) {
+                styler.ColourTo(i,state);
+                state = SCE_CMAKE_DEFAULT;
+                break;
+            }
+
+            if ( cCurrChar == '\'' && state == SCE_CMAKE_STRINGRQ ) {
+                styler.ColourTo(i,state);
+                state = SCE_CMAKE_DEFAULT;
+                break;
+            }
+
+            if ( cNextChar == '\r' || cNextChar == '\n' ) {
+                int nCurLine = styler.GetLine(i+1);
+                int nBack = i;
+                // We need to check if the previous line has a \ in it...
+                bool bNextLine = false;
+
+                while ( nBack > 0 ) {
+                    if ( styler.GetLine(nBack) != nCurLine )
+                        break;
+
+                    char cTemp = styler.SafeGetCharAt(nBack, 'a'); // Letter 'a' is safe here
+
+                    if ( cTemp == '\\' ) {
+                        bNextLine = true;
+                        break;
+                    }
+                    if ( cTemp != '\r' && cTemp != '\n' && cTemp != '\t' && cTemp != ' ' )
+                        break;
+
+                    nBack--;
+                }
+
+                if ( bNextLine ) {
+                    styler.ColourTo(i+1,state);
+                }
+                if ( bNextLine == false ) {
+                    styler.ColourTo(i,state);
+                    state = SCE_CMAKE_DEFAULT;
+                }
+            }
+            break;
+
+        case SCE_CMAKE_VARIABLE:
+
+            // CMake Variable:
+            if ( cCurrChar == '$' )
+                state = SCE_CMAKE_DEFAULT;
+            else if ( cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) )
+                state = SCE_CMAKE_DEFAULT;
+            else if ( (isCmakeChar(cCurrChar) && !isCmakeChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' ) {
+                state = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler );
+                styler.ColourTo( i, state);
+                state = SCE_CMAKE_DEFAULT;
+            }
+            else if ( !isCmakeChar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' ) {
+                if ( classifyWordCmake( styler.GetStartSegment(), i-1, keywordLists, styler) == SCE_CMAKE_NUMBER )
+                    styler.ColourTo( i-1, SCE_CMAKE_NUMBER );
+
+                state = SCE_CMAKE_DEFAULT;
+
+                if ( cCurrChar == '"' ) {
+                    state = SCE_CMAKE_STRINGDQ;
+                    bVarInString = false;
+                    bClassicVarInString = false;
+                }
+                else if ( cCurrChar == '`' ) {
+                    state = SCE_CMAKE_STRINGLQ;
+                    bVarInString = false;
+                    bClassicVarInString = false;
+                }
+                else if ( cCurrChar == '\'' ) {
+                    state = SCE_CMAKE_STRINGRQ;
+                    bVarInString = false;
+                    bClassicVarInString = false;
+                }
+                else if ( cCurrChar == '#' ) {
+                    state = SCE_CMAKE_COMMENT;
+                }
+            }
+            break;
+        }
+
+        if ( state == SCE_CMAKE_COMMENT) {
+            styler.ColourTo(i,state);
+        }
+        else if ( state == SCE_CMAKE_STRINGDQ || state == SCE_CMAKE_STRINGLQ || state == SCE_CMAKE_STRINGRQ ) {
+            bool bIngoreNextDollarSign = false;
+
+            if ( bVarInString && cCurrChar == '$' ) {
+                bVarInString = false;
+                bIngoreNextDollarSign = true;
+            }
+            else if ( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' || cNextChar == '"' || cNextChar == '`' || cNextChar == '\'' ) ) {
+                styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR);
+                bVarInString = false;
+                bIngoreNextDollarSign = false;
+            }
+
+            else if ( bVarInString && !isCmakeChar(cNextChar) ) {
+                int nWordState = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler);
+                if ( nWordState == SCE_CMAKE_VARIABLE )
+                    styler.ColourTo( i, SCE_CMAKE_STRINGVAR);
+                bVarInString = false;
+            }
+            // Covers "${TEST}..."
+            else if ( bClassicVarInString && cNextChar == '}' ) {
+                styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR);
+                bClassicVarInString = false;
+            }
+
+            // Start of var in string
+            if ( !bIngoreNextDollarSign && cCurrChar == '$' && cNextChar == '{' ) {
+                styler.ColourTo( i-1, state);
+                bClassicVarInString = true;
+                bVarInString = false;
+            }
+            else if ( !bIngoreNextDollarSign && cCurrChar == '$' ) {
+                styler.ColourTo( i-1, state);
+                bVarInString = true;
+                bClassicVarInString = false;
+            }
+        }
+    }
+
+    // Colourise remaining document
+    styler.ColourTo(nLengthDoc-1,state);
+}
+
+static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
+{
+    // No folding enabled, no reason to continue...
+    if ( styler.GetPropertyInt("fold") == 0 )
+        return;
+
+    bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1;
+
+    int lineCurrent = styler.GetLine(startPos);
+    unsigned int safeStartPos = styler.LineStart( lineCurrent );
+
+    bool bArg1 = true;
+    int nWordStart = -1;
+
+    int levelCurrent = SC_FOLDLEVELBASE;
+    if (lineCurrent > 0)
+        levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+    int levelNext = levelCurrent;
+
+    for (unsigned int i = safeStartPos; i < startPos + length; i++) {
+        char chCurr = styler.SafeGetCharAt(i);
+
+        if ( bArg1 ) {
+            if ( nWordStart == -1 && (isCmakeLetter(chCurr)) ) {
+                nWordStart = i;
+            }
+            else if ( isCmakeLetter(chCurr) == false && nWordStart > -1 ) {
+                int newLevel = calculateFoldCmake( nWordStart, i-1, levelNext, styler, foldAtElse);
+
+                if ( newLevel == levelNext ) {
+                    if ( foldAtElse ) {
+                        if ( CmakeNextLineHasElse(i, startPos + length, styler) )
+                            levelNext--;
+                    }
+                }
+                else
+                    levelNext = newLevel;
+                bArg1 = false;
+            }
+        }
+
+        if ( chCurr == '\n' ) {
+            if ( bArg1 && foldAtElse) {
+                if ( CmakeNextLineHasElse(i, startPos + length, styler) )
+                    levelNext--;
+            }
+
+            // If we are on a new line...
+            int levelUse = levelCurrent;
+            int lev = levelUse | levelNext << 16;
+            if (levelUse < levelNext )
+                lev |= SC_FOLDLEVELHEADERFLAG;
+            if (lev != styler.LevelAt(lineCurrent))
+                styler.SetLevel(lineCurrent, lev);
+
+            lineCurrent++;
+            levelCurrent = levelNext;
+            bArg1 = true; // New line, lets look at first argument again
+            nWordStart = -1;
+        }
+    }
+
+    int levelUse = levelCurrent;
+    int lev = levelUse | levelNext << 16;
+    if (levelUse < levelNext)
+        lev |= SC_FOLDLEVELHEADERFLAG;
+    if (lev != styler.LevelAt(lineCurrent))
+        styler.SetLevel(lineCurrent, lev);
+}
+
+static const char * const cmakeWordLists[] = {
+    "Commands",
+    "Parameters",
+    "UserDefined",
+    0,
+    0,};
+
+LexerModule lmCmake(SCLEX_CMAKE, ColouriseCmakeDoc, "cmake", FoldCmakeDoc, cmakeWordLists);

Modified: trunk/plugins/editor/scintilla/LexConf.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexConf.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexConf.cxx	Sat Nov 15 17:50:33 2008
@@ -23,6 +23,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
 {
 	int state = SCE_CONF_DEFAULT;

Modified: trunk/plugins/editor/scintilla/LexCrontab.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCrontab.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCrontab.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList
 *keywordLists[], Accessor &styler)
 {

Modified: trunk/plugins/editor/scintilla/LexCsound.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexCsound.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexCsound.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '.' ||

Added: trunk/plugins/editor/scintilla/LexD.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexD.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,358 @@
+/** @file LexD.cxx
+ ** Lexer for D.
+ **
+ ** Copyright (c) 2006 by Waldemar Augustyn <waldemar wdmsys com>
+ **/
+// Copyright 1998-2005 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+/*/ Nested comments require keeping the value of the nesting level for every
+    position in the document.  But since scintilla always styles line by line,
+    we only need to store one value per line. The non-negative number indicates
+    nesting level at the end of the line.
+/*/
+
+// We use custom qualifiers since it is not clear what D allows.
+
+static bool IsWordStart(int ch) {
+	return isascii(ch) && (isalpha(ch) || ch == '_');
+}
+
+static bool IsWord(int ch) {
+	return isascii(ch) && (isalnum(ch) || ch == '_');
+}
+
+static bool IsDoxygen(int ch) {
+	if (isascii(ch) && islower(ch))
+		return true;
+	if (ch == '$' || ch == '@' || ch == '\\' ||
+		ch == '&' || ch == '#' || ch == '<' || ch == '>' ||
+		ch == '{' || ch == '}' || ch == '[' || ch == ']')
+		return true;
+	return false;
+}
+
+
+static void ColouriseDoc(unsigned int startPos, int length, int initStyle, 
+    WordList *keywordlists[], Accessor &styler, bool caseSensitive) {
+
+    WordList &keywords = *keywordlists[0];
+    WordList &keywords2 = *keywordlists[1];
+    WordList &keywords3 = *keywordlists[2];
+    WordList &keywords4 = *keywordlists[3];
+
+    int styleBeforeDCKeyword = SCE_D_DEFAULT;
+
+    StyleContext sc(startPos, length, initStyle, styler);
+
+    int curLine = styler.GetLine(startPos);
+    int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
+
+    for (; sc.More(); sc.Forward()) {
+
+        if (sc.atLineStart) {
+            if (sc.state == SCE_D_STRING) {
+                // Prevent SCE_D_STRINGEOL from leaking back to previous line which
+                // ends with a line continuation by locking in the state upto this position.
+                sc.SetState(SCE_D_STRING);
+            }
+            curLine = styler.GetLine(sc.currentPos);
+            styler.SetLineState(curLine, curNcLevel);
+        }
+
+        // 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();
+                }
+                continue;
+            }
+        }
+
+        // Determine if the current state should terminate.
+        switch (sc.state) {
+            case SCE_D_OPERATOR:
+                sc.SetState(SCE_D_DEFAULT);
+                break;
+            case SCE_D_NUMBER:
+                // We accept almost anything because of hex. and number suffixes
+                if (!IsWord(sc.ch) && sc.ch != '.') {
+                    sc.SetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_IDENTIFIER:
+                if (!IsWord(sc.ch)) {
+                    char s[1000];
+                    if (caseSensitive) {
+                        sc.GetCurrent(s, sizeof(s));
+                    } else {
+                        sc.GetCurrentLowered(s, sizeof(s));
+                    }
+                    if (keywords.InList(s)) {
+                        sc.ChangeState(SCE_D_WORD);
+                    } else if (keywords2.InList(s)) {
+                        sc.ChangeState(SCE_D_WORD2);
+                    } else if (keywords4.InList(s)) {
+                        sc.ChangeState(SCE_D_TYPEDEF);
+                    }
+                    sc.SetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_COMMENT:
+                if (sc.Match('*', '/')) {
+                    sc.Forward();
+                    sc.ForwardSetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_COMMENTDOC:
+                if (sc.Match('*', '/')) {
+                    sc.Forward();
+                    sc.ForwardSetState(SCE_D_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_D_COMMENTDOC;
+                        sc.SetState(SCE_D_COMMENTDOCKEYWORD);
+                    }
+                }
+                break;
+            case SCE_D_COMMENTLINE:
+                if (sc.atLineStart) {
+                    sc.SetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_COMMENTLINEDOC:
+                if (sc.atLineStart) {
+                    sc.SetState(SCE_D_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_D_COMMENTLINEDOC;
+                        sc.SetState(SCE_D_COMMENTDOCKEYWORD);
+                    }
+                }
+                break;
+            case SCE_D_COMMENTDOCKEYWORD:
+                if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) {
+                    sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR);
+                    sc.Forward();
+                    sc.ForwardSetState(SCE_D_DEFAULT);
+                } else if (!IsDoxygen(sc.ch)) {
+                    char s[100];
+                    if (caseSensitive) {
+                        sc.GetCurrent(s, sizeof(s));
+                    } else {
+                        sc.GetCurrentLowered(s, sizeof(s));
+                    }
+                    if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
+                        sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR);
+                    }
+                    sc.SetState(styleBeforeDCKeyword);
+                }
+                break;
+            case SCE_D_COMMENTNESTED:
+                if (sc.Match('+', '/')) {
+                    if (curNcLevel > 0)
+                        curNcLevel -= 1;
+                    curLine = styler.GetLine(sc.currentPos);
+                    styler.SetLineState(curLine, curNcLevel);
+                    sc.Forward();
+                    if (curNcLevel == 0) {
+                        sc.ForwardSetState(SCE_D_DEFAULT);
+		    }
+                }
+                else if (sc.Match('/','+')) {
+                    curNcLevel += 1;
+                    curLine = styler.GetLine(sc.currentPos);
+                    styler.SetLineState(curLine, curNcLevel);
+                    sc.Forward();
+                }
+                break;
+            case SCE_D_STRING:
+                if (sc.atLineEnd) {
+                    sc.ChangeState(SCE_D_STRINGEOL);
+                } else if (sc.ch == '\\') {
+                    if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                        sc.Forward();
+                    }
+                } else if (sc.ch == '\"') {
+                    sc.ForwardSetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_CHARACTER:
+                if (sc.atLineEnd) {
+                    sc.ChangeState(SCE_D_STRINGEOL);
+                } else if (sc.ch == '\\') {
+                    if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+                        sc.Forward();
+                    }
+                } else if (sc.ch == '\'') {
+                    sc.ForwardSetState(SCE_D_DEFAULT);
+                }
+                break;
+            case SCE_D_STRINGEOL:
+                if (sc.atLineStart) {
+                    sc.SetState(SCE_D_DEFAULT);
+                }
+                break;
+        }
+
+        // Determine if a new state should be entered.
+        if (sc.state == SCE_D_DEFAULT) {
+            if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+                    sc.SetState(SCE_D_NUMBER);
+            } else if (IsWordStart(sc.ch)) {
+                    sc.SetState(SCE_D_IDENTIFIER);
+            } else if (sc.Match('/','+')) {
+                curNcLevel += 1;
+		curLine = styler.GetLine(sc.currentPos);
+                styler.SetLineState(curLine, curNcLevel);
+                sc.SetState(SCE_D_COMMENTNESTED);
+                sc.Forward();
+            } else if (sc.Match('/', '*')) {
+                if (sc.Match("/**") || sc.Match("/*!")) {   // Support of Qt/Doxygen doc. style
+                    sc.SetState(SCE_D_COMMENTDOC);
+                } else {
+                    sc.SetState(SCE_D_COMMENT);
+                }
+                sc.Forward();   // Eat the * so it isn't used for the end of the comment
+            } else if (sc.Match('/', '/')) {
+                if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!"))
+                    // Support of Qt/Doxygen doc. style
+                    sc.SetState(SCE_D_COMMENTLINEDOC);
+                else
+                    sc.SetState(SCE_D_COMMENTLINE);
+            } else if (sc.ch == '\"') {
+                sc.SetState(SCE_D_STRING);
+            } else if (sc.ch == '\'') {
+                sc.SetState(SCE_D_CHARACTER);
+            } else if (isoperator(static_cast<char>(sc.ch))) {
+                sc.SetState(SCE_D_OPERATOR);
+            }
+        }
+    }
+    sc.Complete();
+}
+
+static bool IsStreamCommentStyle(int style) {
+    return style == SCE_D_COMMENT ||
+        style == SCE_D_COMMENTDOC ||
+        style == SCE_D_COMMENTDOCKEYWORD ||
+        style == SCE_D_COMMENTDOCKEYWORDERROR;
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment
+// and to make it possible to fiddle the current level for "} else {".
+static void FoldDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) {
+    bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+    bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+    bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else",
+		styler.GetPropertyInt("fold.at.else", 0)) != 0;
+    unsigned int endPos = startPos + length;
+    int visibleChars = 0;
+    int lineCurrent = styler.GetLine(startPos);
+    int levelCurrent = SC_FOLDLEVELBASE;
+    if (lineCurrent > 0)
+        levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+    int levelMinCurrent = levelCurrent;
+    int levelNext = levelCurrent;
+    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 && IsStreamCommentStyle(style)) {
+            if (!IsStreamCommentStyle(stylePrev)) {
+                levelNext++;
+            } else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+                // Comments don't end at end of line and the next character may be unstyled.
+                levelNext--;
+            }
+        }
+        if (style == SCE_D_OPERATOR) {
+            if (ch == '{') {
+                // Measure the minimum before a '{' to allow
+                // folding on "} else {"
+                if (levelMinCurrent > levelNext) {
+                    levelMinCurrent = levelNext;
+                }
+                levelNext++;
+            } else if (ch == '}') {
+                levelNext--;
+            }
+        }
+        if (atEOL) {
+            if (foldComment) {	// Handle nested comments
+		int nc;
+                nc =  styler.GetLineState(lineCurrent);
+                nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0;
+                levelNext += nc;
+	    }
+            int levelUse = levelCurrent;
+            if (foldAtElse) {
+                levelUse = levelMinCurrent;
+            }
+            int lev = levelUse | levelNext << 16;
+            if (visibleChars == 0 && foldCompact)
+                lev |= SC_FOLDLEVELWHITEFLAG;
+            if (levelUse < levelNext)
+                lev |= SC_FOLDLEVELHEADERFLAG;
+            if (lev != styler.LevelAt(lineCurrent)) {
+                styler.SetLevel(lineCurrent, lev);
+            }
+            lineCurrent++;
+            levelCurrent = levelNext;
+            levelMinCurrent = levelCurrent;
+            visibleChars = 0;
+        }
+        if (!IsASpace(ch))
+            visibleChars++;
+    }
+}
+
+static void FoldDDoc(unsigned int startPos, int length, int initStyle,
+    WordList *[], Accessor &styler) {
+        FoldDoc(startPos, length, initStyle, styler);
+}
+
+static const char * const dWordLists[] = {
+            "Primary keywords and identifiers",
+            "Secondary keywords and identifiers",
+            "Documentation comment keywords",
+            "Type definitions and aliases",
+            0,
+        };
+
+static void ColouriseDDoc(unsigned int startPos, int length, 
+    int initStyle, WordList *keywordlists[], Accessor &styler) {
+        ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true);
+}
+
+LexerModule lmD(SCLEX_D, ColouriseDDoc, "d", FoldDDoc, dWordLists);

Modified: trunk/plugins/editor/scintilla/LexEScript.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexEScript.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexEScript.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 
 static inline bool IsAWordChar(const int ch) {

Modified: trunk/plugins/editor/scintilla/LexEiffel.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexEiffel.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexEiffel.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool isEiffelOperator(unsigned int ch) {
 	// '.' left out as it is used to make up numbers
 	return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||

Modified: trunk/plugins/editor/scintilla/LexErlang.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexErlang.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexErlang.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
    TODO:
    o  _Param should be a new lexical type

Modified: trunk/plugins/editor/scintilla/LexFlagship.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexFlagship.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexFlagship.cxx	Sat Nov 15 17:50:33 2008
@@ -22,6 +22,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static bool IsFlagShipComment(Accessor &styler, int pos, int len) {
 	return len>0 && styler[pos]=='\'';
 }

Modified: trunk/plugins/editor/scintilla/LexForth.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexForth.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexForth.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 bool is_whitespace(int ch){
     return ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ';
 }

Modified: trunk/plugins/editor/scintilla/LexFortran.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexFortran.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexFortran.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,11 @@
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /***********************************************/
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%');
@@ -79,7 +84,15 @@
 		int toLineStart = sc.currentPos - posLineStart;
 		if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) {
 			if (toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') {
-				sc.SetState(SCE_F_COMMENT);
+                if (sc.MatchIgnoreCase("cdec$") || sc.MatchIgnoreCase("*dec$") || sc.MatchIgnoreCase("!dec$") ||
+                    sc.MatchIgnoreCase("cdir$") || sc.MatchIgnoreCase("*dir$") || sc.MatchIgnoreCase("!dir$") ||
+                    sc.MatchIgnoreCase("cms$")  || sc.MatchIgnoreCase("*ms$")  || sc.MatchIgnoreCase("!ms$")  ||
+                    sc.chNext == '$') {
+                    sc.SetState(SCE_F_PREPROCESSOR);
+				} else {
+					sc.SetState(SCE_F_COMMENT);
+				}
+
 				while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end
 			} else if (toLineStart > 72) {
 				sc.SetState(SCE_F_COMMENT);
@@ -193,7 +206,8 @@
 		// Determine if a new state should be entered.
 		if (sc.state == SCE_F_DEFAULT) {
 			if (sc.ch == '!') {
-				if (sc.chNext == '$') {
+                if (sc.MatchIgnoreCase("!dec$") || sc.MatchIgnoreCase("!dir$") ||
+                    sc.MatchIgnoreCase("!ms$") || sc.chNext == '$') {
 					sc.SetState(SCE_F_PREPROCESSOR);
 				} else {
 					sc.SetState(SCE_F_COMMENT);

Added: trunk/plugins/editor/scintilla/LexGAP.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexGAP.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,263 @@
+// Scintilla source code edit control
+/** @file LexGAP.cxx
+ ** Lexer for the GAP language. (The GAP System for Computational Discrete Algebra)
+ ** http://www.gap-system.org
+ **/
+// Copyright 2007 by Istvan Szollosi ( szteven <at> gmail <dot> com )
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsGAPOperator(char ch) {
+	if (isalnum(ch)) return false;
+	if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
+		ch == '^' || ch == ',' || ch == '!' || ch == '.' ||
+		ch == '=' || ch == '<' || ch == '>' || ch == '(' ||
+		ch == ')' || ch == ';' || ch == '[' || ch == ']' ||
+		ch == '{' || ch == '}' || ch == ':' )
+		return true;
+	return false;
+}
+
+static void GetRange(unsigned int start, unsigned int end, Accessor &styler, char *s, unsigned int len) {
+	unsigned int i = 0;
+	while ((i < end - start + 1) && (i < len-1)) {
+		s[i] = static_cast<char>(styler[start + i]);
+		i++;
+	}
+	s[i] = '\0';
+}
+
+static void ColouriseGAPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
+
+	WordList &keywords1 = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+	WordList &keywords3 = *keywordlists[2];
+	WordList &keywords4 = *keywordlists[3];
+
+	// Do not leak onto next line
+	if (initStyle == SCE_GAP_STRINGEOL) initStyle = SCE_GAP_DEFAULT;
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		// Prevent SCE_GAP_STRINGEOL from leaking back to previous line
+		if ( sc.atLineStart ) {
+			if (sc.state == SCE_GAP_STRING) sc.SetState(SCE_GAP_STRING);
+			if (sc.state == SCE_GAP_CHAR) sc.SetState(SCE_GAP_CHAR);
+		}
+
+		// 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();
+				}
+				continue;
+			}
+		}
+
+		// Determine if the current state should terminate
+		switch (sc.state) {
+			case SCE_GAP_OPERATOR :
+				sc.SetState(SCE_GAP_DEFAULT);
+				break;
+
+			case SCE_GAP_NUMBER :
+				if (!IsADigit(sc.ch)) {
+					if (sc.ch == '\\') {
+						if (!sc.atLineEnd) {
+							if (!IsADigit(sc.chNext)) {
+								sc.Forward();
+								sc.ChangeState(SCE_GAP_IDENTIFIER);
+							}
+						}
+					} else if (isalpha(sc.ch) || sc.ch == '_') {
+						sc.ChangeState(SCE_GAP_IDENTIFIER);
+					}
+					else sc.SetState(SCE_GAP_DEFAULT);
+				}
+				break;
+
+			case SCE_GAP_IDENTIFIER :
+				if (!(iswordstart(static_cast<char>(sc.ch)) || sc.ch == '$')) {
+					if (sc.ch == '\\') sc.Forward();
+					else {
+						char s[1000];
+						sc.GetCurrent(s, sizeof(s));
+						if (keywords1.InList(s)) {
+							sc.ChangeState(SCE_GAP_KEYWORD);
+						} else if (keywords2.InList(s)) {
+							sc.ChangeState(SCE_GAP_KEYWORD2);
+						} else if (keywords3.InList(s)) {
+							sc.ChangeState(SCE_GAP_KEYWORD3);
+						} else if (keywords4.InList(s)) {
+							sc.ChangeState(SCE_GAP_KEYWORD4);
+						}
+						sc.SetState(SCE_GAP_DEFAULT);
+					}
+				}
+				break;
+
+			case SCE_GAP_COMMENT :
+				if (sc.atLineEnd) {
+					sc.SetState(SCE_GAP_DEFAULT);
+				}
+				break;
+
+			case SCE_GAP_STRING:
+				if (sc.atLineEnd) {
+					sc.ChangeState(SCE_GAP_STRINGEOL);
+				} else if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\"') {
+					sc.ForwardSetState(SCE_GAP_DEFAULT);
+				}
+				break;
+
+			case SCE_GAP_CHAR:
+				if (sc.atLineEnd) {
+					sc.ChangeState(SCE_GAP_STRINGEOL);
+				} else if (sc.ch == '\\') {
+					if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+						sc.Forward();
+					}
+				} else if (sc.ch == '\'') {
+					sc.ForwardSetState(SCE_GAP_DEFAULT);
+				}
+				break;
+
+			case SCE_GAP_STRINGEOL:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_GAP_DEFAULT);
+				}
+				break;
+		}
+
+		// Determine if a new state should be entered
+		if (sc.state == SCE_GAP_DEFAULT) {
+			if (IsGAPOperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_GAP_OPERATOR);
+			}
+			else if (IsADigit(sc.ch)) {
+				sc.SetState(SCE_GAP_NUMBER);
+			} else if (isalpha(sc.ch) || sc.ch == '_' || sc.ch == '\\' || sc.ch == '$' || sc.ch == '~') {
+				sc.SetState(SCE_GAP_IDENTIFIER);
+				if (sc.ch == '\\') sc.Forward();
+			} else if (sc.ch == '#') {
+				sc.SetState(SCE_GAP_COMMENT);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_GAP_STRING);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_GAP_CHAR);
+			}
+		}
+
+	}
+	sc.Complete();
+}
+
+static int ClassifyFoldPointGAP(const char* s) {
+	int level = 0;
+	if (strcmp(s, "function") == 0 ||
+		strcmp(s, "do") == 0 ||
+		strcmp(s, "if") == 0 ||
+		strcmp(s, "repeat") == 0 ) {
+		level = 1;
+	} else if (strcmp(s, "end") == 0 ||
+			strcmp(s, "od") == 0 ||
+			strcmp(s, "fi") == 0 ||
+			strcmp(s, "until") == 0 ) {
+		level = -1;
+	}
+	return level;
+}
+
+static void FoldGAPDoc( unsigned int startPos, int length, int initStyle,   WordList** , Accessor &styler) {
+	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;
+
+	int lastStart = 0;
+
+	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 (stylePrev != SCE_GAP_KEYWORD && style == SCE_GAP_KEYWORD) {
+			// Store last word start point.
+			lastStart = i;
+		}
+
+		if (stylePrev == SCE_GAP_KEYWORD) {
+			if(iswordchar(ch) && !iswordchar(chNext)) {
+				char s[100];
+				GetRange(lastStart, i, styler, s, sizeof(s));
+				levelCurrent += ClassifyFoldPointGAP(s);
+			}
+		}
+
+		if (atEOL) {
+			int lev = levelPrev;
+			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++;
+	}
+
+	int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+	styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const GAPWordListDesc[] = {
+	"Keywords 1",
+	"Keywords 2",
+	"Keywords 3 (unused)",
+	"Keywords 4 (unused)",
+	0
+};
+
+LexerModule lmGAP(
+   SCLEX_GAP,
+   ColouriseGAPDoc,
+   "gap",
+   FoldGAPDoc,
+   GAPWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexGui4Cli.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexGui4Cli.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexGui4Cli.cxx	Sat Nov 15 17:50:33 2008
@@ -36,6 +36,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #define debug Platform::DebugPrintf
 
 static inline bool IsAWordChar(const int ch) {

Modified: trunk/plugins/editor/scintilla/LexHTML.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexHTML.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexHTML.cxx	Sat Nov 15 17:50:33 2008
@@ -19,12 +19,17 @@
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+#include "CharacterSet.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 #define SCE_HA_JS (SCE_HJA_START - SCE_HJ_START)
 #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
 #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
 
-enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
+enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock, eScriptComment };
 enum script_mode { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
 
 static inline bool IsAWordChar(const int ch) {
@@ -35,6 +40,20 @@
 	return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
+inline bool IsOperator(int ch) {
+	if (isascii(ch) && isalnum(ch))
+		return false;
+	// '.' left out as it is used to make up numbers
+	if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
+	        ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
+	        ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
+	        ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
+	        ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
+	        ch == '?' || ch == '!' || ch == '.' || ch == '~')
+		return true;
+	return false;
+}
+
 static inline int MakeLowerCase(int ch) {
 	if (ch < 'A' || ch > 'Z')
 		return ch;
@@ -66,8 +85,15 @@
 		return eScriptJS;
 	if (strstr(s, "php"))
 		return eScriptPHP;
-	if (strstr(s, "xml"))
+	if (strstr(s, "xml")) {
+		const char *xml = strstr(s, "xml");
+		for (const char *t=s; t<xml; t++) {
+			if (!IsASpace(*t)) {
+				return prevValue;
+			}
+		}
 		return eScriptXML;
+	}
 
 	return prevValue;
 }
@@ -102,16 +128,16 @@
 }
 
 static int statePrintForState(int state, script_mode inScriptType) {
-	int StateToPrint;
+	int StateToPrint = state;
 
-	if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
-		StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON);
-	} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
-		StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS);
-	} else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
-		StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS);
-	} else {
-		StateToPrint = state;
+	if (state >= SCE_HJ_START) {
+		if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
+			StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON);
+		} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
+			StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS);
+		} else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
+			StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS);
+		}
 	}
 
 	return StateToPrint;
@@ -173,6 +199,7 @@
 	bool allowTermination = !isStringState(state);
 	if (allowTermination) {
 		switch (state) {
+		case SCE_HB_COMMENTLINE:
 		case SCE_HPHP_COMMENT:
 		case SCE_HP_COMMENTLINE:
 		case SCE_HPA_COMMENTLINE:
@@ -222,7 +249,7 @@
 
 static int classifyTagHTML(unsigned int start, unsigned int end,
                            WordList &keywords, Accessor &styler, bool &tagDontFold,
-			   bool caseSensitive) {
+			   bool caseSensitive, bool isXml, bool allowScripts) {
 	char s[30 + 2];
 	// Copy after the '<'
 	unsigned int i = 0;
@@ -238,33 +265,31 @@
 	s[i] = ' ';
 	s[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
-	// (There are many more. We will need a keywordlist in the property file for this)
-	tagDontFold = (NULL != strstr("meta link img area br hr input ",s));
+	tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ", s));
 
 	//now we can remove the trailing space
 	s[i] = '\0';
 
-	bool isScript = false;
+	// No keywords -> all are known
+	// Name of a closing tag starts at s + 1
 	char chAttr = SCE_H_TAGUNKNOWN;
 	if (s[0] == '!') {
 		chAttr = SCE_H_SGML_DEFAULT;
-	} else if (s[0] == '/') {	// Closing tag
-		if (keywords.InList(s + 1))
-			chAttr = SCE_H_TAG;
-	} else {
-		if (keywords.InList(s)) {
-			chAttr = SCE_H_TAG;
-			isScript = 0 == strcmp(s, "script");
-		}
-	}
-	if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords) {
-		// No keywords -> all are known
+	} else if (!keywords || keywords.InList(s[0] == '/' ? s + 1 : s)) {
 		chAttr = SCE_H_TAG;
-		isScript = 0 == strcmp(s, "script");
 	}
 	styler.ColourTo(end, chAttr);
-	return isScript ? SCE_H_SCRIPT : chAttr;
+	if (chAttr == SCE_H_TAG) {
+		if (allowScripts && 0 == strcmp(s, "script")) {
+			chAttr = SCE_H_SCRIPT;
+		} else if (!isXml && 0 == strcmp(s, "comment")) {
+			chAttr = SCE_H_COMMENT;
+		}
+	}
+	return chAttr;
 }
 
 static void classifyWordHTJS(unsigned int start, unsigned int end,
@@ -383,6 +408,9 @@
 	case eScriptSGML:
 		Result = SCE_H_SGML_DEFAULT;
 		break;
+	case eScriptComment:
+		Result = SCE_H_COMMENT;
+		break;
 	default :
 		Result = SCE_HJ_START;
 		break;
@@ -390,21 +418,21 @@
 	return Result;
 }
 
-static inline bool ishtmlwordchar(char ch) {
+static inline bool ishtmlwordchar(int ch) {
 	return !isascii(ch) ||
 		(isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#');
 }
 
-static inline bool issgmlwordchar(char ch) {
+static inline bool issgmlwordchar(int ch) {
 	return !isascii(ch) ||
 		(isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[');
 }
 
-static inline bool IsPhpWordStart(const unsigned char ch) {
+static inline bool IsPhpWordStart(int ch) {
 	return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f);
 }
 
-static inline bool IsPhpWordChar(char ch) {
+static inline bool IsPhpWordChar(int ch) {
 	return IsADigit(ch) || IsPhpWordStart(ch);
 }
 
@@ -425,11 +453,11 @@
 		   state == SCE_HJA_COMMENTLINE || state == SCE_HB_COMMENTLINE || state == SCE_HBA_COMMENTLINE;
 }
 
-static bool isLineEnd(char ch) {
+static bool isLineEnd(int ch) {
 	return ch == '\r' || ch == '\n';
 }
 
-static bool isOKBeforeRE(char ch) {
+static bool isOKBeforeRE(int ch) {
 	return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
@@ -441,23 +469,55 @@
 	    (state == SCE_HPHP_COMPLEX_VARIABLE);
 }
 
-static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, int i, const int lengthDoc, Accessor &styler) {
+static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, int i, const int lengthDoc, Accessor &styler, bool &isSimpleString) {
 	int j;
+	const int beginning = i - 1;
+	bool isValidSimpleString = false;
+
 	while (i < lengthDoc && (styler[i] == ' ' || styler[i] == '\t'))
 		i++;
-	phpStringDelimiter[0] = '\n';
-	for (j = i; j < lengthDoc && styler[j] != '\n' && styler[j] != '\r'; j++) {
+
+	char ch = styler.SafeGetCharAt(i);
+	const char chNext = styler.SafeGetCharAt(i + 1);
+	if (!IsPhpWordStart(ch)) {
+		if (ch == '\'' && IsPhpWordStart(chNext)) {
+			i++;
+			ch = chNext;
+			isSimpleString = true;
+		} else {
+			phpStringDelimiter[0] = '\0';
+			return beginning;
+		}
+	}
+	phpStringDelimiter[0] = ch;
+	i++;
+
+	for (j = i; j < lengthDoc && !isLineEnd(styler[j]); j++) {
+		if (!IsPhpWordChar(styler[j])) {
+			if (isSimpleString && (styler[j] == '\'') && isLineEnd(styler.SafeGetCharAt(j + 1))) {
+				isValidSimpleString = true;
+				j++;
+				break;
+			} else {
+				phpStringDelimiter[0] = '\0';
+				return beginning;
+			}
+		}
 		if (j - i < phpStringDelimiterSize - 2)
 			phpStringDelimiter[j-i+1] = styler[j];
 		else
 			i++;
 	}
-	phpStringDelimiter[j-i+1] = '\0';
-	return j;
+	if (isSimpleString && !isValidSimpleString) {
+		phpStringDelimiter[0] = '\0';
+		return beginning;
+	}
+	phpStringDelimiter[j-i+1 - (isSimpleString ? 1 : 0)] = '\0';
+	return j - 1;
 }
 
 static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
-                                  Accessor &styler) {
+                                  Accessor &styler, bool isXml) {
 	WordList &keywords = *keywordlists[0];
 	WordList &keywords2 = *keywordlists[1];
 	WordList &keywords3 = *keywordlists[2];
@@ -465,8 +525,8 @@
 	WordList &keywords5 = *keywordlists[4];
 	WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
 
-	// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
-	styler.StartAt(startPos, STYLE_MAX);
+	// Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+	styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
 	char prevWord[200];
 	prevWord[0] = '\0';
 	char phpStringDelimiter[200]; // PHP is not limited in length, we are
@@ -482,13 +542,17 @@
 		}
 		state = SCE_H_DEFAULT;
 	}
-	// String can be heredoc, must find a delimiter first
-	while (startPos > 0 && isPHPStringState(state) && state != SCE_HPHP_SIMPLESTRING) {
-		startPos--;
-		length++;
-		state = styler.StyleAt(startPos);
+	// String can be heredoc, must find a delimiter first. Reread from beginning of line containing the string, to get the correct lineState
+	if (isPHPStringState(state)) {
+		while (startPos > 0 && (isPHPStringState(state) || !isLineEnd(styler[startPos - 1]))) {
+			startPos--;
+			length++;
+			state = styler.StyleAt(startPos);
+		}
+		if (startPos == 0)
+			state = SCE_H_DEFAULT;
 	}
-	styler.StartAt(startPos, STYLE_MAX);
+	styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
 
 	int lineCurrent = styler.GetLine(startPos);
 	int lineState;
@@ -508,20 +572,31 @@
 	int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
 
 	script_type scriptLanguage = ScriptOfState(state);
+	// If eNonHtmlScript coincides with SCE_H_COMMENT, assume eScriptComment
+	if (inScriptType == eNonHtmlScript && state == SCE_H_COMMENT) {
+		scriptLanguage = eScriptComment;
+	}
 
 	const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0;
 	const bool fold = foldHTML && styler.GetPropertyInt("fold", 0);
 	const bool foldHTMLPreprocessor = foldHTML && styler.GetPropertyInt("fold.html.preprocessor", 1);
 	const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	const bool foldComment = fold && styler.GetPropertyInt("fold.hypertext.comment", 0) != 0;
+	const bool foldHeredoc = fold && styler.GetPropertyInt("fold.hypertext.heredoc", 0) != 0;
 	const bool caseSensitive = styler.GetPropertyInt("html.tags.case.sensitive", 0) != 0;
+	const bool allowScripts = styler.GetPropertyInt("lexer.xml.allow.scripts", 1) != 0;
+
+	const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
+	const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true);
+	const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true);
 
 	int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
 	int levelCurrent = levelPrev;
 	int visibleChars = 0;
 
-	char chPrev = ' ';
-	char ch = ' ';
-	char chPrevNonWhite = ' ';
+	int chPrev = ' ';
+	int ch = ' ';
+	int chPrevNonWhite = ' ';
 	// look back to set chPrevNonWhite properly for better regex colouring
 	if (scriptLanguage == eScriptJS && startPos > 0) {
 		int back = startPos;
@@ -533,30 +608,30 @@
 				break;
 		}
 		if (style == SCE_HJ_SYMBOLS) {
-			chPrevNonWhite = styler.SafeGetCharAt(back);
+			chPrevNonWhite = static_cast<unsigned char>(styler.SafeGetCharAt(back));
 		}
 	}
 
 	styler.StartSegment(startPos);
 	const int lengthDoc = startPos + length;
 	for (int i = startPos; i < lengthDoc; i++) {
-		const char chPrev2 = chPrev;
+		const int chPrev2 = chPrev;
 		chPrev = ch;
-		if (!isspacechar(ch) && state != SCE_HJ_COMMENT &&
+		if (!IsASpace(ch) && state != SCE_HJ_COMMENT &&
 			state != SCE_HJ_COMMENTLINE && state != SCE_HJ_COMMENTDOC)
 			chPrevNonWhite = ch;
-		ch = styler[i];
-		char chNext = styler.SafeGetCharAt(i + 1);
-		const char chNext2 = styler.SafeGetCharAt(i + 2);
+		ch = static_cast<unsigned char>(styler[i]);
+		int chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
+		const int chNext2 = static_cast<unsigned char>(styler.SafeGetCharAt(i + 2));
 
 		// Handle DBCS codepages
-		if (styler.IsLeadByte(ch)) {
+		if (styler.IsLeadByte(static_cast<char>(ch))) {
 			chPrev = ' ';
 			i += 1;
 			continue;
 		}
 
-		if ((!isspacechar(ch) || !foldCompact) && fold)
+		if ((!IsASpace(ch) || !foldCompact) && fold)
 			visibleChars++;
 
 		// decide what is the current state to print (depending of the script tag)
@@ -572,9 +647,11 @@
 				if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC) && (!isStringState(state))) {
 				//Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle);
 				//if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) {
-					if ((ch == '{') || (ch == '}')) {
-						levelCurrent += (ch == '{') ? 1 : -1;
+					if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*'))) {
+						levelCurrent += ((ch == '{') || (ch == '/')) ? 1 : -1;
 					}
+				} else if (((state == SCE_HPHP_COMMENT) || (state == SCE_HJ_COMMENT)) && foldComment && (ch == '*') && (chNext == '/')) {
+					levelCurrent--;
 				}
 				break;
 			case eScriptPython:
@@ -644,27 +721,32 @@
 			case SCE_HJ_COMMENTDOC:
 			//case SCE_HJ_COMMENTLINE: // removed as this is a common thing done to hide
 			// the end of script marker from some JS interpreters.
+			case SCE_HB_COMMENTLINE:
+			case SCE_HBA_COMMENTLINE:
 			case SCE_HJ_DOUBLESTRING:
 			case SCE_HJ_SINGLESTRING:
 			case SCE_HJ_REGEX:
 			case SCE_HB_STRING:
+			case SCE_HBA_STRING:
 			case SCE_HP_STRING:
 			case SCE_HP_TRIPLE:
 			case SCE_HP_TRIPLEDOUBLE:
+			case SCE_HPHP_HSTRING:
+			case SCE_HPHP_SIMPLESTRING:
+			case SCE_HPHP_COMMENT:
+			case SCE_HPHP_COMMENTLINE:
 				break;
 			default :
 				// check if the closing tag is a script tag
-				if (state == SCE_HJ_COMMENTLINE) {
-					char tag[7]; // room for the <script> tag
-					char chr;	// current char
-					int j=0;
-					chr = styler.SafeGetCharAt(i+2);
-					while (j < 6 && !isspacechar(chr)) {
-						tag[j++] = static_cast<char>(MakeLowerCase(chr));
-						chr = styler.SafeGetCharAt(i+2+j);
-					}
-					tag[j] = '\0';
-					if (strcmp(tag, "script") != 0) break;
+				if (const char *tag =
+						state == SCE_HJ_COMMENTLINE || isXml ? "script" :
+						state == SCE_H_COMMENT ? "comment" : 0) {
+					int j = i + 2;
+					int chr;
+					do {
+						chr = static_cast<int>(*tag++);
+					} while (chr != 0 && chr == MakeLowerCase(styler.SafeGetCharAt(j++)));
+					if (chr != 0) break;
 				}
 				// closing tag of the script (it's a closing HTML tag anyway)
 				styler.ColourTo(i - 1, StateToPrint);
@@ -687,13 +769,13 @@
 		         (ch == '<') &&
 		         (chNext == '?') &&
 				 !IsScriptCommentState(state) ) {
-			scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 10, eScriptPHP);
+			scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 6, eScriptPHP);
 			if (scriptLanguage != eScriptPHP && isStringState(state)) continue;
 			styler.ColourTo(i - 1, StateToPrint);
 			beforePreProc = state;
 			i++;
 			visibleChars++;
-			i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 10);
+			i += PrintScriptingIndicatorOffset(styler, styler.GetStartSegment() + 2, i + 6);
 			if (scriptLanguage == eScriptXML)
 				styler.ColourTo(i, SCE_H_XMLSTART);
 			else
@@ -708,7 +790,7 @@
 				levelCurrent++;
 			}
 			// should be better
-			ch = styler.SafeGetCharAt(i);
+			ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
 			continue;
 		}
 
@@ -747,7 +829,7 @@
 			if (foldHTMLPreprocessor)
 				levelCurrent++;
 			// should be better
-			ch = styler.SafeGetCharAt(i);
+			ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
 			continue;
 		}
 
@@ -862,7 +944,9 @@
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_H_SGML_SIMPLESTRING;
 			} else if ((ch == '-') && (chPrev == '-')) {
-				styler.ColourTo(i - 2, StateToPrint);
+				if (static_cast<int>(styler.GetStartSegment()) <= (i - 2)) {
+					styler.ColourTo(i - 2, StateToPrint);
+				}
 				state = SCE_H_SGML_COMMENT;
 			} else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) {
 				styler.ColourTo(i - 2, StateToPrint);
@@ -924,12 +1008,12 @@
 				}
 				// find the length of the word
 				int size = 1;
-				while (ishtmlwordchar(styler.SafeGetCharAt(i + size)))
+				while (setHTMLWord.Contains(static_cast<unsigned char>(styler.SafeGetCharAt(i + size))))
 					size++;
 				styler.ColourTo(i + size - 1, StateToPrint);
 				i += size - 1;
 				visibleChars += size - 1;
-				ch = styler.SafeGetCharAt(i);
+				ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
 				if (scriptLanguage == eScriptSGMLblock) {
 					state = SCE_H_SGML_BLOCK_DEFAULT;
 				} else {
@@ -969,7 +1053,7 @@
 			}
 			break;
 		case SCE_H_COMMENT:
-			if ((chPrev2 == '-') && (chPrev == '-') && (ch == '>')) {
+			if ((scriptLanguage != eScriptComment) && (chPrev2 == '-') && (chPrev == '-') && (ch == '>')) {
 				styler.ColourTo(i, StateToPrint);
 				state = SCE_H_DEFAULT;
 				levelCurrent--;
@@ -1012,18 +1096,17 @@
 			}
 			break;
 		case SCE_H_TAGUNKNOWN:
-			if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
+			if (!setTagContinue.Contains(ch) && !((ch == '/') && (chPrev == '<'))) {
 				int eClass = classifyTagHTML(styler.GetStartSegment(),
-					i - 1, keywords, styler, tagDontFold, caseSensitive);
-				if (eClass == SCE_H_SCRIPT) {
+					i - 1, keywords, styler, tagDontFold, caseSensitive, isXml, allowScripts);
+				if (eClass == SCE_H_SCRIPT || eClass == SCE_H_COMMENT) {
 					if (!tagClosing) {
 						inScriptType = eNonHtmlScript;
-						scriptLanguage = clientScript;
-						eClass = SCE_H_TAG;
+						scriptLanguage = eClass == SCE_H_SCRIPT ? clientScript : eScriptComment;
 					} else {
 						scriptLanguage = eScriptNone;
-						eClass = SCE_H_TAG;
 					}
+					eClass = SCE_H_TAG;
 				}
 				if (ch == '>') {
 					styler.ColourTo(i, eClass);
@@ -1033,7 +1116,7 @@
 						state = SCE_H_DEFAULT;
 					}
 					tagOpened = false;
-					if (!tagDontFold){
+					if (!tagDontFold) {
 						if (tagClosing) {
 							levelCurrent--;
 						} else {
@@ -1064,7 +1147,7 @@
 			}
 			break;
 		case SCE_H_ATTRIBUTE:
-			if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
+			if (!setAttributeContinue.Contains(ch)) {
 				if (inScriptType == eNonHtmlScript) {
 					int scriptLanguagePrev = scriptLanguage;
 					clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
@@ -1081,8 +1164,8 @@
 						state = SCE_H_DEFAULT;
 					}
 					tagOpened = false;
-					if (!tagDontFold){
-						if (tagClosing){
+					if (!tagDontFold) {
+						if (tagClosing) {
 							levelCurrent--;
 						} else {
 							levelCurrent++;
@@ -1107,8 +1190,8 @@
 					state = SCE_H_DEFAULT;
 				}
 				tagOpened = false;
-				if (!tagDontFold){
-					if (tagClosing){
+				if (!tagDontFold) {
+					if (tagClosing) {
 						levelCurrent--;
 					} else {
 						levelCurrent++;
@@ -1137,7 +1220,7 @@
 				i++;
 				ch = chNext;
 				state = SCE_H_DEFAULT;
-			} else if (ishtmlwordchar(ch)) {
+			} else if (setHTMLWord.Contains(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_H_ATTRIBUTE;
 			}
@@ -1161,7 +1244,7 @@
 			}
 			break;
 		case SCE_H_VALUE:
-			if (!ishtmlwordchar(ch)) {
+			if (!setHTMLWord.Contains(ch)) {
 				if (ch == '\"' && chPrev == '=') {
 					// Should really test for being first character
 					state = SCE_H_DOUBLESTRING;
@@ -1181,8 +1264,8 @@
 							state = SCE_H_DEFAULT;
 						}
 						tagOpened = false;
-						if (!tagDontFold){
-							if (tagClosing){
+						if (!tagDontFold) {
+							if (tagClosing) {
 								levelCurrent--;
 							} else {
 								levelCurrent++;
@@ -1198,7 +1281,7 @@
 		case SCE_HJ_DEFAULT:
 		case SCE_HJ_START:
 		case SCE_HJ_SYMBOLS:
-			if (iswordstart(ch)) {
+			if (IsAWordStart(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HJ_WORD;
 			} else if (ch == '/' && chNext == '*') {
@@ -1227,7 +1310,7 @@
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HJ_COMMENTLINE;
 				i += 2;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
 				state = SCE_HJ_DEFAULT;
@@ -1239,7 +1322,7 @@
 			}
 			break;
 		case SCE_HJ_WORD:
-			if (!iswordchar(ch)) {
+			if (!IsAWordChar(ch)) {
 				classifyWordHTJS(styler.GetStartSegment(), i - 1, keywords2, styler, inScriptType);
 				//styler.ColourTo(i - 1, eHTJSKeyword);
 				state = SCE_HJ_DEFAULT;
@@ -1258,7 +1341,7 @@
 					styler.ColourTo(i - 1, StateToPrint);
 					state = SCE_HJ_COMMENTLINE;
 					i += 2;
-				} else if (isoperator(ch)) {
+				} else if (IsOperator(ch)) {
 					styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
 					state = SCE_HJ_DEFAULT;
 				}
@@ -1328,7 +1411,7 @@
 					while (isascii(chNext) && islower(chNext)) {   // gobble regex flags
 						i++;
 						ch = chNext;
-						chNext = styler.SafeGetCharAt(i + 1);
+						chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 					}
 				}
 				styler.ColourTo(i, StateToPrint);
@@ -1338,13 +1421,13 @@
 				if (chNext == '\\' || chNext == '/') {
 					i++;
 					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
+					chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 				}
 			}
 			break;
 		case SCE_HB_DEFAULT:
 		case SCE_HB_START:
-			if (iswordstart(ch)) {
+			if (IsAWordStart(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HB_WORD;
 			} else if (ch == '\'') {
@@ -1357,7 +1440,7 @@
 			           styler.SafeGetCharAt(i + 3) == '-') {
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HB_COMMENTLINE;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType));
 				state = SCE_HB_DEFAULT;
@@ -1369,14 +1452,14 @@
 			}
 			break;
 		case SCE_HB_WORD:
-			if (!iswordchar(ch)) {
+			if (!IsAWordChar(ch)) {
 				state = classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType);
 				if (state == SCE_HB_DEFAULT) {
 					if (ch == '\"') {
 						state = SCE_HB_STRING;
 					} else if (ch == '\'') {
 						state = SCE_HB_COMMENTLINE;
-					} else if (isoperator(ch)) {
+					} else if (IsOperator(ch)) {
 						styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType));
 						state = SCE_HB_DEFAULT;
 					}
@@ -1409,7 +1492,7 @@
 			break;
 		case SCE_HP_DEFAULT:
 		case SCE_HP_START:
-			if (iswordstart(ch)) {
+			if (IsAWordStart(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HP_WORD;
 			} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
@@ -1426,7 +1509,7 @@
 					state = SCE_HP_TRIPLEDOUBLE;
 					ch = ' ';
 					chPrev = ' ';
-					chNext = styler.SafeGetCharAt(i + 1);
+					chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 				} else {
 					//					state = statePrintForState(SCE_HP_STRING,inScriptType);
 					state = SCE_HP_STRING;
@@ -1438,11 +1521,11 @@
 					state = SCE_HP_TRIPLE;
 					ch = ' ';
 					chPrev = ' ';
-					chNext = styler.SafeGetCharAt(i + 1);
+					chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 				} else {
 					state = SCE_HP_CHARACTER;
 				}
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i - 1, StateToPrint);
 				styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType));
 			} else if ((ch == ' ') || (ch == '\t')) {
@@ -1453,7 +1536,7 @@
 			}
 			break;
 		case SCE_HP_WORD:
-			if (!iswordchar(ch)) {
+			if (!IsAWordChar(ch)) {
 				classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
 				state = SCE_HP_DEFAULT;
 				if (ch == '#') {
@@ -1464,7 +1547,7 @@
 						state = SCE_HP_TRIPLEDOUBLE;
 						ch = ' ';
 						chPrev = ' ';
-						chNext = styler.SafeGetCharAt(i + 1);
+						chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 					} else {
 						state = SCE_HP_STRING;
 					}
@@ -1474,11 +1557,11 @@
 						state = SCE_HP_TRIPLE;
 						ch = ' ';
 						chPrev = ' ';
-						chNext = styler.SafeGetCharAt(i + 1);
+						chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 					} else {
 						state = SCE_HP_CHARACTER;
 					}
-				} else if (isoperator(ch)) {
+				} else if (IsOperator(ch)) {
 					styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType));
 				}
 			}
@@ -1494,7 +1577,7 @@
 				if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
 					i++;
 					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
+					chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 				}
 			} else if (ch == '\"') {
 				styler.ColourTo(i, StateToPrint);
@@ -1506,7 +1589,7 @@
 				if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
 					i++;
 					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
+					chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
 				}
 			} else if (ch == '\'') {
 				styler.ColourTo(i, StateToPrint);
@@ -1527,7 +1610,7 @@
 			break;
 			///////////// start - PHP state handling
 		case SCE_HPHP_WORD:
-			if (!iswordchar(ch)) {
+			if (!IsAWordChar(ch)) {
 				classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler);
 				if (ch == '/' && chNext == '*') {
 					i++;
@@ -1541,13 +1624,18 @@
 					state = SCE_HPHP_HSTRING;
 					strcpy(phpStringDelimiter, "\"");
 				} else if (styler.Match(i, "<<<")) {
-					state = SCE_HPHP_HSTRING;
-					i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler);
+					bool isSimpleString = false;
+					i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString);
+					if (strlen(phpStringDelimiter)) {
+						state = (isSimpleString ? SCE_HPHP_SIMPLESTRING : SCE_HPHP_HSTRING);
+						if (foldHeredoc) levelCurrent++;
+					}
 				} else if (ch == '\'') {
 					state = SCE_HPHP_SIMPLESTRING;
+					strcpy(phpStringDelimiter, "\'");
 				} else if (ch == '$' && IsPhpWordStart(chNext)) {
 					state = SCE_HPHP_VARIABLE;
-				} else if (isoperator(ch)) {
+				} else if (IsOperator(ch)) {
 					state = SCE_HPHP_OPERATOR;
 				} else {
 					state = SCE_HPHP_DEFAULT;
@@ -1560,19 +1648,16 @@
 				&& strchr(".xXabcdefABCDEF", ch) == NULL
 				&& ((ch != '-' && ch != '+') || (chPrev != 'e' && chPrev != 'E'))) {
 				styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
-				if (isoperator(ch))
+				if (IsOperator(ch))
 					state = SCE_HPHP_OPERATOR;
 				else
 					state = SCE_HPHP_DEFAULT;
 			}
 			break;
 		case SCE_HPHP_VARIABLE:
-			if (!IsPhpWordChar(ch)) {
-				styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
-				if (isoperator(ch))
-					state = SCE_HPHP_OPERATOR;
-				else
-					state = SCE_HPHP_DEFAULT;
+			if (!IsPhpWordChar(chNext)) {
+				styler.ColourTo(i, SCE_HPHP_VARIABLE);
+				state = SCE_HPHP_DEFAULT;
 			}
 			break;
 		case SCE_HPHP_COMMENT:
@@ -1599,25 +1684,48 @@
 				styler.ColourTo(i - 1, StateToPrint);
 				state = SCE_HPHP_HSTRING_VARIABLE;
 			} else if (styler.Match(i, phpStringDelimiter)) {
-				if (strlen(phpStringDelimiter) > 1)
-					i += strlen(phpStringDelimiter) - 1;
-				styler.ColourTo(i, StateToPrint);
-				state = SCE_HPHP_DEFAULT;
+				if (phpStringDelimiter[0] == '\"') {
+					styler.ColourTo(i, StateToPrint);
+					state = SCE_HPHP_DEFAULT;
+				} else if (isLineEnd(chPrev)) {
+				const int psdLength = strlen(phpStringDelimiter);
+					const char chAfterPsd = styler.SafeGetCharAt(i + psdLength);
+					const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1);
+					if (isLineEnd(chAfterPsd) ||
+						(chAfterPsd == ';' && isLineEnd(chAfterPsd2))) {
+							i += (((i + psdLength) < lengthDoc) ? psdLength : lengthDoc) - 1;
+						styler.ColourTo(i, StateToPrint);
+						state = SCE_HPHP_DEFAULT;
+						if (foldHeredoc) levelCurrent--;
+					}
+				}
 			}
 			break;
 		case SCE_HPHP_SIMPLESTRING:
-			if (ch == '\\') {
-				// skip the next char
-				i++;
-			} else if (ch == '\'') {
-				styler.ColourTo(i, StateToPrint);
-				state = SCE_HPHP_DEFAULT;
+			if (phpStringDelimiter[0] == '\'') {
+				if (ch == '\\') {
+					// skip the next char
+					i++;
+				} else if (ch == '\'') {
+					styler.ColourTo(i, StateToPrint);
+					state = SCE_HPHP_DEFAULT;
+				}
+			} else if (isLineEnd(chPrev) && styler.Match(i, phpStringDelimiter)) {
+				const int psdLength = strlen(phpStringDelimiter);
+				const char chAfterPsd = styler.SafeGetCharAt(i + psdLength);
+				const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1);
+				if (isLineEnd(chAfterPsd) ||
+				(chAfterPsd == ';' && isLineEnd(chAfterPsd2))) {
+					i += (((i + psdLength) < lengthDoc) ? psdLength : lengthDoc) - 1;
+					styler.ColourTo(i, StateToPrint);
+					state = SCE_HPHP_DEFAULT;
+					if (foldHeredoc) levelCurrent--;
+				}
 			}
 			break;
 		case SCE_HPHP_HSTRING_VARIABLE:
-			if (!IsPhpWordChar(ch)) {
-				styler.ColourTo(i - 1, StateToPrint);
-				i--; // strange but it works
+			if (!IsPhpWordChar(chNext)) {
+				styler.ColourTo(i, StateToPrint);
 				state = SCE_HPHP_HSTRING;
 			}
 			break;
@@ -1632,7 +1740,7 @@
 			styler.ColourTo(i - 1, StateToPrint);
 			if (IsADigit(ch) || (ch == '.' && IsADigit(chNext))) {
 				state = SCE_HPHP_NUMBER;
-			} else if (iswordstart(ch)) {
+			} else if (IsAWordStart(ch)) {
 				state = SCE_HPHP_WORD;
 			} else if (ch == '/' && chNext == '*') {
 				i++;
@@ -1646,15 +1754,20 @@
 				state = SCE_HPHP_HSTRING;
 				strcpy(phpStringDelimiter, "\"");
 			} else if (styler.Match(i, "<<<")) {
-				state = SCE_HPHP_HSTRING;
-				i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler);
+				bool isSimpleString = false;
+				i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString);
+				if (strlen(phpStringDelimiter)) {
+					state = (isSimpleString ? SCE_HPHP_SIMPLESTRING : SCE_HPHP_HSTRING);
+					if (foldHeredoc) levelCurrent++;
+				}
 			} else if (ch == '\'') {
 				state = SCE_HPHP_SIMPLESTRING;
+				strcpy(phpStringDelimiter, "\'");
 			} else if (ch == '$' && IsPhpWordStart(chNext)) {
 				state = SCE_HPHP_VARIABLE;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				state = SCE_HPHP_OPERATOR;
-			} else if ((state == SCE_HPHP_OPERATOR) && (isspacechar(ch))) {
+			} else if ((state == SCE_HPHP_OPERATOR) && (IsASpace(ch))) {
 				state = SCE_HPHP_DEFAULT;
 			}
 			break;
@@ -1670,9 +1783,9 @@
 				state = SCE_HB_STRING;
 			} else if (ch == '\'') {
 				state = SCE_HB_COMMENTLINE;
-			} else if (iswordstart(ch)) {
+			} else if (IsAWordStart(ch)) {
 				state = SCE_HB_WORD;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i, SCE_HB_DEFAULT);
 			}
 		} else if (state == SCE_HBA_DEFAULT) {    // One of the above succeeded
@@ -1680,9 +1793,9 @@
 				state = SCE_HBA_STRING;
 			} else if (ch == '\'') {
 				state = SCE_HBA_COMMENTLINE;
-			} else if (iswordstart(ch)) {
+			} else if (IsAWordStart(ch)) {
 				state = SCE_HBA_WORD;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i, SCE_HBA_DEFAULT);
 			}
 		} else if (state == SCE_HJ_DEFAULT) {    // One of the above succeeded
@@ -1697,16 +1810,32 @@
 				state = SCE_HJ_DOUBLESTRING;
 			} else if ((ch == '\'') && (nonEmptySegment)) {
 				state = SCE_HJ_SINGLESTRING;
-			} else if (iswordstart(ch)) {
+			} else if (IsAWordStart(ch)) {
 				state = SCE_HJ_WORD;
-			} else if (isoperator(ch)) {
+			} else if (IsOperator(ch)) {
 				styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
 			}
 		}
 	}
 
-	StateToPrint = statePrintForState(state, inScriptType);
+	switch (state) {
+	case SCE_HJ_WORD:
+		classifyWordHTJS(styler.GetStartSegment(), lengthDoc - 1, keywords2, styler, inScriptType);
+		break;
+	case SCE_HB_WORD:
+		classifyWordHTVB(styler.GetStartSegment(), lengthDoc - 1, keywords3, styler, inScriptType);
+		break;
+	case SCE_HP_WORD:
+		classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType);
+		break;
+	case SCE_HPHP_WORD:
+		classifyWordHTPHP(styler.GetStartSegment(), lengthDoc - 1, keywords5, styler);
+		break;
+	default:
+		StateToPrint = statePrintForState(state, inScriptType);
 		styler.ColourTo(lengthDoc - 1, StateToPrint);
+		break;
+	}
 
 	// Fill in the real level of the next line, keeping the current flags as they will be filled in later
 	if (fold) {
@@ -1715,6 +1844,18 @@
 	}
 }
 
+static void ColouriseXMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                                  Accessor &styler) {
+	// Passing in true because we're lexing XML
+	ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, true);
+}
+
+static void ColouriseHTMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                                  Accessor &styler) {
+	// Passing in false because we're notlexing XML
+	ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, false);
+}
+
 static bool isASPScript(int state) {
 	return
 		(state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
@@ -1789,7 +1930,7 @@
 			sc.SetState(SCE_H_DEFAULT);
 		}
 	} else if (sc.state == SCE_H_TAGUNKNOWN) {
-		if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
+		if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
 			char s[100];
 			sc.GetCurrentLowered(s, sizeof(s));
 			if (s[1] == '/') {
@@ -1812,7 +1953,7 @@
 			}
 		}
 	} else if (sc.state == SCE_H_ATTRIBUTE) {
-		if (!ishtmlwordchar(static_cast<char>(sc.ch))) {
+		if (!ishtmlwordchar(sc.ch)) {
 			char s[100];
 			sc.GetCurrentLowered(s, sizeof(s));
 			if (!keywordsTags.InList(s)) {
@@ -1864,7 +2005,7 @@
 		} else if (sc.ch == '>') {
 			sc.SetState(SCE_H_TAG);
 			sc.ForwardSetState(SCE_H_DEFAULT);
-		} else if (ishtmlwordchar(static_cast<char>(sc.ch))) {
+		} else if (ishtmlwordchar(sc.ch)) {
 			sc.SetState(SCE_H_ATTRIBUTE);
 		}
 	}
@@ -1908,8 +2049,8 @@
 
 static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
-	// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
-	StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+	// Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+	StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX));
 	for (; sc.More(); sc.Forward()) {
 		ColouriseASPPiece(sc, keywordlists);
 	}
@@ -1992,7 +2133,7 @@
 			sc.SetState(SCE_HPHP_SIMPLESTRING);
 		} else if (sc.ch == '$' && IsPhpWordStart(static_cast<char>(sc.chNext))) {
 			sc.SetState(SCE_HPHP_VARIABLE);
-		} else if (isoperator(static_cast<char>(sc.ch))) {
+		} else if (IsOperator(static_cast<char>(sc.ch))) {
 			sc.SetState(SCE_HPHP_OPERATOR);
 		}
 	}
@@ -2000,8 +2141,8 @@
 
 static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                                   Accessor &styler) {
-	// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
-	StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+	// Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+	StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX));
 	for (; sc.More(); sc.Forward()) {
 		ColourisePHPPiece(sc, keywordlists);
 	}
@@ -2009,9 +2150,10 @@
 }
 
 static void ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
-                                               Accessor &styler) {
-	if(startPos == 0) initStyle = SCE_HPHP_DEFAULT;
-		ColouriseHyperTextDoc(startPos,length,initStyle,keywordlists,styler);
+        Accessor &styler) {
+	if (startPos == 0)
+		initStyle = SCE_HPHP_DEFAULT;
+	ColouriseHTMLDoc(startPos, length, initStyle, keywordlists, styler);
 }
 
 static const char * const htmlWordListDesc[] = {
@@ -2034,9 +2176,9 @@
 	0,
 };
 
-LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext", 0, htmlWordListDesc, 7);
-LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml", 0, htmlWordListDesc, 7);
+LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8);
+LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8);
 // SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead.
-LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 7);
-LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 7);
-LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 7);
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 8);
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 8);
+LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8);

Modified: trunk/plugins/editor/scintilla/LexHaskell.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexHaskell.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexHaskell.cxx	Sat Nov 15 17:50:33 2008
@@ -31,6 +31,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #ifdef BUILD_AS_EXTERNAL_LEXER
 
 #include "ExternalLexer.h"
@@ -85,12 +89,16 @@
       else if (sc.state == SCE_HA_STRING) {
          if (sc.ch == '\"') {
             sc.ForwardSetState(SCE_HA_DEFAULT);
+         } else if (sc.ch == '\\') {
+            sc.Forward();
          }
       }
          // Char
       else if (sc.state == SCE_HA_CHARACTER) {
          if (sc.ch == '\'') {
             sc.ForwardSetState(SCE_HA_DEFAULT);
+         } else if (sc.ch == '\\') {
+            sc.Forward();
          }
       }
          // Number
@@ -171,6 +179,9 @@
          // Digit
          if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
             sc.SetState(SCE_HA_NUMBER);
+            if (sc.ch == '0' && (sc.chNext == 'X' || sc.chNext == 'x')) { // Match anything starting with "0x" or "0X", too
+               sc.Forward(1);
+            }
          }
          // Comment line
          else if (sc.Match("--")) {
@@ -185,7 +196,7 @@
             sc.SetState(SCE_HA_STRING);
          }
          // Character
-         else if (sc.Match('\'') && IsWhitespace(sc.GetRelative(-1)) ) {
+         else if (sc.Match('\'')) {
             sc.SetState(SCE_HA_CHARACTER);
          }
          // Stringstart

Modified: trunk/plugins/editor/scintilla/LexInno.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexInno.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexInno.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) {
 	int state = SCE_INNO_DEFAULT;
 	char chPrev;
@@ -172,14 +176,14 @@
 			case SCE_INNO_STRING_DOUBLE:
 				if (ch == '"' || isEOL) {
 					state = SCE_INNO_DEFAULT;
-					styler.ColourTo(i,SCE_INNO_DEFAULT);
+					styler.ColourTo(i,SCE_INNO_STRING_DOUBLE);
 				}
 				break;
 
 			case SCE_INNO_STRING_SINGLE:
 				if (ch == '\'' || isEOL) {
 					state = SCE_INNO_DEFAULT;
-					styler.ColourTo(i,SCE_INNO_DEFAULT);
+					styler.ColourTo(i,SCE_INNO_STRING_SINGLE);
 				}
 				break;
 
@@ -219,72 +223,42 @@
 };
 
 static void FoldInnoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
-	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
-
 	unsigned int endPos = startPos + length;
-	int visibleChars = 0;
+	char chNext = styler[startPos];
+
 	int lineCurrent = styler.GetLine(startPos);
 
-	char chNext = styler[startPos];
-	int styleNext = styler.StyleAt(startPos);
-	bool headerPoint = false;
-	int lev;
+	bool sectionFlag = false;
+	int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) : SC_FOLDLEVELBASE;
+	int level;
 
 	for (unsigned int i = startPos; i < endPos; i++) {
 		char ch = chNext;
 		chNext = styler[i+1];
-
-		int style = styleNext;
-		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		int style = styler.StyleAt(i);
 
 		if (style == SCE_INNO_SECTION)
-			headerPoint = true;
+			sectionFlag = true;
 
-		if (atEOL) {
-			lev = SC_FOLDLEVELBASE;
-
-			if (lineCurrent > 0) {
-				int levelPrevious = styler.LevelAt(lineCurrent - 1);
-
-				if (levelPrevious & SC_FOLDLEVELHEADERFLAG)
-					lev = SC_FOLDLEVELBASE + 1;
-				else
-					lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
+		if (atEOL || i == endPos - 1) {
+			if (sectionFlag) {
+				level = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
+				if (level == levelPrev)
+					styler.SetLevel(lineCurrent - 1, levelPrev & ~SC_FOLDLEVELHEADERFLAG);
+			} else {
+				level = levelPrev & SC_FOLDLEVELNUMBERMASK;
+				if (levelPrev & SC_FOLDLEVELHEADERFLAG)
+					level++;
 			}
 
-			if (headerPoint)
-				lev = SC_FOLDLEVELBASE;
-
-			if (visibleChars == 0 && foldCompact)
-				lev |= SC_FOLDLEVELWHITEFLAG;
-
-			if (headerPoint)
-				lev |= SC_FOLDLEVELHEADERFLAG;
-
-			if (lev != styler.LevelAt(lineCurrent))
-				styler.SetLevel(lineCurrent, lev);
+			styler.SetLevel(lineCurrent, level);
 
+			levelPrev = level;
 			lineCurrent++;
-			visibleChars = 0;
-			headerPoint = false;
+			sectionFlag = false;
 		}
-		if (!isspacechar(ch))
-			visibleChars++;
-	}
-
-	if (lineCurrent > 0) {
-		int levelPrevious = styler.LevelAt(lineCurrent - 1);
-
-		if (levelPrevious & SC_FOLDLEVELHEADERFLAG)
-			lev = SC_FOLDLEVELBASE + 1;
-		else
-			lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
-	} else {
-		lev = SC_FOLDLEVELBASE;
 	}
-	int flagsNext = styler.LevelAt(lineCurrent);
-	styler.SetLevel(lineCurrent, lev | flagsNext & ~SC_FOLDLEVELNUMBERMASK);
 }
 
 LexerModule lmInno(SCLEX_INNOSETUP, ColouriseInnoDoc, "inno", FoldInnoDoc, innoWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexKix.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexKix.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexKix.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // Extended to accept accented characters
 static inline bool IsAWordChar(int ch) {
 	return ch >= 0x80 || isalnum(ch) || ch == '_';

Modified: trunk/plugins/editor/scintilla/LexLisp.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexLisp.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexLisp.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #define SCE_LISP_CHARACTER 29
 #define SCE_LISP_MACRO 30
 #define SCE_LISP_MACRO_DISPATCH 31

Modified: trunk/plugins/editor/scintilla/LexLout.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexLout.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexLout.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalpha(ch) || ch == '@' || ch == '_');
 }

Modified: trunk/plugins/editor/scintilla/LexLua.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexLua.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexLua.cxx	Sat Nov 15 17:50:33 2008
@@ -21,43 +21,11 @@
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+#include "CharacterSet.h"
 
-// Extended to accept accented characters
-static inline bool IsAWordChar(int ch) {
-	return ch >= 0x80 ||
-	       (isalnum(ch) || ch == '.' || ch == '_');
-}
-
-static inline bool IsAWordStart(int ch) {
-	return ch >= 0x80 ||
-	       (isalpha(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) || toupper(ch) == 'E' ||
-	        ch == '.' || ch == '-' || ch == '+' ||
-	        (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'));
-}
-
-static inline bool IsLuaOperator(int ch) {
-	if (ch >= 0x80 || isalnum(ch)) {
-		return false;
-	}
-	// '.' left out as it is used to make up numbers
-	if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
-		ch == '(' || ch == ')' || ch == '=' ||
-		ch == '{' || ch == '}' || ch == '~' ||
-		ch == '[' || ch == ']' || ch == ';' ||
-		ch == '<' || ch == '>' || ch == ',' ||
-		ch == '.' || ch == '^' || ch == '%' || ch == ':' ||
-		ch == '#') {
-		return true;
-	}
-	return false;
-}
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 // Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ],
 // return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on.
@@ -87,6 +55,15 @@
 	WordList &keywords7 = *keywordlists[6];
 	WordList &keywords8 = *keywordlists[7];
 
+	// Accepts accented characters
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
+	// Not exactly following number definition (several dots are seen as OK, etc.)
+	// but probably enough in most cases.
+	CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefABCDEF");
+	CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#");
+	CharacterSet setEscapeSkip(CharacterSet::setNone, "\"'\\");
+
 	int currentLine = styler.GetLine(startPos);
 	// Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level,
 	// if we are inside such a string. Block comment was introduced in Lua 5.0,
@@ -132,7 +109,7 @@
 
 		// Handle string line continuation
 		if ((sc.state == SCE_LUA_STRING || sc.state == SCE_LUA_CHARACTER) &&
-		        sc.ch == '\\') {
+				sc.ch == '\\') {
 			if (sc.chNext == '\n' || sc.chNext == '\r') {
 				sc.Forward();
 				if (sc.ch == '\r' && sc.chNext == '\n') {
@@ -147,11 +124,14 @@
 			sc.SetState(SCE_LUA_DEFAULT);
 		} else if (sc.state == SCE_LUA_NUMBER) {
 			// We stop the number definition on non-numerical non-dot non-eE non-sign non-hexdigit char
-			if (!IsANumberChar(sc.ch)) {
+			if (!setNumber.Contains(sc.ch)) {
 				sc.SetState(SCE_LUA_DEFAULT);
+			} else if (sc.ch == '-' || sc.ch == '+') {
+				if (sc.chPrev != 'E' && sc.chPrev != 'e')
+					sc.SetState(SCE_LUA_DEFAULT);
 			}
 		} else if (sc.state == SCE_LUA_IDENTIFIER) {
-			if (!IsAWordChar(sc.ch) || sc.Match('.', '.')) {
+			if (!setWord.Contains(sc.ch) || sc.Match('.', '.')) {
 				char s[100];
 				sc.GetCurrent(s, sizeof(s));
 				if (keywords.InList(s)) {
@@ -166,8 +146,6 @@
 					sc.ChangeState(SCE_LUA_WORD5);
 				} else if (keywords6.InList(s)) {
 					sc.ChangeState(SCE_LUA_WORD6);
-				} else if (keywords6.InList(s)) {
-					sc.ChangeState(SCE_LUA_WORD6);
 				} else if (keywords7.InList(s)) {
 					sc.ChangeState(SCE_LUA_WORD7);
 				} else if (keywords8.InList(s)) {
@@ -181,7 +159,7 @@
 			}
 		} else if (sc.state == SCE_LUA_STRING) {
 			if (sc.ch == '\\') {
-				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+				if (setEscapeSkip.Contains(sc.chNext)) {
 					sc.Forward();
 				}
 			} else if (sc.ch == '\"') {
@@ -192,7 +170,7 @@
 			}
 		} else if (sc.state == SCE_LUA_CHARACTER) {
 			if (sc.ch == '\\') {
-				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+				if (setEscapeSkip.Contains(sc.chNext)) {
 					sc.Forward();
 				}
 			} else if (sc.ch == '\'') {
@@ -228,9 +206,9 @@
 			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
 				sc.SetState(SCE_LUA_NUMBER);
 				if (sc.ch == '0' && toupper(sc.chNext) == 'X') {
-					sc.Forward(1);
+					sc.Forward();
 				}
-			} else if (IsAWordStart(sc.ch)) {
+			} else if (setWordStart.Contains(sc.ch)) {
 				sc.SetState(SCE_LUA_IDENTIFIER);
 			} else if (sc.ch == '\"') {
 				sc.SetState(SCE_LUA_STRING);
@@ -260,11 +238,34 @@
 				}
 			} else if (sc.atLineStart && sc.Match('$')) {
 				sc.SetState(SCE_LUA_PREPROCESSOR);	// Obsolete since Lua 4.0, but still in old code
-			} else if (IsLuaOperator(static_cast<char>(sc.ch))) {
+			} else if (setLuaOperator.Contains(sc.ch)) {
 				sc.SetState(SCE_LUA_OPERATOR);
 			}
 		}
 	}
+
+	if (setWord.Contains(sc.chPrev)) {
+		char s[100];
+		sc.GetCurrent(s, sizeof(s));
+		if (keywords.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD);
+		} else if (keywords2.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD2);
+		} else if (keywords3.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD3);
+		} else if (keywords4.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD4);
+		} else if (keywords5.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD5);
+		} else if (keywords6.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD6);
+		} else if (keywords7.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD7);
+		} else if (keywords8.InList(s)) {
+			sc.ChangeState(SCE_LUA_WORD8);
+		}
+	}
+
 	sc.Complete();
 }
 

Modified: trunk/plugins/editor/scintilla/LexMMIXAL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexMMIXAL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexMMIXAL.cxx	Sat Nov 15 17:50:33 2008
@@ -22,6 +22,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 
 static inline bool IsAWordChar(const int ch) {

Modified: trunk/plugins/editor/scintilla/LexMPT.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexMPT.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexMPT.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "SciLexer.h"
 #include "SString.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static int GetLotLineState(SString &line) {
 	if (line.length()) {
 		// Most of the time the first non-blank character in line determines that line's type

Modified: trunk/plugins/editor/scintilla/LexMSSQL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexMSSQL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexMSSQL.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #define KW_MSSQL_STATEMENTS         0
 #define KW_MSSQL_DATA_TYPES         1
 #define KW_MSSQL_SYSTEM_TABLES      2
@@ -307,16 +311,16 @@
 			inComment = (style == SCE_MSSQL_COMMENT);
 		}
         if (style == SCE_MSSQL_STATEMENT) {
-            // Folding between begin and end
-            if (ch == 'b' || ch == 'e') {
+            // Folding between begin or case and end
+            if (ch == 'b' || ch == 'B' || ch == 'c' || ch == 'C' || ch == 'e' || ch == 'E') {
                 for (unsigned int j = 0; j < 5; j++) {
 					if (!iswordchar(styler[i + j])) {
 						break;
 					}
-					s[j] = styler[i + j];
+					s[j] = static_cast<char>(tolower(styler[i + j]));
 					s[j + 1] = '\0';
                 }
-				if (strcmp(s, "begin") == 0) {
+				if ((strcmp(s, "begin") == 0) || (strcmp(s, "case") == 0)) {
 					levelCurrent++;
 				}
 				if (strcmp(s, "end") == 0) {

Added: trunk/plugins/editor/scintilla/LexMagik.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexMagik.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,445 @@
+// Scintilla source code edit control
+/**
+ * @file LexMagik.cxx
+ * Lexer for GE(r) Smallworld(tm) MagikSF
+ */
+// Copyright 1998-2005 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+/**
+ * Is it a core character (C isalpha(), exclamation and question mark)
+ *
+ * \param  ch The character
+ * \return True if ch is a character, False otherwise
+ */
+static inline bool IsAlphaCore(int ch) {
+    return (isalpha(ch) || ch == '!' || ch == '?');
+}
+
+/**
+ * Is it a character (IsAlphaCore() and underscore)
+ *
+ * \param  ch The character
+ * \return True if ch is a character, False otherwise
+ */
+static inline bool IsAlpha(int ch) {
+    return (IsAlphaCore(ch) || ch == '_');
+}
+
+/**
+ * Is it a symbolic character (IsAlpha() and colon)
+ *
+ * \param  ch The character
+ * \return True if ch is a character, False otherwise
+ */
+static inline bool IsAlphaSym(int ch) {
+    return (IsAlpha(ch) || ch == ':');
+}
+
+/**
+ * Is it a numerical character (IsAlpha() and 0 - 9)
+ *
+ * \param  ch The character
+ * \return True if ch is a character, False otherwise
+ */
+static inline bool IsAlNum(int ch) {
+    return ((ch > '0' && ch < '9') || IsAlpha(ch));
+}
+
+/**
+ * Is it a symbolic numerical character (IsAlNum() and colon)
+ *
+ * \param  ch The character
+ * \return True if ch is a character, False otherwise
+ */
+static inline bool IsAlNumSym(int ch) {
+    return (IsAlNum(ch) || ch == ':');
+}
+
+/**
+ * The lexer function
+ *
+ * \param  startPos Where to start scanning
+ * \param  length Where to scan to
+ * \param  initStyle The style at the initial point, not used in this folder
+ * \param  keywordslists The keywordslists, currently, number 5 is used
+ * \param  styler The styler
+ */
+static void ColouriseMagikDoc(unsigned int startPos, int length, int initStyle,
+                           WordList *keywordlists[], Accessor &styler) {
+    styler.StartAt(startPos);
+
+    WordList &keywords = *keywordlists[0];
+    WordList &pragmatics = *keywordlists[1];
+    WordList &containers = *keywordlists[2];
+    WordList &flow = *keywordlists[3];
+    WordList &characters = *keywordlists[4];
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+
+	for (; sc.More(); sc.Forward()) {
+
+    repeat:
+
+        if(sc.ch == '#') {
+            if (sc.chNext == '#') sc.SetState(SCE_MAGIK_HYPER_COMMENT);
+            else sc.SetState(SCE_MAGIK_COMMENT);
+            for(; sc.More() && !(sc.atLineEnd); sc.Forward());
+            sc.SetState(SCE_MAGIK_DEFAULT);
+            goto repeat;
+        }
+
+        if(sc.ch == '"') {
+            sc.SetState(SCE_MAGIK_STRING);
+
+            if(sc.More())
+            {
+                sc.Forward();
+                for(; sc.More() && sc.ch != '"'; sc.Forward());
+            }
+
+            sc.ForwardSetState(SCE_MAGIK_DEFAULT);
+            goto repeat;
+        }
+
+	    // The default state
+	    if(sc.state == SCE_MAGIK_DEFAULT) {
+
+	        // A certain keyword has been detected
+	        if (sc.ch == '_' && (
+                    sc.currentPos == 0 || !IsAlNum(sc.chPrev))) {
+	            char keyword[50];
+	            memset(keyword, '\0', 50);
+
+	            for(
+                    int scanPosition = 0;
+                    scanPosition < 50;
+                    scanPosition++) {
+	                char keywordChar = static_cast<char>(
+                        tolower(styler.SafeGetCharAt(
+                            scanPosition +
+                                static_cast<int>(sc.currentPos+1), ' ')));
+                    if(IsAlpha(keywordChar)) {
+                        keyword[scanPosition] = keywordChar;
+                    } else {
+                        break;
+                    }
+	            }
+
+                // It is a pragma
+	            if(pragmatics.InList(keyword)) {
+	                sc.SetState(SCE_MAGIK_PRAGMA);
+	            }
+
+	            // it is a normal keyword like _local, _self, etc.
+	            else if(keywords.InList(keyword)) {
+	                sc.SetState(SCE_MAGIK_KEYWORD);
+	            }
+
+                // It is a container keyword, such as _method, _proc, etc.
+	            else if(containers.InList(keyword)) {
+	                sc.SetState(SCE_MAGIK_CONTAINER);
+	            }
+
+	            // It is a flow keyword, such as _for, _if, _try, etc.
+	            else if(flow.InList(keyword)) {
+	                sc.SetState(SCE_MAGIK_FLOW);
+	            }
+
+	            // Interpret as unknown keyword
+	            else {
+	                sc.SetState(SCE_MAGIK_UNKNOWN_KEYWORD);
+	            }
+	        }
+
+            // Symbolic expression
+	        else if(sc.ch == ':' && !IsAlNum(sc.chPrev)) {
+	            sc.SetState(SCE_MAGIK_SYMBOL);
+	            bool firstTrip = true;
+	            for(sc.Forward(); sc.More(); sc.Forward()) {
+	                if(firstTrip && IsAlphaSym(sc.ch));
+	                else if(!firstTrip && IsAlNumSym(sc.ch));
+	                else if(sc.ch == '|') {
+	                    for(sc.Forward();
+                            sc.More() && sc.ch != '|';
+                            sc.Forward());
+	                }
+	                else break;
+
+	                firstTrip = false;
+	            }
+	            sc.SetState(SCE_MAGIK_DEFAULT);
+	            goto repeat;
+	        }
+
+            // Identifier (label) expression
+	        else if(sc.ch == '@') {
+	            sc.SetState(SCE_MAGIK_IDENTIFIER);
+	            bool firstTrip = true;
+	            for(sc.Forward(); sc.More(); sc.Forward()) {
+	                if(firstTrip && IsAlphaCore(sc.ch)) {
+	                    firstTrip = false;
+	                }
+	                else if(!firstTrip && IsAlpha(sc.ch));
+	                else break;
+	            }
+	            sc.SetState(SCE_MAGIK_DEFAULT);
+	            goto repeat;
+	        }
+
+	        // Start of a character
+            else if(sc.ch == '%') {
+                sc.SetState(SCE_MAGIK_CHARACTER);
+                sc.Forward();
+                char keyword[50];
+	            memset(keyword, '\0', 50);
+
+	            for(
+                    int scanPosition = 0;
+                    scanPosition < 50;
+                    scanPosition++) {
+	                char keywordChar = static_cast<char>(
+                        tolower(styler.SafeGetCharAt(
+                            scanPosition +
+                                static_cast<int>(sc.currentPos), ' ')));
+                    if(IsAlpha(keywordChar)) {
+                        keyword[scanPosition] = keywordChar;
+                    } else {
+                        break;
+                    }
+	            }
+
+	            if(characters.InList(keyword)) {
+	                sc.Forward(strlen(keyword));
+	            } else {
+	                sc.Forward();
+	            }
+
+                sc.SetState(SCE_MAGIK_DEFAULT);
+                goto repeat;
+            }
+
+            // Operators
+	        else if(
+                sc.ch == '>' ||
+                sc.ch == '<' ||
+                sc.ch == '.' ||
+                sc.ch == ',' ||
+                sc.ch == '+' ||
+                sc.ch == '-' ||
+                sc.ch == '/' ||
+                sc.ch == '*' ||
+                sc.ch == '~' ||
+                sc.ch == '$' ||
+                sc.ch == '=') {
+                sc.SetState(SCE_MAGIK_OPERATOR);
+            }
+
+            // Braces
+            else if(sc.ch == '(' || sc.ch == ')') {
+                sc.SetState(SCE_MAGIK_BRACE_BLOCK);
+            }
+
+            // Brackets
+            else if(sc.ch == '{' || sc.ch == '}') {
+                sc.SetState(SCE_MAGIK_BRACKET_BLOCK);
+            }
+
+            // Square Brackets
+            else if(sc.ch == '[' || sc.ch == ']') {
+                sc.SetState(SCE_MAGIK_SQBRACKET_BLOCK);
+            }
+
+
+	    }
+
+	    // It is an operator
+	    else if(
+            sc.state == SCE_MAGIK_OPERATOR ||
+            sc.state == SCE_MAGIK_BRACE_BLOCK ||
+            sc.state == SCE_MAGIK_BRACKET_BLOCK ||
+            sc.state == SCE_MAGIK_SQBRACKET_BLOCK) {
+	        sc.SetState(SCE_MAGIK_DEFAULT);
+	        goto repeat;
+	    }
+
+	    // It is the pragma state
+	    else if(sc.state == SCE_MAGIK_PRAGMA) {
+	        if(!IsAlpha(sc.ch)) {
+	            sc.SetState(SCE_MAGIK_DEFAULT);
+                goto repeat;
+	        }
+	    }
+
+	    // It is the keyword state
+	    else if(
+            sc.state == SCE_MAGIK_KEYWORD ||
+            sc.state == SCE_MAGIK_CONTAINER ||
+            sc.state == SCE_MAGIK_FLOW ||
+            sc.state == SCE_MAGIK_UNKNOWN_KEYWORD) {
+	        if(!IsAlpha(sc.ch)) {
+	            sc.SetState(SCE_MAGIK_DEFAULT);
+	            goto repeat;
+	        }
+	    }
+	}
+
+	sc.Complete();
+}
+
+/**
+ * The word list description
+ */
+static const char * const magikWordListDesc[] = {
+    "Accessors (local, global, self, super, thisthread)",
+    "Pragmatic (pragma, private)",
+    "Containers (method, block, proc)",
+    "Flow (if, then, elif, else)",
+    "Characters (space, tab, newline, return)",
+    "Fold Containers (method, proc, block, if, loop)",
+    0};
+
+/**
+ * This function detects keywords which are able to have a body. Note that it
+ * uses the Fold Containers word description, not the containers description. It
+ * only works when the style at that particular position is set on Containers
+ * or Flow (number 3 or 4).
+ *
+ * \param  keywordslist The list of keywords that are scanned, they should only
+ *         contain the start keywords, not the end keywords
+ * \param  The actual keyword
+ * \return 1 if it is a folding start-keyword, -1 if it is a folding end-keyword
+ *         0 otherwise
+ */
+static inline int IsFoldingContainer(WordList &keywordslist, char * keyword) {
+    if(
+        strlen(keyword) > 3 &&
+        keyword[0] == 'e' && keyword[1] == 'n' && keyword[2] == 'd') {
+        if (keywordslist.InList(keyword + 3)) {
+            return -1;
+        }
+
+    } else {
+        if(keywordslist.InList(keyword)) {
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
+/**
+ * The folding function
+ *
+ * \param  startPos Where to start scanning
+ * \param  length Where to scan to
+ * \param  keywordslists The keywordslists, currently, number 5 is used
+ * \param  styler The styler
+ */
+static void FoldMagikDoc(unsigned int startPos, int length, int,
+    WordList *keywordslists[], Accessor &styler) {
+
+    bool compact = styler.GetPropertyInt("fold.compact") != 0;
+
+    WordList &foldingElements = *keywordslists[5];
+    int endPos = startPos + length;
+    int line = styler.GetLine(startPos);
+    int level = styler.LevelAt(line) & SC_FOLDLEVELNUMBERMASK;
+    int flags = styler.LevelAt(line) & ~SC_FOLDLEVELNUMBERMASK;
+
+    for(
+        int currentPos = startPos;
+        currentPos < endPos;
+        currentPos++) {
+            char currentState = styler.StyleAt(currentPos);
+            char c = styler.SafeGetCharAt(currentPos, ' ');
+            int prevLine = styler.GetLine(currentPos - 1);
+            line = styler.GetLine(currentPos);
+
+            // Default situation
+            if(prevLine < line) {
+                styler.SetLevel(line, (level|flags) & ~SC_FOLDLEVELHEADERFLAG);
+                flags = styler.LevelAt(line) & ~SC_FOLDLEVELNUMBERMASK;
+            }
+
+            if(
+                (
+                    currentState == SCE_MAGIK_CONTAINER ||
+                    currentState == SCE_MAGIK_FLOW
+                ) &&
+                c == '_') {
+
+                char keyword[50];
+                memset(keyword, '\0', 50);
+
+                for(
+                    int scanPosition = 0;
+                    scanPosition < 50;
+                    scanPosition++) {
+                    char keywordChar = static_cast<char>(
+                        tolower(styler.SafeGetCharAt(
+                            scanPosition +
+                                currentPos + 1, ' ')));
+                    if(IsAlpha(keywordChar)) {
+                        keyword[scanPosition] = keywordChar;
+                    } else {
+                        break;
+                    }
+                }
+
+                if(IsFoldingContainer(foldingElements, keyword) > 0) {
+                    styler.SetLevel(
+                        line,
+                        styler.LevelAt(line) | SC_FOLDLEVELHEADERFLAG);
+                    level++;
+                } else if(IsFoldingContainer(foldingElements, keyword) < 0) {
+                    styler.SetLevel(line, styler.LevelAt(line));
+                    level--;
+                }
+            }
+
+            if(
+                compact && (
+                    currentState == SCE_MAGIK_BRACE_BLOCK ||
+                    currentState == SCE_MAGIK_BRACKET_BLOCK ||
+                    currentState == SCE_MAGIK_SQBRACKET_BLOCK)) {
+                if(c == '{' || c == '[' || c == '(') {
+                    styler.SetLevel(
+                        line,
+                        styler.LevelAt(line) | SC_FOLDLEVELHEADERFLAG);
+                    level++;
+                } else if(c == '}' || c == ']' || c == ')') {
+                    styler.SetLevel(line, styler.LevelAt(line));
+                    level--;
+                }
+            }
+        }
+
+}
+
+/**
+ * Injecting the module
+ */
+LexerModule lmMagikSF(
+    SCLEX_MAGIK, ColouriseMagikDoc, "magiksf", FoldMagikDoc, magikWordListDesc);
+

Modified: trunk/plugins/editor/scintilla/LexMatlab.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexMatlab.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexMatlab.cxx	Sat Nov 15 17:50:33 2008
@@ -25,6 +25,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static bool IsMatlabCommentChar(int c) {
 	return (c == '%') ;
@@ -100,11 +103,19 @@
 				transpose = true;
 			}
 		} else if (sc.state == SCE_MATLAB_STRING) {
-			if (sc.ch == '\'' && sc.chPrev != '\\') {
+			if (sc.ch == '\\') {
+				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+					sc.Forward();
+				}
+			} else if (sc.ch == '\'') {
 				sc.ForwardSetState(SCE_MATLAB_DEFAULT);
 			}
 		} else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) {
-			if (sc.ch == '"' && sc.chPrev != '\\') {
+			if (sc.ch == '\\') {
+				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+					sc.Forward();
+				}
+			} else if (sc.ch == '\"') {
 				sc.ForwardSetState(SCE_MATLAB_DEFAULT);
 			}
 		} else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
@@ -117,7 +128,7 @@
 		if (sc.state == SCE_MATLAB_DEFAULT) {
 			if (IsCommentChar(sc.ch)) {
 				sc.SetState(SCE_MATLAB_COMMENT);
-			} else if (sc.ch == '!') {
+			} else if (sc.ch == '!' && sc.chNext != '=' ) {
 				sc.SetState(SCE_MATLAB_COMMAND);
 			} else if (sc.ch == '\'') {
 				if (transpose) {
@@ -126,7 +137,7 @@
 					sc.SetState(SCE_MATLAB_STRING);
 				}
 			} else if (sc.ch == '"') {
-              sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING);
+				sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING);
 			} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
 				sc.SetState(SCE_MATLAB_NUMBER);
 			} else if (isalpha(sc.ch)) {
@@ -148,17 +159,17 @@
 
 static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle,
                                WordList *keywordlists[], Accessor &styler) {
-  ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
+	ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
 }
 
 static void ColouriseOctaveDoc(unsigned int startPos, int length, int initStyle,
                                WordList *keywordlists[], Accessor &styler) {
-  ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
+	ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
 }
 
 static void FoldMatlabOctaveDoc(unsigned int startPos, int length, int,
-                          WordList *[], Accessor &styler,
-                          bool (*IsComment)(Accessor&,int,int)) {
+                                WordList *[], Accessor &styler,
+                                bool (*IsComment)(Accessor&, int, int)) {
 
 	int endPos = startPos + length;
 
@@ -202,12 +213,12 @@
 
 static void FoldMatlabDoc(unsigned int startPos, int length, int initStyle,
                           WordList *keywordlists[], Accessor &styler) {
-  FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
+	FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
 }
 
 static void FoldOctaveDoc(unsigned int startPos, int length, int initStyle,
                           WordList *keywordlists[], Accessor &styler) {
-  FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
+	FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
 }
 
 static const char * const matlabWordListDesc[] = {

Modified: trunk/plugins/editor/scintilla/LexMetapost.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexMetapost.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexMetapost.cxx	Sat Nov 15 17:50:33 2008
@@ -3,6 +3,8 @@
 // File: LexMetapost.cxx - general context conformant metapost coloring scheme
 // Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com
 // Version: September 28, 2003
+// Modified by instanton: July 10, 2007
+// Folding based on keywordlists[]
 
 // Copyright: 1998-2003 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
@@ -25,6 +27,10 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // val SCE_METAPOST_DEFAULT = 0
 // val SCE_METAPOST_SPECIAL = 1
 // val SCE_METAPOST_GROUP = 2
@@ -317,4 +323,77 @@
 	0
 } ;
 
-LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", 0, metapostWordListDesc);
+static int classifyFoldPointMetapost(const char* s,WordList *keywordlists[]) {
+	WordList& keywordsStart=*keywordlists[3];
+	WordList& keywordsStop1=*keywordlists[4];
+	
+	if (keywordsStart.InList(s)) {return 1;}
+	else if (keywordsStop1.InList(s)) {return -1;}
+	return 0;
+	
+}
+
+static int ParseMetapostWord(unsigned int pos, Accessor &styler, char *word)
+{
+  int length=0;
+  char ch=styler.SafeGetCharAt(pos);
+  *word=0;
+
+  while(isMETAPOSTidentifier(ch) && isalpha(ch) && length<100){
+          word[length]=ch;
+          length++;
+          ch=styler.SafeGetCharAt(pos+length);
+  }
+  word[length]=0;   
+  return length;
+}
+ 
+static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *keywordlists[], Accessor &styler) 
+{
+	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];
+	
+	char buffer[100]="";
+	
+	for (unsigned int i=startPos; i < endPos; i++) {
+		char ch=chNext;
+		chNext=styler.SafeGetCharAt(i+1);
+		char chPrev=styler.SafeGetCharAt(i-1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+		if(i==0 || chPrev == '\r' || chPrev=='\n'|| chPrev==' '|| chPrev=='(' || chPrev=='$')
+		{
+            ParseMetapostWord(i, styler, buffer);
+			levelCurrent += classifyFoldPointMetapost(buffer,keywordlists);
+		}
+		
+		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);
+
+}
+
+
+LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", FoldMetapostDoc, metapostWordListDesc);

Added: trunk/plugins/editor/scintilla/LexMySQL.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexMySQL.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,367 @@
+// Scintilla source code edit control
+/** @file LexMySQL.cxx
+ ** Lexer for MySQL
+ **/
+// Adopted from LexSQL.cxx by Anders Karlsson <anders mysql com>
+// Original work by Neil Hodgson <neilh scintilla org>
+// Copyright 1998-2005 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(int ch) {
+	return (ch < 0x80) && (isalpha(ch) || ch == '_');
+}
+
+static inline bool IsADoxygenChar(int ch) {
+	return (islower(ch) || ch == '$' || ch == '@' ||
+	        ch == '\\' || ch == '&' || ch == '<' ||
+	        ch == '>' || ch == '#' || ch == '{' ||
+	        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) || toupper(ch) == 'E' ||
+             ch == '.' || ch == '-' || ch == '+');
+}
+
+static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                            Accessor &styler) {
+
+	WordList &major_keywords = *keywordlists[0];
+	WordList &keywords = *keywordlists[1];
+	WordList &database_objects = *keywordlists[2];
+	WordList &functions = *keywordlists[3];
+	WordList &system_variables = *keywordlists[4];
+	WordList &procedure_keywords = *keywordlists[5];
+	WordList &kw_user1 = *keywordlists[6];
+	WordList &kw_user2 = *keywordlists[7];
+	WordList &kw_user3 = *keywordlists[8];
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+		// Determine if the current state should terminate.
+		switch (sc.state) {
+		case SCE_MYSQL_OPERATOR:
+			sc.SetState(SCE_MYSQL_DEFAULT);
+			break;
+		case SCE_MYSQL_NUMBER:
+			// We stop the number definition on non-numerical non-dot non-eE non-sign char
+			if (!IsANumberChar(sc.ch)) {
+				sc.SetState(SCE_MYSQL_DEFAULT);
+			}
+			break;
+		case SCE_MYSQL_IDENTIFIER:
+			if (!IsAWordChar(sc.ch)) {
+				int nextState = SCE_MYSQL_DEFAULT;
+				char s[1000];
+				sc.GetCurrentLowered(s, sizeof(s));
+				if (major_keywords.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_MAJORKEYWORD);
+				} else if (keywords.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_KEYWORD);
+				} else if (database_objects.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_DATABASEOBJECT);
+				} else if (functions.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_FUNCTION);
+				} else if (procedure_keywords.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_PROCEDUREKEYWORD);
+				} else if (kw_user1.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_USER1);
+				} else if (kw_user2.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_USER2);
+				} else if (kw_user3.InList(s)) {
+					sc.ChangeState(SCE_MYSQL_USER3);
+				}
+				sc.SetState(nextState);
+			}
+			break;
+		case SCE_MYSQL_VARIABLE:
+			if (!IsAWordChar(sc.ch)) {
+				sc.SetState(SCE_MYSQL_DEFAULT);
+			}
+			break;
+		case SCE_MYSQL_SYSTEMVARIABLE:
+			if (!IsAWordChar(sc.ch)) {
+				char s[1000];
+				sc.GetCurrentLowered(s, sizeof(s));
+// Check for known system variables here.
+				if (system_variables.InList(&s[2])) {
+					sc.ChangeState(SCE_MYSQL_KNOWNSYSTEMVARIABLE);
+				}
+				sc.SetState(SCE_MYSQL_DEFAULT);
+			}
+			break;
+		case SCE_MYSQL_QUOTEDIDENTIFIER:
+			if (sc.ch == 0x60) {
+				if (sc.chNext == 0x60) {
+					sc.Forward();	// Ignore it
+				} else {
+					sc.ForwardSetState(SCE_MYSQL_DEFAULT);
+				}
+			}
+			break;
+		case SCE_MYSQL_COMMENT:
+			if (sc.Match('*', '/')) {
+				sc.Forward();
+				sc.ForwardSetState(SCE_MYSQL_DEFAULT);
+			}
+			break;
+		case SCE_MYSQL_COMMENTLINE:
+			if (sc.atLineStart) {
+				sc.SetState(SCE_MYSQL_DEFAULT);
+			}
+			break;
+		case SCE_MYSQL_SQSTRING:
+			if (sc.ch == '\\') {
+				// Escape sequence
+				sc.Forward();
+			} else if (sc.ch == '\'') {
+				if (sc.chNext == '\'') {
+					sc.Forward();
+				} else {
+					sc.ChangeState(SCE_MYSQL_STRING);
+					sc.ForwardSetState(SCE_MYSQL_DEFAULT);
+				}
+			}
+			break;
+		case SCE_MYSQL_DQSTRING:
+			if (sc.ch == '\\') {
+				// Escape sequence
+				sc.Forward();
+			} else if (sc.ch == '\"') {
+				if (sc.chNext == '\"') {
+					sc.Forward();
+				} else {
+					sc.ChangeState(SCE_MYSQL_STRING);
+					sc.ForwardSetState(SCE_MYSQL_DEFAULT);
+				}
+			}
+			break;
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_MYSQL_DEFAULT) {
+			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_MYSQL_NUMBER);
+			} else if (IsAWordStart(sc.ch)) {
+				sc.SetState(SCE_MYSQL_IDENTIFIER);
+// Note that the order of SYSTEMVARIABLE and VARIABLE is important here.
+			} else if (sc.ch == 0x40 && sc.chNext == 0x40) {
+				sc.SetState(SCE_MYSQL_SYSTEMVARIABLE);
+				sc.Forward(); // Skip past the second at-sign.
+			} else if (sc.ch == 0x40) {
+				sc.SetState(SCE_MYSQL_VARIABLE);
+			} else if (sc.ch == 0x60) {
+				sc.SetState(SCE_MYSQL_QUOTEDIDENTIFIER);
+			} else if (sc.Match('/', '*')) {
+				sc.SetState(SCE_MYSQL_COMMENT);
+				sc.Forward();	// Eat the * so it isn't used for the end of the comment
+			} else if (sc.Match('-', '-') || sc.Match('#')) {
+				sc.SetState(SCE_MYSQL_COMMENTLINE);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_MYSQL_SQSTRING);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_MYSQL_DQSTRING);
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_MYSQL_OPERATOR);
+			}
+		}
+	}
+	sc.Complete();
+}
+
+static bool IsStreamCommentStyle(int style) {
+	return style == SCE_MYSQL_COMMENT;
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment.
+static void FoldMySQLDoc(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;
+	bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0;
+
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0) {
+		levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
+	}
+	int levelNext = levelCurrent;
+	char chNext = styler[startPos];
+	int styleNext = styler.StyleAt(startPos);
+	int style = initStyle;
+	bool endFound = false;
+	bool whenFound = false;
+	bool elseFound = false;
+	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 && IsStreamCommentStyle(style)) {
+			if (!IsStreamCommentStyle(stylePrev)) {
+				levelNext++;
+			} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+				// Comments don't end at end of line and the next character may be unstyled.
+				levelNext--;
+			}
+		}
+		if (foldComment && (style == SCE_MYSQL_COMMENTLINE)) {
+			// MySQL needs -- comments to be followed by space or control char
+			if ((ch == '-') && (chNext == '-')) {
+				char chNext2 = styler.SafeGetCharAt(i + 2);
+				char chNext3 = styler.SafeGetCharAt(i + 3);
+				if (chNext2 == '{' || chNext3 == '{') {
+					levelNext++;
+				} else if (chNext2 == '}' || chNext3 == '}') {
+					levelNext--;
+				}
+			}
+		}
+		if (style == SCE_MYSQL_OPERATOR) {
+			if (ch == '(') {
+				levelNext++;
+			} else if (ch == ')') {
+				levelNext--;
+			}
+		}
+
+// Style new keywords here.
+		if ((style == SCE_MYSQL_MAJORKEYWORD && stylePrev != SCE_MYSQL_MAJORKEYWORD)
+		  || (style == SCE_MYSQL_KEYWORD && stylePrev != SCE_MYSQL_KEYWORD)
+		  || (style == SCE_MYSQL_PROCEDUREKEYWORD && stylePrev != SCE_MYSQL_PROCEDUREKEYWORD)) {
+			const int MAX_KW_LEN = 6;	// Maximum length of folding keywords
+			char s[MAX_KW_LEN + 2];
+			unsigned int j = 0;
+			for (; j < MAX_KW_LEN + 1; j++) {
+				if (!iswordchar(styler[i + j])) {
+					break;
+				}
+				s[j] = static_cast<char>(tolower(styler[i + j]));
+			}
+			if (j == MAX_KW_LEN + 1) {
+				// Keyword too long, don't test it
+				s[0] = '\0';
+			} else {
+				s[j] = '\0';
+			}
+			if (!foldOnlyBegin && endFound && (strcmp(s, "if") == 0 || strcmp(s, "while") == 0 || strcmp(s, "loop") == 0)) {
+				endFound = false;
+				levelNext--;
+				if (levelNext < SC_FOLDLEVELBASE) {
+					levelNext = SC_FOLDLEVELBASE;
+				}
+// Note that else is special here. It may or may be followed by an if then, but in aly case the level stays the
+// same. When followed by a if .. then, the level will be increased later, if not, at eol.
+			} else if (!foldOnlyBegin && strcmp(s, "else") == 0) {
+				levelNext--;
+				elseFound = true;
+			} else if (!foldOnlyBegin && strcmp(s, "then") == 0) {
+				if(whenFound) {
+					whenFound = false;
+				} else {
+					levelNext++;
+				}
+			} else if (strcmp(s, "if") == 0) {
+				elseFound = false;
+			} else if (strcmp(s, "when") == 0) {
+				whenFound = true;
+			} else if (strcmp(s, "begin") == 0) {
+				levelNext++;
+			} else if (!foldOnlyBegin && (strcmp(s, "loop") == 0 || strcmp(s, "repeat") == 0
+			  || strcmp(s, "while") == 0)) {
+				if(endFound) {
+					endFound = false;
+				} else {
+					levelNext++;
+				}
+			} else if (strcmp(s, "end") == 0) {
+// Multiple END in a row are counted multiple times!
+				if (endFound) {
+					levelNext--;
+					if (levelNext < SC_FOLDLEVELBASE) {
+						levelNext = SC_FOLDLEVELBASE;
+					}
+				}
+				endFound = true;
+				whenFound = false;
+			}
+		}
+// Handle this for a trailing end withiut an if / while etc, as in the case of a begin.
+		if (endFound) {
+			endFound = false;
+			levelNext--;
+			if (levelNext < SC_FOLDLEVELBASE) {
+				levelNext = SC_FOLDLEVELBASE;
+			}
+		}
+		if (atEOL) {
+			if(elseFound)
+				levelNext++;
+			elseFound = false;
+
+			int levelUse = levelCurrent;
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			visibleChars = 0;
+			endFound = false;
+			whenFound = false;
+		}
+		if (!isspacechar(ch)) {
+			visibleChars++;
+		}
+	}
+}
+
+static const char * const mysqlWordListDesc[] = {
+	"Major Keywords",
+	"Keywords",
+	"Database Objects",
+	"Functions",
+	"System Variables",
+	"Procedure keywords",
+	"User Keywords 1",
+	"User Keywords 2",
+	"User Keywords 3"
+};
+
+LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexNsis.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexNsis.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexNsis.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
 // located in SciLexer.h
 #define SCLEX_NSIS 43
@@ -94,7 +98,7 @@
   return false;
 }
 
-static int NsisCmp( char *s1, const char *s2, bool bIgnoreCase )
+static int NsisCmp( const char *s1, const char *s2, bool bIgnoreCase )
 {
   if( bIgnoreCase )
      return CompareCaseInsensitive( s1, s2);
@@ -120,7 +124,7 @@
           return foldlevel;
   }
   else
-  { 
+  {
     if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
         style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_SECTIONGROUP &&
         style != SCE_NSIS_PAGEEX )
@@ -141,7 +145,7 @@
 
   if( s[0] == '!' )
   {
-    if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
+    if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!if", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
       newFoldlevel++;
     else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
       newFoldlevel--;
@@ -155,7 +159,7 @@
     else if( NsisCmp(s, "SectionGroupEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "PageExEnd", bIgnoreCase ) == 0 )
       newFoldlevel--;
   }
-  
+
   return newFoldlevel;
 }
 
@@ -195,6 +199,9 @@
   if( NsisCmp(s, "!else", bIgnoreCase ) == 0 ) // ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
 		return SCE_NSIS_IFDEFINEDEF;
 
+  if( NsisCmp(s, "!if", bIgnoreCase ) == 0 )
+		return SCE_NSIS_IFDEFINEDEF;
+
   if( NsisCmp(s, "SectionGroup", bIgnoreCase) == 0 || NsisCmp(s, "SectionGroupEnd", bIgnoreCase) == 0 ) // Covers SectionGroup and SectionGroupEnd
     return SCE_NSIS_SECTIONGROUP;
 

Modified: trunk/plugins/editor/scintilla/LexOpal.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexOpal.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexOpal.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 inline static void getRange( unsigned int start, unsigned int end, Accessor & styler, char * s, unsigned int len )
 {
 	unsigned int i = 0;

Modified: trunk/plugins/editor/scintilla/LexOthers.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexOthers.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexOthers.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,14 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static bool strstart(const char *haystack, const char *needle) {
+	return strncmp(haystack, needle, strlen(needle)) == 0;
+}
+
 static bool Is0To9(char ch) {
 	return (ch >= '0') && (ch <= '9');
 }
@@ -54,7 +62,6 @@
     Accessor &styler) {
 
 	unsigned int offset = 0;	// Line Buffer Offset
-	unsigned int enVarEnd;		// Environment Variable End point
 	unsigned int cmdLoc;		// External Command / Program Location
 	char wordBuffer[81];		// Word Buffer - large to catch long paths
 	unsigned int wbl;		// Word Buffer Length
@@ -107,39 +114,6 @@
 	if (lineBuffer[offset] == '@') {
 		styler.ColourTo(startLine + offset, SCE_BAT_HIDE);
 		offset++;
-	// Check for Argument (%n) or Environment Variable (%x...%)
-	} else if (lineBuffer[offset] == '%') {
-		enVarEnd = offset + 1;
-		// Search end of word for second % (can be a long path)
-		while ((enVarEnd < lengthLine) &&
-			(!isspacechar(lineBuffer[enVarEnd])) &&
-			(lineBuffer[enVarEnd] != '%') &&
-			(!IsBOperator(lineBuffer[enVarEnd])) &&
-			(!IsBSeparator(lineBuffer[enVarEnd]))) {
-			enVarEnd++;
-		}
-		// Check for Argument (%n)
-		if ((Is0To9(lineBuffer[offset + 1])) &&
-			(lineBuffer[enVarEnd] != '%')) {
-			// Colorize Argument
-			styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
-			offset += 2;
-			// Check for External Command / Program
-			if (!isspacechar(lineBuffer[offset])) {
-				cmdLoc = offset;
-			}
-		// Check for Environment Variable (%x...%)
-		} else if ((lineBuffer[offset + 1] != '%') &&
-			(lineBuffer[enVarEnd] == '%')) {
-			offset = enVarEnd;
-			// Colorize Environment Variable
-			styler.ColourTo(startLine + offset, SCE_BAT_IDENTIFIER);
-			offset++;
-			// Check for External Command / Program
-			if (!isspacechar(lineBuffer[offset])) {
-				cmdLoc = offset;
-			}
-		}
 	}
 	// Skip next spaces
 	while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
@@ -346,8 +320,8 @@
 				(!IsBSeparator(wordBuffer[wbo]))) {
 				wbo++;
 			}
-			// Check for Argument (%n)
-			if ((Is0To9(wordBuffer[1])) &&
+			// Check for Argument (%n) or (%*)
+			if (((Is0To9(wordBuffer[1])) || (wordBuffer[1] == '*')) &&
 				(wordBuffer[wbo] != '%')) {
 				// Check for External Command / Program
 				if (cmdLoc == offset - wbl) {
@@ -357,6 +331,17 @@
 				styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_IDENTIFIER);
 				// Reset Offset to re-process remainder of word
 				offset -= (wbl - 2);
+			// Check for Expanded Argument (%~...) / Variable (%%~...)
+			} else if (((wbl > 1) && (wordBuffer[1] == '~')) ||
+				((wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] == '~'))) {
+				// Check for External Command / Program
+				if (cmdLoc == offset - wbl) {
+					cmdLoc = offset - (wbl - wbo);
+				}
+				// Colorize Expanded Argument / Variable
+				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER);
+				// Reset Offset to re-process remainder of word
+				offset -= (wbl - wbo);
 			// Check for Environment Variable (%x...%)
 			} else if ((wordBuffer[1] != '%') &&
 				(wordBuffer[wbo] == '%')) {
@@ -371,6 +356,7 @@
 				offset -= (wbl - wbo);
 			// Check for Local Variable (%%a)
 			} else if (
+				(wbl > 2) &&
 				(wordBuffer[1] == '%') &&
 				(wordBuffer[2] != '%') &&
 				(!IsBOperator(wordBuffer[2])) &&
@@ -473,6 +459,7 @@
 		}
 	}
 	if (linePos > 0) {	// Last line does not have ending characters
+		lineBuffer[linePos] = '\0';
 		ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
 		                   keywordlists, styler);
 	}
@@ -485,9 +472,13 @@
 	// otherwise it is considered a comment (Only in..., Binary file...)
 	if (0 == strncmp(lineBuffer, "diff ", 5)) {
 		styler.ColourTo(endLine, SCE_DIFF_COMMAND);
-	} else if (0 == strncmp(lineBuffer, "--- ", 4)) {
+	} else if (0 == strncmp(lineBuffer, "Index: ", 7)) {  // For subversion's diff
+		styler.ColourTo(endLine, SCE_DIFF_COMMAND);
+	} else if (0 == strncmp(lineBuffer, "---", 3)) {
 		// In a context diff, --- appears in both the header and the position markers
-		if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
+		if (lineBuffer[3] == ' ' && atoi(lineBuffer + 4) && !strchr(lineBuffer, '/'))
+			styler.ColourTo(endLine, SCE_DIFF_POSITION);
+		else if (lineBuffer[3] == '\r' || lineBuffer[3] == '\n')
 			styler.ColourTo(endLine, SCE_DIFF_POSITION);
 		else
 			styler.ColourTo(endLine, SCE_DIFF_HEADER);
@@ -520,6 +511,8 @@
 		styler.ColourTo(endLine, SCE_DIFF_DELETED);
 	} else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
 		styler.ColourTo(endLine, SCE_DIFF_ADDED);
+	} else if (lineBuffer[0] == '!') {
+		styler.ColourTo(endLine, SCE_DIFF_CHANGED);
 	} else if (lineBuffer[0] != ' ') {
 		styler.ColourTo(endLine, SCE_DIFF_COMMENT);
 	} else {
@@ -546,25 +539,24 @@
 	}
 }
 
-static void FoldDiffDoc(unsigned int startPos, int length, int, WordList*[], Accessor &styler) {
+static void FoldDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
 	int curLine = styler.GetLine(startPos);
-	int prevLevel = SC_FOLDLEVELBASE;
-	if (curLine > 0)
-		prevLevel = styler.LevelAt(curLine-1);
-
 	int curLineStart = styler.LineStart(curLine);
-	do {
-		int nextLevel = prevLevel;
-		if (prevLevel & SC_FOLDLEVELHEADERFLAG)
-			nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1;
+	int prevLevel = curLine > 0 ? styler.LevelAt(curLine - 1) : SC_FOLDLEVELBASE;
+	int nextLevel;
 
+	do {
 		int lineType = styler.StyleAt(curLineStart);
 		if (lineType == SCE_DIFF_COMMAND)
+			nextLevel = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
+		else if (lineType == SCE_DIFF_HEADER)
 			nextLevel = (SC_FOLDLEVELBASE + 1) | SC_FOLDLEVELHEADERFLAG;
-		else if (lineType == SCE_DIFF_HEADER) {
+		else if (lineType == SCE_DIFF_POSITION && styler[curLineStart] != '-')
 			nextLevel = (SC_FOLDLEVELBASE + 2) | SC_FOLDLEVELHEADERFLAG;
-		} else if (lineType == SCE_DIFF_POSITION)
-			nextLevel = (SC_FOLDLEVELBASE + 3) | SC_FOLDLEVELHEADERFLAG;
+		else if (prevLevel & SC_FOLDLEVELHEADERFLAG)
+			nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1;
+		else
+			nextLevel = prevLevel;
 
 		if ((nextLevel & SC_FOLDLEVELHEADERFLAG) && (nextLevel == prevLevel))
 			styler.SetLevel(curLine-1, prevLevel & ~SC_FOLDLEVELHEADERFLAG);
@@ -576,6 +568,78 @@
 	} while (static_cast<int>(startPos) + length > curLineStart);
 }
 
+static void ColourisePoLine(
+    char *lineBuffer,
+    unsigned int lengthLine,
+    unsigned int startLine,
+    unsigned int endPos,
+    Accessor &styler) {
+
+	unsigned int i = 0;
+	static unsigned int state = SCE_PO_DEFAULT;
+	unsigned int state_start = SCE_PO_DEFAULT;
+
+	while ((i < lengthLine) && isspacechar(lineBuffer[i]))	// Skip initial spaces
+		i++;
+	if (i < lengthLine) {
+		if (lineBuffer[i] == '#') {
+			// check if the comment contains any flags ("#, ") and
+			// then whether the flags contain "fuzzy"
+			if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy"))
+				styler.ColourTo(endPos, SCE_PO_FUZZY);
+			else
+				styler.ColourTo(endPos, SCE_PO_COMMENT);
+		} else {
+			if (lineBuffer[0] == '"') {
+				// line continuation, use previous style
+				styler.ColourTo(endPos, state);
+				return;
+			// this implicitly also matches "msgid_plural"
+			} else if (strstart(lineBuffer, "msgid")) {
+				state_start = SCE_PO_MSGID;
+				state = SCE_PO_MSGID_TEXT;
+			} else if (strstart(lineBuffer, "msgstr")) {
+				state_start = SCE_PO_MSGSTR;
+				state = SCE_PO_MSGSTR_TEXT;
+			} else if (strstart(lineBuffer, "msgctxt")) {
+				state_start = SCE_PO_MSGCTXT;
+				state = SCE_PO_MSGCTXT_TEXT;
+			}
+			if (state_start != SCE_PO_DEFAULT) {
+				// find the next space
+				while ((i < lengthLine) && ! isspacechar(lineBuffer[i]))
+					i++;
+				styler.ColourTo(startLine + i - 1, state_start);
+				styler.ColourTo(startLine + i, SCE_PO_DEFAULT);
+				styler.ColourTo(endPos, state);
+			}
+		}
+	} else {
+		styler.ColourTo(endPos, SCE_PO_DEFAULT);
+	}
+}
+
+static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
+	char lineBuffer[1024];
+	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';
+			ColourisePoLine(lineBuffer, linePos, startLine, i, styler);
+			linePos = 0;
+			startLine = i + 1;
+		}
+	}
+	if (linePos > 0) {	// Last line does not have ending characters
+		ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
+	}
+}
+
 
 static void ColourisePropsLine(
     char *lineBuffer,
@@ -720,6 +784,12 @@
 	int lastNonSpace = -1;
 	unsigned int state = SCE_MAKE_DEFAULT;
 	bool bSpecial = false;
+
+	// check for a tab character in column 0 indicating a command
+	bool bCommand = false;
+	if ((lengthLine > 0) && (lineBuffer[0] == '\t'))
+		bCommand = true;
+
 	// Skip initial spaces
 	while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
 		i++;
@@ -740,14 +810,24 @@
 			styler.ColourTo(startLine + i, state);
 			state = SCE_MAKE_DEFAULT;
 		}
-		if (!bSpecial) {
+
+		// skip identifier and target styling if this is a command line
+		if (!bSpecial && !bCommand) {
 			if (lineBuffer[i] == ':') {
-				// We should check that no colouring was made since the beginning of the line,
-				// to avoid colouring stuff like /OUT:file
-				if (lastNonSpace >= 0)
-					styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
-				styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
-				styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
+				if (((i + 1) < lengthLine) && (lineBuffer[i + 1] == '=')) {
+					// it's a ':=', so style as an identifier
+					if (lastNonSpace >= 0)
+						styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
+					styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
+					styler.ColourTo(startLine + i + 1, SCE_MAKE_OPERATOR);
+				} else {
+					// We should check that no colouring was made since the beginning of the line,
+					// to avoid colouring stuff like /OUT:file
+					if (lastNonSpace >= 0)
+						styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
+					styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
+					styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
+				}
 				bSpecial = true;	// Only react to the first ':' of the line
 				state = SCE_MAKE_DEFAULT;
 			} else if (lineBuffer[i] == '=') {
@@ -792,11 +872,7 @@
 	}
 }
 
-static bool strstart(const char *haystack, const char *needle) {
-	return strncmp(haystack, needle, strlen(needle)) == 0;
-}
-
-static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine) {
+static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine, int &startValue) {
 	if (lineBuffer[0] == '>') {
 		// Command or return status
 		return SCE_ERR_CMD;
@@ -879,7 +955,9 @@
 		// Microsoft: <filename>(<line>,<column>)<message>
 		// CTags: \t<message>
 		// Lua 5 traceback: \t<filename>:<line>:<message>
+		// Lua 5.1: <exe>: <filename>:<line>:<message>
 		bool initialTab = (lineBuffer[0] == '\t');
+		bool initialColonPart = false;
 		enum { stInitial,
 			stGccStart, stGccDigit, stGcc,
 			stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
@@ -894,10 +972,12 @@
 			if (state == stInitial) {
 				if (ch == ':') {
 					// May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix)
-					if ((chNext != '\\') && (chNext != '/')) {
+					if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) {
 						// This check is not completely accurate as may be on
 						// GTK+ with a file name that includes ':'.
 						state = stGccStart;
+					} else if (chNext == ' ') { // indicates a Lua 5.1 error message
+						initialColonPart = true;
 					}
 				} else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) {
 					// May be Microsoft
@@ -912,6 +992,7 @@
 			} else if (state == stGccDigit) {	// <filename>:<line>
 				if (ch == ':') {
 					state = stGcc;	// :9.*: is GCC
+					startValue = i + 1;
 					break;
 				} else if (!Is0To9(ch)) {
 					state = stUnrecognized;
@@ -972,7 +1053,7 @@
 			}
 		}
 		if (state == stGcc) {
-			return SCE_ERR_GCC;
+			return initialColonPart ? SCE_ERR_LUA : SCE_ERR_GCC;
 		} else if ((state == stMsVc) || (state == stMsDotNet)) {
 			return SCE_ERR_MS;
 		} else if ((state == stCtagsStringDollar) || (state == stCtags)) {
@@ -987,8 +1068,16 @@
     char *lineBuffer,
     unsigned int lengthLine,
     unsigned int endPos,
-    Accessor &styler) {
-	styler.ColourTo(endPos, RecogniseErrorListLine(lineBuffer, lengthLine));
+    Accessor &styler,
+	bool valueSeparate) {
+	int startValue = -1;
+	int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue);
+	if (valueSeparate && (startValue >= 0)) {
+		styler.ColourTo(endPos - (lengthLine - startValue), style);
+		styler.ColourTo(endPos, SCE_ERR_VALUE);
+	} else {
+		styler.ColourTo(endPos, style);
+	}
 }
 
 static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
@@ -996,17 +1085,18 @@
 	styler.StartAt(startPos);
 	styler.StartSegment(startPos);
 	unsigned int linePos = 0;
+	bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0;
 	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';
-			ColouriseErrorListLine(lineBuffer, linePos, i, styler);
+			ColouriseErrorListLine(lineBuffer, linePos, i, styler, valueSeparate);
 			linePos = 0;
 		}
 	}
 	if (linePos > 0) {	// Last line does not have ending characters
-		ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
+		ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler, valueSeparate);
 	}
 }
 
@@ -1133,6 +1223,7 @@
 
 LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
 LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc);
+LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc);
 LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
 LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
 LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexPB.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPB.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPB.cxx	Sat Nov 15 17:50:33 2008
@@ -48,6 +48,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsTypeCharacter(const int ch)
 {
     return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$' || ch == '?';

Added: trunk/plugins/editor/scintilla/LexPLM.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexPLM.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,198 @@
+// Copyright (c) 1990-2007, Scientific Toolworks, Inc.
+// Author: Jason Haslam
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "StyleContext.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static void GetRange(unsigned int start,
+                     unsigned int end,
+                     Accessor &styler,
+                     char *s,
+                     unsigned int len) {
+	unsigned int i = 0;
+	while ((i < end - start + 1) && (i < len-1)) {
+		s[i] = static_cast<char>(tolower(styler[start + i]));
+		i++;
+	}
+	s[i] = '\0';
+}
+
+static void ColourisePlmDoc(unsigned int startPos,
+                            int length,
+                            int initStyle,
+                            WordList *keywordlists[],
+                            Accessor &styler)
+{
+	unsigned int endPos = startPos + length;
+	int state = initStyle;
+
+	styler.StartAt(startPos);
+	styler.StartSegment(startPos);
+
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = styler.SafeGetCharAt(i);
+		char chNext = styler.SafeGetCharAt(i + 1);
+
+		if (state == SCE_PLM_DEFAULT) {
+			if (ch == '/' && chNext == '*') {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_COMMENT;
+			} else if (ch == '\'') {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_STRING;
+			} else if (isdigit(ch)) {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_NUMBER;
+			} else if (isalpha(ch)) {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_IDENTIFIER;
+			} else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
+			           ch == '=' || ch == '<' || ch == '>' || ch == ':') {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_OPERATOR;
+			} else if (ch == '$') {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_CONTROL;
+			}
+		} else if (state == SCE_PLM_COMMENT) {
+			if (ch == '*' && chNext == '/') {
+				i++;
+				styler.ColourTo(i, state);
+				state = SCE_PLM_DEFAULT;
+			}
+		} else if (state == SCE_PLM_STRING) {
+			if (ch == '\'') {
+				if (chNext == '\'') {
+					i++;
+				} else {
+					styler.ColourTo(i, state);
+					state = SCE_PLM_DEFAULT;
+				}
+			}
+		} else if (state == SCE_PLM_NUMBER) {
+			if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
+				i--;
+				styler.ColourTo(i, state);
+				state = SCE_PLM_DEFAULT;
+			}
+		} else if (state == SCE_PLM_IDENTIFIER) {
+			if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
+				// Get the entire identifier.
+				char word[1024];
+				int segmentStart = styler.GetStartSegment();
+				GetRange(segmentStart, i - 1, styler, word, sizeof(word));
+
+				i--;
+				if (keywordlists[0]->InList(word))
+					styler.ColourTo(i, SCE_PLM_KEYWORD);
+				else
+					styler.ColourTo(i, state);
+				state = SCE_PLM_DEFAULT;
+			}
+		} else if (state == SCE_PLM_OPERATOR) {
+			if (ch != '=' && ch != '>') {
+				i--;
+				styler.ColourTo(i, state);
+				state = SCE_PLM_DEFAULT;
+			}
+		} else if (state == SCE_PLM_CONTROL) {
+			if (ch == '\r' || ch == '\n') {
+				styler.ColourTo(i - 1, state);
+				state = SCE_PLM_DEFAULT;
+			}
+		}
+	}
+	styler.ColourTo(endPos - 1, state);
+}
+
+static void FoldPlmDoc(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;
+	int startKeyword = 0;
+
+	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 (stylePrev != SCE_PLM_KEYWORD && style == SCE_PLM_KEYWORD)
+			startKeyword = i;
+
+		if (style == SCE_PLM_KEYWORD && styleNext != SCE_PLM_KEYWORD) {
+			char word[1024];
+			GetRange(startKeyword, i, styler, word, sizeof(word));
+
+			if (strcmp(word, "procedure") == 0 || strcmp(word, "do") == 0)
+				levelCurrent++;
+			else if (strcmp(word, "end") == 0)
+				levelCurrent--;
+		}
+
+		if (foldComment) {
+			if (stylePrev != SCE_PLM_COMMENT && style == SCE_PLM_COMMENT)
+				levelCurrent++;
+			else if (stylePrev == SCE_PLM_COMMENT && style != SCE_PLM_COMMENT)
+				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++;
+	}
+
+	int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+	styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char *const plmWordListDesc[] = {
+	"Keywords",
+	0
+};
+
+LexerModule lmPLM(SCLEX_PLM, ColourisePlmDoc, "PL/M", FoldPlmDoc, plmWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexPOV.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPOV.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPOV.cxx	Sat Nov 15 17:50:33 2008
@@ -29,6 +29,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsAWordChar(int ch) {
 	return ch < 0x80 && (isalnum(ch) || ch == '_');
 }

Modified: trunk/plugins/editor/scintilla/LexPS.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPS.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPS.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsASelfDelimitingChar(const int ch) {
     return (ch == '[' || ch == ']' || ch == '{' || ch == '}' ||
             ch == '/' || ch == '<' || ch == '>' ||
@@ -103,7 +107,7 @@
                     sc.SetState(SCE_C_DEFAULT);
             } else if (sc.atLineEnd) {
                 sc.SetState(SCE_C_DEFAULT);
-            } else if (IsAWhitespaceChar(sc.ch)) {
+            } else if (IsAWhitespaceChar(sc.ch) && sc.ch != '\r') {
                 sc.ChangeState(SCE_PS_COMMENT);
             }
         } else if (sc.state == SCE_PS_NUMBER) {

Modified: trunk/plugins/editor/scintilla/LexPascal.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPascal.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPascal.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void getRange(unsigned int start,
 		unsigned int end,
 		Accessor &styler,
@@ -289,7 +293,7 @@
 		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
 
-		if (stylePrev == SCE_C_DEFAULT && style == SCE_C_WORD)
+		if (stylePrev != SCE_C_WORD && style == SCE_C_WORD)
 		{
 			// Store last word start point.
 			lastStart = i;

Modified: trunk/plugins/editor/scintilla/LexPerl.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPerl.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPerl.cxx	Sat Nov 15 17:50:33 2008
@@ -1,8 +1,8 @@
 // Scintilla source code edit control
 /** @file LexPerl.cxx
- ** Lexer for subset of Perl.
+ ** Lexer for Perl.
  **/
-// Copyright 1998-2005 by Neil Hodgson <neilh scintilla org>
+// Copyright 1998-2008 by Neil Hodgson <neilh scintilla org>
 // Lexical analysis fixes by Kein-Hong Man <mkh pl jaring my>
 // The License.txt file describes the conditions under which this software may be distributed.
 
@@ -16,158 +16,336 @@
 
 #include "PropSet.h"
 #include "Accessor.h"
+#include "StyleContext.h"
 #include "KeyWords.h"
 #include "Scintilla.h"
 #include "SciLexer.h"
+#include "CharacterSet.h"
 
-#define PERLNUM_BINARY 1    // order is significant: 1-4 cannot have a dot
-#define PERLNUM_HEX 2
-#define PERLNUM_OCTAL 3
-#define PERLNUM_FLOAT 4     // actually exponent part
-#define PERLNUM_DECIMAL 5   // 1-5 are numbers; 6-7 are strings
-#define PERLNUM_VECTOR 6
-#define PERLNUM_V_VECTOR 7
-#define PERLNUM_BAD 8
-
-#define BACK_NONE 0         // lookback state for bareword disambiguation:
-#define BACK_OPERATOR 1     // whitespace/comments are insignificant
-#define BACK_KEYWORD 2      // operators/keywords are needed for disambiguation
-
-#define HERE_DELIM_MAX 256
-
-static inline bool isEOLChar(char ch) {
-	return (ch == '\r') || (ch == '\n');
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+// Info for HERE document handling from perldata.pod (reformatted):
+// ----------------------------------------------------------------
+// A line-oriented form of quoting is based on the shell ``here-doc'' syntax.
+// Following a << you specify a string to terminate the quoted material, and
+// all lines following the current line down to the terminating string are
+// the value of the item.
+// * The terminating string may be either an identifier (a word), or some
+//   quoted text.
+// * If quoted, the type of quotes you use determines the treatment of the
+//   text, just as in regular quoting.
+// * An unquoted identifier works like double quotes.
+// * There must be no space between the << and the identifier.
+//   (If you put a space it will be treated as a null identifier,
+//    which is valid, and matches the first empty line.)
+//   (This is deprecated, -w warns of this syntax)
+// * The terminating string must appear by itself (unquoted and
+//   with no surrounding whitespace) on the terminating line.
+
+#define HERE_DELIM_MAX 256		// maximum length of HERE doc delimiter
+
+#define PERLNUM_BINARY		1	// order is significant: 1-4 cannot have a dot
+#define PERLNUM_HEX			2
+#define PERLNUM_OCTAL		3
+#define PERLNUM_FLOAT_EXP	4	// exponent part only
+#define PERLNUM_DECIMAL		5	// 1-5 are numbers; 6-7 are strings
+#define PERLNUM_VECTOR		6
+#define PERLNUM_V_VECTOR	7
+#define PERLNUM_BAD			8
+
+#define BACK_NONE		0	// lookback state for bareword disambiguation:
+#define BACK_OPERATOR	1	// whitespace/comments are insignificant
+#define BACK_KEYWORD	2	// operators/keywords are needed for disambiguation
+
+static bool isPerlKeyword(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler)
+{
+	// old-style keyword matcher; needed because GetCurrent() needs
+	// current segment to be committed, but we may abandon early...
+	char s[100];
+	unsigned int i, len = end - start;
+	if (len > 30) { len = 30; }
+	for (i = 0; i < len; i++, start++) s[i] = styler[start];
+	s[i] = '\0';
+	return keywords.InList(s);
 }
 
-static bool isSingleCharOp(char ch) {
-	char strCharSet[2];
-	strCharSet[0] = ch;
-	strCharSet[1] = '\0';
-	return (NULL != strstr("rwxoRWXOezsfdlpSbctugkTBMAC", strCharSet));
+static int disambiguateBareword(Accessor &styler, unsigned int bk, unsigned int fw,
+                                int backFlag, unsigned int backPos, unsigned int endPos)
+{
+	// identifiers are recognized by Perl as barewords under some
+	// conditions, the following attempts to do the disambiguation
+	// by looking backward and forward; result in 2 LSB
+	int result = 0;
+	bool moreback = false;		// true if passed newline/comments
+	bool brace = false;			// true if opening brace found
+	// if BACK_NONE, neither operator nor keyword, so skip test
+	if (backFlag == BACK_NONE)
+		return result;
+	// first look backwards past whitespace/comments to set EOL flag
+	// (some disambiguation patterns must be on a single line)
+	if (backPos <= static_cast<unsigned int>(styler.LineStart(styler.GetLine(bk))))
+		moreback = true;
+	// look backwards at last significant lexed item for disambiguation
+	bk = backPos - 1;
+	int ch = static_cast<unsigned char>(styler.SafeGetCharAt(bk));
+	if (ch == '{' && !moreback) {
+		// {bareword: possible variable spec
+		brace = true;
+	} else if ((ch == '&' && styler.SafeGetCharAt(bk - 1) != '&')
+			// &bareword: subroutine call
+			   || styler.Match(bk - 1, "->")
+			// ->bareword: part of variable spec
+			   || styler.Match(bk - 2, "sub")) {
+			// sub bareword: subroutine declaration
+			// (implied BACK_KEYWORD, no keywords end in 'sub'!)
+		result |= 1;
+	}
+	// next, scan forward after word past tab/spaces only;
+	// if ch isn't one of '[{(,' we can skip the test
+	if ((ch == '{' || ch == '(' || ch == '['|| ch == ',')
+		&& fw < endPos) {
+		while (ch = static_cast<unsigned char>(styler.SafeGetCharAt(fw)),
+			   IsASpaceOrTab(ch) && fw < endPos) {
+			fw++;
+		}
+		if ((ch == '}' && brace)
+			// {bareword}: variable spec
+			|| styler.Match(fw, "=>")) {
+			// [{(, bareword=>: hash literal
+			result |= 2;
+		}
+	}
+	return result;
 }
 
-static inline bool isPerlOperator(char ch) {
-	if (ch == '^' || ch == '&' || ch == '\\' ||
-	        ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
-	        ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
-	        ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
-	        ch == '>' || ch == ',' ||
-	        ch == '?' || ch == '!' || ch == '.' || ch == '~')
-		return true;
-	// these chars are already tested before this call
-	// ch == '%' || ch == '*' || ch == '<' || ch == '/' ||
-	return false;
+static void skipWhitespaceComment(Accessor &styler, unsigned int &p)
+{
+	// when backtracking, we need to skip whitespace and comments
+	int style;
+	while ((p > 0) && (style = styler.StyleAt(p),
+		   style == SCE_PL_DEFAULT || style == SCE_PL_COMMENTLINE))
+		p--;
 }
 
-static bool isPerlKeyword(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
-	char s[100];
-    unsigned int i, len = end - start;
-    if (len > 30) { len = 30; }
-	for (i = 0; i < len; i++, start++) s[i] = styler[start];
-    s[i] = '\0';
-	return keywords.InList(s);
+static int styleBeforeBracePair(Accessor &styler, unsigned int bk)
+{
+	// backtrack to find open '{' corresponding to a '}', balanced
+	// return significant style to be tested for '/' disambiguation
+	int braceCount = 1;
+	if (bk == 0)
+		return SCE_PL_DEFAULT;
+	while (--bk > 0) {
+		if (styler.StyleAt(bk) == SCE_PL_OPERATOR) {
+			int bkch = static_cast<unsigned char>(styler.SafeGetCharAt(bk));
+			if (bkch == ';') {	// early out
+				break;
+			} else if (bkch == '}') {
+				braceCount++;
+			} else if (bkch == '{') {
+				if (--braceCount == 0) break;
+			}
+		}
+	}
+	if (bk > 0 && braceCount == 0) {
+		// balanced { found, bk > 0, skip more whitespace/comments
+		bk--;
+		skipWhitespaceComment(styler, bk);
+		return styler.StyleAt(bk);
+	}
+	return SCE_PL_DEFAULT;
 }
 
-// Note: as lexer uses chars, UTF-8 bytes are considered as <0 values
-// Note: iswordchar() was used in only one place in LexPerl, it is
-// unnecessary as '.' is processed as the concatenation operator, so
-// only isWordStart() is used in LexPerl
+static int styleCheckIdentifier(Accessor &styler, unsigned int bk)
+{
+	// backtrack to classify sub-styles of identifier under test
+	// return sub-style to be tested for '/' disambiguation
+	if (styler.SafeGetCharAt(bk) == '>')	// inputsymbol, like <foo>
+		return 1;
+	// backtrack to check for possible "->" or "::" before identifier
+	while (bk > 0 && styler.StyleAt(bk) == SCE_PL_IDENTIFIER) {
+		bk--;
+	}
+	while (bk > 0) {
+		int bkstyle = styler.StyleAt(bk);
+		if (bkstyle == SCE_PL_DEFAULT
+			|| bkstyle == SCE_PL_COMMENTLINE) {
+			// skip whitespace, comments
+		} else if (bkstyle == SCE_PL_OPERATOR) {
+			// test for "->" and "::"
+			if (styler.Match(bk - 1, "->") || styler.Match(bk - 1, "::"))
+				return 2;
+		} else
+			return 3;	// bare identifier
+		bk--;
+	}
+	return 0;
+}
 
-static inline bool isWordStart(char ch) {
-	return !isascii(ch) || isalnum(ch) || ch == '_';
+static int inputsymbolScan(Accessor &styler, unsigned int pos, unsigned int endPos)
+{
+	// looks forward for matching > on same line; a bit ugly
+	unsigned int fw = pos;
+	while (++fw < endPos) {
+		int fwch = static_cast<unsigned char>(styler.SafeGetCharAt(fw));
+		if (fwch == '\r' || fwch == '\n') {
+			return 0;
+		} else if (fwch == '>') {
+			if (styler.Match(fw - 2, "<=>"))	// '<=>' case
+				return 0;
+			return fw - pos;
+		}
+	}
+	return 0;
 }
 
-static inline bool isEndVar(char ch) {
-	return isascii(ch) && !isalnum(ch) && ch != '#' && ch != '$' &&
-	       ch != '_' && ch != '\'';
+static int podLineScan(Accessor &styler, unsigned int &pos, unsigned int endPos)
+{
+	// forward scan the current line to classify line for POD style
+	int state = -1;
+	while (pos <= endPos) {
+		int ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
+		if (ch == '\n' || ch == '\r' || pos >= endPos) {
+			if (ch == '\r' && styler.SafeGetCharAt(pos + 1) == '\n') pos++;
+			break;
+		}
+		if (IsASpaceOrTab(ch)) {	// whitespace, take note
+			if (state == -1)
+				state = SCE_PL_DEFAULT;
+		} else if (state == SCE_PL_DEFAULT) {	// verbatim POD line
+			state = SCE_PL_POD_VERB;
+		} else if (state != SCE_PL_POD_VERB) {	// regular POD line
+			state = SCE_PL_POD;
+		}
+		pos++;
+	}
+	if (state == -1)
+		state = SCE_PL_DEFAULT;
+	return state;
 }
 
-static inline bool isNonQuote(char ch) {
-	return !isascii(ch) || isalnum(ch) || ch == '_';
+static bool styleCheckSubPrototype(Accessor &styler, unsigned int bk)
+{
+	// backtrack to identify if we're starting a subroutine prototype
+	// we also need to ignore whitespace/comments:
+	// 'sub' [whitespace|comment] <identifier> [whitespace|comment]
+	styler.Flush();
+	skipWhitespaceComment(styler, bk);
+	if (bk == 0 || styler.StyleAt(bk) != SCE_PL_IDENTIFIER)	// check identifier
+		return false;
+	while (bk > 0 && (styler.StyleAt(bk) == SCE_PL_IDENTIFIER)) {
+		bk--;
+	}
+	skipWhitespaceComment(styler, bk);
+	if (bk < 2 || styler.StyleAt(bk) != SCE_PL_WORD	// check "sub" keyword
+		|| !styler.Match(bk - 2, "sub"))	// assume suffix is unique!
+		return false;
+	return true;
 }
 
-static inline char actualNumStyle(int numberStyle) {
-    if (numberStyle == PERLNUM_VECTOR || numberStyle == PERLNUM_V_VECTOR) {
-        return SCE_PL_STRING;
-    } else if (numberStyle == PERLNUM_BAD) {
-        return SCE_PL_ERROR;
-    }
-    return SCE_PL_NUMBER;
+static bool isMatch(const char *sref, char *s)
+{
+	// match per-line delimiter - must kill trailing CR if CRLF
+	if (s[strlen(s) - 1] == '\r')
+		s[strlen(s) - 1] = '\0';
+	return (strcmp(sref, s) == 0);
 }
 
-static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
-	if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
-		return false;
+static int actualNumStyle(int numberStyle) {
+	if (numberStyle == PERLNUM_VECTOR || numberStyle == PERLNUM_V_VECTOR) {
+		return SCE_PL_STRING;
+	} else if (numberStyle == PERLNUM_BAD) {
+		return SCE_PL_ERROR;
 	}
-	while (*val) {
-		if (*val != styler[pos++]) {
-			return false;
-		}
-		val++;
-	}
-	return true;
+	return SCE_PL_NUMBER;
 }
 
-static char opposite(char ch) {
-	if (ch == '(')
-		return ')';
-	if (ch == '[')
-		return ']';
-	if (ch == '{')
-		return '}';
-	if (ch == '<')
-		return '>';
+static int opposite(int ch) {
+	if (ch == '(') return ')';
+	if (ch == '[') return ']';
+	if (ch == '{') return '}';
+	if (ch == '<') return '>';
 	return ch;
 }
 
 static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
                              WordList *keywordlists[], Accessor &styler) {
 
+	WordList &keywords = *keywordlists[0];
+
+	// keywords that forces /PATTERN/ at all times; should track vim's behaviour
+	WordList reWords;
+	reWords.Set("elsif if split while");
+
+	// charset classes
+	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+	CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
+	CharacterSet setSingleCharOp(CharacterSet::setNone, "rwxoRWXOezsfdlpSbctugkTBMAC");
+	// lexing of "%*</" operators is non-trivial; these are missing in the set below
+	CharacterSet setPerlOperator(CharacterSet::setNone, "^&\\()-+=|{}[]:;>,?!.~");
+	CharacterSet setQDelim(CharacterSet::setNone, "qrwx");
+	CharacterSet setModifiers(CharacterSet::setAlpha);
+	CharacterSet setPreferRE(CharacterSet::setNone, "*/<%");
+	// setArray and setHash also accepts chars for special vars like $_,
+	// which are then truncated when the next char does not match setVar
+	CharacterSet setVar(CharacterSet::setAlphaNum, "#$_'", 0x80, true);
+	CharacterSet setArray(CharacterSet::setAlpha, "#$_+-", 0x80, true);
+	CharacterSet setHash(CharacterSet::setAlpha, "#$_!^+-", 0x80, true);
+	CharacterSet &setPOD = setModifiers;
+	CharacterSet setNonHereDoc(CharacterSet::setDigits, "=$@");
+	CharacterSet setHereDocDelim(CharacterSet::setAlphaNum, "_");
+	CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$ %&*];");
+	// for format identifiers
+	CharacterSet setFormatStart(CharacterSet::setAlpha, "_=");
+	CharacterSet &setFormat = setHereDocDelim;
+
 	// Lexer for perl often has to backtrack to start of current style to determine
 	// which characters are being used as quotes, how deeply nested is the
-	// start position and what the termination string is for here documents
+	// start position and what the termination string is for HERE documents.
 
-	WordList &keywords = *keywordlists[0];
-
-	class HereDocCls {
+	class HereDocCls {	// Class to manage HERE doc sequence
 	public:
 		int State;		// 0: '<<' encountered
-		// 1: collect the delimiter
-		// 2: here doc text (lines after the delimiter)
-		char Quote;		// the char after '<<'
+						// 1: collect the delimiter
+						// 2: here doc text (lines after the delimiter)
+		int Quote;		// the char after '<<'
 		bool Quoted;		// true if Quote in ('\'','"','`')
 		int DelimiterLength;	// strlen(Delimiter)
 		char *Delimiter;	// the Delimiter, 256: sizeof PL_tokenbuf
 		HereDocCls() {
 			State = 0;
-            Quote = 0;
-            Quoted = false;
+			Quote = 0;
+			Quoted = false;
 			DelimiterLength = 0;
 			Delimiter = new char[HERE_DELIM_MAX];
 			Delimiter[0] = '\0';
 		}
+		void Append(int ch) {
+			Delimiter[DelimiterLength++] = static_cast<char>(ch);
+			Delimiter[DelimiterLength] = '\0';
+		}
 		~HereDocCls() {
 			delete []Delimiter;
 		}
 	};
-	HereDocCls HereDoc;	// TODO: FIFO for stacked here-docs
+	HereDocCls HereDoc;		// TODO: FIFO for stacked here-docs
 
-	class QuoteCls {
+	class QuoteCls {	// Class to manage quote pairs
 		public:
-		int  Rep;
-		int  Count;
-		char Up;
-		char Down;
+		int Rep;
+		int Count;
+		int Up, Down;
 		QuoteCls() {
 			this->New(1);
 		}
-		void New(int r) {
+		void New(int r = 1) {
 			Rep   = r;
 			Count = 0;
 			Up    = '\0';
 			Down  = '\0';
 		}
-		void Open(char u) {
+		void Open(int u) {
 			Count++;
 			Up    = u;
 			Down  = opposite(Up);
@@ -175,490 +353,700 @@
 	};
 	QuoteCls Quote;
 
-	int state = initStyle;
-	char numState = PERLNUM_DECIMAL;
+	// additional state for number lexing
+	int numState = PERLNUM_DECIMAL;
 	int dotCount = 0;
-	unsigned int lengthDoc = startPos + length;
-	//int sookedpos = 0; // these have no apparent use, see POD state
-	//char sooked[100];
-	//sooked[sookedpos] = '\0';
-
-	// If in a long distance lexical state, seek to the beginning to find quote characters
-	// Perl strings can be multi-line with embedded newlines, so backtrack.
-	// Perl numbers have additional state during lexing, so backtrack too.
-	if (state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX) {
-		while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_PL_HERE_DELIM)) {
+
+	unsigned int endPos = startPos + length;
+
+	// Backtrack to beginning of style if required...
+	// If in a long distance lexical state, backtrack to find quote characters.
+	// Includes strings (may be multi-line), numbers (additional state), format
+	// bodies, as well as POD sections.
+	if (initStyle == SCE_PL_HERE_Q
+		|| initStyle == SCE_PL_HERE_QQ
+		|| initStyle == SCE_PL_HERE_QX
+		|| initStyle == SCE_PL_FORMAT
+	) {
+		int delim = (initStyle == SCE_PL_FORMAT) ? SCE_PL_FORMAT_IDENT:SCE_PL_HERE_DELIM;
+		while ((startPos > 1) && (styler.StyleAt(startPos) != delim)) {
 			startPos--;
 		}
 		startPos = styler.LineStart(styler.GetLine(startPos));
-		state = styler.StyleAt(startPos - 1);
+		initStyle = styler.StyleAt(startPos - 1);
 	}
-	if ( state == SCE_PL_STRING_Q
-	|| state == SCE_PL_STRING_QQ
-	|| state == SCE_PL_STRING_QX
-	|| state == SCE_PL_STRING_QR
-	|| state == SCE_PL_STRING_QW
-	|| state == SCE_PL_REGEX
-	|| state == SCE_PL_REGSUBST
-	|| state == SCE_PL_STRING
-	|| state == SCE_PL_BACKTICKS
-	|| state == SCE_PL_CHARACTER
-	|| state == SCE_PL_NUMBER
-	|| state == SCE_PL_IDENTIFIER
-    || state == SCE_PL_ERROR
+	if (initStyle == SCE_PL_STRING_Q
+		|| initStyle == SCE_PL_STRING_QQ
+		|| initStyle == SCE_PL_STRING_QX
+		|| initStyle == SCE_PL_STRING_QR
+		|| initStyle == SCE_PL_STRING_QW
+		|| initStyle == SCE_PL_REGEX
+		|| initStyle == SCE_PL_REGSUBST
+		|| initStyle == SCE_PL_STRING
+		|| initStyle == SCE_PL_BACKTICKS
+		|| initStyle == SCE_PL_CHARACTER
+		|| initStyle == SCE_PL_NUMBER
+		|| initStyle == SCE_PL_IDENTIFIER
+		|| initStyle == SCE_PL_ERROR
+		|| initStyle == SCE_PL_SUB_PROTOTYPE
 	) {
-		while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
+		while ((startPos > 1) && (styler.StyleAt(startPos - 1) == initStyle)) {
 			startPos--;
 		}
-		state = SCE_PL_DEFAULT;
+		initStyle = SCE_PL_DEFAULT;
+	} else if (initStyle == SCE_PL_POD
+			   || initStyle == SCE_PL_POD_VERB
+	) {
+		// POD backtracking finds preceeding blank lines and goes back past them
+		int ln = styler.GetLine(startPos);
+		if (ln > 0) {
+			initStyle = styler.StyleAt(styler.LineStart(--ln));
+			if (initStyle == SCE_PL_POD || initStyle == SCE_PL_POD_VERB) {
+				while (ln > 0 && styler.GetLineState(ln) == SCE_PL_DEFAULT)
+					ln--;
+			}
+			startPos = styler.LineStart(++ln);
+			initStyle = styler.StyleAt(startPos - 1);
+		} else {
+			startPos = 0;
+			initStyle = SCE_PL_DEFAULT;
+		}
 	}
 
-    // lookback at start of lexing to set proper state for backflag
-    // after this, they are updated when elements are lexed
-    int backflag = BACK_NONE;
-    unsigned int backPos = startPos;
-    if (backPos > 0) {
-        backPos--;
-        int sty = SCE_PL_DEFAULT;
-        while ((backPos > 0) && (sty = styler.StyleAt(backPos),
-               sty == SCE_PL_DEFAULT || sty == SCE_PL_COMMENTLINE))
-            backPos--;
-        if (sty == SCE_PL_OPERATOR)
-            backflag = BACK_OPERATOR;
-        else if (sty == SCE_PL_WORD)
-            backflag = BACK_KEYWORD;
-    }
+	// backFlag, backPos are additional state to aid identifier corner cases.
+	// Look backwards past whitespace and comments in order to detect either
+	// operator or keyword. Later updated as we go along.
+	int backFlag = BACK_NONE;
+	unsigned int backPos = startPos;
+	if (backPos > 0) {
+		backPos--;
+		skipWhitespaceComment(styler, backPos);
+		if (styler.StyleAt(backPos) == SCE_PL_OPERATOR)
+			backFlag = BACK_OPERATOR;
+		else if (styler.StyleAt(backPos) == SCE_PL_WORD)
+			backFlag = BACK_KEYWORD;
+		backPos++;
+	}
 
-	styler.StartAt(startPos);
-	char chPrev = styler.SafeGetCharAt(startPos - 1);
-	if (startPos == 0)
-		chPrev = '\n';
-	char chNext = styler[startPos];
-	styler.StartSegment(startPos);
+	StyleContext sc(startPos, endPos - startPos, initStyle, styler, static_cast<char>(STYLE_MAX));
 
-	for (unsigned int i = startPos; i < lengthDoc; i++) {
-		char ch = chNext;
-		// if the current character is not consumed due to the completion of an
-		// earlier style, lexing can be restarted via a simple goto
-	restartLexer:
-		chNext = styler.SafeGetCharAt(i + 1);
-		char chNext2 = styler.SafeGetCharAt(i + 2);
+	for (; sc.More(); sc.Forward()) {
 
-		if (styler.IsLeadByte(ch)) {
-			chNext = styler.SafeGetCharAt(i + 2);
-			chPrev = ' ';
-			i += 1;
-			continue;
+		// Determine if the current state should terminate.
+		switch (sc.state) {
+			case SCE_PL_OPERATOR:
+				sc.SetState(SCE_PL_DEFAULT);
+				backFlag = BACK_OPERATOR;
+				backPos = sc.currentPos;
+				break;
+			case SCE_PL_IDENTIFIER:		// identifier, bareword, inputsymbol
+				if ((!setWord.Contains(sc.ch) && sc.ch != '\'')
+					|| sc.Match('.', '.')
+					|| sc.chPrev == '>') {	// end of inputsymbol
+					sc.SetState(SCE_PL_DEFAULT);
+				}
+				break;
+			case SCE_PL_WORD:		// keyword, plus special cases
+				if (!setWord.Contains(sc.ch)) {
+					char s[100];
+					sc.GetCurrent(s, sizeof(s));
+					if ((strcmp(s, "__DATA__") == 0) || (strcmp(s, "__END__") == 0)) {
+						sc.ChangeState(SCE_PL_DATASECTION);
+					} else {
+						if ((strcmp(s, "format") == 0)) {
+							sc.SetState(SCE_PL_FORMAT_IDENT);
+							HereDoc.State = 0;
+						} else {
+							sc.SetState(SCE_PL_DEFAULT);
+						}
+						backFlag = BACK_KEYWORD;
+						backPos = sc.currentPos;
+					}
+				}
+				break;
+			case SCE_PL_SCALAR:
+			case SCE_PL_ARRAY:
+			case SCE_PL_HASH:
+			case SCE_PL_SYMBOLTABLE:
+				if (sc.Match(':', ':')) {	// skip ::
+					sc.Forward();
+				} else if (!setVar.Contains(sc.ch)) {
+					if (sc.LengthCurrent() == 1) {
+						// Special variable: $(, $_ etc.
+						sc.Forward();
+					}
+					sc.SetState(SCE_PL_DEFAULT);
+				}
+				break;
+			case SCE_PL_NUMBER:
+				// if no early break, number style is terminated at "(go through)"
+				if (sc.ch == '.') {
+					if (sc.chNext == '.') {
+						// double dot is always an operator (go through)
+					} else if (numState <= PERLNUM_FLOAT_EXP) {
+						// non-decimal number or float exponent, consume next dot
+						sc.SetState(SCE_PL_OPERATOR);
+						break;
+					} else {	// decimal or vectors allows dots
+						dotCount++;
+						if (numState == PERLNUM_DECIMAL) {
+							if (dotCount <= 1)	// number with one dot in it
+								break;
+							if (IsADigit(sc.chNext)) {	// really a vector
+								numState = PERLNUM_VECTOR;
+								break;
+							}
+							// number then dot (go through)
+						} else if (IsADigit(sc.chNext))	// vectors
+							break;
+						// vector then dot (go through)
+					}
+				} else if (sc.ch == '_') {
+					// permissive underscoring for number and vector literals
+					break;
+				} else if (numState == PERLNUM_DECIMAL) {
+					if (sc.ch == 'E' || sc.ch == 'e') {	// exponent, sign
+						numState = PERLNUM_FLOAT_EXP;
+						if (sc.chNext == '+' || sc.chNext == '-') {
+							sc.Forward();
+						}
+						break;
+					} else if (IsADigit(sc.ch))
+						break;
+					// number then word (go through)
+				} else if (numState == PERLNUM_HEX) {
+					if (IsADigit(sc.ch, 16))
+						break;
+				} else if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) {
+					if (IsADigit(sc.ch))	// vector
+						break;
+					if (setWord.Contains(sc.ch) && dotCount == 0) {	// change to word
+						sc.ChangeState(SCE_PL_IDENTIFIER);
+						break;
+					}
+					// vector then word (go through)
+				} else if (IsADigit(sc.ch)) {
+					if (numState == PERLNUM_FLOAT_EXP) {
+						break;
+					} else if (numState == PERLNUM_OCTAL) {
+						if (sc.ch <= '7') break;
+					} else if (numState == PERLNUM_BINARY) {
+						if (sc.ch <= '1') break;
+					}
+					// mark invalid octal, binary numbers (go through)
+					numState = PERLNUM_BAD;
+					break;
+				}
+				// complete current number or vector
+				sc.ChangeState(actualNumStyle(numState));
+				sc.SetState(SCE_PL_DEFAULT);
+				break;
+			case SCE_PL_COMMENTLINE:
+				if (sc.atLineEnd) {
+					sc.SetState(SCE_PL_DEFAULT);
+				}
+				break;
+			case SCE_PL_HERE_DELIM:
+				if (HereDoc.State == 0) { // '<<' encountered
+					int delim_ch = sc.chNext;
+					int ws_skip = 0;
+					HereDoc.State = 1;	// pre-init HERE doc class
+					HereDoc.Quote = sc.chNext;
+					HereDoc.Quoted = false;
+					HereDoc.DelimiterLength = 0;
+					HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+					if (IsASpaceOrTab(delim_ch)) {
+						// skip whitespace; legal only for quoted delimiters
+						unsigned int i = sc.currentPos + 1;
+						while ((i < endPos) && IsASpaceOrTab(delim_ch)) {
+							i++;
+							delim_ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
+						}
+						ws_skip = i - sc.currentPos - 1;
+					}
+					if (delim_ch == '\'' || delim_ch == '"' || delim_ch == '`') {
+						// a quoted here-doc delimiter; skip any whitespace
+						sc.Forward(ws_skip + 1);
+						HereDoc.Quote = delim_ch;
+						HereDoc.Quoted = true;
+					} else if (ws_skip == 0 && setNonHereDoc.Contains(sc.chNext)
+							   || ws_skip > 0) {
+						// left shift << or <<= operator cases
+						// restore position if operator
+						sc.ChangeState(SCE_PL_OPERATOR);
+						sc.ForwardSetState(SCE_PL_DEFAULT);
+						backFlag = BACK_OPERATOR;
+						backPos = sc.currentPos;
+						HereDoc.State = 0;
+					} else {
+						// specially handle initial '\' for identifier
+						if (ws_skip == 0 && HereDoc.Quote == '\\')
+							sc.Forward();
+						// an unquoted here-doc delimiter, no special handling
+						// (cannot be prefixed by spaces/tabs), or
+						// symbols terminates; deprecated zero-length delimiter
+					}
+				} else if (HereDoc.State == 1) { // collect the delimiter
+					backFlag = BACK_NONE;
+					if (HereDoc.Quoted) { // a quoted here-doc delimiter
+						if (sc.ch == HereDoc.Quote) { // closing quote => end of delimiter
+							sc.ForwardSetState(SCE_PL_DEFAULT);
+						} else if (!sc.atLineEnd) {
+							if (sc.Match('\\', static_cast<char>(HereDoc.Quote))) { // escaped quote
+								sc.Forward();
+							}
+							if (sc.ch != '\r') {	// skip CR if CRLF
+								HereDoc.Append(sc.ch);
+							}
+						}
+					} else { // an unquoted here-doc delimiter
+						if (setHereDocDelim.Contains(sc.ch)) {
+							HereDoc.Append(sc.ch);
+						} else {
+							sc.SetState(SCE_PL_DEFAULT);
+						}
+					}
+					if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) {
+						sc.SetState(SCE_PL_ERROR);
+						HereDoc.State = 0;
+					}
+				}
+				break;
+			case SCE_PL_HERE_Q:
+			case SCE_PL_HERE_QQ:
+			case SCE_PL_HERE_QX: {
+				// also implies HereDoc.State == 2
+				sc.Complete();
+				while (!sc.atLineEnd)
+					sc.Forward();
+				char s[HERE_DELIM_MAX];
+				sc.GetCurrent(s, sizeof(s));
+				if (isMatch(HereDoc.Delimiter, s)) {
+					sc.SetState(SCE_PL_DEFAULT);
+					backFlag = BACK_NONE;
+					HereDoc.State = 0;
+				}
+				} break;
+			case SCE_PL_POD:
+			case SCE_PL_POD_VERB: {
+				unsigned int fw = sc.currentPos;
+				int ln = styler.GetLine(fw);
+				if (sc.atLineStart && sc.Match("=cut")) {	// end of POD
+					sc.SetState(SCE_PL_POD);
+					sc.Forward(4);
+					sc.SetState(SCE_PL_DEFAULT);
+					styler.SetLineState(ln, SCE_PL_POD);
+					break;
+				}
+				int pod = podLineScan(styler, fw, endPos);	// classify POD line
+				styler.SetLineState(ln, pod);
+				if (pod == SCE_PL_DEFAULT) {
+					if (sc.state == SCE_PL_POD_VERB) {
+						unsigned int fw2 = fw;
+						while (fw2 <= endPos && pod == SCE_PL_DEFAULT) {
+							fw = fw2++;	// penultimate line (last blank line)
+							pod = podLineScan(styler, fw2, endPos);
+							styler.SetLineState(styler.GetLine(fw2), pod);
+						}
+						if (pod == SCE_PL_POD) {	// truncate verbatim POD early
+							sc.SetState(SCE_PL_POD);
+						} else
+							fw = fw2;
+					} else
+						pod = SCE_PL_POD;
+				} else {
+					if (pod == SCE_PL_POD_VERB	// still part of current paragraph
+					    && (styler.GetLineState(ln - 1) == SCE_PL_POD)) {
+						pod = SCE_PL_POD;
+						styler.SetLineState(ln, pod);
+					} else if (pod == SCE_PL_POD
+							   && (styler.GetLineState(ln - 1) == SCE_PL_POD_VERB)) {
+						pod = SCE_PL_POD_VERB;
+						styler.SetLineState(ln, pod);
+					}
+					sc.SetState(pod);
+				}
+				sc.Forward(fw - sc.currentPos);	// commit style
+				} break;
+			case SCE_PL_REGEX:
+			case SCE_PL_STRING_QR:
+				if (Quote.Rep <= 0) {
+					if (!setModifiers.Contains(sc.ch))
+						sc.SetState(SCE_PL_DEFAULT);
+				} else if (!Quote.Up && !IsASpace(sc.ch)) {
+					Quote.Open(sc.ch);
+				} else if (sc.ch == '\\' && Quote.Up != '\\') {
+					sc.Forward();
+				} else if (sc.ch == Quote.Down) {
+					Quote.Count--;
+					if (Quote.Count == 0)
+						Quote.Rep--;
+				} else if (sc.ch == Quote.Up) {
+					Quote.Count++;
+				}
+				break;
+			case SCE_PL_REGSUBST:
+				if (Quote.Rep <= 0) {
+					if (!setModifiers.Contains(sc.ch))
+						sc.SetState(SCE_PL_DEFAULT);
+				} else if (!Quote.Up && !IsASpace(sc.ch)) {
+					Quote.Open(sc.ch);
+				} else if (sc.ch == '\\' && Quote.Up != '\\') {
+					sc.Forward();
+				} else if (Quote.Count == 0 && Quote.Rep == 1) {
+					// We matched something like s(...) or tr{...}, Perl 5.10
+					// appears to allow almost any character for use as the
+					// next delimiters. Whitespace and comments are accepted in
+					// between, but we'll limit to whitespace here.
+					// For '#', if no whitespace in between, it's a delimiter.
+					if (IsASpace(sc.ch)) {
+						// Keep going
+					} else if (sc.ch == '#' && IsASpaceOrTab(sc.chPrev)) {
+						sc.SetState(SCE_PL_DEFAULT);
+					} else {
+						Quote.Open(sc.ch);
+					}
+				} else if (sc.ch == Quote.Down) {
+					Quote.Count--;
+					if (Quote.Count == 0)
+						Quote.Rep--;
+					if (Quote.Up == Quote.Down)
+						Quote.Count++;
+				} else if (sc.ch == Quote.Up) {
+					Quote.Count++;
+				}
+				break;
+			case SCE_PL_STRING_Q:
+			case SCE_PL_STRING_QQ:
+			case SCE_PL_STRING_QX:
+			case SCE_PL_STRING_QW:
+			case SCE_PL_STRING:
+			case SCE_PL_CHARACTER:
+			case SCE_PL_BACKTICKS:
+				if (!Quote.Down && !IsASpace(sc.ch)) {
+					Quote.Open(sc.ch);
+				} else if (sc.ch == '\\' && Quote.Up != '\\') {
+					sc.Forward();
+				} else if (sc.ch == Quote.Down) {
+					Quote.Count--;
+					if (Quote.Count == 0)
+						sc.ForwardSetState(SCE_PL_DEFAULT);
+				} else if (sc.ch == Quote.Up) {
+					Quote.Count++;
+				}
+				break;
+			case SCE_PL_SUB_PROTOTYPE: {
+				int i = 0;
+				// forward scan; must all be valid proto characters
+				while (setSubPrototype.Contains(sc.GetRelative(i)))
+					i++;
+				if (sc.GetRelative(i) == ')') {	// valid sub prototype
+					sc.Forward(i);
+					sc.ForwardSetState(SCE_PL_DEFAULT);
+				} else {
+					// abandon prototype, restart from '('
+					sc.ChangeState(SCE_PL_OPERATOR);
+					sc.SetState(SCE_PL_DEFAULT);
+				}
+				} break;
+			case SCE_PL_FORMAT: {
+				sc.Complete();
+				while (!sc.atLineEnd)
+					sc.Forward();
+				char s[10];
+				sc.GetCurrent(s, sizeof(s));
+				if (isMatch(".", s))
+					sc.SetState(SCE_PL_DEFAULT);
+				} break;
+			case SCE_PL_ERROR:
+				break;
 		}
-		if ((chPrev == '\r' && ch == '\n')) {	// skip on DOS/Windows
-			styler.ColourTo(i, state);
-			chPrev = ch;
-			continue;
+		// Needed for specific continuation styles (one follows the other)
+		switch (sc.state) {
+			// continued from SCE_PL_WORD
+			case SCE_PL_FORMAT_IDENT:
+				// occupies HereDoc state 3 to avoid clashing with HERE docs
+				if (IsASpaceOrTab(sc.ch)) {		// skip whitespace
+					sc.ChangeState(SCE_PL_DEFAULT);
+					while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd)
+						sc.Forward();
+					sc.SetState(SCE_PL_FORMAT_IDENT);
+				}
+				if (setFormatStart.Contains(sc.ch)) {	// identifier or '='
+					if (sc.ch != '=') {
+						do {
+							sc.Forward();
+						} while (setFormat.Contains(sc.ch));
+					}
+					while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd)
+						sc.Forward();
+					if (sc.ch == '=') {
+						sc.ForwardSetState(SCE_PL_DEFAULT);
+						HereDoc.State = 3;
+					} else {
+						// invalid indentifier; inexact fallback, but hey
+						sc.ChangeState(SCE_PL_IDENTIFIER);
+						sc.SetState(SCE_PL_DEFAULT);
+					}
+				} else {
+					sc.ChangeState(SCE_PL_DEFAULT);	// invalid indentifier
+				}
+				backFlag = BACK_NONE;
+				break;
 		}
 
-		if (HereDoc.State == 1 && isEOLChar(ch)) {
+		// Must check end of HereDoc states here before default state is handled
+		if (HereDoc.State == 1 && sc.atLineEnd) {
 			// Begin of here-doc (the line after the here-doc delimiter):
 			// Lexically, the here-doc starts from the next line after the >>, but the
 			// first line of here-doc seem to follow the style of the last EOL sequence
+			int st_new = SCE_PL_HERE_QQ;
 			HereDoc.State = 2;
 			if (HereDoc.Quoted) {
-				if (state == SCE_PL_HERE_DELIM) {
+				if (sc.state == SCE_PL_HERE_DELIM) {
 					// Missing quote at end of string! We are stricter than perl.
 					// Colour here-doc anyway while marking this bit as an error.
-					state = SCE_PL_ERROR;
+					sc.ChangeState(SCE_PL_ERROR);
 				}
-				styler.ColourTo(i - 1, state);
 				switch (HereDoc.Quote) {
-				case '\'':
-					state = SCE_PL_HERE_Q ;
-					break;
-				case '"':
-					state = SCE_PL_HERE_QQ;
-					break;
-				case '`':
-					state = SCE_PL_HERE_QX;
-					break;
+					case '\'': st_new = SCE_PL_HERE_Q ; break;
+					case '"' : st_new = SCE_PL_HERE_QQ; break;
+					case '`' : st_new = SCE_PL_HERE_QX; break;
 				}
 			} else {
-				styler.ColourTo(i - 1, state);
-				switch (HereDoc.Quote) {
-				case '\\':
-					state = SCE_PL_HERE_Q ;
-					break;
-				default :
-					state = SCE_PL_HERE_QQ;
-				}
+				if (HereDoc.Quote == '\\')
+					st_new = SCE_PL_HERE_Q;
 			}
+			sc.SetState(st_new);
+		}
+		if (HereDoc.State == 3 && sc.atLineEnd) {
+			// Start of format body.
+			HereDoc.State = 0;
+			sc.SetState(SCE_PL_FORMAT);
 		}
 
-		if (state == SCE_PL_DEFAULT) {
-			if ((isascii(ch) && isdigit(ch)) || (isascii(chNext) && isdigit(chNext) &&
-				(ch == '.' || ch == 'v'))) {
-				state = SCE_PL_NUMBER;
-                backflag = BACK_NONE;
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_PL_DEFAULT) {
+			if (IsADigit(sc.ch) ||
+				(IsADigit(sc.chNext) && (sc.ch == '.' || sc.ch == 'v'))) {
+				sc.SetState(SCE_PL_NUMBER);
+				backFlag = BACK_NONE;
 				numState = PERLNUM_DECIMAL;
 				dotCount = 0;
-				if (ch == '0') {	// hex,bin,octal
-					if (chNext == 'x') {
+				if (sc.ch == '0') {		// hex,bin,octal
+					if (sc.chNext == 'x') {
 						numState = PERLNUM_HEX;
-					} else if (chNext == 'b') {
-                        numState = PERLNUM_BINARY;
-                    } else if (isascii(chNext) && isdigit(chNext)) {
-                        numState = PERLNUM_OCTAL;
-                    }
-                    if (numState != PERLNUM_DECIMAL) {
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-                    }
-				} else if (ch == 'v') {	// vector
+					} else if (sc.chNext == 'b') {
+						numState = PERLNUM_BINARY;
+					} else if (IsADigit(sc.chNext)) {
+						numState = PERLNUM_OCTAL;
+					}
+					if (numState != PERLNUM_DECIMAL) {
+						sc.Forward();
+					}
+				} else if (sc.ch == 'v') {		// vector
 					numState = PERLNUM_V_VECTOR;
 				}
-			} else if (isWordStart(ch)) {
-                // if immediately prefixed by '::', always a bareword
-                state = SCE_PL_WORD;
-                if (chPrev == ':' && styler.SafeGetCharAt(i - 2) == ':') {
-                    state = SCE_PL_IDENTIFIER;
-                }
-                unsigned int kw = i + 1;
-                // first check for possible quote-like delimiter
-				if (ch == 's' && !isNonQuote(chNext)) {
-					state = SCE_PL_REGSUBST;
+			} else if (setWord.Contains(sc.ch)) {
+				// if immediately prefixed by '::', always a bareword
+				sc.SetState(SCE_PL_WORD);
+				if (sc.chPrev == ':' && sc.GetRelative(-2) == ':') {
+					sc.ChangeState(SCE_PL_IDENTIFIER);
+				}
+				unsigned int bk = sc.currentPos;
+				unsigned int fw = sc.currentPos + 1;
+				// first check for possible quote-like delimiter
+				if (sc.ch == 's' && !setWord.Contains(sc.chNext)) {
+					sc.ChangeState(SCE_PL_REGSUBST);
 					Quote.New(2);
-				} else if (ch == 'm' && !isNonQuote(chNext)) {
-					state = SCE_PL_REGEX;
-					Quote.New(1);
-				} else if (ch == 'q' && !isNonQuote(chNext)) {
-					state = SCE_PL_STRING_Q;
-					Quote.New(1);
-				} else if (ch == 'y' && !isNonQuote(chNext)) {
-					state = SCE_PL_REGSUBST;
+				} else if (sc.ch == 'm' && !setWord.Contains(sc.chNext)) {
+					sc.ChangeState(SCE_PL_REGEX);
+					Quote.New();
+				} else if (sc.ch == 'q' && !setWord.Contains(sc.chNext)) {
+					sc.ChangeState(SCE_PL_STRING_Q);
+					Quote.New();
+				} else if (sc.ch == 'y' && !setWord.Contains(sc.chNext)) {
+					sc.ChangeState(SCE_PL_REGSUBST);
 					Quote.New(2);
-				} else if (ch == 't' && chNext == 'r' && !isNonQuote(chNext2)) {
-					state = SCE_PL_REGSUBST;
+				} else if (sc.Match('t', 'r') && !setWord.Contains(sc.GetRelative(2))) {
+					sc.ChangeState(SCE_PL_REGSUBST);
 					Quote.New(2);
-                    kw++;
-				} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isNonQuote(chNext2)) {
-					if      (chNext == 'q') state = SCE_PL_STRING_QQ;
-					else if (chNext == 'x') state = SCE_PL_STRING_QX;
-					else if (chNext == 'r') state = SCE_PL_STRING_QR;
-					else if (chNext == 'w') state = SCE_PL_STRING_QW;
-					Quote.New(1);
-                    kw++;
-				} else if (ch == 'x' && (chNext == '=' ||	// repetition
-                           !isWordStart(chNext) ||
-                           (isdigit(chPrev) && isdigit(chNext)))) {
-                    state = SCE_PL_OPERATOR;
-                }
-                // if potentially a keyword, scan forward and grab word, then check
-                // if it's really one; if yes, disambiguation test is performed
-                // otherwise it is always a bareword and we skip a lot of scanning
-                // note: keywords assumed to be limited to [_a-zA-Z] only
-                if (state == SCE_PL_WORD) {
-                    while (isWordStart(styler.SafeGetCharAt(kw))) kw++;
-                    if (!isPerlKeyword(styler.GetStartSegment(), kw, keywords, styler)) {
-                        state = SCE_PL_IDENTIFIER;
-                    }
-                }
-                // if already SCE_PL_IDENTIFIER, then no ambiguity, skip this
-                // for quote-like delimiters/keywords, attempt to disambiguate
-                // to select for bareword, change state -> SCE_PL_IDENTIFIER
-                if (state != SCE_PL_IDENTIFIER && i > 0) {
-                    unsigned int j = i;
-                    bool moreback = false;      // true if passed newline/comments
-                    bool brace = false;         // true if opening brace found
-                    char ch2;
-                    // first look backwards past whitespace/comments for EOLs
-                    // if BACK_NONE, neither operator nor keyword, so skip test
-                    if (backflag != BACK_NONE) {
-                        while (--j > backPos) {
-                            if (isEOLChar(styler.SafeGetCharAt(j)))
-                                moreback = true;
-                        }
-                        ch2 = styler.SafeGetCharAt(j);
-                        if (ch2 == '{' && !moreback) {
-                            // {bareword: possible variable spec
-                            brace = true;
-                        } else if ((ch2 == '&' && styler.SafeGetCharAt(j - 1) != '&')
-                                // &bareword: subroutine call
-                                || (ch2 == '>' && styler.SafeGetCharAt(j - 1) == '-')
-                                // ->bareword: part of variable spec
-                                || (ch2 == 'b' && styler.Match(j - 2, "su"))) {
-                                // sub bareword: subroutine declaration
-                                // (implied BACK_KEYWORD, no keywords end in 'sub'!)
-                            state = SCE_PL_IDENTIFIER;
-                        }
-                        // if status still ambiguous, look forward after word past
-                        // tabs/spaces only; if ch2 isn't one of '[{(,' it can never
-                        // match anything, so skip the whole thing
-                        j = kw;
-                        if (state != SCE_PL_IDENTIFIER
-                            && (ch2 == '{' || ch2 == '(' || ch2 == '['|| ch2 == ',')
-                            && kw < lengthDoc) {
-                            while (ch2 = styler.SafeGetCharAt(j),
-                                   (ch2 == ' ' || ch2 == '\t') && j < lengthDoc) {
-                                j++;
-                            }
-                            if ((ch2 == '}' && brace)
-                             // {bareword}: variable spec
-                             || (ch2 == '=' && styler.SafeGetCharAt(j + 1) == '>')) {
-                             // [{(, bareword=>: hash literal
-                                state = SCE_PL_IDENTIFIER;
-                            }
-                        }
-                    }
-                }
-                backflag = BACK_NONE;
-                // an identifier or bareword
-                if (state == SCE_PL_IDENTIFIER) {
-                    if ((!isWordStart(chNext) && chNext != '\'')
-                        || (chNext == '.' && chNext2 == '.')) {
-                        // We need that if length of word == 1!
-                        // This test is copied from the SCE_PL_WORD handler.
-                        styler.ColourTo(i, SCE_PL_IDENTIFIER);
-                        state = SCE_PL_DEFAULT;
-                    }
-                // a keyword
-                } else if (state == SCE_PL_WORD) {
-                    i = kw - 1;
-                    if (ch == '_' && chNext == '_' &&
-                        (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")
-                      || isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__"))) {
-                        styler.ColourTo(i, SCE_PL_DATASECTION);
-                        state = SCE_PL_DATASECTION;
-                    } else {
-                        styler.ColourTo(i, SCE_PL_WORD);
-                        state = SCE_PL_DEFAULT;
-                        backflag = BACK_KEYWORD;
-                        backPos = i;
-                    }
-                    ch = styler.SafeGetCharAt(i);
-                    chNext = styler.SafeGetCharAt(i + 1);
-                // a repetition operator 'x'
-                } else if (state == SCE_PL_OPERATOR) {
-                    styler.ColourTo(i, SCE_PL_OPERATOR);
-                    state = SCE_PL_DEFAULT;
-                // quote-like delimiter, skip one char if double-char delimiter
-                } else {
-                    i = kw - 1;
-                    chNext = styler.SafeGetCharAt(i + 1);
-                }
-			} else if (ch == '#') {
-				state = SCE_PL_COMMENTLINE;
-			} else if (ch == '\"') {
-				state = SCE_PL_STRING;
-				Quote.New(1);
-				Quote.Open(ch);
-                backflag = BACK_NONE;
-			} else if (ch == '\'') {
-				if (chPrev == '&') {
+					sc.Forward();
+					fw++;
+				} else if (sc.ch == 'q' && setQDelim.Contains(sc.chNext)
+						   && !setWord.Contains(sc.GetRelative(2))) {
+					if      (sc.chNext == 'q') sc.ChangeState(SCE_PL_STRING_QQ);
+					else if (sc.chNext == 'x') sc.ChangeState(SCE_PL_STRING_QX);
+					else if (sc.chNext == 'r') sc.ChangeState(SCE_PL_STRING_QR);
+					else sc.ChangeState(SCE_PL_STRING_QW);	// sc.chNext == 'w'
+					Quote.New();
+					sc.Forward();
+					fw++;
+				} else if (sc.ch == 'x' && (sc.chNext == '=' ||	// repetition
+						   !setWord.Contains(sc.chNext) ||
+						   (IsADigit(sc.chPrev) && IsADigit(sc.chNext)))) {
+					sc.ChangeState(SCE_PL_OPERATOR);
+				}
+				// if potentially a keyword, scan forward and grab word, then check
+				// if it's really one; if yes, disambiguation test is performed
+				// otherwise it is always a bareword and we skip a lot of scanning
+				if (sc.state == SCE_PL_WORD) {
+					while (setWord.Contains(static_cast<unsigned char>(styler.SafeGetCharAt(fw))))
+						fw++;
+					if (!isPerlKeyword(styler.GetStartSegment(), fw, keywords, styler)) {
+						sc.ChangeState(SCE_PL_IDENTIFIER);
+					}
+				}
+				// if already SCE_PL_IDENTIFIER, then no ambiguity, skip this
+				// for quote-like delimiters/keywords, attempt to disambiguate
+				// to select for bareword, change state -> SCE_PL_IDENTIFIER
+				if (sc.state != SCE_PL_IDENTIFIER && bk > 0) {
+					if (disambiguateBareword(styler, bk, fw, backFlag, backPos, endPos))
+						sc.ChangeState(SCE_PL_IDENTIFIER);
+				}
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '#') {
+				sc.SetState(SCE_PL_COMMENTLINE);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_PL_STRING);
+				Quote.New();
+				Quote.Open(sc.ch);
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '\'') {
+				if (sc.chPrev == '&' && setWordStart.Contains(sc.chNext)) {
 					// Archaic call
-					styler.ColourTo(i, state);
+					sc.SetState(SCE_PL_IDENTIFIER);
 				} else {
-					state = SCE_PL_CHARACTER;
-					Quote.New(1);
-					Quote.Open(ch);
-				}
-                backflag = BACK_NONE;
-			} else if (ch == '`') {
-				state = SCE_PL_BACKTICKS;
-				Quote.New(1);
-				Quote.Open(ch);
-                backflag = BACK_NONE;
-			} else if (ch == '$') {
-				if ((chNext == '{') || isspacechar(chNext)) {
-					styler.ColourTo(i, SCE_PL_SCALAR);
-				} else {
-					state = SCE_PL_SCALAR;
-					if ((chNext == '`' && chNext2 == '`')
-                     || (chNext == ':' && chNext2 == ':')) {
-						i += 2;
-						ch = styler.SafeGetCharAt(i);
-						chNext = styler.SafeGetCharAt(i + 1);
-					} else {
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-					}
-				}
-                backflag = BACK_NONE;
-			} else if (ch == '@') {
-				if (!isascii(chNext) || isalpha(chNext) || chNext == '#' || chNext == '$'
-					|| chNext == '_' || chNext == '+' || chNext == '-') {
-					state = SCE_PL_ARRAY;
-                } else if (chNext == ':' && chNext2 == ':') {
-                    state = SCE_PL_ARRAY;
-                    i += 2;
-                    ch = styler.SafeGetCharAt(i);
-                    chNext = styler.SafeGetCharAt(i + 1);
-				} else if (chNext != '{' && chNext != '[') {
-					styler.ColourTo(i, SCE_PL_ARRAY);
+					sc.SetState(SCE_PL_CHARACTER);
+					Quote.New();
+					Quote.Open(sc.ch);
+				}
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '`') {
+				sc.SetState(SCE_PL_BACKTICKS);
+				Quote.New();
+				Quote.Open(sc.ch);
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '$') {
+				sc.SetState(SCE_PL_SCALAR);
+				if (sc.chNext == '{') {
+					sc.ForwardSetState(SCE_PL_OPERATOR);
+				} else if (IsASpace(sc.chNext)) {
+					sc.ForwardSetState(SCE_PL_DEFAULT);
 				} else {
-					styler.ColourTo(i, SCE_PL_ARRAY);
+					sc.Forward();
+					if (sc.Match('`', '`') || sc.Match(':', ':')) {
+						sc.Forward();
+					}
 				}
-                backflag = BACK_NONE;
-			} else if (ch == '%') {
-				if (!isascii(chNext) || isalpha(chNext) || chNext == '#' || chNext == '$'
-                    || chNext == '_' || chNext == '!' || chNext == '^') {
-					state = SCE_PL_HASH;
-                    i++;
-                    ch = chNext;
-                    chNext = chNext2;
-                } else if (chNext == ':' && chNext2 == ':') {
-                    state = SCE_PL_HASH;
-                    i += 2;
-                    ch = styler.SafeGetCharAt(i);
-                    chNext = styler.SafeGetCharAt(i + 1);
-				} else if (chNext == '{') {
-					styler.ColourTo(i, SCE_PL_HASH);
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '@') {
+				sc.SetState(SCE_PL_ARRAY);
+				if (setArray.Contains(sc.chNext)) {
+					// no special treatment
+				} else if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
+					sc.Forward(2);
+				} else if (sc.chNext == '{' || sc.chNext == '[') {
+					sc.ForwardSetState(SCE_PL_OPERATOR);
 				} else {
-					styler.ColourTo(i, SCE_PL_OPERATOR);
+					sc.ChangeState(SCE_PL_OPERATOR);
 				}
-                backflag = BACK_NONE;
-			} else if (ch == '*') {
-                char strch[2];
-                strch[0] = chNext;
-                strch[1] = '\0';
-                if (chNext == ':' && chNext2 == ':') {
-                    state = SCE_PL_SYMBOLTABLE;
-                    i += 2;
-                    ch = styler.SafeGetCharAt(i);
-                    chNext = styler.SafeGetCharAt(i + 1);
-				} else if (!isascii(chNext) || isalpha(chNext) || chNext == '_'
-                        || NULL != strstr("^/|,\\\";#%^:?<>)[]", strch)) {
-					state = SCE_PL_SYMBOLTABLE;
-                    i++;
-                    ch = chNext;
-                    chNext = chNext2;
-				} else if (chNext == '{') {
-					styler.ColourTo(i, SCE_PL_SYMBOLTABLE);
-				} else {
-					if (chNext == '*') {	// exponentiation
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-					}
-					styler.ColourTo(i, SCE_PL_OPERATOR);
-				}
-                backflag = BACK_NONE;
-			} else if (ch == '/' || (ch == '<' && chNext == '<')) {
+				backFlag = BACK_NONE;
+			} else if (setPreferRE.Contains(sc.ch)) {
 				// Explicit backward peeking to set a consistent preferRE for
 				// any slash found, so no longer need to track preferRE state.
 				// Find first previous significant lexed element and interpret.
-                // Test for HERE doc start '<<' shares this code, helps to
-                // determine if it should be an operator.
+				// A few symbols shares this code for disambiguation.
 				bool preferRE = false;
-                bool isHereDoc = (ch == '<');
-                bool hereDocSpace = false;      // these are for corner case:
-                bool hereDocScalar = false;     // SCALAR [whitespace] '<<'
-				unsigned int bk = (i > 0)? i - 1: 0;
-				char bkch;
+				bool isHereDoc = sc.Match('<', '<');
+				bool hereDocSpace = false;		// for: SCALAR [whitespace] '<<'
+				unsigned int bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0;
+				unsigned int bkend;
 				styler.Flush();
-                if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
-                    hereDocSpace = true;
-				while ((bk > 0) && (styler.StyleAt(bk) == SCE_PL_DEFAULT ||
-					styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) {
-					bk--;
-				}
+				if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
+					hereDocSpace = true;
+				skipWhitespaceComment(styler, bk);
 				if (bk == 0) {
-					// position 0 won't really be checked; rarely happens
-					// hard to fix due to an unsigned index i
+					// avoid backward scanning breakage
 					preferRE = true;
 				} else {
 					int bkstyle = styler.StyleAt(bk);
-					bkch = styler.SafeGetCharAt(bk);
+					int bkch = static_cast<unsigned char>(styler.SafeGetCharAt(bk));
 					switch(bkstyle) {
 					case SCE_PL_OPERATOR:
 						preferRE = true;
 						if (bkch == ')' || bkch == ']') {
 							preferRE = false;
 						} else if (bkch == '}') {
-							// backtrack further, count balanced brace pairs
-							// if a brace pair found, see if it's a variable
-							int braceCount = 1;
-							while (--bk > 0) {
-								bkstyle = styler.StyleAt(bk);
-								if (bkstyle == SCE_PL_OPERATOR) {
-									bkch = styler.SafeGetCharAt(bk);
-									if (bkch == ';') {	// early out
-										break;
-									} else if (bkch == '}') {
-										braceCount++;
-									} else if (bkch == '{') {
-										if (--braceCount == 0)
-											break;
-									}
-								}
-							}
-							if (bk == 0) {
-								// at beginning, true
-							} else if (braceCount == 0) {
-								// balanced { found, bk>0, skip more whitespace
-								if (styler.StyleAt(--bk) == SCE_PL_DEFAULT) {
-									while (bk > 0) {
-										bkstyle = styler.StyleAt(--bk);
-										if (bkstyle != SCE_PL_DEFAULT)
-											break;
-									}
-								}
-								bkstyle = styler.StyleAt(bk);
-								if (bkstyle == SCE_PL_SCALAR
-								 || bkstyle == SCE_PL_ARRAY
-								 || bkstyle == SCE_PL_HASH
-								 || bkstyle == SCE_PL_SYMBOLTABLE
-								 || bkstyle == SCE_PL_OPERATOR) {
-									preferRE = false;
-								}
+							// backtrack by counting balanced brace pairs
+							// needed to test for variables like ${}, @{} etc.
+							bkstyle = styleBeforeBracePair(styler, bk);
+							if (bkstyle == SCE_PL_SCALAR
+								|| bkstyle == SCE_PL_ARRAY
+								|| bkstyle == SCE_PL_HASH
+								|| bkstyle == SCE_PL_SYMBOLTABLE
+								|| bkstyle == SCE_PL_OPERATOR) {
+								preferRE = false;
 							}
+						} else if (bkch == '+' || bkch == '-') {
+							if (bkch == static_cast<unsigned char>(styler.SafeGetCharAt(bk - 1))
+								&& bkch != static_cast<unsigned char>(styler.SafeGetCharAt(bk - 2)))
+							// exceptions for operators: unary suffixes ++, --
+							preferRE = false;
 						}
 						break;
 					case SCE_PL_IDENTIFIER:
 						preferRE = true;
-						if (bkch == '>') {	// inputsymbol
+						bkstyle = styleCheckIdentifier(styler, bk);
+						if ((bkstyle == 1) || (bkstyle == 2)) {
+							// inputsymbol or var with "->" or "::" before identifier
 							preferRE = false;
-							break;
-						}
-						// backtrack to find "->" or "::" before identifier
-						while (bk > 0 && styler.StyleAt(bk) == SCE_PL_IDENTIFIER) {
-							bk--;
-						}
-						while (bk > 0) {
-							bkstyle = styler.StyleAt(bk);
-							if (bkstyle == SCE_PL_DEFAULT ||
-							    bkstyle == SCE_PL_COMMENTLINE) {
-							} else if (bkstyle == SCE_PL_OPERATOR) {
-								// gcc 3.2.3 bloats if more compact form used
-								bkch = styler.SafeGetCharAt(bk);
-								if (bkch == '>') { // "->"
-									if (styler.SafeGetCharAt(bk - 1) == '-') {
-										preferRE = false;
-										break;
-									}
-								} else if (bkch == ':') { // "::"
-									if (styler.SafeGetCharAt(bk - 1) == ':') {
-										preferRE = false;
-										break;
-									}
-								}
-							} else {// bare identifier, usually a function call but Perl
-								// optimizes them as pseudo-constants, then the next
-								// '/' will be a divide; favour divide over regex
-								// if there is a whitespace after the '/'
-								if (isspacechar(chNext)) {
+						} else if (bkstyle == 3) {
+							// bare identifier, test cases follows:
+							if (sc.ch == '/') {
+								// if '/', /PATTERN/ unless digit/space immediately after '/'
+								// if '//', always expect defined-or operator to follow identifier
+								if (IsASpace(sc.chNext) || IsADigit(sc.chNext) || sc.chNext == '/')
+									preferRE = false;
+							} else if (sc.ch == '*' || sc.ch == '%') {
+								if (IsASpace(sc.chNext) || IsADigit(sc.chNext) || sc.Match('*', '*'))
+									preferRE = false;
+							} else if (sc.ch == '<') {
+								if (IsASpace(sc.chNext) || sc.chNext == '=')
 									preferRE = false;
-								}
-								break;
 							}
-							bk--;
 						}
 						break;
-                    case SCE_PL_SCALAR:     // for $var<< case
-                        hereDocScalar = true;
-                        break;
-					// other styles uses the default, preferRE=false
+					case SCE_PL_SCALAR:		// for $var<< case:
+						if (isHereDoc && hereDocSpace)	// if SCALAR whitespace '<<', *always* a HERE doc
+							preferRE = true;
+						break;
 					case SCE_PL_WORD:
+						preferRE = true;
+						// for HERE docs, always true
+						if (sc.ch == '/') {
+							// adopt heuristics similar to vim-style rules:
+							// keywords always forced as /PATTERN/: split, if, elsif, while
+							// everything else /PATTERN/ unless digit/space immediately after '/'
+							// for '//', defined-or favoured unless special keywords
+							bkend = bk + 1;
+							while (bk > 0 && styler.StyleAt(bk - 1) == SCE_PL_WORD) {
+								bk--;
+							}
+							if (isPerlKeyword(bk, bkend, reWords, styler))
+								break;
+							if (IsASpace(sc.chNext) || IsADigit(sc.chNext) || sc.chNext == '/')
+								preferRE = false;
+						} else if (sc.ch == '*' || sc.ch == '%') {
+							if (IsASpace(sc.chNext) || IsADigit(sc.chNext) || sc.Match('*', '*'))
+								preferRE = false;
+						} else if (sc.ch == '<') {
+							if (IsASpace(sc.chNext) || sc.chNext == '=')
+								preferRE = false;
+						}
+						break;
+					// other styles uses the default, preferRE=false
 					case SCE_PL_POD:
-					case SCE_PL_POD_VERB:
 					case SCE_PL_HERE_Q:
 					case SCE_PL_HERE_QQ:
 					case SCE_PL_HERE_QX:
@@ -666,462 +1054,114 @@
 						break;
 					}
 				}
-                if (isHereDoc) {    // handle HERE doc
-                    // if SCALAR whitespace '<<', *always* a HERE doc
-                    if (preferRE || (hereDocSpace && hereDocScalar)) {
-                        state = SCE_PL_HERE_DELIM;
-                        HereDoc.State = 0;
-                    } else {        // << operator
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-                        styler.ColourTo(i, SCE_PL_OPERATOR);
-                    }
-                } else {            // handle regexp
-                    if (preferRE) {
-                        state = SCE_PL_REGEX;
-                        Quote.New(1);
-                        Quote.Open(ch);
-                    } else {        // / operator
-                        styler.ColourTo(i, SCE_PL_OPERATOR);
-                    }
-                }
-                backflag = BACK_NONE;
-			} else if (ch == '<') {
-				// looks forward for matching > on same line
-				unsigned int fw = i + 1;
-				while (fw < lengthDoc) {
-					char fwch = styler.SafeGetCharAt(fw);
-					if (fwch == ' ') {
-						if (styler.SafeGetCharAt(fw-1) != '\\' ||
-						    styler.SafeGetCharAt(fw-2) != '\\')
-						break;
-					} else if (isEOLChar(fwch) || isspacechar(fwch)) {
-						break;
-					} else if (fwch == '>') {
-						if ((fw - i) == 2 &&	// '<=>' case
-						    styler.SafeGetCharAt(fw-1) == '=') {
-							styler.ColourTo(fw, SCE_PL_OPERATOR);
-						} else {
-							styler.ColourTo(fw, SCE_PL_IDENTIFIER);
-						}
-						i = fw;
-						ch = fwch;
-						chNext = styler.SafeGetCharAt(i+1);
-					}
-					fw++;
-				}
-				styler.ColourTo(i, SCE_PL_OPERATOR);
-                backflag = BACK_NONE;
-			} else if (ch == '='	// POD
-			           && isalpha(chNext)
-			           && (isEOLChar(chPrev))) {
-				state = SCE_PL_POD;
-                backflag = BACK_NONE;
-				//sookedpos = 0;
-				//sooked[sookedpos] = '\0';
-			} else if (ch == '-'	// file test operators
-			           && isSingleCharOp(chNext)
-			           && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) {
-				styler.ColourTo(i + 1, SCE_PL_WORD);
-				state = SCE_PL_DEFAULT;
-				i++;
-				ch = chNext;
-				chNext = chNext2;
-                backflag = BACK_NONE;
-			} else if (isPerlOperator(ch)) {
-				if (ch == '.' && chNext == '.') { // .. and ...
-					i++;
-					if (chNext2 == '.') { i++; }
-					state = SCE_PL_DEFAULT;
-					ch = styler.SafeGetCharAt(i);
-					chNext = styler.SafeGetCharAt(i + 1);
-				}
-				styler.ColourTo(i, SCE_PL_OPERATOR);
-                backflag = BACK_OPERATOR;
-                backPos = i;
-			} else {
-				// keep colouring defaults to make restart easier
-				styler.ColourTo(i, SCE_PL_DEFAULT);
-			}
-		} else if (state == SCE_PL_NUMBER) {
-			if (ch == '.') {
-				if (chNext == '.') {
-					// double dot is always an operator
-					goto numAtEnd;
-				} else if (numState <= PERLNUM_FLOAT) {
-					// non-decimal number or float exponent, consume next dot
-					styler.ColourTo(i - 1, SCE_PL_NUMBER);
-					styler.ColourTo(i, SCE_PL_OPERATOR);
-					state = SCE_PL_DEFAULT;
-				} else { // decimal or vectors allows dots
-					dotCount++;
-					if (numState == PERLNUM_DECIMAL) {
-						if (dotCount > 1) {
-							if (isdigit(chNext)) { // really a vector
-								numState = PERLNUM_VECTOR;
-							} else	// number then dot
-								goto numAtEnd;
-						}
-					} else { // vectors
-						if (!isdigit(chNext))	// vector then dot
-							goto numAtEnd;
-					}
-				}
-			} else if (ch == '_' && numState == PERLNUM_DECIMAL) {
-				if (!isdigit(chNext)) {
-					goto numAtEnd;
-				}
-			} else if (!isascii(ch) || isalnum(ch)) {
-				if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) {
-					if (!isascii(ch) || isalpha(ch)) {
-						if (dotCount == 0) { // change to word
-							state = SCE_PL_IDENTIFIER;
-						} else { // vector then word
-							goto numAtEnd;
-						}
-					}
-				} else if (numState == PERLNUM_DECIMAL) {
-					if (ch == 'E' || ch == 'e') { // exponent
-						numState = PERLNUM_FLOAT;
-						if (chNext == '+' || chNext == '-') {
-							i++;
-							ch = chNext;
-							chNext = chNext2;
-						}
-					} else if (!isascii(ch) || !isdigit(ch)) { // number then word
-						goto numAtEnd;
-					}
-				} else if (numState == PERLNUM_FLOAT) {
-					if (!isdigit(ch)) { // float then word
-						goto numAtEnd;
-					}
-				} else if (numState == PERLNUM_OCTAL) {
-                    if (!isdigit(ch))
-                        goto numAtEnd;
-                    else if (ch > '7')
-                        numState = PERLNUM_BAD;
-                } else if (numState == PERLNUM_BINARY) {
-                    if (!isdigit(ch))
-                        goto numAtEnd;
-                    else if (ch > '1')
-                        numState = PERLNUM_BAD;
-                } else if (numState == PERLNUM_HEX) {
-                    int ch2 = toupper(ch);
-                    if (!isdigit(ch) && !(ch2 >= 'A' && ch2 <= 'F'))
-                        goto numAtEnd;
-				} else {//(numState == PERLNUM_BAD) {
-                    if (!isdigit(ch))
-                        goto numAtEnd;
-                }
-			} else {
-				// complete current number or vector
-			numAtEnd:
-				styler.ColourTo(i - 1, actualNumStyle(numState));
-				state = SCE_PL_DEFAULT;
-				goto restartLexer;
-			}
-		} else if (state == SCE_PL_IDENTIFIER) {
-			if (!isWordStart(chNext) && chNext != '\'') {
-				styler.ColourTo(i, SCE_PL_IDENTIFIER);
-				state = SCE_PL_DEFAULT;
-				ch = ' ';
-			}
-		} else {
-			if (state == SCE_PL_COMMENTLINE) {
-				if (isEOLChar(ch)) {
-					styler.ColourTo(i - 1, state);
-					state = SCE_PL_DEFAULT;
-					goto restartLexer;
-				} else if (isEOLChar(chNext)) {
-					styler.ColourTo(i, state);
-					state = SCE_PL_DEFAULT;
-				}
-			} else if (state == SCE_PL_HERE_DELIM) {
-				//
-				// From perldata.pod:
-				// ------------------
-				// A line-oriented form of quoting is based on the shell ``here-doc''
-				// syntax.
-				// Following a << you specify a string to terminate the quoted material,
-				// and all lines following the current line down to the terminating
-				// string are the value of the item.
-				// The terminating string may be either an identifier (a word),
-				// or some quoted text.
-				// If quoted, the type of quotes you use determines the treatment of
-				// the text, just as in regular quoting.
-				// An unquoted identifier works like double quotes.
-				// There must be no space between the << and the identifier.
-				// (If you put a space it will be treated as a null identifier,
-				// which is valid, and matches the first empty line.)
-				// (This is deprecated, -w warns of this syntax)
-				// The terminating string must appear by itself (unquoted and with no
-				// surrounding whitespace) on the terminating line.
-				//
-				// From Bash info:
-				// ---------------
-				// Specifier format is: <<[-]WORD
-				// Optional '-' is for removal of leading tabs from here-doc.
-				// Whitespace acceptable after <<[-] operator.
-				//
-				if (HereDoc.State == 0) { // '<<' encountered
-                    bool gotspace = false;
-                    unsigned int oldi = i;
-                    if (chNext == ' ' || chNext == '\t') {
-                        // skip whitespace; legal for quoted delimiters
-                        gotspace = true;
-                        do {
-                            i++;
-                            chNext = styler.SafeGetCharAt(i + 1);
-                        } while ((i + 1 < lengthDoc) && (chNext == ' ' || chNext == '\t'));
-                        chNext2 = styler.SafeGetCharAt(i + 2);
-                    }
-					HereDoc.State = 1;
-					HereDoc.Quote = chNext;
-					HereDoc.Quoted = false;
-					HereDoc.DelimiterLength = 0;
-					HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
-					if (chNext == '\'' || chNext == '"' || chNext == '`') {
-                        // a quoted here-doc delimiter
-						i++;
-						ch = chNext;
-						chNext = chNext2;
-						HereDoc.Quoted = true;
-					} else if (isspacechar(chNext) || isdigit(chNext) || chNext == '\\'
-						|| chNext == '=' || chNext == '$' || chNext == '@'
-                        || ((isalpha(chNext) || chNext == '_') && gotspace)) {
-						// left shift << or <<= operator cases
-                        // restore position if operator
-                        i = oldi;
-						styler.ColourTo(i, SCE_PL_OPERATOR);
-						state = SCE_PL_DEFAULT;
+				backFlag = BACK_NONE;
+				if (isHereDoc) {	// handle '<<', HERE doc
+					if (preferRE) {
+						sc.SetState(SCE_PL_HERE_DELIM);
 						HereDoc.State = 0;
-                        goto restartLexer;
-					} else {
-						// an unquoted here-doc delimiter, no special handling
-                        // (cannot be prefixed by spaces/tabs), or
-						// symbols terminates; deprecated zero-length delimiter
+					} else {		// << operator
+						sc.SetState(SCE_PL_OPERATOR);
+						sc.Forward();
 					}
-
-				} else if (HereDoc.State == 1) { // collect the delimiter
-                    backflag = BACK_NONE;
-					if (HereDoc.Quoted) { // a quoted here-doc delimiter
-						if (ch == HereDoc.Quote) { // closing quote => end of delimiter
-							styler.ColourTo(i, state);
-							state = SCE_PL_DEFAULT;
+				} else if (sc.ch == '*') {	// handle '*', typeglob
+					if (preferRE) {
+						sc.SetState(SCE_PL_SYMBOLTABLE);
+						if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
+							sc.Forward(2);
+						} else if (sc.chNext == '{') {
+							sc.ForwardSetState(SCE_PL_OPERATOR);
 						} else {
-							if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote
-								i++;
-								ch = chNext;
-								chNext = chNext2;
-							}
-							HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
-							HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+							sc.Forward();
 						}
-					} else { // an unquoted here-doc delimiter
-						if (isalnum(ch) || ch == '_') {
-							HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
-							HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+					} else {
+						sc.SetState(SCE_PL_OPERATOR);
+						if (sc.chNext == '*') 	// exponentiation
+							sc.Forward();
+					}
+				} else if (sc.ch == '%') {	// handle '%', hash
+					if (preferRE) {
+						sc.SetState(SCE_PL_HASH);
+						if (setHash.Contains(sc.chNext)) {
+							sc.Forward();
+						} else if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
+							sc.Forward(2);
+						} else if (sc.chNext == '{') {
+							sc.ForwardSetState(SCE_PL_OPERATOR);
 						} else {
-							styler.ColourTo(i - 1, state);
-							state = SCE_PL_DEFAULT;
-							goto restartLexer;
+							sc.ChangeState(SCE_PL_OPERATOR);
 						}
-					}
-					if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) {
-						styler.ColourTo(i - 1, state);
-						state = SCE_PL_ERROR;
-						goto restartLexer;
-					}
-				}
-			} else if (HereDoc.State == 2) {
-				// state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX
-				if (isEOLChar(chPrev) && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
-					i += HereDoc.DelimiterLength;
-					chPrev = styler.SafeGetCharAt(i - 1);
-					ch = styler.SafeGetCharAt(i);
-					if (isEOLChar(ch)) {
-						styler.ColourTo(i - 1, state);
-						state = SCE_PL_DEFAULT;
-                        backflag = BACK_NONE;
-						HereDoc.State = 0;
-						goto restartLexer;
-					}
-					chNext = styler.SafeGetCharAt(i + 1);
-				}
-			} else if (state == SCE_PL_POD
-				|| state == SCE_PL_POD_VERB) {
-				if (isEOLChar(chPrev)) {
-					if (ch == ' ' || ch == '\t') {
-						styler.ColourTo(i - 1, state);
-						state = SCE_PL_POD_VERB;
 					} else {
-						styler.ColourTo(i - 1, state);
-						state = SCE_PL_POD;
-						if (ch == '=') {
-							if (isMatch(styler, lengthDoc, i, "=cut")) {
-								styler.ColourTo(i - 1 + 4, state);
-								i += 4;
-								state = SCE_PL_DEFAULT;
-								ch = styler.SafeGetCharAt(i);
-								//chNext = styler.SafeGetCharAt(i + 1);
-								goto restartLexer;
-							}
-						}
+						sc.SetState(SCE_PL_OPERATOR);
 					}
-				}
-			} else if (state == SCE_PL_SCALAR	// variable names
-				|| state == SCE_PL_ARRAY
-				|| state == SCE_PL_HASH
-				|| state == SCE_PL_SYMBOLTABLE) {
-				if (ch == ':' && chNext == ':') {	// skip ::
-					i++;
-					ch = chNext;
-					chNext = chNext2;
-				}
-				else if (isEndVar(ch)) {
-					if (i == (styler.GetStartSegment() + 1)) {
-						// Special variable: $(, $_ etc.
-						styler.ColourTo(i, state);
-						state = SCE_PL_DEFAULT;
+				} else if (sc.ch == '<') {	// handle '<', inputsymbol
+					if (preferRE) {
+						// forward scan
+						int i = inputsymbolScan(styler, sc.currentPos, endPos);
+						if (i > 0) {
+							sc.SetState(SCE_PL_IDENTIFIER);
+							sc.Forward(i);
+						} else {
+							sc.SetState(SCE_PL_OPERATOR);
+						}
 					} else {
-						styler.ColourTo(i - 1, state);
-						state = SCE_PL_DEFAULT;
-						goto restartLexer;
+						sc.SetState(SCE_PL_OPERATOR);
 					}
-				}
-			} else if (state == SCE_PL_REGEX
-				|| state == SCE_PL_STRING_QR
-				) {
-				if (!Quote.Up && !isspacechar(ch)) {
-					Quote.Open(ch);
-				} else if (ch == '\\' && Quote.Up != '\\') {
-					// SG: Is it save to skip *every* escaped char?
-					i++;
-					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
-				} else {
-					if (ch == Quote.Down /*&& chPrev != '\\'*/) {
-						Quote.Count--;
-						if (Quote.Count == 0) {
-							Quote.Rep--;
-							if (Quote.Up == Quote.Down) {
-								Quote.Count++;
-							}
-						}
-						if (!isalpha(chNext)) {
-							if (Quote.Rep <= 0) {
-								styler.ColourTo(i, state);
-								state = SCE_PL_DEFAULT;
-								ch = ' ';
-							}
-						}
-					} else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
-						Quote.Count++;
-					} else if (!isascii(chNext) || !isalpha(chNext)) {
-						if (Quote.Rep <= 0) {
-							styler.ColourTo(i, state);
-							state = SCE_PL_DEFAULT;
-							ch = ' ';
+				} else {			// handle '/', regexp
+					if (preferRE) {
+						sc.SetState(SCE_PL_REGEX);
+						Quote.New();
+						Quote.Open(sc.ch);
+					} else {		// / and // operators
+						sc.SetState(SCE_PL_OPERATOR);
+						if (sc.chNext == '/') {
+							sc.Forward();
 						}
 					}
 				}
-			} else if (state == SCE_PL_REGSUBST) {
-				if (!Quote.Up && !isspacechar(ch)) {
-					Quote.Open(ch);
-				} else if (ch == '\\' && Quote.Up != '\\') {
-					// SG: Is it save to skip *every* escaped char?
-					i++;
-					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
+			} else if (sc.ch == '='		// POD
+					   && setPOD.Contains(sc.chNext)
+					   && sc.atLineStart) {
+				sc.SetState(SCE_PL_POD);
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '-' && setWordStart.Contains(sc.chNext)) {	// extended '-' cases
+				unsigned int bk = sc.currentPos;
+				unsigned int fw = 2;
+				if (setSingleCharOp.Contains(sc.chNext) &&	// file test operators
+					!setWord.Contains(sc.GetRelative(2))) {
+					sc.SetState(SCE_PL_WORD);
 				} else {
-					if (Quote.Count == 0 && Quote.Rep == 1) {
-						/* We matched something like s(...) or tr{...}
-						* and are looking for the next matcher characters,
-						* which could be either bracketed ({...}) or non-bracketed
-						* (/.../).
-						*
-						* Number-signs are problematic.  If they occur after
-						* the close of the first part, treat them like
-						* a Quote.Up char, even if they actually start comments.
-						*
-						* If we find an alnum, we end the regsubst, and punt.
-						*
-						* Eric Promislow   ericp activestate com  Aug 9,2000
-						*/
-						if (isspacechar(ch)) {
-							// Keep going
-						}
-						else if (!isascii(ch) || isalnum(ch)) {
-							styler.ColourTo(i, state);
-							state = SCE_PL_DEFAULT;
-							ch = ' ';
-						} else {
-							Quote.Open(ch);
-						}
-					} else if (ch == Quote.Down /*&& chPrev != '\\'*/) {
-						Quote.Count--;
-						if (Quote.Count == 0) {
-							Quote.Rep--;
-						}
-						if (!isascii(chNext) || !isalpha(chNext)) {
-							if (Quote.Rep <= 0) {
-								styler.ColourTo(i, state);
-								state = SCE_PL_DEFAULT;
-								ch = ' ';
-							}
-						}
-						if (Quote.Up == Quote.Down) {
-							Quote.Count++;
-						}
-					} else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
-						Quote.Count++;
-					} else if (!isascii(chNext) || !isalpha(chNext)) {
-						if (Quote.Rep <= 0) {
-							styler.ColourTo(i, state);
-							state = SCE_PL_DEFAULT;
-							ch = ' ';
-						}
-					}
+					// nominally a minus and bareword; find extent of bareword
+					while (setWord.Contains(sc.GetRelative(fw)))
+						fw++;
+					sc.SetState(SCE_PL_OPERATOR);
+				}
+				// force to bareword for hash key => or {variable literal} cases
+				if (disambiguateBareword(styler, bk, bk + fw, backFlag, backPos, endPos) & 2) {
+					sc.ChangeState(SCE_PL_IDENTIFIER);
+				}
+				backFlag = BACK_NONE;
+			} else if (sc.ch == '(' && sc.currentPos > 0) {	// '(' or subroutine prototype
+				if (styleCheckSubPrototype(styler, sc.currentPos - 1)) {
+					sc.SetState(SCE_PL_SUB_PROTOTYPE);
+					backFlag = BACK_NONE;
+				} else {
+					sc.SetState(SCE_PL_OPERATOR);
 				}
-			} else if (state == SCE_PL_STRING_Q
-				|| state == SCE_PL_STRING_QQ
-				|| state == SCE_PL_STRING_QX
-				|| state == SCE_PL_STRING_QW
-				|| state == SCE_PL_STRING
-				|| state == SCE_PL_CHARACTER
-				|| state == SCE_PL_BACKTICKS
-				) {
-				if (!Quote.Down && !isspacechar(ch)) {
-					Quote.Open(ch);
-				} else if (ch == '\\' && Quote.Up != '\\') {
-					i++;
-					ch = chNext;
-					chNext = styler.SafeGetCharAt(i + 1);
-				} else if (ch == Quote.Down) {
-					Quote.Count--;
-					if (Quote.Count == 0) {
-						Quote.Rep--;
-						if (Quote.Rep <= 0) {
-							styler.ColourTo(i, state);
-							state = SCE_PL_DEFAULT;
-							ch = ' ';
-						}
-						if (Quote.Up == Quote.Down) {
-							Quote.Count++;
-						}
-					}
-				} else if (ch == Quote.Up) {
-					Quote.Count++;
+			} else if (setPerlOperator.Contains(sc.ch)) {	// operators
+				sc.SetState(SCE_PL_OPERATOR);
+				if (sc.Match('.', '.')) {	// .. and ...
+					sc.Forward();
+					if (sc.chNext == '.') sc.Forward();
 				}
+			} else if (sc.ch == 4 || sc.ch == 26) {		// ^D and ^Z ends valid perl source
+				sc.SetState(SCE_PL_DATASECTION);
+			} else {
+				// keep colouring defaults
+				sc.Complete();
 			}
 		}
-		if (state == SCE_PL_ERROR) {
-			break;
-		}
-		chPrev = ch;
 	}
-	styler.ColourTo(lengthDoc - 1, state);
+	sc.Complete();
 }
 
 static bool IsCommentLine(int line, Accessor &styler) {
@@ -1129,17 +1169,17 @@
 	int eol_pos = styler.LineStart(line + 1) - 1;
 	for (int i = pos; i < eol_pos; i++) {
 		char ch = styler[i];
-        int style = styler.StyleAt(i);
+		int style = styler.StyleAt(i);
 		if (ch == '#' && style == SCE_PL_COMMENTLINE)
 			return true;
-		else if (ch != ' ' && ch != '\t')
+		else if (!IsASpaceOrTab(ch))
 			return false;
 	}
 	return false;
 }
 
 static void FoldPerlDoc(unsigned int startPos, int length, int, WordList *[],
-                            Accessor &styler) {
+                        Accessor &styler) {
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
 	// Custom folding of POD and packages
@@ -1164,18 +1204,18 @@
 		int style = styleNext;
 		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-		bool atLineStart = isEOLChar(chPrev) || i == 0;
-        // Comment folding
+		bool atLineStart = ((chPrev == '\r') || (chPrev == '\n')) || i == 0;
+		// Comment folding
 		if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
-        {
-            if (!IsCommentLine(lineCurrent - 1, styler)
-                && IsCommentLine(lineCurrent + 1, styler))
-                levelCurrent++;
-            else if (IsCommentLine(lineCurrent - 1, styler)
-                     && !IsCommentLine(lineCurrent+1, styler))
-                levelCurrent--;
-        }
-		if (style == SCE_C_OPERATOR) {
+		{
+			if (!IsCommentLine(lineCurrent - 1, styler)
+				&& IsCommentLine(lineCurrent + 1, styler))
+				levelCurrent++;
+			else if (IsCommentLine(lineCurrent - 1, styler)
+					 && !IsCommentLine(lineCurrent+1, styler))
+				levelCurrent--;
+		}
+		if (style == SCE_PL_OPERATOR) {
 			if (ch == '{') {
 				levelCurrent++;
 			} else if (ch == '}') {
@@ -1193,17 +1233,17 @@
 				else if (styler.Match(i, "=head"))
 					isPodHeading = true;
 			} else if (style == SCE_PL_DATASECTION) {
-                if (ch == '=' && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE)
-                    levelCurrent++;
-                else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE)
-                    levelCurrent--;
-                else if (styler.Match(i, "=head"))
+				if (ch == '=' && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE)
+					levelCurrent++;
+				else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE)
+					levelCurrent--;
+				else if (styler.Match(i, "=head"))
 					isPodHeading = true;
-                // if package used or unclosed brace, level > SC_FOLDLEVELBASE!
-                // reset needed as level test is vs. SC_FOLDLEVELBASE
-                else if (styler.Match(i, "__END__"))
-                    levelCurrent = SC_FOLDLEVELBASE;
-            }
+				// if package used or unclosed brace, level > SC_FOLDLEVELBASE!
+				// reset needed as level test is vs. SC_FOLDLEVELBASE
+				else if (styler.Match(i, "__END__"))
+					levelCurrent = SC_FOLDLEVELBASE;
+			}
 		}
 		// Custom package folding
 		if (foldPackage && atLineStart) {
@@ -1215,9 +1255,9 @@
 		if (atEOL) {
 			int lev = levelPrev;
 			if (isPodHeading) {
-                lev = levelPrev - 1;
-                lev |= SC_FOLDLEVELHEADERFLAG;
-                isPodHeading = false;
+				lev = levelPrev - 1;
+				lev |= SC_FOLDLEVELHEADERFLAG;
+				isPodHeading = false;
 			}
 			// Check if line was a package declaration
 			// because packages need "special" treatment
@@ -1226,7 +1266,7 @@
 				levelCurrent = SC_FOLDLEVELBASE + 1;
 				isPackageLine = false;
 			}
-            lev |= levelCurrent << 16;
+			lev |= levelCurrent << 16;
 			if (visibleChars == 0 && foldCompact)
 				lev |= SC_FOLDLEVELWHITEFLAG;
 			if ((levelCurrent > levelPrev) && (visibleChars > 0))
@@ -1252,5 +1292,4 @@
 	0
 };
 
-LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc);
-
+LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc, 8);

Added: trunk/plugins/editor/scintilla/LexPowerShell.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexPowerShell.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,175 @@
+// Scintilla source code edit control
+/** @file LexPowerShell.cxx
+ ** Lexer for PowerShell scripts.
+ **/
+// Copyright 2008 by Tim Gerundt <tim gerundt de>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+// Extended to accept accented characters
+static inline bool IsAWordChar(int ch) {
+	return ch >= 0x80 || isalnum(ch) || ch == '-';
+}
+
+static void ColourisePowerShellDoc(unsigned int startPos, int length, int initStyle,
+                           WordList *keywordlists[], Accessor &styler) {
+
+	WordList &keywords = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+	WordList &keywords3 = *keywordlists[2];
+
+	styler.StartAt(startPos);
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		if (sc.state == SCE_POWERSHELL_COMMENT) {
+			if (sc.atLineEnd) {
+				sc.SetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_STRING) {
+			// This is a doubles quotes string
+			if (sc.ch == '\"') {
+				sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_CHARACTER) {
+			// This is a single quote string
+			if (sc.ch == '\'') {
+				sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_NUMBER) {
+			if (!IsADigit(sc.ch)) {
+				sc.SetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_VARIABLE) {
+			if (!IsAWordChar(sc.ch)) {
+				sc.SetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_OPERATOR) {
+			if (!isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_POWERSHELL_DEFAULT);
+			}
+		} else if (sc.state == SCE_POWERSHELL_IDENTIFIER) {
+			if (!IsAWordChar(sc.ch)) {
+				char s[100];
+				sc.GetCurrentLowered(s, sizeof(s));
+
+				if (keywords.InList(s)) {
+					sc.ChangeState(SCE_POWERSHELL_KEYWORD);
+				} else if (keywords2.InList(s)) {
+					sc.ChangeState(SCE_POWERSHELL_CMDLET);
+				} else if (keywords3.InList(s)) {
+					sc.ChangeState(SCE_POWERSHELL_ALIAS);
+				}
+				sc.SetState(SCE_POWERSHELL_DEFAULT);
+			}
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_POWERSHELL_DEFAULT) {
+			if (sc.ch == '#') {
+				sc.SetState(SCE_POWERSHELL_COMMENT);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_POWERSHELL_STRING);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_POWERSHELL_CHARACTER);
+			} else if (sc.ch == '$') {
+				sc.SetState(SCE_POWERSHELL_VARIABLE);
+			} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_POWERSHELL_NUMBER);
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				sc.SetState(SCE_POWERSHELL_OPERATOR);
+			} else if (IsAWordChar(sc.ch)) {
+				sc.SetState(SCE_POWERSHELL_IDENTIFIER);
+			}
+		}
+	}
+	sc.Complete();
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment
+// and to make it possible to fiddle the current level for "} else {".
+static void FoldPowerShellDoc(unsigned int startPos, int length, int,
+                           WordList *[], Accessor &styler) {
+	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0)
+		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+	int levelMinCurrent = levelCurrent;
+	int levelNext = levelCurrent;
+	char chNext = styler[startPos];
+	int styleNext = styler.StyleAt(startPos);
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = chNext;
+		chNext = styler.SafeGetCharAt(i + 1);
+		int style = styleNext;
+		styleNext = styler.StyleAt(i + 1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		if (style == SCE_POWERSHELL_OPERATOR) {
+			if (ch == '{') {
+				// Measure the minimum before a '{' to allow
+				// folding on "} else {"
+				if (levelMinCurrent > levelNext) {
+					levelMinCurrent = levelNext;
+				}
+				levelNext++;
+			} else if (ch == '}') {
+				levelNext--;
+			}
+		}
+		if (!IsASpace(ch))
+			visibleChars++;
+		if (atEOL || (i == endPos-1)) {
+			int levelUse = levelCurrent;
+			if (foldAtElse) {
+				levelUse = levelMinCurrent;
+			}
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			levelMinCurrent = levelCurrent;
+			visibleChars = 0;
+		}
+	}
+}
+
+static const char * const powershellWordLists[] = {
+	"Commands",
+	"Cmdlets",
+	"Aliases",
+	0
+};
+
+LexerModule lmPowerShell(SCLEX_POWERSHELL, ColourisePowerShellDoc, "powershell", FoldPowerShellDoc, powershellWordLists);
+

Added: trunk/plugins/editor/scintilla/LexProgress.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexProgress.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,276 @@
+// Scintilla source code edit control
+/** @file LexProgress.cxx
+ **  Lexer for Progress 4GL.
+ ** Based on LexCPP.cxx of Neil Hodgson <neilh scintilla org>
+  **/
+// Copyright 2006-2007 by Yuval Papish <Yuval YuvCom com>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/** TODO:
+WebSpeed support in html lexer
+Support "end triggers" expression of the triggers phrase
+change lmPS to lmProgress
+Support more than 6 comments levels
+**/
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(int ch) {
+	return (ch < 0x80) && (isalpha(ch) || ch == '_');
+}
+
+enum SentenceStart { SetSentenceStart = 0xf, ResetSentenceStart = 0x10}; // true -> bit = 0
+
+static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                            Accessor &styler) {
+
+    WordList &keywords1 = *keywordlists[0];
+    WordList &keywords2 = *keywordlists[1];
+    WordList &keywords3 = *keywordlists[2];
+    //WordList &keywords4 = *keywordlists[3];
+    //WordList &keywords5 = *keywordlists[4];
+
+	int visibleChars = 0;
+	int mask;
+
+	StyleContext sc(startPos, length, 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;
+		}
+
+		// Handle line continuation generically.
+		if (sc.ch == '~') {
+			if (sc.chNext > ' ') {
+				// skip special char after ~
+				sc.Forward();
+				continue;
+			}
+			else {
+				// Skip whitespace between ~ and EOL
+				while (sc.More() && (sc.chNext == ' ' || sc.chNext == '\t') ) {
+					sc.Forward();
+				}
+				if (sc.chNext == '\n' || sc.chNext == '\r') {
+					sc.Forward();
+					if (sc.ch == '\r' && sc.chNext == '\n') {
+						sc.Forward();
+					}
+					sc.Forward();
+					continue;
+				}
+			}
+		}
+		// Determine if a new state should be terminated.
+		mask = sc.state & 0x10;
+		switch (sc.state & 0xf) {
+			case SCE_4GL_OPERATOR:
+				sc.SetState(SCE_4GL_DEFAULT | mask);
+				break;
+			case SCE_4GL_NUMBER:
+				if (!(IsADigit(sc.ch))) {
+					sc.SetState(SCE_4GL_DEFAULT | mask);
+				}
+				break;
+			case SCE_4GL_IDENTIFIER:
+				if (!IsAWordChar(sc.ch) && sc.ch != '-') {
+					char s[1000];
+					sc.GetCurrentLowered(s, sizeof(s));
+					if (((sc.state & 0x10) == 0) && keywords2.InList(s) || keywords3.InList(s)) {
+						sc.ChangeState(SCE_4GL_BLOCK | ResetSentenceStart);
+					}
+					else if (keywords1.InList(s)) {
+						if ((s[0] == 'e' && s[1] =='n' && s[2] == 'd' && !isalnum(s[3]) && s[3] != '-') ||
+							(s[0] == 'f' && s[1] =='o' && s[2] == 'r' && s[3] == 'w' && s[4] =='a' && s[5] == 'r' && s[6] == 'd'&& !isalnum(s[7]))) {
+							sc.ChangeState(SCE_4GL_END | ResetSentenceStart);
+						}
+						else if	((s[0] == 'e' && s[1] =='l' && s[2] == 's' && s[3] == 'e') ||
+								 (s[0] == 't' && s[1] =='h' && s[2] == 'e' && s[3] == 'n')) {
+							sc.ChangeState(SCE_4GL_WORD & SetSentenceStart);
+						}
+						else {
+							sc.ChangeState(SCE_4GL_WORD | ResetSentenceStart);
+						}
+					}
+					sc.SetState(SCE_4GL_DEFAULT | (sc.state & 0x10));
+				}
+				break;
+			case SCE_4GL_PREPROCESSOR:
+				if (sc.atLineStart) {
+					sc.SetState(SCE_4GL_DEFAULT & SetSentenceStart);
+				} else if (sc.ch == '*' && sc.chNext == '/') {
+					sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+				}
+				break;
+			case SCE_4GL_STRING:
+				if (sc.ch == '\"') {
+					sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+				}
+				break;
+			case SCE_4GL_CHARACTER:
+				if (sc.ch == '\'') {
+					sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+				}
+				break;
+			default:
+				if ((sc.state & 0xf) >= SCE_4GL_COMMENT1) {
+					if (sc.ch == '*' && sc.chNext == '/') {
+						sc.Forward();
+						if ((sc.state & 0xf) == SCE_4GL_COMMENT1) {
+							sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+						}
+						else
+							sc.SetState((sc.state & 0x1f) - 1);
+					} else if (sc.ch == '/' && sc.chNext == '*') {
+						sc.Forward();
+						sc.SetState((sc.state & 0x1f) + 1);
+					}
+				}
+		}
+
+		// Determine if a new state should be entered.
+		mask = sc.state & 0x10;
+		if ((sc.state & 0xf) == SCE_4GL_DEFAULT) {
+			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_4GL_NUMBER | ResetSentenceStart);
+			} else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
+				sc.SetState(SCE_4GL_IDENTIFIER | mask);
+			} else if (sc.ch == '/' && sc.chNext == '*') {
+				sc.SetState(SCE_4GL_COMMENT1 | mask);
+				sc.Forward();
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_4GL_STRING | ResetSentenceStart);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_4GL_CHARACTER | ResetSentenceStart);
+			} else if (sc.ch == '&' && visibleChars == 0 && ((sc.state & 0x10) == 0)) {
+				sc.SetState(SCE_4GL_PREPROCESSOR | ResetSentenceStart);
+				// Skip whitespace between & and preprocessor word
+				do {
+					sc.Forward();
+				} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
+			// Handle syntactical line termination
+			} else if ((sc.ch == '.' || sc.ch == ':' || sc.ch == '}') && (sc.chNext == ' ' || sc.chNext == '\t' || sc.chNext == '\n' || sc.chNext == '\r')) {
+				sc.SetState(sc.state & SetSentenceStart);
+			} else if (isoperator(static_cast<char>(sc.ch))) {
+				if (sc.ch == ':')
+					sc.SetState(SCE_4GL_OPERATOR & SetSentenceStart);
+				else
+					sc.SetState(SCE_4GL_OPERATOR | ResetSentenceStart);
+			}
+		}
+
+		if (!IsASpace(sc.ch)) {
+			visibleChars++;
+		}
+	}
+	sc.Complete();
+}
+
+static bool IsStreamCommentStyle(int style) {
+	return (style & 0xf) >= SCE_4GL_COMMENT1 ;
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment
+// and to make it possible to fiddle the current level for "} else {".
+static void FoldNoBox4glDoc(unsigned int startPos, int length, int initStyle,
+                            Accessor &styler) {
+	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0)
+		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+	int levelMinCurrent = levelCurrent;
+	int levelNext = levelCurrent;
+	char chNext = static_cast<char>(tolower(styler[startPos]));
+	int styleNext = styler.StyleAt(startPos);
+	int style = initStyle;
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = chNext;
+		chNext = static_cast<char>(tolower(styler.SafeGetCharAt(i + 1)));
+		int stylePrev = style;
+		style = styleNext;
+		styleNext = styler.StyleAt(i + 1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		if (foldComment && IsStreamCommentStyle(style)) {
+			if (!IsStreamCommentStyle(stylePrev)) {
+				levelNext++;
+			} else if (!IsStreamCommentStyle(styleNext)) { // && !atEOL) {
+				// Comments don't end at end of line and the next character may be unstyled.
+				levelNext--;
+			}
+		}
+		else if ((style & 0xf) == SCE_4GL_BLOCK && !isalnum(chNext)) {
+			levelNext++;
+		}
+		else if ((style & 0xf) == SCE_4GL_END  && (ch == 'e' || ch == 'f')) {
+			levelNext--;
+		}
+		if (atEOL) {
+			int levelUse = levelCurrent;
+			if (foldAtElse) {
+				levelUse = levelMinCurrent;
+			}
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			levelMinCurrent = levelCurrent;
+			visibleChars = 0;
+		}
+		if (!isspacechar(ch))
+			visibleChars++;
+	}
+}
+
+static void Fold4glDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+                       Accessor &styler) {
+	FoldNoBox4glDoc(startPos, length, initStyle, styler);
+}
+
+static const char * const FglWordLists[] = {
+            "Primary keywords and identifiers",
+            "Secondary keywords and identifiers",
+            "Documentation comment keywords",
+            "Unused",
+            "Global classes and typedefs",
+            0,
+        };
+
+LexerModule lmProgress(SCLEX_PS, Colourise4glDoc, "progress", Fold4glDoc, FglWordLists);
+
+

Modified: trunk/plugins/editor/scintilla/LexPython.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexPython.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexPython.cxx	Sat Nov 15 17:50:33 2008
@@ -20,7 +20,12 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 enum kwType { kwOther, kwClass, kwDef, kwImport };
+static const int indicatorWhitespace = 1;
 
 static bool IsPyComment(Accessor &styler, int pos, int len) {
 	return len > 0 && styler[pos] == '#';
@@ -123,26 +128,29 @@
 	styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
 	bool hexadecimal = false;
 
-	// Python uses a different mask because bad indentation is marked by oring with 32
-	StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
+	StyleContext sc(startPos, endPos - startPos, initStyle, styler);
+
+	bool indentGood = true;
+	int startIndicator = sc.currentPos;
 
 	for (; sc.More(); sc.Forward()) {
 
 		if (sc.atLineStart) {
-			const char chBad = static_cast<char>(64);
-			const char chGood = static_cast<char>(0);
-			char chFlags = chGood;
+			styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
+			indentGood = true;
 			if (whingeLevel == 1) {
-				chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
+				indentGood = (spaceFlags & wsInconsistent) == 0;
 			} else if (whingeLevel == 2) {
-				chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood;
+				indentGood = (spaceFlags & wsSpaceTab) == 0;
 			} else if (whingeLevel == 3) {
-				chFlags = (spaceFlags & wsSpace) ? chBad : chGood;
+				indentGood = (spaceFlags & wsSpace) == 0;
 			} else if (whingeLevel == 4) {
-				chFlags = (spaceFlags & wsTab) ? chBad : chGood;
+				indentGood = (spaceFlags & wsTab) == 0;
+			}
+			if (!indentGood) {
+				styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);
+				startIndicator = sc.currentPos;
 			}
-			sc.SetState(sc.state);
-			styler.SetFlags(chFlags, static_cast<char>(sc.state));
 		}
 
 		if (sc.atLineEnd) {
@@ -154,7 +162,6 @@
 				sc.SetState(sc.state);
 			}
 			lineCurrent++;
-			styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
 			if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
 				sc.ChangeState(SCE_P_STRINGEOL);
 				sc.ForwardSetState(SCE_P_DEFAULT);
@@ -210,10 +217,8 @@
 				sc.SetState(SCE_P_DEFAULT);
 			}
 		} else if (sc.state == SCE_P_DECORATOR) {
-			if (sc.ch == '\r' || sc.ch == '\n') {
+			if (!IsAWordChar(sc.ch)) {
 				sc.SetState(SCE_P_DEFAULT);
-			} else if (sc.ch == '#') {
-				sc.SetState((sc.chNext == '#') ? SCE_P_COMMENTBLOCK  :  SCE_P_COMMENTLINE);
 			}
 		} else if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
 			if (sc.ch == '\\') {
@@ -248,6 +253,12 @@
 			}
 		}
 
+		if (!indentGood && !IsASpaceOrTab(sc.ch)) {
+			styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 1);
+			startIndicator = sc.currentPos;
+			indentGood = true;
+		}
+
 		// State exit code may have moved on to end of line
 		if (needEOLCheck && sc.atLineEnd) {
 			lineCurrent++;
@@ -282,6 +293,7 @@
 			}
 		}
 	}
+	styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);
 	sc.Complete();
 }
 

Added: trunk/plugins/editor/scintilla/LexR.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/LexR.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,213 @@
+// Scintilla source code edit control
+/** @file Lexr.cxx
+ ** Lexer for R, S, SPlus Statistics Program (Heavily derived from CPP Lexer).
+ **
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+	return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAnOperator(const int ch) {
+	if (isascii(ch) && isalnum(ch))
+		return false;
+	// '.' left out as it is used to make up numbers
+	if (ch == '-' || ch == '+' || ch == '!' || ch == '~' ||
+	        ch == '?' || ch == ':' || ch == '*' || ch == '/' ||
+	        ch == '^' || ch == '<' || ch == '>' || ch == '=' ||
+	        ch == '&' || ch == '|' || ch == '$' || ch == '(' ||
+	        ch == ')' || ch == '}' || ch == '{' || ch == '[' ||
+		ch == ']')
+		return true;
+	return false;
+}
+
+static void ColouriseRDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+                            Accessor &styler) {
+
+	WordList &keywords   = *keywordlists[0];
+	WordList &keywords2 = *keywordlists[1];
+	WordList &keywords3 = *keywordlists[2];
+
+
+	// Do not leak onto next line
+	if (initStyle == SCE_R_INFIXEOL)
+		initStyle = SCE_R_DEFAULT;
+
+
+	StyleContext sc(startPos, length, initStyle, styler);
+
+	for (; sc.More(); sc.Forward()) {
+
+		if (sc.atLineStart && (sc.state == SCE_R_STRING)) {
+			// Prevent SCE_R_STRINGEOL from leaking back to previous line
+			sc.SetState(SCE_R_STRING);
+		}
+
+		// Determine if the current state should terminate.
+		if (sc.state == SCE_R_OPERATOR) {
+			sc.SetState(SCE_R_DEFAULT);
+		} else if (sc.state == SCE_R_NUMBER) {
+			if (!IsADigit(sc.ch) && !(sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_R_DEFAULT);
+			}
+		} else if (sc.state == SCE_R_IDENTIFIER) {
+			if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+				char s[100];
+				sc.GetCurrentLowered(s, sizeof(s));
+				if (keywords.InList(s)) {
+					sc.ChangeState(SCE_R_KWORD);
+				} else if  (keywords2.InList(s)) {
+					sc.ChangeState(SCE_R_BASEKWORD);
+				} else if  (keywords3.InList(s)) {
+					sc.ChangeState(SCE_R_OTHERKWORD);
+				}
+				sc.SetState(SCE_R_DEFAULT);
+			}
+		} else if (sc.state == SCE_R_COMMENT) {
+			if (sc.ch == '\r' || sc.ch == '\n') {
+				sc.SetState(SCE_R_DEFAULT);
+			}
+		} else if (sc.state == SCE_R_STRING) {
+			if (sc.ch == '\\') {
+				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+					sc.Forward();
+				}
+			} else if (sc.ch == '\"') {
+				sc.ForwardSetState(SCE_R_DEFAULT);
+			}
+		} else if (sc.state == SCE_R_INFIX) {
+			if (sc.ch == '%') {
+				sc.ForwardSetState(SCE_R_DEFAULT);
+			} else if (sc.atLineEnd) {
+				sc.ChangeState(SCE_R_INFIXEOL);
+				sc.ForwardSetState(SCE_R_DEFAULT);
+			}
+		}else if (sc.state == SCE_R_STRING2) {
+			if (sc.ch == '\\') {
+				if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+					sc.Forward();
+				}
+			} else if (sc.ch == '\'') {
+				sc.ForwardSetState(SCE_R_DEFAULT);
+			}
+		}
+
+		// Determine if a new state should be entered.
+		if (sc.state == SCE_R_DEFAULT) {
+			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+				sc.SetState(SCE_R_NUMBER);
+			} else if (IsAWordStart(sc.ch) ) {
+				sc.SetState(SCE_R_IDENTIFIER);
+			} else if (sc.Match('#')) {
+					sc.SetState(SCE_R_COMMENT);
+			} else if (sc.ch == '\"') {
+				sc.SetState(SCE_R_STRING);
+			} else if (sc.ch == '%') {
+				sc.SetState(SCE_R_INFIX);
+			} else if (sc.ch == '\'') {
+				sc.SetState(SCE_R_STRING2);
+			} else if (IsAnOperator(sc.ch)) {
+				sc.SetState(SCE_R_OPERATOR);
+			}
+		}
+	}
+	sc.Complete();
+}
+
+// Store both the current line's fold level and the next lines in the
+// level store to make it easy to pick up with each increment
+// and to make it possible to fiddle the current level for "} else {".
+static void FoldRDoc(unsigned int startPos, int length, int, WordList *[],
+                       Accessor &styler) {
+	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+	unsigned int endPos = startPos + length;
+	int visibleChars = 0;
+	int lineCurrent = styler.GetLine(startPos);
+	int levelCurrent = SC_FOLDLEVELBASE;
+	if (lineCurrent > 0)
+		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+	int levelMinCurrent = levelCurrent;
+	int levelNext = levelCurrent;
+	char chNext = styler[startPos];
+	int styleNext = styler.StyleAt(startPos);
+	for (unsigned int i = startPos; i < endPos; i++) {
+		char ch = chNext;
+		chNext = styler.SafeGetCharAt(i + 1);
+		int style = styleNext;
+		styleNext = styler.StyleAt(i + 1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+		if (style == SCE_R_OPERATOR) {
+			if (ch == '{') {
+				// Measure the minimum before a '{' to allow
+				// folding on "} else {"
+				if (levelMinCurrent > levelNext) {
+					levelMinCurrent = levelNext;
+				}
+				levelNext++;
+			} else if (ch == '}') {
+				levelNext--;
+			}
+		}
+		if (atEOL) {
+			int levelUse = levelCurrent;
+			if (foldAtElse) {
+				levelUse = levelMinCurrent;
+			}
+			int lev = levelUse | levelNext << 16;
+			if (visibleChars == 0 && foldCompact)
+				lev |= SC_FOLDLEVELWHITEFLAG;
+			if (levelUse < levelNext)
+				lev |= SC_FOLDLEVELHEADERFLAG;
+			if (lev != styler.LevelAt(lineCurrent)) {
+				styler.SetLevel(lineCurrent, lev);
+			}
+			lineCurrent++;
+			levelCurrent = levelNext;
+			levelMinCurrent = levelCurrent;
+			visibleChars = 0;
+		}
+		if (!isspacechar(ch))
+			visibleChars++;
+	}
+}
+
+
+static const char * const RWordLists[] = {
+            "Language Keywords",
+            "Base / Default package function",
+            "Other Package Functions",
+            "Unused",
+            "Unused",
+            0,
+        };
+
+
+
+LexerModule lmR(SCLEX_R, ColouriseRDoc, "r", FoldRDoc, RWordLists);

Modified: trunk/plugins/editor/scintilla/LexRebol.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexRebol.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexRebol.cxx	Sat Nov 15 17:50:33 2008
@@ -26,6 +26,9 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static inline bool IsAWordChar(const int ch) {
 	return (isalnum(ch) || ch == '?' || ch == '!' || ch == '.' || ch == '\'' || ch == '+' || ch == '-' || ch == '*' || ch == '&' || ch == '|' || ch == '=' || ch == '_' || ch == '~');

Modified: trunk/plugins/editor/scintilla/LexRuby.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexRuby.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexRuby.cxx	Sat Nov 15 17:50:33 2008
@@ -49,7 +49,10 @@
 }
 
 static inline bool isSafeWordcharOrHigh(char ch) {
-    return isHighBitChar(ch) || iswordchar(ch);
+    // Error: scintilla's KeyWords.h includes '.' as a word-char
+    // we want to separate things that can take methods from the
+    // methods.
+    return isHighBitChar(ch) || isalnum(ch) || ch == '_';
 }
 
 static bool inline iswhitespace(char ch) {
@@ -95,7 +98,7 @@
                               Accessor &styler);
 
 static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
-	char s[100];
+	char s[MAX_KEYWORD_LENGTH];
     unsigned int i, j;
 	unsigned int lim = end - start + 1; // num chars to copy
 	if (lim >= MAX_KEYWORD_LENGTH) {
@@ -238,6 +241,74 @@
     return true;
 }
 
+// This class is used by the enter and exit methods, so it needs
+// to be hoisted out of the function.
+
+class QuoteCls {
+    public:
+    int  Count;
+    char Up;
+    char Down;
+    QuoteCls() {
+        this->New();
+    }
+    void New() {
+        Count = 0;
+        Up    = '\0';
+        Down  = '\0';
+    }
+    void Open(char u) {
+        Count++;
+        Up    = u;
+        Down  = opposite(Up);
+    }
+    QuoteCls(const QuoteCls& q) {
+        // copy constructor -- use this for copying in
+        Count = q.Count;
+        Up    = q.Up;
+        Down  = q.Down;
+    }
+    QuoteCls& operator=(const QuoteCls& q) { // assignment constructor
+        if (this != &q) {
+            Count = q.Count;
+            Up    = q.Up;
+            Down  = q.Down;
+        }
+		return *this;
+    }
+            
+};
+
+
+static void enterInnerExpression(int  *p_inner_string_types,
+                                 int  *p_inner_expn_brace_counts,
+                                 QuoteCls *p_inner_quotes,
+                                 int&  inner_string_count,
+                                 int&  state,
+                                 int&  brace_counts,
+                                 QuoteCls curr_quote
+                                 ) {
+    p_inner_string_types[inner_string_count] = state;
+    state = SCE_RB_DEFAULT;
+    p_inner_expn_brace_counts[inner_string_count] = brace_counts;
+    brace_counts = 0;
+    p_inner_quotes[inner_string_count] = curr_quote;
+    ++inner_string_count;
+}
+
+static void exitInnerExpression(int *p_inner_string_types,
+                                 int *p_inner_expn_brace_counts,
+                                 QuoteCls *p_inner_quotes,
+                                 int& inner_string_count,
+                                 int& state,
+                                 int&  brace_counts,
+                                 QuoteCls& curr_quote
+                                ) {
+    --inner_string_count;
+    state = p_inner_string_types[inner_string_count];
+    brace_counts = p_inner_expn_brace_counts[inner_string_count];
+    curr_quote = p_inner_quotes[inner_string_count];
+}
 
 static bool isEmptyLine(int pos,
                         Accessor &styler) {
@@ -288,7 +359,7 @@
 //
 // iPrev points to the start of <<
 
-static bool sureThisIsHeredoc(int iPrev, 
+static bool sureThisIsHeredoc(int iPrev,
                               Accessor &styler,
                               char *prevWord) {
                     
@@ -605,25 +676,6 @@
 	};
 	HereDocCls HereDoc;	
 
-	class QuoteCls {
-		public:
-		int  Count;
-		char Up;
-		char Down;
-		QuoteCls() {
-			this->New();
-		}
-		void New() {
-			Count = 0;
-			Up    = '\0';
-			Down  = '\0';
-		}
-		void Open(char u) {
-			Count++;
-			Up    = u;
-			Down  = opposite(Up);
-		}
-	};
 	QuoteCls Quote;
 
     int numDots = 0;  // For numbers --
@@ -643,6 +695,7 @@
 
 	char chPrev = styler.SafeGetCharAt(startPos - 1);
 	char chNext = styler.SafeGetCharAt(startPos);
+	bool is_real_number = true;   // Differentiate between constants and ?-sequences.
 	// Ruby uses a different mask because bad indentation is marked by oring with 32
 	styler.StartAt(startPos, 127);
 	styler.StartSegment(startPos);
@@ -654,8 +707,39 @@
                              SCE_RB_STRING_QW,
                              SCE_RB_STRING_QX};
     static const char* q_chars = "qQrwWx";
-    
-	for (int i = startPos; i < lengthDoc; i++) {
+
+    // In most cases a value of 2 should be ample for the code in the
+    // Ruby library, and the code the user is likely to enter.
+    // For example,
+    // fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}"
+    //     if options[:verbose]
+    // from fileutils.rb nests to a level of 2
+    // If the user actually hits a 6th occurrence of '#{' in a double-quoted
+    // string (including regex'es, %Q, %<sym>, %w, and other strings
+    // that interpolate), it will stay as a string.  The problem with this
+    // is that quotes might flip, a 7th '#{' will look like a comment,
+    // and code-folding might be wrong.
+
+    // If anyone runs into this problem, I recommend raising this
+    // value slightly higher to replacing the fixed array with a linked
+    // list.  Keep in mind this code will be called everytime the lexer
+    // is invoked.
+
+#define INNER_STRINGS_MAX_COUNT 5
+    // These vars track our instances of "...#{,,,%Q<..#{,,,}...>,,,}..."
+    int inner_string_types[INNER_STRINGS_MAX_COUNT];
+    // Track # braces when we push a new #{ thing
+    int inner_expn_brace_counts[INNER_STRINGS_MAX_COUNT];
+    QuoteCls inner_quotes[INNER_STRINGS_MAX_COUNT];
+    int inner_string_count = 0;
+    int brace_counts = 0;   // Number of #{ ... } things within an expression
+
+    int i;
+	for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
+        inner_string_types[i] = 0;
+        inner_expn_brace_counts[i] = 0;
+    }
+	for (i = startPos; i < lengthDoc; i++) {
 		char ch = chNext;
 		chNext = styler.SafeGetCharAt(i + 1);
 		char chNext2 = styler.SafeGetCharAt(i + 2);
@@ -690,6 +774,7 @@
             if (isSafeDigit(ch)) {
             	styler.ColourTo(i - 1, state);
 				state = SCE_RB_NUMBER;
+                is_real_number = true;
                 numDots = 0;
             } else if (isHighBitChar(ch) || iswordstart(ch)) {
             	styler.ColourTo(i - 1, state);
@@ -885,7 +970,7 @@
 						chNext = styler.SafeGetCharAt(i + 1);
                         have_string = true;
                     }
-                } else if (!isSafeWordcharOrHigh(chNext)) {
+                } else if (preferRE && !isSafeWordcharOrHigh(chNext)) {
                     // Ruby doesn't allow high bit chars here,
                     // but the editor host might
                     state = SCE_RB_STRING_QQ;
@@ -898,6 +983,16 @@
                     // stay in default
                     preferRE = true;
                 }
+            } else if (ch == '?') {
+                styler.ColourTo(i - 1, state);
+                if (iswhitespace(chNext) || chNext == '\n' || chNext == '\r') {
+                    styler.ColourTo(i, SCE_RB_OPERATOR);
+                } else {
+                    // It's the start of a character code escape sequence
+                    // Color it as a number.
+                    state = SCE_RB_NUMBER;
+                    is_real_number = false;
+                }
             } else if (isoperator(ch) || ch == '.') {
 				styler.ColourTo(i - 1, state);
 				styler.ColourTo(i, SCE_RB_OPERATOR);
@@ -909,7 +1004,20 @@
                 // we aren't ending an object exp'n, and ops
                 // like : << / are unary operators.
                 
-                preferRE = (strchr(")}].", ch) == NULL);
+                if (ch == '{') {
+                    ++brace_counts;
+                    preferRE = true;
+                } else if (ch == '}' && --brace_counts < 0
+                           && inner_string_count > 0) {
+                    styler.ColourTo(i, SCE_RB_OPERATOR);
+                    exitInnerExpression(inner_string_types,
+                                        inner_expn_brace_counts,
+                                        inner_quotes,
+                                        inner_string_count,
+                                        state, brace_counts, Quote);
+                } else {
+                    preferRE = (strchr(")}].", ch) == NULL);
+                }
                 // Stay in default state
             } else if (isEOLChar(ch)) {
                 // Make sure it's a true line-end, with no backslash
@@ -984,7 +1092,37 @@
                 }
             }
         } else if (state == SCE_RB_NUMBER) {
-            if (isSafeAlnumOrHigh(ch) || ch == '_') {
+            if (!is_real_number) {
+                if (ch != '\\') {
+                    styler.ColourTo(i, state);
+                    state = SCE_RB_DEFAULT;
+                    preferRE = false;
+                } else if (strchr("\\ntrfvaebs", chNext)) {
+                    // Terminal escape sequence -- handle it next time
+                    // Nothing more to do this time through the loop
+                } else if (chNext == 'C' || chNext == 'M') {
+                    if (chNext2 != '-') {
+                        // \C or \M ends the sequence -- handle it next time
+                    } else {
+                        // Move from abc?\C-x
+                        //               ^
+                        // to
+                        //                 ^
+                        i += 2;
+                        ch = chNext2;
+                        chNext = styler.SafeGetCharAt(i + 1);
+                    }
+                } else if (chNext == 'c') {
+                    // Stay here, \c is a combining sequence
+                    advance_char(i, ch, chNext, chNext2); // pass by ref
+                } else {
+                    // ?\x, including ?\\ is final.
+                    styler.ColourTo(i + 1, state);
+                    state = SCE_RB_DEFAULT;
+                    preferRE = false;
+                    advance_char(i, ch, chNext, chNext2);
+                }
+            } else if (isSafeAlnumOrHigh(ch) || ch == '_') {
                 // Keep going
             } else if (ch == '.' && ++numDots == 1) {
                 // Keep going
@@ -1155,30 +1293,47 @@
                 Quote.Count++;
                 
             } else if (ch == '#' ) {
-                //todo: distinguish comments from pound chars
-                // for now, handle as comment
-                styler.ColourTo(i - 1, state);
-                bool inEscape = false;
-                while (++i < lengthDoc) {
-                    ch = styler.SafeGetCharAt(i);
-                    if (ch == '\\') {
-                        inEscape = true;
-                    } else if (isEOLChar(ch)) {
-                        // Comment inside a regex
-                        styler.ColourTo(i - 1, SCE_RB_COMMENTLINE);
-                        break;
-                    } else if (inEscape) {
-                        inEscape = false;  // don't look at char
-                    } else if (ch == Quote.Down) {
-                        // Have the regular handler deal with this
-                        // to get trailing modifiers.
-                        i--;
-                        ch = styler[i];
-						break;
+                if (chNext == '{'
+                    && inner_string_count < INNER_STRINGS_MAX_COUNT) {
+                    // process #{ ... }
+                    styler.ColourTo(i - 1, state);
+                    styler.ColourTo(i + 1, SCE_RB_OPERATOR);
+                    enterInnerExpression(inner_string_types,
+                                         inner_expn_brace_counts,
+                                         inner_quotes,
+                                         inner_string_count,
+                                         state,
+                                         brace_counts,
+                                         Quote);
+                    preferRE = true;
+                    // Skip one
+                    advance_char(i, ch, chNext, chNext2);
+                } else {
+                    //todo: distinguish comments from pound chars
+                    // for now, handle as comment
+                    styler.ColourTo(i - 1, state);
+                    bool inEscape = false;
+                    while (++i < lengthDoc) {
+                        ch = styler.SafeGetCharAt(i);
+                        if (ch == '\\') {
+                            inEscape = true;
+                        } else if (isEOLChar(ch)) {
+                            // Comment inside a regex
+                            styler.ColourTo(i - 1, SCE_RB_COMMENTLINE);
+                            break;
+                        } else if (inEscape) {
+                            inEscape = false;  // don't look at char
+                        } else if (ch == Quote.Down) {
+                            // Have the regular handler deal with this
+                            // to get trailing modifiers.
+                            i--;
+                            ch = styler[i];
+                            break;
+                        }
                     }
+                    chNext = styler.SafeGetCharAt(i + 1);
+                    chNext2 = styler.SafeGetCharAt(i + 2);
                 }
-                chNext = styler.SafeGetCharAt(i + 1);
-                chNext2 = styler.SafeGetCharAt(i + 2);
             }
         // Quotes of all kinds...
         } else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ || 
@@ -1199,6 +1354,23 @@
                 }
             } else if (ch == Quote.Up) {
                 Quote.Count++;
+            } else if (ch == '#' && chNext == '{'
+                       && inner_string_count < INNER_STRINGS_MAX_COUNT
+                       && state != SCE_RB_CHARACTER
+                       && state != SCE_RB_STRING_Q) {
+                // process #{ ... }
+                styler.ColourTo(i - 1, state);
+                styler.ColourTo(i + 1, SCE_RB_OPERATOR);
+                enterInnerExpression(inner_string_types,
+                                     inner_expn_brace_counts,
+                                     inner_quotes,
+                                     inner_string_count,
+                                     state,
+                                     brace_counts,
+                                     Quote);
+                preferRE = true;
+                // Skip one
+                advance_char(i, ch, chNext, chNext2);
             }
         }
             
@@ -1469,7 +1641,7 @@
             if (foldComment && stylePrev != SCE_RB_COMMENTLINE) {
                 if (chNext == '{') {
 					levelCurrent++;
-				} else if (chNext == '}') {
+				} else if (chNext == '}' && levelCurrent > 0) {
 					levelCurrent--;
 				}
             }
@@ -1520,6 +1692,7 @@
 			visibleChars++;
             buffer_ends_with_eol = false;
         }
+		stylePrev = style;
     }
 	// Fill in the real level of the next line, keeping the current flags as they will be filled in later
     if (!buffer_ends_with_eol) {

Modified: trunk/plugins/editor/scintilla/LexSQL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexSQL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexSQL.cxx	Sat Nov 15 17:50:33 2008
@@ -20,8 +20,12 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsAWordChar(int ch) {
-	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+	return (ch < 0x80) && (isalnum(ch) || ch == '_');
 }
 
 static inline bool IsAWordStart(int ch) {

Modified: trunk/plugins/editor/scintilla/LexScriptol.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexScriptol.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexScriptol.cxx	Sat Nov 15 17:50:33 2008
@@ -17,6 +17,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord)
 {
     char s[100];

Modified: trunk/plugins/editor/scintilla/LexSmalltalk.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexSmalltalk.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexSmalltalk.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
 | lexTable classificationBlock charClasses |
 charClasses := #(#DecDigit #Letter #Special #Upper #BinSel).

Modified: trunk/plugins/editor/scintilla/LexSpecman.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexSpecman.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexSpecman.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,9 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
 
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');

Modified: trunk/plugins/editor/scintilla/LexSpice.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexSpice.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexSpice.cxx	Sat Nov 15 17:50:33 2008
@@ -19,6 +19,10 @@
 #include "SciLexer.h"
 #include "SString.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 /*
  * Interface
  */

Modified: trunk/plugins/editor/scintilla/LexTADS3.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexTADS3.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexTADS3.cxx	Sat Nov 15 17:50:33 2008
@@ -2,12 +2,8 @@
 /** @file LexTADS3.cxx
  ** Lexer for TADS3.
  **/
-/* Copyright 2005 by Michael Cartmell
- * Parts copyright 1998-2002 by Neil Hodgson <neilh scintilla org>
- * In particular FoldTADS3Doc is derived from FoldCppDoc
- * The License.txt file describes the conditions under which this software may
- * be distributed.
- */
+// Copyright 1998-2006 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
 
 /*
  * TADS3 is a language designed by Michael J. Roberts for the writing of text
@@ -50,516 +46,583 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static const int T3_SINGLE_QUOTE = 1;
 static const int T3_INT_EXPRESSION = 2;
+static const int T3_INT_EXPRESSION_IN_TAG = 4;
+static const int T3_HTML_SQUOTE = 8;
 
 static inline bool IsEOL(const int ch, const int chNext) {
-	return (ch == '\r' && chNext != '\n') || (ch == '\n');
+        return (ch == '\r' && chNext != '\n') || (ch == '\n');
+}
+
+/*
+ *   Test the current character to see if it's the START of an EOL sequence;
+ *   if so, skip ahead to the last character of the sequence and return true,
+ *   and if not just return false.  There are a few places where we want to
+ *   check to see if a newline sequence occurs at a particular point, but
+ *   where a caller expects a subroutine to stop only upon reaching the END
+ *   of a newline sequence (in particular, CR-LF on Windows).  That's why
+ *   IsEOL() above only returns true on CR if the CR isn't followed by an LF
+ *   - it doesn't want to admit that there's a newline until reaching the END
+ *   of the sequence.  We meet both needs by saying that there's a newline
+ *   when we see the CR in a CR-LF, but skipping the CR before returning so
+ *   that the caller's caller will see that we've stopped at the LF.  
+ */
+static inline bool IsEOLSkip(StyleContext &sc)
+{
+    /* test for CR-LF */
+    if (sc.ch == '\r' && sc.chNext == '\n')
+    {
+        /* got CR-LF - skip the CR and indicate that we're at a newline */
+        sc.Forward();
+        return true;
+    }
+
+    /* 
+     *   in other cases, we have at most a 1-character newline, so do the
+     *   normal IsEOL test 
+     */
+    return IsEOL(sc.ch, sc.chNext);
 }
 
 static inline bool IsASpaceOrTab(const int ch) {
-	return ch == ' ' || ch == '\t';
+        return ch == ' ' || ch == '\t';
 }
 
 static inline bool IsATADS3Operator(const int ch) {
-	return ch == '=' || ch == '{' || ch == '}' || ch == '(' || ch == ')'
-		|| ch == '[' || ch == ']' || ch == ',' || ch == ':' || ch == ';'
-		|| ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%'
-		|| ch == '?' || ch == '!' || ch == '<' || ch == '>' || ch == '|'
-		|| ch == '@' || ch == '&' || ch == '~';
+        return ch == '=' || ch == '{' || ch == '}' || ch == '(' || ch == ')'
+                || ch == '[' || ch == ']' || ch == ',' || ch == ':' || ch == ';'
+                || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%'
+                || ch == '?' || ch == '!' || ch == '<' || ch == '>' || ch == '|'
+                || ch == '@' || ch == '&' || ch == '~';
 }
 
 static inline bool IsAWordChar(const int ch) {
-	return isalnum(ch) || ch == '_' || ch == '.';
+        return isalnum(ch) || ch == '_';
 }
 
 static inline bool IsAWordStart(const int ch) {
-	return isalpha(ch) || ch == '_';
+        return isalpha(ch) || ch == '_';
 }
 
 static inline bool IsAHexDigit(const int ch) {
-	int lch = tolower(ch);
-	return isdigit(lch) || lch == 'a' || lch == 'b' || lch == 'c'
-		|| lch == 'd' || lch == 'e' || lch == 'f';
+        int lch = tolower(ch);
+        return isdigit(lch) || lch == 'a' || lch == 'b' || lch == 'c'
+                || lch == 'd' || lch == 'e' || lch == 'f';
 }
 
 static inline bool IsAnHTMLChar(int ch) {
-	return isalnum(ch) || ch == '-' || ch == '_' || ch == '.';
+        return isalnum(ch) || ch == '-' || ch == '_' || ch == '.';
 }
 
 static inline bool IsADirectiveChar(int ch) {
-	return isalnum(ch) || isspace(ch) || ch == '-' || ch == '/';
+        return isalnum(ch) || isspace(ch) || ch == '-' || ch == '/';
 }
 
 static inline bool IsANumberStart(StyleContext &sc) {
-	return isdigit(sc.ch)
-		|| (!isdigit(sc.chPrev) && sc.ch == '.' && isdigit(sc.chNext));
+        return isdigit(sc.ch)
+                || (!isdigit(sc.chPrev) && sc.ch == '.' && isdigit(sc.chNext));
 }
 
 inline static void ColouriseTADS3Operator(StyleContext &sc) {
-	int initState = sc.state;
-	sc.SetState(SCE_T3_OPERATOR);
-	sc.ForwardSetState(initState);
+        int initState = sc.state;
+        int c = sc.ch;
+        sc.SetState(c == '{' || c == '}' ? SCE_T3_BRACE : SCE_T3_OPERATOR);
+        sc.ForwardSetState(initState);
 }
 
 static void ColouriseTADSHTMLString(StyleContext &sc, int &lineState) {
-	int endState = sc.state;
-	int chQuote = sc.ch;
-	if (endState == SCE_T3_HTML_STRING) {
-		if (lineState&T3_SINGLE_QUOTE) {
-			endState = SCE_T3_S_STRING;
-			chQuote = '"';
-		} else if (lineState&T3_INT_EXPRESSION) {
-			endState = SCE_T3_X_STRING;
-			chQuote = '\'';
-		} else {
-			endState = SCE_T3_D_STRING;
-			chQuote = '\'';
-		}
-	} else {
-		sc.SetState(SCE_T3_HTML_STRING);
-		sc.Forward();
-	}
-	int chString = chQuote == '"'? '\'': '"';
-
-	while (sc.More()) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		if (sc.ch == chQuote) {
-			sc.ForwardSetState(endState);
-			return;
-		}
-		if (sc.ch == chString) {
-			sc.SetState(endState);
-			return;
-		}
-		if (sc.Match('\\', static_cast<char>(chQuote))
-			|| sc.Match('\\', static_cast<char>(chString))) {
-			sc.Forward(2);
-		} else {
-			sc.Forward();
-		}
-	}
+        int endState = sc.state;
+        int chQuote = sc.ch;
+        int chString = (lineState & T3_SINGLE_QUOTE) ? '\'' : '"';
+        if (endState == SCE_T3_HTML_STRING) {
+                if (lineState&T3_SINGLE_QUOTE) {
+                        endState = SCE_T3_S_STRING;
+                        chString = '\'';
+                } else if (lineState&T3_INT_EXPRESSION) {
+                        endState = SCE_T3_X_STRING;
+                        chString = '"';
+                } else {
+                        endState = SCE_T3_HTML_DEFAULT;
+                        chString = '"';
+                }
+                chQuote = (lineState & T3_HTML_SQUOTE) ? '\'' : '"';
+        } else {
+                sc.SetState(SCE_T3_HTML_STRING);
+                sc.Forward();
+        }
+        if (chQuote == '"')
+                lineState &= ~T3_HTML_SQUOTE; 
+        else
+                lineState |= T3_HTML_SQUOTE;
+
+        while (sc.More()) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                if (sc.ch == chQuote) {
+                        sc.ForwardSetState(endState);
+                        return;
+                }
+                if (sc.Match('\\', static_cast<char>(chQuote))) {
+                        sc.Forward(2);
+                        sc.SetState(endState);
+                        return;
+                }
+                if (sc.ch == chString) {
+                        sc.SetState(SCE_T3_DEFAULT);
+                        return;
+                }
+
+                if (sc.Match('<', '<')) {
+                        lineState |= T3_INT_EXPRESSION | T3_INT_EXPRESSION_IN_TAG;
+                        sc.SetState(SCE_T3_X_DEFAULT);
+                        sc.Forward(2);
+                        return;
+                }
+
+                if (sc.Match('\\', static_cast<char>(chQuote))
+                        || sc.Match('\\', static_cast<char>(chString))
+                        || sc.Match('\\', '\\')) {
+                        sc.Forward(2);
+                } else {
+                        sc.Forward();
+                }
+        }
 }
 
 static void ColouriseTADS3HTMLTagStart(StyleContext &sc) {
-	sc.SetState(SCE_T3_HTML_TAG);
-	sc.Forward();
-	if (sc.ch == '/') {
-		sc.Forward();
-	}
-	while (IsAnHTMLChar(sc.ch)) {
-		sc.Forward();
-	}
+        sc.SetState(SCE_T3_HTML_TAG);
+        sc.Forward();
+        if (sc.ch == '/') {
+                sc.Forward();
+        }
+        while (IsAnHTMLChar(sc.ch)) {
+                sc.Forward();
+        }
 }
 
 static void ColouriseTADS3HTMLTag(StyleContext &sc, int &lineState) {
-	int endState = sc.state;
-	int chQuote = '"';
-	int chString = '\'';
-	switch (endState) {
-		case SCE_T3_S_STRING:
-			ColouriseTADS3HTMLTagStart(sc);
-			sc.SetState(SCE_T3_HTML_DEFAULT);
-			chQuote = '\'';
-			chString = '"';
-			break;
-		case SCE_T3_D_STRING:
-		case SCE_T3_X_STRING:
-			ColouriseTADS3HTMLTagStart(sc);
-			sc.SetState(SCE_T3_HTML_DEFAULT);
-			break;
-		case SCE_T3_HTML_DEFAULT:
-			if (lineState&T3_SINGLE_QUOTE) {
-				endState = SCE_T3_S_STRING;
-				chQuote = '\'';
-				chString = '"';
-			} else if (lineState&T3_INT_EXPRESSION) {
-				endState = SCE_T3_X_STRING;
-			} else {
-				endState = SCE_T3_D_STRING;
-			}
-			break;
-	}
-
-	while (sc.More()) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		if (sc.Match('/', '>')) {
-			sc.SetState(SCE_T3_HTML_TAG);
-			sc.Forward(2);
-			sc.SetState(endState);
-			return;
-		}
-		if (sc.ch == '>') {
-			sc.SetState(SCE_T3_HTML_TAG);
-			sc.ForwardSetState(endState);
-			return;
-		}
-		if (sc.ch == chQuote) {
-			sc.SetState(endState);
-			return;
-		}
-		if (sc.ch == chString) {
-			ColouriseTADSHTMLString(sc, lineState);
-		} else if (sc.ch == '=') {
-			ColouriseTADS3Operator(sc);
-		} else {
-			sc.Forward();
-		}
-	}
+        int endState = sc.state;
+        int chQuote = '"';
+        int chString = '\'';
+        switch (endState) {
+                case SCE_T3_S_STRING:
+                        ColouriseTADS3HTMLTagStart(sc);
+                        sc.SetState(SCE_T3_HTML_DEFAULT);
+                        chQuote = '\'';
+                        chString = '"';
+                        break;
+                case SCE_T3_D_STRING:
+                case SCE_T3_X_STRING:
+                        ColouriseTADS3HTMLTagStart(sc);
+                        sc.SetState(SCE_T3_HTML_DEFAULT);
+                        break;
+                case SCE_T3_HTML_DEFAULT:
+                        if (lineState&T3_SINGLE_QUOTE) {
+                                endState = SCE_T3_S_STRING;
+                                chQuote = '\'';
+                                chString = '"';
+                        } else if (lineState&T3_INT_EXPRESSION) {
+                                endState = SCE_T3_X_STRING;
+                        } else {
+                                endState = SCE_T3_D_STRING;
+                        }
+                        break;
+        }
+
+        while (sc.More()) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                if (sc.Match('/', '>')) {
+                        sc.SetState(SCE_T3_HTML_TAG);
+                        sc.Forward(2);
+                        sc.SetState(endState);
+                        return;
+                }
+                if (sc.ch == '>') {
+                        sc.SetState(SCE_T3_HTML_TAG);
+                        sc.ForwardSetState(endState);
+                        return;
+                }
+                if (sc.ch == chQuote) {
+                        sc.SetState(endState);
+                        return;
+                }
+                if (sc.Match('\\', static_cast<char>(chQuote))) {
+                        sc.Forward();
+                        ColouriseTADSHTMLString(sc, lineState);
+                        if (sc.state == SCE_T3_X_DEFAULT)
+                            break;
+                } else if (sc.ch == chString) {
+                        ColouriseTADSHTMLString(sc, lineState);
+                } else if (sc.ch == '=') {
+                        ColouriseTADS3Operator(sc);
+                } else {
+                        sc.Forward();
+                }
+        }
 }
 
 static void ColouriseTADS3Keyword(StyleContext &sc,
-							WordList *keywordlists[], 	unsigned int endPos) {
-	char s[250];
-	WordList &keywords = *keywordlists[0];
-	WordList &userwords1 = *keywordlists[1];
-	WordList &userwords2 = *keywordlists[2];
-	WordList &userwords3 = *keywordlists[3];
-	int initState = sc.state;
-	sc.SetState(SCE_T3_IDENTIFIER);
-	while (sc.More() && (IsAWordChar(sc.ch))) {
-		sc.Forward();
-	}
-	sc.GetCurrent(s, sizeof(s));
-	if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) {
-		// have to find if "in" is next
-		int n = 1;
-		while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n)))
-			n++;
-		if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') {
-			sc.Forward(n+2);
-			sc.ChangeState(SCE_T3_KEYWORD);
-		}
-	} else if (keywords.InList(s)) {
-		sc.ChangeState(SCE_T3_KEYWORD);
-	} else if (userwords3.InList(s)) {
-		sc.ChangeState(SCE_T3_USER3);
-	} else if (userwords2.InList(s)) {
-		sc.ChangeState(SCE_T3_USER2);
-	} else if (userwords1.InList(s)) {
-		sc.ChangeState(SCE_T3_USER1);
-	}
-	sc.SetState(initState);
+                                                        WordList *keywordlists[],       unsigned int endPos) {
+        char s[250];
+        WordList &keywords = *keywordlists[0];
+        WordList &userwords1 = *keywordlists[1];
+        WordList &userwords2 = *keywordlists[2];
+        WordList &userwords3 = *keywordlists[3];
+        int initState = sc.state;
+        sc.SetState(SCE_T3_IDENTIFIER);
+        while (sc.More() && (IsAWordChar(sc.ch))) {
+                sc.Forward();
+        }
+        sc.GetCurrent(s, sizeof(s));
+        if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) {
+                // have to find if "in" is next
+                int n = 1;
+                while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n)))
+                        n++;
+                if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') {
+                        sc.Forward(n+2);
+                        sc.ChangeState(SCE_T3_KEYWORD);
+                }
+        } else if (keywords.InList(s)) {
+                sc.ChangeState(SCE_T3_KEYWORD);
+        } else if (userwords3.InList(s)) {
+                sc.ChangeState(SCE_T3_USER3);
+        } else if (userwords2.InList(s)) {
+                sc.ChangeState(SCE_T3_USER2);
+        } else if (userwords1.InList(s)) {
+                sc.ChangeState(SCE_T3_USER1);
+        }
+        sc.SetState(initState);
 }
 
 static void ColouriseTADS3MsgParam(StyleContext &sc, int &lineState) {
-	int endState = sc.state;
-	int chQuote = '"';
-	switch (endState) {
-		case SCE_T3_S_STRING:
-			sc.SetState(SCE_T3_MSG_PARAM);
-			sc.Forward();
-			chQuote = '\'';
-			break;
-		case SCE_T3_D_STRING:
-		case SCE_T3_X_STRING:
-			sc.SetState(SCE_T3_MSG_PARAM);
-			sc.Forward();
-			break;
-		case SCE_T3_MSG_PARAM:
-			if (lineState&T3_SINGLE_QUOTE) {
-				endState = SCE_T3_S_STRING;
-				chQuote = '\'';
-			} else if (lineState&T3_INT_EXPRESSION) {
-				endState = SCE_T3_X_STRING;
-			} else {
-				endState = SCE_T3_D_STRING;
-			}
-			break;
-	}
-	while (sc.More() && sc.ch != '}' && sc.ch != chQuote) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		if (sc.ch == '\\') {
-			sc.Forward();
-		}
-		sc.Forward();
-	}
-	if (sc.ch == chQuote) {
-		sc.SetState(endState);
-	} else {
-		sc.ForwardSetState(endState);
-	}
+        int endState = sc.state;
+        int chQuote = '"';
+        switch (endState) {
+                case SCE_T3_S_STRING:
+                        sc.SetState(SCE_T3_MSG_PARAM);
+                        sc.Forward();
+                        chQuote = '\'';
+                        break;
+                case SCE_T3_D_STRING:
+                case SCE_T3_X_STRING:
+                        sc.SetState(SCE_T3_MSG_PARAM);
+                        sc.Forward();
+                        break;
+                case SCE_T3_MSG_PARAM:
+                        if (lineState&T3_SINGLE_QUOTE) {
+                                endState = SCE_T3_S_STRING;
+                                chQuote = '\'';
+                        } else if (lineState&T3_INT_EXPRESSION) {
+                                endState = SCE_T3_X_STRING;
+                        } else {
+                                endState = SCE_T3_D_STRING;
+                        }
+                        break;
+        }
+        while (sc.More() && sc.ch != '}' && sc.ch != chQuote) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                if (sc.ch == '\\') {
+                        sc.Forward();
+                }
+                sc.Forward();
+        }
+        if (sc.ch == chQuote) {
+                sc.SetState(endState);
+        } else {
+                sc.ForwardSetState(endState);
+        }
 }
 
 static void ColouriseTADS3LibDirective(StyleContext &sc, int &lineState) {
-	int initState = sc.state;
-	int chQuote = '"';
-	switch (initState) {
-		case SCE_T3_S_STRING:
-			sc.SetState(SCE_T3_LIB_DIRECTIVE);
-			sc.Forward(2);
-			chQuote = '\'';
-			break;
-		case SCE_T3_D_STRING:
-			sc.SetState(SCE_T3_LIB_DIRECTIVE);
-			sc.Forward(2);
-			break;
-		case SCE_T3_LIB_DIRECTIVE:
-			if (lineState&T3_SINGLE_QUOTE) {
-				initState = SCE_T3_S_STRING;
-				chQuote = '\'';
-			} else {
-				initState = SCE_T3_D_STRING;
-			}
-			break;
-	}
-	while (sc.More() && IsADirectiveChar(sc.ch)) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		sc.Forward();
-	};
-	if (sc.ch == '>' || !sc.More()) {
-		sc.ForwardSetState(initState);
-	} else if (sc.ch == chQuote) {
-		sc.SetState(initState);
-	} else {
-		sc.ChangeState(initState);
-		sc.Forward();
-	}
+        int initState = sc.state;
+        int chQuote = '"';
+        switch (initState) {
+                case SCE_T3_S_STRING:
+                        sc.SetState(SCE_T3_LIB_DIRECTIVE);
+                        sc.Forward(2);
+                        chQuote = '\'';
+                        break;
+                case SCE_T3_D_STRING:
+                        sc.SetState(SCE_T3_LIB_DIRECTIVE);
+                        sc.Forward(2);
+                        break;
+                case SCE_T3_LIB_DIRECTIVE:
+                        if (lineState&T3_SINGLE_QUOTE) {
+                                initState = SCE_T3_S_STRING;
+                                chQuote = '\'';
+                        } else {
+                                initState = SCE_T3_D_STRING;
+                        }
+                        break;
+        }
+        while (sc.More() && IsADirectiveChar(sc.ch)) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                sc.Forward();
+        };
+        if (sc.ch == '>' || !sc.More()) {
+                sc.ForwardSetState(initState);
+        } else if (sc.ch == chQuote) {
+                sc.SetState(initState);
+        } else {
+                sc.ChangeState(initState);
+                sc.Forward();
+        }
 }
 
 static void ColouriseTADS3String(StyleContext &sc, int &lineState) {
-	int chQuote = sc.ch;
-	int endState = sc.state;
-	switch (sc.state) {
-		case SCE_T3_DEFAULT:
-		case SCE_T3_X_DEFAULT:
-			if (chQuote == '"') {
-				if (sc.state == SCE_T3_DEFAULT) {
-					sc.SetState(SCE_T3_D_STRING);
-				} else {
-					sc.SetState(SCE_T3_X_STRING);
-				}
-				lineState &= ~T3_SINGLE_QUOTE;
-			} else {
-				sc.SetState(SCE_T3_S_STRING);
-				lineState |= T3_SINGLE_QUOTE;
-			}
-			sc.Forward();
-			break;
-		case SCE_T3_S_STRING:
-			chQuote = '\'';
-			endState = lineState&T3_INT_EXPRESSION ?
-				SCE_T3_X_DEFAULT : SCE_T3_DEFAULT;
-			break;
-		case SCE_T3_D_STRING:
-			chQuote = '"';
-			endState = SCE_T3_DEFAULT;
-			break;
-		case SCE_T3_X_STRING:
-			chQuote = '"';
-			endState = SCE_T3_X_DEFAULT;
-			break;
-	}
-	while (sc.More()) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		if (sc.ch == chQuote) {
-			sc.ForwardSetState(endState);
-			return;
-		}
-		if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) {
-			lineState |= T3_INT_EXPRESSION;
-			sc.SetState(SCE_T3_X_DEFAULT);
-			sc.Forward(2);
-			return;
-		}
-		if (sc.Match('\\', static_cast<char>(chQuote))) {
-			sc.Forward(2);
-		} else if (sc.ch == '{') {
-			ColouriseTADS3MsgParam(sc, lineState);
-		} else if (sc.Match('<', '.')) {
-			ColouriseTADS3LibDirective(sc, lineState);
-		} else if (sc.ch == '<') {
-			ColouriseTADS3HTMLTag(sc, lineState);
-		} else {
-			sc.Forward();
-		}
-	}
+        int chQuote = sc.ch;
+        int endState = sc.state;
+        switch (sc.state) {
+                case SCE_T3_DEFAULT:
+                case SCE_T3_X_DEFAULT:
+                        if (chQuote == '"') {
+                                if (sc.state == SCE_T3_DEFAULT) {
+                                        sc.SetState(SCE_T3_D_STRING);
+                                } else {
+                                        sc.SetState(SCE_T3_X_STRING);
+                                }
+                                lineState &= ~T3_SINGLE_QUOTE;
+                        } else {
+                                sc.SetState(SCE_T3_S_STRING);
+                                lineState |= T3_SINGLE_QUOTE;
+                        }
+                        sc.Forward();
+                        break;
+                case SCE_T3_S_STRING:
+                        chQuote = '\'';
+                        endState = lineState&T3_INT_EXPRESSION ?
+                                SCE_T3_X_DEFAULT : SCE_T3_DEFAULT;
+                        break;
+                case SCE_T3_D_STRING:
+                        chQuote = '"';
+                        endState = SCE_T3_DEFAULT;
+                        break;
+                case SCE_T3_X_STRING:
+                        chQuote = '"';
+                        endState = SCE_T3_X_DEFAULT;
+                        break;
+        }
+        while (sc.More()) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                if (sc.ch == chQuote) {
+                        sc.ForwardSetState(endState);
+                        return;
+                }
+                if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) {
+                        lineState |= T3_INT_EXPRESSION;
+                        sc.SetState(SCE_T3_X_DEFAULT);
+                        sc.Forward(2);
+                        return;
+                }
+                if (sc.Match('\\', static_cast<char>(chQuote))
+                    || sc.Match('\\', '\\')) {
+                        sc.Forward(2);
+                } else if (sc.ch == '{') {
+                        ColouriseTADS3MsgParam(sc, lineState);
+                } else if (sc.Match('<', '.')) {
+                        ColouriseTADS3LibDirective(sc, lineState);
+                } else if (sc.ch == '<') {
+                        ColouriseTADS3HTMLTag(sc, lineState);
+                        if (sc.state == SCE_T3_X_DEFAULT)
+                                return;
+                } else {
+                        sc.Forward();
+                }
+        }
 }
 
 static void ColouriseTADS3Comment(StyleContext &sc, int endState) {
-	sc.SetState(SCE_T3_BLOCK_COMMENT);
-	while (sc.More()) {
-		if (IsEOL(sc.ch, sc.chNext)) {
-			return;
-		}
-		if (sc.Match('*', '/')) {
-			sc.Forward(2);
-			sc.SetState(endState);
-			return;
-		}
-		sc.Forward();
-	}
+        sc.SetState(SCE_T3_BLOCK_COMMENT);
+        while (sc.More()) {
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        return;
+                }
+                if (sc.Match('*', '/')) {
+                        sc.Forward(2);
+                        sc.SetState(endState);
+                        return;
+                }
+                sc.Forward();
+        }
 }
 
 static void ColouriseToEndOfLine(StyleContext &sc, int initState, int endState) {
-	sc.SetState(initState);
-	while (sc.More()) {
-		if (sc.ch == '\\') {
-			sc.Forward();
-			if (IsEOL(sc.ch, sc.chNext)) {
-					return;
-			}
-		}
-		if (IsEOL(sc.ch, sc.chNext)) {
-			sc.SetState(endState);
-			return;
-		}
-		sc.Forward();
-	}
+        sc.SetState(initState);
+        while (sc.More()) {
+                if (sc.ch == '\\') {
+                        sc.Forward();
+                        if (IsEOLSkip(sc)) {
+                                        return;
+                        }
+                }
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        sc.SetState(endState);
+                        return;
+                }
+                sc.Forward();
+        }
 }
 
 static void ColouriseTADS3Number(StyleContext &sc) {
-	int endState = sc.state;
-	bool inHexNumber = false;
-	bool seenE = false;
-	bool seenDot = sc.ch == '.';
-	sc.SetState(SCE_T3_NUMBER);
-	if (sc.More()) {
-		sc.Forward();
-	}
-	if (sc.chPrev == '0' && tolower(sc.ch) == 'x') {
-		inHexNumber = true;
-		sc.Forward();
-	}
-	while (sc.More()) {
-		if (inHexNumber) {
-			if (!IsAHexDigit(sc.ch)) {
-				break;
-			}
-		} else if (!isdigit(sc.ch)) {
-			if (!seenE && tolower(sc.ch) == 'e') {
-				seenE = true;
-				seenDot = true;
-				if (sc.chNext == '+' || sc.chNext == '-') {
-					sc.Forward();
-				}
-			} else if (!seenDot && sc.ch == '.') {
-				seenDot = true;
-			} else {
-				break;
-			}
-		}
-		sc.Forward();
-	}
-	sc.SetState(endState);
+        int endState = sc.state;
+        bool inHexNumber = false;
+        bool seenE = false;
+        bool seenDot = sc.ch == '.';
+        sc.SetState(SCE_T3_NUMBER);
+        if (sc.More()) {
+                sc.Forward();
+        }
+        if (sc.chPrev == '0' && tolower(sc.ch) == 'x') {
+                inHexNumber = true;
+                sc.Forward();
+        }
+        while (sc.More()) {
+                if (inHexNumber) {
+                        if (!IsAHexDigit(sc.ch)) {
+                                break;
+                        }
+                } else if (!isdigit(sc.ch)) {
+                        if (!seenE && tolower(sc.ch) == 'e') {
+                                seenE = true;
+                                seenDot = true;
+                                if (sc.chNext == '+' || sc.chNext == '-') {
+                                        sc.Forward();
+                                }
+                        } else if (!seenDot && sc.ch == '.') {
+                                seenDot = true;
+                        } else {
+                                break;
+                        }
+                }
+                sc.Forward();
+        }
+        sc.SetState(endState);
 }
 
 static void ColouriseTADS3Doc(unsigned int startPos, int length, int initStyle,
-							   WordList *keywordlists[], Accessor &styler) {
-	int visibleChars = 0;
-	int bracketLevel = 0;
-	int lineState = 0;
-	unsigned int endPos = startPos + length;
-	int lineCurrent = styler.GetLine(startPos);
-	if (lineCurrent > 0) {
-		lineState = styler.GetLineState(lineCurrent-1);
-	}
-	StyleContext sc(startPos, length, initStyle, styler);
-
-	while (sc.More()) {
-
-		if (IsEOL(sc.ch, sc.chNext)) {
-			styler.SetLineState(lineCurrent, lineState);
-			lineCurrent++;
-			visibleChars = 0;
-			sc.Forward();
-			if (sc.ch == '\n') {
-				sc.Forward();
-			}
-		}
-
-		switch(sc.state) {
-			case SCE_T3_PREPROCESSOR:
-			case SCE_T3_LINE_COMMENT:
-				ColouriseToEndOfLine(sc, sc.state, lineState&T3_INT_EXPRESSION ?
-					SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
-				break;
-			case SCE_T3_S_STRING:
-			case SCE_T3_D_STRING:
-			case SCE_T3_X_STRING:
-				ColouriseTADS3String(sc, lineState);
-				visibleChars++;
-				break;
-			case SCE_T3_MSG_PARAM:
-				ColouriseTADS3MsgParam(sc, lineState);
-				break;
-			case SCE_T3_LIB_DIRECTIVE:
-				ColouriseTADS3LibDirective(sc, lineState);
-				break;
-			case SCE_T3_HTML_DEFAULT:
-				ColouriseTADS3HTMLTag(sc, lineState);
-				break;
-			case SCE_T3_HTML_STRING:
-				ColouriseTADSHTMLString(sc, lineState);
-				break;
-			case SCE_T3_BLOCK_COMMENT:
-				ColouriseTADS3Comment(sc, lineState&T3_INT_EXPRESSION ?
-					SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
-				break;
-			case SCE_T3_DEFAULT:
-			case SCE_T3_X_DEFAULT:
-				if (IsASpaceOrTab(sc.ch)) {
-					sc.Forward();
-				} else if (sc.ch == '#' && visibleChars == 0) {
-					ColouriseToEndOfLine(sc, SCE_T3_PREPROCESSOR, sc.state);
-				} else if (sc.Match('/', '*')) {
-					ColouriseTADS3Comment(sc, sc.state);
-					visibleChars++;
-				} else if (sc.Match('/', '/')) {
-					ColouriseToEndOfLine(sc, SCE_T3_LINE_COMMENT, sc.state);
-				} else if (sc.ch == '"') {
-					bracketLevel = 0;
-					ColouriseTADS3String(sc, lineState);
-					visibleChars++;
-				} else if (sc.ch == '\'') {
-					ColouriseTADS3String(sc, lineState);
-					visibleChars++;
-				} else if (sc.state == SCE_T3_X_DEFAULT && bracketLevel == 0
-						   && sc.Match('>', '>')) {
-					sc.Forward(2);
-					sc.SetState(SCE_T3_D_STRING);
-					lineState &= ~(T3_SINGLE_QUOTE|T3_INT_EXPRESSION);
-				} else if (IsATADS3Operator(sc.ch)) {
-					if (sc.state == SCE_T3_X_DEFAULT) {
-						if (sc.ch == '(') {
-							bracketLevel++;
-						} else if (sc.ch == ')') {
-							bracketLevel--;
-						}
-					}
-					ColouriseTADS3Operator(sc);
-					visibleChars++;
-				} else if (IsANumberStart(sc)) {
-					ColouriseTADS3Number(sc);
-					visibleChars++;
-				} else if (IsAWordStart(sc.ch)) {
-					ColouriseTADS3Keyword(sc, keywordlists, endPos);
-					visibleChars++;
-				} else if (sc.Match("...")) {
-					sc.SetState(SCE_T3_IDENTIFIER);
-					sc.Forward(3);
-					sc.SetState(SCE_T3_DEFAULT);
-				} else {
-					sc.Forward();
-					visibleChars++;
-				}
-				break;
-			default:
-				sc.SetState(SCE_T3_DEFAULT);
-				sc.Forward();
-		}
-	}
-	sc.Complete();
+                                                           WordList *keywordlists[], Accessor &styler) {
+        int visibleChars = 0;
+        int bracketLevel = 0;
+        int lineState = 0;
+        unsigned int endPos = startPos + length;
+        int lineCurrent = styler.GetLine(startPos);
+        if (lineCurrent > 0) {
+                lineState = styler.GetLineState(lineCurrent-1);
+        }
+        StyleContext sc(startPos, length, initStyle, styler);
+
+        while (sc.More()) {
+
+                if (IsEOL(sc.ch, sc.chNext)) {
+                        styler.SetLineState(lineCurrent, lineState);
+                        lineCurrent++;
+                        visibleChars = 0;
+                        sc.Forward();
+                        if (sc.ch == '\n') {
+                                sc.Forward();
+                        }
+                }
+
+                switch(sc.state) {
+                        case SCE_T3_PREPROCESSOR:
+                        case SCE_T3_LINE_COMMENT:
+                                ColouriseToEndOfLine(sc, sc.state, lineState&T3_INT_EXPRESSION ?
+                                        SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
+                                break;
+                        case SCE_T3_S_STRING:
+                        case SCE_T3_D_STRING:
+                        case SCE_T3_X_STRING:
+                                ColouriseTADS3String(sc, lineState);
+                                visibleChars++;
+                                break;
+                        case SCE_T3_MSG_PARAM:
+                                ColouriseTADS3MsgParam(sc, lineState);
+                                break;
+                        case SCE_T3_LIB_DIRECTIVE:
+                                ColouriseTADS3LibDirective(sc, lineState);
+                                break;
+                        case SCE_T3_HTML_DEFAULT:
+                                ColouriseTADS3HTMLTag(sc, lineState);
+                                break;
+                        case SCE_T3_HTML_STRING:
+                                ColouriseTADSHTMLString(sc, lineState);
+                                break;
+                        case SCE_T3_BLOCK_COMMENT:
+                                ColouriseTADS3Comment(sc, lineState&T3_INT_EXPRESSION ?
+                                        SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
+                                break;
+                        case SCE_T3_DEFAULT:
+                        case SCE_T3_X_DEFAULT:
+                                if (IsASpaceOrTab(sc.ch)) {
+                                        sc.Forward();
+                                } else if (sc.ch == '#' && visibleChars == 0) {
+                                        ColouriseToEndOfLine(sc, SCE_T3_PREPROCESSOR, sc.state);
+                                } else if (sc.Match('/', '*')) {
+                                        ColouriseTADS3Comment(sc, sc.state);
+                                        visibleChars++;
+                                } else if (sc.Match('/', '/')) {
+                                        ColouriseToEndOfLine(sc, SCE_T3_LINE_COMMENT, sc.state);
+                                } else if (sc.ch == '"') {
+                                        bracketLevel = 0;
+                                        ColouriseTADS3String(sc, lineState);
+                                        visibleChars++;
+                                } else if (sc.ch == '\'') {
+                                        ColouriseTADS3String(sc, lineState);
+                                        visibleChars++;
+                                } else if (sc.state == SCE_T3_X_DEFAULT && bracketLevel == 0
+                                                   && sc.Match('>', '>')) {
+                                        sc.Forward(2);
+                                        sc.SetState(SCE_T3_D_STRING);
+                                        if (lineState & T3_INT_EXPRESSION_IN_TAG)
+                                                sc.SetState(SCE_T3_HTML_STRING);
+                                        lineState &= ~(T3_SINGLE_QUOTE|T3_INT_EXPRESSION
+                                                       |T3_INT_EXPRESSION_IN_TAG);
+                                } else if (IsATADS3Operator(sc.ch)) {
+                                        if (sc.state == SCE_T3_X_DEFAULT) {
+                                                if (sc.ch == '(') {
+                                                        bracketLevel++;
+                                                } else if (sc.ch == ')' && bracketLevel > 0) {
+                                                        bracketLevel--;
+                                                }
+                                        }
+                                        ColouriseTADS3Operator(sc);
+                                        visibleChars++;
+                                } else if (IsANumberStart(sc)) {
+                                        ColouriseTADS3Number(sc);
+                                        visibleChars++;
+                                } else if (IsAWordStart(sc.ch)) {
+                                        ColouriseTADS3Keyword(sc, keywordlists, endPos);
+                                        visibleChars++;
+                                } else if (sc.Match("...")) {
+                                        sc.SetState(SCE_T3_IDENTIFIER);
+                                        sc.Forward(3);
+                                        sc.SetState(SCE_T3_DEFAULT);
+                                } else {
+                                        sc.Forward();
+                                        visibleChars++;
+                                }
+                                break;
+                        default:
+                                sc.SetState(SCE_T3_DEFAULT);
+                                sc.Forward();
+                }
+        }
+        sc.Complete();
 }
 
 /*
@@ -567,15 +630,15 @@
 
  // default style
  silverKey : Key 'small silver key' 'small silver key'
-	"A small key glints in the sunlight. "
+        "A small key glints in the sunlight. "
  ;
 
  and
 
  silverKey : Key {
-	'small silver key'
-	'small silver key'
-	"A small key glints in the sunlight. "
+        'small silver key'
+        'small silver key'
+        "A small key glints in the sunlight. "
  }
 
  Some constructs mandate one or the other, but usually the author has may choose
@@ -614,224 +677,228 @@
 static const int T3_EXPECTINGPUNCTUATION = 1 << 14;
 
 static inline bool IsStringTransition(int s1, int s2) {
-	return s1 != s2
-		&& (s1 == SCE_T3_S_STRING || s1 == SCE_T3_X_STRING
-			|| s1 == SCE_T3_D_STRING && s2 != SCE_T3_X_DEFAULT)
-		&& s2 != SCE_T3_LIB_DIRECTIVE
-		&& s2 != SCE_T3_MSG_PARAM
-		&& s2 != SCE_T3_HTML_TAG
-		&& s2 != SCE_T3_HTML_STRING;
+        return s1 != s2
+                && (s1 == SCE_T3_S_STRING || s1 == SCE_T3_X_STRING
+                        || s1 == SCE_T3_D_STRING && s2 != SCE_T3_X_DEFAULT)
+                && s2 != SCE_T3_LIB_DIRECTIVE
+                && s2 != SCE_T3_MSG_PARAM
+                && s2 != SCE_T3_HTML_TAG
+                && s2 != SCE_T3_HTML_STRING;
 }
 
 static inline bool IsATADS3Punctuation(const int ch) {
-	return ch == ':' || ch == ',' || ch == '(' || ch == ')';
+        return ch == ':' || ch == ',' || ch == '(' || ch == ')';
 }
 
 static inline bool IsAnIdentifier(const int style) {
-	return style == SCE_T3_IDENTIFIER
-		|| style == SCE_T3_USER1
-		|| style == SCE_T3_USER2
-		|| style == SCE_T3_USER3;
+        return style == SCE_T3_IDENTIFIER
+                || style == SCE_T3_USER1
+                || style == SCE_T3_USER2
+                || style == SCE_T3_USER3;
+}
+
+static inline bool IsAnOperator(const int style) {
+    return style == SCE_T3_OPERATOR || SCE_T3_BRACE;
 }
 
 static inline bool IsSpaceEquivalent(const int ch, const int style) {
-	return isspace(ch)
-		|| style == SCE_T3_BLOCK_COMMENT
-		|| style == SCE_T3_LINE_COMMENT
-		|| style == SCE_T3_PREPROCESSOR;
+        return isspace(ch)
+                || style == SCE_T3_BLOCK_COMMENT
+                || style == SCE_T3_LINE_COMMENT
+                || style == SCE_T3_PREPROCESSOR;
 }
 
 static char peekAhead(unsigned int startPos, unsigned int endPos,
-					  Accessor &styler) {
-	for (unsigned int i = startPos; i < endPos; i++) {
-		int style = styler.StyleAt(i);
-		char ch = styler[i];
-		if (!IsSpaceEquivalent(ch, style)) {
-			if (IsAnIdentifier(style)) {
-				return 'a';
-			}
-			if (IsATADS3Punctuation(ch)) {
-				return ':';
-			}
-			if (ch == '{') {
-				return '{';
-			}
-			return '*';
-		}
-	}
-	return ' ';
+                                          Accessor &styler) {
+        for (unsigned int i = startPos; i < endPos; i++) {
+                int style = styler.StyleAt(i);
+                char ch = styler[i];
+                if (!IsSpaceEquivalent(ch, style)) {
+                        if (IsAnIdentifier(style)) {
+                                return 'a';
+                        }
+                        if (IsATADS3Punctuation(ch)) {
+                                return ':';
+                        }
+                        if (ch == '{') {
+                                return '{';
+                        }
+                        return '*';
+                }
+        }
+        return ' ';
 }
 
 static void FoldTADS3Doc(unsigned int startPos, int length, int initStyle,
                             WordList *[], Accessor &styler) {
-	unsigned int endPos = startPos + length;
-	int lineCurrent = styler.GetLine(startPos);
-	int levelCurrent = SC_FOLDLEVELBASE;
-	if (lineCurrent > 0)
-		levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
-	int seenStart = levelCurrent & T3_SEENSTART;
-	int expectingIdentifier = levelCurrent & T3_EXPECTINGIDENTIFIER;
-	int expectingPunctuation = levelCurrent & T3_EXPECTINGPUNCTUATION;
-	levelCurrent &= SC_FOLDLEVELNUMBERMASK;
-	int levelMinCurrent = levelCurrent;
-	int levelNext = levelCurrent;
-	char chNext = styler[startPos];
-	int styleNext = styler.StyleAt(startPos);
-	int style = initStyle;
-	char ch = chNext;
-	int stylePrev = style;
-	bool redo = false;
-	for (unsigned int i = startPos; i < endPos; i++) {
-		if (redo) {
-			redo = false;
-			i--;
-		} else {
-			ch = chNext;
-			chNext = styler.SafeGetCharAt(i + 1);
-			stylePrev = style;
-			style = styleNext;
-			styleNext = styler.StyleAt(i + 1);
-		}
-		bool atEOL = IsEOL(ch, chNext);
-
-		if (levelNext == SC_FOLDLEVELBASE) {
-			if (IsSpaceEquivalent(ch, style)) {
-				if (expectingPunctuation) {
-					expectingIdentifier = 0;
-				}
-				if (style == SCE_T3_BLOCK_COMMENT) {
-					levelNext++;
-				}
-			} else if (ch == '{') {
-				levelNext++;
-				seenStart = 0;
-			} else if (ch == '\'' || ch == '"' || ch == '[') {
-				levelNext++;
-				if (seenStart) {
-					redo = true;
-				}
-			} else if (ch == ';') {
-				seenStart = 0;
-				expectingIdentifier = 0;
-				expectingPunctuation = 0;
-			} else if (expectingIdentifier && expectingPunctuation) {
-				if (IsATADS3Punctuation(ch)) {
-					if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
-						levelNext++;
-					} else {
-						expectingPunctuation = 0;
-					}
-				} else if (!IsAnIdentifier(style)) {
-					levelNext++;
-				}
-			} else if (expectingIdentifier && !expectingPunctuation) {
-				if (!IsAnIdentifier(style)) {
-					levelNext++;
-				} else {
-					expectingPunctuation = T3_EXPECTINGPUNCTUATION;
-				}
-			} else if (!expectingIdentifier && expectingPunctuation) {
-				if (!IsATADS3Punctuation(ch)) {
-					levelNext++;
-				} else {
-					if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
-						levelNext++;
-					} else {
-						expectingIdentifier = T3_EXPECTINGIDENTIFIER;
-						expectingPunctuation = 0;
-					}
-				}
-			} else if (!expectingIdentifier && !expectingPunctuation) {
-				if (IsAnIdentifier(style)) {
-					seenStart = T3_SEENSTART;
-					expectingIdentifier = T3_EXPECTINGIDENTIFIER;
-					expectingPunctuation = T3_EXPECTINGPUNCTUATION;
-				}
-			}
-
-			if (levelNext != SC_FOLDLEVELBASE && style != SCE_T3_BLOCK_COMMENT) {
-				expectingIdentifier = 0;
-				expectingPunctuation = 0;
-			}
-
-		} else if (levelNext == SC_FOLDLEVELBASE+1 && seenStart
-				   && ch == ';' && style == SCE_T3_OPERATOR ) {
-			levelNext--;
-			seenStart = 0;
-		} else if (style == SCE_T3_BLOCK_COMMENT) {
-			if (stylePrev != SCE_T3_BLOCK_COMMENT) {
-				levelNext++;
-			} else if (styleNext != SCE_T3_BLOCK_COMMENT && !atEOL) {
-				// Comments don't end at end of line and the next character may be unstyled.
-				levelNext--;
-			}
-		} else if (ch == '\'' || ch == '"') {
-			if (IsStringTransition(style, stylePrev)) {
-				if (levelMinCurrent > levelNext) {
-					levelMinCurrent = levelNext;
-				}
-				levelNext++;
-			} else if (IsStringTransition(style, styleNext)) {
-				levelNext--;
-			}
-		} else if (style == SCE_T3_OPERATOR) {
-			if (ch == '{' || ch == '[') {
-				// Measure the minimum before a '{' to allow
-				// folding on "} else {"
-				if (levelMinCurrent > levelNext) {
-					levelMinCurrent = levelNext;
-				}
-				levelNext++;
-			} else if (ch == '}' || ch == ']') {
-				levelNext--;
-			}
-		}
-
-		if (atEOL) {
-			if (seenStart && levelNext == SC_FOLDLEVELBASE) {
-				switch (peekAhead(i+1, endPos, styler)) {
-					case ' ':
-					case '{':
-						break;
-					case '*':
-						levelNext++;
-						break;
-					case 'a':
-						if (expectingPunctuation) {
-							levelNext++;
-						}
-						break;
-					case ':':
-						if (expectingIdentifier) {
-							levelNext++;
-						}
-						break;
-				}
-				if (levelNext != SC_FOLDLEVELBASE) {
-					expectingIdentifier = 0;
-					expectingPunctuation = 0;
-				}
-			}
-			int lev = levelMinCurrent | (levelNext | expectingIdentifier
-				| expectingPunctuation | seenStart) << 16;
-			if (levelMinCurrent < levelNext)
-				lev |= SC_FOLDLEVELHEADERFLAG;
-			if (lev != styler.LevelAt(lineCurrent)) {
-				styler.SetLevel(lineCurrent, lev);
-			}
-			lineCurrent++;
-			levelCurrent = levelNext;
-			levelMinCurrent = levelCurrent;
-		}
-	}
+        unsigned int endPos = startPos + length;
+        int lineCurrent = styler.GetLine(startPos);
+        int levelCurrent = SC_FOLDLEVELBASE;
+        if (lineCurrent > 0)
+                levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+        int seenStart = levelCurrent & T3_SEENSTART;
+        int expectingIdentifier = levelCurrent & T3_EXPECTINGIDENTIFIER;
+        int expectingPunctuation = levelCurrent & T3_EXPECTINGPUNCTUATION;
+        levelCurrent &= SC_FOLDLEVELNUMBERMASK;
+        int levelMinCurrent = levelCurrent;
+        int levelNext = levelCurrent;
+        char chNext = styler[startPos];
+        int styleNext = styler.StyleAt(startPos);
+        int style = initStyle;
+        char ch = chNext;
+        int stylePrev = style;
+        bool redo = false;
+        for (unsigned int i = startPos; i < endPos; i++) {
+                if (redo) {
+                        redo = false;
+                        i--;
+                } else {
+                        ch = chNext;
+                        chNext = styler.SafeGetCharAt(i + 1);
+                        stylePrev = style;
+                        style = styleNext;
+                        styleNext = styler.StyleAt(i + 1);
+                }
+                bool atEOL = IsEOL(ch, chNext);
+
+                if (levelNext == SC_FOLDLEVELBASE) {
+                        if (IsSpaceEquivalent(ch, style)) {
+                                if (expectingPunctuation) {
+                                        expectingIdentifier = 0;
+                                }
+                                if (style == SCE_T3_BLOCK_COMMENT) {
+                                        levelNext++;
+                                }
+                        } else if (ch == '{') {
+                                levelNext++;
+                                seenStart = 0;
+                        } else if (ch == '\'' || ch == '"' || ch == '[') {
+                                levelNext++;
+                                if (seenStart) {
+                                        redo = true;
+                                }
+                        } else if (ch == ';') {
+                                seenStart = 0;
+                                expectingIdentifier = 0;
+                                expectingPunctuation = 0;
+                        } else if (expectingIdentifier && expectingPunctuation) {
+                                if (IsATADS3Punctuation(ch)) {
+                                        if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
+                                                levelNext++;
+                                        } else {
+                                                expectingPunctuation = 0;
+                                        }
+                                } else if (!IsAnIdentifier(style)) {
+                                        levelNext++;
+                                }
+                        } else if (expectingIdentifier && !expectingPunctuation) {
+                                if (!IsAnIdentifier(style)) {
+                                        levelNext++;
+                                } else {
+                                        expectingPunctuation = T3_EXPECTINGPUNCTUATION;
+                                }
+                        } else if (!expectingIdentifier && expectingPunctuation) {
+                                if (!IsATADS3Punctuation(ch)) {
+                                        levelNext++;
+                                } else {
+                                        if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
+                                                levelNext++;
+                                        } else {
+                                                expectingIdentifier = T3_EXPECTINGIDENTIFIER;
+                                                expectingPunctuation = 0;
+                                        }
+                                }
+                        } else if (!expectingIdentifier && !expectingPunctuation) {
+                                if (IsAnIdentifier(style)) {
+                                        seenStart = T3_SEENSTART;
+                                        expectingIdentifier = T3_EXPECTINGIDENTIFIER;
+                                        expectingPunctuation = T3_EXPECTINGPUNCTUATION;
+                                }
+                        }
+
+                        if (levelNext != SC_FOLDLEVELBASE && style != SCE_T3_BLOCK_COMMENT) {
+                                expectingIdentifier = 0;
+                                expectingPunctuation = 0;
+                        }
+
+                } else if (levelNext == SC_FOLDLEVELBASE+1 && seenStart
+                                   && ch == ';' && IsAnOperator(style)) {
+                        levelNext--;
+                        seenStart = 0;
+                } else if (style == SCE_T3_BLOCK_COMMENT) {
+                        if (stylePrev != SCE_T3_BLOCK_COMMENT) {
+                                levelNext++;
+                        } else if (styleNext != SCE_T3_BLOCK_COMMENT && !atEOL) {
+                                // Comments don't end at end of line and the next character may be unstyled.
+                                levelNext--;
+                        }
+                } else if (ch == '\'' || ch == '"') {
+                        if (IsStringTransition(style, stylePrev)) {
+                                if (levelMinCurrent > levelNext) {
+                                        levelMinCurrent = levelNext;
+                                }
+                                levelNext++;
+                        } else if (IsStringTransition(style, styleNext)) {
+                                levelNext--;
+                        }
+                } else if (IsAnOperator(style)) {
+                        if (ch == '{' || ch == '[') {
+                                // Measure the minimum before a '{' to allow
+                                // folding on "} else {"
+                                if (levelMinCurrent > levelNext) {
+                                        levelMinCurrent = levelNext;
+                                }
+                                levelNext++;
+                        } else if (ch == '}' || ch == ']') {
+                                levelNext--;
+                        }
+                }
+
+                if (atEOL) {
+                        if (seenStart && levelNext == SC_FOLDLEVELBASE) {
+                                switch (peekAhead(i+1, endPos, styler)) {
+                                        case ' ':
+                                        case '{':
+                                                break;
+                                        case '*':
+                                                levelNext++;
+                                                break;
+                                        case 'a':
+                                                if (expectingPunctuation) {
+                                                        levelNext++;
+                                                }
+                                                break;
+                                        case ':':
+                                                if (expectingIdentifier) {
+                                                        levelNext++;
+                                                }
+                                                break;
+                                }
+                                if (levelNext != SC_FOLDLEVELBASE) {
+                                        expectingIdentifier = 0;
+                                        expectingPunctuation = 0;
+                                }
+                        }
+                        int lev = levelMinCurrent | (levelNext | expectingIdentifier
+                                | expectingPunctuation | seenStart) << 16;
+                        if (levelMinCurrent < levelNext)
+                                lev |= SC_FOLDLEVELHEADERFLAG;
+                        if (lev != styler.LevelAt(lineCurrent)) {
+                                styler.SetLevel(lineCurrent, lev);
+                        }
+                        lineCurrent++;
+                        levelCurrent = levelNext;
+                        levelMinCurrent = levelCurrent;
+                }
+        }
 }
 
 static const char * const tads3WordList[] = {
-	"TADS3 Keywords",
-	"User defined 1",
-	"User defined 2",
-	"User defined 3",
-	0
+        "TADS3 Keywords",
+        "User defined 1",
+        "User defined 2",
+        "User defined 3",
+        0
 };
 
 LexerModule lmTADS3(SCLEX_TADS3, ColouriseTADS3Doc, "tads3", FoldTADS3Doc, tads3WordList);

Modified: trunk/plugins/editor/scintilla/LexTCL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexTCL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexTCL.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // Extended to accept accented characters
 static inline bool IsAWordChar(int ch) {
 	return ch >= 0x80 ||

Modified: trunk/plugins/editor/scintilla/LexTeX.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexTeX.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexTeX.cxx	Sat Nov 15 17:50:33 2008
@@ -12,6 +12,10 @@
 
 // If you run into strange boundary cases, just tell me and I'll look into it.
 
+
+// TeX Folding code added by instanton (soft_share 126 com) with borrowed code from VisualTeX source by Alex Romanenko.
+// Version: June 22, 2007
+
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
@@ -27,6 +31,10 @@
 #include "SciLexer.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // val SCE_TEX_DEFAULT = 0
 // val SCE_TEX_SPECIAL = 1
 // val SCE_TEX_GROUP   = 2
@@ -169,9 +177,9 @@
 	styler.StartSegment(startPos) ;
 
 	bool processComment   = styler.GetPropertyInt("lexer.tex.comment.process",   0) == 1 ;
-    bool useKeywords      = styler.GetPropertyInt("lexer.tex.use.keywords",      1) == 1 ;
+	bool useKeywords      = styler.GetPropertyInt("lexer.tex.use.keywords",      1) == 1 ;
 	bool autoIf           = styler.GetPropertyInt("lexer.tex.auto.if",           1) == 1 ;
-    int  defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ;
+	int  defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ;
 
 	char key[100] ;
 	int  k ;
@@ -272,7 +280,202 @@
 }
 
 
-// Hooks into the system:
+static inline bool isNumber(int ch) {
+	return
+      (ch == '0') || (ch == '1') || (ch == '2') || 
+      (ch == '3') || (ch == '4') || (ch == '5') || 
+      (ch == '6') || (ch == '7') || (ch == '8') || (ch == '9');
+}
+
+static inline bool isWordChar(int ch) {
+	return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z'));
+}
+
+static int ParseTeXCommand(unsigned int pos, Accessor &styler, char *command)
+{
+  int length=0;
+  char ch=styler.SafeGetCharAt(pos+1);
+  
+  if(ch==',' || ch==':' || ch==';' || ch=='%'){
+      command[0]=ch;
+      command[1]=0;
+	  return 1;
+  }
+
+  // find end
+     while(isWordChar(ch) && !isNumber(ch) && ch!='_' && ch!='.' && length<100){
+          command[length]=ch;
+          length++;
+          ch=styler.SafeGetCharAt(pos+length+1);
+     }
+     
+  command[length]='\0';   
+  if(!length) return 0;
+  return length+1;
+}
+
+static int classifyFoldPointTeXPaired(const char* s) {
+	int lev=0; 
+	if (!(isdigit(s[0]) || (s[0] == '.'))){
+		if (strcmp(s, "begin")==0||strcmp(s,"FoldStart")==0||
+			strcmp(s,"abstract")==0||strcmp(s,"unprotect")==0||
+			strcmp(s,"title")==0||strncmp(s,"start",5)==0||strncmp(s,"Start",5)==0||
+			strcmp(s,"documentclass")==0||strncmp(s,"if",2)==0
+			)
+			lev=1;
+		if (strcmp(s, "end")==0||strcmp(s,"FoldStop")==0||
+			strcmp(s,"maketitle")==0||strcmp(s,"protect")==0||
+			strncmp(s,"stop",4)==0||strncmp(s,"Stop",4)==0||
+			strcmp(s,"fi")==0
+			) 
+		lev=-1;
+	}
+	return lev;
+}
+
+static int classifyFoldPointTeXUnpaired(const char* s) {
+	int lev=0; 
+	if (!(isdigit(s[0]) || (s[0] == '.'))){
+		if (strcmp(s,"part")==0||
+			strcmp(s,"chapter")==0||
+			strcmp(s,"section")==0||
+			strcmp(s,"subsection")==0||
+			strcmp(s,"subsubsection")==0||
+			strcmp(s,"CJKfamily")==0||
+			strcmp(s,"appendix")==0||
+			strcmp(s,"Topic")==0||strcmp(s,"topic")==0||
+			strcmp(s,"subject")==0||strcmp(s,"subsubject")==0||
+			strcmp(s,"def")==0||strcmp(s,"gdef")==0||strcmp(s,"edef")==0||
+			strcmp(s,"xdef")==0||strcmp(s,"framed")==0||
+			strcmp(s,"frame")==0||
+			strcmp(s,"foilhead")==0||strcmp(s,"overlays")==0||strcmp(s,"slide")==0
+			){
+			    lev=1;
+			}
+	}
+	return lev;
+}
+
+static bool IsTeXCommentLine(int line, Accessor &styler) {
+	int pos = styler.LineStart(line);
+	int eol_pos = styler.LineStart(line + 1) - 1;
+	
+	int startpos = pos;
+
+	while (startpos<eol_pos){
+		char ch = styler[startpos];
+		if (ch!='%' && ch!=' ') return false;
+		else if (ch=='%') return true;
+		startpos++;
+	}		
+
+	return false;
+}
+
+// FoldTeXDoc: borrowed from VisualTeX with modifications
+
+static void FoldTexDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) 
+{
+	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];
+	char buffer[100]="";
+	
+	for (unsigned int i=startPos; i < endPos; i++) {
+		char ch=chNext;
+		chNext=styler.SafeGetCharAt(i+1);
+		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+        if(ch=='\\') {
+            ParseTeXCommand(i, styler, buffer);
+			levelCurrent += classifyFoldPointTeXPaired(buffer)+classifyFoldPointTeXUnpaired(buffer);
+		}
+
+		if (levelCurrent > SC_FOLDLEVELBASE && ((ch == '\r' || ch=='\n') && (chNext == '\\'))) {
+            ParseTeXCommand(i+1, styler, buffer);
+			levelCurrent -= classifyFoldPointTeXUnpaired(buffer);
+		}
+
+	char chNext2;
+	char chNext3;
+	char chNext4;
+	char chNext5;
+	chNext2=styler.SafeGetCharAt(i+2);
+	chNext3=styler.SafeGetCharAt(i+3);
+	chNext4=styler.SafeGetCharAt(i+4);
+	chNext5=styler.SafeGetCharAt(i+5);
+
+	bool atEOfold = (ch == '%') && 
+			(chNext == '%') && (chNext2=='}') && 
+				(chNext3=='}')&& (chNext4=='-')&& (chNext5=='-');
+
+	bool atBOfold = (ch == '%') && 
+			(chNext == '%') && (chNext2=='-') && 
+				(chNext3=='-')&& (chNext4=='{')&& (chNext5=='{');
+
+	if(atBOfold){
+		levelCurrent+=1;
+	}
+
+	if(atEOfold){
+		levelCurrent-=1;
+	}
+	
+	if(ch=='\\' && chNext=='['){
+		levelCurrent+=1;
+	}
+	
+	if(ch=='\\' && chNext==']'){
+		levelCurrent-=1;
+	}
+
+	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+
+	if (foldComment && atEOL && IsTeXCommentLine(lineCurrent, styler))
+        {
+            if (lineCurrent==0 && IsTeXCommentLine(lineCurrent + 1, styler)
+				)
+                levelCurrent++;
+            else if (lineCurrent!=0 && !IsTeXCommentLine(lineCurrent - 1, styler)
+               && IsTeXCommentLine(lineCurrent + 1, styler)
+				)
+                levelCurrent++;
+            else if (lineCurrent!=0 && IsTeXCommentLine(lineCurrent - 1, styler) &&
+                     !IsTeXCommentLine(lineCurrent+1, styler))
+                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 texWordListDesc[] = {
     "TeX, eTeX, pdfTeX, Omega",
@@ -285,4 +488,4 @@
 	0,
 } ;
 
-LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", 0, texWordListDesc);
+LexerModule lmTeX(SCLEX_TEX,   ColouriseTeXDoc, "tex", FoldTexDoc, texWordListDesc);

Modified: trunk/plugins/editor/scintilla/LexVB.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexVB.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexVB.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // Internal state, highlighted as number
 #define SCE_B_FILENUMBER SCE_B_DEFAULT+100
 

Modified: trunk/plugins/editor/scintilla/LexVHDL.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexVHDL.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexVHDL.cxx	Sat Nov 15 17:50:33 2008
@@ -25,6 +25,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void ColouriseVHDLDoc(
   unsigned int startPos,
   int length,

Modified: trunk/plugins/editor/scintilla/LexVerilog.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexVerilog.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexVerilog.cxx	Sat Nov 15 17:50:33 2008
@@ -21,6 +21,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static inline bool IsAWordChar(const int ch) {
 	return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
 }
@@ -93,7 +97,7 @@
 				sc.ForwardSetState(SCE_V_DEFAULT);
 			}
 		} else if (sc.state == SCE_V_COMMENTLINE || sc.state == SCE_V_COMMENTLINEBANG) {
-			if (sc.atLineEnd) {
+			if (sc.atLineStart) {
 				sc.SetState(SCE_V_DEFAULT);
 			}
                 } else if (sc.state == SCE_V_STRING) {
@@ -160,11 +164,11 @@
         //      Generally used methodology in verilog code is
         //      one module per file, so folding at module definition is useless.
         // fold_at_brace/parenthese -
-        //      Folding of long port lists can be convenient. 
+        //      Folding of long port lists can be convenient.
 	bool foldAtModule = styler.GetPropertyInt("fold.verilog.flags", 0) != 0;
 	bool foldAtBrace  = 1;
 	bool foldAtParenthese  = 1;
-                                
+
 	unsigned int endPos = startPos + length;
 	int visibleChars = 0;
 	int lineCurrent = styler.GetLine(startPos);
@@ -234,22 +238,24 @@
 		}
                 if (style == SCE_V_WORD && stylePrev != SCE_V_WORD) {
                         unsigned int j = i;
-                        if (styler.Match(j, "case") || 
-                            styler.Match(j, "casex") || 
-                            styler.Match(j, "casez") || 
-                            styler.Match(j, "function") || 
-                            styler.Match(j, "fork") || 
-                            styler.Match(j, "table") || 
-                            styler.Match(j, "task") || 
-                            styler.Match(j, "specify") || 
-                            styler.Match(j, "primitive") || 
-                            styler.Match(j, "module") && foldAtModule || 
+                        if (styler.Match(j, "case") ||
+                            styler.Match(j, "casex") ||
+                            styler.Match(j, "casez") ||
+                            styler.Match(j, "function") ||
+                            styler.Match(j, "fork") ||
+                            styler.Match(j, "table") ||
+                            styler.Match(j, "task") ||
+                            styler.Match(j, "generate") ||
+                            styler.Match(j, "specify") ||
+                            styler.Match(j, "primitive") ||
+                            styler.Match(j, "module") && foldAtModule ||
                             styler.Match(j, "begin")) {
                                 levelNext++;
-                        } else if (styler.Match(j, "endcase") || 
+                        } else if (styler.Match(j, "endcase") ||
                                    styler.Match(j, "endfunction") ||
                                    styler.Match(j, "join") ||
                                    styler.Match(j, "endtask") ||
+                                   styler.Match(j, "endgenerate") ||
                                    styler.Match(j, "endtable") ||
                                    styler.Match(j, "endspecify") ||
                                    styler.Match(j, "endprimitive") ||

Modified: trunk/plugins/editor/scintilla/LexYAML.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LexYAML.cxx	(original)
+++ trunk/plugins/editor/scintilla/LexYAML.cxx	Sat Nov 15 17:50:33 2008
@@ -20,6 +20,10 @@
 #include "Scintilla.h"
 #include "SciLexer.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static const char * const yamlWordListDesc[] = {
 	"Keywords",
 	0
@@ -33,12 +37,12 @@
 static unsigned int SpaceCount(char* lineBuffer) {
 	if (lineBuffer == NULL)
 		return 0;
-	
+
 	char* headBuffer = lineBuffer;
-	
+
 	while (*headBuffer == ' ')
 		headBuffer++;
-	
+
 	return headBuffer - lineBuffer;
 }
 
@@ -58,14 +62,14 @@
 	unsigned int endPos,
 	WordList &keywords,
 	Accessor &styler) {
-	    
+
 	unsigned int i = 0;
 	bool bInQuotes = false;
 	unsigned int indentAmount = SpaceCount(lineBuffer);
-		
+
 	if (currentLine > 0) {
 		int parentLineState = styler.GetLineState(currentLine - 1);
-	
+
 		if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) {
 			unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK);
 			if (indentAmount > parentIndentAmount) {
@@ -98,7 +102,8 @@
 		if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') {
 			bInQuotes = !bInQuotes;
 		} else if (lineBuffer[i] == ':' && !bInQuotes) {
-			styler.ColourTo(startLine + i, SCE_YAML_IDENTIFIER);
+			styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER);
+			styler.ColourTo(startLine + i, SCE_YAML_OPERATOR);
 			// Non-folding scalar
 			i++;
 			while ((i < lengthLine) && isspacechar(lineBuffer[i]))
@@ -126,6 +131,10 @@
 					styler.ColourTo(endPos, SCE_YAML_ERROR);
 					return;
 				}
+			} else if (lineBuffer[i] == '#') {
+				styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT);
+				styler.ColourTo(endPos, SCE_YAML_COMMENT);
+				return;
 			}
 			styler.SetLineState(currentLine, YAML_STATE_VALUE);
 			if (lineBuffer[i] == '&' || lineBuffer[i] == '*') {
@@ -138,7 +147,7 @@
 			} else {
 				unsigned int i2 = i;
 				while ((i < lengthLine) && lineBuffer[i]) {
-					if (!isdigit(lineBuffer[i]) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
+					if (!(isascii(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
 						styler.ColourTo(endPos, SCE_YAML_DEFAULT);
 						return;
 					}
@@ -165,7 +174,7 @@
 	unsigned int endPos = startPos + length;
 	unsigned int maxPos = styler.Length();
 	unsigned int lineCurrent = styler.GetLine(startPos);
-	
+
 	for (unsigned int i = startPos; i < maxPos && i < endPos; i++) {
 		lineBuffer[linePos++] = styler[i];
 		if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {

Modified: trunk/plugins/editor/scintilla/LineMarker.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/LineMarker.cxx	(original)
+++ trunk/plugins/editor/scintilla/LineMarker.cxx	Sat Nov 15 17:50:33 2008
@@ -13,6 +13,10 @@
 #include "XPM.h"
 #include "LineMarker.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
 	pal.WantFind(fore, want);
 	pal.WantFind(back, want);
@@ -295,6 +299,10 @@
 		};
 		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
 				fore.allocated, back.allocated);
+	} else if (markType == SC_MARK_LEFTRECT) {
+		PRectangle rcLeft = rcWhole;
+		rcLeft.right = rcLeft.left + 4;
+		surface->FillRectangle(rcLeft, back.allocated);
 	} else { // SC_MARK_FULLRECT
 		surface->FillRectangle(rcWhole, back.allocated);
 	}

Modified: trunk/plugins/editor/scintilla/LineMarker.h
==============================================================================
--- trunk/plugins/editor/scintilla/LineMarker.h	(original)
+++ trunk/plugins/editor/scintilla/LineMarker.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef LINEMARKER_H
 #define LINEMARKER_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class LineMarker {
@@ -51,4 +55,8 @@
 	void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/Makefile.am
==============================================================================
--- trunk/plugins/editor/scintilla/Makefile.am	(original)
+++ trunk/plugins/editor/scintilla/Makefile.am	Sat Nov 15 17:50:33 2008
@@ -58,6 +58,15 @@
 	StyleContext.h\
 	XPM.h\
 	XPM.cxx\
+	Decoration.h \
+	Decoration.cxx \
+	PositionCache.h \
+	PositionCache.cxx \
+	RunStyles.cxx \
+	RunStyles.h \
+	SplitVector.h \
+	Partitioning.h \
+	CharacterSet.h \
 	scintilla-marshal.h\
 	scintilla-marshal.c\
 	$(LEXER_SRCS)

Added: trunk/plugins/editor/scintilla/Partitioning.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/Partitioning.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,184 @@
+// Scintilla source code edit control
+/** @file Partitioning.h
+ ** Data structure used to partition an interval. Used for holding line start/end positions.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef PARTITIONING_H
+#define PARTITIONING_H
+
+/// A split vector of integers with a method for adding a value to all elements 
+/// in a range.
+/// Used by the Partitioning class.
+
+class SplitVectorWithRangeAdd : public SplitVector<int> {
+public:
+	SplitVectorWithRangeAdd(int growSize_) {
+		SetGrowSize(growSize_);
+		ReAllocate(growSize_);
+	}
+	~SplitVectorWithRangeAdd() {
+	}
+	void RangeAddDelta(int start, int end, int delta) {
+		// end is 1 past end, so end-start is number of elements to change
+		int i = 0;
+		int rangeLength = end - start;
+		int range1Length = rangeLength;
+		int part1Left = part1Length - start;
+		if (range1Length > part1Left)
+			range1Length = part1Left;
+		while (i < range1Length) {
+			body[start++] += delta;
+			i++;
+		}
+		start += gapLength;
+		while (i < rangeLength) {
+			body[start++] += delta;
+			i++;
+		}
+	}
+};
+
+/// Divide an interval into multiple partitions.
+/// Useful for breaking a document down into sections such as lines.
+
+class Partitioning {
+private:
+	// To avoid calculating all the partition positions whenever any text is inserted
+	// there may be a step somewhere in the list.
+	int stepPartition;
+	int stepLength;
+	SplitVectorWithRangeAdd *body;
+
+	// Move step forward
+	void ApplyStep(int partitionUpTo) {
+		if (stepLength != 0) {
+			body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength);
+		}
+		stepPartition = partitionUpTo;
+		if (stepPartition >= body->Length()-1) {
+			stepPartition = body->Length()-1;
+			stepLength = 0;
+		}
+	}
+
+	// Move step backward
+	void BackStep(int partitionDownTo) {
+		if (stepLength != 0) {
+			body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength);
+		}
+		stepPartition = partitionDownTo;
+	}
+
+	void Allocate(int growSize) {
+		body = new SplitVectorWithRangeAdd(growSize);
+		stepPartition = 0;
+		stepLength = 0;
+		body->Insert(0, 0);	// This value stays 0 for ever
+		body->Insert(1, 0);	// This is the end of the first partition and will be the start of the second
+	}
+
+public:
+	Partitioning(int growSize) {
+		Allocate(growSize);
+	}
+
+	~Partitioning() {
+		delete body;
+		body = 0;
+	}
+
+	int Partitions() const {
+		return body->Length()-1;
+	}
+
+	void InsertPartition(int partition, int pos) {
+		if (stepPartition < partition) {
+			ApplyStep(partition);
+		}
+		body->Insert(partition, pos);
+		stepPartition++;
+	}
+
+	void SetPartitionStartPosition(int partition, int pos) {
+		ApplyStep(partition+1);
+		if ((partition < 0) || (partition > body->Length())) {
+			return;
+		}
+		body->SetValueAt(partition, pos);
+	}
+
+	void InsertText(int partitionInsert, int delta) {
+		// Point all the partitions after the insertion point further along in the buffer
+		if (stepLength != 0) {
+			if (partitionInsert >= stepPartition) {
+				// Fill in up to the new insertion point
+				ApplyStep(partitionInsert);
+				stepLength += delta;
+			} else if (partitionInsert >= (stepPartition - body->Length() / 10)) {
+				// Close to step but before so move step back
+				BackStep(partitionInsert);
+				stepLength += delta;
+			} else {
+				ApplyStep(body->Length()-1);
+				stepPartition = partitionInsert;
+				stepLength = delta;
+			}
+		} else {
+			stepPartition = partitionInsert;
+			stepLength = delta;
+		}
+	}
+
+	void RemovePartition(int partition) {
+		if (partition > stepPartition) {
+			ApplyStep(partition);
+			stepPartition--;
+		} else {
+			stepPartition--;
+		}
+		body->Delete(partition);
+	}
+
+	int PositionFromPartition(int partition) const {
+		PLATFORM_ASSERT(partition >= 0);
+		PLATFORM_ASSERT(partition < body->Length());
+		if ((partition < 0) || (partition >= body->Length())) {
+			return 0;
+		}
+		int pos = body->ValueAt(partition);
+		if (partition > stepPartition)
+			pos += stepLength;
+		return pos;
+	}
+
+	int PartitionFromPosition(int pos) {
+		if (body->Length() <= 1)
+			return 0;
+		if (pos >= (PositionFromPartition(body->Length()-1)))
+			return body->Length() - 1 - 1;
+		int lower = 0;
+		int upper = body->Length()-1;
+		do {
+			int middle = (upper + lower + 1) / 2; 	// Round high
+			int posMiddle = body->ValueAt(middle);
+			if (middle > stepPartition)
+				posMiddle += stepLength;
+			if (pos < posMiddle) {
+				upper = middle - 1;
+			} else {
+				lower = middle;
+			}
+		} while (lower < upper);
+		return lower;
+	}
+
+	void DeleteAll() {
+		int growSize = body->GetGrowSize();
+		delete body;
+		Allocate(growSize);
+	}
+};
+
+#endif

Modified: trunk/plugins/editor/scintilla/PlatGTK.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/PlatGTK.cxx	(original)
+++ trunk/plugins/editor/scintilla/PlatGTK.cxx	Sat Nov 15 17:50:33 2008
@@ -31,10 +31,6 @@
    with gdk_string_extents. */
 #define FAST_WAY
 
-#ifdef G_OS_WIN32
-#define snprintf _snprintf
-#endif
-
 #if GTK_MAJOR_VERSION >= 2
 #define USE_PANGO 1
 #include "Converter.h"
@@ -572,7 +568,7 @@
 			                        faceName, sizeof(faceName),
 			                        charset, sizeof(charset));
 
-			snprintf(fontspec,
+			g_snprintf(fontspec,
 			         sizeof(fontspec) - 1,
 			         spec,
 			         foundary, faceName,
@@ -588,7 +584,7 @@
 				strncat(fontset, fontspec, remaining - 1);
 				remaining -= strlen(fontset);
 
-				snprintf(fontspec,
+				g_snprintf(fontspec,
 				         sizeof(fontspec) - 1,
 				         ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s",
 				         foundary, faceName,
@@ -623,7 +619,7 @@
 	                        faceName, sizeof(faceName),
 	                        charset, sizeof(charset));
 
-	snprintf(fontspec,
+	g_snprintf(fontspec,
 	         sizeof(fontspec) - 1,
 	         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
 	         foundary, faceName,
@@ -634,7 +630,7 @@
 	newid = LoadFontOrSet(fontspec, characterSet);
 	if (!newid) {
 		// some fonts have oblique, not italic
-		snprintf(fontspec,
+		g_snprintf(fontspec,
 		         sizeof(fontspec) - 1,
 		         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
 		         foundary, faceName,
@@ -645,7 +641,7 @@
 		newid = LoadFontOrSet(fontspec, characterSet);
 	}
 	if (!newid) {
-		snprintf(fontspec,
+		g_snprintf(fontspec,
 		         sizeof(fontspec) - 1,
 		         "-*-*-*-*-*-*-*-%0d-*-*-*-*-%s",
 		         size * 10,
@@ -745,7 +741,7 @@
 	case SC_CHARSET_ANSI:
 		return "";
 	case SC_CHARSET_DEFAULT:
-		return "LATIN1";
+		return "ISO-8859-1";
 	case SC_CHARSET_BALTIC:
 		return "ISO-8859-13";
 	case SC_CHARSET_CHINESEBIG5:
@@ -1053,7 +1049,7 @@
 #else
 void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
 		ColourAllocated outline, int alphaOutline, int flags) {
-	if (gc && drawable) {
+	if (gc && drawable && rc.Width() > 0) {
 		int width = rc.Width();
 		int height = rc.Height();
 		// Ensure not distorted too much by corners when small
@@ -1075,22 +1071,22 @@
 		guint32 valOutline = *(reinterpret_cast<guint32 *>(pixVal));
 		guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha));
 		int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4;
-		for (int y=0; y<height; y++) {
-			for (int x=0; x<width; x++) {
-				if ((x==0) || (x==width-1) || (y == 0) || (y == height-1)) {
-					pixels[y*stride+x] = valOutline;
+		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[y*stride+x] = valFill;
+					pixels[yr*stride+xr] = valFill;
 				}
 			}
 		}
 		for (int c=0;c<cornerSize; c++) {
-			for (int x=0;x<c+1; x++) {
-				AllFour(pixels, stride, width, height, x, c-x, valEmpty);
+			for (int xr=0;xr<c+1; xr++) {
+				AllFour(pixels, stride, width, height, xr, c-xr, valEmpty);
 			}
 		}
-		for (int x=1;x<cornerSize; x++) {
-			AllFour(pixels, stride, width, height, x, cornerSize-x, valOutline);
+		for (int xr=1;xr<cornerSize; xr++) {
+			AllFour(pixels, stride, width, height, xr, cornerSize-xr, valOutline);
 		}
 
 		// Draw with alpha
@@ -1250,7 +1246,7 @@
                                  ColourAllocated fore) {
 	PenColour(fore);
 	if (gc && drawable) {
-		int x = rc.left;
+		int xText = rc.left;
 #ifdef USE_PANGO
 		if (PFont(font_)->pfd) {
 			char *utfForm = 0;
@@ -1275,7 +1271,7 @@
 			}
 			pango_layout_set_font_description(layout, PFont(font_)->pfd);
 			PangoLayoutLine *pll = pango_layout_get_line(layout,0);
-			gdk_draw_layout_line(drawable, gc, x, ybase, pll);
+			gdk_draw_layout_line(drawable, gc, xText, ybase, pll);
 			if (useGFree) {
 				g_free(utfForm);
 			} else {
@@ -1293,7 +1289,7 @@
 				len = maxLengthTextRun-1;
 			int wclen;
 			if (et == UTF8) {
-				wclen = UCS2FromUTF8(s, len,
+				wclen = UTF16FromUTF8(s, len,
 					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
 			} else {	// dbcs, so convert using current locale
 				char sMeasure[maxLengthTextRun];
@@ -1306,13 +1302,13 @@
 				draw8bit = false;
 				wctext[wclen] = L'\0';
 				GdkWChar *wcp = wctext;
-				while ((wclen > 0) && (x < maxCoordinate)) {
+				while ((wclen > 0) && (xText < maxCoordinate)) {
 					int lenDraw = Platform::Minimum(wclen, segmentLength);
 					gdk_draw_text_wc(drawable, PFont(font_)->pfont, gc,
-							 x, ybase, wcp, lenDraw);
+							 xText, ybase, wcp, lenDraw);
 					wclen -= lenDraw;
 					if (wclen > 0) {	// Avoid next calculation if possible as may be expensive
-						x += gdk_text_width_wc(PFont(font_)->pfont,
+						xText += gdk_text_width_wc(PFont(font_)->pfont,
 								       wcp, lenDraw);
 					}
 					wcp += lenDraw;
@@ -1320,13 +1316,13 @@
 			}
 		}
 		if (draw8bit) {
-			while ((len > 0) && (x < maxCoordinate)) {
+			while ((len > 0) && (xText < maxCoordinate)) {
 				int lenDraw = Platform::Minimum(len, segmentLength);
 				gdk_draw_text(drawable, PFont(font_)->pfont, gc,
-				              x, ybase, s, lenDraw);
+				              xText, ybase, s, lenDraw);
 				len -= lenDraw;
 				if (len > 0) {	// Avoid next calculation if possible as may be expensive
-					x += gdk_text_width(PFont(font_)->pfont, s, lenDraw);
+					xText += gdk_text_width(PFont(font_)->pfont, s, lenDraw);
 				}
 				s += lenDraw;
 			}
@@ -1383,8 +1379,15 @@
 					pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
 					int position = PANGO_PIXELS(pos.x);
 					int curIndex = pango_layout_iter_get_index(iter);
+					int places = curIndex - i;
+					int distance = position - positions[i-1];
 					while (i < curIndex) {
-						positions[i++] = position;
+						// Evenly distribute space among bytes of this cluster.
+						// Would be better to find number of characters and then
+						// divide evenly between characters with each byte of a character
+						// being at the same position.
+						positions[i] = position - (curIndex - 1 - i) * distance / places;
+						i++;
 					}
 				}
 				while (i < lenPositions)
@@ -1436,12 +1439,25 @@
 						utfForm = UTF8FromLatin1(s, len);
 					}
 					pango_layout_set_text(layout, utfForm, len);
-					int i = 0;
 					PangoLayoutIter *iter = pango_layout_get_iter(layout);
 					pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+					int i = 0;
+					int positionStart = 0;
+					int clusterStart = 0;
+					// Each Latin1 input character may take 1 or 2 bytes in UTF-8
+					// and groups of up to 3 may be represented as ligatures.
 					while (pango_layout_iter_next_cluster(iter)) {
 						pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-						positions[i++] = PANGO_PIXELS(pos.x);
+						int position = PANGO_PIXELS(pos.x);
+						int distance = position - positionStart;
+						int clusterEnd = pango_layout_iter_get_index(iter);
+						int ligatureLength = g_utf8_strlen(utfForm + clusterStart, clusterEnd - clusterStart);
+						PLATFORM_ASSERT(ligatureLength > 0 && ligatureLength <= 3);
+						for (int charInLig=0; charInLig<ligatureLength; charInLig++) {
+							positions[i++] = position - (ligatureLength - 1 - charInLig) * distance / ligatureLength;
+						}
+						positionStart = position;
+						clusterStart = clusterEnd;
 					}
 					while (i < lenPositions)
 						positions[i++] = PANGO_PIXELS(pos.x + pos.width);
@@ -1468,7 +1484,7 @@
 				len = maxLengthTextRun-1;
 			int wclen;
 			if (et == UTF8) {
-				wclen = UCS2FromUTF8(s, len,
+				wclen = UTF16FromUTF8(s, len,
 					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
 			} else {	// dbcsMode, so convert using current locale
 				char sDraw[maxLengthTextRun];
@@ -1554,7 +1570,7 @@
 #endif
 		if (et == UTF8) {
 			GdkWChar wctext[maxLengthTextRun];
-			size_t wclen = UCS2FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)),
+			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);
@@ -1854,6 +1870,34 @@
 	gtk_window_set_title(GTK_WINDOW(id), s);
 }
 
+/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
+   gdk window coordinates */
+PRectangle Window::GetMonitorRect(Point pt) {
+	gint x_offset, y_offset;
+	pt = pt;
+
+	gdk_window_get_origin(PWidget(id)->window, &x_offset, &y_offset);
+
+// gtk 2.2+
+#if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2)
+	{
+		GdkScreen* screen;
+		gint monitor_num;
+		GdkRectangle rect;
+
+		screen = gtk_widget_get_screen(PWidget(id));
+		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
+	return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(),
+	                  (-y_offset) + gdk_screen_height());
+#endif
+}
+
 struct ListImage {
 	const char *xpm_data;
 #if GTK_MAJOR_VERSION < 2
@@ -1941,7 +1985,7 @@
 		doubleClickAction = action;
 		doubleClickActionData = data;
 	}
-	virtual void SetList(const char* list, char separator, char typesep);
+	virtual void SetList(const char *listText, char separator, char typesep);
 };
 
 ListBox *ListBox::Allocate() {
@@ -2283,7 +2327,7 @@
 		return;
 	}
 
-	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n);
+	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
 	if (valid) {
 		gtk_tree_selection_select_iter(selection, &iter);
 
@@ -2356,7 +2400,7 @@
 	GtkTreeIter iter;
 	GtkTreeModel *model =
 		gtk_tree_view_get_model(GTK_TREE_VIEW(list));
-	bool valid = gtk_tree_model_get_iter_first(model, &iter);
+	bool valid = gtk_tree_model_get_iter_first(model, &iter) != FALSE;
 	int i = 0;
 	while(valid) {
 		gchar *s;
@@ -2364,7 +2408,7 @@
 		if (s && (0 == strncmp(prefix, s, strlen(prefix)))) {
 			return i;
 		}
-		valid = gtk_tree_model_iter_next(model, &iter);
+		valid = gtk_tree_model_iter_next(model, &iter) != FALSE;
 		i++;
 	}
 #endif
@@ -2388,7 +2432,7 @@
 #else
 	GtkTreeIter iter;
 	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
-	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n);
+	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
 	if (valid) {
 		gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);
 	}
@@ -2446,12 +2490,12 @@
 	xset.Clear();
 }
 
-void ListBoxX::SetList(const char* list, char separator, char typesep) {
+void ListBoxX::SetList(const char *listText, char separator, char typesep) {
 	Clear();
-	int count = strlen(list) + 1;
+	int count = strlen(listText) + 1;
 	char *words = new char[count];
 	if (words) {
-		memcpy(words, list, count);
+		memcpy(words, listText, count);
 		char *startword = words;
 		char *numword = NULL;
 		int i = 0;
@@ -2609,7 +2653,7 @@
 }
 
 void Platform::DebugDisplay(const char *s) {
-	printf("%s", s);
+	fprintf(stderr, "%s", s);
 }
 
 bool Platform::IsKeyDown(int) {

Added: trunk/plugins/editor/scintilla/PositionCache.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/PositionCache.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,635 @@
+// Scintilla source code edit control
+/** @file PositionCache.cxx
+ ** Classes for caching layout information.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+#include "ContractionState.h"
+#include "CellBuffer.h"
+#include "KeyMap.h"
+#include "Indicator.h"
+#include "XPM.h"
+#include "LineMarker.h"
+#include "Style.h"
+#include "ViewStyle.h"
+#include "CharClassify.h"
+#include "Decoration.h"
+#include "Document.h"
+#include "PositionCache.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsControlCharacter(int ch) {
+	// iscntrl returns true for lots of chars > 127 which are displayable
+	return ch >= 0 && ch < ' ';
+}
+
+LineLayout::LineLayout(int maxLineLength_) :
+	lineStarts(0),
+	lenLineStarts(0),
+	lineNumber(-1),
+	inCache(false),
+	maxLineLength(-1),
+	numCharsInLine(0),
+	validity(llInvalid),
+	xHighlightGuide(0),
+	highlightColumn(0),
+	selStart(0),
+	selEnd(0),
+	containsCaret(false),
+	edgeColumn(0),
+	chars(0),
+	styles(0),
+	styleBitsSet(0),
+	indicators(0),
+	positions(0),
+	hsStart(0),
+	hsEnd(0),
+	widthLine(wrapWidthInfinite),
+	lines(1) {
+	Resize(maxLineLength_);
+}
+
+LineLayout::~LineLayout() {
+	Free();
+}
+
+void LineLayout::Resize(int maxLineLength_) {
+	if (maxLineLength_ > maxLineLength) {
+		Free();
+		chars = new char[maxLineLength_ + 1];
+		styles = new unsigned char[maxLineLength_ + 1];
+		indicators = new char[maxLineLength_ + 1];
+		// Extra position allocated as sometimes the Windows
+		// GetTextExtentExPoint API writes an extra element.
+		positions = new int[maxLineLength_ + 1 + 1];
+		maxLineLength = maxLineLength_;
+	}
+}
+
+void LineLayout::Free() {
+	delete []chars;
+	chars = 0;
+	delete []styles;
+	styles = 0;
+	delete []indicators;
+	indicators = 0;
+	delete []positions;
+	positions = 0;
+	delete []lineStarts;
+	lineStarts = 0;
+}
+
+void LineLayout::Invalidate(validLevel validity_) {
+	if (validity > validity_)
+		validity = validity_;
+}
+
+int LineLayout::LineStart(int line) const {
+	if (line <= 0) {
+		return 0;
+	} else if ((line >= lines) || !lineStarts) {
+		return numCharsInLine;
+	} else {
+		return lineStarts[line];
+	}
+}
+
+int LineLayout::LineLastVisible(int line) const {
+	if (line < 0) {
+		return 0;
+	} else if ((line >= lines-1) || !lineStarts) {
+		int startLine = LineStart(line);
+		int endLine = numCharsInLine;
+		while ((endLine > startLine) && IsEOLChar(chars[endLine-1])) {
+			endLine--;
+		}
+		return endLine;
+	} else {
+		return lineStarts[line+1];
+	}
+}
+
+bool LineLayout::InLine(int offset, int line) const {
+	return ((offset >= LineStart(line)) && (offset < LineStart(line + 1)) ||
+		((offset == numCharsInLine) && (line == (lines-1))));
+}
+
+void LineLayout::SetLineStart(int line, int start) {
+	if ((line >= lenLineStarts) && (line != 0)) {
+		int newMaxLines = line + 20;
+		int *newLineStarts = new int[newMaxLines];
+		if (!newLineStarts)
+			return;
+		for (int i = 0; i < newMaxLines; i++) {
+			if (i < lenLineStarts)
+				newLineStarts[i] = lineStarts[i];
+			else
+				newLineStarts[i] = 0;
+		}
+		delete []lineStarts;
+		lineStarts = newLineStarts;
+		lenLineStarts = newMaxLines;
+	}
+	lineStarts[line] = start;
+}
+
+void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
+                                    char bracesMatchStyle, int xHighlight) {
+	if (rangeLine.ContainsCharacter(braces[0])) {
+		int braceOffset = braces[0] - rangeLine.start;
+		if (braceOffset < numCharsInLine) {
+			bracePreviousStyles[0] = styles[braceOffset];
+			styles[braceOffset] = bracesMatchStyle;
+		}
+	}
+	if (rangeLine.ContainsCharacter(braces[1])) {
+		int braceOffset = braces[1] - rangeLine.start;
+		if (braceOffset < numCharsInLine) {
+			bracePreviousStyles[1] = styles[braceOffset];
+			styles[braceOffset] = bracesMatchStyle;
+		}
+	}
+	if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
+	        (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
+		xHighlightGuide = xHighlight;
+	}
+}
+
+void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
+	if (rangeLine.ContainsCharacter(braces[0])) {
+		int braceOffset = braces[0] - rangeLine.start;
+		if (braceOffset < numCharsInLine) {
+			styles[braceOffset] = bracePreviousStyles[0];
+		}
+	}
+	if (rangeLine.ContainsCharacter(braces[1])) {
+		int braceOffset = braces[1] - rangeLine.start;
+		if (braceOffset < numCharsInLine) {
+			styles[braceOffset] = bracePreviousStyles[1];
+		}
+	}
+	xHighlightGuide = 0;
+}
+
+int LineLayout::FindBefore(int x, int lower, int upper) const {
+	do {
+		int middle = (upper + lower + 1) / 2; 	// Round high
+		int posMiddle = positions[middle];
+		if (x < posMiddle) {
+			upper = middle - 1;
+		} else {
+			lower = middle;
+		}
+	} while (lower < upper);
+	return lower;
+}
+
+LineLayoutCache::LineLayoutCache() :
+	level(0), length(0), size(0), cache(0),
+	allInvalidated(false), styleClock(-1), useCount(0) {
+	Allocate(0);
+}
+
+LineLayoutCache::~LineLayoutCache() {
+	Deallocate();
+}
+
+void LineLayoutCache::Allocate(int length_) {
+	PLATFORM_ASSERT(cache == NULL);
+	allInvalidated = false;
+	length = length_;
+	size = length;
+	if (size > 1) {
+		size = (size / 16 + 1) * 16;
+	}
+	if (size > 0) {
+		cache = new LineLayout * [size];
+	}
+	for (int i = 0; i < size; i++)
+		cache[i] = 0;
+}
+
+void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
+	PLATFORM_ASSERT(useCount == 0);
+	int lengthForLevel = 0;
+	if (level == llcCaret) {
+		lengthForLevel = 1;
+	} else if (level == llcPage) {
+		lengthForLevel = linesOnScreen + 1;
+	} else if (level == llcDocument) {
+		lengthForLevel = linesInDoc;
+	}
+	if (lengthForLevel > size) {
+		Deallocate();
+		Allocate(lengthForLevel);
+	} else {
+		if (lengthForLevel < length) {
+			for (int i = lengthForLevel; i < length; i++) {
+				delete cache[i];
+				cache[i] = 0;
+			}
+		}
+		length = lengthForLevel;
+	}
+	PLATFORM_ASSERT(length == lengthForLevel);
+	PLATFORM_ASSERT(cache != NULL || length == 0);
+}
+
+void LineLayoutCache::Deallocate() {
+	PLATFORM_ASSERT(useCount == 0);
+	for (int i = 0; i < length; i++)
+		delete cache[i];
+	delete []cache;
+	cache = 0;
+	length = 0;
+	size = 0;
+}
+
+void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
+	if (cache && !allInvalidated) {
+		for (int i = 0; i < length; i++) {
+			if (cache[i]) {
+				cache[i]->Invalidate(validity_);
+			}
+		}
+		if (validity_ == LineLayout::llInvalid) {
+			allInvalidated = true;
+		}
+	}
+}
+
+void LineLayoutCache::SetLevel(int level_) {
+	allInvalidated = false;
+	if ((level_ != -1) && (level != level_)) {
+		level = level_;
+		Deallocate();
+	}
+}
+
+LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+                                      int linesOnScreen, int linesInDoc) {
+	AllocateForLevel(linesOnScreen, linesInDoc);
+	if (styleClock != styleClock_) {
+		Invalidate(LineLayout::llCheckTextAndStyle);
+		styleClock = styleClock_;
+	}
+	allInvalidated = false;
+	int pos = -1;
+	LineLayout *ret = 0;
+	if (level == llcCaret) {
+		pos = 0;
+	} else if (level == llcPage) {
+		if (lineNumber == lineCaret) {
+			pos = 0;
+		} else if (length > 1) {
+			pos = 1 + (lineNumber % (length - 1));
+		}
+	} else if (level == llcDocument) {
+		pos = lineNumber;
+	}
+	if (pos >= 0) {
+		PLATFORM_ASSERT(useCount == 0);
+		if (cache && (pos < length)) {
+			if (cache[pos]) {
+				if ((cache[pos]->lineNumber != lineNumber) ||
+				        (cache[pos]->maxLineLength < maxChars)) {
+					delete cache[pos];
+					cache[pos] = 0;
+				}
+			}
+			if (!cache[pos]) {
+				cache[pos] = new LineLayout(maxChars);
+			}
+			if (cache[pos]) {
+				cache[pos]->lineNumber = lineNumber;
+				cache[pos]->inCache = true;
+				ret = cache[pos];
+				useCount++;
+			}
+		}
+	}
+
+	if (!ret) {
+		ret = new LineLayout(maxChars);
+		ret->lineNumber = lineNumber;
+	}
+
+	return ret;
+}
+
+void LineLayoutCache::Dispose(LineLayout *ll) {
+	allInvalidated = false;
+	if (ll) {
+		if (!ll->inCache) {
+			delete ll;
+		} else {
+			useCount--;
+		}
+	}
+}
+
+void BreakFinder::Insert(int val) {
+	// Expand if needed
+	if (saeLen >= saeSize) {
+		saeSize *= 2;
+		int *selAndEdgeNew = new int[saeSize];
+		for (unsigned int j = 0; j<saeLen; j++) {
+			selAndEdgeNew[j] = selAndEdge[j];
+		}
+		delete []selAndEdge;
+		selAndEdge = selAndEdgeNew;
+	}
+
+	if (val >= nextBreak) {
+		for (unsigned int j = 0; j<saeLen; j++) {
+			if (val == selAndEdge[j]) {
+				return;
+			} if (val < selAndEdge[j]) {
+				for (unsigned int k = saeLen; k>j; k--) {
+					selAndEdge[k] = selAndEdge[k-1];
+				}
+				saeLen++;
+				selAndEdge[j] = val;
+				return;
+			}
+		}
+		// Not less than any so append
+		selAndEdge[saeLen++] = val;
+	}
+}
+
+extern bool BadUTF(const char *s, int len, int &trailBytes);
+
+static int NextBadU(const char *s, int p, int len, int &trailBytes) {
+	while (p < len) {
+		p++;
+		if (BadUTF(s + p, len - p, trailBytes))
+			return p;
+	}
+	return -1;
+}
+
+BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart) :
+	ll(ll_),
+	lineStart(lineStart_),
+	lineEnd(lineEnd_),
+	posLineStart(posLineStart_),
+	utf8(utf8_),
+	nextBreak(lineStart_),
+	saeSize(0),
+	saeLen(0),
+	saeCurrentPos(0),
+	saeNext(0),
+	subBreak(-1) {
+	saeSize = 8;
+	selAndEdge = new int[saeSize];
+	for (unsigned int j=0; j < saeSize; j++) {
+		selAndEdge[j] = 0;
+	}
+
+	// Search for first visible break
+	// First find the first visible character
+	nextBreak = ll->FindBefore(xStart, lineStart, lineEnd);
+	// Now back to a style break
+	while ((nextBreak > lineStart) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
+		nextBreak--;
+	}
+
+	if (ll->selStart != ll->selEnd) {
+		Insert(ll->selStart - posLineStart - 1);
+		Insert(ll->selEnd - posLineStart - 1);
+	}
+
+	Insert(ll->edgeColumn - 1);
+	Insert(lineEnd - 1);
+
+	if (utf8) {
+		int trailBytes=0;
+		for (int pos = -1;;) {
+			pos = NextBadU(ll->chars, pos, lineEnd, trailBytes);
+			if (pos < 0)
+				break;
+			Insert(pos-1);
+			Insert(pos);
+		}
+	}
+	saeNext = (saeLen > 0) ? selAndEdge[0] : -1;
+}
+
+BreakFinder::~BreakFinder() {
+	delete []selAndEdge;
+}
+
+int BreakFinder::First() {
+	return nextBreak;
+}
+
+int BreakFinder::Next() {
+	if (subBreak == -1) {
+		int prev = nextBreak;
+		while (nextBreak < lineEnd) {
+			if ((ll->styles[nextBreak] != ll->styles[nextBreak + 1]) ||
+					(nextBreak == saeNext) ||
+					IsControlCharacter(ll->chars[nextBreak]) || IsControlCharacter(ll->chars[nextBreak + 1])) {
+				if (nextBreak == saeNext) {
+					saeCurrentPos++;
+					saeNext = (saeLen > saeCurrentPos) ? selAndEdge[saeCurrentPos] : -1;
+				}
+				nextBreak++;
+				if ((nextBreak - prev) < lengthStartSubdivision) {
+					return nextBreak;
+				}
+				break;
+			}
+			nextBreak++;
+		}
+		if ((nextBreak - prev) < lengthStartSubdivision) {
+			return nextBreak;
+		}
+		subBreak = prev;
+	}
+	// Splitting up a long run from prev to nextBreak in lots of approximately lengthEachSubdivision.
+	// For very long runs add extra breaks after spaces or if no spaces before low punctuation.
+	if ((nextBreak - subBreak) <= lengthEachSubdivision) {
+		subBreak = -1;
+		return nextBreak;
+	} else {
+		int lastGoodBreak = -1;
+		int lastOKBreak = -1;
+		int j;
+		for (j = subBreak + 1; j <= nextBreak; j++) {
+			if (IsSpaceOrTab(ll->chars[j - 1]) && !IsSpaceOrTab(ll->chars[j])) {
+				lastGoodBreak = j;
+			}
+			if (ll->chars[j] < 'A') {
+				lastOKBreak = j;
+			}
+			if (((j - subBreak) >= lengthEachSubdivision) && ((lastGoodBreak >= 0) || (lastOKBreak >= 0))) {
+				break;
+			}
+		}
+		if (lastGoodBreak >= 0) {
+			subBreak = lastGoodBreak;
+		} else if (lastOKBreak >= 0) {
+			subBreak = lastOKBreak;
+		} else {
+			subBreak = nextBreak;
+		}
+		if (subBreak >= nextBreak) {
+			subBreak = -1;
+			return nextBreak;
+		} else {
+			return subBreak;
+		}
+	}
+}
+
+PositionCacheEntry::PositionCacheEntry() :
+	styleNumber(0), len(0), clock(0), positions(0) {
+}
+
+void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
+	unsigned int len_, int *positions_, unsigned int clock_) {
+	Clear();
+	styleNumber = styleNumber_;
+	len = len_;
+	clock = clock_;
+	if (s_ && positions_) {
+		positions = new short[len + (len + 1) / 2];
+		for (unsigned int i=0;i<len;i++) {
+			positions[i] = static_cast<short>(positions_[i]);
+		}
+		memcpy(reinterpret_cast<char *>(positions + len), s_, len);
+	}
+}
+
+PositionCacheEntry::~PositionCacheEntry() {
+	Clear();
+}
+
+void PositionCacheEntry::Clear() {
+	delete []positions;
+	positions = 0;
+	styleNumber = 0;
+	len = 0;
+	clock = 0;
+}
+
+bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
+	unsigned int len_, int *positions_) const {
+	if ((styleNumber == styleNumber_) && (len == len_) &&
+		(memcmp(reinterpret_cast<char *>(positions + len), s_, len)== 0)) {
+		for (unsigned int i=0;i<len;i++) {
+			positions_[i] = positions[i];
+		}
+		return true;
+	} else {
+		return false;
+	}
+}
+
+int PositionCacheEntry::Hash(unsigned int styleNumber, const char *s, unsigned int len) {
+	unsigned int ret = s[0] << 7;
+	for (unsigned int i=0; i<len; i++) {
+		ret *= 1000003;
+		ret ^= s[i];
+	}
+	ret *= 1000003;
+	ret ^= len;
+	ret *= 1000003;
+	ret ^= styleNumber;
+	return ret;
+}
+
+bool PositionCacheEntry::NewerThan(const PositionCacheEntry &other) {
+	return clock > other.clock;
+}
+
+void PositionCacheEntry::ResetClock() {
+	if (clock > 0) {
+		clock = 1;
+	}
+}
+
+PositionCache::PositionCache() {
+	size = 0x400;
+	clock = 1;
+	pces = new PositionCacheEntry[size];
+	allClear = true;
+}
+
+PositionCache::~PositionCache() {
+	Clear();
+	delete []pces;
+}
+
+void PositionCache::Clear() {
+	if (!allClear) {
+		for (size_t i=0;i<size;i++) {
+			pces[i].Clear();
+		}
+	}
+	clock = 1;
+	allClear = true;
+}
+
+void PositionCache::SetSize(size_t size_) {
+	Clear();
+	delete []pces;
+	size = size_;
+	pces = new PositionCacheEntry[size];
+}
+
+void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
+	const char *s, unsigned int len, int *positions) {
+	allClear = false;
+	int probe = -1;
+	if ((size > 0) && (len < 30)) {
+		// Only store short strings in the cache so it doesn't churn with
+		// long comments with only a single comment.
+
+		// Two way associative: try two probe positions.
+		int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
+		probe = hashValue % size;
+		if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
+			return;
+		}
+		int probe2 = (hashValue * 37) % size;
+		if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
+			return;
+		}
+		// Not found. Choose the oldest of the two slots to replace
+		if (pces[probe].NewerThan(pces[probe2])) {
+			probe = probe2;
+		}
+	}
+	surface->MeasureWidths(vstyle.styles[styleNumber].font, s, len, positions);
+	if (probe >= 0) {
+		clock++;
+		if (clock > 60000) {
+			// Since there are only 16 bits for the clock, wrap it round and
+			// reset all cache entries so none get stuck with a high clock.
+			for (size_t i=0;i<size;i++) {
+				pces[i].ResetClock();
+			}
+			clock = 2;
+		}
+		pces[probe].Set(styleNumber, s, len, positions, clock);
+	}
+}

Added: trunk/plugins/editor/scintilla/PositionCache.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/PositionCache.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,166 @@
+// Scintilla source code edit control
+/** @file PositionCache.h
+ ** Classes for caching layout information.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef POSITIONCACHE_H
+#define POSITIONCACHE_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+static inline bool IsEOLChar(char ch) {
+	return (ch == '\r') || (ch == '\n');
+}
+
+/**
+ */
+class LineLayout {
+private:
+	friend class LineLayoutCache;
+	int *lineStarts;
+	int lenLineStarts;
+	/// Drawing is only performed for @a maxLineLength characters on each line.
+	int lineNumber;
+	bool inCache;
+public:
+	enum { wrapWidthInfinite = 0x7ffffff };
+	int maxLineLength;
+	int numCharsInLine;
+	enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
+	int xHighlightGuide;
+	bool highlightColumn;
+	int selStart;
+	int selEnd;
+	bool containsCaret;
+	int edgeColumn;
+	char *chars;
+	unsigned char *styles;
+	int styleBitsSet;
+	char *indicators;
+	int *positions;
+	char bracePreviousStyles[2];
+
+	// Hotspot support
+	int hsStart;
+	int hsEnd;
+
+	// Wrapped line support
+	int widthLine;
+	int lines;
+
+	LineLayout(int maxLineLength_);
+	virtual ~LineLayout();
+	void Resize(int maxLineLength_);
+	void Free();
+	void Invalidate(validLevel validity_);
+	int LineStart(int line) const;
+	int LineLastVisible(int line) const;
+	bool InLine(int offset, int line) const;
+	void SetLineStart(int line, int start);
+	void SetBracesHighlight(Range rangeLine, Position braces[],
+		char bracesMatchStyle, int xHighlight);
+	void RestoreBracesHighlight(Range rangeLine, Position braces[]);
+	int FindBefore(int x, int lower, int upper) const;
+};
+
+/**
+ */
+class LineLayoutCache {
+	int level;
+	int length;
+	int size;
+	LineLayout **cache;
+	bool allInvalidated;
+	int styleClock;
+	int useCount;
+	void Allocate(int length_);
+	void AllocateForLevel(int linesOnScreen, int linesInDoc);
+public:
+	LineLayoutCache();
+	virtual ~LineLayoutCache();
+	void Deallocate();
+	enum {
+		llcNone=SC_CACHE_NONE,
+		llcCaret=SC_CACHE_CARET,
+		llcPage=SC_CACHE_PAGE,
+		llcDocument=SC_CACHE_DOCUMENT
+	};
+	void Invalidate(LineLayout::validLevel validity_);
+	void SetLevel(int level_);
+	int GetLevel() { return level; }
+	LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+		int linesOnScreen, int linesInDoc);
+	void Dispose(LineLayout *ll);
+};
+
+class PositionCacheEntry {
+	unsigned int styleNumber:8;
+	unsigned int len:8;
+	unsigned int clock:16;
+	short *positions;
+public:
+	PositionCacheEntry();
+	~PositionCacheEntry();
+	void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
+	void Clear();
+	bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
+	static int Hash(unsigned int styleNumber, const char *s, unsigned int len);
+	bool NewerThan(const PositionCacheEntry &other);
+	void ResetClock();
+};
+
+// Class to break a line of text into shorter runs at sensible places.
+class BreakFinder {
+	// If a whole run is longer than lengthStartSubdivision then subdivide
+	// into smaller runs at spaces or punctuation.
+	enum { lengthStartSubdivision = 300 };
+	// Try to make each subdivided run lengthEachSubdivision or shorter.
+	enum { lengthEachSubdivision = 100 };
+	LineLayout *ll;
+	int lineStart;
+	int lineEnd;
+	int posLineStart;
+	bool utf8;
+	int nextBreak;
+	int *selAndEdge;
+	unsigned int saeSize;
+	unsigned int saeLen;
+	unsigned int saeCurrentPos;
+	int saeNext;
+	int subBreak;
+	void Insert(int val);
+public:
+	BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart);
+	~BreakFinder();
+	int First();
+	int Next();
+};
+
+class PositionCache {
+	PositionCacheEntry *pces;
+	size_t size;
+	unsigned int clock;
+	bool allClear;
+public:
+	PositionCache();
+	~PositionCache();
+	void Clear();
+	void SetSize(size_t size_);
+	int GetSize() { return size; }
+	void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
+		const char *s, unsigned int len, int *positions);
+};
+
+inline bool IsSpaceOrTab(int ch) {
+	return ch == ' ' || ch == '\t';
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif

Modified: trunk/plugins/editor/scintilla/PropSet.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/PropSet.cxx	(original)
+++ trunk/plugins/editor/scintilla/PropSet.cxx	Sat Nov 15 17:50:33 2008
@@ -15,6 +15,10 @@
 
 #include "PropSet.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 // The comparison and case changing functions here assume ASCII
 // or extended ASCII such as the normal Windows code page.
 
@@ -329,8 +333,6 @@
 
 // End SString functions
 
-bool PropSet::caseSensitiveFilenames = false;
-
 PropSet::PropSet() {
 	superPS = 0;
 	for (int root = 0; root < hashRoots; root++)
@@ -422,7 +424,7 @@
 	Set(s);
 }
 
-SString PropSet::Get(const char *key) {
+SString PropSet::Get(const char *key) const {
 	unsigned int hash = HashString(key, strlen(key));
 	for (Property *p = props[hash % hashRoots]; p; p = p->next) {
 		if ((hash == p->hash) && (0 == strcmp(p->key, key))) {
@@ -437,21 +439,6 @@
 	}
 }
 
-bool PropSet::IncludesVar(const char *value, const char *key) {
-	const char *var = strstr(value, "$(");
-	while (var) {
-		if (isprefix(var + 2, key) && (var[2 + strlen(key)] == ')')) {
-			// Found $(key) which would lead to an infinite loop so exit
-			return true;
-		}
-		var = strstr(var + 2, ")");
-		if (var)
-			var = strstr(var + 1, "$(");
-	}
-	return false;
-}
-
-
 // There is some inconsistency between GetExpanded("foo") and Expand("$(foo)").
 // A solution is to keep a stack of variables that have been expanded, so that
 // recursive expansions can be skipped.  For now I'll just use the C++ stack
@@ -469,7 +456,7 @@
 	const VarChain *link;
 };
 
-static int ExpandAllInPlace(PropSet &props, SString &withVars, int maxExpands, const VarChain &blankVars = VarChain()) {
+static int ExpandAllInPlace(const PropSet &props, SString &withVars, int maxExpands, const VarChain &blankVars = VarChain()) {
 	int varStart = withVars.search("$(");
 	while ((varStart >= 0) && (maxExpands > 0)) {
 		int varEnd = withVars.search(")", varStart+2);
@@ -505,20 +492,19 @@
 	return maxExpands;
 }
 
-
-SString PropSet::GetExpanded(const char *key) {
+SString PropSet::GetExpanded(const char *key) const {
 	SString val = Get(key);
 	ExpandAllInPlace(*this, val, 100, VarChain(key));
 	return val;
 }
 
-SString PropSet::Expand(const char *withVars, int maxExpands) {
+SString PropSet::Expand(const char *withVars, int maxExpands) const {
 	SString val = withVars;
 	ExpandAllInPlace(*this, val, maxExpands);
 	return val;
 }
 
-int PropSet::GetInt(const char *key, int defaultValue) {
+int PropSet::GetInt(const char *key, int defaultValue) const {
 	SString val = GetExpanded(key);
 	if (val.length())
 		return val.value();
@@ -538,118 +524,6 @@
 		return true;
 }
 
-static bool IsSuffix(const char *target, const char *suffix, bool caseSensitive) {
-	size_t lentarget = strlen(target);
-	size_t lensuffix = strlen(suffix);
-	if (lensuffix > lentarget)
-		return false;
-	if (caseSensitive) {
-		for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
-			if (target[i + lentarget - lensuffix] != suffix[i])
-				return false;
-		}
-	} else {
-	for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
-		if (MakeUpperCase(target[i + lentarget - lensuffix]) !=
-		        MakeUpperCase(suffix[i]))
-			return false;
-	}
-	}
-	return true;
-}
-
-SString PropSet::GetWild(const char *keybase, const char *filename) {
-	for (int root = 0; root < hashRoots; root++) {
-		for (Property *p = props[root]; p; p = p->next) {
-			if (isprefix(p->key, keybase)) {
-				char * orgkeyfile = p->key + strlen(keybase);
-				char *keyfile = NULL;
-
-				if (strstr(orgkeyfile, "$(") == orgkeyfile) {
-					char *cpendvar = strchr(orgkeyfile, ')');
-					if (cpendvar) {
-						*cpendvar = '\0';
-						SString s = GetExpanded(orgkeyfile + 2);
-						*cpendvar = ')';
-						keyfile = StringDup(s.c_str());
-					}
-				}
-				char *keyptr = keyfile;
-
-				if (keyfile == NULL)
-					keyfile = orgkeyfile;
-
-				for (;;) {
-					char *del = strchr(keyfile, ';');
-					if (del == NULL)
-						del = keyfile + strlen(keyfile);
-					char delchr = *del;
-					*del = '\0';
-					if (*keyfile == '*') {
-						if (IsSuffix(filename, keyfile + 1, caseSensitiveFilenames)) {
-							*del = delchr;
-							delete []keyptr;
-							return p->val;
-						}
-					} else if (0 == strcmp(keyfile, filename)) {
-						*del = delchr;
-						delete []keyptr;
-						return p->val;
-					}
-					if (delchr == '\0')
-						break;
-					*del = delchr;
-					keyfile = del + 1;
-				}
-				delete []keyptr;
-
-				if (0 == strcmp(p->key, keybase)) {
-					return p->val;
-				}
-			}
-		}
-	}
-	if (superPS) {
-		// Failed here, so try in base property set
-		return superPS->GetWild(keybase, filename);
-	} else {
-		return "";
-	}
-}
-
-
-
-// GetNewExpand does not use Expand as it has to use GetWild with the filename for each
-// variable reference found.
-SString PropSet::GetNewExpand(const char *keybase, const char *filename) {
-	char *base = StringDup(GetWild(keybase, filename).c_str());
-	char *cpvar = strstr(base, "$(");
-	int maxExpands = 1000;	// Avoid infinite expansion of recursive definitions
-	while (cpvar && (maxExpands > 0)) {
-		char *cpendvar = strchr(cpvar, ')');
-		if (cpendvar) {
-			int lenvar = cpendvar - cpvar - 2;  	// Subtract the $()
-			char *var = StringDup(cpvar + 2, lenvar);
-			SString val = GetWild(var, filename);
-			if (0 == strcmp(var, keybase))
-				val.clear(); // Self-references evaluate to empty string
-			size_t newlenbase = strlen(base) + val.length() - lenvar;
-			char *newbase = new char[newlenbase];
-			strncpy(newbase, base, cpvar - base);
-			strcpy(newbase + (cpvar - base), val.c_str());
-			strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
-			delete []var;
-			delete []base;
-			base = newbase;
-		}
-		cpvar = strstr(base, "$(");
-		maxExpands--;
-	}
-	SString sret = base;
-	delete []base;
-	return sret;
-}
-
 void PropSet::Clear() {
 	for (int root = 0; root < hashRoots; root++) {
 		Property *p = props[root];
@@ -667,7 +541,7 @@
 	}
 }
 
-char *PropSet::ToString() {
+char *PropSet::ToString() const {
 	size_t len=0;
 	for (int r = 0; r < hashRoots; r++) {
 		for (Property *p = props[r]; p; p = p->next) {
@@ -696,50 +570,6 @@
 }
 
 /**
- * Initiate enumeration.
- */
-bool PropSet::GetFirst(char **key, char **val) {
-	for (int i = 0; i < hashRoots; i++) {
-		for (Property *p = props[i]; p; p = p->next) {
-			if (p) {
-				*key = p->key;
-				*val = p->val;
-				enumnext = p->next; // GetNext will begin here ...
-				enumhash = i;		  // ... in this block
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-/**
- * Continue enumeration.
- */
-bool PropSet::GetNext(char ** key, char ** val) {
-	bool firstloop = true;
-
-	// search begins where we left it : in enumhash block
-	for (int i = enumhash; i < hashRoots; i++) {
-		if (!firstloop)
-			enumnext = props[i]; // Begin with first property in block
-		// else : begin where we left
-		firstloop = false;
-
-		for (Property *p = enumnext; p; p = p->next) {
-			if (p) {
-				*key = p->key;
-				*val = p->val;
-				enumnext = p->next; // for GetNext
-				enumhash = i;
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-/**
  * Creates an array that points into each word in the string and puts \0 terminators
  * after each word.
  */
@@ -792,37 +622,17 @@
 	if (words) {
 		delete []list;
 		delete []words;
-		delete []wordsNoCase;
 	}
 	words = 0;
-	wordsNoCase = 0;
 	list = 0;
 	len = 0;
 	sorted = false;
-	sortedNoCase = false;
 }
 
 void WordList::Set(const char *s) {
 	list = StringDup(s);
 	sorted = false;
-	sortedNoCase = false;
-	words = ArrayFromWordList(list, &len, onlyLineEnds);
-	wordsNoCase = new char * [len + 1];
-	memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
-}
-
-char *WordList::Allocate(int size) {
-	list = new char[size + 1];
-	list[size] = '\0';
-	return list;
-}
-
-void WordList::SetFromAllocated() {
-	sorted = false;
-	sortedNoCase = false;
 	words = ArrayFromWordList(list, &len, onlyLineEnds);
-	wordsNoCase = new char * [len + 1];
-	memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
 }
 
 extern "C" int cmpString(const void *a1, const void *a2) {
@@ -830,21 +640,11 @@
 	return strcmp(*(char**)(a1), *(char**)(a2));
 }
 
-extern "C" int cmpStringNoCase(const void *a1, const void *a2) {
-	// Can't work out the correct incantation to use modern casts here
-	return CompareCaseInsensitive(*(char**)(a1), *(char**)(a2));
-}
-
 static void SortWordList(char **words, unsigned int len) {
 	qsort(reinterpret_cast<void*>(words), len, sizeof(*words),
 	      cmpString);
 }
 
-static void SortWordListNoCase(char **wordsNoCase, unsigned int len) {
-	qsort(reinterpret_cast<void*>(wordsNoCase), len, sizeof(*wordsNoCase),
-	      cmpStringNoCase);
-}
-
 bool WordList::InList(const char *s) {
 	if (0 == words)
 		return false;
@@ -861,7 +661,7 @@
 	unsigned char firstChar = s[0];
 	int j = starts[firstChar];
 	if (j >= 0) {
-		while (words[j][0] == firstChar) {
+		while ((unsigned char)words[j][0] == firstChar) {
 			if (s[1] == words[j][1]) {
 				const char *a = words[j] + 1;
 				const char *b = s + 1;
@@ -953,218 +753,3 @@
 	}
 	return false;
 }
-
-/**
- * Returns an element (complete) of the wordlist array which has
- * the same beginning as the passed string.
- * The length of the word to compare is passed too.
- * Letter case can be ignored or preserved (default).
- */
-const char *WordList::GetNearestWord(const char *wordStart, int searchLen, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */, int wordIndex /*= -1 */) {
-	int start = 0; // lower bound of the api array block to search
-	int end = len - 1; // upper bound of the api array block to search
-	int pivot; // index of api array element just being compared
-	int cond; // comparison result (in the sense of strcmp() result)
-	const char *word; // api array element just being compared
-
-	if (0 == words)
-		return NULL;
-	if (ignoreCase) {
-		if (!sortedNoCase) {
-			sortedNoCase = true;
-			SortWordListNoCase(wordsNoCase, len);
-		}
-		while (start <= end) { // binary searching loop
-			pivot = (start + end) >> 1;
-			word = wordsNoCase[pivot];
-			cond = CompareNCaseInsensitive(wordStart, word, searchLen);
-			if (!cond) {
-				// find first word
-				start = pivot;
-				while (start > 0 && !CompareNCaseInsensitive(wordStart, wordsNoCase[start-1], searchLen)) {
-					start--;
-				}
-				// find last word
-				end = pivot;
-				while (end < len-1 && !CompareNCaseInsensitive(wordStart, wordsNoCase[end+1], searchLen)) {
-					end++;
-				}
-
-				// Finds first word in a series of equal words
-				for (pivot = start; pivot <= end; pivot++) {
-					word = wordsNoCase[pivot];
-					if (!wordCharacters.contains(word[searchLen])) {
-						if (wordIndex <= 0) // Checks if a specific index was requested
-							return word; // result must not be freed with free()
-						wordIndex--;
-					}
-				}
-				return NULL;
-			}
-			else if (cond > 0)
-				start = pivot + 1;
-			else if (cond < 0)
-				end = pivot - 1;
-		}
-	} else { // preserve the letter case
-		if (!sorted) {
-			sorted = true;
-			SortWordList(words, len);
-		}
-		while (start <= end) { // binary searching loop
-			pivot = (start + end) >> 1;
-			word = words[pivot];
-			cond = strncmp(wordStart, word, searchLen);
-			if (!cond) {
-				// find first word
-				start = pivot;
-				while (start > 0 && !strncmp(wordStart, words[start-1], searchLen)) {
-					start--;
-				}
-				// find last word
-				end = pivot;
-				while (end < len-1 && !strncmp(wordStart, words[end+1], searchLen)) {
-					end++;
-				}
-
-				// Finds first word in a series of equal words
-				pivot = start;
-				while (pivot <= end) {
-					word = words[pivot];
-					if (!wordCharacters.contains(word[searchLen])) {
-						if (wordIndex <= 0) // Checks if a specific index was requested
-							return word; // result must not be freed with free()
-						wordIndex--;
-					}
-					pivot++;
-				}
-				return NULL;
-			}
-			else if (cond > 0)
-				start = pivot + 1;
-			else if (cond < 0)
-				end = pivot - 1;
-		}
-	}
-	return NULL;
-}
-
-/**
- * Find the length of a 'word' which is actually an identifier in a string
- * which looks like "identifier(..." or "identifier" and where
- * there may be extra spaces after the identifier that should not be
- * counted in the length.
- */
-static unsigned int LengthWord(const char *word, char otherSeparator) {
-	// Find a '('. If that fails go to the end of the string.
-	const char *endWord = strchr(word, '(');
-	if (!endWord && otherSeparator)
-		endWord = strchr(word, otherSeparator);
-	if (!endWord)
-		endWord = word + strlen(word);
-	// Last case always succeeds so endWord != 0
-
-	// Drop any space characters.
-	if (endWord > word) {
-		endWord--;	// Back from the '(', otherSeparator, or '\0'
-		// Move backwards over any spaces
-		while ((endWord > word) && (IsASpace(*endWord))) {
-			endWord--;
-		}
-	}
-	return endWord - word;
-}
-
-/**
- * Returns elements (first words of them) of the wordlist array which have
- * the same beginning as the passed string.
- * The length of the word to compare is passed too.
- * Letter case can be ignored or preserved (default).
- * If there are more words meeting the condition they are returned all of
- * them in the ascending order separated with spaces.
- *
- * NOTE: returned buffer has to be freed with delete[].
- */
-char *WordList::GetNearestWords(
-    const char *wordStart,
-    int searchLen,
-    bool ignoreCase /*= false*/,
-    char otherSeparator /*= '\0'*/,
-    bool exactLen /*=false*/) {
-	unsigned int wordlen; // length of the word part (before the '(' brace) of the api array element
-	SString wordsNear;
-	wordsNear.setsizegrowth(1000);
-	int start = 0; // lower bound of the api array block to search
-	int end = len - 1; // upper bound of the api array block to search
-	int pivot; // index of api array element just being compared
-	int cond; // comparison result (in the sense of strcmp() result)
-
-	if (0 == words)
-		return NULL;
-	if (ignoreCase) {
-		if (!sortedNoCase) {
-			sortedNoCase = true;
-			SortWordListNoCase(wordsNoCase, len);
-		}
-		while (start <= end) { // Binary searching loop
-			pivot = (start + end) / 2;
-			cond = CompareNCaseInsensitive(wordStart, wordsNoCase[pivot], searchLen);
-			if (!cond) {
-				// Find first match
-				while ((pivot > start) &&
-					(0 == CompareNCaseInsensitive(wordStart,
-						wordsNoCase[pivot-1], searchLen))) {
-					--pivot;
-				}
-				// Grab each match
-				while ((pivot <= end) &&
-					(0 == CompareNCaseInsensitive(wordStart,
-						wordsNoCase[pivot], searchLen))) {
-					wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
-					++pivot;
-					if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
-						continue;
-					wordsNear.append(wordsNoCase[pivot-1], wordlen, ' ');
-				}
-				return wordsNear.detach();
-			} else if (cond < 0) {
-				end = pivot - 1;
-			} else if (cond > 0) {
-				start = pivot + 1;
-			}
-		}
-	} else {	// Preserve the letter case
-		if (!sorted) {
-			sorted = true;
-			SortWordList(words, len);
-		}
-		while (start <= end) { // Binary searching loop
-			pivot = (start + end) / 2;
-			cond = strncmp(wordStart, words[pivot], searchLen);
-			if (!cond) {
-				// Find first match
-				while ((pivot > start) &&
-					(0 == strncmp(wordStart,
-						words[pivot-1], searchLen))) {
-					--pivot;
-				}
-				// Grab each match
-				while ((pivot <= end) &&
-					(0 == strncmp(wordStart,
-						words[pivot], searchLen))) {
-					wordlen = LengthWord(words[pivot], otherSeparator) + 1;
-					++pivot;
-					if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
-						continue;
-					wordsNear.append(words[pivot-1], wordlen, ' ');
-				}
-				return wordsNear.detach();
-			} else if (cond < 0) {
-				end = pivot - 1;
-			} else if (cond > 0) {
-				start = pivot + 1;
-			}
-		}
-	}
-	return NULL;
-}

Modified: trunk/plugins/editor/scintilla/RESearch.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/RESearch.cxx	(original)
+++ trunk/plugins/editor/scintilla/RESearch.cxx	Sat Nov 15 17:50:33 2008
@@ -16,6 +16,7 @@
  * Converted to modern function prototypes.
  * Put all global/static variables into an object so this code can be
  * used from multiple threads, etc.
+ * Some extensions by Philippe Lhoste PhiLho(a)GMX.net
  *
  * These routines are the PUBLIC DOMAIN equivalents of regex
  * routines as found in 4.nBSD UN*X, with minor extensions.
@@ -32,7 +33,7 @@
  * Interfaces:
  *  RESearch::Compile:      compile a regular expression into a NFA.
  *
- *          const char *RESearch::Compile(const char *pat, int length,
+ *          const char *RESearch::Compile(const char *pattern, int length,
  *                                        bool caseSensitive, bool posix)
  *
  * Returns a short error string if they fail.
@@ -58,31 +59,38 @@
  *      [2]     .       matches any character.
  *
  *      [3]     \       matches the character following it, except:
- *                      - \a, \b, \f, \n, \t, \v match the
- *                      corresponding C escape char;
+ *                      - \a, \b, \f, \n, \r, \t, \v match the corresponding C
+ *                      escape char, respectively BEL, BS, FF, LF, CR, TAB and VT;
+ *                      Note that \r and \n are never matched because Scintilla
+ *                      regex searches are made line per line
+ *                      (stripped of end-of-line chars).
  *                      - if not in posix mode, when followed by a
  *                      left or right round bracket (see [7]);
  *                      - when followed by a digit 1 to 9 (see [8]);
  *                      - when followed by a left or right angle bracket
- *                      (see [9]).
- *                      It is used as an escape character for all
- *                      other meta-characters, and itself. When used
- *                      in a set ([4]), it is treated as an ordinary
- *                      character (except for escape chars).
+ *                      (see [9]);
+ *                      - when followed by d, D, s, S, w or W (see [10]);
+ *                      - when followed by x and two hexa digits (see [11].
+ *                      Backslash is used as an escape character for all
+ *                      other meta-characters, and itself.
  *
  *      [4]     [set]   matches one of the characters in the set.
  *                      If the first character in the set is "^",
- *                      it matches a character NOT in the set, i.e.
- *                      complements the set. A shorthand S-E (start-end)
- *                      is used to specify a set of characters S upto
- *                      E, inclusive. The special characters "]" and
- *                      "-" have no special meaning if they appear
- *                      as the first chars in the set. To include both,
- *                      put - first: [-]A-Z]:
- *                      [-]|] matches these 2 chars,
- *                      []-|] matches from ] to | chars.
+ *                      it matches the characters NOT in the set, i.e.
+ *                      complements the set. A shorthand S-E (start dash end)
+ *                      is used to specify a set of characters S up to
+ *                      E, inclusive. S and E must be characters, otherwise
+ *                      the dash is taken literally (eg. in expression [\d-a]).
+ *                      The special characters "]" and "-" have no special
+ *                      meaning if they appear as the first chars in the set.
+ *                      To include both, put - first: [-]A-Z]
+ *                      (or just backslash them).
  *                      examples:        match:
  *
+ *                              [-]|]    matches these 3 chars,
+ *
+ *                              []-|]    matches from ] to | chars
+ *
  *                              [a-z]    any lowercase alpha
  *
  *                              [^-]]    any char except - and ]
@@ -92,13 +100,15 @@
  *
  *                              [a-zA-Z] any alpha
  *
- *      [5]     *       any regular expression form [1] to [4], followed by
- *                      closure char (*) matches zero or more matches of
- *                      that form.
+ *      [5]     *       any regular expression form [1] to [4]
+ *                      (except [7], [8] and [9] forms of [3]),
+ *                      followed by closure char (*)
+ *                      matches zero or more matches of that form.
  *
  *      [6]     +       same as [5], except it matches one or more.
+ *                      Both [5] and [6] are greedy (they match as much as possible).
  *
- *      [7]             a regular expression in the form [1] to [10], enclosed
+ *      [7]             a regular expression in the form [1] to [12], enclosed
  *                      as \(form\) (or (form) with posix flag) matches what
  *                      form matches. The enclosure creates a set of tags,
  *                      used for [8] and for pattern substitution.
@@ -112,14 +122,30 @@
  *                      pattern matching to the beginning of a word, and/or
  *                      the end of a word. A word is defined to be a character
  *                      string beginning and/or ending with the characters
- *                      A-Z a-z 0-9 and _. It must also be preceded and/or
+ *                      A-Z a-z 0-9 and _. Scintilla extends this definition
+ *                      by user setting. The word must also be preceded and/or
  *                      followed by any character outside those mentioned.
  *
- *      [10]            a composite regular expression xy where x and y
- *                      are in the form [1] to [10] matches the longest
+ *      [10]    \l      a backslash followed by d, D, s, S, w or W,
+ *                      becomes a character class (both inside and
+ *                      outside sets []).
+ *                        d: decimal digits
+ *                        D: any char except decimal digits
+ *                        s: whitespace (space, \t \n \r \f \v)
+ *                        S: any char except whitespace (see above)
+ *                        w: alphanumeric & underscore (changed by user setting)
+ *                        W: any char except alphanumeric & underscore (see above)
+ *
+ *      [11]    \xHH    a backslash followed by x and two hexa digits,
+ *                      becomes the character whose Ascii code is equal
+ *                      to these digits. If not followed by two digits,
+ *                      it is 'x' char itself.
+ *
+ *      [12]            a composite regular expression xy where x and y
+ *                      are in the form [1] to [11] matches the longest
  *                      match of x followed by a match for y.
  *
- *      [11]    ^       a regular expression starting with a ^ character
+ *      [13]    ^       a regular expression starting with a ^ character
  *              $       and/or ending with a $ character, restricts the
  *                      pattern matching to the beginning of the line,
  *                      or the end of line. [anchors] Elsewhere in the
@@ -143,11 +169,11 @@
  *
  * Notes:
  *
- *	This implementation uses a bit-set representation for character
- *	classes for speed and compactness. Each character is represented
- *	by one bit in a 256-bit block. Thus, CCL always takes a
+ *  This implementation uses a bit-set representation for character
+ *  classes for speed and compactness. Each character is represented
+ *  by one bit in a 256-bit block. Thus, CCL always takes a
  *	constant 32 bytes in the internal nfa, and RESearch::Execute does a single
- *	bit comparison to locate the character in the set.
+ *  bit comparison to locate the character in the set.
  *
  * Examples:
  *
@@ -180,6 +206,10 @@
 #pragma warning(disable: 4514)
 #endif
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 #define OKP     1
 #define NOP     0
 
@@ -204,7 +234,7 @@
 #define BLKIND  0370
 #define BITIND  07
 
-const char bitarr[] = {1,2,4,8,16,32,64,'\200'};
+const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' };
 
 #define badpat(x)	(*nfa = END, x)
 
@@ -212,7 +242,7 @@
  * Character classification table for word boundary operators BOW
  * and EOW is passed in by the creator of this object (Scintilla
  * Document). The Document default state is that word chars are:
- * 0-9,a-z, A-Z and _
+ * 0-9, a-z, A-Z and _
  */
 
 RESearch::RESearch(CharClassify *charClassTable) {
@@ -227,14 +257,14 @@
 void RESearch::Init() {
 	sta = NOP;                  /* status of lastpat */
 	bol = 0;
-	for (int i=0; i<MAXTAG; i++)
+	for (int i = 0; i < MAXTAG; i++)
 		pat[i] = 0;
-	for (int j=0; j<BITBLK; j++)
+	for (int j = 0; j < BITBLK; j++)
 		bittab[j] = 0;
 }
 
 void RESearch::Clear() {
-	for (int i=0; i<MAXTAG; i++) {
+	for (int i = 0; i < MAXTAG; i++) {
 		delete []pat[i];
 		pat[i] = 0;
 		bopat[i] = NOTFOUND;
@@ -244,12 +274,12 @@
 
 bool RESearch::GrabMatches(CharacterIndexer &ci) {
 	bool success = true;
-	for (unsigned int i=0; i<MAXTAG; i++) {
+	for (unsigned int i = 0; i < MAXTAG; i++) {
 		if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
 			unsigned int len = eopat[i] - bopat[i];
 			pat[i] = new char[len + 1];
 			if (pat[i]) {
-				for (unsigned int j=0; j<len; j++)
+				for (unsigned int j = 0; j < len; j++)
 					pat[i][j] = ci.CharAt(bopat[i] + j);
 				pat[i][len] = '\0';
 			} else {
@@ -260,27 +290,27 @@
 	return success;
 }
 
-void RESearch::ChSet(char c) {
+void RESearch::ChSet(unsigned char c) {
 	bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
 }
 
-void RESearch::ChSetWithCase(char c, bool caseSensitive) {
+void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) {
 	if (caseSensitive) {
 		ChSet(c);
 	} else {
 		if ((c >= 'a') && (c <= 'z')) {
 			ChSet(c);
-			ChSet(static_cast<char>(c - 'a' + 'A'));
+			ChSet(static_cast<unsigned char>(c - 'a' + 'A'));
 		} else if ((c >= 'A') && (c <= 'Z')) {
 			ChSet(c);
-			ChSet(static_cast<char>(c - 'A' + 'a'));
+			ChSet(static_cast<unsigned char>(c - 'A' + 'a'));
 		} else {
 			ChSet(c);
 		}
 	}
 }
 
-const char escapeValue(char ch) {
+const unsigned char escapeValue(unsigned char ch) {
 	switch (ch) {
 	case 'a':	return '\a';
 	case 'b':	return '\b';
@@ -293,7 +323,120 @@
 	return 0;
 }
 
-const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, bool posix) {
+static int GetHexaChar(unsigned char hd1, unsigned char hd2) {
+	int hexValue = 0;
+	if (hd1 >= '0' && hd1 <= '9') {
+		hexValue += 16 * (hd1 - '0');
+	} else if (hd1 >= 'A' && hd1 <= 'F') {
+		hexValue += 16 * (hd1 - 'A' + 10);
+	} else if (hd1 >= 'a' && hd1 <= 'f') {
+		hexValue += 16 * (hd1 - 'a' + 10);
+	} else
+		return -1;
+	if (hd2 >= '0' && hd2 <= '9') {
+		hexValue += hd2 - '0';
+	} else if (hd2 >= 'A' && hd2 <= 'F') {
+		hexValue += hd2 - 'A' + 10;
+	} else if (hd2 >= 'a' && hd2 <= 'f') {
+		hexValue += hd2 - 'a' + 10;
+	} else
+		return -1;
+	return hexValue;
+}
+
+/**
+ * Called when the parser finds a backslash not followed
+ * by a valid expression (like \( in non-Posix mode).
+ * @param pattern: pointer on the char after the backslash.
+ * @param incr: (out) number of chars to skip after expression evaluation.
+ * @return the char if it resolves to a simple char,
+ * or -1 for a char class. In this case, bittab is changed.
+ */
+int RESearch::GetBackslashExpression(
+		const char *pattern,
+		int &incr) {
+	// Since error reporting is primitive and messages are not used anyway,
+	// I choose to interpret unexpected syntax in a logical way instead
+	// of reporting errors. Otherwise, we can stick on, eg., PCRE behavior.
+	incr = 0;	// Most of the time, will skip the char "naturally".
+	int c;
+	int result = -1;
+	unsigned char bsc = *pattern;
+	if (!bsc) {
+		// Avoid overrun
+		result = '\\';	// \ at end of pattern, take it literally
+		return result;
+	}
+
+	switch (bsc) {
+	case 'a':
+	case 'b':
+	case 'n':
+	case 'f':
+	case 'r':
+	case 't':
+	case 'v':
+		result = escapeValue(bsc);
+		break;
+	case 'x': {
+			unsigned char hd1 = *(pattern + 1);
+			unsigned char hd2 = *(pattern + 2);
+			int hexValue = GetHexaChar(hd1, hd2);
+			if (hexValue >= 0) {
+				result = hexValue;
+				incr = 2;	// Must skip the digits
+			} else {
+				result = 'x';	// \x without 2 digits: see it as 'x'
+			}
+		}
+		break;
+	case 'd':
+		for (c = '0'; c <= '9'; c++) {
+			ChSet(static_cast<unsigned char>(c));
+		}
+		break;
+	case 'D':
+		for (c = 0; c < MAXCHR; c++) {
+			if (c < '0' || c > '9') {
+				ChSet(static_cast<unsigned char>(c));
+			}
+		}
+		break;
+	case 's':
+		ChSet(' ');
+		ChSet('\t');
+		ChSet('\n');
+		ChSet('\r');
+		ChSet('\f');
+		ChSet('\v');
+		break;
+	case 'S':
+		for (c = 0; c < MAXCHR; c++) {
+			if (c != ' ' && !(c >= 0x09 && c <= 0x0D)) {
+				ChSet(static_cast<unsigned char>(c));
+			}
+		}
+	case 'w':
+		for (c = 0; c < MAXCHR; c++) {
+			if (iswordc(static_cast<unsigned char>(c))) {
+				ChSet(static_cast<unsigned char>(c));
+			}
+		}
+		break;
+	case 'W':
+		for (c = 0; c < MAXCHR; c++) {
+			if (!iswordc(static_cast<unsigned char>(c))) {
+				ChSet(static_cast<unsigned char>(c));
+			}
+		}
+		break;
+	default:
+		result = bsc;
+	}
+	return result;
+}
+
+const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) {
 	char *mp=nfa;          /* nfa pointer       */
 	char *lp;              /* saved pointer     */
 	char *sp=nfa;          /* another one       */
@@ -304,28 +447,28 @@
 
 	int n;
 	char mask;             /* xor mask -CCL/NCL */
-	int c1, c2;
+	int c1, c2, prevChar;
 
-	if (!pat || !length)
+	if (!pattern || !length)
 		if (sta)
 			return 0;
 		else
 			return badpat("No previous regular expression");
 	sta = NOP;
 
-	const char *p=pat;     /* pattern pointer   */
+	const char *p=pattern;     /* pattern pointer   */
 	for (int i=0; i<length; i++, p++) {
 		if (mp > mpMax)
 			return badpat("Pattern too long");
 		lp = mp;
-		switch(*p) {
+		switch (*p) {
 
 		case '.':               /* match any char  */
 			*mp++ = ANY;
 			break;
 
 		case '^':               /* match beginning */
-			if (p == pat)
+			if (p == pattern)
 				*mp++ = BOL;
 			else {
 				*mp++ = CHR;
@@ -344,6 +487,7 @@
 
 		case '[':               /* match char class */
 			*mp++ = CCL;
+			prevChar = 0;
 
 			i++;
 			if (*++p == '^') {
@@ -355,53 +499,101 @@
 
 			if (*p == '-') {	/* real dash */
 				i++;
+				prevChar = *p;
 				ChSet(*p++);
 			}
 			if (*p == ']') {	/* real brace */
 				i++;
+				prevChar = *p;
 				ChSet(*p++);
 			}
 			while (*p && *p != ']') {
-				if (*p == '-' && *(p+1) && *(p+1) != ']') {
-					i++;
-					p++;
-					c1 = *(p-2) + 1;
-					i++;
-					c2 = *p++;
-					while (c1 <= c2) {
-						ChSetWithCase(static_cast<char>(c1++), caseSensitive);
+				if (*p == '-') {
+					if (prevChar < 0) {
+						// Previous def. was a char class like \d, take dash literally
+						prevChar = *p;
+						ChSet(*p);
+					} else if (*(p+1)) {
+						if (*(p+1) != ']') {
+							c1 = prevChar + 1;
+							i++;
+							c2 = *++p;
+							if (c2 == '\\') {
+								if (!*(p+1))	// End of RE
+									return badpat("Missing ]");
+								else {
+									i++;
+									p++;
+									int incr;
+									c2 = GetBackslashExpression(p, incr);
+									i += incr;
+									p += incr;
+									if (c2 >= 0) {
+										// Convention: \c (c is any char) is case sensitive, whatever the option
+										ChSet(static_cast<unsigned char>(c2));
+										prevChar = c2;
+									} else {
+										// bittab is already changed
+										prevChar = -1;
+									}
+								}
+							}
+							if (prevChar < 0) {
+								// Char after dash is char class like \d, take dash literally
+								prevChar = '-';
+								ChSet('-');
+							} else {
+								// Put all chars between c1 and c2 included in the char set
+								while (c1 <= c2) {
+									ChSetWithCase(static_cast<unsigned char>(c1++), caseSensitive);
+								}
+							}
+						} else {
+							// Dash before the ], take it literally
+							prevChar = *p;
+							ChSet(*p);
+						}
+					} else {
+						return badpat("Missing ]");
 					}
 				} else if (*p == '\\' && *(p+1)) {
 					i++;
 					p++;
-					char escape = escapeValue(*p);
-					if (escape)
-						ChSetWithCase(escape, caseSensitive);
-					else
-						ChSetWithCase(*p, caseSensitive);
-					i++;
-					p++;
+					int incr;
+					int c = GetBackslashExpression(p, incr);
+					i += incr;
+					p += incr;
+					if (c >= 0) {
+						// Convention: \c (c is any char) is case sensitive, whatever the option
+						ChSet(static_cast<unsigned char>(c));
+						prevChar = c;
+					} else {
+						// bittab is already changed
+						prevChar = -1;
+					}
 				} else {
-					i++;
-					ChSetWithCase(*p++, caseSensitive);
+					prevChar = *p;
+					ChSetWithCase(*p, caseSensitive);
 				}
+				i++;
+				p++;
 			}
 			if (!*p)
 				return badpat("Missing ]");
 
-			for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
+			for (n = 0; n < BITBLK; bittab[n++] = 0)
 				*mp++ = static_cast<char>(mask ^ bittab[n]);
 
 			break;
 
 		case '*':               /* match 0 or more... */
 		case '+':               /* match 1 or more... */
-			if (p == pat)
+			if (p == pattern)
 				return badpat("Empty closure");
 			lp = sp;		/* previous opcode */
 			if (*lp == CLO)		/* equivalence... */
 				break;
-			switch(*lp) {
+			switch (*lp) {
 
 			case BOL:
 			case BOT:
@@ -429,8 +621,7 @@
 
 		case '\\':              /* tags, backrefs... */
 			i++;
-			switch(*++p) {
-
+			switch (*++p) {
 			case '<':
 				*mp++ = BOW;
 				break;
@@ -454,28 +645,16 @@
 				if (tagc > n) {
 					*mp++ = static_cast<char>(REF);
 					*mp++ = static_cast<char>(n);
-				}
-				else
+				} else
 					return badpat("Undetermined reference");
 				break;
-			case 'a':
-			case 'b':
-			case 'n':
-			case 'f':
-			case 'r':
-			case 't':
-			case 'v':
-				*mp++ = CHR;
-				*mp++ = escapeValue(*p);
-				break;
 			default:
 				if (!posix && *p == '(') {
 					if (tagc < MAXTAG) {
 						tagstk[++tagi] = tagc;
 						*mp++ = BOT;
 						*mp++ = static_cast<char>(tagc++);
-					}
-					else
+					} else
 						return badpat("Too many \\(\\) pairs");
 				} else if (!posix && *p == ')') {
 					if (*sp == BOT)
@@ -483,12 +662,22 @@
 					if (tagi > 0) {
 						*mp++ = static_cast<char>(EOT);
 						*mp++ = static_cast<char>(tagstk[tagi--]);
-					}
-					else
+					} else
 						return badpat("Unmatched \\)");
 				} else {
-					*mp++ = CHR;
-					*mp++ = *p;
+					int incr;
+					int c = GetBackslashExpression(p, incr);
+					i += incr;
+					p += incr;
+					if (c >= 0) {
+						*mp++ = CHR;
+						*mp++ = static_cast<unsigned char>(c);
+					} else {
+						*mp++ = CCL;
+						mask = 0;
+						for (n = 0; n < BITBLK; bittab[n++] = 0)
+							*mp++ = static_cast<char>(mask ^ bittab[n]);
+					}
 				}
 			}
 			break;
@@ -499,8 +688,7 @@
 					tagstk[++tagi] = tagc;
 					*mp++ = BOT;
 					*mp++ = static_cast<char>(tagc++);
-				}
-				else
+				} else
 					return badpat("Too many () pairs");
 			} else if (posix && *p == ')') {
 				if (*sp == BOT)
@@ -508,18 +696,22 @@
 				if (tagi > 0) {
 					*mp++ = static_cast<char>(EOT);
 					*mp++ = static_cast<char>(tagstk[tagi--]);
-				}
-				else
+				} else
 					return badpat("Unmatched )");
-			} else if (caseSensitive) {
-				*mp++ = CHR;
-				*mp++ = *p;
 			} else {
-				*mp++ = CCL;
-				mask = 0;
-				ChSetWithCase(*p, false);
-				for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
-					*mp++ = static_cast<char>(mask ^ bittab[n]);
+				unsigned char c = *p;
+				if (!c)	// End of RE
+					c = '\\';	// We take it as raw backslash
+				if (caseSensitive || !iswordc(c)) {
+					*mp++ = CHR;
+					*mp++ = c;
+				} else {
+					*mp++ = CCL;
+					mask = 0;
+					ChSetWithCase(c, false);
+					for (n = 0; n < BITBLK; bittab[n++] = 0)
+						*mp++ = static_cast<char>(mask ^ bittab[n]);
+				}
 			}
 			break;
 		}
@@ -553,9 +745,8 @@
  *  respectively.
  *
  */
-
 int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
-	char c;
+	unsigned char c;
 	int ep = NOTFOUND;
 	char *ap = nfa;
 
@@ -564,7 +755,7 @@
 
 	Clear();
 
-	switch(*ap) {
+	switch (*ap) {
 
 	case BOL:			/* anchored: match from BOL only */
 		ep = PMatch(ci, lp, endp, ap);
@@ -651,7 +842,7 @@
 	int are;	/* to save the line ptr.  */
 
 	while ((op = *ap++) != END)
-		switch(op) {
+		switch (op) {
 
 		case CHR:
 			if (ci.CharAt(lp++) != *ap++)
@@ -662,6 +853,8 @@
 				return NOTFOUND;
 			break;
 		case CCL:
+			if (lp >= endp)
+				return NOTFOUND;
 			c = ci.CharAt(lp++);
 			if (!isinset(ap,c))
 				return NOTFOUND;
@@ -699,7 +892,7 @@
 			break;
 		case CLO:
 			are = lp;
-			switch(*ap) {
+			switch (*ap) {
 
 			case ANY:
 				while (lp < endp)
@@ -749,7 +942,7 @@
  *      tagged subpattern does not exist, null is substituted.
  */
 int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
-	char c;
+	unsigned char c;
 	int  pin;
 	int bp;
 	int ep;
@@ -758,7 +951,7 @@
 		return 0;
 
 	while ((c = *src++) != 0) {
-		switch(c) {
+		switch (c) {
 
 		case '&':
 			pin = 0;
@@ -783,6 +976,7 @@
 				return 0;
 		}
 	}
-	*dst = (char) 0;
+	*dst = '\0';
 	return 1;
 }
+

Modified: trunk/plugins/editor/scintilla/RESearch.h
==============================================================================
--- trunk/plugins/editor/scintilla/RESearch.h	(original)
+++ trunk/plugins/editor/scintilla/RESearch.h	Sat Nov 15 17:50:33 2008
@@ -9,6 +9,10 @@
 #ifndef RESEARCH_H
 #define RESEARCH_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /*
  * The following defines are not meant to be changeable.
  * They are for readability only.
@@ -30,13 +34,13 @@
 	RESearch(CharClassify *charClassTable);
 	~RESearch();
 	bool GrabMatches(CharacterIndexer &ci);
-	const char *Compile(const char *pat, int length, bool caseSensitive, bool posix);
+	const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix);
 	int Execute(CharacterIndexer &ci, int lp, int endp);
 	int Substitute(CharacterIndexer &ci, char *src, char *dst);
 
-	enum {MAXTAG=10};
-	enum {MAXNFA=2048};
-	enum {NOTFOUND=-1};
+	enum { MAXTAG=10 };
+	enum { MAXNFA=2048 };
+	enum { NOTFOUND=-1 };
 
 	int bopat[MAXTAG];
 	int eopat[MAXTAG];
@@ -45,16 +49,17 @@
 private:
 	void Init();
 	void Clear();
-	void ChSet(char c);
-	void ChSetWithCase(char c, bool caseSensitive);
+	void ChSet(unsigned char c);
+	void ChSetWithCase(unsigned char c, bool caseSensitive);
+	int GetBackslashExpression(const char *pattern, int &incr);
 
 	int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
 
 	int bol;
-	int  tagstk[MAXTAG]; /* subpat tag stack */
+	int tagstk[MAXTAG];  /* subpat tag stack */
 	char nfa[MAXNFA];    /* automaton */
 	int sta;
-	char bittab[BITBLK]; /* bit table for CCL pre-set bits */
+	unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
 	int failure;
 	CharClassify *charClass;
 	bool iswordc(unsigned char x) {
@@ -62,4 +67,9 @@
 	}
 };
 
+#ifdef SCI_NAMESPACE
+}
 #endif
+
+#endif
+

Added: trunk/plugins/editor/scintilla/RunStyles.cxx
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/RunStyles.cxx	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,216 @@
+/** @file RunStyles.cxx
+ ** Data structure used to store sparse styles.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+// Find the first run at a position
+int RunStyles::RunFromPosition(int position) {
+	int run = starts->PartitionFromPosition(position);
+	// Go to first element with this position
+	while ((run > 0) && (position == starts->PositionFromPartition(run-1))) {
+		run--;
+	}
+	return run;
+}
+
+// If there is no run boundary at position, insert one continuing style.
+int RunStyles::SplitRun(int position) {
+	int run = RunFromPosition(position);
+	int posRun = starts->PositionFromPartition(run);
+	if (posRun < position) {
+		int runStyle = ValueAt(position);
+		run++;
+		starts->InsertPartition(run, position);
+		styles->InsertValue(run, 1, runStyle);
+	}
+	return run;
+}
+
+void RunStyles::RemoveRun(int run) {
+	starts->RemovePartition(run);
+	styles->DeleteRange(run, 1);
+}
+
+void RunStyles::RemoveRunIfEmpty(int run) {
+	if ((run < starts->Partitions()) && (starts->Partitions() > 1)) {
+		if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) {
+			RemoveRun(run);
+		}
+	}
+}
+
+void RunStyles::RemoveRunIfSameAsPrevious(int run) {
+	if ((run > 0) && (run < starts->Partitions())) {
+		if (styles->ValueAt(run-1) == styles->ValueAt(run)) {
+			RemoveRun(run);
+		}
+	}
+}
+
+RunStyles::RunStyles() {
+	starts = new Partitioning(8);
+	styles = new SplitVector<int>();
+	styles->InsertValue(0, 2, 0);
+}
+
+RunStyles::~RunStyles() {
+	delete starts;
+	starts = NULL;
+	delete styles;
+	styles = NULL;
+}
+
+int RunStyles::Length() const {
+	return starts->PositionFromPartition(starts->Partitions());
+}
+
+int RunStyles::ValueAt(int position) const {
+	return styles->ValueAt(starts->PartitionFromPosition(position));
+}
+
+int RunStyles::FindNextChange(int position, int end) {
+	int run = starts->PartitionFromPosition(position);
+	if (run < starts->Partitions()) {
+		int runChange = starts->PositionFromPartition(run);
+		if (runChange > position)
+			return runChange;
+		int nextChange = starts->PositionFromPartition(run + 1);
+		if (nextChange > position) {
+			return nextChange;
+		} else if (position < end) {
+			return end;
+		} else {
+			return end + 1;
+		}
+	} else {
+		return end + 1;
+	}
+}
+
+int RunStyles::StartRun(int position) {
+	return starts->PositionFromPartition(starts->PartitionFromPosition(position));
+}
+
+int RunStyles::EndRun(int position) {
+	return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1);
+}
+
+bool RunStyles::FillRange(int &position, int value, int &fillLength) {
+	int end = position + fillLength;
+	int runEnd = RunFromPosition(end);
+	if (styles->ValueAt(runEnd) == value) {
+		// End already has value so trim range.
+		end = starts->PositionFromPartition(runEnd);
+		if (position >= end) {
+			// Whole range is already same as value so no action
+			return false;
+		}
+		fillLength = end - position;
+	} else {
+		runEnd = SplitRun(end);
+	}
+	int runStart = RunFromPosition(position);
+	if (styles->ValueAt(runStart) == value) {
+		// Start is in expected value so trim range.
+		runStart++;
+		position = starts->PositionFromPartition(runStart);
+		fillLength = end - position;
+	} else {
+		if (starts->PositionFromPartition(runStart) < position) {
+			runStart = SplitRun(position);
+			runEnd++;
+		}
+	}
+	if (runStart < runEnd) {
+		styles->SetValueAt(runStart, value);
+		// Remove each old run over the range
+		for (int run=runStart+1; run<runEnd; run++) {
+			RemoveRun(runStart+1);
+		}
+		runEnd = RunFromPosition(end);
+		RemoveRunIfSameAsPrevious(runEnd);
+		RemoveRunIfSameAsPrevious(runStart);
+	}
+	return true;
+}
+
+void RunStyles::SetValueAt(int position, int value) {
+	int len = 1;
+	FillRange(position, value, len);
+}
+
+void RunStyles::InsertSpace(int position, int insertLength) {
+	int runStart = RunFromPosition(position);
+	if (starts->PositionFromPartition(runStart) == position) {
+		int runStyle = ValueAt(position);
+		// Inserting at start of run so make previous longer
+		if (runStart == 0) {
+			// Inserting at start of document so ensure 0
+			if (runStyle) {
+				styles->SetValueAt(0, 0);
+				starts->InsertPartition(1, 0);
+				styles->InsertValue(1, 1, runStyle);
+				starts->InsertText(0, insertLength);
+			} else {
+				starts->InsertText(runStart, insertLength);
+			}
+		} else {
+			if (runStyle) {
+				starts->InsertText(runStart-1, insertLength);
+			} else {
+				// Insert at end of run so do not extend style
+				starts->InsertText(runStart, insertLength);
+			}
+		}
+	} else {
+		starts->InsertText(runStart, insertLength);
+	}
+}
+
+void RunStyles::DeleteAll() {
+	delete starts;
+	starts = NULL;
+	delete styles;
+	styles = NULL;
+	starts = new Partitioning(8);
+	styles = new SplitVector<int>();
+	styles->InsertValue(0, 2, 0);
+}
+
+void RunStyles::DeleteRange(int position, int deleteLength) {
+	int end = position + deleteLength;
+	int runStart = RunFromPosition(position);
+	int runEnd = RunFromPosition(end);
+	if (runStart == runEnd) {
+		// Deleting from inside one run
+		starts->InsertText(runStart, -deleteLength);
+	} else {
+		runStart = SplitRun(position);
+		runEnd = SplitRun(end);
+		starts->InsertText(runStart, -deleteLength);
+		// Remove each old run over the range
+		for (int run=runStart; run<runEnd; run++) {
+			RemoveRun(runStart);
+		}
+		RemoveRunIfEmpty(runStart);
+		RemoveRunIfSameAsPrevious(runStart);
+	}
+}
+

Added: trunk/plugins/editor/scintilla/RunStyles.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/RunStyles.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,46 @@
+/** @file RunStyles.h
+ ** Data structure used to store sparse styles.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/// Styling buffer using one element for each run rather than using
+/// a filled buffer.
+
+#ifndef RUNSTYLES_H
+#define RUNSTYLES_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+class RunStyles {
+public:
+	Partitioning *starts;
+	SplitVector<int> *styles;
+	int RunFromPosition(int position);
+	int SplitRun(int position);
+	void RemoveRun(int run);
+	void RemoveRunIfEmpty(int run);
+	void RemoveRunIfSameAsPrevious(int run);
+public:
+	RunStyles();
+	~RunStyles();
+	int Length() const;
+	int ValueAt(int position) const;
+	int FindNextChange(int position, int end);
+	int StartRun(int position);
+	int EndRun(int position);
+	// Returns true if some values may have changed
+	bool FillRange(int &position, int value, int &fillLength);
+	void SetValueAt(int position, int value);
+	void InsertSpace(int position, int insertLength);
+	void DeleteAll();
+	void DeleteRange(int position, int deleteLength);
+};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif

Modified: trunk/plugins/editor/scintilla/SVector.h
==============================================================================
--- trunk/plugins/editor/scintilla/SVector.h	(original)
+++ trunk/plugins/editor/scintilla/SVector.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef SVECTOR_H
 #define SVECTOR_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  * A simple expandable integer vector.
  * Storage not allocated for elements until an element is used.
@@ -124,4 +128,8 @@
 	}
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/ScintillaBase.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/ScintillaBase.cxx	(original)
+++ trunk/plugins/editor/scintilla/ScintillaBase.cxx	Sat Nov 15 17:50:33 2008
@@ -20,8 +20,10 @@
 #include "DocumentAccessor.h"
 #include "KeyWords.h"
 #endif
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "ContractionState.h"
-#include "SVector.h"
 #include "CellBuffer.h"
 #include "CallTip.h"
 #include "KeyMap.h"
@@ -32,10 +34,16 @@
 #include "ViewStyle.h"
 #include "AutoComplete.h"
 #include "CharClassify.h"
+#include "Decoration.h"
 #include "Document.h"
+#include "PositionCache.h"
 #include "Editor.h"
 #include "ScintillaBase.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 ScintillaBase::ScintillaBase() {
 	displayPopupMenu = true;
 	listType = 0;
@@ -165,7 +173,7 @@
 			return 0;
 
 		default:
-			ac.Cancel();
+			AutoCompleteCancel();
 		}
 	}
 
@@ -174,7 +182,7 @@
 		    (iMessage != SCI_CHARLEFT) &&
 		    (iMessage != SCI_CHARLEFTEXTEND) &&
 		    (iMessage != SCI_CHARRIGHT) &&
-		    (iMessage != SCI_CHARLEFTEXTEND) &&
+		    (iMessage != SCI_CHARRIGHTEXTEND) &&
 		    (iMessage != SCI_EDITTOGGLEOVERTYPE) &&
 		    (iMessage != SCI_DELETEBACK) &&
 		    (iMessage != SCI_DELETEBACKNOTLINE)
@@ -222,6 +230,9 @@
 
 	PRectangle rcClient = GetClientRectangle();
 	Point pt = LocationFromPosition(currentPos - lenEntered);
+	PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
+	if (rcPopupBounds.Height() == 0)
+		rcPopupBounds = rcClient;
 
 	int heightLB = 100;
 	int widthLB = 100;
@@ -232,18 +243,18 @@
 	}
 	PRectangle rcac;
 	rcac.left = pt.x - ac.lb->CaretFromEdge();
-	if (pt.y >= rcClient.bottom - heightLB &&  // Wont fit below.
-	        pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
+	if (pt.y >= rcPopupBounds.bottom - heightLB &&  // Wont fit below.
+	        pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above.
 		rcac.top = pt.y - heightLB;
-		if (rcac.top < 0) {
-			heightLB += rcac.top;
-			rcac.top = 0;
+		if (rcac.top < rcPopupBounds.top) {
+			heightLB -= (rcPopupBounds.top - rcac.top);
+			rcac.top = rcPopupBounds.top;
 		}
 	} else {
 		rcac.top = pt.y + vs.lineHeight;
 	}
 	rcac.right = rcac.left + widthLB;
-	rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom);
+	rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom);
 	ac.lb->SetPositionRelative(rcac, wMain);
 	ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
 	unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
@@ -261,8 +272,8 @@
 	// Make an allowance for large strings in list
 	rcList.left = pt.x - ac.lb->CaretFromEdge();
 	rcList.right = rcList.left + widthLB;
-	if (((pt.y + vs.lineHeight) >= (rcClient.bottom - heightAlloced)) &&  // Wont fit below.
-	        ((pt.y + vs.lineHeight / 2) >= (rcClient.bottom + rcClient.top) / 2)) { // and there is more room above.
+	if (((pt.y + vs.lineHeight) >= (rcPopupBounds.bottom - heightAlloced)) &&  // Wont fit below.
+	        ((pt.y + vs.lineHeight / 2) >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2)) { // and there is more room above.
 		rcList.top = pt.y - heightAlloced;
 	} else {
 		rcList.top = pt.y + vs.lineHeight;
@@ -276,6 +287,13 @@
 }
 
 void ScintillaBase::AutoCompleteCancel() {
+	if (ac.Active()) {
+		SCNotification scn = {0};
+		scn.nmhdr.code = SCN_AUTOCCANCELLED;
+		scn.wParam = 0;
+		scn.listType = 0;
+		NotifyParent(scn);
+	}
 	ac.Cancel();
 }
 
@@ -297,7 +315,7 @@
 	if (ac.IsFillUpChar(ch)) {
 		AutoCompleteCompleted();
 	} else if (ac.IsStopChar(ch)) {
-		ac.Cancel();
+		AutoCompleteCancel();
 	} else {
 		AutoCompleteMoveToCurrentWord();
 	}
@@ -305,9 +323,9 @@
 
 void ScintillaBase::AutoCompleteCharacterDeleted() {
 	if (currentPos < ac.posStart - ac.startLen) {
-		ac.Cancel();
+		AutoCompleteCancel();
 	} else if (ac.cancelAtStartPos && (currentPos <= ac.posStart)) {
-		ac.Cancel();
+		AutoCompleteCancel();
 	} else {
 		AutoCompleteMoveToCurrentWord();
 	}
@@ -320,7 +338,7 @@
 	if (item != -1) {
 		ac.lb->GetValue(item, selected, sizeof(selected));
 	} else {
-		ac.Cancel();
+		AutoCompleteCancel();
 		return;
 	}
 
@@ -356,7 +374,7 @@
 	SetEmptySelection(ac.posStart);
 	if (item != -1) {
 		SString piece = selected;
-		pdoc->InsertString(firstPos, piece.c_str());
+		pdoc->InsertCString(firstPos, piece.c_str());
 		SetEmptySelection(firstPos + static_cast<int>(piece.length()));
 	}
 	pdoc->EndUndoAction();
@@ -367,7 +385,7 @@
 }
 
 void ScintillaBase::CallTipShow(Point pt, const char *defn) {
-	AutoCompleteCancel();
+	ac.Cancel();
 	pt.y += vs.lineHeight;
 	// If container knows about STYLE_CALLTIP then use it in place of the
 	// STYLE_DEFAULT for the face name, size and character set. Also use it
@@ -507,7 +525,7 @@
 		break;
 
 	case SCI_AUTOCCANCEL:
-		AutoCompleteCancel();
+		ac.Cancel();
 		break;
 
 	case SCI_AUTOCACTIVE:
@@ -632,7 +650,7 @@
 
 	case SCI_CALLTIPSETBACK:
 		ct.colourBG = ColourDesired(wParam);
-		vs.styles[STYLE_CALLTIP].fore = ct.colourBG;
+		vs.styles[STYLE_CALLTIP].back = ct.colourBG;
 		InvalidateStyleRedraw();
 		break;
 

Modified: trunk/plugins/editor/scintilla/ScintillaBase.h
==============================================================================
--- trunk/plugins/editor/scintilla/ScintillaBase.h	(original)
+++ trunk/plugins/editor/scintilla/ScintillaBase.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef SCINTILLABASE_H
 #define SCINTILLABASE_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class ScintillaBase : public Editor {
@@ -90,4 +94,8 @@
 	virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/ScintillaGTK.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/ScintillaGTK.cxx	(original)
+++ trunk/plugins/editor/scintilla/ScintillaGTK.cxx	Sat Nov 15 17:50:33 2008
@@ -15,7 +15,7 @@
 #include "Platform.h"
 
 #if PLAT_GTK_WIN32
-#include "Windows.h"
+#include "windows.h"
 #endif
 
 #include "Scintilla.h"
@@ -26,8 +26,11 @@
 #include "Accessor.h"
 #include "KeyWords.h"
 #endif
-#include "ContractionState.h"
 #include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+#include "ContractionState.h"
 #include "CellBuffer.h"
 #include "CallTip.h"
 #include "KeyMap.h"
@@ -37,8 +40,10 @@
 #include "Style.h"
 #include "AutoComplete.h"
 #include "ViewStyle.h"
+#include "Decoration.h"
 #include "CharClassify.h"
 #include "Document.h"
+#include "PositionCache.h"
 #include "Editor.h"
 #include "SString.h"
 #include "ScintillaBase.h"
@@ -73,7 +78,7 @@
 #pragma warning(disable: 4505)
 #endif
 
-#if GTK_CHECK_VERSION(2,2,0)
+#if GTK_CHECK_VERSION(2,6,0)
 #define USE_GTK_CLIPBOARD
 #endif
 
@@ -152,6 +157,7 @@
 	virtual void Initialise();
 	virtual void Finalise();
 	virtual void DisplayCursor(Window::Cursor c);
+	virtual bool DragThreshold(Point ptStart, Point ptNow);
 	virtual void StartDrag();
 	int TargetAsUTF8(char *text);
 	int EncodedFromUTF8(char *utf8, char *encoded);
@@ -192,6 +198,7 @@
 	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
@@ -255,8 +262,9 @@
 	static gint SelectionNotify(GtkWidget *widget, GdkEventSelection *selection_event);
 #endif
 	static void DragBegin(GtkWidget *widget, GdkDragContext *context);
+	gboolean DragMotionThis(GdkDragContext *context, gint x, gint y, guint dragtime);
 	static gboolean DragMotion(GtkWidget *widget, GdkDragContext *context,
-	                           gint x, gint y, guint time);
+	                           gint x, gint y, guint dragtime);
 	static void DragLeave(GtkWidget *widget, GdkDragContext *context,
 	                      guint time);
 	static void DragEnd(GtkWidget *widget, GdkDragContext *context);
@@ -305,12 +313,18 @@
 GdkAtom ScintillaGTK::atomUriList = 0;
 GdkAtom ScintillaGTK::atomDROPFILES_DND = 0;
 
-static const GtkTargetEntry clipboardTargets[] = {
-	{ "text/uri-list", 0, TARGET_URI },
-	{ "UTF8_STRING", 0, TARGET_UTF8_STRING },
-	{ "STRING", 0, TARGET_STRING },
+static const GtkTargetEntry clipboardCopyTargets[] = {
+	{ (gchar *) "UTF8_STRING", 0, TARGET_UTF8_STRING },
+	{ (gchar *) "STRING", 0, TARGET_STRING },
 };
-static const gint nClipboardTargets = sizeof(clipboardTargets) / sizeof(clipboardTargets[0]);
+static const gint nClipboardCopyTargets = sizeof(clipboardCopyTargets) / sizeof(clipboardCopyTargets[0]);
+
+static const GtkTargetEntry clipboardPasteTargets[] = {
+	{ (gchar *) "text/uri-list", 0, TARGET_URI },
+	{ (gchar *) "UTF8_STRING", 0, TARGET_UTF8_STRING },
+	{ (gchar *) "STRING", 0, TARGET_STRING },
+};
+static const gint nClipboardPasteTargets = sizeof(clipboardPasteTargets) / sizeof(clipboardPasteTargets[0]);
 
 static GtkWidget *PWidget(Window &w) {
 	return reinterpret_cast<GtkWidget *>(w.GetID());
@@ -758,17 +772,37 @@
 	gtk_widget_grab_focus(PWidget(wMain));
 
 	gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
-	                          clipboardTargets, nClipboardTargets);
+	                          clipboardCopyTargets, nClipboardCopyTargets);
 
 #ifndef USE_GTK_CLIPBOARD
 	gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), atomClipboard,
-	                          clipboardTargets, nClipboardTargets);
+	                          clipboardPasteTargets, nClipboardPasteTargets);
 #endif
 
 	gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)),
-	                  GTK_DEST_DEFAULT_ALL, clipboardTargets, nClipboardTargets,
+	                  GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets,
 	                  static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE));
 
+#if GLIB_MAJOR_VERSION >= 2
+	// Set caret period based on GTK settings
+	gboolean blinkOn = false;
+	if (g_object_class_find_property(G_OBJECT_GET_CLASS(
+			G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink")) {
+		g_object_get(G_OBJECT(
+			gtk_settings_get_default()), "gtk-cursor-blink", &blinkOn, NULL);
+	}
+	if (blinkOn &&
+		g_object_class_find_property(G_OBJECT_GET_CLASS(
+			G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink-time")) {
+		gint value;
+		g_object_get(G_OBJECT(
+			gtk_settings_get_default()), "gtk-cursor-blink-time", &value, NULL);
+		caret.period = gint(value / 1.75);
+	} else {
+		caret.period = 0;
+	}
+#endif
+
 	SetTicking(true);
 }
 
@@ -784,14 +818,19 @@
 		wText.SetCursor(static_cast<Window::Cursor>(cursorMode));
 }
 
+bool ScintillaGTK::DragThreshold(Point ptStart, Point ptNow) {
+#if GTK_MAJOR_VERSION < 2
+	return Editor::DragThreshold(ptStart, ptNow);
+#else
+	return gtk_drag_check_threshold(GTK_WIDGET(PWidget(wMain)),
+		ptStart.x, ptStart.y, ptNow.x, ptNow.y);
+#endif
+}
+
 void ScintillaGTK::StartDrag() {
 	dragWasDropped = false;
-	static const GtkTargetEntry targets[] = {
-	    { "UTF8_STRING", 0, TARGET_UTF8_STRING },
-	    { "STRING", 0, TARGET_STRING },
-	};
-	static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
-	GtkTargetList *tl = gtk_target_list_new(targets, n_targets);
+	inDragDrop = ddDragging;
+	GtkTargetList *tl = gtk_target_list_new(clipboardCopyTargets, nClipboardCopyTargets);
 	gtk_drag_begin(GTK_WIDGET(PWidget(wMain)),
 	               tl,
 	               static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
@@ -1253,17 +1292,9 @@
 				atomClipboard,
 				GDK_CURRENT_TIME);
 #else
-	GtkClipboard *clipBoard;
-	clipBoard = gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
-	if (clipBoard == NULL) // Occurs if widget isn't in a toplevel
-		return;
-
 	SelectionText *clipText = new SelectionText();
 	clipText->Copy(selectedText);
-
-	gtk_clipboard_set_with_data(clipBoard, clipboardTargets, nClipboardTargets,
-				    ClipboardGetSelection, ClipboardClearSelection, clipText);
-
+	StoreOnClipboard(clipText);
 #endif
 }
 
@@ -1275,17 +1306,9 @@
 		                        atomClipboard,
 		                        GDK_CURRENT_TIME);
 #else
-		GtkClipboard *clipBoard;
-		clipBoard = gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
-		if (clipBoard == NULL) // Occurs if widget isn't in a toplevel
-			return;
-
 		SelectionText *clipText = new SelectionText();
 		CopySelectionRange(clipText);
-
-		gtk_clipboard_set_with_data(clipBoard, clipboardTargets, nClipboardTargets,
-					    ClipboardGetSelection, ClipboardClearSelection, clipText);
-
+		StoreOnClipboard(clipText);
 #endif
 #if PLAT_GTK_WIN32
 		if (selType == selRectangle) {
@@ -1383,13 +1406,13 @@
 void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, SelectionText &selText) {
 	char *data = reinterpret_cast<char *>(selectionData->data);
 	int len = selectionData->length;
-	GdkAtom selectionType = selectionData->type;
+	GdkAtom selectionTypeData = selectionData->type;
 
 	// Return empty string if selection is not a string
-	if ((selectionType != GDK_TARGET_STRING) && (selectionType != atomUTF8)) {
+	if ((selectionTypeData != GDK_TARGET_STRING) && (selectionTypeData != atomUTF8)) {
 		char *empty = new char[1];
 		empty[0] = '\0';
-		selText.Set(empty, 0, SC_CP_UTF8, 0, false);
+		selText.Set(empty, 0, SC_CP_UTF8, 0, false, false);
 		return;
 	}
 
@@ -1402,22 +1425,22 @@
 #endif
 
 	char *dest;
-	if (selectionType == GDK_TARGET_STRING) {
+	if (selectionTypeData == GDK_TARGET_STRING) {
 		dest = Document::TransformLineEnds(&len, data, len, pdoc->eolMode);
 		if (IsUnicodeMode()) {
 			// Unknown encoding so assume in Latin1
 			char *destPrevious = dest;
 			dest = UTF8FromLatin1(dest, len);
-			selText.Set(dest, len, SC_CP_UTF8, 0, selText.rectangular);
+			selText.Set(dest, len, SC_CP_UTF8, 0, selText.rectangular, false);
 			delete []destPrevious;
 		} else {
 			// Assume buffer is in same encoding as selection
 			selText.Set(dest, len, pdoc->dbcsCodePage,
-				vs.styles[STYLE_DEFAULT].characterSet, isRectangular);
+				vs.styles[STYLE_DEFAULT].characterSet, isRectangular, false);
 		}
 	} else {	// UTF-8
 		dest = Document::TransformLineEnds(&len, data, len, pdoc->eolMode);
-		selText.Set(dest, len, SC_CP_UTF8, 0, isRectangular);
+		selText.Set(dest, len, SC_CP_UTF8, 0, isRectangular, false);
 #ifdef USE_CONVERTER
 		const char *charSetBuffer = CharacterSetID();
 		if (!IsUnicodeMode() && *charSetBuffer) {
@@ -1425,7 +1448,7 @@
 				// Convert to locale
 				dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true);
 				selText.Set(dest, len, pdoc->dbcsCodePage,
-					vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular);
+					vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false);
 		}
 #endif
 	}
@@ -1488,15 +1511,15 @@
 
 void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *text) {
 #if PLAT_GTK_WIN32
-	// Many native win32 programs require \n line endings, so make a copy of
-	// the clip text now with newlines converted.  Use { } to hide symbols
+	// GDK on Win32 expands any \n into \r\n, so make a copy of
+	// the clip text now with newlines converted to \n.  Use { } to hide symbols
 	// from code below
 	SelectionText *newline_normalized = NULL;
 	{
 		int tmpstr_len;
 		char *tmpstr = Document::TransformLineEnds(&tmpstr_len, text->s, text->len, SC_EOL_LF);
 		newline_normalized = new SelectionText();
-		newline_normalized->Set(tmpstr, tmpstr_len, SC_CP_UTF8, 0, text->rectangular);
+		newline_normalized->Set(tmpstr, tmpstr_len, SC_CP_UTF8, 0, text->rectangular, false);
 		text = newline_normalized;
 	}
 #endif
@@ -1510,7 +1533,7 @@
 			int new_len;
 			char* tmputf = ConvertText(&new_len, text->s, text->len, "UTF-8", charSet, false);
 			converted = new SelectionText();
-			converted->Set(tmputf, new_len, SC_CP_UTF8, 0, text->rectangular);
+			converted->Set(tmputf, new_len, SC_CP_UTF8, 0, text->rectangular, false);
 			text = converted;
 		}
 	}
@@ -1601,6 +1624,18 @@
 }
 
 #ifdef USE_GTK_CLIPBOARD
+void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) {
+	GtkClipboard *clipBoard =
+		gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
+	if (clipBoard == NULL) // Occurs if widget isn't in a toplevel
+		return;
+
+	if (gtk_clipboard_set_with_data(clipBoard, clipboardCopyTargets, nClipboardCopyTargets,
+				    ClipboardGetSelection, ClipboardClearSelection, clipText)) {
+		gtk_clipboard_set_can_store(clipBoard, clipboardCopyTargets, nClipboardCopyTargets);
+	}
+}
+
 void ScintillaGTK::ClipboardGetSelection(GtkClipboard *, GtkSelectionData *selection_data, guint info, void *data) {
 	GetSelection(selection_data, info, static_cast<SelectionText*>(data));
 }
@@ -1807,7 +1842,15 @@
 	// Compute amount and direction to scroll (even tho on win32 there is
 	// intensity of scrolling info in the native message, gtk doesn't
 	// support this so we simulate similarly adaptive scrolling)
+	// Note that this is disabled on OS X (Darwin) where the X11 server already has
+	// and adaptive scrolling algorithm that fights with this one
 	int cLineScroll;
+#if defined(__MWERKS__) || defined(__APPLE_CPP__) || defined(__APPLE_CC__)
+	cLineScroll = sciThis->linesPerScroll;
+	if (cLineScroll == 0)
+		cLineScroll = 4;
+	sciThis->wheelMouseIntensity = cLineScroll;
+#else
 	int timeDelta = 1000000;
 	GTimeVal curTime;
 	g_get_current_time(&curTime);
@@ -1825,6 +1868,7 @@
 			cLineScroll = 4;
 		sciThis->wheelMouseIntensity = cLineScroll;
 	}
+#endif
 	if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT) {
 		cLineScroll *= -1;
 	}
@@ -1841,7 +1885,7 @@
 		return FALSE;
 	}
 
-    // Horizontal scrolling
+	// Horizontal scrolling
 	if (event->direction == GDK_SCROLL_LEFT || event->direction == GDK_SCROLL_RIGHT) {
 		sciThis->HorizontalScrollTo(sciThis->xOffset + cLineScroll);
 
@@ -1945,6 +1989,12 @@
 		return SCK_SUBTRACT;
 	case GDK_KP_Divide:
 		return SCK_DIVIDE;
+	case GDK_Super_L:
+		return SCK_WIN;
+	case GDK_Super_R:
+		return SCK_RWIN;
+	case GDK_Menu:
+		return SCK_MENU;
 	default:
 		return keyIn;
 	}
@@ -1974,10 +2024,8 @@
 	// This will have to change for Unicode
 	else if (key >= 0xFE00)
 		key = KeyTranslate(key);
-	else if (IsUnicodeMode())
-		;	// No operation
 #if GTK_MAJOR_VERSION < 2
-	else if ((key >= 0x100) && (key < 0x1000))
+	else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000))
 		key &= 0xff;
 #endif
 
@@ -1988,7 +2036,7 @@
 	//fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
 	if (event->keyval == 0xffffff && event->length > 0) {
 		ClearSelection();
-		if (pdoc->InsertString(CurrentPosition(), event->string)) {
+		if (pdoc->InsertCString(CurrentPosition(), event->string)) {
 			MovePositionTo(CurrentPosition() + event->length);
 		}
 	}
@@ -2324,18 +2372,30 @@
 	//Platform::DebugPrintf("DragBegin\n");
 }
 
-gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
-                                  gint x, gint y, guint dragtime) {
-	ScintillaGTK *sciThis = ScintillaFromWidget(widget);
-	//Platform::DebugPrintf("DragMotion %d %d %x %x %x\n", x, y,
-	//	context->actions, context->suggested_action, sciThis);
+gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context,
+                                 gint x, gint y, guint dragtime) {
 	Point npt(x, y);
-	sciThis->inDragDrop = true;
-	sciThis->SetDragPosition(sciThis->PositionFromLocation(npt));
-	gdk_drag_status(context, context->suggested_action, dragtime);
+	SetDragPosition(PositionFromLocation(npt));
+	GdkDragAction preferredAction = context->suggested_action;
+	int pos = PositionFromLocation(npt);
+	if ((inDragDrop == ddDragging) && (0 == PositionInSelection(pos))) {
+		// Avoid dragging selection onto itself as that produces a move
+		// with no real effect but which creates undo actions.
+		preferredAction = static_cast<GdkDragAction>(0);
+	} else if (context->actions == static_cast<GdkDragAction>
+		(GDK_ACTION_COPY | GDK_ACTION_MOVE)) {
+		preferredAction = GDK_ACTION_MOVE;
+	}
+	gdk_drag_status(context, preferredAction, dragtime);
 	return FALSE;
 }
 
+gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
+                                 gint x, gint y, guint dragtime) {
+	ScintillaGTK *sciThis = ScintillaFromWidget(widget);
+	return sciThis->DragMotionThis(context, x, y, dragtime);
+}
+
 void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, guint) {
 	ScintillaGTK *sciThis = ScintillaFromWidget(widget);
 	sciThis->SetDragPosition(invalidPosition);
@@ -2349,6 +2409,7 @@
 		sciThis->SetEmptySelection(sciThis->posDrag);
 	sciThis->SetDragPosition(invalidPosition);
 	//Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
+	sciThis->inDragDrop = ddNone;
 }
 
 gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/,

Added: trunk/plugins/editor/scintilla/SplitVector.h
==============================================================================
--- (empty file)
+++ trunk/plugins/editor/scintilla/SplitVector.h	Sat Nov 15 17:50:33 2008
@@ -0,0 +1,249 @@
+// Scintilla source code edit control
+/** @file SplitVector.h
+ ** Main data structure for holding arrays that handle insertions 
+ ** and deletions efficiently.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef SPLITVECTOR_H
+#define SPLITVECTOR_H
+
+template <typename T>
+class SplitVector {
+protected:
+	T *body;
+	int size;
+	int lengthBody;
+	int part1Length;
+	int gapLength;	/// invariant: gapLength == size - lengthBody
+	int growSize;
+
+	/// Move the gap to a particular position so that insertion and
+	/// deletion at that point will not require much copying and
+	/// hence be fast.
+	void GapTo(int position) {
+		if (position != part1Length) {
+			if (position < part1Length) {
+				memmove(
+					body + position + gapLength,
+					body + position,
+					sizeof(T) * (part1Length - position));
+			} else {	// position > part1Length
+				memmove(
+					body + part1Length,
+					body + part1Length + gapLength,
+					sizeof(T) * (position - part1Length));
+			}
+			part1Length = position;
+		}
+	}
+
+	/// Check that there is room in the buffer for an insertion,
+	/// reallocating if more space needed.
+	void RoomFor(int insertionLength) {
+		if (gapLength <= insertionLength) {
+			if (growSize * 6 < size)
+				growSize *= 2;
+			ReAllocate(size + insertionLength + growSize);
+		}
+	}
+
+	void Init() {
+		body = NULL;
+		growSize = 8;
+		size = 0;
+		lengthBody = 0;
+		part1Length = 0;
+		gapLength = 0;
+	}
+
+public:
+	/// Construct a split buffer.
+	SplitVector() {
+		Init();
+	}
+
+	~SplitVector() {
+		delete []body;
+		body = 0;
+	}
+
+	int GetGrowSize() const {
+		return growSize;
+	}
+
+	void SetGrowSize(int growSize_) {
+		growSize = growSize_;
+	}
+
+	/// Reallocate the storage for the buffer to be newSize and
+	/// copy exisiting contents to the new buffer.
+	/// Must not be used to decrease the size of the buffer.
+	void ReAllocate(int newSize) {
+		if (newSize > size) {
+			// Move the gap to the end
+			GapTo(lengthBody);
+			T *newBody = new T[newSize];
+			if ((size != 0) && (body != 0)) {
+				memmove(newBody, body, sizeof(T) * lengthBody);
+				delete []body;
+			}
+			body = newBody;
+			gapLength += newSize - size;
+			size = newSize;
+		}
+	}
+
+	/// Retrieve the character at a particular position.
+	/// Retrieving positions outside the range of the buffer returns 0.
+	/// The assertions here are disabled since calling code can be 
+	/// simpler if out of range access works and returns 0.
+	T ValueAt(int position) const {
+		if (position < part1Length) {
+			//PLATFORM_ASSERT(position >= 0);
+			if (position < 0) {
+				return 0;
+			} else {
+				return body[position];
+			}
+		} else {
+			//PLATFORM_ASSERT(position < lengthBody);
+			if (position >= lengthBody) {
+				return 0;
+			} else {
+				return body[gapLength + position];
+			}
+		}
+	}
+
+	void SetValueAt(int position, T v) {
+		if (position < part1Length) {
+			PLATFORM_ASSERT(position >= 0);
+			if (position < 0) {
+				;
+			} else {
+				body[position] = v;
+			}
+		} else {
+			PLATFORM_ASSERT(position < lengthBody);
+			if (position >= lengthBody) {
+				;
+			} else {
+				body[gapLength + position] = v;
+			}
+		}
+	}
+
+	T& operator[](int position) const {
+		PLATFORM_ASSERT(position >= 0 && position < lengthBody);
+		if (position < part1Length) {
+			return body[position];
+		} else {
+			return body[gapLength + position];
+		}
+	}
+
+	/// Retrieve the length of the buffer.
+	int Length() const {
+		return lengthBody;
+	}
+
+	/// Insert a single value into the buffer.
+	/// Inserting at positions outside the current range fails.
+	void Insert(int position, T v) {
+		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+		if ((position < 0) || (position > lengthBody)) {
+			return;
+		}
+		RoomFor(1);
+		GapTo(position);
+		body[part1Length] = v;
+		lengthBody++;
+		part1Length++;
+		gapLength--;
+	}
+
+	/// Insert a number of elements into the buffer setting their value.
+	/// Inserting at positions outside the current range fails.
+	void InsertValue(int position, int insertLength, T v) {
+		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+		if (insertLength > 0) {
+			if ((position < 0) || (position > lengthBody)) {
+				return;
+			}
+			RoomFor(insertLength);
+			GapTo(position);
+			for (int i = 0; i < insertLength; i++)
+				body[part1Length + i] = v;
+			lengthBody += insertLength;
+			part1Length += insertLength;
+			gapLength -= insertLength;
+		}
+	}
+
+	/// Ensure at least length elements allocated, 
+	/// appending zero valued elements if needed.
+	void EnsureLength(int wantedLength) {
+		if (Length() < wantedLength) {
+			InsertValue(Length(), wantedLength - Length(), 0);
+		}
+	}
+	
+	/// Insert text into the buffer from an array.
+	void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
+		PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
+		if (insertLength > 0) {
+			if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {
+				return;
+			}
+			RoomFor(insertLength);
+			GapTo(positionToInsert);
+			memmove(body + part1Length, s + positionFrom, sizeof(T) * insertLength);
+			lengthBody += insertLength;
+			part1Length += insertLength;
+			gapLength -= insertLength;
+		}
+	}
+
+	/// Delete one element from the buffer.
+	void Delete(int position) {
+		PLATFORM_ASSERT((position >= 0) && (position < lengthBody));
+		if ((position < 0) || (position >= lengthBody)) {
+			return;
+		}
+		DeleteRange(position, 1);
+	}
+
+	/// Delete a range from the buffer.
+	/// Deleting positions outside the current range fails.
+	void DeleteRange(int position, int deleteLength) {
+		PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));
+		if ((position < 0) || ((position + deleteLength) > lengthBody)) {
+			return;
+		}
+		if ((position == 0) && (deleteLength == lengthBody)) {
+			// Full deallocation returns storage and is faster
+			delete []body;
+			Init();
+		} else if (deleteLength > 0) {
+			GapTo(position);
+			lengthBody -= deleteLength;
+			gapLength += deleteLength;
+		}
+	}
+
+	/// Delete all the buffer contents.
+	void DeleteAll() {
+		DeleteRange(0, lengthBody);
+	}
+
+	T* BufferPointer() {
+		RoomFor(1);
+		GapTo(lengthBody);
+		body[lengthBody] = 0;
+		return body;
+	}
+};
+
+#endif

Modified: trunk/plugins/editor/scintilla/Style.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/Style.cxx	(original)
+++ trunk/plugins/editor/scintilla/Style.cxx	Sat Nov 15 17:50:33 2008
@@ -12,6 +12,10 @@
 #include "Scintilla.h"
 #include "Style.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 Style::Style() {
 	aliasOfDefaultFont = true;
 	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),

Modified: trunk/plugins/editor/scintilla/Style.h
==============================================================================
--- trunk/plugins/editor/scintilla/Style.h	(original)
+++ trunk/plugins/editor/scintilla/Style.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef STYLE_H
 #define STYLE_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class Style {
@@ -53,4 +57,8 @@
 	bool IsProtected() const { return !(changeable && visible);};
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/StyleContext.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/StyleContext.cxx	(original)
+++ trunk/plugins/editor/scintilla/StyleContext.cxx	Sat Nov 15 17:50:33 2008
@@ -16,6 +16,10 @@
 #include "Accessor.h"
 #include "StyleContext.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static void getRange(unsigned int start,
 		unsigned int end,
 		Accessor &styler,

Modified: trunk/plugins/editor/scintilla/StyleContext.h
==============================================================================
--- trunk/plugins/editor/scintilla/StyleContext.h	(original)
+++ trunk/plugins/editor/scintilla/StyleContext.h	Sat Nov 15 17:50:33 2008
@@ -5,6 +5,10 @@
 // Copyright 1998-2004 by Neil Hodgson <neilh scintilla org>
 // This file is in the public domain.
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 // All languages handled so far can treat all characters >= 0x80 as one class
 // which just continues the current token or starts an identifier if in default.
 // DBCS treated specially as the second character can be < 0x80 and hence
@@ -116,6 +120,8 @@
 		if (ch != static_cast<unsigned char>(*s))
 			return false;
 		s++;
+		if (!*s)
+			return true;
 		if (chNext != static_cast<unsigned char>(*s))
 			return false;
 		s++;
@@ -146,6 +152,10 @@
 	void GetCurrentLowered(char *s, unsigned int len);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 inline bool IsASpace(unsigned int ch) {
     return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
 }

Modified: trunk/plugins/editor/scintilla/UniConversion.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/UniConversion.cxx	(original)
+++ trunk/plugins/editor/scintilla/UniConversion.cxx	Sat Nov 15 17:50:33 2008
@@ -9,49 +9,80 @@
 
 #include "UniConversion.h"
 
+enum { SURROGATE_LEAD_FIRST = 0xD800 };
+enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
+enum { SURROGATE_TRAIL_LAST = 0xDFFF };
+
 unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
 	unsigned int len = 0;
-	for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
+	for (unsigned int i = 0; i < tlen && uptr[i];) {
 		unsigned int uch = uptr[i];
-		if (uch < 0x80)
+		if (uch < 0x80) {
 			len++;
-		else if (uch < 0x800)
+		} else if (uch < 0x800) {
 			len += 2;
-		else
-			len +=3;
+		} else if ((uch >= SURROGATE_LEAD_FIRST) &&
+			(uch <= SURROGATE_TRAIL_LAST)) {
+			len += 4;
+			i++;
+		} else {
+			len += 3;
+		}
+		i++;
 	}
 	return len;
 }
 
-void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
+void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
 	int k = 0;
-	for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
+	for (unsigned int i = 0; i < tlen && uptr[i];) {
 		unsigned int uch = uptr[i];
 		if (uch < 0x80) {
 			putf[k++] = static_cast<char>(uch);
 		} else if (uch < 0x800) {
 			putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
 			putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
+		} else if ((uch >= SURROGATE_LEAD_FIRST) &&
+			(uch <= SURROGATE_TRAIL_LAST)) {
+			// Half a surrogate pair
+			i++;
+			unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
+			putf[k++] = static_cast<char>(0xF0 | (xch >> 18));
+			putf[k++] = static_cast<char>(0x80 | (xch >> 12) & 0x3f);
+			putf[k++] = static_cast<char>(0x80 | ((xch >> 6) & 0x3f));
+			putf[k++] = static_cast<char>(0x80 | (xch & 0x3f));
 		} else {
 			putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
 			putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
 			putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
 		}
+		i++;
 	}
 	putf[len] = '\0';
 }
 
-unsigned int UCS2Length(const char *s, unsigned int len) {
+unsigned int UTF16Length(const char *s, unsigned int len) {
 	unsigned int ulen = 0;
-	for (unsigned int i=0;i<len;i++) {
+	unsigned int charLen;
+	for (unsigned int i=0;i<len;) {
 		unsigned char ch = static_cast<unsigned char>(s[i]);
-		if ((ch < 0x80) || (ch > (0x80 + 0x40)))
+		if (ch < 0x80) {
+			charLen = 1;
+		} else if (ch < 0x80 + 0x40 + 0x20) {
+			charLen = 2;
+		} else if (ch < 0x80 + 0x40 + 0x20 + 0x10) {
+			charLen = 3;
+		} else {
+			charLen = 4;
 			ulen++;
+		}
+		i += charLen;
+		ulen++;
 	}
 	return ulen;
 }
 
-unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
+unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
 	unsigned int ui=0;
 	const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
 	unsigned int i=0;
@@ -63,12 +94,24 @@
 			tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6);
 			ch = us[i++];
 			tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
-		} else {
+		} else if (ch < 0x80 + 0x40 + 0x20 + 0x10) {
 			tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12);
 			ch = us[i++];
 			tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6));
 			ch = us[i++];
 			tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
+		} else {
+			// Outside the BMP so need two surrogates
+			int val = (ch & 0x7) << 18;
+			ch = us[i++];
+			val += (ch & 0x3F) << 12;
+			ch = us[i++];
+			val += (ch & 0x3F) << 6;
+			ch = us[i++];
+			val += (ch & 0x3F);
+			tbuf[ui] = static_cast<wchar_t>(((val - 0x10000) >> 10) + SURROGATE_LEAD_FIRST);
+			ui++;
+			tbuf[ui] = static_cast<wchar_t>((val & 0x3ff) + SURROGATE_TRAIL_FIRST);
 		}
 		ui++;
 	}

Modified: trunk/plugins/editor/scintilla/UniConversion.h
==============================================================================
--- trunk/plugins/editor/scintilla/UniConversion.h	(original)
+++ trunk/plugins/editor/scintilla/UniConversion.h	Sat Nov 15 17:50:33 2008
@@ -6,7 +6,7 @@
 // The License.txt file describes the conditions under which this software may be distributed.
 
 unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
-void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
-unsigned int UCS2Length(const char *s, unsigned int len);
-unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
+void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
+unsigned int UTF16Length(const char *s, unsigned int len);
+unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
 

Modified: trunk/plugins/editor/scintilla/ViewStyle.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/ViewStyle.cxx	(original)
+++ trunk/plugins/editor/scintilla/ViewStyle.cxx	Sat Nov 15 17:50:33 2008
@@ -10,23 +10,34 @@
 #include "Platform.h"
 
 #include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
 #include "Indicator.h"
 #include "XPM.h"
 #include "LineMarker.h"
 #include "Style.h"
 #include "ViewStyle.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 MarginStyle::MarginStyle() :
 	style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) {
 }
 
 // A list of the fontnames - avoids wasting space in each style
 FontNames::FontNames() {
+	size = 8;
+	names = new char *[size];
 	max = 0;
 }
 
 FontNames::~FontNames() {
 	Clear();
+	delete []names;
+	names = 0;
 }
 
 void FontNames::Clear() {
@@ -44,6 +55,17 @@
 			return names[i];
 		}
 	}
+	if (max >= size) {
+		// Grow array
+		int sizeNew = size * 2;
+		char **namesNew = new char *[sizeNew];
+		for (int j=0;j<max;j++) {
+			namesNew[j] = names[j];
+		}
+		delete []names;
+		names = namesNew;
+		size = sizeNew;
+	}
 	names[max] = new char[strlen(name) + 1];
 	strcpy(names[max], name);
 	max++;
@@ -55,8 +77,8 @@
 }
 
 ViewStyle::ViewStyle(const ViewStyle &source) {
-	Init();
-	for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
+	Init(source.stylesSize);
+	for (unsigned int sty=0;sty<source.stylesSize;sty++) {
 		styles[sty] = source.styles[sty];
 		// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
 		styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
@@ -74,6 +96,7 @@
 	selbackground.desired = source.selbackground.desired;
 	selbackground2.desired = source.selbackground2.desired;
 	selAlpha = source.selAlpha;
+	selEOLFilled = source.selEOLFilled;
 
 	foldmarginColourSet = source.foldmarginColourSet;
 	foldmarginColour.desired = source.foldmarginColour.desired;
@@ -99,6 +122,7 @@
 	caretLineAlpha = source.caretLineAlpha;
 	edgecolour.desired = source.edgecolour.desired;
 	edgeState = source.edgeState;
+	caretStyle = source.caretStyle;
 	caretWidth = source.caretWidth;
 	someStylesProtected = false;
 	leftMarginWidth = source.leftMarginWidth;
@@ -118,17 +142,25 @@
 }
 
 ViewStyle::~ViewStyle() {
+	delete []styles;
+	styles = NULL;
 }
 
-void ViewStyle::Init() {
+void ViewStyle::Init(size_t stylesSize_) {
+	stylesSize = 0;
+	styles = NULL;
+	AllocStyles(stylesSize_);
 	fontNames.Clear();
 	ResetDefaultStyle();
 
 	indicators[0].style = INDIC_SQUIGGLE;
+	indicators[0].under = false;
 	indicators[0].fore = ColourDesired(0, 0x7f, 0);
 	indicators[1].style = INDIC_TT;
+	indicators[1].under = false;
 	indicators[1].fore = ColourDesired(0, 0, 0xff);
 	indicators[2].style = INDIC_PLAIN;
+	indicators[2].under = false;
 	indicators[2].fore = ColourDesired(0xff, 0, 0);
 
 	lineHeight = 1;
@@ -143,6 +175,7 @@
 	selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
 	selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
 	selAlpha = SC_ALPHA_NOALPHA;
+	selEOLFilled = false;
 
 	foldmarginColourSet = false;
 	foldmarginColour.desired = ColourDesired(0xff, 0, 0);
@@ -163,6 +196,7 @@
 	caretLineAlpha = SC_ALPHA_NOALPHA;
 	edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
 	edgeState = EDGE_NONE;
+	caretStyle = CARETSTYLE_LINE;
 	caretWidth = 1;
 	someStylesProtected = false;
 
@@ -195,7 +229,7 @@
 	}
 	zoomLevel = 0;
 	viewWhitespace = wsInvisible;
-	viewIndentationGuides = false;
+	viewIndentationGuides = ivNone;
 	viewEOL = false;
 	showMarkedLines = true;
 	extraFontFlag = false;
@@ -203,7 +237,7 @@
 
 void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
 	unsigned int i;
-	for (i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+	for (i=0;i<stylesSize;i++) {
 		pal.WantFind(styles[i].fore, want);
 		pal.WantFind(styles[i].back, want);
 	}
@@ -238,7 +272,7 @@
 	maxAscent = styles[STYLE_DEFAULT].ascent;
 	maxDescent = styles[STYLE_DEFAULT].descent;
 	someStylesProtected = false;
-	for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+	for (unsigned int i=0; i<stylesSize; i++) {
 		if (i != STYLE_DEFAULT) {
 			styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT], extraFontFlag);
 			if (maxAscent < styles[i].ascent)
@@ -266,17 +300,45 @@
 	}
 }
 
+void ViewStyle::AllocStyles(size_t sizeNew) {
+	Style *stylesNew = new Style[sizeNew];
+	size_t i=0;
+	for (; i<stylesSize; i++) {
+		stylesNew[i] = styles[i];
+		stylesNew[i].fontName = styles[i].fontName;
+	}
+	if (stylesSize > STYLE_DEFAULT) {
+		for (; i<sizeNew; i++) {
+			if (i != STYLE_DEFAULT) {
+				stylesNew[i].ClearTo(styles[STYLE_DEFAULT]);
+			}
+		}
+	}
+	delete []styles;
+	styles = stylesNew;
+	stylesSize = sizeNew;
+}
+
+void ViewStyle::EnsureStyle(size_t index) {
+	if (index >= stylesSize) {
+		size_t sizeNew = stylesSize * 2;
+		while (sizeNew < index)
+			sizeNew *= 2;
+		AllocStyles(sizeNew);
+	}
+}
+
 void ViewStyle::ResetDefaultStyle() {
 	styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
 		ColourDesired(0xff,0xff,0xff),
-	        Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
+		Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
 		SC_CHARSET_DEFAULT,
 		false, false, false, false, Style::caseMixed, true, true, false);
 }
 
 void ViewStyle::ClearStyles() {
 	// Reset all styles to be like the default style
-	for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+	for (unsigned int i=0; i<stylesSize; i++) {
 		if (i != STYLE_DEFAULT) {
 			styles[i].ClearTo(styles[STYLE_DEFAULT]);
 		}
@@ -293,5 +355,5 @@
 }
 
 bool ViewStyle::ProtectionActive() const {
-    return someStylesProtected;
+	return someStylesProtected;
 }

Modified: trunk/plugins/editor/scintilla/ViewStyle.h
==============================================================================
--- trunk/plugins/editor/scintilla/ViewStyle.h	(original)
+++ trunk/plugins/editor/scintilla/ViewStyle.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef VIEWSTYLE_H
 #define VIEWSTYLE_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class MarginStyle {
@@ -23,7 +27,8 @@
  */
 class FontNames {
 private:
-	char *names[STYLE_MAX + 1];
+	char **names;
+	int size;
 	int max;
 
 public:
@@ -33,6 +38,8 @@
 	const char *Save(const char *name);
 };
 
+enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
+
 enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
 
 /**
@@ -40,7 +47,8 @@
 class ViewStyle {
 public:
 	FontNames fontNames;
-	Style styles[STYLE_MAX + 1];
+	size_t stylesSize;
+	Style *styles;
 	LineMarker markers[MARKER_MAX + 1];
 	Indicator indicators[INDIC_MAX + 1];
 	int lineHeight;
@@ -54,6 +62,7 @@
 	ColourPair selbackground;
 	ColourPair selbackground2;
 	int selAlpha;
+	bool selEOLFilled;
 	bool whitespaceForegroundSet;
 	ColourPair whitespaceForeground;
 	bool whitespaceBackgroundSet;
@@ -80,7 +89,7 @@
 	int fixedColumnWidth;
 	int zoomLevel;
 	WhiteSpaceVisibility viewWhitespace;
-	bool viewIndentationGuides;
+	IndentView viewIndentationGuides;
 	bool viewEOL;
 	bool showMarkedLines;
 	ColourPair caretcolour;
@@ -89,6 +98,7 @@
 	int caretLineAlpha;
 	ColourPair edgecolour;
 	int edgeState;
+	int caretStyle;
 	int caretWidth;
 	bool someStylesProtected;
 	bool extraFontFlag;
@@ -96,13 +106,19 @@
 	ViewStyle();
 	ViewStyle(const ViewStyle &source);
 	~ViewStyle();
-	void Init();
+	void Init(size_t stylesSize_=64);
 	void RefreshColourPalette(Palette &pal, bool want);
 	void Refresh(Surface &surface);
+	void AllocStyles(size_t sizeNew);
+	void EnsureStyle(size_t index);
 	void ResetDefaultStyle();
 	void ClearStyles();
 	void SetStyleFontName(int styleIndex, const char *name);
 	bool ProtectionActive() const;
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/WindowAccessor.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/WindowAccessor.cxx	(original)
+++ trunk/plugins/editor/scintilla/WindowAccessor.cxx	Sat Nov 15 17:50:33 2008
@@ -17,6 +17,10 @@
 #include "WindowAccessor.h"
 #include "Scintilla.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 WindowAccessor::~WindowAccessor() {
 }
 
@@ -176,3 +180,12 @@
 		return indent;
 }
 
+void WindowAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+	Platform::SendScintilla(id, SCI_SETINDICATORCURRENT, indicator);
+	if (value) {
+		Platform::SendScintilla(id, SCI_SETINDICATORVALUE, value);
+		Platform::SendScintilla(id, SCI_INDICATORFILLRANGE, start, end - start);
+	} else {
+		Platform::SendScintilla(id, SCI_INDICATORCLEARRANGE, start, end - start);
+	}
+}

Modified: trunk/plugins/editor/scintilla/XPM.cxx
==============================================================================
--- trunk/plugins/editor/scintilla/XPM.cxx	(original)
+++ trunk/plugins/editor/scintilla/XPM.cxx	Sat Nov 15 17:50:33 2008
@@ -12,6 +12,10 @@
 
 #include "XPM.h"
 
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
 static const char *NextField(const char *s) {
 	// In case there are leading spaces in the string
 	while (*s && *s == ' ') {

Modified: trunk/plugins/editor/scintilla/XPM.h
==============================================================================
--- trunk/plugins/editor/scintilla/XPM.h	(original)
+++ trunk/plugins/editor/scintilla/XPM.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,10 @@
 #ifndef XPM_H
 #define XPM_H
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  * Hold a pixmap in XPM format.
  */
@@ -69,4 +73,8 @@
 	int GetWidth();
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/include/Accessor.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/Accessor.h	(original)
+++ trunk/plugins/editor/scintilla/include/Accessor.h	Sat Nov 15 17:50:33 2008
@@ -75,4 +75,5 @@
 	virtual void ColourTo(unsigned int pos, int chAttr)=0;
 	virtual void SetLevel(int line, int level)=0;
 	virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
+	virtual void IndicatorFill(int start, int end, int indicator, int value)=0;
 };

Modified: trunk/plugins/editor/scintilla/include/HFacer.py
==============================================================================
--- trunk/plugins/editor/scintilla/include/HFacer.py	(original)
+++ trunk/plugins/editor/scintilla/include/HFacer.py	Sat Nov 15 17:50:33 2008
@@ -71,6 +71,6 @@
 	f.ReadFromFile("Scintilla.iface")
 	Regenerate("Scintilla.h", printHFile, f)
 	Regenerate("SciLexer.h", printLexHFile, f)
-	print "Maximum ID is", max(x for x in f.values if int(x) < 3000)
+	print "Maximum ID is", max([x for x in f.values if int(x) < 3000])
 except:
 	raise

Modified: trunk/plugins/editor/scintilla/include/KeyWords.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/KeyWords.h	(original)
+++ trunk/plugins/editor/scintilla/include/KeyWords.h	Sat Nov 15 17:50:33 2008
@@ -5,6 +5,10 @@
 // Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
                   WordList *keywordlists[], Accessor &styler);
                   
@@ -51,6 +55,10 @@
 	static const LexerModule *Find(const char *languageName);
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 /**
  * Check if a character is a space.
  * This is ASCII specific but is safe with chars >= 0x80.

Modified: trunk/plugins/editor/scintilla/include/Platform.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/Platform.h	(original)
+++ trunk/plugins/editor/scintilla/include/Platform.h	Sat Nov 15 17:50:33 2008
@@ -16,6 +16,7 @@
 
 #define PLAT_GTK 0
 #define PLAT_GTK_WIN32 0
+#define PLAT_MACOSX 0
 #define PLAT_WIN 0
 #define PLAT_WX  0
 #define PLAT_FOX 0
@@ -32,17 +33,24 @@
 #undef PLAT_GTK
 #define PLAT_GTK 1
 
-#ifdef _MSC_VER
+#if defined(__WIN32__) || defined(_MSC_VER)
 #undef PLAT_GTK_WIN32
 #define PLAT_GTK_WIN32 1
 #endif
 
+#elif defined(MACOSX)
+#undef PLAT_MACOSX
+#define PLAT_MACOSX 1
+
 #else
 #undef PLAT_WIN
 #define PLAT_WIN 1
 
 #endif
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
 
 // 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
@@ -114,6 +122,9 @@
 	}
 	int Width() { return right - left; }
 	int Height() { return bottom - top; }
+	bool Empty() {
+		return (Height() <= 0) || (Width() <= 0);
+	}
 };
 
 /**
@@ -360,9 +371,23 @@
 class Window {
 protected:
 	WindowID id;
+#if PLAT_MACOSX
+	void *windowRef;
+	void *control;
+#endif
 public:
-	Window() : id(0), cursorLast(cursorInvalid) {}
-	Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
+	Window() : id(0), cursorLast(cursorInvalid) {
+#if PLAT_MACOSX
+	  windowRef = 0;
+	  control = 0;
+#endif
+	}
+	Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {
+#if PLAT_MACOSX
+	  windowRef = 0;
+	  control = 0;
+#endif
+	}
 	virtual ~Window();
 	Window &operator=(WindowID id_) {
 		id = id_;
@@ -383,6 +408,11 @@
 	enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
 	void SetCursor(Cursor curs);
 	void SetTitle(const char *s);
+	PRectangle GetMonitorRect(Point pt);
+#if PLAT_MACOSX
+	void SetWindow(void *ref) { windowRef = ref; };
+	void SetControl(void *_control) { control = _control; };
+#endif
 private:
 	Cursor cursorLast;
 };
@@ -506,8 +536,16 @@
 #ifdef  NDEBUG
 #define PLATFORM_ASSERT(c) ((void)0)
 #else
+#ifdef SCI_NAMESPACE
+#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
+#else
 #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
 #endif
+#endif
+
+#ifdef SCI_NAMESPACE
+}
+#endif
 
 // Shut up annoying Visual C++ warnings:
 #ifdef _MSC_VER

Modified: trunk/plugins/editor/scintilla/include/PropSet.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/PropSet.h	(original)
+++ trunk/plugins/editor/scintilla/include/PropSet.h	Sat Nov 15 17:50:33 2008
@@ -13,6 +13,10 @@
 
 bool isprefix(const char *target, const char *prefix);
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 struct Property {
 	unsigned int hash;
 	char *key;
@@ -29,7 +33,6 @@
 	Property *props[hashRoots];
 	Property *enumnext;
 	int enumhash;
-	static bool caseSensitiveFilenames;
 	static unsigned int HashString(const char *s, size_t len) {
 		unsigned int ret = 0;
 		while (len--) {
@@ -39,7 +42,6 @@
 		}
 		return ret;
 	}
-	static bool IncludesVar(const char *value, const char *key);
 
 public:
 	PropSet *superPS;
@@ -49,19 +51,12 @@
 	void Set(const char *keyVal);
 	void Unset(const char *key, int lenKey=-1);
 	void SetMultiple(const char *s);
-	SString Get(const char *key);
-	SString GetExpanded(const char *key);
-	SString Expand(const char *withVars, int maxExpands=100);
-	int GetInt(const char *key, int defaultValue=0);
-	SString GetWild(const char *keybase, const char *filename);
-	SString GetNewExpand(const char *keybase, const char *filename="");
+	SString Get(const char *key) const;
+	SString GetExpanded(const char *key) const;
+	SString Expand(const char *withVars, int maxExpands=100) const;
+	int GetInt(const char *key, int defaultValue=0) const;
 	void Clear();
-	char *ToString();	// Caller must delete[] the return value
-	bool GetFirst(char **key, char **val);
-	bool GetNext(char **key, char **val);
-	static void SetCaseSensitiveFilenames(bool caseSensitiveFilenames_) {
-		caseSensitiveFilenames = caseSensitiveFilenames_;
-	}
+	char *ToString() const;	// Caller must delete[] the return value
 
 private:
 	// copy-value semantics not implemented
@@ -75,35 +70,30 @@
 public:
 	// Each word contains at least one character - a empty word acts as sentinel at the end.
 	char **words;
-	char **wordsNoCase;
 	char *list;
 	int len;
 	bool onlyLineEnds;	///< Delimited by any white space or only line ends
 	bool sorted;
-	bool sortedNoCase;
 	int starts[256];
 	WordList(bool onlyLineEnds_ = false) :
-		words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
-		sorted(false), sortedNoCase(false) {}
+		words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
+		sorted(false)
+		{}
 	~WordList() { Clear(); }
 	operator bool() { return len ? true : false; }
-	char *operator[](int ind) { return words[ind]; }
 	void Clear();
 	void Set(const char *s);
-	char *Allocate(int size);
-	void SetFromAllocated();
 	bool InList(const char *s);
 	bool InListAbbreviated(const char *s, const char marker);
-	const char *GetNearestWord(const char *wordStart, int searchLen,
-		bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1);
-	char *GetNearestWords(const char *wordStart, int searchLen,
-		bool ignoreCase=false, char otherSeparator='\0', bool exactLen=false);
 };
 
 inline bool IsAlphabetic(unsigned int ch) {
 	return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
 }
 
+#ifdef SCI_NAMESPACE
+}
+#endif
 
 #ifdef _MSC_VER
 // Visual C++ doesn't like the private copy idiom for disabling

Modified: trunk/plugins/editor/scintilla/include/SString.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/SString.h	(original)
+++ trunk/plugins/editor/scintilla/include/SString.h	Sat Nov 15 17:50:33 2008
@@ -8,6 +8,7 @@
 #ifndef SSTRING_H
 #define SSTRING_H
 
+
 #include <string.h>
 
 // These functions are implemented because each platform calls them something different.
@@ -15,6 +16,10 @@
 int CompareNCaseInsensitive(const char *a, const char *b, size_t len);
 bool EqualCaseInsensitive(const char *a, const char *b);
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 // Define another string class.
 // While it would be 'better' to use std::string, that doubles the executable size.
 // An SString may contain embedded nul characters.
@@ -295,4 +300,8 @@
 	return SContainer::StringAllocate(s, len);
 }
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 #endif

Modified: trunk/plugins/editor/scintilla/include/SciLexer.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/SciLexer.h	(original)
+++ trunk/plugins/editor/scintilla/include/SciLexer.h	Sat Nov 15 17:50:33 2008
@@ -91,6 +91,18 @@
 #define SCLEX_INNOSETUP 76
 #define SCLEX_OPAL 77
 #define SCLEX_SPICE 78
+#define SCLEX_D 79
+#define SCLEX_CMAKE 80
+#define SCLEX_GAP 81
+#define SCLEX_PLM 82
+#define SCLEX_PROGRESS 83
+#define SCLEX_ABAQUS 84
+#define SCLEX_ASYMPTOTE 85
+#define SCLEX_R 86
+#define SCLEX_MAGIK 87
+#define SCLEX_POWERSHELL 88
+#define SCLEX_MYSQL 89
+#define SCLEX_PO 90
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -128,6 +140,24 @@
 #define SCE_C_COMMENTDOCKEYWORD 17
 #define SCE_C_COMMENTDOCKEYWORDERROR 18
 #define SCE_C_GLOBALCLASS 19
+#define SCE_D_DEFAULT 0
+#define SCE_D_COMMENT 1
+#define SCE_D_COMMENTLINE 2
+#define SCE_D_COMMENTDOC 3
+#define SCE_D_COMMENTNESTED 4
+#define SCE_D_NUMBER 5
+#define SCE_D_WORD 6
+#define SCE_D_WORD2 7
+#define SCE_D_WORD3 8
+#define SCE_D_TYPEDEF 9
+#define SCE_D_STRING 10
+#define SCE_D_STRINGEOL 11
+#define SCE_D_CHARACTER 12
+#define SCE_D_OPERATOR 13
+#define SCE_D_IDENTIFIER 14
+#define SCE_D_COMMENTLINEDOC 15
+#define SCE_D_COMMENTDOCKEYWORD 16
+#define SCE_D_COMMENTDOCKEYWORDERROR 17
 #define SCE_TCL_DEFAULT 0
 #define SCE_TCL_COMMENT 1
 #define SCE_TCL_COMMENTLINE 2
@@ -293,6 +323,9 @@
 #define SCE_PL_STRING_QR 29
 #define SCE_PL_STRING_QW 30
 #define SCE_PL_POD_VERB 31
+#define SCE_PL_SUB_PROTOTYPE 40
+#define SCE_PL_FORMAT_IDENT 41
+#define SCE_PL_FORMAT 42
 #define SCE_RB_DEFAULT 0
 #define SCE_RB_ERROR 1
 #define SCE_RB_COMMENTLINE 2
@@ -398,6 +431,7 @@
 #define SCE_ERR_ABSF 18
 #define SCE_ERR_TIDY 19
 #define SCE_ERR_JAVA_STACK 20
+#define SCE_ERR_VALUE 21
 #define SCE_BAT_DEFAULT 0
 #define SCE_BAT_COMMENT 1
 #define SCE_BAT_WORD 2
@@ -420,6 +454,7 @@
 #define SCE_DIFF_POSITION 4
 #define SCE_DIFF_DELETED 5
 #define SCE_DIFF_ADDED 6
+#define SCE_DIFF_CHANGED 7
 #define SCE_CONF_DEFAULT 0
 #define SCE_CONF_COMMENT 1
 #define SCE_CONF_NUMBER 2
@@ -584,6 +619,11 @@
 #define SCE_CSS_SINGLESTRING 14
 #define SCE_CSS_IDENTIFIER2 15
 #define SCE_CSS_ATTRIBUTE 16
+#define SCE_CSS_IDENTIFIER3 17
+#define SCE_CSS_PSEUDOELEMENT 18
+#define SCE_CSS_EXTENDED_IDENTIFIER 19
+#define SCE_CSS_EXTENDED_PSEUDOCLASS 20
+#define SCE_CSS_EXTENDED_PSEUDOELEMENT 21
 #define SCE_POV_DEFAULT 0
 #define SCE_POV_COMMENT 1
 #define SCE_POV_COMMENTLINE 2
@@ -710,6 +750,7 @@
 #define SCE_YAML_DOCUMENT 6
 #define SCE_YAML_TEXT 7
 #define SCE_YAML_ERROR 8
+#define SCE_YAML_OPERATOR 9
 #define SCE_TEX_DEFAULT 0
 #define SCE_TEX_SPECIAL 1
 #define SCE_TEX_GROUP 2
@@ -927,6 +968,7 @@
 #define SCE_T3_USER1 17
 #define SCE_T3_USER2 18
 #define SCE_T3_USER3 19
+#define SCE_T3_BRACE 20
 #define SCE_REBOL_DEFAULT 0
 #define SCE_REBOL_COMMENTLINE 1
 #define SCE_REBOL_COMMENTBLOCK 2
@@ -1067,6 +1109,168 @@
 #define SCE_SPICE_DELIMITER 6
 #define SCE_SPICE_VALUE 7
 #define SCE_SPICE_COMMENTLINE 8
+#define SCE_CMAKE_DEFAULT 0
+#define SCE_CMAKE_COMMENT 1
+#define SCE_CMAKE_STRINGDQ 2
+#define SCE_CMAKE_STRINGLQ 3
+#define SCE_CMAKE_STRINGRQ 4
+#define SCE_CMAKE_COMMANDS 5
+#define SCE_CMAKE_PARAMETERS 6
+#define SCE_CMAKE_VARIABLE 7
+#define SCE_CMAKE_USERDEFINED 8
+#define SCE_CMAKE_WHILEDEF 9
+#define SCE_CMAKE_FOREACHDEF 10
+#define SCE_CMAKE_IFDEFINEDEF 11
+#define SCE_CMAKE_MACRODEF 12
+#define SCE_CMAKE_STRINGVAR 13
+#define SCE_CMAKE_NUMBER 14
+#define SCE_GAP_DEFAULT 0
+#define SCE_GAP_IDENTIFIER 1
+#define SCE_GAP_KEYWORD 2
+#define SCE_GAP_KEYWORD2 3
+#define SCE_GAP_KEYWORD3 4
+#define SCE_GAP_KEYWORD4 5
+#define SCE_GAP_STRING 6
+#define SCE_GAP_CHAR 7
+#define SCE_GAP_OPERATOR 8
+#define SCE_GAP_COMMENT 9
+#define SCE_GAP_NUMBER 10
+#define SCE_GAP_STRINGEOL 11
+#define SCE_PLM_DEFAULT 0
+#define SCE_PLM_COMMENT 1
+#define SCE_PLM_STRING 2
+#define SCE_PLM_NUMBER 3
+#define SCE_PLM_IDENTIFIER 4
+#define SCE_PLM_OPERATOR 5
+#define SCE_PLM_CONTROL 6
+#define SCE_PLM_KEYWORD 7
+#define SCE_4GL_DEFAULT 0
+#define SCE_4GL_NUMBER 1
+#define SCE_4GL_WORD 2
+#define SCE_4GL_STRING 3
+#define SCE_4GL_CHARACTER 4
+#define SCE_4GL_PREPROCESSOR 5
+#define SCE_4GL_OPERATOR 6
+#define SCE_4GL_IDENTIFIER 7
+#define SCE_4GL_BLOCK 8
+#define SCE_4GL_END 9
+#define SCE_4GL_COMMENT1 10
+#define SCE_4GL_COMMENT2 11
+#define SCE_4GL_COMMENT3 12
+#define SCE_4GL_COMMENT4 13
+#define SCE_4GL_COMMENT5 14
+#define SCE_4GL_COMMENT6 15
+#define SCE_4GL_DEFAULT_ 16
+#define SCE_4GL_NUMBER_ 17
+#define SCE_4GL_WORD_ 18
+#define SCE_4GL_STRING_ 19
+#define SCE_4GL_CHARACTER_ 20
+#define SCE_4GL_PREPROCESSOR_ 21
+#define SCE_4GL_OPERATOR_ 22
+#define SCE_4GL_IDENTIFIER_ 23
+#define SCE_4GL_BLOCK_ 24
+#define SCE_4GL_END_ 25
+#define SCE_4GL_COMMENT1_ 26
+#define SCE_4GL_COMMENT2_ 27
+#define SCE_4GL_COMMENT3_ 28
+#define SCE_4GL_COMMENT4_ 29
+#define SCE_4GL_COMMENT5_ 30
+#define SCE_4GL_COMMENT6_ 31
+#define SCE_ABAQUS_DEFAULT 0
+#define SCE_ABAQUS_COMMENT 1
+#define SCE_ABAQUS_COMMENTBLOCK 2
+#define SCE_ABAQUS_NUMBER 3
+#define SCE_ABAQUS_STRING 4
+#define SCE_ABAQUS_OPERATOR 5
+#define SCE_ABAQUS_WORD 6
+#define SCE_ABAQUS_PROCESSOR 7
+#define SCE_ABAQUS_COMMAND 8
+#define SCE_ABAQUS_SLASHCOMMAND 9
+#define SCE_ABAQUS_STARCOMMAND 10
+#define SCE_ABAQUS_ARGUMENT 11
+#define SCE_ABAQUS_FUNCTION 12
+#define SCE_ASY_DEFAULT 0
+#define SCE_ASY_COMMENT 1
+#define SCE_ASY_COMMENTLINE 2
+#define SCE_ASY_NUMBER 3
+#define SCE_ASY_WORD 4
+#define SCE_ASY_STRING 5
+#define SCE_ASY_CHARACTER 6
+#define SCE_ASY_OPERATOR 7
+#define SCE_ASY_IDENTIFIER 8
+#define SCE_ASY_STRINGEOL 9
+#define SCE_ASY_COMMENTLINEDOC 10
+#define SCE_ASY_WORD2 11
+#define SCE_R_DEFAULT 0
+#define SCE_R_COMMENT 1
+#define SCE_R_KWORD 2
+#define SCE_R_BASEKWORD 3
+#define SCE_R_OTHERKWORD 4
+#define SCE_R_NUMBER 5
+#define SCE_R_STRING 6
+#define SCE_R_STRING2 7
+#define SCE_R_OPERATOR 8
+#define SCE_R_IDENTIFIER 9
+#define SCE_R_INFIX 10
+#define SCE_R_INFIXEOL 11
+#define SCE_MAGIK_DEFAULT 0
+#define SCE_MAGIK_COMMENT 1
+#define SCE_MAGIK_HYPER_COMMENT 16
+#define SCE_MAGIK_STRING 2
+#define SCE_MAGIK_CHARACTER 3
+#define SCE_MAGIK_NUMBER 4
+#define SCE_MAGIK_IDENTIFIER 5
+#define SCE_MAGIK_OPERATOR 6
+#define SCE_MAGIK_FLOW 7
+#define SCE_MAGIK_CONTAINER 8
+#define SCE_MAGIK_BRACKET_BLOCK 9
+#define SCE_MAGIK_BRACE_BLOCK 10
+#define SCE_MAGIK_SQBRACKET_BLOCK 11
+#define SCE_MAGIK_UNKNOWN_KEYWORD 12
+#define SCE_MAGIK_KEYWORD 13
+#define SCE_MAGIK_PRAGMA 14
+#define SCE_MAGIK_SYMBOL 15
+#define SCE_POWERSHELL_DEFAULT 0
+#define SCE_POWERSHELL_COMMENT 1
+#define SCE_POWERSHELL_STRING 2
+#define SCE_POWERSHELL_CHARACTER 3
+#define SCE_POWERSHELL_NUMBER 4
+#define SCE_POWERSHELL_VARIABLE 5
+#define SCE_POWERSHELL_OPERATOR 6
+#define SCE_POWERSHELL_IDENTIFIER 7
+#define SCE_POWERSHELL_KEYWORD 8
+#define SCE_POWERSHELL_CMDLET 9
+#define SCE_POWERSHELL_ALIAS 10
+#define SCE_MYSQL_DEFAULT 0
+#define SCE_MYSQL_COMMENT 1
+#define SCE_MYSQL_COMMENTLINE 2
+#define SCE_MYSQL_VARIABLE 3
+#define SCE_MYSQL_SYSTEMVARIABLE 4
+#define SCE_MYSQL_KNOWNSYSTEMVARIABLE 5
+#define SCE_MYSQL_NUMBER 6
+#define SCE_MYSQL_MAJORKEYWORD 7
+#define SCE_MYSQL_KEYWORD 8
+#define SCE_MYSQL_DATABASEOBJECT 9
+#define SCE_MYSQL_PROCEDUREKEYWORD 10
+#define SCE_MYSQL_STRING 11
+#define SCE_MYSQL_SQSTRING 12
+#define SCE_MYSQL_DQSTRING 13
+#define SCE_MYSQL_OPERATOR 14
+#define SCE_MYSQL_FUNCTION 15
+#define SCE_MYSQL_IDENTIFIER 16
+#define SCE_MYSQL_QUOTEDIDENTIFIER 17
+#define SCE_MYSQL_USER1 18
+#define SCE_MYSQL_USER2 19
+#define SCE_MYSQL_USER3 20
+#define SCE_PO_DEFAULT 0
+#define SCE_PO_COMMENT 1
+#define SCE_PO_MSGID 2
+#define SCE_PO_MSGID_TEXT 3
+#define SCE_PO_MSGSTR 4
+#define SCE_PO_MSGSTR_TEXT 5
+#define SCE_PO_MSGCTXT 6
+#define SCE_PO_MSGCTXT_TEXT 7
+#define SCE_PO_FUZZY 8
 #define SCLEX_ASP 29
 #define SCLEX_PHP 30
 //--Autogenerated -- end of section automatically generated from Scintilla.iface

Modified: trunk/plugins/editor/scintilla/include/Scintilla.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/Scintilla.h	(original)
+++ trunk/plugins/editor/scintilla/include/Scintilla.h	Sat Nov 15 17:50:33 2008
@@ -124,6 +124,7 @@
 #define SC_MARK_ARROWS 24
 #define SC_MARK_PIXMAP 25
 #define SC_MARK_FULLRECT 26
+#define SC_MARK_LEFTRECT 27
 #define SC_MARK_CHARACTER 10000
 #define SC_MARKNUM_FOLDEREND 25
 #define SC_MARKNUM_FOLDEROPENMID 26
@@ -165,7 +166,7 @@
 #define STYLE_INDENTGUIDE 37
 #define STYLE_CALLTIP 38
 #define STYLE_LASTPREDEFINED 39
-#define STYLE_MAX 127
+#define STYLE_MAX 255
 #define SC_CHARSET_ANSI 0
 #define SC_CHARSET_DEFAULT 1
 #define SC_CHARSET_BALTIC 186
@@ -200,6 +201,19 @@
 #define SC_CASE_MIXED 0
 #define SC_CASE_UPPER 1
 #define SC_CASE_LOWER 2
+#define SCI_STYLEGETFORE 2481
+#define SCI_STYLEGETBACK 2482
+#define SCI_STYLEGETBOLD 2483
+#define SCI_STYLEGETITALIC 2484
+#define SCI_STYLEGETSIZE 2485
+#define SCI_STYLEGETFONT 2486
+#define SCI_STYLEGETEOLFILLED 2487
+#define SCI_STYLEGETUNDERLINE 2488
+#define SCI_STYLEGETCASE 2489
+#define SCI_STYLEGETCHARACTERSET 2490
+#define SCI_STYLEGETVISIBLE 2491
+#define SCI_STYLEGETCHANGEABLE 2492
+#define SCI_STYLEGETHOTSPOT 2493
 #define SCI_STYLESETCASE 2060
 #define SCI_STYLESETCHARACTERSET 2066
 #define SCI_STYLESETHOTSPOT 2409
@@ -207,6 +221,8 @@
 #define SCI_SETSELBACK 2068
 #define SCI_GETSELALPHA 2477
 #define SCI_SETSELALPHA 2478
+#define SCI_GETSELEOLFILLED 2479
+#define SCI_SETSELEOLFILLED 2480
 #define SCI_SETCARETFORE 2069
 #define SCI_ASSIGNCMDKEY 2070
 #define SCI_CLEARCMDKEY 2071
@@ -218,7 +234,6 @@
 #define SCI_SETWORDCHARS 2077
 #define SCI_BEGINUNDOACTION 2078
 #define SCI_ENDUNDOACTION 2079
-#define INDIC_MAX 7
 #define INDIC_PLAIN 0
 #define INDIC_SQUIGGLE 1
 #define INDIC_TT 2
@@ -227,6 +242,8 @@
 #define INDIC_HIDDEN 5
 #define INDIC_BOX 6
 #define INDIC_ROUNDBOX 7
+#define INDIC_MAX 31
+#define INDIC_CONTAINER 8
 #define INDIC0_MASK 0x20
 #define INDIC1_MASK 0x40
 #define INDIC2_MASK 0x80
@@ -235,6 +252,8 @@
 #define SCI_INDICGETSTYLE 2081
 #define SCI_INDICSETFORE 2082
 #define SCI_INDICGETFORE 2083
+#define SCI_INDICSETUNDER 2510
+#define SCI_INDICGETUNDER 2511
 #define SCI_SETWHITESPACEFORE 2084
 #define SCI_SETWHITESPACEBACK 2085
 #define SCI_SETSTYLEBITS 2090
@@ -286,6 +305,10 @@
 #define SCI_GETCOLUMN 2129
 #define SCI_SETHSCROLLBAR 2130
 #define SCI_GETHSCROLLBAR 2131
+#define SC_IV_NONE 0
+#define SC_IV_REAL 1
+#define SC_IV_LOOKFORWARD 2
+#define SC_IV_LOOKBOTH 3
 #define SCI_SETINDENTATIONGUIDES 2132
 #define SCI_GETINDENTATIONGUIDES 2133
 #define SCI_SETHIGHLIGHTGUIDE 2134
@@ -436,6 +459,8 @@
 #define SCI_GETLAYOUTCACHE 2273
 #define SCI_SETSCROLLWIDTH 2274
 #define SCI_GETSCROLLWIDTH 2275
+#define SCI_SETSCROLLWIDTHTRACKING 2516
+#define SCI_GETSCROLLWIDTHTRACKING 2517
 #define SCI_TEXTWIDTH 2276
 #define SCI_SETENDATLASTLINE 2277
 #define SCI_GETENDATLASTLINE 2278
@@ -487,6 +512,7 @@
 #define SCI_ZOOMOUT 2334
 #define SCI_DELWORDLEFT 2335
 #define SCI_DELWORDRIGHT 2336
+#define SCI_DELWORDRIGHTEND 2518
 #define SCI_LINECUT 2337
 #define SCI_LINEDELETE 2338
 #define SCI_LINETRANSPOSE 2339
@@ -572,9 +598,13 @@
 #define SCI_SETPRINTWRAPMODE 2406
 #define SCI_GETPRINTWRAPMODE 2407
 #define SCI_SETHOTSPOTACTIVEFORE 2410
+#define SCI_GETHOTSPOTACTIVEFORE 2494
 #define SCI_SETHOTSPOTACTIVEBACK 2411
+#define SCI_GETHOTSPOTACTIVEBACK 2495
 #define SCI_SETHOTSPOTACTIVEUNDERLINE 2412
+#define SCI_GETHOTSPOTACTIVEUNDERLINE 2496
 #define SCI_SETHOTSPOTSINGLELINE 2421
+#define SCI_GETHOTSPOTSINGLELINE 2497
 #define SCI_PARADOWN 2413
 #define SCI_PARADOWNEXTEND 2414
 #define SCI_PARAUP 2415
@@ -626,6 +656,27 @@
 #define SC_ALPHA_NOALPHA 256
 #define SCI_SETCARETLINEBACKALPHA 2470
 #define SCI_GETCARETLINEBACKALPHA 2471
+#define CARETSTYLE_INVISIBLE 0
+#define CARETSTYLE_LINE 1
+#define CARETSTYLE_BLOCK 2
+#define SCI_SETCARETSTYLE 2512
+#define SCI_GETCARETSTYLE 2513
+#define SCI_SETINDICATORCURRENT 2500
+#define SCI_GETINDICATORCURRENT 2501
+#define SCI_SETINDICATORVALUE 2502
+#define SCI_GETINDICATORVALUE 2503
+#define SCI_INDICATORFILLRANGE 2504
+#define SCI_INDICATORCLEARRANGE 2505
+#define SCI_INDICATORALLONFOR 2506
+#define SCI_INDICATORVALUEAT 2507
+#define SCI_INDICATORSTART 2508
+#define SCI_INDICATOREND 2509
+#define SCI_SETPOSITIONCACHE 2514
+#define SCI_GETPOSITIONCACHE 2515
+#define SCI_COPYALLOWLINE 2519
+#define SCI_GETCHARACTERPOINTER 2520
+#define SCI_SETKEYSUNICODE 2521
+#define SCI_GETKEYSUNICODE 2522
 #define SCI_STARTRECORD 3001
 #define SCI_STOPRECORD 3002
 #define SCI_SETLEXER 4001
@@ -653,7 +704,10 @@
 #define SC_MOD_BEFOREINSERT 0x400
 #define SC_MOD_BEFOREDELETE 0x800
 #define SC_MULTILINEUNDOREDO 0x1000
-#define SC_MODEVENTMASKALL 0x1FFF
+#define SC_STARTACTION 0x2000
+#define SC_MOD_CHANGEINDICATOR 0x4000
+#define SC_MOD_CHANGELINESTATE 0x8000
+#define SC_MODEVENTMASKALL 0xFFFF
 #define SCEN_CHANGE 768
 #define SCEN_SETFOCUS 512
 #define SCEN_KILLFOCUS 256
@@ -674,6 +728,9 @@
 #define SCK_ADD 310
 #define SCK_SUBTRACT 311
 #define SCK_DIVIDE 312
+#define SCK_WIN 313
+#define SCK_RWIN 314
+#define SCK_MENU 315
 #define SCMOD_NORM 0
 #define SCMOD_SHIFT 1
 #define SCMOD_CTRL 2
@@ -700,12 +757,19 @@
 #define SCN_HOTSPOTDOUBLECLICK 2020
 #define SCN_CALLTIPCLICK 2021
 #define SCN_AUTOCSELECTION 2022
+#define SCN_INDICATORCLICK 2023
+#define SCN_INDICATORRELEASE 2024
+#define SCN_AUTOCCANCELLED 2025
 //--Autogenerated -- end of section automatically generated from Scintilla.iface
 
 // These structures are defined to be exactly the same shape as the Win32
 // CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
 // So older code that treats Scintilla as a RichEdit will work.
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 struct CharacterRange {
 	long cpMin;
 	long cpMax;
@@ -767,6 +831,10 @@
 	int y;		// SCN_DWELLSTART, SCN_DWELLEND
 };
 
+#ifdef SCI_NAMESPACE
+}
+#endif
+
 // Deprecation section listing all API features that are deprecated and will
 // will be removed completely in a future version.
 // To enable these features define INCLUDE_DEPRECATED_FEATURES

Modified: trunk/plugins/editor/scintilla/include/Scintilla.iface
==============================================================================
--- trunk/plugins/editor/scintilla/include/Scintilla.iface	(original)
+++ trunk/plugins/editor/scintilla/include/Scintilla.iface	Sat Nov 15 17:50:33 2008
@@ -104,7 +104,7 @@
 # Set all style bytes to 0, remove all folding information.
 fun void ClearDocumentStyle=2005(,)
 
-# Returns the number of characters in the document.
+# Returns the number of bytes in the document.
 get int GetLength=2006(,)
 
 # Returns the character byte at the position.
@@ -268,6 +268,7 @@
 val SC_MARK_ARROWS=24
 val SC_MARK_PIXMAP=25
 val SC_MARK_FULLRECT=26
+val SC_MARK_LEFTRECT=27
 
 val SC_MARK_CHARACTER=10000
 
@@ -360,7 +361,7 @@
 val STYLE_INDENTGUIDE=37
 val STYLE_CALLTIP=38
 val STYLE_LASTPREDEFINED=39
-val STYLE_MAX=127
+val STYLE_MAX=255
 
 # Character set identifiers are used in StyleSetCharacterSet.
 # The values are the same as the Windows *_CHARSET values.
@@ -421,6 +422,48 @@
 val SC_CASE_MIXED=0
 val SC_CASE_UPPER=1
 val SC_CASE_LOWER=2
+
+# Get the foreground colour of a style.
+get colour StyleGetFore=2481(int style,)
+
+# Get the background colour of a style.
+get colour StyleGetBack=2482(int style,)
+
+# Get is a style bold or not.
+get bool StyleGetBold=2483(int style,)
+
+# Get is a style italic or not.
+get bool StyleGetItalic=2484(int style,)
+
+# Get the size of characters of a style.
+get int StyleGetSize=2485(int style,)
+
+# Get the font of a style.
+# Returns the length of the fontName
+fun int StyleGetFont=2486(int style, stringresult fontName)
+
+# Get is a style to have its end of line filled or not.
+get bool StyleGetEOLFilled=2487(int style,)
+
+# Get is a style underlined or not.
+get bool StyleGetUnderline=2488(int style,)
+
+# Get is a style mixed case, or to force upper or lower case.
+get int StyleGetCase=2489(int style,)
+
+# Get the character get of the font in a style.
+get int StyleGetCharacterSet=2490(int style,)
+
+# Get is a style visible or not.
+get bool StyleGetVisible=2491(int style,)
+
+# Get is a style changeable or not (read only).
+# Experimental feature, currently buggy.
+get bool StyleGetChangeable=2492(int style,)
+
+# Get is a style a hotspot or not.
+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)
 
@@ -442,6 +485,12 @@
 # Set the alpha of the selection.
 set void SetSelAlpha=2478(int alpha,)
 
+# Is the selection end of line filled?
+get bool GetSelEOLFilled=2479(,)
+
+# Set the selection to have its end of line filled or not.
+set void SetSelEOLFilled=2480(bool filled,)
+
 # Set the foreground colour of the caret.
 set void SetCaretFore=2069(colour fore,)
 
@@ -467,7 +516,7 @@
 set void SetCaretPeriod=2076(int periodMilliseconds,)
 
 # Set the set of characters making up words for when moving or selecting by word.
-# First sets deaults like SetCharsDefault.
+# First sets defaults like SetCharsDefault.
 set void SetWordChars=2077(, string characters)
 
 # Start a sequence of actions that is undone and redone as a unit.
@@ -477,8 +526,8 @@
 # End a sequence of actions that is undone and redone as a unit.
 fun void EndUndoAction=2079(,)
 
+# Indicator style enumeration and some constants
 enu IndicatorStyle=INDIC_
-val INDIC_MAX=7
 val INDIC_PLAIN=0
 val INDIC_SQUIGGLE=1
 val INDIC_TT=2
@@ -487,6 +536,8 @@
 val INDIC_HIDDEN=5
 val INDIC_BOX=6
 val INDIC_ROUNDBOX=7
+val INDIC_MAX=31
+val INDIC_CONTAINER=8
 val INDIC0_MASK=0x20
 val INDIC1_MASK=0x40
 val INDIC2_MASK=0x80
@@ -504,6 +555,12 @@
 # Retrieve the foreground colour of an indicator.
 get colour IndicGetFore=2083(int indic,)
 
+# Set an indicator to draw under text or over(default).
+set void IndicSetUnder=2510(int indic, bool under)
+
+# Retrieve whether indicator drawn under or over text.
+get bool IndicGetUnder=2511(int indic,)
+
 # Set the foreground colour of all whitespace and whether to use this setting.
 fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
 
@@ -671,11 +728,17 @@
 # Is the horizontal scroll bar visible?
 get bool GetHScrollBar=2131(,)
 
+enu IndentView=SC_IV_
+val SC_IV_NONE=0
+val SC_IV_REAL=1
+val SC_IV_LOOKFORWARD=2
+val SC_IV_LOOKBOTH=3
+
 # Show or hide indentation guides.
-set void SetIndentationGuides=2132(bool show,)
+set void SetIndentationGuides=2132(int indentView,)
 
 # Are the indentation guides visible?
-get bool GetIndentationGuides=2133(,)
+get int GetIndentationGuides=2133(,)
 
 # Set the highlighted indentation guide column.
 # 0 = no highlighted guide.
@@ -1087,6 +1150,12 @@
 # Retrieve the document width assumed for scrolling.
 get int GetScrollWidth=2275(,)
 
+# Sets whether the maximum width line displayed is used to set scroll width.
+set void SetScrollWidthTracking=2516(bool tracking,)
+
+# Retrieve whether the scroll width tracks wide lines.
+get bool GetScrollWidthTracking=2517(,)
+
 # Measure the pixel width of some text in a particular style.
 # NUL terminated text argument.
 # Does not handle tab or control characters.
@@ -1250,6 +1319,9 @@
 # Delete the word to the right of the caret.
 fun void DelWordRight=2336(,)
 
+# Delete the word to the right of the caret, but not the trailing non-word characters.
+fun void DelWordRightEnd=2518(,)
+
 # Cut the line containing the caret.
 fun void LineCut=2337(,)
 
@@ -1311,7 +1383,7 @@
 # Move the caret inside current view if it's not there already.
 fun void MoveCaretInsideView=2401(,)
 
-# How many characters are on a line, not including end of line characters?
+# How many characters are on a line, including end of line characters?
 fun int LineLength=2350(int line,)
 
 # Highlight the characters at two positions.
@@ -1464,7 +1536,7 @@
 # Set the focus to this Scintilla widget.
 fun void GrabFocus=2400(,)
 
-enu CaretPolicy = CARET_
+enu CaretPolicy=CARET_
 # Caret policy, used by SetXCaretPolicy and SetYCaretPolicy.
 # If CARET_SLOP is set, we can define a slop value: caretSlop.
 # This value defines an unwanted zone (UZ) where the caret is... unwanted.
@@ -1505,15 +1577,27 @@
 # Set a fore colour for active hotspots.
 set void SetHotspotActiveFore=2410(bool useSetting, colour fore)
 
+# Get the fore colour for active hotspots.
+get colour GetHotspotActiveFore=2494(,)
+
 # Set a back colour for active hotspots.
 set void SetHotspotActiveBack=2411(bool useSetting, colour back)
 
+# Get the back colour for active hotspots.
+get colour GetHotspotActiveBack=2495(,)
+
 # Enable / Disable underlining active hotspots.
 set void SetHotspotActiveUnderline=2412(bool underline,)
 
+# Get whether underlining for active hotspots.
+get bool GetHotspotActiveUnderline=2496(,)
+
 # Limit hotspots to single line so hotspots on two lines don't merge.
 set void SetHotspotSingleLine=2421(bool singleLine,)
 
+# Get the HotspotSingleLine property
+get bool GetHotspotSingleLine=2497(,)
+
 # Move caret between paragraphs (delimited by empty lines).
 fun void ParaDown=2413(,)
 fun void ParaDownExtend=2414(,)
@@ -1666,6 +1750,66 @@
 # Get the background alpha of the caret line.
 get int GetCaretLineBackAlpha=2471(,)
 
+enu CaretStyle=CARETSTYLE_
+val CARETSTYLE_INVISIBLE=0
+val CARETSTYLE_LINE=1
+val CARETSTYLE_BLOCK=2
+
+# Set the style of the caret to be drawn.
+set void SetCaretStyle=2512(int caretStyle,)
+
+# Returns the current style of the caret.
+get int GetCaretStyle=2513(,)
+
+# Set the indicator used for IndicatorFillRange and IndicatorClearRange
+set void SetIndicatorCurrent=2500(int indicator,)
+
+# Get the current indicator
+get int GetIndicatorCurrent=2501(,)
+
+# Set the value used for IndicatorFillRange
+set void SetIndicatorValue=2502(int value,)
+
+# Get the current indicator vaue
+get int GetIndicatorValue=2503(,)
+
+# Turn a indicator on over a range.
+fun void IndicatorFillRange=2504(int position, int fillLength)
+
+# Turn a indicator off over a range.
+fun void IndicatorClearRange=2505(int position, int clearLength)
+
+# Are any indicators present at position?
+fun int IndicatorAllOnFor=2506(int position,)
+
+# What value does a particular indicator have at at a position?
+fun int IndicatorValueAt=2507(int indicator, int position)
+
+# Where does a particular indicator start?
+fun int IndicatorStart=2508(int indicator, int position)
+
+# Where does a particular indicator end?
+fun int IndicatorEnd=2509(int indicator, int position)
+
+# Set number of entries in position cache
+set void SetPositionCache=2514(int size,)
+
+# How many entries are allocated to the position cache?
+get int GetPositionCache=2515(,)
+
+# Copy the selection, if selection empty copy the line with the caret
+fun void CopyAllowLine=2519(,)
+
+# Compact the document buffer and return a read-only pointer to the
+# characters in the document.
+get int GetCharacterPointer=2520(,)
+
+# Always interpret keyboard input as Unicode
+set void SetKeysUnicode=2521(bool keysUnicode,)
+
+# Are keys always interpreted as Unicode?
+get bool GetKeysUnicode=2522(,)
+
 # Start notifying the container of all key presses and commands.
 fun void StartRecord=3001(,)
 
@@ -1728,7 +1872,10 @@
 val SC_MOD_BEFOREINSERT=0x400
 val SC_MOD_BEFOREDELETE=0x800
 val SC_MULTILINEUNDOREDO=0x1000
-val SC_MODEVENTMASKALL=0x1FFF
+val SC_STARTACTION=0x2000
+val SC_MOD_CHANGEINDICATOR=0x4000
+val SC_MOD_CHANGELINESTATE=0x8000
+val SC_MODEVENTMASKALL=0xFFFF
 
 # For compatibility, these go through the COMMAND notification rather than NOTIFY
 # and should have had exactly the same values as the EN_* constants.
@@ -1760,6 +1907,9 @@
 val SCK_ADD=310
 val SCK_SUBTRACT=311
 val SCK_DIVIDE=312
+val SCK_WIN=313
+val SCK_RWIN=314
+val SCK_MENU=315
 
 enu KeyMod=SCMOD_
 val SCMOD_NORM=0
@@ -1847,6 +1997,18 @@
 val SCLEX_INNOSETUP=76
 val SCLEX_OPAL=77
 val SCLEX_SPICE=78
+val SCLEX_D=79
+val SCLEX_CMAKE=80
+val SCLEX_GAP=81
+val SCLEX_PLM=82
+val SCLEX_PROGRESS=83
+val SCLEX_ABAQUS=84
+val SCLEX_ASYMPTOTE=85
+val SCLEX_R=86
+val SCLEX_MAGIK=87
+val SCLEX_POWERSHELL=88
+val SCLEX_MYSQL=89
+val SCLEX_PO=90
 
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -1893,6 +2055,26 @@
 val SCE_C_COMMENTDOCKEYWORD=17
 val SCE_C_COMMENTDOCKEYWORDERROR=18
 val SCE_C_GLOBALCLASS=19
+# Lexical states for SCLEX_D
+lex D=SCLEX_D SCE_D_
+val SCE_D_DEFAULT=0
+val SCE_D_COMMENT=1
+val SCE_D_COMMENTLINE=2
+val SCE_D_COMMENTDOC=3
+val SCE_D_COMMENTNESTED=4
+val SCE_D_NUMBER=5
+val SCE_D_WORD=6
+val SCE_D_WORD2=7
+val SCE_D_WORD3=8
+val SCE_D_TYPEDEF=9
+val SCE_D_STRING=10
+val SCE_D_STRINGEOL=11
+val SCE_D_CHARACTER=12
+val SCE_D_OPERATOR=13
+val SCE_D_IDENTIFIER=14
+val SCE_D_COMMENTLINEDOC=15
+val SCE_D_COMMENTDOCKEYWORD=16
+val SCE_D_COMMENTDOCKEYWORDERROR=17
 # Lexical states for SCLEX_TCL
 lex TCL=SCLEX_TCL SCE_TCL_
 val SCE_TCL_DEFAULT=0
@@ -2079,6 +2261,9 @@
 val SCE_PL_STRING_QR=29
 val SCE_PL_STRING_QW=30
 val SCE_PL_POD_VERB=31
+val SCE_PL_SUB_PROTOTYPE=40
+val SCE_PL_FORMAT_IDENT=41
+val SCE_PL_FORMAT=42
 # Lexical states for SCLEX_RUBY
 lex Ruby=SCLEX_RUBY SCE_RB_
 val SCE_RB_DEFAULT=0
@@ -2198,6 +2383,7 @@
 val SCE_ERR_ABSF=18
 val SCE_ERR_TIDY=19
 val SCE_ERR_JAVA_STACK=20
+val SCE_ERR_VALUE=21
 # Lexical states for SCLEX_BATCH
 lex Batch=SCLEX_BATCH SCE_BAT_
 val SCE_BAT_DEFAULT=0
@@ -2226,6 +2412,7 @@
 val SCE_DIFF_POSITION=4
 val SCE_DIFF_DELETED=5
 val SCE_DIFF_ADDED=6
+val SCE_DIFF_CHANGED=7
 # Lexical states for SCLEX_CONF (Apache Configuration Files Lexer)
 lex Conf=SCLEX_CONF SCE_CONF_
 val SCE_CONF_DEFAULT=0
@@ -2419,6 +2606,11 @@
 val SCE_CSS_SINGLESTRING=14
 val SCE_CSS_IDENTIFIER2=15
 val SCE_CSS_ATTRIBUTE=16
+val SCE_CSS_IDENTIFIER3=17
+val SCE_CSS_PSEUDOELEMENT=18
+val SCE_CSS_EXTENDED_IDENTIFIER=19
+val SCE_CSS_EXTENDED_PSEUDOCLASS=20
+val SCE_CSS_EXTENDED_PSEUDOELEMENT=21
 # Lexical states for SCLEX_POV
 lex POV=SCLEX_POV SCE_POV_
 val SCE_POV_DEFAULT=0
@@ -2563,6 +2755,7 @@
 val SCE_YAML_DOCUMENT=6
 val SCE_YAML_TEXT=7
 val SCE_YAML_ERROR=8
+val SCE_YAML_OPERATOR=9
 # Lexical states for SCLEX_TEX
 lex TeX=SCLEX_TEX SCE_TEX_
 val SCE_TEX_DEFAULT=0
@@ -2812,6 +3005,7 @@
 val SCE_T3_USER1=17
 val SCE_T3_USER2=18
 val SCE_T3_USER3=19
+val SCE_T3_BRACE=20
 # Lexical states for SCLEX_REBOL
 lex Rebol=SCLEX_REBOL SCE_REBOL_
 val SCE_REBOL_DEFAULT=0
@@ -2968,6 +3162,190 @@
 val SCE_SPICE_DELIMITER=6
 val SCE_SPICE_VALUE=7
 val SCE_SPICE_COMMENTLINE=8
+# Lexical states for SCLEX_CMAKE
+lex CMAKE=SCLEX_CMAKE SCE_CMAKE_
+val SCE_CMAKE_DEFAULT=0
+val SCE_CMAKE_COMMENT=1
+val SCE_CMAKE_STRINGDQ=2
+val SCE_CMAKE_STRINGLQ=3
+val SCE_CMAKE_STRINGRQ=4
+val SCE_CMAKE_COMMANDS=5
+val SCE_CMAKE_PARAMETERS=6
+val SCE_CMAKE_VARIABLE=7
+val SCE_CMAKE_USERDEFINED=8
+val SCE_CMAKE_WHILEDEF=9
+val SCE_CMAKE_FOREACHDEF=10
+val SCE_CMAKE_IFDEFINEDEF=11
+val SCE_CMAKE_MACRODEF=12
+val SCE_CMAKE_STRINGVAR=13
+val SCE_CMAKE_NUMBER=14
+# Lexical states for SCLEX_GAP
+lex Gap=SCLEX_GAP SCE_GAP_
+val SCE_GAP_DEFAULT=0
+val SCE_GAP_IDENTIFIER=1
+val SCE_GAP_KEYWORD=2
+val SCE_GAP_KEYWORD2=3
+val SCE_GAP_KEYWORD3=4
+val SCE_GAP_KEYWORD4=5
+val SCE_GAP_STRING=6
+val SCE_GAP_CHAR=7
+val SCE_GAP_OPERATOR=8
+val SCE_GAP_COMMENT=9
+val SCE_GAP_NUMBER=10
+val SCE_GAP_STRINGEOL=11
+# Lexical state for SCLEX_PLM
+lex PLM=SCLEX_PLM SCE_PLM_
+val SCE_PLM_DEFAULT=0
+val SCE_PLM_COMMENT=1
+val SCE_PLM_STRING=2
+val SCE_PLM_NUMBER=3
+val SCE_PLM_IDENTIFIER=4
+val SCE_PLM_OPERATOR=5
+val SCE_PLM_CONTROL=6
+val SCE_PLM_KEYWORD=7
+# Lexical state for SCLEX_PROGRESS
+lex Progress=SCLEX_PROGRESS SCE_4GL_
+val SCE_4GL_DEFAULT=0
+val SCE_4GL_NUMBER=1
+val SCE_4GL_WORD=2
+val SCE_4GL_STRING=3
+val SCE_4GL_CHARACTER=4
+val SCE_4GL_PREPROCESSOR=5
+val SCE_4GL_OPERATOR=6
+val SCE_4GL_IDENTIFIER=7
+val SCE_4GL_BLOCK=8
+val SCE_4GL_END=9
+val SCE_4GL_COMMENT1=10
+val SCE_4GL_COMMENT2=11
+val SCE_4GL_COMMENT3=12
+val SCE_4GL_COMMENT4=13
+val SCE_4GL_COMMENT5=14
+val SCE_4GL_COMMENT6=15
+val SCE_4GL_DEFAULT_=16
+val SCE_4GL_NUMBER_=17
+val SCE_4GL_WORD_=18
+val SCE_4GL_STRING_=19
+val SCE_4GL_CHARACTER_=20
+val SCE_4GL_PREPROCESSOR_=21
+val SCE_4GL_OPERATOR_=22
+val SCE_4GL_IDENTIFIER_=23
+val SCE_4GL_BLOCK_=24
+val SCE_4GL_END_=25
+val SCE_4GL_COMMENT1_=26
+val SCE_4GL_COMMENT2_=27
+val SCE_4GL_COMMENT3_=28
+val SCE_4GL_COMMENT4_=29
+val SCE_4GL_COMMENT5_=30
+val SCE_4GL_COMMENT6_=31
+# Lexical states for SCLEX_ABAQUS
+lex ABAQUS=SCLEX_ABAQUS SCE_ABAQUS_
+val SCE_ABAQUS_DEFAULT=0
+val SCE_ABAQUS_COMMENT=1
+val SCE_ABAQUS_COMMENTBLOCK=2
+val SCE_ABAQUS_NUMBER=3
+val SCE_ABAQUS_STRING=4
+val SCE_ABAQUS_OPERATOR=5
+val SCE_ABAQUS_WORD=6
+val SCE_ABAQUS_PROCESSOR=7
+val SCE_ABAQUS_COMMAND=8
+val SCE_ABAQUS_SLASHCOMMAND=9
+val SCE_ABAQUS_STARCOMMAND=10
+val SCE_ABAQUS_ARGUMENT=11
+val SCE_ABAQUS_FUNCTION=12
+# Lexical states for SCLEX_ASYMPTOTE
+lex Asymptote=SCLEX_ASYMPTOTE SCE_ASY_
+val SCE_ASY_DEFAULT=0
+val SCE_ASY_COMMENT=1
+val SCE_ASY_COMMENTLINE=2
+val SCE_ASY_NUMBER=3
+val SCE_ASY_WORD=4
+val SCE_ASY_STRING=5
+val SCE_ASY_CHARACTER=6
+val SCE_ASY_OPERATOR=7
+val SCE_ASY_IDENTIFIER=8
+val SCE_ASY_STRINGEOL=9
+val SCE_ASY_COMMENTLINEDOC=10
+val SCE_ASY_WORD2=11
+# Lexical states for SCLEX_R
+lex R=SCLEX_R SCE_R_
+val SCE_R_DEFAULT=0
+val SCE_R_COMMENT=1
+val SCE_R_KWORD=2
+val SCE_R_BASEKWORD=3
+val SCE_R_OTHERKWORD=4
+val SCE_R_NUMBER=5
+val SCE_R_STRING=6
+val SCE_R_STRING2=7
+val SCE_R_OPERATOR=8
+val SCE_R_IDENTIFIER=9
+val SCE_R_INFIX=10
+val SCE_R_INFIXEOL=11
+# Lexical state for SCLEX_MAGIKSF
+lex MagikSF=SCLEX_MAGIKSF SCE_MAGIK_
+val SCE_MAGIK_DEFAULT=0
+val SCE_MAGIK_COMMENT=1
+val SCE_MAGIK_HYPER_COMMENT=16
+val SCE_MAGIK_STRING=2
+val SCE_MAGIK_CHARACTER=3
+val SCE_MAGIK_NUMBER=4
+val SCE_MAGIK_IDENTIFIER=5
+val SCE_MAGIK_OPERATOR=6
+val SCE_MAGIK_FLOW=7
+val SCE_MAGIK_CONTAINER=8
+val SCE_MAGIK_BRACKET_BLOCK=9
+val SCE_MAGIK_BRACE_BLOCK=10
+val SCE_MAGIK_SQBRACKET_BLOCK=11
+val SCE_MAGIK_UNKNOWN_KEYWORD=12
+val SCE_MAGIK_KEYWORD=13
+val SCE_MAGIK_PRAGMA=14
+val SCE_MAGIK_SYMBOL=15
+# Lexical state for SCLEX_POWERSHELL
+lex PowerShell=SCLEX_POWERSHELL SCE_POWERSHELL_
+val SCE_POWERSHELL_DEFAULT=0
+val SCE_POWERSHELL_COMMENT=1
+val SCE_POWERSHELL_STRING=2
+val SCE_POWERSHELL_CHARACTER=3
+val SCE_POWERSHELL_NUMBER=4
+val SCE_POWERSHELL_VARIABLE=5
+val SCE_POWERSHELL_OPERATOR=6
+val SCE_POWERSHELL_IDENTIFIER=7
+val SCE_POWERSHELL_KEYWORD=8
+val SCE_POWERSHELL_CMDLET=9
+val SCE_POWERSHELL_ALIAS=10
+# Lexical state for SCLEX_MYSQL
+lex MySQL=SCLEX_MYSQL SCE_MYSQL_
+val SCE_MYSQL_DEFAULT=0
+val SCE_MYSQL_COMMENT=1
+val SCE_MYSQL_COMMENTLINE=2
+val SCE_MYSQL_VARIABLE=3
+val SCE_MYSQL_SYSTEMVARIABLE=4
+val SCE_MYSQL_KNOWNSYSTEMVARIABLE=5
+val SCE_MYSQL_NUMBER=6
+val SCE_MYSQL_MAJORKEYWORD=7
+val SCE_MYSQL_KEYWORD=8
+val SCE_MYSQL_DATABASEOBJECT=9
+val SCE_MYSQL_PROCEDUREKEYWORD=10
+val SCE_MYSQL_STRING=11
+val SCE_MYSQL_SQSTRING=12
+val SCE_MYSQL_DQSTRING=13
+val SCE_MYSQL_OPERATOR=14
+val SCE_MYSQL_FUNCTION=15
+val SCE_MYSQL_IDENTIFIER=16
+val SCE_MYSQL_QUOTEDIDENTIFIER=17
+val SCE_MYSQL_USER1=18
+val SCE_MYSQL_USER2=19
+val SCE_MYSQL_USER3=20
+# Lexical state for SCLEX_PO
+lex Po=SCLEX_PO SCE_PO_
+val SCE_PO_DEFAULT=0
+val SCE_PO_COMMENT=1
+val SCE_PO_MSGID=2
+val SCE_PO_MSGID_TEXT=3
+val SCE_PO_MSGSTR=4
+val SCE_PO_MSGSTR_TEXT=5
+val SCE_PO_MSGCTXT=6
+val SCE_PO_MSGCTXT_TEXT=7
+val SCE_PO_FUZZY=8
 
 # Events
 
@@ -2994,6 +3372,9 @@
 evt void HotSpotDoubleClick=2020(int modifiers, int position)
 evt void CallTipClick=2021(int position)
 evt void AutoCSelection=2022(string text)
+evt void IndicatorClick=2023(int modifiers, int position)
+evt void IndicatorRelease=2024(int modifiers, int position)
+evt void AutoCCancelled=2025(void)
 
 cat Deprecated
 

Modified: trunk/plugins/editor/scintilla/include/WindowAccessor.h
==============================================================================
--- trunk/plugins/editor/scintilla/include/WindowAccessor.h	(original)
+++ trunk/plugins/editor/scintilla/include/WindowAccessor.h	Sat Nov 15 17:50:33 2008
@@ -6,6 +6,10 @@
 // Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
 /**
  */
 class WindowAccessor : public Accessor {
@@ -54,4 +58,9 @@
 	void ColourTo(unsigned int pos, int chAttr);
 	void SetLevel(int line, int level);
 	int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+	void IndicatorFill(int start, int end, int indicator, int value);
 };
+
+#ifdef SCI_NAMESPACE
+}
+#endif

Modified: trunk/plugins/editor/scintilla/lexers.make
==============================================================================
--- trunk/plugins/editor/scintilla/lexers.make	(original)
+++ trunk/plugins/editor/scintilla/lexers.make	Sat Nov 15 17:50:33 2008
@@ -1,10 +1,12 @@
 ## Lexers make file
 LEXER_OBJS = \
 	$(top_srcdir)/plugins/editor/scintilla/StyleContext.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexAbaqus.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAda.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAPDL.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAsm.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAsn1.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexASY.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAU3.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexAVE.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexBaan.o\
@@ -13,17 +15,20 @@
 	$(top_srcdir)/plugins/editor/scintilla/LexBullant.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCaml.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCLW.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexCmake.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexConf.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCPP.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCrontab.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCsound.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexCSS.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexD.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexEiffel.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexErlang.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexEScript.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexFlagship.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexForth.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexFortran.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexGAP.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexGui4Cli.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexHaskell.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexHTML.o\
@@ -32,20 +37,26 @@
 	$(top_srcdir)/plugins/editor/scintilla/LexLisp.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexLout.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexLua.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexMagik.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexMatlab.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexMetapost.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexMMIXAL.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexMPT.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexMSSQL.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexMySQL.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexNsis.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexOpal.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexOthers.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPascal.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPB.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPerl.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexPLM.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPOV.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexPowerShell.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexProgress.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPS.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexPython.o\
+	$(top_srcdir)/plugins/editor/scintilla/LexR.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexRebol.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexRuby.o\
 	$(top_srcdir)/plugins/editor/scintilla/LexScriptol.o\
@@ -62,10 +73,12 @@
 	$(top_srcdir)/plugins/editor/scintilla/LexYAML.o
 
 LEXER_SRCS = \
+	LexAbaqus.cxx\
 	LexAda.cxx\
 	LexAPDL.cxx\
 	LexAsm.cxx\
 	LexAsn1.cxx\
+	LexASY.cxx\
 	LexAU3.cxx\
 	LexAVE.cxx\
 	LexBaan.cxx\
@@ -74,17 +87,20 @@
 	LexBullant.cxx\
 	LexCaml.cxx\
 	LexCLW.cxx\
+	LexCmake.cxx\
 	LexConf.cxx\
 	LexCPP.cxx\
 	LexCrontab.cxx\
 	LexCsound.cxx\
 	LexCSS.cxx\
+	LexD.cxx\
 	LexEiffel.cxx\
 	LexErlang.cxx\
 	LexEScript.cxx\
 	LexFlagship.cxx\
 	LexForth.cxx\
 	LexFortran.cxx\
+	LexGAP.cxx\
 	LexGui4Cli.cxx\
 	LexHaskell.cxx\
 	LexHTML.cxx\
@@ -93,20 +109,26 @@
 	LexLisp.cxx\
 	LexLout.cxx\
 	LexLua.cxx\
+	LexMagik.cxx\
 	LexMatlab.cxx\
 	LexMetapost.cxx\
 	LexMMIXAL.cxx\
 	LexMPT.cxx\
 	LexMSSQL.cxx\
+	LexMySQL.cxx\
 	LexNsis.cxx\
 	LexOpal.cxx\
 	LexOthers.cxx\
 	LexPascal.cxx\
 	LexPB.cxx\
 	LexPerl.cxx\
+	LexPLM.cxx\
 	LexPOV.cxx\
+	LexPowerShell.cxx\
+	LexProgress.cxx\
 	LexPS.cxx\
 	LexPython.cxx\
+	LexR.cxx\
 	LexRebol.cxx\
 	LexRuby.cxx\
 	LexScriptol.cxx\

Modified: trunk/plugins/editor/scintilla/patches/scintilla-64-bit.diff
==============================================================================
--- trunk/plugins/editor/scintilla/patches/scintilla-64-bit.diff	(original)
+++ trunk/plugins/editor/scintilla/patches/scintilla-64-bit.diff	Sat Nov 15 17:50:33 2008
@@ -1,6 +1,6 @@
 --- scintilla/include/Scintilla.h
 +++ scintilla/include/Scintilla.h
-@@ -24,6 +24,11 @@
+@@ -28,6 +28,11 @@
  #if _MSC_VER >= 1300
  #include <BaseTsd.h>
  #endif
@@ -12,7 +12,7 @@
  #ifdef MAXULONG_PTR
  typedef ULONG_PTR uptr_t;
  typedef LONG_PTR sptr_t;
-@@ -31,6 +36,7 @@
+@@ -35,6 +40,7 @@
  typedef unsigned long uptr_t;
  typedef long sptr_t;
  #endif

Modified: trunk/plugins/editor/scintilla/patches/scintilla-pango-always.diff
==============================================================================
--- trunk/plugins/editor/scintilla/patches/scintilla-pango-always.diff	(original)
+++ trunk/plugins/editor/scintilla/patches/scintilla-pango-always.diff	Sat Nov 15 17:50:33 2008
@@ -1,6 +1,6 @@
 --- scintilla-new/gtk/PlatGTK.cxx	2004-10-03 18:22:16.000000000 +0530
 +++ scintilla/PlatGTK.cxx	2005-01-18 22:05:31.000000000 +0530
-@@ -493,16 +493,16 @@
+@@ -509,16 +509,16 @@
  	charset[0] = '\0';
  
  #ifdef USE_PANGO

Modified: trunk/plugins/editor/scintilla/patches/scintilla-string-fix.diff
==============================================================================
--- trunk/plugins/editor/scintilla/patches/scintilla-string-fix.diff	(original)
+++ trunk/plugins/editor/scintilla/patches/scintilla-string-fix.diff	Sat Nov 15 17:50:33 2008
@@ -1,15 +1,15 @@
 --- scintilla-new/include/SString.h	2004-04-24 17:52:29.000000000 +0530
 +++ scintilla/include/SString.h	2005-01-18 22:15:35.000000000 +0530
-@@ -8,6 +8,8 @@
- #ifndef SSTRING_H
+@@ -9,6 +9,8 @@
  #define SSTRING_H
  
+ 
 +#include <string.h>
 +
  // These functions are implemented because each platform calls them something different.
  int CompareCaseInsensitive(const char *a, const char *b);
  int CompareNCaseInsensitive(const char *a, const char *b, size_t len);
-@@ -128,7 +130,7 @@
+@@ -133,7 +135,7 @@
   * May have embedded zeroes as a result of @a substitute, but relies too heavily on C string
   * functions to allow reliable manipulations of these strings, other than simple appends, etc.
   */
@@ -18,7 +18,7 @@
  	lenpos_t sLen;			///< The size of the string in s
  	lenpos_t sizeGrowth;	///< Minimum growth size when appending strings
  	enum { sizeGrowthDefault = 64 };
-@@ -206,6 +208,22 @@
+@@ -211,6 +213,22 @@
  	const char *c_str() const {
  		return s ? s : "";
  	}



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