char BackSpaceOneChar() { if (CurrentTextRun == null) { return('\0'); } else { if (CharIndex == 0) { return('\0'); } //move back 1 char and do delete EditableRun removingTextRun = CurrentTextRun; int removeIndex = CurrentTextRunCharIndex; SetCurrentCharStepLeft(); char toBeRemovedChar = CurrentChar; EditableRun.InnerRemove(removingTextRun, removeIndex, 1, false); if (removingTextRun.CharacterCount == 0) { CurrentLine.Remove(removingTextRun); EnsureCurrentTextRun(); } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); return(toBeRemovedChar); } }
char Delete() { if (CurrentTextRun == null) { return('\0'); } else { if (CharIndex < 0) { return('\0'); } char toBeRemovedChar = CurrentChar; EditableRun removingTextRun = CurrentTextRun; int removeIndex = CurrentTextRunCharIndex; CharIndex--; EditableRun.InnerRemove(removingTextRun, removeIndex, 1, false); if (removingTextRun.CharacterCount == 0) { CurrentLine.Remove(removingTextRun); EnsureCurrentTextRun(); } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); return(toBeRemovedChar); } }
public void AddTextSpan(EditableRun textRun) { if (CurrentLine.IsBlankLine) { CurrentLine.AddLast(textRun); SetCurrentTextRun(textRun); CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); SetCurrentCharIndex(CharIndex + textRun.CharacterCount); } else { if (CurrentTextRun != null) { VisualPointInfo newPointInfo = CurrentLine.Split(GetCurrentPointInfo()); if (newPointInfo.IsOnTheBeginOfLine) { CurrentLine.AddBefore((EditableRun)newPointInfo.TextRun, textRun); } else { CurrentLine.AddAfter((EditableRun)newPointInfo.TextRun, textRun); } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); EnsureCurrentTextRun(CharIndex + textRun.CharacterCount); } else { throw new NotSupportedException(); } } }
public void ReplaceCurrentLine(IEnumerable <EditableRun> textRuns) { int currentCharIndex = CharIndex; CurrentLine.ReplaceAll(textRuns); CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); EnsureCurrentTextRun(currentCharIndex); }
public void RemoveSelectedTextRuns(VisualSelectionRange selectionRange) { int precutIndex = selectionRange.StartPoint.LineCharIndex; CurrentLine.Remove(selectionRange); CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); EnsureCurrentTextRun(precutIndex); }
public void ClearCurrentLine() { int currentCharIndex = CharIndex; CurrentLine.ReplaceAll(null); CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); EnsureCurrentTextRun(currentCharIndex); }
public void RemoveSelectedTextRuns(VisualSelectionRange selectionRange) { #if DEBUG //if (!CurrentLine.dbugHasOwner) //{ //} #endif int precutIndex = selectionRange.StartPoint.LineCharIndex; CurrentLine.Remove(selectionRange); InvalidateCurrentRun(); CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); SetCurrentCharIndex2(precutIndex); }
public void AddCharacter(char c) { if (CurrentLine.IsBlankLine) { //TODO: review here, enable this feature or not //some char can't be a start char on blank line if (!InternalTextLayerController.CanCaretStopOnThisChar(c)) { return; } // //1. new EditableRun t = new EditableTextRun(this.RootGfx, c, this.CurrentSpanStyle); var owner = this.FlowLayer.OwnerRenderElement; CurrentLine.AddLast(t); SetCurrentTextRun(t); } else { EditableRun cRun = CurrentTextRun; if (cRun != null) { if (cRun.IsInsertable) { cRun.InsertAfter(CurrentTextRunCharIndex, c); } else { AddTextSpan(new EditableTextRun(this.RootGfx, c, this.CurrentSpanStyle)); return; } } else { throw new NotSupportedException(); } } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); SetCurrentCharStepRight(); }
public void AddCharacter(char c) { if (CurrentLine.IsBlankLine) { //TODO: review here, enable this feature or not //some char can't be a start char on blank line if (!TextFlowEditSession.CanCaretStopOnThisChar(c)) { return; } // //1. new var run = new TextRun(this.CurrentSpanStyle, new char[] { c }); CurrentLine.AddLast(run); SetCurrentTextRun(run); } else { Run run = CurrentTextRun; if (run != null) { if (run.IsInsertable) { run.InsertAfter(CurrentTextRunCharIndex, c); } else { AddTextSpan(new TextRun(CurrentSpanStyle, new char[] { c })); return; } } else { throw new NotSupportedException(); } } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); SetCurrentCharStepRight(); }
public void AddCharacter(char c) { if (CurrentLine.IsBlankLine) { //1. new EditableRun t = new EditableTextRun(this.Root, c, this.CurrentSpanStyle); var owner = this.FlowLayer.OwnerRenderElement; CurrentLine.AddLast(t); SetCurrentTextRun(t); } else { EditableRun cRun = CurrentTextRun; if (cRun != null) { if (cRun.IsInsertable) { cRun.InsertAfter(CurrentTextRunCharIndex, c); } else { AddTextSpan(new EditableTextRun(this.Root, c, this.CurrentSpanStyle)); return; } } else { throw new NotSupportedException(); } } CurrentLine.TextLineReCalculateActualLineSize(); CurrentLine.RefreshInlineArrange(); CharIndex++; }