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. }
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. }