public void ClearSelection()
{
Point mousepos;
mousepos = textArea.mousepos;
// this is the most logical place to reset selection starting
// positions because it is always called before a new selection
selectFrom.first = selectFrom.where;
selectionStart = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);
if(selectFrom.where == WhereFrom.Gutter)
selectionStart.X = 0;
ClearWithoutUpdate();
document.CommitUpdate();
}
/// <summary> /// Selects the specified text range. /// </summary> static void SelectText(SelectionManager selectionManager, IDocument document, int startOffset, int length) { selectionManager.ClearSelection(); TextLocation selectionStart = document.OffsetToPosition(startOffset); TextLocation selectionEnd = document.OffsetToPosition(startOffset + length); selectionManager.SetSelection(selectionStart, selectionEnd); }