/// <summary> /// Doubles the click selection extend. /// </summary> void DoubleClickSelectionExtend() { Point mousepos = _textArea.MousePositionInternal; _textArea.SelectionManager.ClearSelection(); if (_textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { Fold marker = _textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { marker.IsFolded = false; _textArea.MotherTextAreaControl.AdjustScrollBars(); } if (_textArea.Caret.Offset < _textArea.Document.TextLength) { switch (_textArea.Document.GetCharAt(_textArea.Caret.Offset)) { case '"': if (_textArea.Caret.Offset < _textArea.Document.TextLength) { int next = FindNext(_textArea.Document, _textArea.Caret.Offset + 1, '"'); _minSelection = _textArea.Caret.Position; if (next > _textArea.Caret.Offset && next < _textArea.Document.TextLength) { next += 1; } _maxSelection = _textArea.Document.OffsetToPosition(next); } break; default: _minSelection = _textArea.Document.OffsetToPosition(FindWordStart(_textArea.Document, _textArea.Caret.Offset)); _maxSelection = _textArea.Document.OffsetToPosition(FindWordEnd(_textArea.Document, _textArea.Caret.Offset)); break; } _textArea.Caret.Position = _maxSelection; _textArea.SelectionManager.ExtendSelection(_minSelection, _maxSelection); } if (_textArea.SelectionManager.Selections.Count > 0) { ISelection selection = _textArea.SelectionManager.Selections[0]; selection.StartPosition = _minSelection; selection.EndPosition = _maxSelection; _textArea.SelectionManager.SelectionStart = _minSelection; } // after a double-click selection, the caret is placed correctly, // but it is not positioned internally. The effect is when the cursor // is moved up or down a line, the caret will take on the column first // clicked on for the double-click _textArea.SetDesiredColumn(); // HACK WARNING !!! // must refresh here, because when a error tooltip is showed and the underlined // code is double clicked the textArea don't update correctly, updateline doesn't // work ... but the refresh does. // Mike _textArea.Refresh(); } }
void InsertString(int offset, string str) { _textArea.Document.Insert(offset, str); _textArea.Caret.Position = _textArea.Document.OffsetToPosition(offset + str.Length); _textArea.Refresh(); }