SF.net SVN: geany: [1213] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jan 20 23:54:29 UTC 2007


Revision: 1213
          http://svn.sourceforge.net/geany/?rev=1213&view=rev
Author:   eht16
Date:     2007-01-20 15:54:28 -0800 (Sat, 20 Jan 2007)

Log Message:
-----------
Updated Scintilla to version 1.72.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/scintilla/CellBuffer.cxx
    trunk/scintilla/CellBuffer.h
    trunk/scintilla/ContractionState.cxx
    trunk/scintilla/Document.cxx
    trunk/scintilla/Document.h
    trunk/scintilla/DocumentAccessor.cxx
    trunk/scintilla/Editor.cxx
    trunk/scintilla/Editor.h
    trunk/scintilla/LexCPP.cxx
    trunk/scintilla/LexD.cxx
    trunk/scintilla/LexHTML.cxx
    trunk/scintilla/LexOthers.cxx
    trunk/scintilla/LexRuby.cxx
    trunk/scintilla/PlatGTK.cxx
    trunk/scintilla/ScintillaBase.cxx
    trunk/scintilla/ScintillaGTK.cxx
    trunk/scintilla/ViewStyle.cxx
    trunk/scintilla/ViewStyle.h
    trunk/scintilla/include/Scintilla.h
    trunk/scintilla/include/Scintilla.iface
    trunk/src/sci_cb.c

Added Paths:
-----------
    trunk/scintilla/Partitioning.h
    trunk/scintilla/SplitVector.h

Removed Paths:
-------------
    trunk/scintilla/LexGen.py

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/ChangeLog	2007-01-20 23:54:28 UTC (rev 1213)
@@ -1,6 +1,7 @@
 2007-01-20  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * scintilla/makefile.win32: Fixed typo.
+ * scintilla/*, src/sci_cb.c: Updated Scintilla to version 1.72.
 
 
 2007-01-19  Enrico Tröger  <enrico.troeger at uvena.de>

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

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

Modified: trunk/scintilla/ContractionState.cxx
===================================================================
--- trunk/scintilla/ContractionState.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/ContractionState.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -208,11 +208,11 @@
 			if (lines[line].visible != visible) {
 				delta += visible ? lines[line].height : -lines[line].height;
 				lines[line].visible = visible;
+				valid = false;
 			}
 		}
 	}
 	linesInDisplay += delta;
-	valid = false;
 	return delta != 0;
 }
 

Modified: trunk/scintilla/Document.cxx
===================================================================
--- trunk/scintilla/Document.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/Document.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -14,6 +14,8 @@
 
 #include "Scintilla.h"
 #include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 #include "CharClassify.h"
 #include "Document.h"
@@ -358,10 +360,9 @@
 	}
 }
 
-// Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt.
+// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt.
 // SetStyleAt does not change the persistent state of a document
 
-// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
 bool Document::DeleteChars(int pos, int len) {
 	if (len == 0)
 		return false;
@@ -380,8 +381,8 @@
 			        0, 0));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			bool startSequence=false;
-			const char *text = cb.DeleteChars(pos * 2, len * 2, startSequence);
+			bool startSequence = false;
+			const char *text = cb.DeleteChars(pos, len, startSequence);
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
 			if ((pos < Length()) || (pos == 0))
@@ -390,7 +391,7 @@
 				ModifiedAt(pos-1);
 			NotifyModified(
 			    DocModification(
-			        SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_START_ACTION:0),
+			        SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
 			        pos, len,
 			        LinesTotal() - prevLinesTotal, text));
 		}
@@ -400,9 +401,12 @@
 }
 
 /**
- * Insert a styled string (char/style pairs) with a length.
+ * Insert a string with a length.
  */
