SF.net SVN: geany:[4923] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun May 16 17:44:24 UTC 2010


Revision: 4923
          http://geany.svn.sourceforge.net/geany/?rev=4923&view=rev
Author:   eht16
Date:     2010-05-16 17:44:24 +0000 (Sun, 16 May 2010)

Log Message:
-----------
Update Scintilla to version 2.11.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/geany.pc.in
    trunk/plugins/Makefile.am
    trunk/scintilla/AutoComplete.cxx
    trunk/scintilla/AutoComplete.h
    trunk/scintilla/CallTip.cxx
    trunk/scintilla/CallTip.h
    trunk/scintilla/CellBuffer.cxx
    trunk/scintilla/CellBuffer.h
    trunk/scintilla/Converter.h
    trunk/scintilla/Decoration.h
    trunk/scintilla/Document.cxx
    trunk/scintilla/Document.h
    trunk/scintilla/Editor.cxx
    trunk/scintilla/Editor.h
    trunk/scintilla/LexHTML.cxx
    trunk/scintilla/LexOthers.cxx
    trunk/scintilla/PlatGTK.cxx
    trunk/scintilla/PositionCache.cxx
    trunk/scintilla/PositionCache.h
    trunk/scintilla/RESearch.cxx
    trunk/scintilla/ScintillaBase.cxx
    trunk/scintilla/ScintillaGTK.cxx
    trunk/scintilla/Style.cxx
    trunk/scintilla/StyleContext.h
    trunk/scintilla/UniConversion.cxx
    trunk/scintilla/UniConversion.h
    trunk/scintilla/XPM.h
    trunk/scintilla/include/Scintilla.h
    trunk/scintilla/include/Scintilla.iface
    trunk/scintilla/include/ScintillaWidget.h
    trunk/src/Makefile.am
    trunk/src/plugindata.h
    trunk/wscript

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/ChangeLog	2010-05-16 17:44:24 UTC (rev 4923)
@@ -11,6 +11,9 @@
  * src/geanymenubuttonaction.c:
    Explicitly check for the type when iterating the action's proxies.
    For some reason on Windows, a GtkImageMenuItem proxy is created.
