--- Editor.h	Sun Apr 12 17:32:54 2009
+++ linux/scintilla/src/Editor.h	Sun May 10 17:15:54 2009
@@ -202,6 +202,8 @@ protected:	// ScintillaBase subclass nee
 	SelectionText drag;
 	enum selTypes { noSel, selStream, selRectangle, selLines };
 	selTypes selType;
+	bool multiLineCaret ; 
+	bool multiLineEdit ; 
 	bool moveExtendsSelection;
 	int xStartSelect;	///< x position of start of rectangular selection
 	int xEndSelect;		///< x position of end of rectangular selection
--- Editor.cxx	Sat Apr 25 08:06:04 2009
+++ linux/scintilla/src/Editor.cxx	Sun May 10 17:12:50 2009
@@ -120,6 +120,8 @@ Editor::Editor() {
 	originalAnchorPos = 0;
 
 	selType = selStream;
+	multiLineCaret = 0 ;
+	multiLineEdit = 1 ;
 	moveExtendsSelection = false;
 	xStartSelect = 0;
 	xEndSelect = 0;
@@ -1244,10 +1246,15 @@ void Editor::DropCaret() {
 }
 
 void Editor::InvalidateCaret() {
-	if (posDrag >= 0)
+	if (posDrag >= 0) {
 		InvalidateRange(posDrag, posDrag + 1);
-	else
+	} else {
+		if (multiLineCaret && selType == selRectangle) {
+			InvalidateRange(currentPos, anchor + 1);
+		} else {
 		InvalidateRange(currentPos, currentPos + 1);
+		}
+	}
 	UpdateSystemCaret();
 }
 
@@ -2932,6 +2939,7 @@ void Editor::Paint(Surface *surfaceWindo
 	//Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n",
 	//	paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
 
+	int xcurrentPos = XFromPosition(currentPos) ; 
 	pixmapLine->Release();
 	RefreshStyleData();
 	RefreshPixMaps(surfaceWindow);
@@ -3164,8 +3172,19 @@ void Editor::Paint(Surface *surfaceWindo
 #endif
 
 				// Draw the Caret
-				if (lineDoc == lineCaret) {
+				if (!multiLineCaret && (selType == selRectangle)  && (ll->selStart  >0 )) {
+					rcLine.left = xcurrentPos + xStart;
+					rcLine.right = rcLine.left + 1;
+					surface->FillRectangle(rcLine, vs.caretcolour.allocated);
+				} 
+				if (lineDoc == lineCaret || (multiLineCaret && selType == selRectangle)) {
 					int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength);
+					if (multiLineCaret && (selType == selRectangle) && (posDrag < 0)) {
+						offset = Platform::Minimum(
+							((xStartSelect < xEndSelect) ? lineIterator.endPos :
+							lineIterator.startPos) - rangeLine.start,
+							ll->maxLineLength);
+					}
 					if (ll->InLine(offset, subLine)) {
 						int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
 
@@ -3540,22 +3559,52 @@ void Editor::AddChar(char ch) {
 // AddCharUTF inserts an array of bytes which may or may not be in UTF-8.
 void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 	bool wasSelection = currentPos != anchor;
-	ClearSelection();
-	bool charReplaceAction = false;
-	if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos + 1)) {
-		if (currentPos < (pdoc->Length())) {
-			if (!IsEOLChar(pdoc->CharAt(currentPos))) {
-				charReplaceAction = true;
-				pdoc->BeginUndoAction();
-				pdoc->DelChar(currentPos);
+	if(multiLineEdit && wasSelection && selType == selRectangle ) {
+		int startPos;
+		int endPos;
+		int offset = Platform::Minimum(XFromPosition(currentPos),
+		                               XFromPosition(anchor));
+		pdoc->BeginUndoAction();
+		SelectionLineIterator lineIterator(this, false);
+		while (lineIterator.Iterate()) {
+			startPos = lineIterator.startPos;
+			endPos   = lineIterator.endPos;
+			unsigned int chars = endPos - startPos;
+			if (0 != chars) {
+				pdoc->DeleteChars(startPos, chars);
 			}
+			// add spaces
+			while( offset > XFromPosition(startPos) ){
+				pdoc->InsertChar(startPos, ' ');  
+				startPos++;
+			}
+			if(inOverstrike  &&  (!IsEOLChar(pdoc->CharAt(startPos))) ) {
+				pdoc->DelChar(startPos);
+			} 
+			pdoc->InsertString(startPos, s, len);
 		}
-	}
-	if (pdoc->InsertString(currentPos, s, len)) {
-		SetEmptySelection(currentPos + len);
-	}
-	if (charReplaceAction) {
+		anchor += len;
+		currentPos += len;
+		SetRectangularRange();
 		pdoc->EndUndoAction();
+	} else {
+		ClearSelection();
+		bool charReplaceAction = false;
+		if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos + 1)) {
+			if (currentPos < (pdoc->Length())) {
+				if (!IsEOLChar(pdoc->CharAt(currentPos))) {
+					charReplaceAction = true;
+					pdoc->BeginUndoAction();
+					pdoc->DelChar(currentPos);
+				}
+			}
+		}
+		if (pdoc->InsertString(currentPos, s, len)) {
+			SetEmptySelection(currentPos + len);
+		}
+		if (charReplaceAction) {
+			pdoc->EndUndoAction();
+		}
 	}
 	// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
 	if (wrapState != eWrapNone) {
@@ -3708,7 +3757,7 @@ void Editor::PasteRectangular(int pos, c
 			// Pad the end of lines with spaces if required
 			currentPos = PositionFromLineX(line, xInsert);
 			if ((XFromPosition(currentPos) < xInsert) && (i + 1 < len)) {
-				for (int i = 0; i < xInsert - XFromPosition(currentPos); i++) {
+				while (xInsert > XFromPosition(currentPos)) {
 					pdoc->InsertChar(currentPos, ' ');
 					currentPos++;
 				}
@@ -3729,14 +3778,40 @@ bool Editor::CanPaste() {
 }
 
 void Editor::Clear() {
-	if (currentPos == anchor) {
+	bool wasSelection = currentPos != anchor;
+	if(multiLineEdit && wasSelection && selType == selRectangle ) {
+		int startPos;
+		int endPos;
+
+		int offset = Platform::Minimum(XFromPosition(currentPos),
+		                               XFromPosition(anchor));
+
+		pdoc->BeginUndoAction();
+		SelectionLineIterator lineIterator(this, false);
+		while (lineIterator.Iterate()) {
+			startPos = lineIterator.startPos;
+			endPos   = lineIterator.endPos;
+			
+			if(XFromPosition(endPos) >= offset){
+				unsigned int chars = endPos - startPos;
+				if (0 != chars) {
+					pdoc->DeleteChars(startPos, chars);
+				} else  if(!IsEOLChar(pdoc->CharAt(startPos)))
+					pdoc->DelChar(startPos);
+			}
+		}
+		SetRectangularRange();
+		pdoc->EndUndoAction();
+
+	} else if (currentPos == anchor) {
 		if (!RangeContainsProtected(currentPos, currentPos + 1)) {
 			DelChar();
 		}
 	} else {
 		ClearSelection();
 	}
-	SetEmptySelection(currentPos);
+	if( !wasSelection )
+		SetEmptySelection(currentPos);
 }
 
 void Editor::SelectAll() {
@@ -3772,7 +3847,32 @@ void Editor::DelChar() {
 }
 
 void Editor::DelCharBack(bool allowLineStartDeletion) {
-	if (currentPos == anchor) {
+	bool wasSelection = currentPos != anchor;
+	if(multiLineEdit && wasSelection && selType == selRectangle ) {
+		int startPos;
+		int endPos;
+
+		int offset = Platform::Minimum(XFromPosition(currentPos),
+		                               XFromPosition(anchor));
+
+		pdoc->BeginUndoAction();
+		SelectionLineIterator lineIterator(this, false);
+		while (lineIterator.Iterate()) {
+			startPos = lineIterator.startPos;
+			endPos   = lineIterator.endPos;
+
+			if(XFromPosition(endPos) >= offset){
+				unsigned int chars = endPos - startPos;
+				if (0 != chars) {
+					pdoc->DeleteChars(startPos, chars);
+				} else
+					pdoc->DelCharBack(startPos);
+			}
+		}
+		SetRectangularRange();
+		pdoc->EndUndoAction();
+
+	} else if (currentPos == anchor) {
 		if (!RangeContainsProtected(currentPos - 1, currentPos)) {
 			int lineCurrentPos = pdoc->LineFromPosition(currentPos);
 			if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) {
