SF.net SVN: geany: [2350] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sat Mar 15 11:11:57 UTC 2008
Revision: 2350
http://geany.svn.sourceforge.net/geany/?rev=2350&view=rev
Author: eht16
Date: 2008-03-15 04:11:57 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Add (basic) column mode editing, pasting text does not work. Patch by chuck, thanks.
Modified Paths:
--------------
trunk/ChangeLog
trunk/scintilla/Editor.cxx
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-03-15 11:06:55 UTC (rev 2349)
+++ trunk/ChangeLog 2008-03-15 11:11:57 UTC (rev 2350)
@@ -2,6 +2,8 @@
* src/projects.c: Fix wrong directory when choosing project filename
in the New Project dialog.
+ * scintilla/Editor.cxx: Add (basic) column mode editing, pasting text
+ does not work. Patch by chuck, thanks.
2008-03-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/scintilla/Editor.cxx
===================================================================
--- trunk/scintilla/Editor.cxx 2008-03-15 11:06:55 UTC (rev 2349)
+++ trunk/scintilla/Editor.cxx 2008-03-15 11:11:57 UTC (rev 2350)
@@ -3366,23 +3366,52 @@
// 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(wasSelection && selType == selRectangle ) {
+ int startPos;
+ int endPos;
+
+ int c1 = pdoc->GetColumn(currentPos);
+ int c2 = pdoc->GetColumn(anchor);
+ int offset = c1 < c2 ? c1 : c2;
+
+ pdoc->BeginUndoAction();
+ SelectionLineIterator lineIterator(this, false);
+ while (lineIterator.Iterate()) {
+ startPos = lineIterator.startPos;
+ endPos = lineIterator.endPos;
+
+ if(pdoc->GetColumn(endPos) >= offset){
+ unsigned int chars = endPos - startPos;
+ if (0 != chars) {
+ pdoc->DeleteChars(startPos, chars);
+ }
+ pdoc->InsertString(startPos, s, len);
+ }
+ }
+ 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 (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) {
AutoSurface surface(this);
@@ -3537,14 +3566,41 @@
}
void Editor::Clear() {
- if (currentPos == anchor) {
+ bool wasSelection = currentPos != anchor;
+ if(wasSelection && selType == selRectangle ) {
+ int startPos;
+ int endPos;
+
+ int c1 = pdoc->GetColumn(currentPos);
+ int c2 = pdoc->GetColumn(anchor);
+ int offset = c1 < c2 ? c1 : c2;
+
+ pdoc->BeginUndoAction();
+ SelectionLineIterator lineIterator(this, false);
+ while (lineIterator.Iterate()) {
+ startPos = lineIterator.startPos;
+ endPos = lineIterator.endPos;
+
+ if(pdoc->GetColumn(endPos) >= offset){
+ unsigned int chars = endPos - startPos;
+ if (0 != chars) {
+ pdoc->DeleteChars(startPos, chars);
+ } else
+ 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() {
@@ -3580,7 +3636,33 @@
}
void Editor::DelCharBack(bool allowLineStartDeletion) {
- if (currentPos == anchor) {
+ bool wasSelection = currentPos != anchor;
+ if(wasSelection && selType == selRectangle ) {
+ int startPos;
+ int endPos;
+
+ int c1 = pdoc->GetColumn(currentPos);
+ int c2 = pdoc->GetColumn(anchor);
+ int offset = c1 < c2 ? c1 : c2;
+
+ pdoc->BeginUndoAction();
+ SelectionLineIterator lineIterator(this, false);
+ while (lineIterator.Iterate()) {
+ startPos = lineIterator.startPos;
+ endPos = lineIterator.endPos;
+
+ if(pdoc->GetColumn(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)) {
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