diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 41 | ||||
-rw-r--r-- | src/Editor.h | 2 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 12 |
3 files changed, 36 insertions, 19 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 254a99736..4fa10968d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1907,24 +1907,26 @@ void Editor::DelChar() { ShowCaretAtCurrentPosition(); } -void Editor::DelCharBack() { +void Editor::DelCharBack(bool allowLineStartDeletion) { if (currentPos == anchor) { int lineCurrentPos = pdoc->LineFromPosition(currentPos); - if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) && - pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) { - pdoc->BeginUndoAction(); - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars); - if (indentation % indentationStep == 0) { - pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); + if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) { + if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) && + pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) { + pdoc->BeginUndoAction(); + int indentation = pdoc->GetLineIndentation(lineCurrentPos); + int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars); + if (indentation % indentationStep == 0) { + pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); + } else { + pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); + } + SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); + pdoc->EndUndoAction(); } else { - pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); + int newPos = pdoc->DelCharBack(currentPos); + SetEmptySelection(newPos); } - SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); - pdoc->EndUndoAction(); - } else { - int newPos = pdoc->DelCharBack(currentPos); - SetEmptySelection(newPos); } } else { ClearSelection(); @@ -2246,6 +2248,9 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_LINETRANSPOSE: case SCI_LOWERCASE: case SCI_UPPERCASE: + case SCI_LINESCROLLDOWN: + case SCI_LINESCROLLUP: + case SCI_DELETEBACKNOTLINE: break; // Filter out all others like display changes. Also, newlines are redundant @@ -2460,7 +2465,12 @@ int Editor::KeyCommand(unsigned int iMessage) { CancelModes(); break; case SCI_DELETEBACK: - DelCharBack(); + DelCharBack(true); + SetLastXChosen(); + EnsureCaretVisible(); + break; + case SCI_DELETEBACKNOTLINE: + DelCharBack(false); SetLastXChosen(); EnsureCaretVisible(); break; @@ -4575,6 +4585,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: + case SCI_DELETEBACKNOTLINE: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: diff --git a/src/Editor.h b/src/Editor.h index 6f4f54e98..3561cee78 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -258,7 +258,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void Undo(); void Redo(); void DelChar(); - void DelCharBack(); + void DelCharBack(bool allowLineStartDeletion); virtual void ClaimSelection() = 0; virtual void NotifyChange() = 0; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 831d9fc34..eb882cfad 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -137,7 +137,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { AutoCompleteMove(5000); return 0; case SCI_DELETEBACK: - DelCharBack(); + DelCharBack(true); + AutoCompleteChanged(); + EnsureCaretVisible(); + return 0; + case SCI_DELETEBACKNOTLINE: + DelCharBack(false); AutoCompleteChanged(); EnsureCaretVisible(); return 0; @@ -160,11 +165,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { (iMessage != SCI_CHARRIGHT) && (iMessage != SCI_CHARLEFTEXTEND) && (iMessage != SCI_EDITTOGGLEOVERTYPE) && - (iMessage != SCI_DELETEBACK) + (iMessage != SCI_DELETEBACK) && + (iMessage != SCI_DELETEBACKNOTLINE) ) { ct.CallTipCancel(); } - if (iMessage == SCI_DELETEBACK) { + if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) { if (currentPos <= ct.posStartCallTip) { ct.CallTipCancel(); } |