-bool Document::InsertStyledString(int position, char *s, int insertLength) {
+bool Document::InsertString(int position, const char *s, int insertLength) {
+	if (insertLength <= 0) {
+		return false;
+	}
 	CheckReadOnly();
 	if (enteredCount != 0) {
 		return false;
@@ -412,19 +416,19 @@
 			NotifyModified(
 			    DocModification(
 			        SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
-			        position / 2, insertLength / 2,
+			        position, insertLength,
 			        0, s));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			bool startSequence=false;
+			bool startSequence = false;
 			const char *text = cb.InsertString(position, s, insertLength, startSequence);
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
-			ModifiedAt(position / 2);
+			ModifiedAt(position);
 			NotifyModified(
 			    DocModification(
-			        SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_START_ACTION:0),
-			        position / 2, insertLength / 2,
+			        SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+			        position, insertLength,
 			        LinesTotal() - prevLinesTotal, text));
 		}
 		enteredCount--;
@@ -546,39 +550,18 @@
  * Insert a single character.
  */
 bool Document::InsertChar(int pos, char ch) {
-	char chs[2];
+	char chs[1];
 	chs[0] = ch;
-	chs[1] = 0;
-	return InsertStyledString(pos*2, chs, 2);
+	return InsertString(pos, chs, 1);
 }
 
 /**
  * Insert a null terminated string.
  */
-bool Document::InsertString(int position, const char *s) {
+bool Document::InsertCString(int position, const char *s) {
 	return InsertString(position, s, strlen(s));
 }
 
-/**
- * Insert a string with a length.
- */
-bool Document::InsertString(int position, const char *s, size_t insertLength) {
-	bool changed = false;
-	if (insertLength > 0) {
-		char *sWithStyle = new char[insertLength * 2];
-		if (sWithStyle) {
-			for (size_t i = 0; i < insertLength; i++) {
-				sWithStyle[i*2] = s[i];
-				sWithStyle[i*2 + 1] = 0;
-			}
-			changed = InsertStyledString(position*2, sWithStyle,
-				static_cast<int>(insertLength*2));
-			delete []sWithStyle;
-		}
-	}
-	return changed;
-}
-
 void Document::ChangeChar(int pos, char ch) {
 	DeleteChars(pos, 1);
 	InsertChar(pos, ch);
@@ -655,7 +638,7 @@
 		int indentPos = GetLineIndentPosition(line);
 		BeginUndoAction();
 		DeleteChars(thisLineStart, indentPos - thisLineStart);
-		InsertString(thisLineStart, linebuf);
+		InsertCString(thisLineStart, linebuf);
 		EndUndoAction();
 	}
 }
@@ -684,6 +667,8 @@
 				return column;
 			} else if (ch == '\n') {
 				return column;
+			} else if (i >= Length()) {
+				return column;
 			} else {
 				column++;
 				i = MovePositionOutsideChar(i + 1, 1);
@@ -856,7 +841,7 @@
 		while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
 			pos--;
 	} else {
-		if (!onlyWordCharacters)
+		if (!onlyWordCharacters && pos < Length())
 			ccStart = WordCharClass(cb.CharAt(pos));
 		while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
 			pos++;

Modified: trunk/scintilla/Document.h
===================================================================
--- trunk/scintilla/Document.h	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/Document.h	2007-01-20 23:54:28 UTC (rev 1213)
@@ -136,7 +136,7 @@
 	// Gateways to modifying document
 	void ModifiedAt(int pos);
 	bool DeleteChars(int pos, int len);
-	bool InsertStyledString(int position, char *s, int insertLength);
+	bool InsertString(int position, const char *s, int insertLength);
 	int Undo();
 	int Redo();
 	bool CanUndo() { return cb.CanUndo(); }
@@ -163,8 +163,7 @@
 	bool IsReadOnly() { return cb.IsReadOnly(); }
 
 	bool InsertChar(int pos, char ch);
-	bool InsertString(int position, const char *s);
-	bool InsertString(int position, const char *s, size_t insertLength);
+	bool InsertCString(int position, const char *s);
 	void ChangeChar(int pos, char ch);
 	void DelChar(int pos);
 	void DelCharBack(int pos);
@@ -197,7 +196,7 @@
 	int NextWordStart(int pos, int delta);
 	int NextWordEnd(int pos, int delta);
 	int Length() { return cb.Length(); }
-	void Allocate(int newSize) { cb.Allocate(newSize*2); }
+	void Allocate(int newSize) { cb.Allocate(newSize); }
 	long FindText(int minPos, int maxPos, const char *s,
 		bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length);
 	long FindText(int iMessage, unsigned long wParam, long lParam);

Modified: trunk/scintilla/DocumentAccessor.cxx
===================================================================
--- trunk/scintilla/DocumentAccessor.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/DocumentAccessor.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -16,6 +16,8 @@
 #include "SVector.h"
 #include "Accessor.h"
 #include "DocumentAccessor.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 #include "Scintilla.h"
 #include "CharClassify.h"

Modified: trunk/scintilla/Editor.cxx
===================================================================
--- trunk/scintilla/Editor.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/Editor.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -19,6 +19,8 @@
 
 #include "ContractionState.h"
 #include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 #include "KeyMap.h"
 #include "Indicator.h"
@@ -1661,7 +1663,7 @@
 				unsigned int posLineStart = pdoc->LineStart(line);
 				LayoutLine(line, surface, vs, ll, pixelWidth);
 				for (int subLine = 1; subLine < ll->lines; subLine++) {
-					pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) +
+					pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) +
 						ll->LineStart(subLine), eol);
 					targetEnd += static_cast<int>(strlen(eol));
 				}
@@ -1915,6 +1917,7 @@
 LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
 	int posLineStart = pdoc->LineStart(lineNumber);
 	int posLineEnd = pdoc->LineStart(lineNumber + 1);
+	PLATFORM_ASSERT(posLineEnd >= posLineStart);
 	int lineCaret = pdoc->LineFromPosition(currentPos);
 	return llc.Retrieve(lineNumber, lineCaret,
 	                    posLineEnd - posLineStart, pdoc->GetStyleClock(),
@@ -1930,6 +1933,7 @@
 	if (!ll)
 		return;
 	PLATFORM_ASSERT(line < pdoc->LinesTotal());
+	PLATFORM_ASSERT(ll->chars != NULL);
 	int posLineStart = pdoc->LineStart(line);
 	int posLineEnd = pdoc->LineStart(line + 1);
 	// If the line is very long, limit the treatment to a length that should fit in the viewport
@@ -2273,6 +2277,21 @@
 		surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
 	}
 