+ * geany.pc.in, wscript, plugins/Makefile.am, src/Makefile.am,
+   src/plugindata.h, scintilla/*, scintilla/include/*:
+   Update Scintilla to version 2.11.
 
 
 2010-05-15  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/geany.pc.in
===================================================================
--- trunk/geany.pc.in	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/geany.pc.in	2010-05-16 17:44:24 UTC (rev 4923)
@@ -11,4 +11,4 @@
 Requires: gtk+-2.0 >= 2.8.0
 Version: @VERSION@
 Libs: -L${libdir}
-Cflags: -I${includedir}/geany -I${includedir}/geany/tagmanager -I${includedir}/geany/scintilla
+Cflags: -DGTK -I${includedir}/geany -I${includedir}/geany/tagmanager -I${includedir}/geany/scintilla

Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/plugins/Makefile.am	2010-05-16 17:44:24 UTC (rev 4923)
@@ -97,6 +97,7 @@
 
 AM_CPPFLAGS = \
 	-DDATADIR=\"$(datadir)\" \
+	-DGTK \
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/tagmanager/include \
 	-I$(top_srcdir)/scintilla/include \

Modified: trunk/scintilla/AutoComplete.cxx
===================================================================
--- trunk/scintilla/AutoComplete.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/AutoComplete.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -43,12 +43,12 @@
 	}
 }
 
-bool AutoComplete::Active() {
+bool AutoComplete::Active() const {
 	return active;
 }
 
-void AutoComplete::Start(Window &parent, int ctrlID, 
-	int position, Point location, int startLen_, 
+void AutoComplete::Start(Window &parent, int ctrlID,
+	int position, Point location, int startLen_,
 	int lineHeight, bool unicodeMode) {
 	if (active) {
 		Cancel();
@@ -82,7 +82,7 @@
 	separator = separator_;
 }
 
-char AutoComplete::GetSeparator() {
+char AutoComplete::GetSeparator() const {
 	return separator;
 }
 
@@ -90,7 +90,7 @@
 	typesep = separator_;
 }
 
-char AutoComplete::GetTypesep() {
+char AutoComplete::GetTypesep() const {
 	return typesep;
 }
 

Modified: trunk/scintilla/AutoComplete.h
===================================================================
--- trunk/scintilla/AutoComplete.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/AutoComplete.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -36,7 +36,7 @@
 	~AutoComplete();
 
 	/// Is the auto completion list displayed?
-	bool Active();
+	bool Active() const;
 
 	/// Display the auto completion list positioned to be near a character position
 	void Start(Window &parent, int ctrlID, int position, Point location,
@@ -52,11 +52,11 @@
 
 	/// The separator character is used when interpreting the list in SetList
 	void SetSeparator(char separator_);
-	char GetSeparator();
+	char GetSeparator() const;
 
 	/// The typesep character is used for seperating the word from the type
 	void SetTypesep(char separator_);
-	char GetTypesep();
+	char GetTypesep() const;
 
 	/// The list string contains a sequence of words separated by the separator character
 	void SetList(const char *list);

Modified: trunk/scintilla/CallTip.cxx
===================================================================
--- trunk/scintilla/CallTip.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/CallTip.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -68,7 +68,7 @@
 }
 
 // We ignore tabs unless a tab width has been set.
-bool CallTip::IsTabCharacter(char ch) {
+bool CallTip::IsTabCharacter(char ch) const {
 	return (tabSize > 0) && (ch == '\t');
 }
 
@@ -95,7 +95,7 @@
 	int maxEnd = 0;
 	const int numEnds = 10;
 	int ends[numEnds + 2];
-	for (int i=0;i<len;i++) {
+	for (int i=0; i<len; i++) {
 		if ((maxEnd < numEnds) &&
 		        (IsArrowCharacter(s[i]) || IsTabCharacter(s[i])) ) {
 			if (i > 0)

Modified: trunk/scintilla/CallTip.h
===================================================================
--- trunk/scintilla/CallTip.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/CallTip.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -33,7 +33,7 @@
 		int posStart, int posEnd, int ytext, PRectangle rcClient,
 		bool highlight, bool draw);
 	int PaintContents(Surface *surfaceWindow, bool draw);
-	bool IsTabCharacter(char c);
+	bool IsTabCharacter(char c) const;
 	int NextTabPos(int x);
 
 public:
@@ -61,7 +61,7 @@
 
 	/// Setup the calltip and return a rectangle of the area required.
 	PRectangle CallTipStart(int pos, Point pt, const char *defn,
-		const char *faceName, int size, int codePage_, 
+		const char *faceName, int size, int codePage_,
 		int characterSet, Window &wParent);
 
 	void CallTipCancel();

Modified: trunk/scintilla/CellBuffer.cxx
===================================================================
--- trunk/scintilla/CellBuffer.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/CellBuffer.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -197,7 +197,7 @@
 				// Insertions must be immediately after to coalesce
 				currentAction++;
 			} else if (at == removeAction) {
-				if ((lengthData == 1) || (lengthData == 2)){
+				if ((lengthData == 1) || (lengthData == 2)) {
 					if ((position + lengthData) == actPrevious->position) {
 						; // Backspace -> OK
 					} else if (position == actPrevious->position) {
@@ -349,7 +349,7 @@
 		                      lengthRetrieve, substance.Length());
 		return;
 	}
-	
+
 	for (int i=0; i<lengthRetrieve; i++) {
 		*buffer++ = substance.ValueAt(position + i);
 	}
@@ -359,7 +359,7 @@
 	return style.ValueAt(position);
 }
 
-const char *CellBuffer::BufferPointer() { 
+const char *CellBuffer::BufferPointer() {
 	return substance.BufferPointer();
 }
 
@@ -455,7 +455,7 @@
 		return lv.LineStart(line);
 }
 
-bool CellBuffer::IsReadOnly() {
+bool CellBuffer::IsReadOnly() const {
 	return readOnly;
 }
 
@@ -586,7 +586,7 @@
 	return collectingUndo;
 }
 
-bool CellBuffer::IsCollectingUndo() {
+bool CellBuffer::IsCollectingUndo() const {
 	return collectingUndo;
 }
 

Modified: trunk/scintilla/CellBuffer.h
===================================================================
--- trunk/scintilla/CellBuffer.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/CellBuffer.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -170,7 +170,7 @@
 
 	const char *DeleteChars(int position, int deleteLength, bool &startSequence);
 
-	bool IsReadOnly();
+	bool IsReadOnly() const;
 	void SetReadOnly(bool set);
 
 	/// The save point is a marker in the undo stack where the container has stated that
@@ -183,7 +183,7 @@
 	void BasicDeleteChars(int position, int deleteLength);
 
 	bool SetUndoCollection(bool collectUndo);
-	bool IsCollectingUndo();
+	bool IsCollectingUndo() const;
 	void BeginUndoAction();
 	void EndUndoAction();
 	void AddUndoAction(int token, bool mayCoalesce);

Modified: trunk/scintilla/Converter.h
===================================================================
--- trunk/scintilla/Converter.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Converter.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -3,12 +3,7 @@
 // Copyright 2004 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
-#include <iconv.h>
-#if GTK_MAJOR_VERSION >= 2
-	typedef GIConv ConverterHandle;
-#else
-	typedef iconv_t ConverterHandle;
-#endif
+typedef GIConv ConverterHandle;
 const ConverterHandle iconvhBad = (ConverterHandle)(-1);
 // Since various versions of iconv can not agree on whether the src argument
 // is char ** or const char ** provide a templatised adaptor.
@@ -24,11 +19,7 @@
 class Converter {
 	ConverterHandle iconvh;
 	void OpenHandle(const char *fullDestination, const char *charSetSource) {
-#if GTK_MAJOR_VERSION >= 2
 		iconvh = g_iconv_open(fullDestination, charSetSource);
-#else
-		iconvh = iconv_open(fullDestination, charSetSource);
-#endif
 	}
 	bool Succeeded() const {
 		return iconvh != iconvhBad;
@@ -65,11 +56,7 @@
 	}
 	void Close() {
 		if (Succeeded()) {
-#if GTK_MAJOR_VERSION >= 2
 			g_iconv_close(iconvh);
-#else
-			iconv_close(iconvh);
-#endif
 			iconvh = iconvhBad;
 		}
 	}
@@ -77,11 +64,7 @@
 		if (!Succeeded()) {
 			return (size_t)(-1);
 		} else {
-#if GTK_MAJOR_VERSION >= 2
 			return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft);
-#else
-			return iconv_adaptor(iconv, iconvh, src, srcleft, dst, dstleft);
-#endif
 		}
 	}
 };

Modified: trunk/scintilla/Decoration.h
===================================================================
--- trunk/scintilla/Decoration.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Decoration.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -40,10 +40,10 @@
 	~DecorationList();
 
 	void SetCurrentIndicator(int indicator);
-	int GetCurrentIndicator() { return currentIndicator; }
+	int GetCurrentIndicator() const { return currentIndicator; }
 
 	void SetCurrentValue(int value);
-	int GetCurrentValue() { return currentValue; }
+	int GetCurrentValue() const { return currentValue; }
 
 	// Returns true if some values may have changed
 	bool FillRange(int &position, int value, int &fillLength);

Modified: trunk/scintilla/Document.cxx
===================================================================
--- trunk/scintilla/Document.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Document.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -10,6 +10,17 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#include <string>
+#include <vector>
+
+// With Borland C++ 5.5, including <string> includes Windows.h leading to defining
+// FindText to FindTextA which makes calls here to Document::FindText fail.
+#ifdef __BORLANDC__
+#ifdef FindText
+#undef FindText
+#endif
+#endif
+
 #include "Platform.h"
 
 #include "Scintilla.h"
@@ -22,6 +33,7 @@
 #include "Decoration.h"
 #include "Document.h"
 #include "RESearch.h"
+#include "UniConversion.h"
 
 #ifdef SCI_NAMESPACE
 using namespace Scintilla;
@@ -140,13 +152,13 @@
 	NotifySavePoint(true);
 }
 
-int Document::GetMark(int line) { 
-	return static_cast<LineMarkers*>(perLineData[ldMarkers])->MarkValue(line); 
+int Document::GetMark(int line) {
+	return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line);
 }
 
 int Document::AddMark(int line, int markerNum) {
 	if (line <= LinesTotal()) {
-		int prev = static_cast<LineMarkers*>(perLineData[ldMarkers])->
+		int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
 			AddMark(line, markerNum, LinesTotal());
 		DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
 		NotifyModified(mh);
@@ -160,20 +172,20 @@
 	unsigned int m = valueSet;
 	for (int i = 0; m; i++, m >>= 1)
 		if (m & 1)
-			static_cast<LineMarkers*>(perLineData[ldMarkers])->
+			static_cast<LineMarkers *>(perLineData[ldMarkers])->
 				AddMark(line, i, LinesTotal());
 	DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
 	NotifyModified(mh);
 }
 
 void Document::DeleteMark(int line, int markerNum) {
-	static_cast<LineMarkers*>(perLineData[ldMarkers])->DeleteMark(line, markerNum, false);
+	static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, false);
 	DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
 	NotifyModified(mh);
 }
 
 void Document::DeleteMarkFromHandle(int markerHandle) {
-	static_cast<LineMarkers*>(perLineData[ldMarkers])->DeleteMarkFromHandle(markerHandle);
+	static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMarkFromHandle(markerHandle);
 	DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
 	mh.line = -1;
 	NotifyModified(mh);
@@ -181,15 +193,15 @@
 
 void Document::DeleteAllMarks(int markerNum) {
 	for (int line = 0; line < LinesTotal(); line++) {
-		static_cast<LineMarkers*>(perLineData[ldMarkers])->DeleteMark(line, markerNum, true);
+		static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, true);
 	}
 	DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
 	mh.line = -1;
 	NotifyModified(mh);
 }
 
-int Document::LineFromHandle(int markerHandle) { 
-	return static_cast<LineMarkers*>(perLineData[ldMarkers])->LineFromHandle(markerHandle); 
+int Document::LineFromHandle(int markerHandle) {
+	return static_cast<LineMarkers *>(perLineData[ldMarkers])->LineFromHandle(markerHandle);
 }
 
 int Document::LineStart(int line) const {
@@ -226,7 +238,7 @@
 	int startPosition = LineStart(line);
 	int endLine = LineEnd(line);
 	int startText = startPosition;
-	while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t' ) )
+	while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t'))
 		startText++;
 	if (position == startText)
 		return startPosition;
@@ -235,7 +247,7 @@
 }
 
 int Document::SetLevel(int line, int level) {
-	int prev = static_cast<LineLevels*>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal());
+	int prev = static_cast<LineLevels *>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal());
 	if (prev != level) {
 		DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
 		                   LineStart(line), 0, 0, 0, line);
@@ -246,12 +258,12 @@
 	return prev;
 }
 
-int Document::GetLevel(int line) { 
-	return static_cast<LineLevels*>(perLineData[ldLevels])->GetLevel(line); 
+int Document::GetLevel(int line) {
+	return static_cast<LineLevels *>(perLineData[ldLevels])->GetLevel(line);
 }
 
-void Document::ClearLevels() { 
-	static_cast<LineLevels*>(perLineData[ldLevels])->ClearLevels(); 
+void Document::ClearLevels() {
+	static_cast<LineLevels *>(perLineData[ldLevels])->ClearLevels();
 }
 
 static bool IsSubordinate(int levelStart, int levelTry) {
@@ -437,7 +449,7 @@
 			while (posCheck < pos) {
 				char mbstr[maxBytesInDBCSCharacter+1];
 				int i;
-				for(i=0;i<Platform::DBCSCharMaxLength();i++) {
+				for (i=0; i<Platform::DBCSCharMaxLength(); i++) {
 					mbstr[i] = cb.CharAt(posCheck+i);
 				}
 				mbstr[i] = '\0';
@@ -739,7 +751,7 @@
 	if ((line >= 0) && (line < LinesTotal())) {
 		int lineStart = LineStart(line);
 		int length = Length();
-		for (int i = lineStart;i < length;i++) {
+		for (int i = lineStart; i < length; i++) {
 			char ch = cb.CharAt(i);
 			if (ch == ' ')
 				indent++;
@@ -782,7 +794,7 @@
 	int column = 0;
 	int line = LineFromPosition(pos);
 	if ((line >= 0) && (line < LinesTotal())) {
-		for (int i = LineStart(line);i < pos;) {
+		for (int i = LineStart(line); i < pos;) {
 			char ch = cb.CharAt(i);
 			if (ch == '\t') {
 				column = NextTab(column, tabInChars);
@@ -969,7 +981,7 @@
 		while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
 			pos++;
 	}
-	return MovePositionOutsideChar(pos, delta);
+	return MovePositionOutsideChar(pos, delta, true);
 }
 
 /**
@@ -1074,79 +1086,170 @@
 		return static_cast<char>(ch - 'A' + 'a');
 }
 
+static bool GoodTrailByte(int v) {
+	return (v >= 0x80) && (v < 0xc0);
+}
+
+size_t Document::ExtractChar(int pos, char *bytes) {
+	unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
+	size_t widthChar = UTF8CharLength(ch);
+	bytes[0] = ch;
+	for (size_t i=1; i<widthChar; i++) {
+		bytes[i] = cb.CharAt(pos+i);
+		if (!GoodTrailByte(static_cast<unsigned char>(bytes[i]))) { // Bad byte
+			widthChar = 1;
+		}
+	}
+	return widthChar;
+}
+
+CaseFolderTable::CaseFolderTable() {
+	for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
+		mapping[iChar] = static_cast<char>(iChar);
+	}
+}
+
+CaseFolderTable::~CaseFolderTable() {
+}
+
+size_t CaseFolderTable::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
+	if (lenMixed > sizeFolded) {
+		return 0;
+	} else {
+		for (size_t i=0; i<lenMixed; i++) {
+			folded[i] = mapping[static_cast<unsigned char>(mixed[i])];
+		}
+		return lenMixed;
+	}
+}
+
+void CaseFolderTable::SetTranslation(char ch, char chTranslation) {
+	mapping[static_cast<unsigned char>(ch)] = chTranslation;
+}
+
+void CaseFolderTable::StandardASCII() {
+	for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
+		if (iChar >= 'A' && iChar <= 'Z') {
+			mapping[iChar] = static_cast<char>(iChar - 'A' + 'a');
+		} else {
+			mapping[iChar] = static_cast<char>(iChar);
+		}
+	}
+}
+
+bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) {
+	return (!word && !wordStart) ||
+			(word && IsWordAt(pos, pos + length)) ||
+			(wordStart && IsWordStartAt(pos));
+}
+
 /**
  * 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,
+long Document::FindText(int minPos, int maxPos, const char *search,
                         bool caseSensitive, bool word, bool wordStart, bool regExp, int flags,
-                        int *length) {
+                        int *length, CaseFolder *pcf) {
 	if (regExp) {
 		if (!regex)
 			regex = CreateRegexSearch(&charClass);
-		return regex->FindText(this, minPos, maxPos, s, caseSensitive, word, wordStart, flags, length);
+		return regex->FindText(this, minPos, maxPos, search, caseSensitive, word, wordStart, flags, length);
 	} else {
 
-		bool forward = minPos <= maxPos;
-		int increment = forward ? 1 : -1;
+		const bool forward = minPos <= maxPos;
+		const int increment = forward ? 1 : -1;
 
 		// Range endpoints should not be inside DBCS characters, but just in case, move them.
-		int startPos = MovePositionOutsideChar(minPos, increment, false);
-		int endPos = MovePositionOutsideChar(maxPos, increment, false);
+		const int startPos = MovePositionOutsideChar(minPos, increment, false);
+		const int endPos = MovePositionOutsideChar(maxPos, increment, false);
 
 		// Compute actual search ranges needed
-		int lengthFind = *length;
-		if (lengthFind == -1)
-			lengthFind = static_cast<int>(strlen(s));
-		int endSearch = endPos;
-		if (startPos <= endPos) {
-			endSearch = endPos - lengthFind + 1;
-		}
+		const int lengthFind = (*length == -1) ? static_cast<int>(strlen(search)) : *length;
+		const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
+
 		//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
-		char firstChar = s[0];
-		if (!caseSensitive)
-			firstChar = static_cast<char>(MakeUpperCase(firstChar));
+		const int limitPos = Platform::Maximum(startPos, endPos);
 		int pos = forward ? startPos : (startPos - 1);
-		while (forward ? (pos < endSearch) : (pos >= endSearch)) {
-			char ch = CharAt(pos);
-			if (caseSensitive) {
-				if (ch == firstChar) {
-					bool found = true;
-					if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false;
-					for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
-						ch = CharAt(pos + posMatch);
-						if (ch != s[posMatch])
-							found = false;
+		if (caseSensitive) {
+			while (forward ? (pos < endSearch) : (pos >= endSearch)) {
+				bool found = (pos + lengthFind) <= limitPos;
+				for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) {
+					found = CharAt(pos + indexSearch) == search[indexSearch];
+				}
+				if (found && MatchesWordOptions(word, wordStart, pos, lengthFind)) {
+					return pos;
+				}
+				pos += increment;
+				if (dbcsCodePage && (pos >= 0)) {
+					// Have to use >= 0 as otherwise next statement would change 
+					// -1 to 0 and make loop infinite.
+					// Ensure trying to match from start of character
+					pos = MovePositionOutsideChar(pos, increment, false);
+				}
+			}
+		} else if (SC_CP_UTF8 == dbcsCodePage) {
+			const size_t maxBytesCharacter = 4;
+			const size_t maxFoldingExpansion = 4;
+			std::vector<char> searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1);
+			const int lenSearch = pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+			while (forward ? (pos < endSearch) : (pos >= endSearch)) {
+				int widthFirstCharacter = 0;
+				int indexDocument = 0;
+				int indexSearch = 0;
+				bool characterMatches = true;
+				while (characterMatches && 
+					((pos + indexDocument) < limitPos) && 
+					(indexSearch < lenSearch)) {
+					char bytes[maxBytesCharacter + 1];
+					bytes[maxBytesCharacter] = 0;
+					const int widthChar = ExtractChar(pos + indexDocument, bytes);
+					if (!widthFirstCharacter)
+						widthFirstCharacter = widthChar;
+					char folded[maxBytesCharacter * maxFoldingExpansion + 1];
+					const int lenFlat = pcf->Fold(folded, sizeof(folded), bytes, widthChar);
+					folded[lenFlat] = 0;
+					// Does folded match the buffer
+					characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat);
+					indexDocument += widthChar;
+					indexSearch += lenFlat;
+				}
+				if (characterMatches && (indexSearch == static_cast<int>(lenSearch))) {
+					if (MatchesWordOptions(word, wordStart, pos, indexDocument)) {
+						*length = indexDocument;
+						return pos;
 					}
-					if (found) {
-						if ((!word && !wordStart) ||
-						        (word && IsWordAt(pos, pos + lengthFind)) ||
-						        (wordStart && IsWordStartAt(pos)))
-							return pos;
-					}
 				}
-			} else {
-				if (MakeUpperCase(ch) == firstChar) {
-					bool found = true;
-					if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false;
-					for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
-						ch = CharAt(pos + posMatch);
-						if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch]))
-							found = false;
+				if (forward) {
+					pos += widthFirstCharacter;
+				} else {
+					pos--;
+					if (pos > 0) {
+						// Ensure trying to match from start of character
+						pos = MovePositionOutsideChar(pos, increment, false);
 					}
-					if (found) {
-						if ((!word && !wordStart) ||
-						        (word && IsWordAt(pos, pos + lengthFind)) ||
-						        (wordStart && IsWordStartAt(pos)))
-							return pos;
-					}
 				}
 			}
-			pos += increment;
-			if (dbcsCodePage && (pos >= 0)) {
-				// Ensure trying to match from start of character
-				pos = MovePositionOutsideChar(pos, increment, false);
+		} else {
+			CaseFolderTable caseFolder;
+			std::vector<char> searchThing(lengthFind + 1);
+			pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+			while (forward ? (pos < endSearch) : (pos >= endSearch)) {
+				bool found = (pos + lengthFind) <= limitPos;
+				for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) {
+					char ch = CharAt(pos + indexSearch);
+					char folded[2];
+					pcf->Fold(folded, sizeof(folded), &ch, 1);
+					found = folded[0] == searchThing[indexSearch];
+				}
+				if (found && MatchesWordOptions(word, wordStart, pos, lengthFind)) {
+					return pos;
+				}
+				pos += increment;
+				if (dbcsCodePage && (pos >= 0)) {
+					// Ensure trying to match from start of character
+					pos = MovePositionOutsideChar(pos, increment, false);
+				}
 			}
 		}
 	}
@@ -1256,7 +1359,7 @@
 }
 
 int Document::SetLineState(int line, int state) {
-	int statePrevious = static_cast<LineState*>(perLineData[ldState])->SetLineState(line, state);
+	int statePrevious = static_cast<LineState *>(perLineData[ldState])->SetLineState(line, state);
 	if (state != statePrevious) {
 		DocModification mh(SC_MOD_CHANGELINESTATE, 0, 0, 0, 0, line);
 		NotifyModified(mh);
@@ -1264,59 +1367,59 @@
 	return statePrevious;
 }
 
-int Document::GetLineState(int line) { 
-	return static_cast<LineState*>(perLineData[ldState])->GetLineState(line); 
+int Document::GetLineState(int line) {
+	return static_cast<LineState *>(perLineData[ldState])->GetLineState(line);
 }
 
-int Document::GetMaxLineState() { 
-	return static_cast<LineState*>(perLineData[ldState])->GetMaxLineState(); 
+int Document::GetMaxLineState() {
+	return static_cast<LineState *>(perLineData[ldState])->GetMaxLineState();
 }
 
 StyledText Document::MarginStyledText(int line) {
-	LineAnnotation *pla = static_cast<LineAnnotation*>(perLineData[ldMargin]);
-	return StyledText(pla->Length(line), pla->Text(line), 
+	LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldMargin]);
+	return StyledText(pla->Length(line), pla->Text(line),
 		pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
 }
 
 void Document::MarginSetText(int line, const char *text) {
-	static_cast<LineAnnotation*>(perLineData[ldMargin])->SetText(line, text); 
+	static_cast<LineAnnotation *>(perLineData[ldMargin])->SetText(line, text);
 	DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line);
 	NotifyModified(mh);
 }
 
 void Document::MarginSetStyle(int line, int style) {
-	static_cast<LineAnnotation*>(perLineData[ldMargin])->SetStyle(line, style); 
+	static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyle(line, style);
 }
 
 void Document::MarginSetStyles(int line, const unsigned char *styles) {
-	static_cast<LineAnnotation*>(perLineData[ldMargin])->SetStyles(line, styles); 
+	static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyles(line, styles);
 }
 
 int Document::MarginLength(int line) const {
-	return static_cast<LineAnnotation*>(perLineData[ldMargin])->Length(line);
+	return static_cast<LineAnnotation *>(perLineData[ldMargin])->Length(line);
 }
 
 void Document::MarginClearAll() {
 	int maxEditorLine = LinesTotal();
-	for (int l=0;l<maxEditorLine;l++)
+	for (int l=0; l<maxEditorLine; l++)
 		MarginSetText(l, 0);
 	// Free remaining data
-	static_cast<LineAnnotation*>(perLineData[ldMargin])->ClearAll();
+	static_cast<LineAnnotation *>(perLineData[ldMargin])->ClearAll();
 }
 
 bool Document::AnnotationAny() const {
-	return static_cast<LineAnnotation*>(perLineData[ldAnnotation])->AnySet(); 
+	return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->AnySet();
 }
 
 StyledText Document::AnnotationStyledText(int line) {
-	LineAnnotation *pla = static_cast<LineAnnotation*>(perLineData[ldAnnotation]);
-	return StyledText(pla->Length(line), pla->Text(line), 
+	LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldAnnotation]);
+	return StyledText(pla->Length(line), pla->Text(line),
 		pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
 }
 
 void Document::AnnotationSetText(int line, const char *text) {
 	const int linesBefore = AnnotationLines(line);
-	static_cast<LineAnnotation*>(perLineData[ldAnnotation])->SetText(line, text); 
+	static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetText(line, text);
 	const int linesAfter = AnnotationLines(line);
 	DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line);
 	mh.annotationLinesAdded = linesAfter - linesBefore;
@@ -1324,27 +1427,27 @@
 }
 
 void Document::AnnotationSetStyle(int line, int style) {
-	static_cast<LineAnnotation*>(perLineData[ldAnnotation])->SetStyle(line, style); 
+	static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyle(line, style);
 }
 
 void Document::AnnotationSetStyles(int line, const unsigned char *styles) {
-	static_cast<LineAnnotation*>(perLineData[ldAnnotation])->SetStyles(line, styles); 
+	static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyles(line, styles);
 }
 
 int Document::AnnotationLength(int line) const {
-	return static_cast<LineAnnotation*>(perLineData[ldAnnotation])->Length(line);
+	return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->Length(line);
 }
 
 int Document::AnnotationLines(int line) const {
-	return static_cast<LineAnnotation*>(perLineData[ldAnnotation])->Lines(line);
+	return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->Lines(line);
 }
 
 void Document::AnnotationClearAll() {
 	int maxEditorLine = LinesTotal();
-	for (int l=0;l<maxEditorLine;l++)
+	for (int l=0; l<maxEditorLine; l++)
 		AnnotationSetText(l, 0);
 	// Free remaining data
-	static_cast<LineAnnotation*>(perLineData[ldAnnotation])->ClearAll();
+	static_cast<LineAnnotation *>(perLineData[ldAnnotation])->ClearAll();
 }
 
 void Document::IncrementStyleClock() {
@@ -1523,11 +1626,11 @@
 int Document::ExtendStyleRange(int pos, int delta, bool singleLine) {
 	int sStart = cb.StyleAt(pos);
 	if (delta < 0) {
-		while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) )
+		while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))))
 			pos--;
 		pos++;
 	} else {
-		while (pos < (Length()) && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) )
+		while (pos < (Length()) && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))))
 			pos++;
 	}
 	return pos;
@@ -1569,7 +1672,7 @@
 	int depth = 1;
 	position = position + direction;
 	while ((position >= 0) && (position < Length())) {
-		position = MovePositionOutsideChar(position, direction);
+		position = MovePositionOutsideChar(position, direction, true);
 		char chAtPos = CharAt(position);
 		char styAtPos = static_cast<char>(StyleAt(position) & stylingBitsMask);
 		if ((position > GetEndStyled()) || (styAtPos == styBrace)) {
@@ -1600,7 +1703,7 @@
                         bool caseSensitive, bool word, bool wordStart, int flags,
                         int *length);
 
-	virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length);
+	virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length);
 
 private:
 	RESearch search;
@@ -1715,7 +1818,7 @@
 	return pos;
 }
 
-const char *BuiltinRegex::SubstituteByPosition(Document* doc, const char *text, int *length) {
+const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, int *length) {
 	delete []substituted;
 	substituted = 0;
 	DocumentIndexer di(doc, doc->Length());
@@ -1737,6 +1840,7 @@
 				case 'r':
 				case 't':
 				case 'v':
+				case '\\':
 					i++;
 				}
 				lenResult++;
@@ -1780,6 +1884,9 @@
 				case 'v':
 					*o++ = '\v';
 					break;
+				case '\\':
+					*o++ = '\\';
+					break;
 				default:
 					*o++ = '\\';
 					j--;

Modified: trunk/scintilla/Document.h
===================================================================
--- trunk/scintilla/Document.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Document.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -81,17 +81,17 @@
  */
 class RegexSearchBase {
 public:
-	virtual ~RegexSearchBase(){}
+	virtual ~RegexSearchBase() {}
 
-	virtual long FindText(Document* doc, int minPos, int maxPos, const char *s,
+	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;
+	virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0;
 };
 
 /// Factory function for RegexSearchBase
-extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable);
+extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable);
 
 struct StyledText {
 	size_t length;
@@ -99,7 +99,7 @@
 	bool multipleStyles;
 	size_t style;
 	const unsigned char *styles;
-	StyledText(	size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : 
+	StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) :
 		length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) {
 	}
 	// Return number of bytes from start to before '\n' or end of text.
