public void Write(ConsoleStyle style) { var cursorIndex = CursorIndex; EditLine.EnableStyleAt(cursorIndex, style); Render(cursorIndex); }
private void Delete(bool word) { if (HasSelection) { RemoveSelection(); return; } var cursorIndex = CursorIndex; if (cursorIndex < EditLine.Count) { if (word) { var count = FindNextWordRight(cursorIndex) - cursorIndex; EditLine.RemoveRangeAt(cursorIndex, count); } else { EditLine.RemoveAt(cursorIndex); } Render(); } }
private void Backspace(bool word) { if (HasSelection) { RemoveSelection(); return; } var cursorIndex = CursorIndex; if (cursorIndex == 0) { return; } if (word) { MoveLeft(true); var newCursorIndex = CursorIndex; var length = cursorIndex - CursorIndex; EditLine.RemoveRangeAt(newCursorIndex, length); cursorIndex = newCursorIndex; } else { cursorIndex--; EditLine.RemoveAt(cursorIndex); } Render(cursorIndex); }
public override void Trigger(object sender, MouseEventArgs e, Invoker invoker) { Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location); if (foundSymbol == null) { } else if (foundSymbol.type == "Class") { ClassSymbol foundClass = foundSymbol as ClassSymbol; EditClass editClassWindow = new EditClass(foundClass, TargetDrawing, invoker); editClassWindow.Show(); } else if (foundSymbol.type == "Binary") { BinaryRelationship foundBinary = foundSymbol as BinaryRelationship; EditBinary editBinaryWindow = new EditBinary(foundBinary, TargetDrawing, invoker); editBinaryWindow.Show(); } else { Relationship foundLine = foundSymbol as Relationship; EditLine editLineWindow = new EditLine(foundLine, invoker, TargetDrawing); editLineWindow.Show(); } }
private bool EnterInternal(bool hasControl) { if (HasSelection) { EndSelection(); } End(); var text = EditLine.Count == 0 ? string.Empty : EditLine.ToString(); // Try to validate the string if (OnTextValidatingEnter != null) { bool isValid = false; try { Evaluating = true; isValid = OnTextValidatingEnter(text, hasControl); } finally { Evaluating = false; } if (!isValid) { Render(); return(false); } } bool isNotEmpty = !IsClean || EditLine.Count > 0 || AfterEditLine.Count > 0; if (isNotEmpty) { Render(reset: true); } // Propagate enter validation OnTextValidatedEnter?.Invoke(text); if (!string.IsNullOrEmpty(text)) { History.Add(text); } _stackIndex = -1; if (!ExitOnNextEval) { Render(0); } return(true); }
public void Write(string text, int index, int length) { if (text == null) { throw new ArgumentNullException(nameof(text)); } var cursorIndex = CursorIndex + length; EditLine.InsertRange(CursorIndex, text, index, length); Render(cursorIndex); }
public void Write(char c) { if (SelectionIndex >= 0) { RemoveSelection(); } EndSelection(); var cursorIndex = CursorIndex; EditLine.Insert(cursorIndex, c); cursorIndex++; Render(cursorIndex); }
public void SetLine(string text) { if (text == null) { throw new ArgumentNullException(nameof(text)); } EndSelection(); // Don't update if it is already empty if (EditLine.Count == 0 && string.IsNullOrEmpty(text)) { return; } EditLine.ReplaceBy(text); Render(EditLine.Count); }
private bool Enter(bool force) { if (EnterInternal(force)) { while (PendingTextToEnter.Count > 0) { var newTextToEnter = PendingTextToEnter.Dequeue(); EditLine.Clear(); EditLine.Append(newTextToEnter); if (!EnterInternal(force)) { return(false); } } return(true); } return(false); }