+	if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
+	} else {
+		if (overrideBackground) {
+			surface->FillRectangle(rcSegment, background);
+		} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		} else {
+			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+		}
+		if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) {
+			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+		}
+ 	}
+
 	if (drawWrapMarkEnd) {
 		PRectangle rcPlace = rcSegment;
 
@@ -4096,7 +4115,7 @@
 	char *text = CopyRange(start, end);
 	if (forLine) {
 		const char *eol = StringFromEOLMode(pdoc->eolMode);
-		pdoc->InsertString(end, eol);
+		pdoc->InsertCString(end, eol);
 		pdoc->InsertString(end + istrlen(eol), text, end - start);
 	} else {
 		pdoc->InsertString(end, text, end - start);
@@ -4116,7 +4135,7 @@
 	} else if (pdoc->eolMode == SC_EOL_CR) {
 		eol = "\r";
 	} // else SC_EOL_LF -> "\n" already set
-	if (pdoc->InsertString(currentPos, eol)) {
+	if (pdoc->InsertCString(currentPos, eol)) {
 		SetEmptySelection(currentPos + istrlen(eol));
 		while (*eol) {
 			NotifyChar(*eol);
@@ -4975,7 +4994,7 @@
 			SetEmptySelection(position);
 		} else {
 			position = MovePositionOutsideChar(position, currentPos - position);
-			if (pdoc->InsertString(position, value)) {
+			if (pdoc->InsertCString(position, value)) {
 				SetSelection(position + istrlen(value), position);
 			}
 			pdoc->EndUndoAction();
@@ -5681,6 +5700,26 @@
 	}
 }
 
+void Editor::AddStyledText(char *buffer, int appendLength) {
+	// The buffer consists of alternating character bytes and style bytes
+	size_t textLength = appendLength / 2;
+	char *text = new char[textLength];
+	if (text) {
+		size_t i;
+		for (i=0;i<textLength;i++) {
+			text[i] = buffer[i*2];
+		}
+		pdoc->InsertString(CurrentPosition(), text, textLength);
+		for (i=0;i<textLength;i++) {
+			text[i] = buffer[i*2+1];
+		}
+		pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
+		pdoc->SetStyles(textLength, text);
+		delete []text;
+	}
+	SetEmptySelection(currentPos + textLength);
+}
+
 static bool ValidMargin(unsigned long wParam) {
 	return wParam < ViewStyle::margins;
 }
@@ -5717,7 +5756,7 @@
 			pdoc->BeginUndoAction();
 			pdoc->DeleteChars(0, pdoc->Length());
 			SetEmptySelection(0);
-			pdoc->InsertString(0, CharPtrFromSPtr(lParam));
+			pdoc->InsertCString(0, CharPtrFromSPtr(lParam));
 			pdoc->EndUndoAction();
 			return 1;
 		}
@@ -5867,7 +5906,7 @@
 			pdoc->BeginUndoAction();
 			ClearSelection();
 			char *replacement = CharPtrFromSPtr(lParam);
-			pdoc->InsertString(currentPos, replacement);
+			pdoc->InsertCString(currentPos, replacement);
 			pdoc->EndUndoAction();
 			SetEmptySelection(currentPos + istrlen(replacement));
 			EnsureCaretVisible();
@@ -6023,13 +6062,10 @@
 			return 0;
 		}
 
-	case SCI_ADDSTYLEDTEXT: {
-			if (lParam == 0)
-				return 0;
-			pdoc->InsertStyledString(CurrentPosition() * 2, CharPtrFromSPtr(lParam), wParam);
-			SetEmptySelection(currentPos + wParam / 2);
-			return 0;
-		}
+	case SCI_ADDSTYLEDTEXT:
+		if (lParam)
+			AddStyledText(CharPtrFromSPtr(lParam), wParam);
+		return 0;
 
 	case SCI_INSERTTEXT: {
 			if (lParam == 0)
@@ -6039,7 +6075,7 @@
 				insertPos = CurrentPosition();
 			int newCurrent = CurrentPosition();
 			char *sz = CharPtrFromSPtr(lParam);
-			pdoc->InsertString(insertPos, sz);
+			pdoc->InsertCString(insertPos, sz);
 			if (newCurrent > insertPos)
 				newCurrent += istrlen(sz);
 			SetEmptySelection(newCurrent);
@@ -6898,6 +6934,14 @@
 	case SCI_GETSELALPHA:
 		return vs.selAlpha;
 
+	case SCI_GETSELEOLFILLED:
+		return vs.selEOLFilled;
+
+	case SCI_SETSELEOLFILLED:
+		vs.selEOLFilled = wParam != 0;
+		InvalidateStyleRedraw();
+		break;
+
 	case SCI_SETWHITESPACEFORE:
 		vs.whitespaceForegroundSet = wParam != 0;
 		vs.whitespaceForeground.desired = ColourDesired(lParam);

Modified: trunk/scintilla/Editor.h
===================================================================
--- trunk/scintilla/Editor.h	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/Editor.h	2007-01-20 23:54:28 UTC (rev 1213)
@@ -527,6 +527,7 @@
 	int CodePage() const;
 	virtual bool ValidCodePage(int /* codePage */) const { return true; }
 	int WrapCount(int line);
+	void AddStyledText(char *buffer, int appendLength);
 
 	virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
 

Modified: trunk/scintilla/LexCPP.cxx
===================================================================
--- trunk/scintilla/LexCPP.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/LexCPP.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -371,8 +371,8 @@
 // Store both the current line's fold level and the next lines in the
 // level store to make it easy to pick up with each increment
 // and to make it possible to fiddle the current level for "} else {".
-static void FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
-                            Accessor &styler) {
+static void FoldCppDoc(unsigned int startPos, int length, int initStyle, 
+					   WordList *[], Accessor &styler) {
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
@@ -396,9 +396,9 @@
 		styleNext = styler.StyleAt(i + 1);
 		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
 		if (foldComment && IsStreamCommentStyle(style)) {
-			if (!IsStreamCommentStyle(stylePrev)) {
+			if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) {
 				levelNext++;
-			} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+			} else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) {
 				// Comments don't end at end of line and the next character may be unstyled.
 				levelNext--;
 			}
@@ -461,11 +461,6 @@
 	}
 }
 