@@ -115,6 +115,24 @@
 	}
 };
 
+class CaseFolder {
+public:
+	virtual ~CaseFolder() {
+	};
+	virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0;
+};
+
+class CaseFolderTable : public CaseFolder {
+protected:
+	char mapping[256];
+public:
+	CaseFolderTable();
+	virtual ~CaseFolderTable();
+	virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed);
+	void SetTranslation(char ch, char chTranslation);
+	void StandardASCII();
+};
+
 /**
  */
 class Document : PerLine {
@@ -147,11 +165,11 @@
 	int lenWatchers;
 
 	// ldSize is not real data - it is for dimensions and loops
-	enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };	
+	enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
 	PerLine *perLineData[ldSize];
 
 	bool matchesValid;
-	RegexSearchBase* regex;
+	RegexSearchBase *regex;
 
 public:
 	int stylingBits;
@@ -254,9 +272,10 @@
 	int NextWordEnd(int pos, int delta);
 	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, int flags, int *length);
-	long FindText(int iMessage, unsigned long wParam, long lParam);
+	size_t ExtractChar(int pos, char *bytes);
+	bool MatchesWordOptions(bool word, bool wordStart, int pos, int length);
+	long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word,
+		bool wordStart, bool regExp, int flags, int *length, CaseFolder *pcf);
 	const char *SubstituteByPosition(const char *text, int *length);
 	int LinesTotal() const;
 
@@ -324,7 +343,7 @@
 	Document *pdoc;
 	bool groupNeeded;
 public:
-	UndoGroup(Document *pdoc_, bool groupNeeded_=true) : 
+	UndoGroup(Document *pdoc_, bool groupNeeded_=true) :
 		pdoc(pdoc_), groupNeeded(groupNeeded_) {
 		if (groupNeeded) {
 			pdoc->BeginUndoAction();

Modified: trunk/scintilla/Editor.cxx
===================================================================
--- trunk/scintilla/Editor.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Editor.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -13,6 +13,7 @@
 #include <string>
 #include <vector>
 #include <algorithm>
+#include <memory>
 
 // With Borland C++ 5.5, including <string> includes Windows.h leading to defining
 // FindText to FindTextA which makes calls here to Document::FindText fail.
@@ -52,7 +53,7 @@
 	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) {
+static bool CanDeferToLastStep(const DocModification &mh) {
 	if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
 		return true;	// CAN skip
 	if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)))
@@ -62,7 +63,7 @@
 	return false;		// PRESUMABLY must do
 }
 
-static bool CanEliminate(const DocModification& mh) {
+static bool CanEliminate(const DocModification &mh) {
 	return
 	    (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0;
 }
@@ -71,7 +72,7 @@
 	return whether this modification represents the FINAL step
 	in a [possibly lengthy] multi-step Undo/Redo sequence
 */
-static bool IsLastStep(const DocModification& mh) {
+static bool IsLastStep(const DocModification &mh) {
 	return
 	    (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0
 	    && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
@@ -150,6 +151,7 @@
 	caretSticky = false;
 	multipleSelection = false;
 	additionalSelectionTyping = false;
+	multiPasteMode = SC_MULTIPASTE_ONCE;
 	additionalCaretsBlink = true;
 	additionalCaretsVisible = true;
 	virtualSpaceOptions = SCVS_NONE;
@@ -850,6 +852,12 @@
 	int delta = newPos.Position() - sel.MainCaret();
 	newPos = ClampPositionIntoDocument(newPos);
 	newPos = MovePositionOutsideChar(newPos, delta);
+	if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) {
+		// Can't turn into multiple selection so clear additional selections
+		InvalidateSelection(SelectionRange(newPos), true);
+		SelectionRange rangeMain = sel.RangeMain();
+		sel.SetSelection(rangeMain);
+	}
 	if (!sel.IsRectangular() && (selt == Selection::selRectangle)) {
 		// Switching to rectangular
 		SelectionRange rangeMain = sel.RangeMain();
@@ -908,7 +916,7 @@
  */
 void Editor::SetLastXChosen() {
 	Point pt = PointMainCaret();
-	lastXChosen = pt.x;
+	lastXChosen = pt.x + xOffset;
 }
 
 void Editor::ScrollTo(int line, bool moveThumb) {
@@ -955,12 +963,12 @@
 	Point pt = PointMainCaret();
 	if (pt.y < rcClient.top) {
 		MovePositionTo(SPositionFromLocation(
-		            Point(lastXChosen, rcClient.top)),
+		            Point(lastXChosen - xOffset, rcClient.top)),
 					Selection::noSel, ensureVisible);
 	} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
 		int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight;
 		MovePositionTo(SPositionFromLocation(
-		            Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)),
+		            Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed)),
 		        Selection::noSel, ensureVisible);
 	}
 }
@@ -1495,7 +1503,7 @@
 
 bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) {
 	if (st.multipleStyles) {
-		for (size_t iStyle=0;iStyle<st.length; iStyle++) {
+		for (size_t iStyle=0; iStyle<st.length; iStyle++) {
 			if (!vs.ValidStyle(styleOffset + st.styles[iStyle]))
 				return false;
 		}
@@ -1824,6 +1832,7 @@
 }
 
 bool BadUTF(const char *s, int len, int &trailBytes) {
+	// For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 	if (trailBytes) {
 		trailBytes--;
 		return false;
@@ -1840,6 +1849,23 @@
 		if (len < 4)
 			return true;
 		if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) {
+			if (*us == 0xf4) {
+				// Chcek if encoding a value beyond the last Unicode character 10FFFF
+				if (us[1] > 0x8f) {
+					return true;
+				} else if (us[1] == 0x8f) {
+					if (us[2] > 0xbf) {
+						return true;
+					} else if (us[2] == 0xbf) {
+						if (us[3] > 0xbf) {
+							return true;
+						}
+					}
+				}
+			} else if ((*us == 0xf0) && ((us[1] & 0xf0) == 0x80)) {
+				// Overlong
+				return true;
+			}
 			trailBytes = 3;
 			return false;
 		} else {
@@ -1850,6 +1876,22 @@
 		if (len < 3)
 			return true;
 		if (GoodTrailByte(us[1]) && GoodTrailByte(us[2])) {
+			if ((*us == 0xe0) && ((us[1] & 0xe0) == 0x80)) {
+				// Overlong
+				return true;
+			}
+			if ((*us == 0xed) && ((us[1] & 0xe0) == 0xa0)) {
+				// Surrogate
+				return true;
+			}
+			if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbe)) {
+				// U+FFFE
+				return true;
+			}
+			if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbf)) {
+				// U+FFFF
+				return true;
+			}
 			trailBytes = 2;
 			return false;
 		} else {
@@ -2018,8 +2060,8 @@
 						}
 						lastSegItalics = false;
 					} else if (isBadUTF) {
-						char hexits[3];
-						sprintf(hexits, "%2X", ll->chars[charInLine] & 0xff);
+						char hexits[4];
+						sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff);
 						ll->positions[charInLine + 1] =
 						    surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3;
 					} else {	// Regular character
@@ -2481,7 +2523,7 @@
 			surface->LineTo(rcSegment.left, rcSegment.bottom);
 			surface->MoveTo(rcSegment.right, rcSegment.top);
 			surface->LineTo(rcSegment.right, rcSegment.bottom);
-			if (subLine == ll->lines){
+			if (subLine == ll->lines) {
 				surface->MoveTo(rcSegment.left, rcSegment.top);
 				surface->LineTo(rcSegment.right, rcSegment.top);
 			}
@@ -2787,8 +2829,9 @@
 					        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);
+				// A single byte >= 0x80 in UTF-8 is a bad byte and is displayed as its hex value
+				char hexits[4];
+				sprintf(hexits, "x%2X", ll->chars[i] & 0xff);
 				DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
 			} else {
 				// Normal text display
@@ -2840,7 +2883,7 @@
 					}
 				}
 			}
-			if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) {
+			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;
@@ -3474,7 +3517,7 @@
 	vsPrint.showCaretLineBackground = false;
 
 	// Set colours for printing according to users settings
-	for (size_t sty = 0;sty < vsPrint.stylesSize;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);
@@ -3529,7 +3572,7 @@
 
 	int nPrintPos = pfr->chrg.cpMin;
 	int visibleLine = 0;
-	int widthPrint = pfr->rc.Width() - vsPrint.fixedColumnWidth;
+	int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
 	if (printWrapState == eWrapNone)
 		widthPrint = LineLayout::wrapWidthInfinite;
 
@@ -3727,7 +3770,11 @@
 				if (wrapState != eWrapNone) {
 					AutoSurface surface(this);
 					if (surface) {
-						WrapOneLine(surface, pdoc->LineFromPosition(positionInsert));
+						if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) {
+							SetScrollBars();
+							SetVerticalScrollPos();
+							Redraw();
+						}
 					}
 				}
 			}
