public VisualSelectionRangeSnapShot DoDelete() { //recursive #if DEBUG if (dbugEnableTextManRecorder) { _dbugActivityRecorder.WriteInfo("TxLMan::DoDelete"); _dbugActivityRecorder.BeginContext(); } #endif VisualSelectionRangeSnapShot removedRange = this.RemoveSelectedText(); if (removedRange.IsEmpty()) { _updateJustCurrentLine = true; char deletedChar = _textLineWriter.DoDeleteOneChar(); if (deletedChar == '\0') { //end of this line _commandHistoryList.AddDocAction( new DocActionJoinWithNextLine( _textLineWriter.LineNumber, _textLineWriter.CharIndex)); JoinWithNextLine(); _updateJustCurrentLine = false; } else { _commandHistoryList.AddDocAction( new DocActionDeleteChar( deletedChar, _textLineWriter.LineNumber, _textLineWriter.CharIndex)); char nextChar = _textLineWriter.NextChar; if (nextChar != '\0') { if (!CanCaretStopOnThisChar(nextChar)) { //TODO: review return range here again return(DoDelete()); } } } } #if DEBUG if (dbugEnableTextManRecorder) { _dbugActivityRecorder.EndContext(); } #endif NotifyContentSizeChanged(); return(removedRange); }
public bool DoBackspace() { #if DEBUG if (dbugEnableTextManRecorder) { dbug_BackSpaceCount++; _dbugActivityRecorder.WriteInfo("TxLMan::DoBackSpace"); _dbugActivityRecorder.BeginContext(); } #endif VisualSelectionRangeSnapShot removeSelRange = this.RemoveSelectedText(); if (!removeSelRange.IsEmpty()) { CancelSelect(); #if DEBUG if (dbugEnableTextManRecorder) { _dbugActivityRecorder.EndContext(); } #endif return(true); } else { _updateJustCurrentLine = true; char deletedChar = _textLineWriter.DoBackspaceOneChar(); if (deletedChar == '\0') { //end of current line if (!IsOnFirstLine) { CurrentLineNumber--; DoEnd(); _commandHistoryList.AddDocAction( new DocActionJoinWithNextLine( _textLineWriter.LineNumber, _textLineWriter.CharIndex)); JoinWithNextLine(); } #if DEBUG if (dbugEnableTextManRecorder) { _dbugActivityRecorder.EndContext(); } #endif return(false); } else { _commandHistoryList.AddDocAction( new DocActionDeleteChar( deletedChar, _textLineWriter.LineNumber, _textLineWriter.CharIndex)); #if DEBUG if (dbugEnableTextManRecorder) { _dbugActivityRecorder.EndContext(); } #endif return(true); } } }