-static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
-                       Accessor &styler) {
-	FoldNoBoxCppDoc(startPos, length, initStyle, styler);
-}
-
 static const char * const cppWordLists[] = {
             "Primary keywords and identifiers",
             "Secondary keywords and identifiers",

Modified: trunk/scintilla/LexD.cxx
===================================================================
--- trunk/scintilla/LexD.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/LexD.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -2,7 +2,6 @@
  ** Lexer for D.
  **
  ** Copyright (c) 2006 by Waldemar Augustyn <waldemar at wdmsys.com>
- ** Licensed under the terms described in LicenseContributor.txt.
  **/
 // Copyright 1998-2005 by Neil Hodgson <neilh at scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
@@ -24,24 +23,24 @@
 
 /*/ Nested comments require keeping the value of the nesting level for every
     position in the document.  But since scintilla always styles line by line,
-    we only need to store that value per line. The non-negative number indicates
+    we only need to store one value per line. The non-negative number indicates
     nesting level at the end of the line.
 /*/
 
 // We use custom qualifiers since it is not clear what D allows.
 
-static bool IsWordStart(char ch) {
+static bool IsWordStart(int ch) {
 	return isascii(ch) && (isalpha(ch) || ch == '_');
 }
 
-static bool IsWord(char ch) {
+static bool IsWord(int ch) {
 	return isascii(ch) && (isalnum(ch) || ch == '_');
 }
 
-static bool IsDoxygen(char ch) {
+static bool IsDoxygen(int ch) {
 	if (isascii(ch) && islower(ch))
 		return true;
-	if (ch == '$' || ch == '@' || ch == '\\' || 
+	if (ch == '$' || ch == '@' || ch == '\\' ||
 		ch == '&' || ch == '#' || ch == '<' || ch == '>' ||
 		ch == '{' || ch == '}' || ch == '[' || ch == ']')
 		return true;
@@ -49,7 +48,7 @@
 }
 
 
-static void ColouriseDDoc(unsigned int startPos, int length, int initStyle, 
+static void ColouriseDoc(unsigned int startPos, int length, int initStyle, 
     WordList *keywordlists[], Accessor &styler, bool caseSensitive) {
 
     WordList &keywords = *keywordlists[0];
@@ -60,13 +59,10 @@
     int styleBeforeDCKeyword = SCE_D_DEFAULT;
 
     StyleContext sc(startPos, length, initStyle, styler);
-	    
+
     int curLine = styler.GetLine(startPos);
     int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
 
-    //~ printf("WA LexD::Colorize start(%d)  end(%d)  initStyle(%d) curLine(%d) begNcLevel(%d)\n",
-        //~ startPos, startPos+length, initStyle, curLine+1, curNcLevel);
-
     for (; sc.More(); sc.Forward()) {
 
         if (sc.atLineStart) {
@@ -77,10 +73,8 @@
             }
             curLine = styler.GetLine(sc.currentPos);
             styler.SetLineState(curLine, curNcLevel);
-            //~ printf("    WA LexD::Colorize set line(%d) to curNcLevel(%d) BOL\n",
-                //~ curLine+1, curNcLevel);
         }
-	
+
         // Handle line continuation generically.
         if (sc.ch == '\\') {
             if (sc.chNext == '\n' || sc.chNext == '\r') {
@@ -179,8 +173,6 @@
                         curNcLevel -= 1;
                     curLine = styler.GetLine(sc.currentPos);
                     styler.SetLineState(curLine, curNcLevel);
-                    //~ printf("    WA LexD::Colorize set line(%d) to curNcLevel(%d) NEST DOWN\n",
-                        //~ curLine+1, curNcLevel);
                     sc.Forward();
                     if (curNcLevel == 0) {
                         sc.ForwardSetState(SCE_D_DEFAULT);
@@ -190,8 +182,6 @@
                     curNcLevel += 1;
                     curLine = styler.GetLine(sc.currentPos);
                     styler.SetLineState(curLine, curNcLevel);
-                    //~ printf("    WA LexD::Colorize set line(%d) to curNcLevel(%d) NEST UP\n",
-                        //~ curLine+1, curNcLevel);
                     sc.Forward();
                 }
                 break;
@@ -234,8 +224,6 @@
                 curNcLevel += 1;
 		curLine = styler.GetLine(sc.currentPos);
                 styler.SetLineState(curLine, curNcLevel);
-                //~ printf("    WA LexD::Colorize set line(%d) to curNcLevel(%d) NEST NEW\n",
-                    //~ curLine+1, curNcLevel);
                 sc.SetState(SCE_D_COMMENTNESTED);
                 sc.Forward();
             } else if (sc.Match('/', '*')) {
@@ -261,8 +249,6 @@
         }
     }
     sc.Complete();
-    //~ styler.Flush();	// Make sure nested comments are properly accounted for
-    //~ styler.ClearNestedCommentChange();
 }
 
 static bool IsStreamCommentStyle(int style) {
@@ -275,11 +261,11 @@
 // Store both the current line's fold level and the next lines in the
 // level store to make it easy to pick up with each increment
 // and to make it possible to fiddle the current level for "} else {".
-static void FoldNoBoxDDoc(unsigned int startPos, int length, int initStyle,
-                            Accessor &styler) {
+static void FoldDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) {
     bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
     bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
-    bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
+    bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else",
+		styler.GetPropertyInt("fold.at.else", 0)) != 0;
     unsigned int endPos = startPos + length;
     int visibleChars = 0;
     int lineCurrent = styler.GetLine(startPos);
@@ -347,9 +333,9 @@
     }
 }
 
-static void FoldDDoc(unsigned int startPos, int length, int initStyle, 
+static void FoldDDoc(unsigned int startPos, int length, int initStyle,
     WordList *[], Accessor &styler) {
-        FoldNoBoxDDoc(startPos, length, initStyle, styler);
+        FoldDoc(startPos, length, initStyle, styler);
 }
 
 static const char * const dWordLists[] = {
@@ -360,10 +346,9 @@
             0,
         };
 
-static void ColouriseDDocSensitive(unsigned int startPos, int length, 
+static void ColouriseDDoc(unsigned int startPos, int length, 
     int initStyle, WordList *keywordlists[], Accessor &styler) {
-        ColouriseDDoc(startPos, length, initStyle, keywordlists, styler, true);
+        ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true);
 }
 
-LexerModule lmD(SCLEX_D, ColouriseDDocSensitive, "d", FoldDDoc, dWordLists);
-
+LexerModule lmD(SCLEX_D, ColouriseDDoc, "d", FoldDDoc, dWordLists);

Deleted: trunk/scintilla/LexGen.py
===================================================================
--- trunk/scintilla/LexGen.py	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/LexGen.py	2007-01-20 23:54:28 UTC (rev 1213)
@@ -1,180 +0,0 @@
-# LexGen.py - implemented 2002 by Neil Hodgson neilh at scintilla.org
-# Released to the public domain.
-
-# Regenerate the Scintilla and SciTE source files that list
-# all the lexers and all the properties files.
-# Should be run whenever a new lexer is added or removed.
-# Requires Python 2.1 or later
-# Most files are regenerated in place with templates stored in comments.
-# The VS .NET project file is generated into a different file as the
-# VS .NET environment will not retain comments when modifying the file.
-# The files are copied to a string apart from sections between a
-# ++Autogenerated comment and a --Autogenerated comment which is
-# generated by the CopyWithInsertion function. After the whole
-# string is instantiated, it is compared with the target file and
-# if different the file is rewritten.
-# Does not regenerate the Visual C++ 6 project files but does the VS .NET
-# project file.
-
-import string
-import sys
-import os
-import glob
-
-# EOL constants
-CR = "\r"
-LF = "\n"
-CRLF = "\r\n"
-if sys.platform == "win32":
-    NATIVE = CRLF
-else:
-    # Yes, LF is the native EOL even on Mac OS X. CR is just for
-    # Mac OS <=9 (a.k.a. "Mac Classic")
-    NATIVE = LF
-
-# Automatically generated sections contain start and end comments,
-# a definition line and the results.
-# The results are replaced by regenerating based on the definition line.
-# The definition line is a comment prefix followed by "**".
-# If there is a digit after the ** then this indicates which list to use
-# and the digit and next character are not part of the definition
-# Backslash is used as an escape within the definition line.
-# The part between \( and \) is repeated for each item in the list.
-# \* is replaced by each list item. \t, and \n are tab and newline.
-def CopyWithInsertion(input, commentPrefix, retainDefs, eolType, *lists):
-	copying = 1
-	listid = 0
-	output = []
-	for line in input.splitlines(0):
-		isStartGenerated = line.startswith(commentPrefix + "++Autogenerated")
-		if copying and not isStartGenerated:
-			output.append(line)
-		if isStartGenerated:
-			if retainDefs:
-				output.append(line)
-			copying = 0
-			definition = ""
-		elif not copying and line.startswith(commentPrefix + "**"):
-			if retainDefs:
-				output.append(line)
-			definition = line[len(commentPrefix + "**"):]
-			listid = 0
-			if definition[0] in string.digits:
-				listid = int(definition[:1])
-				definition = definition[2:]
-			# Hide double slashes as a control character
-			definition = definition.replace("\\\\", "\001")
-			# Do some normal C style transforms
-			definition = definition.replace("\\n", "\n")
-			definition = definition.replace("\\t", "\t")
-			# Get the doubled backslashes back as single backslashes
-			definition = definition.replace("\001", "\\")
-			startRepeat = definition.find("\\(")
-			endRepeat = definition.find("\\)")
-			intro = definition[:startRepeat]
-			out = ""
-			if intro.endswith("\n"):
-				pos = 0
-			else:
-				pos = len(intro)
-			out += intro
-			middle = definition[startRepeat+2:endRepeat]
-			for i in lists[listid]:
-				item = middle.replace("\\*", i)
-				if pos and (pos + len(item) >= 80):
-					out += "\\\n"
-					pos = 0
-				out += item
-				pos += len(item)
-				if item.endswith("\n"):
-					pos = 0
-			outro = definition[endRepeat+2:]
-			out += outro
-			out = out.replace("\n", eolType) # correct EOLs in generated content
-			output.append(out)
-		elif line.startswith(commentPrefix + "--Autogenerated"):
-			copying = 1
-			if retainDefs:
-				output.append(line)
-	output = [line.rstrip(" \t") for line in output] # trim trailing whitespace
-	return eolType.join(output) + eolType
-
-def UpdateFile(filename, updated):
-	""" If the file is different to updated then copy updated
-	into the file else leave alone so CVS and make don't treat
-	it as modified. """
-	try:
-		infile = open(filename, "rb")
-	except IOError:	# File is not there yet
-		out = open(filename, "wb")
-		out.write(updated)
-		out.close()
-		print "New", filename
-		return
-	original = infile.read()
-	infile.close()
-	if updated != original:
-		os.unlink(filename)
-		out = open(filename, "wb")
-		out.write(updated)
-		out.close()
-		print "Changed", filename
-	#~ else:
-		#~ print "Unchanged", filename
-
-def Generate(inpath, outpath, commentPrefix, eolType, *lists):
-	"""Generate 'outpath' from 'inpath'.
-
-	    "eolType" indicates the type of EOLs to use in the generated
-	        file. It should be one of following constants: LF, CRLF,
-	        CR, or NATIVE.
-	"""
-	#print "generate '%s' -> '%s' (comment prefix: %r, eols: %r)"\
-	#      % (inpath, outpath, commentPrefix, eolType)
-	try:
-		infile = open(inpath, "r")
-	except IOError:
-		print "Can not open", inpath
-		return
-	original = infile.read()
-	infile.close()
-	updated = CopyWithInsertion(original, commentPrefix,
-		inpath == outpath, eolType, *lists)
-	UpdateFile(outpath, updated)
-
-def Regenerate(filename, commentPrefix, eolType, *lists):
-	"""Regenerate the given file.
-
-	    "eolType" indicates the type of EOLs to use in the generated
-	        file. It should be one of following constants: LF, CRLF,
-	        CR, or NATIVE.
-	"""
-	Generate(filename, filename, commentPrefix, eolType, *lists)
-
-def FindModules(lexFile):
-	modules = []
-	f = open(lexFile)
-	for l in f.readlines():
-		if l.startswith("LexerModule"):
-			l = l.replace("(", " ")
-			modules.append(l.split()[1])
-	return modules
-
-def ciCompare(a,b):
-	return a.lower() < b.lower()
-
-def RegenerateAll():
-	root="./"
-
-	# Find all the lexer source code files
-	lexFilePaths = glob.glob(root + "Lex*.cxx")
-	lexFiles = [os.path.basename(f)[:-4] for f in lexFilePaths]
-	print lexFiles
-	lexerModules = []
-	for lexFile in lexFilePaths:
-		lexerModules.extend(FindModules(lexFile))
-	lexerModules.sort(ciCompare)
-
-	Regenerate(root + "KeyWords.cxx", "//", NATIVE, lexerModules)
-	
-RegenerateAll()

Modified: trunk/scintilla/LexHTML.cxx
===================================================================
--- trunk/scintilla/LexHTML.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/LexHTML.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -173,6 +173,7 @@
 	bool allowTermination = !isStringState(state);
 	if (allowTermination) {
 		switch (state) {
+		case SCE_HB_COMMENTLINE:
 		case SCE_HPHP_COMMENT:
 		case SCE_HP_COMMENTLINE:
 		case SCE_HPA_COMMENTLINE:

Modified: trunk/scintilla/LexOthers.cxx
===================================================================
--- trunk/scintilla/LexOthers.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/LexOthers.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -125,7 +125,7 @@
 			styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
 			offset += 2;
 			// Check for External Command / Program
-			if (!isspacechar(lineBuffer[offset])) {
+			if (offset < lengthLine && !isspacechar(lineBuffer[offset])) {
 				cmdLoc = offset;
 			}
 		// Check for Environment Variable (%x...%)
@@ -136,7 +136,7 @@
 			styler.ColourTo(startLine + offset, SCE_BAT_IDENTIFIER);
 			offset++;
 			// Check for External Command / Program
-			if (!isspacechar(lineBuffer[offset])) {
+			if (offset < lengthLine && !isspacechar(lineBuffer[offset])) {
 				cmdLoc = offset;
 			}
 		}
@@ -371,6 +371,7 @@
 				offset -= (wbl - wbo);
 			// Check for Local Variable (%%a)
 			} else if (
+				(wbl > 2) &&
 				(wordBuffer[1] == '%') &&
 				(wordBuffer[2] != '%') &&
 				(!IsBOperator(wordBuffer[2])) &&
@@ -473,6 +474,7 @@
 		}
 	}
 	if (linePos > 0) {	// Last line does not have ending characters
+		lineBuffer[linePos] = '\0';
 		ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
 		                   keywordlists, styler);
 	}

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

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

Modified: trunk/scintilla/PlatGTK.cxx
===================================================================
--- trunk/scintilla/PlatGTK.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/PlatGTK.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -745,7 +745,7 @@
 	case SC_CHARSET_ANSI:
 		return "";
 	case SC_CHARSET_DEFAULT:
-		return "LATIN1";
+		return "ISO-8859-1";
 	case SC_CHARSET_BALTIC:
 		return "ISO-8859-13";
 	case SC_CHARSET_CHINESEBIG5:
@@ -2283,7 +2283,7 @@
 		return;
 	}
 
-	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n);
+	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
 	if (valid) {
 		gtk_tree_selection_select_iter(selection, &iter);
 
@@ -2356,7 +2356,7 @@
 	GtkTreeIter iter;
 	GtkTreeModel *model =
 		gtk_tree_view_get_model(GTK_TREE_VIEW(list));
-	bool valid = gtk_tree_model_get_iter_first(model, &iter);
+	bool valid = gtk_tree_model_get_iter_first(model, &iter) != FALSE;
 	int i = 0;
 	while(valid) {
 		gchar *s;
@@ -2364,7 +2364,7 @@
 		if (s && (0 == strncmp(prefix, s, strlen(prefix)))) {
 			return i;
 		}
-		valid = gtk_tree_model_iter_next(model, &iter);
+		valid = gtk_tree_model_iter_next(model, &iter) != FALSE;
 		i++;
 	}
 #endif
@@ -2388,7 +2388,7 @@
 #else
 	GtkTreeIter iter;
 	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
-	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n);
+	bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
 	if (valid) {
 		gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);
 	}

Modified: trunk/scintilla/ScintillaBase.cxx
===================================================================
--- trunk/scintilla/ScintillaBase.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/ScintillaBase.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -22,6 +22,8 @@
 #endif
 #include "ContractionState.h"
 #include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 #include "CallTip.h"
 #include "KeyMap.h"
@@ -356,7 +358,7 @@
 	SetEmptySelection(ac.posStart);
 	if (item != -1) {
 		SString piece = selected;
-		pdoc->InsertString(firstPos, piece.c_str());
+		pdoc->InsertCString(firstPos, piece.c_str());
 		SetEmptySelection(firstPos + static_cast<int>(piece.length()));
 	}
 	pdoc->EndUndoAction();

Modified: trunk/scintilla/ScintillaGTK.cxx
===================================================================
--- trunk/scintilla/ScintillaGTK.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/ScintillaGTK.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -28,6 +28,8 @@
 #endif
 #include "ContractionState.h"
 #include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
 #include "CellBuffer.h"
 #include "CallTip.h"
 #include "KeyMap.h"
@@ -1807,7 +1809,15 @@
 	// Compute amount and direction to scroll (even tho on win32 there is
 	// intensity of scrolling info in the native message, gtk doesn't
 	// support this so we simulate similarly adaptive scrolling)
+	// Note that this is disabled on OS X (Darwin) where the X11 server already has
+	// and adaptive scrolling algorithm that fights with this one
 	int cLineScroll;
+#if defined(__MWERKS__) || defined(__APPLE_CPP__) || defined(__APPLE_CC__)
+	cLineScroll = sciThis->linesPerScroll;
+	if (cLineScroll == 0)
+		cLineScroll = 4;
+	sciThis->wheelMouseIntensity = cLineScroll;
+#else
 	int timeDelta = 1000000;
 	GTimeVal curTime;
 	g_get_current_time(&curTime);
@@ -1825,6 +1835,7 @@
 			cLineScroll = 4;
 		sciThis->wheelMouseIntensity = cLineScroll;
 	}
+#endif
 	if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT) {
 		cLineScroll *= -1;
 	}
@@ -1841,7 +1852,7 @@
 		return FALSE;
 	}
 