@@ -3787,6 +3834,38 @@
 	}
 }
 
+void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) {
+	if (multiPasteMode == SC_MULTIPASTE_ONCE) {
+		selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace()));
+		if (pdoc->InsertString(selStart.Position(), text, len)) {
+			SetEmptySelection(selStart.Position() + len);
+		}
+	} else {
+		// SC_MULTIPASTE_EACH
+		for (size_t r=0; r<sel.Count(); r++) {
+			if (!RangeContainsProtected(sel.Range(r).Start().Position(),
+				sel.Range(r).End().Position())) {
+				int positionInsert = sel.Range(r).Start().Position();
+				if (!sel.Range(r).Empty()) {
+					if (sel.Range(r).Length()) {
+						pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
+						sel.Range(r).ClearVirtualSpace();
+					} else {
+						// Range is all virtual so collapse to start of virtual space
+						sel.Range(r).MinimizeVirtualSpace();
+					}
+				}
+				positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
+				if (pdoc->InsertString(positionInsert, text, len)) {
+					sel.Range(r).caret.SetPosition(positionInsert + len);
+					sel.Range(r).anchor.SetPosition(positionInsert + len);
+				}
+				sel.Range(r).ClearVirtualSpace();
+			}
+		}
+	}
+}
+
 void Editor::ClearSelection() {
 	if (!sel.IsRectangular())
 		FilterSelections();
@@ -3902,9 +3981,9 @@
 }
 
 void Editor::Clear() {
-	UndoGroup ug(pdoc);
 	// If multiple selections, don't delete EOLS
 	if (sel.Empty()) {
+		UndoGroup ug(pdoc, sel.Count() > 1);
 		for (size_t r=0; r<sel.Count(); r++) {
 			if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) {
 				if (sel.Range(r).Start().VirtualSpace()) {
@@ -4014,7 +4093,7 @@
 	NotifyParent(scn);
 }
 
-void Editor::NotifyStyleNeeded(Document*, void *, int endStyleNeeded) {
+void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) {
 	NotifyStyleToNeeded(endStyleNeeded);
 }
 
@@ -4139,12 +4218,12 @@
 }
 
 // Notifications from document
-void Editor::NotifyModifyAttempt(Document*, void *) {
+void Editor::NotifyModifyAttempt(Document *, void *) {
 	//Platform::DebugPrintf("** Modify Attempt\n");
 	NotifyModifyAttempt();
 }
 
-void Editor::NotifySavePoint(Document*, void *, bool atSavePoint) {
+void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
 	//Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off");
 	NotifySavePoint(atSavePoint);
 }
@@ -4187,7 +4266,7 @@
 	}
 }
 
-void Editor::NotifyModified(Document*, DocModification mh, void *) {
+void Editor::NotifyModified(Document *, DocModification mh, void *) {
 	needUpdateUI = true;
 	if (paintState == painting) {
 		CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
@@ -4463,16 +4542,16 @@
 	int topStutterLine = topLine + caretYSlop;
 	int bottomStutterLine =
 	    pdoc->LineFromPosition(PositionFromLocation(
-	                Point(lastXChosen, direction * vs.lineHeight * LinesToScroll())))
+	                Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
 	    - caretYSlop - 1;
 
 	if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
 		topLineNew = topLine;
-		newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * caretYSlop));
+		newPos = PositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop));
 
 	} else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) {
 		topLineNew = topLine;
-		newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * (LinesToScroll() - caretYSlop)));
+		newPos = PositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)));
 
 	} else {
 		Point pt = LocationFromPosition(sel.MainCaret());
@@ -4480,7 +4559,7 @@
 		topLineNew = Platform::Clamp(
 		            topLine + direction * LinesToScroll(), 0, MaxScrollPos());
 		newPos = PositionFromLocation(
-		            Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll())));
+		            Point(lastXChosen - xOffset, pt.y + direction * (vs.lineHeight * LinesToScroll())));
 	}
 
 	if (topLineNew != topLine) {
@@ -4493,14 +4572,36 @@
 	}
 }
 
-void Editor::ChangeCaseOfSelection(bool makeUpperCase) {
+void Editor::ChangeCaseOfSelection(int caseMapping) {
 	UndoGroup ug(pdoc);
 	for (size_t r=0; r<sel.Count(); r++) {
 		SelectionRange current = sel.Range(r);
-		pdoc->ChangeCase(Range(current.Start().Position(), current.End().Position()),
-	        makeUpperCase);
-		// Automatic movement cuts off last character so reset to exactly the same as it was.
-		sel.Range(r) = current;
+		SelectionRange currentNoVS = current;
+		currentNoVS.ClearVirtualSpace();
+		char *text = CopyRange(currentNoVS.Start().Position(), currentNoVS.End().Position());
+		size_t rangeBytes = currentNoVS.Length();
+		if (rangeBytes > 0) {
+			std::string sText(text, rangeBytes);
+
+			std::string sMapped = CaseMapString(sText, caseMapping);
+
+			if (sMapped != sText) {
+				size_t firstDifference = 0;
+				while (sMapped[firstDifference] == sText[firstDifference])
+					firstDifference++;
+				size_t lastDifference = sMapped.size() - 1;
+				while (sMapped[lastDifference] == sText[lastDifference])
+					lastDifference--;
+				size_t endSame = sMapped.size() - 1 - lastDifference;
+				pdoc->DeleteChars(currentNoVS.Start().Position() + firstDifference,
+					rangeBytes - firstDifference - endSame);
+				pdoc->InsertString(currentNoVS.Start().Position() + firstDifference,
+					sMapped.c_str() + firstDifference, lastDifference - firstDifference + 1);
+				// Automatic movement changes selection so reset to exactly the same as it was.
+				sel.Range(r) = current;
+			}
+		}
+		delete []text;
 	}
 }
 
@@ -4613,10 +4714,10 @@
 	int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
 	int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0;
 	SelectionPosition posNew = SPositionFromLocation(
-	            Point(lastXChosen, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace());
+	            Point(lastXChosen - xOffset, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace());
 	if ((direction > 0) && (subLine >= (cs.GetHeight(lineDoc) - 1 - commentLines))) {
 		posNew = SPositionFromLocation(
-	            Point(lastXChosen, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace());
+	            Point(lastXChosen - xOffset, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace());
 	}
 	if (direction < 0) {
 		// Line wrapping may lead to a location on the same line, so
@@ -5094,10 +5195,10 @@
 		Duplicate(false);
 		break;
 	case SCI_LOWERCASE:
-		ChangeCaseOfSelection(false);
+		ChangeCaseOfSelection(cmLower);
 		break;
 	case SCI_UPPERCASE:
-		ChangeCaseOfSelection(true);
+		ChangeCaseOfSelection(cmUpper);
 		break;
 	case SCI_WORDPARTLEFT:
 		MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1));
@@ -5205,7 +5306,7 @@
 					int indentation = pdoc->GetLineIndentation(lineCurrentPos);
 					int indentationStep = pdoc->IndentSize();
 					pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
-					SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
+					sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
 				} else {
 					int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
 							pdoc->tabInChars;
@@ -5244,6 +5345,31 @@
 	}
 }
 
+class CaseFolderASCII : public CaseFolderTable {
+public:
+	CaseFolderASCII() {
+		StandardASCII();
+	}
+	~CaseFolderASCII() {
+	}
+	virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
+		if (lenMixed > sizeFolded) {
+			return 0;
+		} else {
+			for (size_t i=0; i<lenMixed; i++) {
+				folded[i] = mapping[static_cast<unsigned char>(mixed[i])];
+			}
+			return lenMixed;
+		}
+	}
+};
+
+
+CaseFolder *Editor::CaseFolderForEncoding() {
+	// Simple default that only maps ASCII upper case to lower case.
+	return new CaseFolderASCII();
+}
+
 /**
  * Search of a text in the document, in the given range.
  * @return The position of the found text, -1 if not found.
@@ -5255,13 +5381,15 @@
 
 	Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam);
 	int lengthFound = istrlen(ft->lpstrText);
+	std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding());
 	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,
-	        &lengthFound);
+	        &lengthFound,
+			pcf.get());
 	if (pos != -1) {
 		ft->chrgText.cpMin = pos;
 		ft->chrgText.cpMax = pos + lengthFound;
@@ -5298,6 +5426,7 @@
 	const char *txt = reinterpret_cast<char *>(lParam);
 	int pos;
 	int lengthFound = istrlen(txt);
+	std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding());
 	if (iMessage == SCI_SEARCHNEXT) {
 		pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
 		        (wParam & SCFIND_MATCHCASE) != 0,
@@ -5305,7 +5434,8 @@
 		        (wParam & SCFIND_WORDSTART) != 0,
 		        (wParam & SCFIND_REGEXP) != 0,
 		        wParam,
-		        &lengthFound);
+		        &lengthFound,
+				pcf.get());
 	} else {
 		pos = pdoc->FindText(searchAnchor, 0, txt,
 		        (wParam & SCFIND_MATCHCASE) != 0,
@@ -5313,9 +5443,9 @@
 		        (wParam & SCFIND_WORDSTART) != 0,
 		        (wParam & SCFIND_REGEXP) != 0,
 		        wParam,
-		        &lengthFound);
+		        &lengthFound,
+				pcf.get());
 	}
-
 	if (pos != -1) {
 		SetSelection(pos, pos + lengthFound);
 	}
@@ -5323,19 +5453,39 @@
 	return pos;
 }
 
+std::string Editor::CaseMapString(const std::string &s, int caseMapping) {
+	std::string ret(s);
+	for (size_t i=0; i<ret.size(); i++) {
+		switch (caseMapping) {
+			case cmUpper:
+				if (ret[i] >= 'a' && ret[i] <= 'z')
+					ret[i] = static_cast<char>(ret[i] - 'a' + 'A');
+				break;
+			case cmLower:
+				if (ret[i] >= 'A' && ret[i] <= 'Z')
+					ret[i] = static_cast<char>(ret[i] - 'A' + 'a');
+				break;
+		}
+	}
+	return ret;
+}
+
 /**
  * Search for text in the target range of the document.
  * @return The position of the found text, -1 if not found.
  */
 long Editor::SearchInTarget(const char *text, int length) {
 	int lengthFound = length;
+
+	std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding());
 	int pos = pdoc->FindText(targetStart, targetEnd, text,
 	        (searchFlags & SCFIND_MATCHCASE) != 0,
 	        (searchFlags & SCFIND_WHOLEWORD) != 0,
 	        (searchFlags & SCFIND_WORDSTART) != 0,
 	        (searchFlags & SCFIND_REGEXP) != 0,
 	        searchFlags,
-	        &lengthFound);
+	        &lengthFound,
+			pcf.get());
 	if (pos != -1) {
 		targetStart = pos;
 		targetEnd = pos + lengthFound;
@@ -5615,7 +5765,11 @@
 	}
 }
 
-static bool AllowVirtualSpace(int	virtualSpaceOptions, bool rectangular) {
+void Editor::MouseLeave() {
+	SetHotSpotRange(NULL);
+}
+
+static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
 	return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0)
 		|| (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0));
 }
@@ -5745,7 +5899,7 @@
 		}
 	}
 	lastClickTime = curTime;
-	lastXChosen = pt.x;
+	lastXChosen = pt.x + xOffset;
 	ShowCaretAtCurrentPosition();
 }
 
@@ -5793,7 +5947,7 @@
 	}
 }
 
-void Editor::GetHotSpotRange(int& hsStart_, int& hsEnd_) {
+void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) {
 	hsStart_ = hsStart;
 	hsEnd_ = hsEnd;
 }
@@ -5891,6 +6045,7 @@
 		if (vs.fixedColumnWidth > 0) {	// There is a margin
 			if (PointInSelMargin(pt)) {
 				DisplayCursor(Window::cursorReverseArrow);
+				SetHotSpotRange(NULL);
 				return; 	// No need to test for selection
 			}
 		}
@@ -5968,7 +6123,7 @@
 		SetRectangularRange();
 		lastClickTime = curTime;
 		lastClick = pt;
-		lastXChosen = pt.x;
+		lastXChosen = pt.x + xOffset;
 		if (sel.selType == Selection::selStream) {
 			SetLastXChosen();
 		}
@@ -6257,6 +6412,24 @@
 	}
 }
 
+int Editor::GetTag(char *tagValue, int tagNumber) {
+	char name[3] = "\\?";
+	const char *text = 0;
+	int length = 0;
+	if ((tagNumber >= 1) && (tagNumber <= 9)) {
+		name[1] = static_cast<char>(tagNumber + '0');
+		length = 2;
+		text = pdoc->SubstituteByPosition(name, &length);
+	}
+	if (tagValue) {
+		if (text)
+			memcpy(tagValue, text, length + 1);
+		else
+			*tagValue = '\0';
+	}
+	return length;
+}
+
 int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
 	UndoGroup ug(pdoc);
 	if (length == -1)
@@ -6303,11 +6476,11 @@
 	size_t textLength = appendLength / 2;
 	char *text = new char[textLength];
 	size_t i;
