public void AppendText(string newText) { _settingText = true; BeginUpdate(); try { TextLocation oldEndPoint = Document.OffsetToPosition(Document.TextLength); bool oldReadOnly = Document.ReadOnly; Document.ReadOnly = false; if ((Document.TextLength > 0) && (newText.Length > 0)) { Document.Insert(Document.TextLength, "\r\n"); } Document.Insert(Document.TextLength, newText); Document.ReadOnly = oldReadOnly; ActiveTextAreaControl.Caret.Position = oldEndPoint; ActiveTextAreaControl.ScrollToCaret(); } finally { _settingText = false; EndUpdate(); } Refresh(); // if this isn't done then half the loaded text won't show up. }
private void SetSelection(int index, int length) { ActiveTextAreaControl.SelectionManager.ClearSelection(); TextLocation startSelection = ActiveTextAreaControl.Document.OffsetToPosition(index); TextLocation endSelection = ActiveTextAreaControl.Document.OffsetToPosition(index + length); ActiveTextAreaControl.SelectionManager.SetSelection(startSelection, endSelection); ActiveTextAreaControl.Caret.Position = startSelection; ActiveTextAreaControl.ScrollTo(startSelection.Line, startSelection.Column); }
public TextEditorControl Append(string s, bool refresh = true) { // http://community.icsharpcode.net/forums/t/9931.aspx // Is this really the best way to do this? Document.Insert(Document.TextLength, s); if (refresh) { ActiveTextAreaControl.JumpTo(Document.TotalNumberOfLines, Document.LineSegmentCollection[Document.TotalNumberOfLines - 1].Length, true); } return(this); }
private void TextChangedEventHandler(object sender, EventArgs e) { var editor = sender as TextEditorControlEx; if (editor != null) { bool vScrollBarIsNeeded = editor.Document.TotalNumberOfLines > ActiveTextAreaControl.TextArea.TextView.VisibleLineCount; if (ActiveTextAreaControl.VScrollBar.Visible && HideVScrollBarIfPossible && !vScrollBarIsNeeded) { ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical, false); } } }
public void SetText(string newText) { _settingText = true; BeginUpdate(); try { Document.TextContent = _repairCRLF.Replace(newText, "\r\n"); Document.UndoStack.ClearAll(); Document.BookmarkManager.Clear(); Document.UpdateQueue.Clear(); ActiveTextAreaControl.Caret.Position = TextLocation.Empty; ActiveTextAreaControl.ScrollToCaret(); } finally { _settingText = false; EndUpdate(); } Refresh(); // if this isn't done then half the loaded text won't show up. }
public void JumpTo(int line, int column) { ActiveTextAreaControl.ScrollTo(line, column); ActiveTextAreaControl.Caret.Line = line; ActiveTextAreaControl.Caret.Column = column; }
private void DoSelectAll() { new SelectWholeDocument().Execute(ActiveTextAreaControl.TextArea); ActiveTextAreaControl.Focus(); }
private void DoPaste() { new Paste().Execute(ActiveTextAreaControl.TextArea); ActiveTextAreaControl.Focus(); }
private void DoCopy() { new Copy().Execute(ActiveTextAreaControl.TextArea); ActiveTextAreaControl.Focus(); }