private string GetCurrentLineText() { var caretIndex = CommandLineBox.CaretIndex; var lineIndex = CommandLineBox.GetLineIndexFromCharacterIndex(caretIndex); return(lineIndex >= 0 && lineIndex < CommandLineBox.LineCount ? CommandLineBox.GetLineText(lineIndex) : ""); }
private void ReplaceCurrentLineText(string newText) { var caretIndex = CommandLineBox.CaretIndex; var lineIndex = CommandLineBox.GetLineIndexFromCharacterIndex(caretIndex); var characterIndex = CommandLineBox.GetCharacterIndexFromLineIndex(lineIndex); var textOnLine = CommandLineBox.GetLineText(lineIndex); CommandLineBox.Select(characterIndex, textOnLine.Length); CommandLineBox.SelectedText = newText; CommandLineBox.Focus(); CommandLineBox.Select(CommandLineBox.Text.Length, 0); CommandLineBox.ScrollToLine(lineIndex); }