-	for (i = 0;i < textLength;i++) {
+	for (i = 0; i < textLength; i++) {
 		text[i] = buffer[i*2];
 	}
 	pdoc->InsertString(CurrentPosition(), text, textLength);
-	for (i = 0;i < textLength;i++) {
+	for (i = 0; i < textLength; i++) {
 		text[i] = buffer[i*2+1];
 	}
 	pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
@@ -6641,6 +6814,9 @@
 	case SCI_GETSEARCHFLAGS:
 		return searchFlags;
 
+	case SCI_GETTAG:
+		return GetTag(CharPtrFromSPtr(lParam), wParam);
+
 	case SCI_POSITIONBEFORE:
 		return pdoc->MovePositionOutsideChar(wParam - 1, -1, true);
 
@@ -7127,9 +7303,11 @@
 		return wrapState;
 
 	case SCI_SETWRAPVISUALFLAGS:
-		wrapVisualFlags = wParam;
-		InvalidateStyleRedraw();
-		ReconfigureScrollBars();
+		if (wrapVisualFlags != static_cast<int>(wParam)) {
+			wrapVisualFlags = wParam;
+			InvalidateStyleRedraw();
+			ReconfigureScrollBars();
+		}
 		break;
 
 	case SCI_GETWRAPVISUALFLAGS:
@@ -7144,18 +7322,22 @@
 		return wrapVisualFlagsLocation;
 
 	case SCI_SETWRAPSTARTINDENT:
-		wrapVisualStartIndent = wParam;
-		InvalidateStyleRedraw();
-		ReconfigureScrollBars();
+		if (wrapVisualStartIndent != static_cast<int>(wParam)) {
+			wrapVisualStartIndent = wParam;
+			InvalidateStyleRedraw();
+			ReconfigureScrollBars();
+		}
 		break;
 
 	case SCI_GETWRAPSTARTINDENT:
 		return wrapVisualStartIndent;
 
 	case SCI_SETWRAPINDENTMODE:
-		wrapIndentMode = wParam;
-		InvalidateStyleRedraw();
-		ReconfigureScrollBars();
+		if (wrapIndentMode != static_cast<int>(wParam)) {
+			wrapIndentMode = wParam;
+			InvalidateStyleRedraw();
+			ReconfigureScrollBars();
+		}
 		break;
 
 	case SCI_GETWRAPINDENTMODE:
@@ -8261,6 +8443,13 @@
 	case SCI_GETADDITIONALSELECTIONTYPING:
 		return additionalSelectionTyping;
 
+	case SCI_SETMULTIPASTE:
+		multiPasteMode = wParam;
+		break;
+
+	case SCI_GETMULTIPASTE:
+		return multiPasteMode;
+
 	case SCI_SETADDITIONALCARETSBLINK:
 		additionalCaretsBlink = wParam != 0;
 		InvalidateCaret();

Modified: trunk/scintilla/Editor.h
===================================================================
--- trunk/scintilla/Editor.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/Editor.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -142,6 +142,7 @@
 	bool caretSticky;
 	bool multipleSelection;
 	bool additionalSelectionTyping;
+	int multiPasteMode;
 	bool additionalCaretsBlink;
 	bool additionalCaretsVisible;
 
@@ -338,7 +339,7 @@
         PRectangle rcLine, LineLayout *ll, int subLine);
 	void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
 		PRectangle rcLine, LineLayout *ll, int subLine);
-	void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, 
+	void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
 		int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour);
 	void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 		PRectangle rcLine, LineLayout *ll, int subLine);
@@ -358,6 +359,7 @@
 	int InsertSpace(int position, unsigned int spaces);
 	void AddChar(char ch);
 	virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
+	void InsertPaste(SelectionPosition selStart, const char *text, int len);
 	void ClearSelection();
 	void ClearAll();
 	void ClearDocumentStyle();
@@ -403,7 +405,9 @@
 	void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
 	void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
-	void ChangeCaseOfSelection(bool makeUpperCase);
+	enum { cmSame, cmUpper, cmLower } caseMap;
+	virtual std::string CaseMapString(const std::string &s, int caseMapping);
+	void ChangeCaseOfSelection(int caseMapping);
 	void LineTranspose();
 	void Duplicate(bool forLine);
 	virtual void CancelModes();
@@ -420,6 +424,7 @@
 
 	void Indent(bool forwards);
 
+	virtual CaseFolder *CaseFolderForEncoding();
 	long FindText(uptr_t wParam, sptr_t lParam);
 	void SearchAnchor();
 	long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
@@ -442,6 +447,7 @@
 	bool PointInSelMargin(Point pt);
 	void LineSelection(int lineCurrent_, int lineAnchor_);
 	void DwellEnd(bool mouseMoved);
+	void MouseLeave();
 	virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
 	void ButtonMove(Point pt);
 	void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
@@ -461,18 +467,19 @@
 
 	void SetAnnotationHeights(int start, int end);
 	void SetDocPointer(Document *document);
-	
+
 	void SetAnnotationVisible(int visible);
 
 	void Expand(int &line, bool doExpand);
 	void ToggleContraction(int line);
 	void EnsureLineVisible(int lineDoc, bool enforcePolicy);
+	int GetTag(char *tagValue, int tagNumber);
 	int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
 
 	bool PositionIsHotspot(int position);
 	bool PointIsHotspot(Point pt);
 	void SetHotSpotRange(Point *pt);
-	void GetHotSpotRange(int& hsStart, int& hsEnd);
+	void GetHotSpotRange(int &hsStart, int &hsEnd);
 
 	int CodePage() const;
 	virtual bool ValidCodePage(int /* codePage */) const { return true; }

Modified: trunk/scintilla/LexHTML.cxx
===================================================================
--- trunk/scintilla/LexHTML.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/LexHTML.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -76,12 +76,12 @@
 		char ch = static_cast<char>(styler.SafeGetCharAt(start + i));
 		if ((i == 0) && !IsAWordStart(ch))
 			break;
-		if ((i > 0) && !IsAWordChar(ch)) 
+		if ((i > 0) && !IsAWordChar(ch))
 			break;
 		s[i] = ch;
 	}
 	s[i] = '\0';
-	
+
 	return s;
 }
 
@@ -494,7 +494,7 @@
 	if (strlen(blockType) == 0) {
 		return ((ch == '%') && (chNext == '>'));
 	} else if ((0 == strcmp(blockType, "inherit")) ||
-			   (0 == strcmp(blockType, "namespace")) || 
+			   (0 == strcmp(blockType, "namespace")) ||
 			   (0 == strcmp(blockType, "include")) ||
 			   (0 == strcmp(blockType, "page"))) {
 		return ((ch == '/') && (chNext == '>'));
@@ -507,6 +507,18 @@
 	}
 }
 
+static bool isDjangoBlockEnd(const int ch, const int chNext, const char *blockType) {
+	if (strlen(blockType) == 0) {
+		return 0;
+	} else if (0 == strcmp(blockType, "%")) {
+		return ((ch == '%') && (chNext == '}'));
+	} else if (0 == strcmp(blockType, "{")) {
+		return ((ch == '}') && (chNext == '}'));
+	} else {
+		return 0;
+	}
+}
+
 static bool isPHPStringState(int state) {
 	return
 	    (state == SCE_HPHP_HSTRING) ||
@@ -583,6 +595,8 @@
 	int state = stateForPrintState(StateToPrint);
 	char makoBlockType[200];
 	makoBlockType[0] = '\0';
+	char djangoBlockType[2];
+	djangoBlockType[0] = '\0';
 
 	// If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen
 	if (InTagState(state)) {
@@ -612,8 +626,8 @@
 		// Default client and ASP scripting language is JavaScript
 		lineState = eScriptJS << 8;
 
-		// property asp.default.language 
-		//	Script in ASP code is initially assumed to be in JavaScript. 
+		// property asp.default.language
+		//	Script in ASP code is initially assumed to be in JavaScript.
 		//	To change this to VBScript set asp.default.language to 2. Python is 3.
 		lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
 	}
@@ -631,43 +645,47 @@
 		scriptLanguage = eScriptComment;
 	}
 
-	// property fold.html 
-	//	Folding is turned on or off for HTML and XML files with this option. 
+	// property fold.html
+	//	Folding is turned on or off for HTML and XML files with this option.
 	//	The fold option must also be on for folding to occur.
 	const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0;
 
 	const bool fold = foldHTML && styler.GetPropertyInt("fold", 0);
 
-	// property fold.html.preprocessor 
-	//	Folding is turned on or off for scripts embedded in HTML files with this option. 
+	// property fold.html.preprocessor
+	//	Folding is turned on or off for scripts embedded in HTML files with this option.
 	//	The default is on.
 	const bool foldHTMLPreprocessor = foldHTML && styler.GetPropertyInt("fold.html.preprocessor", 1);
 
 	const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
 
-	// property fold.hypertext.comment 
-	//	Allow folding for comments in scripts embedded in HTML. 
-	//	The default is off. 
+	// property fold.hypertext.comment
+	//	Allow folding for comments in scripts embedded in HTML.
+	//	The default is off.
 	const bool foldComment = fold && styler.GetPropertyInt("fold.hypertext.comment", 0) != 0;
 
-	// property fold.hypertext.heredoc 
-	//	Allow folding for heredocs in scripts embedded in HTML. 
-	//	The default is off.  
+	// property fold.hypertext.heredoc
+	//	Allow folding for heredocs in scripts embedded in HTML.
+	//	The default is off.
 	const bool foldHeredoc = fold && styler.GetPropertyInt("fold.hypertext.heredoc", 0) != 0;
 
-	// property html.tags.case.sensitive 
-	//	For XML and HTML, setting this property to 1 will make tags match in a case 
-	//	sensitive way which is the expected behaviour for XML and XHTML. 
+	// property html.tags.case.sensitive
+	//	For XML and HTML, setting this property to 1 will make tags match in a case
+	//	sensitive way which is the expected behaviour for XML and XHTML.
 	const bool caseSensitive = styler.GetPropertyInt("html.tags.case.sensitive", 0) != 0;
 
-	// property lexer.xml.allow.scripts 
-	//	Set to 0 to disable scripts in XML.  
+	// property lexer.xml.allow.scripts
+	//	Set to 0 to disable scripts in XML.
 	const bool allowScripts = styler.GetPropertyInt("lexer.xml.allow.scripts", 1) != 0;
 
-	// property lexer.html.mako 
-	//	Set to 1 to enable the mako template language.  
+	// property lexer.html.mako
+	//	Set to 1 to enable the mako template language.
 	const bool isMako = styler.GetPropertyInt("lexer.html.mako", 0) != 0;
 
+	// property lexer.html.django
+	//	Set to 1 to enable the django template language.  
+	const bool isDjango = styler.GetPropertyInt("lexer.html.django", 0) != 0;
+
 	const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
 	const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true);
 	const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true);
@@ -800,7 +818,7 @@
 		if (((ch == '\r' && chNext != '\n') || (ch == '\n')) &&
 			(!isMako || (0 != strcmp(makoBlockType, "%")))) {
 		}
-		
+
 		// generic end of script processing
 		else if ((inScriptType == eNonHtmlScript) && (ch == '<') && (chNext == '/')) {
 			// Check if it's the end of the script tag (or any other HTML tag)
@@ -886,13 +904,13 @@
 		}
 
 		// handle the start Mako template Python code