-    // Horizontal scrolling
+	// Horizontal scrolling
 	if (event->direction == GDK_SCROLL_LEFT || event->direction == GDK_SCROLL_RIGHT) {
 		sciThis->HorizontalScrollTo(sciThis->xOffset + cLineScroll);
 
@@ -1945,6 +1956,12 @@
 		return SCK_SUBTRACT;
 	case GDK_KP_Divide:
 		return SCK_DIVIDE;
+	case GDK_Super_L:
+		return SCK_WIN;
+	case GDK_Super_R:
+		return SCK_RWIN;
+	case GDK_Menu:
+		return SCK_MENU;
 	default:
 		return keyIn;
 	}
@@ -1974,10 +1991,8 @@
 	// This will have to change for Unicode
 	else if (key >= 0xFE00)
 		key = KeyTranslate(key);
-	else if (IsUnicodeMode())
-		;	// No operation
 #if GTK_MAJOR_VERSION < 2
-	else if ((key >= 0x100) && (key < 0x1000))
+	else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000))
 		key &= 0xff;
 #endif
 
@@ -1988,7 +2003,7 @@
 	//fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
 	if (event->keyval == 0xffffff && event->length > 0) {
 		ClearSelection();
-		if (pdoc->InsertString(CurrentPosition(), event->string)) {
+		if (pdoc->InsertCString(CurrentPosition(), event->string)) {
 			MovePositionTo(CurrentPosition() + event->length);
 		}
 	}
@@ -2325,14 +2340,17 @@
 }
 
 gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
