public override void Execute(object parameter) { var e = parameter as TextCompositionEventArgs; var selectionArea = selectionViewReader.GetCurrentSelectionArea(); var prevCaretPosition = caretViewReader.CaretPosition; UpdateCommandState(BeforeCommandExecutedState); if (selectionArea == null) { textView.EnterText(e.Text); } else { textView.ReplaceText(e.Text, selectionArea); } UpdateCommandState(AfterCommandExecutedState); caretView.HandleTextChange(e.Text); textView.Postbox.Put(new TextAddedMessage { Text = e.Text, PrevCaretPosition = prevCaretPosition, NewCaretPosition = caretViewReader.CaretPosition }); }
public void InitializeTest() { cv = new CaretView(); tv = new TextView(cv); tv.EnterText("one"); tv.EnterText("\r"); tv.EnterText("two"); tv.EnterText("\r"); tv.EnterText("three"); tv.EnterText("\r"); tv.EnterText("four"); tv.EnterText("\r"); tv.EnterText("five"); tv.EnterText("\r"); tv.EnterText("six"); }
public void EnterOpeningAndClosingBracket_LineStateShouldNotChange() { const string text1 = "{}"; tv.EnterText(text1); tv.HandleTextFolding(GetFoldClickedMessage(0, 0, 1, 0, FoldingStates.FOLDED)); tv.HandleTextFolding(GetFoldClickedMessage(0, 0, 1, 0, FoldingStates.EXPANDED)); var renderedLines = tv.GetScreenLines(); Assert.AreEqual(renderedLines[0], text1); }
public void FourCharsPasted_LinesShouldBe1() { tv.EnterText("asdf"); Assert.AreEqual(1, tv.LinesCount); }