-		else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') || 
+		else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') ||
 															 (lineStartVisibleChars == 1 && ch == '%') ||
 															 (ch == '$' && chNext == '{') ||
 															 (ch == '<' && chNext == '/' && chNext2 == '%'))) {
 			if (ch == '%')
 				strcpy(makoBlockType, "%");
-			else if (ch == '$') 
+			else if (ch == '$')
 				strcpy(makoBlockType, "{");
 			else if (chNext == '/')
 				GetNextWord(styler, i+3, makoBlockType, sizeof(makoBlockType));
@@ -917,7 +935,7 @@
 			styler.ColourTo(i, SCE_H_ASP);
 			if (foldHTMLPreprocessor && ch == '<')
 				levelCurrent++;
-				
+
 			if (ch != '%' && ch != '$') {
 				i += strlen(makoBlockType);
 				visibleChars += strlen(makoBlockType);
@@ -931,8 +949,33 @@
 			continue;
 		}
 
+		// handle the start Django template code
+		else if (isDjango && scriptLanguage == eScriptNone && (ch == '{' && (chNext == '%' ||  chNext == '{'))) {
+			if (chNext == '%')
+				strcpy(djangoBlockType, "%");
+			else
+				strcpy(djangoBlockType, "{");
+			styler.ColourTo(i - 1, StateToPrint);
+			beforePreProc = state;
+			if (inScriptType == eNonHtmlScript)
+				inScriptType = eNonHtmlScriptPreProc;
+			else
+				inScriptType = eNonHtmlPreProc;
+
+			i += 1;
+			visibleChars += 1;
+			state = SCE_HP_START;
+			scriptLanguage = eScriptPython;
+			styler.ColourTo(i, SCE_H_ASP);
+			if (foldHTMLPreprocessor && chNext == '%')
+				levelCurrent++;
+
+			ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
+			continue;
+		}
+
 		// handle the start of ASP pre-processor = Non-HTML
-		else if (!isMako && !isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) {
+		else if (!isMako && !isDjango && !isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) {
 			styler.ColourTo(i - 1, StateToPrint);
 			beforePreProc = state;
 			if (inScriptType == eNonHtmlScript)
@@ -998,8 +1041,8 @@
 		}
 
 		// handle the end of Mako Python code
-		else if (isMako && 
-			     ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && 
+		else if (isMako &&
+			     ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) &&
 				 (scriptLanguage != eScriptNone) && stateAllowsTermination(state) &&
 				 isMakoBlockEnd(ch, chNext, makoBlockType)) {
 			if (state == SCE_H_ASPAT) {
@@ -1030,8 +1073,37 @@
 			continue;
 		}
 
+		// handle the end of Django template code
+		else if (isDjango && 
+			     ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && 
+				 (scriptLanguage != eScriptNone) && stateAllowsTermination(state) &&
+				 isDjangoBlockEnd(ch, chNext, djangoBlockType)) {
+			if (state == SCE_H_ASPAT) {
+				aspScript = segIsScriptingIndicator(styler,
+				                                    styler.GetStartSegment(), i - 1, aspScript);
+			}
+			if (state == SCE_HP_WORD) {
+				classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
+			} else {
+				styler.ColourTo(i - 1, StateToPrint);
+			}
+			i += 1;
+			visibleChars += 1;
+			styler.ColourTo(i, SCE_H_ASP);
+			state = beforePreProc;
+			if (inScriptType == eNonHtmlScriptPreProc)
+				inScriptType = eNonHtmlScript;
+			else
+				inScriptType = eHtml;
+			if (foldHTMLPreprocessor) {
+				levelCurrent--;
+			}
+			scriptLanguage = eScriptNone;
+			continue;
+		}
+
 		// handle the end of a pre-processor = Non-HTML
-		else if ((!isMako && ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) &&
+		else if ((!isMako && !isDjango && ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) &&
 				  (((scriptLanguage != eScriptNone) && stateAllowsTermination(state))) &&
 				  (((ch == '%') || (ch == '?')) && (chNext == '>'))) ||
 		         ((scriptLanguage == eScriptSGML) && (ch == '>') && (state != SCE_H_SGML_COMMENT))) {

Modified: trunk/scintilla/LexOthers.cxx
===================================================================
--- trunk/scintilla/LexOthers.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/LexOthers.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -37,6 +37,10 @@
 	return (ch >= '1') && (ch <= '9');
 }
 
+static bool IsAlphabetic(int ch) {
+	return isascii(ch) && isalpha(ch);
+}
+
 static inline bool AtEOL(Accessor &styler, unsigned int i) {
 	return (styler[i] == '\n') ||
 	       ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
@@ -101,7 +105,7 @@
 		}
 		return;
 	// Check for Drive Change (Drive Change is internal command) - return if found
-	} else if ((isalpha(lineBuffer[offset])) &&
+	} else if ((IsAlphabetic(lineBuffer[offset])) &&
 		(lineBuffer[offset + 1] == ':') &&
 		((isspacechar(lineBuffer[offset + 2])) ||
 		(((lineBuffer[offset + 2] == '\\')) &&
@@ -723,10 +727,10 @@
 	unsigned int linePos = 0;
 	unsigned int startLine = startPos;
 
-	// property lexer.props.allow.initial.spaces 
-	//	For properties files, set to 0 to style all lines that start with whitespace in the default style. 
-	//	This is not suitable for SciTE .properties files which use indentation for flow control but 
-	//	can be used for RFC2822 text where indentation is used for continuation lines. 
+	// property lexer.props.allow.initial.spaces
+	//	For properties files, set to 0 to style all lines that start with whitespace in the default style.
+	//	This is not suitable for SciTE .properties files which use indentation for flow control but
+	//	can be used for RFC2822 text where indentation is used for continuation lines.
 	bool allowInitialSpaces = styler.GetPropertyInt("lexer.props.allow.initial.spaces", 1) != 0;
 
 	for (unsigned int i = startPos; i < startPos + length; i++) {
@@ -961,17 +965,17 @@
 	} else if (strstart(lineBuffer, "Warning ")) {
 		// Borland warning message
 		return SCE_ERR_BORLAND;
-	} else if (strstr(lineBuffer, "at line " ) &&
-	           (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
+	} else if (strstr(lineBuffer, "at line ") &&
+	        (strstr(lineBuffer, "at line ") < (lineBuffer + lengthLine)) &&
 	           strstr(lineBuffer, "file ") &&
 	           (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
 		// Lua 4 error message
 		return SCE_ERR_LUA;
-	} else if (strstr(lineBuffer, " at " ) &&
-	           (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
+	} else if (strstr(lineBuffer, " at ") &&
+	        (strstr(lineBuffer, " at ") < (lineBuffer + lengthLine)) &&
 	           strstr(lineBuffer, " line ") &&
 	           (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) &&
-	           (strstr(lineBuffer, " at " ) < (strstr(lineBuffer, " line ")))) {
+	        (strstr(lineBuffer, " at ") < (strstr(lineBuffer, " line ")))) {
 		// perl error message
 		return SCE_ERR_PERL;
 	} else if ((memcmp(lineBuffer, "   at ", 6) == 0) &&
@@ -1065,7 +1069,7 @@
 						numstep = 1; // ch was ' ', handle as if it's a delphi errorline, only add 1 to i.
 					else
 						numstep = 2; // otherwise add 2.
-					for (j = i + numstep; j < lengthLine && isalpha(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
+					for (j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
 						word[chPos++] = lineBuffer[j];
 					word[chPos] = 0;
 					if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") ||
@@ -1131,11 +1135,11 @@
 	styler.StartSegment(startPos);
 	unsigned int linePos = 0;
 
-	// property lexer.errorlist.value.separate 
-	//	For lines in the output pane that are matches from Find in Files or GCC-style 
-	//	diagnostics, style the path and line number separately from the rest of the 
-	//	line with style 21 used for the rest of the line. 
-	//	This allows matched text to be more easily distinguished from its location. 
+	// property lexer.errorlist.value.separate
+	//	For lines in the output pane that are matches from Find in Files or GCC-style
+	//	diagnostics, style the path and line number separately from the rest of the
+	//	line with style 21 used for the rest of the line.
+	//	This allows matched text to be more easily distinguished from its location.
 	bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0;
 	for (unsigned int i = startPos; i < startPos + length; i++) {
 		lineBuffer[linePos++] = styler[i];
@@ -1252,13 +1256,13 @@
 	styler.ColourTo(lengthDoc-1, state);
 }
 
-static const char * const batchWordListDesc[] = {
+static const char *const batchWordListDesc[] = {
 	"Internal Commands",
 	"External Commands",
 	0
 };
 
-static const char * const emptyWordListDesc[] = {
+static const char *const emptyWordListDesc[] = {
 	0
 };
 

Modified: trunk/scintilla/PlatGTK.cxx
===================================================================
--- trunk/scintilla/PlatGTK.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/PlatGTK.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -31,10 +31,7 @@
    with gdk_string_extents. */
 #define FAST_WAY
 
-#if GTK_MAJOR_VERSION >= 2
-#define USE_PANGO 1
 #include "Converter.h"
-#endif
 
 #ifdef _MSC_VER
 // Ignore unreferenced local functions in GTK+ headers
@@ -105,21 +102,16 @@
 public:
 	int ascent;
 	GdkFont *pfont;
-#ifdef USE_PANGO
 	PangoFontDescription *pfd;
 	int characterSet;
-#endif
 	FontHandle(GdkFont *pfont_) {
 		et = singleByte;
 		ascent = 0;
 		pfont = pfont_;
-#ifdef USE_PANGO
 		pfd = 0;
 		characterSet = -1;
-#endif
 		ResetWidths(et);
 	}
-#ifdef USE_PANGO
 	FontHandle(PangoFontDescription *pfd_, int characterSet_) {
 		et = singleByte;
 		ascent = 0;
@@ -128,16 +120,13 @@
 		characterSet = characterSet_;
 		ResetWidths(et);
 	}
-#endif
 	~FontHandle() {
 		if (pfont)
 			gdk_font_unref(pfont);
 		pfont = 0;
-#ifdef USE_PANGO
 		if (pfd)
 			pango_font_description_free(pfd);
 		pfd = 0;
-#endif
 	}
 	void ResetWidths(encodingType et_) {
 		et = et_;
@@ -513,7 +502,6 @@
 	faceName[0] = '\0';
 	charset[0] = '\0';
 
-#ifdef USE_PANGO
 	if (fontName[0] == '!') {
 		PangoFontDescription *pfd = pango_font_description_new();
 		if (pfd) {
@@ -524,7 +512,6 @@
 			return new FontHandle(pfd, characterSet);
 		}
 	}
-#endif
 
 	GdkFont *newid = 0;
 	// If name of the font begins with a '-', assume, that it is
@@ -693,13 +680,11 @@
 	int y;
 	bool inited;
 	bool createdGC;
-#ifdef USE_PANGO
 	PangoContext *pcontext;
 	PangoLayout *layout;
 	Converter conv;
 	int characterSet;
 	void SetConverter(int characterSet_);
-#endif
 public:
 	SurfaceImpl();
 	virtual ~SurfaceImpl();
@@ -796,22 +781,16 @@
 	}
 }
 
-#ifdef USE_PANGO
-
 void SurfaceImpl::SetConverter(int characterSet_) {
 	if (characterSet != characterSet_) {
 		characterSet = characterSet_;
 		conv.Open("UTF-8", CharacterSetID(characterSet), false);
 	}
 }
-#endif
 
 SurfaceImpl::SurfaceImpl() : et(singleByte), drawable(0), gc(0), ppixmap(0),
 x(0), y(0), inited(false), createdGC(false)
-#ifdef USE_PANGO
-, pcontext(0), layout(0), characterSet(-1)
-#endif
-{
+, pcontext(0), layout(0), characterSet(-1) {
 }
 
 SurfaceImpl::~SurfaceImpl() {
@@ -829,7 +808,6 @@
 	if (ppixmap)
 		gdk_pixmap_unref(ppixmap);
 	ppixmap = 0;
-#ifdef USE_PANGO
 	if (layout)
 		g_object_unref(layout);
 	layout = 0;
@@ -838,7 +816,6 @@
 	pcontext = 0;
 	conv.Close();
 	characterSet = -1;
-#endif
 	x = 0;
 	y = 0;
 	inited = false;
@@ -849,34 +826,23 @@
 	return inited;
 }
 
-// The WindowID argument is only used for Pango builds
-#ifdef USE_PANGO
-#define WID_NAME wid
-#else
-#define WID_NAME
-#endif
-
-void SurfaceImpl::Init(WindowID WID_NAME) {
+void SurfaceImpl::Init(WindowID wid) {
 	Release();
-#ifdef USE_PANGO
 	PLATFORM_ASSERT(wid);
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	PLATFORM_ASSERT(pcontext);
 	layout = pango_layout_new(pcontext);
 	PLATFORM_ASSERT(layout);
-#endif
 	inited = true;
 }
 
-void SurfaceImpl::Init(SurfaceID sid, WindowID WID_NAME) {
+void SurfaceImpl::Init(SurfaceID sid, WindowID wid) {
 	PLATFORM_ASSERT(sid);
 	GdkDrawable *drawable_ = reinterpret_cast<GdkDrawable *>(sid);
 	Release();
-#ifdef USE_PANGO
 	PLATFORM_ASSERT(wid);
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	layout = pango_layout_new(pcontext);
-#endif
 	drawable = drawable_;
 	gc = gdk_gc_new(drawable_);
 	// Ask for lines that do not paint the last pixel so is like Win32
@@ -885,18 +851,16 @@
 	inited = true;
 }
 
-void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID WID_NAME) {
+void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID wid) {
 	PLATFORM_ASSERT(surface_);
 	Release();
 	SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_);
 	PLATFORM_ASSERT(surfImpl->drawable);
-#ifdef USE_PANGO
 	PLATFORM_ASSERT(wid);
 	pcontext = gtk_widget_create_pango_context(PWidget(wid));
 	PLATFORM_ASSERT(pcontext);
 	layout = pango_layout_new(pcontext);
 	PLATFORM_ASSERT(layout);
-#endif
 	if (height > 0 && width > 0)
 		ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1);
 	drawable = ppixmap;
@@ -1023,8 +987,6 @@
 	}
 }
 
-#if GTK_MAJOR_VERSION >= 2
-
 // Plot a point into a guint32 buffer symetrically to all 4 qudrants
 static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) {
 	pixels[y*stride+x] = val;
@@ -1045,20 +1007,6 @@
 	return co & 0xff;
 }
 
-#endif
-
-#if GTK_MAJOR_VERSION < 2
-void SurfaceImpl::AlphaRectangle(PRectangle rc, int , ColourAllocated , int , ColourAllocated outline, int , int ) {
-	if (gc && drawable) {
-		// Can't use GdkPixbuf on GTK+ 1.x, so draw an outline rather than use alpha.
-		PenColour(outline);
-		gdk_draw_rectangle(drawable, gc, 0,
-		                   rc.left, rc.top,
-		                   rc.right - rc.left - 1, rc.bottom - rc.top - 1);
-	}
-}
-#else
-
 static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) {
 	union {
 		guint8 pixVal[4];
@@ -1082,9 +1030,9 @@
 		GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
 
 		guint32 valEmpty = u32FromRGBA(0,0,0,0);
-		guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()), 
+		guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()),
 			GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill);
-		guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()), 
+		guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()),
 			GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline);
 		guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha));
 		int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4;
@@ -1114,8 +1062,6 @@
 	}
 }
 
-#endif
-
 void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
 	PenColour(back);
 	gdk_draw_arc(drawable, gc, 1,
@@ -1169,7 +1115,6 @@
 	return utfForm;
 }
 
-#ifdef USE_PANGO
 static char *UTF8FromIconv(const Converter &conv, const char *s, int &len) {
 	if (conv) {
 		char *utfForm = new char[len*3+1];
@@ -1254,8 +1199,6 @@
 	}
 }
 
-#endif
-
 // On GTK+, wchar_t is 4 bytes
 
 const int maxLengthTextRun = 10000;
@@ -1265,7 +1208,6 @@
 	PenColour(fore);
 	if (gc && drawable) {
 		int xText = rc.left;
-#ifdef USE_PANGO
 		if (PFont(font_)->pfd) {
 			char *utfForm = 0;
 			bool useGFree = false;
@@ -1301,7 +1243,6 @@
 			}
 			return;
 		}
-#endif
 		// Draw text as a series of segments to avoid limitations in X servers
 		const int segmentLength = 1000;
 		bool draw8bit = true;
@@ -1376,8 +1317,6 @@
 	}
 }
 
