Add (basic) column mode editing, pasting text does not work. Patch by chuck, thanks.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2350 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
e85ee6758c
commit
3e0efbf7fa
@ -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>
|
||||
|
@ -3366,6 +3366,34 @@ 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;
|
||||
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)) {
|
||||
@ -3383,6 +3411,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
|
||||
if (charReplaceAction) {
|
||||
pdoc->EndUndoAction();
|
||||
}
|
||||
}
|
||||
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
|
||||
if (wrapState != eWrapNone) {
|
||||
AutoSurface surface(this);
|
||||
@ -3537,13 +3566,40 @@ bool Editor::CanPaste() {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
if( !wasSelection )
|
||||
SetEmptySelection(currentPos);
|
||||
}
|
||||
|
||||
@ -3580,7 +3636,33 @@ void Editor::DelChar() {
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user