diff options
author | nyamatongwe <devnull@localhost> | 2000-03-22 12:16:54 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-03-22 12:16:54 +0000 |
commit | ff69e140ac7634ab8ec4365f97f0adae27692b53 (patch) | |
tree | 7c44f53d74ea3a4303084e24b5a40e8139bc9a01 /src/Editor.cxx | |
parent | 06795dc71160ed0b5ff3a2919e6fd9ef7adc8a4c (diff) | |
download | scintilla-mirror-ff69e140ac7634ab8ec4365f97f0adae27692b53.tar.gz |
Split UndoHistory out of CellBuffer.
Fixed coalescing of nodes in the undo history.
Added LineCut, LineDelete, LineTranspose, UpperCase and LowerCase keyboard
commands and added keys for them.
Added UUID lexical class to CPP lexer.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 8550286ac..226184db2 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1700,6 +1700,11 @@ void Editor::NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam) { case SCI_VCHOMEEXTEND: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: + case SCI_LINECUT: + case SCI_LINEDELETE: + case SCI_LINETRANSPOSE: + case SCI_LOWERCASE: + case SCI_UPPERCASE: break; // Filter out all others (display changes, etc) @@ -1735,6 +1740,60 @@ void Editor::PageMove(int direction, bool extend) { } } +void Editor::ChangeCaseOfSelection(bool makeUpperCase) { + pdoc->BeginUndoAction(); + int startCurrent = currentPos; + int startAnchor = anchor; + if (selType == selRectangle) { + int lineStart = pdoc->LineFromPosition(SelectionStart()); + int lineEnd = pdoc->LineFromPosition(SelectionEnd()); + for (int line=lineStart; line <= lineEnd; line++) { + pdoc->ChangeCase( + Range(SelectionStart(line), SelectionEnd(line)), + makeUpperCase); + } + // Would be nicer to keep the rectangular selection but this is complex + selType = selStream; + SetSelection(startCurrent, startCurrent); + } else { + pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), + makeUpperCase); + SetSelection(startCurrent, startAnchor); + } + pdoc->EndUndoAction(); +} + + +void Editor::LineTranspose() { + int line = pdoc->LineFromPosition(currentPos); + if (line > 0) { + int startPrev = pdoc->LineStart(line-1); + int endPrev = pdoc->LineEnd(line-1); + int start = pdoc->LineStart(line); + int end = pdoc->LineEnd(line); + int startNext = pdoc->LineStart(line+1); + if (end < pdoc->Length()) { + end = startNext; + char *thisLine = CopyRange(start, end); + pdoc->DeleteChars(start, end-start); + pdoc->InsertString(startPrev, thisLine, end-start); + MovePositionTo(startPrev+end-start); + delete []thisLine; + } else { + // Last line so line has no line end + char *thisLine = CopyRange(start, end); + char *prevEnd = CopyRange(endPrev, start); + pdoc->DeleteChars(endPrev, end-endPrev); + pdoc->InsertString(startPrev, thisLine, end-start); + pdoc->InsertString(startPrev + end-start, prevEnd, start-endPrev); + MovePositionTo(startPrev + end-endPrev); + delete []thisLine; + delete []prevEnd; + } + + } +} + int Editor::KeyCommand(UINT iMessage) { Point pt = LocationFromPosition(currentPos); @@ -1910,6 +1969,37 @@ int Editor::KeyCommand(UINT iMessage) { MovePositionTo(currentPos); } break; + case SCI_LINECUT: { + int lineStart = pdoc->LineFromPosition(currentPos); + int lineEnd = pdoc->LineFromPosition(anchor); + if (lineStart > lineEnd) { + int t = lineEnd; + lineEnd = lineStart; + lineStart = t; + } + int start = pdoc->LineStart(lineStart); + int end = pdoc->LineStart(lineEnd+1); + SetSelection(start,end); + Cut(); + } + break; + case SCI_LINEDELETE: { + int line = pdoc->LineFromPosition(currentPos); + int start = pdoc->LineStart(line); + int end = pdoc->LineStart(line+1); + pdoc->DeleteChars(start, end-start); + MovePositionTo(start); + } + break; + case SCI_LINETRANSPOSE: + LineTranspose(); + break; + case SCI_LOWERCASE: + ChangeCaseOfSelection(false); + break; + case SCI_UPPERCASE: + ChangeCaseOfSelection(true); + break; } return 0; } @@ -3094,7 +3184,8 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) { #ifdef INCLUDE_DEPRECATED_FEATURES case SCI_APPENDUNDOSTARTACTION: - pdoc->AppendUndoStartAction(); + // Not just deprecated - now dead + //pdoc->AppendUndoStartAction(); return 0; #endif @@ -3649,6 +3740,11 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) { case SCI_ZOOMOUT: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: + case SCI_LINECUT: + case SCI_LINEDELETE: + case SCI_LINETRANSPOSE: + case SCI_LOWERCASE: + case SCI_UPPERCASE: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: |