-#ifdef USE_PANGO
-
 class ClusterIterator {
 	PangoLayoutIter *iter;
 	PangoRectangle pos;
@@ -1388,8 +1327,8 @@
 	int position;
 	int distance;
 	int curIndex;
-	ClusterIterator(PangoLayout *layout, int len) : lenPositions(len), finished(false), 
-		positionStart(0), position(0), distance(0) {
+	ClusterIterator(PangoLayout *layout, int len) : lenPositions(len), finished(false),
+		positionStart(0), position(0), distance(0), curIndex(0) {
 		iter = pango_layout_get_iter(layout);
 		pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
 	}
@@ -1397,7 +1336,7 @@
 		pango_layout_iter_free(iter);
 	}
 
-	void Next() { 
+	void Next() {
 		positionStart = position;
 		if (pango_layout_iter_next_cluster(iter)) {
 			pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
@@ -1412,12 +1351,9 @@
 	}
 };
 
-#endif
-
 void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
 	if (font_.GetID()) {
 		int totalWidth = 0;
-#ifdef USE_PANGO
 		const int lenPositions = len;
 		if (PFont(font_)->pfd) {
 			if (len == 1) {
@@ -1516,7 +1452,6 @@
 			}
 			return;
 		}
-#endif
 		GdkFont *gf = PFont(font_)->pfont;
 		bool measure8bit = true;
 		if (et != singleByte) {
@@ -1577,7 +1512,6 @@
 
 int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
 	if (font_.GetID()) {
-#ifdef USE_PANGO
 		if (PFont(font_)->pfd) {
 			char *utfForm = 0;
 			pango_layout_set_font_description(layout, PFont(font_)->pfd);
@@ -1612,7 +1546,6 @@
 			}
 			return PANGO_PIXELS(pos.width);
 		}
-#endif
 		if (et == UTF8) {
 			GdkWChar wctext[maxLengthTextRun];
 			size_t wclen = UTF16FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)),
@@ -1629,11 +1562,9 @@
 
 int SurfaceImpl::WidthChar(Font &font_, char ch) {
 	if (font_.GetID()) {
-#ifdef USE_PANGO
 		if (PFont(font_)->pfd) {
 			return WidthText(font_, &ch, 1);
 		}
-#endif
 		return gdk_char_width(PFont(font_)->pfont, ch);
 	} else {
 		return 1;
@@ -1663,7 +1594,6 @@
 #ifdef FAST_WAY
 	FontMutexLock();
 	int ascent = PFont(font_)->ascent;
-#ifdef USE_PANGO
 	if ((ascent == 0) && (PFont(font_)->pfd)) {
 		PangoFontMetrics *metrics = pango_context_get_metrics(pcontext,
 			PFont(font_)->pfd, pango_context_get_language(pcontext));
@@ -1672,7 +1602,6 @@
 		pango_font_metrics_unref(metrics);
 		ascent = PFont(font_)->ascent;
 	}
-#endif
 	if ((ascent == 0) && (PFont(font_)->pfont)) {
 		ascent = PFont(font_)->pfont->ascent;
 	}
@@ -1700,7 +1629,6 @@
 		return 1;
 #ifdef FAST_WAY
 
-#ifdef USE_PANGO
 	if (PFont(font_)->pfd) {
 		PangoFontMetrics *metrics = pango_context_get_metrics(pcontext,
 			PFont(font_)->pfd, pango_context_get_language(pcontext));
@@ -1708,7 +1636,6 @@
 		pango_font_metrics_unref(metrics);
 		return descent;
 	}
-#endif
 	return PFont(font_)->pfont->descent;
 #else
 
@@ -1794,18 +1721,12 @@
 }
 
 void Window::SetPosition(PRectangle rc) {
-#if 1
 	GtkAllocation alloc;
 	alloc.x = rc.left;
 	alloc.y = rc.top;
 	alloc.width = rc.Width();
 	alloc.height = rc.Height();
 	gtk_widget_size_allocate(PWidget(wid), &alloc);
-#else
-
-	gtk_widget_set_uposition(wid, rc.left, rc.top);
-	gtk_widget_set_usize(wid, rc.right - rc.left, rc.bottom - rc.top);
-#endif
 }
 
 void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
@@ -1831,21 +1752,8 @@
 	if (oy + sizey > screenHeight)
 		oy = screenHeight - sizey;
 
-#if GTK_MAJOR_VERSION >= 2
 	gtk_window_move(GTK_WINDOW(PWidget(wid)), ox, oy);
-#else
-	gtk_widget_set_uposition(PWidget(wid), ox, oy);
-#endif
 
-#if 0
-
-	GtkAllocation alloc;
-	alloc.x = rc.left + ox;
-	alloc.y = rc.top + oy;
-	alloc.width = rc.right - rc.left;
-	alloc.height = rc.bottom - rc.top;
-	gtk_widget_size_allocate(wid, &alloc);
-#endif
 	gtk_widget_set_usize(PWidget(wid), sizex, sizey);
 }
 
@@ -1927,8 +1835,8 @@
 
 	gdk_window_get_origin(PWidget(wid)->window, &x_offset, &y_offset);
 
-// gtk 2.2+
-#if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2)
+#if GTK_CHECK_VERSION(2,2,0)
+	// GTK+ 2.2+
 	{
 		GdkScreen* screen;
 		gint monitor_num;
@@ -1949,25 +1857,13 @@
 
 struct ListImage {
 	const char *xpm_data;
-#if GTK_MAJOR_VERSION < 2
-	GdkPixmap *pixmap;
-	GdkBitmap *bitmap;
-#else
 	GdkPixbuf *pixbuf;
-#endif
 };
 
 static void list_image_free(gpointer, gpointer value, gpointer) {
 	ListImage *list_image = (ListImage *) value;
-#if GTK_MAJOR_VERSION < 2
-	if (list_image->pixmap)
-		gdk_pixmap_unref(list_image->pixmap);
-	if (list_image->bitmap)
-		gdk_bitmap_unref(list_image->bitmap);
-#else
 	if (list_image->pixbuf)
 		gdk_pixbuf_unref (list_image->pixbuf);
-#endif
 	g_free(list_image);
 }
 
@@ -1977,24 +1873,17 @@
 ListBox::~ListBox() {
 }
 
-#if GTK_MAJOR_VERSION >= 2
 enum {
 	PIXBUF_COLUMN,
 	TEXT_COLUMN,
 	N_COLUMNS
 };
-#endif
 
 class ListBoxX : public ListBox {
 	WindowID list;
 	WindowID scroller;
-#if GTK_MAJOR_VERSION < 2
-	int current;
-#endif
 	void *pixhash;
-#if GTK_MAJOR_VERSION >= 2
-        GtkCellRenderer* pixbuf_renderer;
-#endif
+	GtkCellRenderer* pixbuf_renderer;
 	XPMSet xset;
 	int desiredVisibleRows;
 	unsigned int maxItemCharacters;
@@ -2003,15 +1892,9 @@
 	CallBackAction doubleClickAction;
 	void *doubleClickActionData;
 
-	ListBoxX() : list(0), pixhash(NULL),
+	ListBoxX() : list(0), pixhash(NULL), pixbuf_renderer(0),
 		desiredVisibleRows(5), maxItemCharacters(0),
 		aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) {
-#if GTK_MAJOR_VERSION < 2
-			current = 0;
-#endif
-#if GTK_MAJOR_VERSION >= 2
-			pixbuf_renderer = 0;
-#endif
 	}
 	virtual ~ListBoxX() {
 		if (pixhash) {
@@ -2047,19 +1930,6 @@
 	return lb;
 }
 
-#if GTK_MAJOR_VERSION < 2
-static void UnselectionAC(GtkWidget *, gint, gint,
-                        GdkEventButton *, gpointer p) {
-	int *pi = reinterpret_cast<int *>(p);
-	*pi = -1;
-}
-static void SelectionAC(GtkWidget *, gint row, gint,
-                        GdkEventButton *, gpointer p) {
-	int *pi = reinterpret_cast<int *>(p);
-	*pi = row;
-}
-#endif
-
 static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
 	try {
 		ListBoxX* lb = reinterpret_cast<ListBoxX*>(p);
@@ -2074,7 +1944,6 @@
 	return FALSE;
 }
 
-#if GTK_MAJOR_VERSION >= 2
 /* Change the active color to the selected color so the listbox uses the color
 scheme that it would use if it had the focus. */
 static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
@@ -2097,7 +1966,6 @@
 	if (!gdk_color_equal(&style->text[GTK_STATE_SELECTED], &style->text[GTK_STATE_ACTIVE]))
 		gtk_widget_modify_text(w, GTK_STATE_ACTIVE, &style->text[GTK_STATE_SELECTED]);
 }
-#endif
 
 void ListBoxX::Create(Window &, int, Point, int, bool) {
 	wid = gtk_window_new(GTK_WINDOW_POPUP);
@@ -2115,21 +1983,6 @@
 	gtk_container_add(GTK_CONTAINER(frame), PWidget(scroller));
 	gtk_widget_show(PWidget(scroller));
 
-#if GTK_MAJOR_VERSION < 2
-	list = gtk_clist_new(1);
-	GtkWidget *wid = PWidget(list);	// No code inside the GTK_OBJECT macro
-	gtk_widget_show(wid);
-	gtk_container_add(GTK_CONTAINER(PWidget(scroller)), wid);
-	gtk_clist_set_column_auto_resize(GTK_CLIST(wid), 0, TRUE);
-	gtk_clist_set_selection_mode(GTK_CLIST(wid), GTK_SELECTION_BROWSE);
-	gtk_signal_connect(GTK_OBJECT(wid), "unselect_row",
-	                   GTK_SIGNAL_FUNC(UnselectionAC), &current);
-	gtk_signal_connect(GTK_OBJECT(wid), "select_row",
-	                   GTK_SIGNAL_FUNC(SelectionAC), &current);
-	gtk_signal_connect(GTK_OBJECT(wid), "button_press_event",
-	                   GTK_SIGNAL_FUNC(ButtonPress), this);
-	gtk_clist_set_shadow_type(GTK_CLIST(wid), GTK_SHADOW_NONE);
-#else
 	/* Tree and its model */
 	GtkListStore *store =
 		gtk_list_store_new(N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
@@ -2153,7 +2006,7 @@
 	gtk_tree_view_column_pack_start(column, pixbuf_renderer, FALSE);
 	gtk_tree_view_column_add_attribute(column, pixbuf_renderer,
 										"pixbuf", PIXBUF_COLUMN);
-	
+
 	GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
 	gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), 1);
 	gtk_tree_view_column_pack_start(column, renderer, TRUE);
@@ -2169,28 +2022,15 @@
 	gtk_widget_show(wid);
 	g_signal_connect(G_OBJECT(wid), "button_press_event",
 	                   G_CALLBACK(ButtonPress), this);
-#endif
 	gtk_widget_realize(PWidget(wid));
 }
 
 void ListBoxX::SetFont(Font &scint_font) {
-#if GTK_MAJOR_VERSION < 2
-	GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(PWidget(list)));
-	if (!gdk_font_equal(style->font, PFont(scint_font)->pfont)) {
-		style = gtk_style_copy(style);
-		gdk_font_unref(style->font);
-		style->font = PFont(scint_font)->pfont;
-		gdk_font_ref(style->font);
-		gtk_widget_set_style(GTK_WIDGET(PWidget(list)), style);
-		gtk_style_unref(style);
-	}
-#else
 	// Only do for Pango font as there have been crashes for GDK fonts
 	if (Created() && PFont(scint_font)->pfd) {
 		// Current font is Pango font
 		gtk_widget_modify_font(PWidget(list), PFont(scint_font)->pfd);
 	}
-#endif
 }
 
 void ListBoxX::SetAverageCharWidth(int width) {
@@ -2218,13 +2058,6 @@
 
 		// First calculate height of the clist for our desired visible
 		// row count otherwise it tries to expand to the total # of rows
-#if GTK_MAJOR_VERSION < 2
-		int ythickness = PWidget(list)->style->klass->ythickness;
-		height = (rows * GTK_CLIST(list)->row_height
-		          + rows + 1
-		          + 2 * (ythickness
-		                 + GTK_CONTAINER(PWidget(list))->border_width));
-#else
 		// Get cell height
 		int row_width=0;
 		int row_height=0;
@@ -2236,7 +2069,6 @@
 		height = (rows * row_height
 		          + 2 * (ythickness
 		                 + GTK_CONTAINER(PWidget(list))->border_width + 1));
-#endif
 		gtk_widget_set_usize(GTK_WIDGET(PWidget(list)), -1, height);
 
 		// Get the size of the scroller because we set usize on the window
@@ -2256,30 +2088,19 @@
 }
 
 int ListBoxX::CaretFromEdge() {
-#if GTK_MAJOR_VERSION >= 2
 	gint renderer_width, renderer_height;
 	gtk_cell_renderer_get_fixed_size(pixbuf_renderer, &renderer_width,
 						&renderer_height);
 	return 4 + renderer_width;
-#endif
-	return 4 + xset.GetWidth();
 }
 
 void ListBoxX::Clear() {
-#if GTK_MAJOR_VERSION < 2
-	gtk_clist_clear(GTK_CLIST(list));
-#else
 	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
 	gtk_list_store_clear(GTK_LIST_STORE(model));
-#endif
 	maxItemCharacters = 0;
 }
 
-#if GTK_MAJOR_VERSION < 2
-static void init_pixmap(ListImage *list_image, GtkWidget *window) {
-#else
 static void init_pixmap(ListImage *list_image) {
-#endif
 	const char *textForm = list_image->xpm_data;
 	const char * const * xpm_lineform = reinterpret_cast<const char * const *>(textForm);
 	const char **xpm_lineformfromtext = 0;
@@ -2294,28 +2115,10 @@
 	}
 
 	// Drop any existing pixmap/bitmap as data may have changed
-#if GTK_MAJOR_VERSION < 2
-	if (list_image->pixmap)
-		gdk_pixmap_unref(list_image->pixmap);
-	list_image->pixmap = NULL;
-	if (list_image->bitmap)
-		gdk_bitmap_unref(list_image->bitmap);
-	list_image->bitmap = NULL;
-
-	list_image->pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL
-	             , gtk_widget_get_colormap(window), &(list_image->bitmap), NULL
-	             , (gchar **) xpm_lineform);
-	if (NULL == list_image->pixmap) {
-		if (list_image->bitmap)
-			gdk_bitmap_unref(list_image->bitmap);
-		list_image->bitmap = NULL;
-	}
-#else
 	if (list_image->pixbuf)
 		gdk_pixbuf_unref(list_image->pixbuf);
 	list_image->pixbuf =
 		gdk_pixbuf_new_from_xpm_data((const gchar**)xpm_lineform);
-#endif
 	delete []xpm_lineformfromtext;
 }
 
@@ -2327,16 +2130,6 @@
 		list_image = (ListImage *) g_hash_table_lookup((GHashTable *) pixhash
 		             , (gconstpointer) GINT_TO_POINTER(type));
 	}