-                                  gint x, gint y, guint dragtime) {
+                                 gint x, gint y, guint dragtime) {
 	ScintillaGTK *sciThis = ScintillaFromWidget(widget);
-	//Platform::DebugPrintf("DragMotion %d %d %x %x %x\n", x, y,
-	//	context->actions, context->suggested_action, sciThis);
 	Point npt(x, y);
 	sciThis->inDragDrop = true;
 	sciThis->SetDragPosition(sciThis->PositionFromLocation(npt));
-	gdk_drag_status(context, context->suggested_action, dragtime);
+	GdkDragAction preferredAction = context->suggested_action;
+	if (context->actions == static_cast<GdkDragAction>
+		(GDK_ACTION_COPY | GDK_ACTION_MOVE)) {
+		preferredAction = GDK_ACTION_MOVE;
+	}
+	gdk_drag_status(context, preferredAction, dragtime);
 	return FALSE;
 }
 

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

Modified: trunk/scintilla/ViewStyle.cxx
===================================================================
--- trunk/scintilla/ViewStyle.cxx	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/ViewStyle.cxx	2007-01-20 23:54:28 UTC (rev 1213)
@@ -74,6 +74,7 @@
 	selbackground.desired = source.selbackground.desired;
 	selbackground2.desired = source.selbackground2.desired;
 	selAlpha = source.selAlpha;
