diff options
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 4 | ||||
| -rw-r--r-- | src/Editor.cxx | 41 | ||||
| -rw-r--r-- | src/Editor.h | 2 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 12 | 
5 files changed, 41 insertions, 19 deletions
| diff --git a/include/Scintilla.h b/include/Scintilla.h index ceb7cc7e4..370aa6d50 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -388,6 +388,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_UPPERCASE 2341  #define SCI_LINESCROLLDOWN 2342  #define SCI_LINESCROLLUP 2343 +#define SCI_DELETEBACKNOTLINE 2344  #define SCI_MOVECARETINSIDEVIEW 2401  #define SCI_LINELENGTH 2350  #define SCI_BRACEHIGHLIGHT 2351 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index f6d360fc6..36675e29e 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1032,6 +1032,10 @@ fun void LineScrollDown=2342(,)  # Scroll the document up, keeping the caret visible.  fun void LineScrollUp=2343(,) +# Delete the selection or if no selection, the character before the caret. +# Will not delete the chraacter before at the start of a line. +fun void DeleteBackNotLine=2344(,) +  # Move the caret inside current view if it's not there already  fun void MoveCaretInsideView=2401(,) 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();  			} | 