-#if GTK_MAJOR_VERSION < 2
-	char * szs[] = { s, NULL };
-	int rownum = gtk_clist_append(GTK_CLIST(list), szs);
-	if (list_image) {
-		if (NULL == list_image->pixmap)
-			init_pixmap(list_image, (GtkWidget *) list);
-		gtk_clist_set_pixtext(GTK_CLIST(list), rownum, 0, s, SPACING
-		                      , list_image->pixmap, list_image->bitmap);
-	}
-#else
 	GtkTreeIter iter;
 	GtkListStore *store =
 		GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
@@ -2351,7 +2144,7 @@
 
 			gint pixbuf_width = gdk_pixbuf_get_width(list_image->pixbuf);
 			gint renderer_height, renderer_width;
-			gtk_cell_renderer_get_fixed_size(pixbuf_renderer, 
+			gtk_cell_renderer_get_fixed_size(pixbuf_renderer,
 								&renderer_width, &renderer_height);
 			if (pixbuf_width > renderer_width)
 				gtk_cell_renderer_set_fixed_size(pixbuf_renderer,
@@ -2364,7 +2157,6 @@
 			gtk_list_store_set(GTK_LIST_STORE(store), &iter,
 								TEXT_COLUMN, s, -1);
 	}
-#endif
 	size_t len = strlen(s);
 	if (maxItemCharacters < len)
 		maxItemCharacters = len;
@@ -2372,24 +2164,12 @@
 
 int ListBoxX::Length() {
 	if (wid)
-#if GTK_MAJOR_VERSION < 2
-		return GTK_CLIST(list)->rows;
-#else
 		return gtk_tree_model_iter_n_children(gtk_tree_view_get_model
 											   (GTK_TREE_VIEW(list)), NULL);
-#endif
 	return 0;
 }
 
 void ListBoxX::Select(int n) {
-#if GTK_MAJOR_VERSION < 2
-	if (n == -1) {
-		gtk_clist_unselect_row(GTK_CLIST(list), current, 0);
-	} else {
-		gtk_clist_select_row(GTK_CLIST(list), n, 0);
-		gtk_clist_moveto(GTK_CLIST(list), n, 0, 0.5, 0.5);
-	}
-#else
 	GtkTreeIter iter;
 	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
 	GtkTreeSelection *selection =
@@ -2437,13 +2217,9 @@
 	} else {
 		gtk_tree_selection_unselect_all(selection);
 	}
-#endif
 }
 
 int ListBoxX::GetSelection() {
-#if GTK_MAJOR_VERSION < 2
-	return current;
-#else
 	GtkTreeIter iter;
 	GtkTreeModel *model;
 	GtkTreeSelection *selection;
@@ -2456,20 +2232,9 @@
 			return indices[0];
 	}
 	return -1;
-#endif
 }
 
 int ListBoxX::Find(const char *prefix) {
-#if GTK_MAJOR_VERSION < 2
-	int count = Length();
-	for (int i = 0; i < count; i++) {
-		char *s = 0;
-		gtk_clist_get_text(GTK_CLIST(list), i, 0, &s);
-		if (s && (0 == strncmp(prefix, s, strlen(prefix)))) {
-			return i;
-		}
-	}
-#else
 	GtkTreeIter iter;
 	GtkTreeModel *model =
 		gtk_tree_view_get_model(GTK_TREE_VIEW(list));
@@ -2484,32 +2249,17 @@
 		valid = gtk_tree_model_iter_next(model, &iter) != FALSE;
 		i++;
 	}
-#endif
 	return -1;
 }
 
 void ListBoxX::GetValue(int n, char *value, int len) {
 	char *text = NULL;
-#if GTK_MAJOR_VERSION < 2
-	GtkCellType type = gtk_clist_get_cell_type(GTK_CLIST(list), n, 0);
-	switch (type) {
-	case GTK_CELL_TEXT:
-		gtk_clist_get_text(GTK_CLIST(list), n, 0, &text);
-		break;
-	case GTK_CELL_PIXTEXT:
-		gtk_clist_get_pixtext(GTK_CLIST(list), n, 0, &text, NULL, NULL, NULL);
-		break;
-	default:
-		break;
-	}
-#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) != FALSE;
 	if (valid) {
 		gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);
 	}
-#endif
 	if (text && len > 0) {
 		strncpy(value, text, len);
 		value[len - 1] = '\0';
@@ -2538,18 +2288,9 @@
 		(gconstpointer) GINT_TO_POINTER(type));
 	if (list_image) {
 		// Drop icon already registered
-#if GTK_MAJOR_VERSION < 2
-		if (list_image->pixmap)
-			gdk_pixmap_unref(list_image->pixmap);
-		list_image->pixmap = 0;
-		if (list_image->bitmap)
-			gdk_bitmap_unref(list_image->bitmap);
-		list_image->bitmap = 0;
-#else
 		if (list_image->pixbuf)
 			gdk_pixbuf_unref(list_image->pixbuf);
 		list_image->pixbuf = NULL;
-#endif
 		list_image->xpm_data = xpm_data;
 	} else {
 		list_image = g_new0(ListImage, 1);
@@ -2602,11 +2343,7 @@
 
 void Menu::Destroy() {
 	if (mid)
-#if GTK_MAJOR_VERSION < 2
-		gtk_object_unref(GTK_OBJECT(mid));
-#else
 		g_object_unref(G_OBJECT(mid));
-#endif
 	mid = 0;
 }
 
@@ -2624,12 +2361,8 @@
 	if ((pt.y + requisition.height) > screenHeight) {
 		pt.y = screenHeight - requisition.height;
 	}
-#if GTK_MAJOR_VERSION >= 2
 	gtk_item_factory_popup(factory, pt.x - 4, pt.y - 4, 3,
 		gtk_get_current_event_time());
-#else
-	gtk_item_factory_popup(factory, pt.x - 4, pt.y - 4, 3, 0);
-#endif
 }
 
 ElapsedTime::ElapsedTime() {
@@ -2701,12 +2434,8 @@
 #ifdef G_OS_WIN32
 	return "Lucida Console";
 #else
-#ifdef USE_PANGO
 	return "!Sans";
-#else
-	return "lucidatypewriter";
 #endif
-#endif
 }
 
 int Platform::DefaultFontSize() {

Modified: trunk/scintilla/PositionCache.cxx
===================================================================
--- trunk/scintilla/PositionCache.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/PositionCache.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#include <string>
 #include <vector>
 
 #include "Platform.h"
@@ -361,7 +362,8 @@
 		for (unsigned int j = 0; j<saeLen; j++) {
 			if (val == selAndEdge[j]) {
 				return;
-			} if (val < selAndEdge[j]) {
+			}
+			if (val < selAndEdge[j]) {
 				for (unsigned int k = saeLen; k>j; k--) {
 					selAndEdge[k] = selAndEdge[k-1];
 				}
@@ -447,7 +449,7 @@
 	delete []selAndEdge;
 }
 
-int BreakFinder::First() {
+int BreakFinder::First() const {
 	return nextBreak;
 }
 
@@ -534,7 +536,7 @@
 	clock = clock_;
 	if (s_ && positions_) {
 		positions = new short[len + (len + 1) / 2];
-		for (unsigned int i=0;i<len;i++) {
+		for (unsigned int i=0; i<len; i++) {
 			positions[i] = static_cast<short>(positions_[i]);
 		}
 		memcpy(reinterpret_cast<char *>(positions + len), s_, len);
@@ -557,7 +559,7 @@
 	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++) {
+		for (unsigned int i=0; i<len; i++) {
 			positions_[i] = positions[i];
 		}
 		return true;
@@ -579,7 +581,7 @@
 	return ret;
 }
 
-bool PositionCacheEntry::NewerThan(const PositionCacheEntry &other) {
+bool PositionCacheEntry::NewerThan(const PositionCacheEntry &other) const {
 	return clock > other.clock;
 }
 
@@ -603,7 +605,7 @@
 
 void PositionCache::Clear() {
 	if (!allClear) {
-		for (size_t i=0;i<size;i++) {
+		for (size_t i=0; i<size; i++) {
 			pces[i].Clear();
 		}
 	}
@@ -647,7 +649,7 @@
 		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++) {
+			for (size_t i=0; i<size; i++) {
 				pces[i].ResetClock();
 			}
 			clock = 2;

Modified: trunk/scintilla/PositionCache.h
===================================================================
--- trunk/scintilla/PositionCache.h	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/PositionCache.h	2010-05-16 17:44:24 UTC (rev 4923)
@@ -93,7 +93,7 @@
 	};
 	void Invalidate(LineLayout::validLevel validity_);
 	void SetLevel(int level_);
-	int GetLevel() { return level; }
+	int GetLevel() const { return level; }
 	LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
 		int linesOnScreen, int linesInDoc);
 	void Dispose(LineLayout *ll);
@@ -111,7 +111,7 @@
 	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);
+	bool NewerThan(const PositionCacheEntry &other) const;
 	void ResetClock();
 };
 
@@ -138,7 +138,7 @@
 public:
 	BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection);
 	~BreakFinder();
-	int First();
+	int First() const;
 	int Next();
 };
 
@@ -152,7 +152,7 @@
 	~PositionCache();
 	void Clear();
 	void SetSize(size_t size_);
-	int GetSize() { return size; }
+	int GetSize() const { return size; }
 	void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
 		const char *s, unsigned int len, int *positions);
 };

Modified: trunk/scintilla/RESearch.cxx
===================================================================
--- trunk/scintilla/RESearch.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/RESearch.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -248,6 +248,7 @@
  */
 
 RESearch::RESearch(CharClassify *charClassTable) {
+	failure = 0;
 	charClass = charClassTable;
 	Init();
 }

Modified: trunk/scintilla/ScintillaBase.cxx
===================================================================
--- trunk/scintilla/ScintillaBase.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/ScintillaBase.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#include <string>
 #include <vector>
 
 #include "Platform.h"
@@ -56,7 +57,7 @@
 	lexLanguage = SCLEX_CONTAINER;
 	performingStyle = false;
 	lexCurrent = 0;
-	for (int wl = 0;wl < numWordLists;wl++)
+	for (int wl = 0; wl < numWordLists; wl++)
 		keyWordLists[wl] = new WordList;
 	keyWordLists[numWordLists] = 0;
 #endif
@@ -64,7 +65,7 @@
 
 ScintillaBase::~ScintillaBase() {
 #ifdef SCI_LEXER
-	for (int wl = 0;wl < numWordLists;wl++)
+	for (int wl = 0; wl < numWordLists; wl++)
 		delete keyWordLists[wl];
 #endif
 }
@@ -202,8 +203,8 @@
 	return Editor::KeyCommand(iMessage);
 }
 
-void ScintillaBase::AutoCompleteDoubleClick(void* p) {
-	ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
+void ScintillaBase::AutoCompleteDoubleClick(void *p) {
+	ScintillaBase *sci = reinterpret_cast<ScintillaBase *>(p);
 	sci->AutoCompleteCompleted();
 }
 

Modified: trunk/scintilla/ScintillaGTK.cxx
===================================================================
--- trunk/scintilla/ScintillaGTK.cxx	2010-05-16 17:43:35 UTC (rev 4922)
+++ trunk/scintilla/ScintillaGTK.cxx	2010-05-16 17:44:24 UTC (rev 4923)
@@ -56,9 +56,7 @@
 
 #include "gtk/gtksignal.h"
 #include "gtk/gtkmarshal.h"
-#if GLIB_MAJOR_VERSION >= 2
 #include "scintilla-marshal.h"
-#endif
 
 #ifdef SCI_LEXER
 #include <glib.h>
@@ -66,15 +64,7 @@
 #include "ExternalLexer.h"
 #endif
 
-#define INTERNATIONAL_INPUT
-
-#if !PLAT_GTK_WIN32 || GTK_MAJOR_VERSION >= 2
-#define USE_CONVERTER
-#endif
-
-#ifdef USE_CONVERTER
 #include "Converter.h"
-#endif
 
 #ifdef _MSC_VER
 // Constant conditional expressions are because of GTK+ headers
@@ -87,11 +77,7 @@
 #define USE_GTK_CLIPBOARD
 #endif
 
-#if GLIB_MAJOR_VERSION < 2
-#define OBJECT_CLASS GtkObjectClass
-#else
 #define OBJECT_CLASS GObjectClass
-#endif
 
 #ifdef SCI_NAMESPACE
 using namespace Scintilla;
@@ -135,17 +121,9 @@
 	CLIPFORMAT cfColumnSelect;
 #endif
 
-#ifdef INTERNATIONAL_INPUT

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list