+	selEOLFilled = source.selEOLFilled;
 
 	foldmarginColourSet = source.foldmarginColourSet;
 	foldmarginColour.desired = source.foldmarginColour.desired;
@@ -143,6 +144,7 @@
 	selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
 	selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
 	selAlpha = SC_ALPHA_NOALPHA;
+	selEOLFilled = false;
 
 	foldmarginColourSet = false;
 	foldmarginColour.desired = ColourDesired(0xff, 0, 0);

Modified: trunk/scintilla/ViewStyle.h
===================================================================
--- trunk/scintilla/ViewStyle.h	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/ViewStyle.h	2007-01-20 23:54:28 UTC (rev 1213)
@@ -54,6 +54,7 @@
 	ColourPair selbackground;
 	ColourPair selbackground2;
 	int selAlpha;
+	bool selEOLFilled;
 	bool whitespaceForegroundSet;
 	ColourPair whitespaceForeground;
 	bool whitespaceBackgroundSet;

Modified: trunk/scintilla/include/Scintilla.h
===================================================================
--- trunk/scintilla/include/Scintilla.h	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/include/Scintilla.h	2007-01-20 23:54:28 UTC (rev 1213)
@@ -201,6 +201,8 @@
 #define SCI_SETSELBACK 2068
 #define SCI_GETSELALPHA 2477
 #define SCI_SETSELALPHA 2478
+#define SCI_GETSELEOLFILLED 2479
+#define SCI_SETSELEOLFILLED 2480
 #define SCI_SETCARETFORE 2069
 #define SCI_ASSIGNCMDKEY 2070
 #define SCI_CLEARCMDKEY 2071
@@ -647,7 +649,7 @@
 #define SC_MOD_BEFOREINSERT 0x400
 #define SC_MOD_BEFOREDELETE 0x800
 #define SC_MULTILINEUNDOREDO 0x1000
-#define SC_START_ACTION 0x2000
+#define SC_STARTACTION 0x2000
 #define SC_MODEVENTMASKALL 0x2FFF
 #define SCEN_CHANGE 768
 #define SCEN_SETFOCUS 512
@@ -669,6 +671,9 @@
 #define SCK_ADD 310
 #define SCK_SUBTRACT 311
 #define SCK_DIVIDE 312
+#define SCK_WIN 313
+#define SCK_RWIN 314
+#define SCK_MENU 315
 #define SCMOD_NORM 0
 #define SCMOD_SHIFT 1
 #define SCMOD_CTRL 2

Modified: trunk/scintilla/include/Scintilla.iface
===================================================================
--- trunk/scintilla/include/Scintilla.iface	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/scintilla/include/Scintilla.iface	2007-01-20 23:54:28 UTC (rev 1213)
@@ -316,9 +316,14 @@
 # Add a set of markers to a line.
 fun void MarkerAddSet=2466(int line, int set)
 
