Exemplo n.º 1
0
 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);
        }
Exemplo n.º 3
0
 public static void Select(this ITextSelection selection, SnapshotPoint startPoint, SnapshotPoint endPoint)
 {
     selection.Select(new VirtualSnapshotPoint(startPoint), new VirtualSnapshotPoint(endPoint));
 }
Exemplo n.º 4
0
        public static void Select(this ITextSelection selection, int start, int length)
        {
            var snapshotSpan = new SnapshotSpan(selection.TextView.TextSnapshot, start, length);

            selection.Select(snapshotSpan);
        }
Exemplo n.º 5
0
 public void ChangeModeToNormalShouldClearSelection()
 {
     Create(lines: "foo");
     _selection.Select(_textView.GetLine(0).Extent);
     _mode.Process(KeyInputUtil.EscapeKey);
     Assert.IsTrue(_selection.GetSpan().IsEmpty);
 }