/// <summary> /// Performs text input. /// This raises the <see cref="TextEntering"/> event, replaces the selection with the text, /// and then raises the <see cref="TextEntered"/> event. /// </summary> public void PerformTextInput(TextCompositionEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (this.Document == null) { throw ThrowUtil.NoDocumentAssigned(); } OnTextEntering(e); if (!e.Handled) { if (e.Text == "\n" || e.Text == "\r" || e.Text == "\r\n") { ReplaceSelectionWithNewLine(); } else { if (OverstrikeMode && Selection.IsEmpty && Document.GetLineByNumber(Caret.Line).EndOffset > Caret.Offset) { EditingCommands.SelectRightByCharacter.Execute(null, this); } ReplaceSelectionWithText(e.Text); } OnTextEntered(e); caret.BringCaretToView(); } }
/// <summary> /// Performs text input. /// This raises the <see cref="TextEntering"/> event, replaces the selection with the text, /// and then raises the <see cref="TextEntered"/> event. /// </summary> public void PerformTextInput(TextCompositionEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (this.Document == null) { throw ThrowUtil.NoDocumentAssigned(); } OnTextEntering(e); if (!e.Handled) { if (e.Text == "\n" || e.Text == "\r" || e.Text == "\r\n") { ReplaceSelectionWithNewLine(); } else { ReplaceSelectionWithText(e.Text); } OnTextEntered(e); caret.BringCaretToView(); } }