+# Set the alpha used for a marker that is drawn in the text area, not the margin.
+fun void MarkerSetAlpha=2476(int markerNumber, int alpha)
+
 enu MarginType=SC_MARGIN_
 val SC_MARGIN_SYMBOL=0
 val SC_MARGIN_NUMBER=1
+val SC_MARGIN_BACK=2
+val SC_MARGIN_FORE=3
 
 # Set a margin to be either numeric or symbolic.
 set void SetMarginTypeN=2240(int margin, int marginType)
@@ -431,6 +436,18 @@
 # Set the background colour of the selection and whether to use this setting.
 fun void SetSelBack=2068(bool useSetting, colour back)
 
+# Get the alpha of the selection.
+get int GetSelAlpha=2477(,)
+
+# Set the alpha of the selection.
+set void SetSelAlpha=2478(int alpha,)
+
+# Is the selection end of line filled?
+get bool GetSelEOLFilled=2479(,)
+
+# Set the selection to have its end of line filled or not.
+set void SetSelEOLFilled=2480(bool filled,)
+
 # Set the foreground colour of the caret.
 set void SetCaretFore=2069(colour fore,)
 
@@ -1300,7 +1317,7 @@
 # Move the caret inside current view if it's not there already.
 fun void MoveCaretInsideView=2401(,)
 
-# How many characters are on a line, not including end of line characters?
+# How many characters are on a line, including end of line characters?
 fun int LineLength=2350(int line,)
 
 # Highlight the characters at two positions.
@@ -1717,7 +1734,8 @@
 val SC_MOD_BEFOREINSERT=0x400
 val SC_MOD_BEFOREDELETE=0x800
 val SC_MULTILINEUNDOREDO=0x1000
-val SC_MODEVENTMASKALL=0x1FFF
+val SC_STARTACTION=0x2000
+val SC_MODEVENTMASKALL=0x2FFF
 
 # For compatibility, these go through the COMMAND notification rather than NOTIFY
 # and should have had exactly the same values as the EN_* constants.
@@ -1749,6 +1767,9 @@
 val SCK_ADD=310
 val SCK_SUBTRACT=311
 val SCK_DIVIDE=312
+val SCK_WIN=313
+val SCK_RWIN=314
+val SCK_MENU=315
 
 enu KeyMod=SCMOD_
 val SCMOD_NORM=0
@@ -1835,6 +1856,8 @@
 val SCLEX_FREEBASIC=75
 val SCLEX_INNOSETUP=76
 val SCLEX_OPAL=77
+val SCLEX_SPICE=78
+val SCLEX_D=79
 
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -1881,6 +1904,26 @@
 val SCE_C_COMMENTDOCKEYWORD=17
 val SCE_C_COMMENTDOCKEYWORDERROR=18
 val SCE_C_GLOBALCLASS=19
+# Lexical states for SCLEX_D
+lex D=SCLEX_D SCE_D_
+val SCE_D_DEFAULT=0
+val SCE_D_COMMENT=1
+val SCE_D_COMMENTLINE=2
+val SCE_D_COMMENTDOC=3
+val SCE_D_COMMENTNESTED=4
+val SCE_D_NUMBER=5
+val SCE_D_WORD=6
+val SCE_D_WORD2=7
+val SCE_D_WORD3=8
+val SCE_D_TYPEDEF=9
+val SCE_D_STRING=10
+val SCE_D_STRINGEOL=11
+val SCE_D_CHARACTER=12
+val SCE_D_OPERATOR=13
+val SCE_D_IDENTIFIER=14
+val SCE_D_COMMENTLINEDOC=15
+val SCE_D_COMMENTDOCKEYWORD=16
+val SCE_D_COMMENTDOCKEYWORDERROR=17
 # Lexical states for SCLEX_TCL
 lex TCL=SCLEX_TCL SCE_TCL_
 val SCE_TCL_DEFAULT=0
@@ -1903,6 +1946,8 @@
 val SCE_TCL_WORD6=17
 val SCE_TCL_WORD7=18
 val SCE_TCL_WORD8=19
+val SCE_TCL_COMMENT_BOX=20
+val SCE_TCL_BLOCK_COMMENT=21
 # Lexical states for SCLEX_HTML, SCLEX_XML
 lex HTML=SCLEX_HTML SCE_H
 lex XML=SCLEX_XML SCE_H
@@ -2678,6 +2723,7 @@
 val SCE_AU3_SPECIAL=12
 val SCE_AU3_EXPAND=13
 val SCE_AU3_COMOBJ=14
+val SCE_AU3_UDF=15
 # Lexical states for SCLEX_APDL
 lex APDL=SCLEX_APDL SCE_APDL_
 val SCE_APDL_DEFAULT=0
@@ -2942,6 +2988,17 @@
 val SCE_OPAL_PAR=7
 val SCE_OPAL_BOOL_CONST=8
 val SCE_OPAL_DEFAULT=32
+# Lexical states for SCLEX_SPICE
+lex Spice=SCLEX_SPICE SCE_SPICE_
+val SCE_SPICE_DEFAULT=0
+val SCE_SPICE_IDENTIFIER=1
+val SCE_SPICE_KEYWORD=2
+val SCE_SPICE_KEYWORD2=3
+val SCE_SPICE_KEYWORD3=4
+val SCE_SPICE_NUMBER=5
+val SCE_SPICE_DELIMITER=6
+val SCE_SPICE_VALUE=7
+val SCE_SPICE_COMMENTLINE=8
 
 # Events
 

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2007-01-20 15:16:26 UTC (rev 1212)
+++ trunk/src/sci_cb.c	2007-01-20 23:54:28 UTC (rev 1213)
@@ -183,7 +183,7 @@
 		}
  		case SCN_MODIFIED:
 		{
-			if (nt->modificationType & SC_START_ACTION && ! app->ignore_callback)
+			if (nt->modificationType & SC_STARTACTION && ! app->ignore_callback)
 			{
 				// get notified about undo changes
 				document_undo_add(idx, UNDO_SCINTILLA, NULL);


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