/// <summary> /// Delete the node or character in front of the cursor /// </summary> public async Task <bool> ActionDeleteNodeOrCharInFrontOfCursorPos(XmlCursorPos position, SetUndoSnapshotOptions setUnDoSnapshot) { if (!this.ActionsAllowed) { return(false); } // Move the cursor one position to the left var deleteArea = new XmlCursor(); deleteArea.StartPos.SetPos(position.ActualNode, position.PosOnNode, position.PosInTextNode); var endPos = deleteArea.StartPos.Clone(); await CursorPosMoveHelper.MoveLeft(endPos, this.editorState.RootNode, this.xmlRules); deleteArea.EndPos.SetPos(endPos.ActualNode, endPos.PosOnNode, endPos.PosInTextNode); await deleteArea.OptimizeSelection(); if (deleteArea.StartPos.ActualNode == this.editorState.RootNode) { return(false); // You must not delete the root node } if (setUnDoSnapshot == SetUndoSnapshotOptions.Yes) { this.editorState.UndoHandler.SetSnapshot("delete", this.editorState.CursorRaw); } var deleteResult = await XmlCursorSelectionHelper.DeleteSelection(deleteArea); if (deleteResult.Success) { // After successful deletion the new CursorPos is retrieved here await this.editorState.CursorRaw.SetPositions(deleteResult.NewCursorPosAfterDelete.ActualNode, deleteResult.NewCursorPosAfterDelete.PosOnNode, deleteResult.NewCursorPosAfterDelete.PosInTextNode, throwChangedEventWhenValuesChanged : false); await this.editorState.FireContentChangedEvent(needToSetFocusOnEditorWhenLost : false, forceFullRepaint : false); return(true); } return(false); }
public async Task <bool> MoveLeft(XmlCursorPos cursorPos) { return(await CursorPosMoveHelper.MoveLeft(cursorPos, this.editorContext.EditorState.RootNode, this.editorContext.XmlRules)); }