public static void Select(this ITextSelection selection, params SnapshotSpan[] spans) { if (spans.Length == 1) { selection.Mode = TextSelectionMode.Stream; selection.Clear(); selection.Select(spans[0], false); } else { selection.Mode = TextSelectionMode.Box; foreach (var span in spans) { selection.Select(span, false); } } }
public static void Restore(TextSelectionState state, ITextSelection selection, ITextCaret caret) { caret.MoveTo( state.m_caretPosition.BufferPosition.TranslateTo(selection.TextView.TextSnapshot, PointTrackingMode.Positive), state.m_caretPosition.Affinity); selection.Mode = state.m_mode; SnapshotSpan newSpan; if (state.m_mode == TextSelectionMode.Box) { newSpan = new SnapshotSpan( state.m_trackedSpans[0].GetStartPoint(selection.TextView.TextBuffer.CurrentSnapshot), state.m_trackedSpans[state.m_trackedSpans.Count - 1].GetEndPoint(selection.TextView.TextBuffer.CurrentSnapshot)); } else { newSpan = state.m_trackedSpans[0].GetSpan(selection.TextView.TextBuffer.CurrentSnapshot); } selection.Select(newSpan, state.m_isReversed); }
public static void Select(this ITextSelection selection, SnapshotPoint startPoint, SnapshotPoint endPoint) { selection.Select(new VirtualSnapshotPoint(startPoint), new VirtualSnapshotPoint(endPoint)); }
public static void Select(this ITextSelection selection, int start, int length) { var snapshotSpan = new SnapshotSpan(selection.TextView.TextSnapshot, start, length); selection.Select(snapshotSpan); }
public void ChangeModeToNormalShouldClearSelection() { Create(lines: "foo"); _selection.Select(_textView.GetLine(0).Extent); _mode.Process(KeyInputUtil.EscapeKey); Assert.IsTrue(_selection.GetSpan().IsEmpty); }