void PerformActionInUndo(Func <bool> action) { ITrackingPoint anchor = _textView.TextSnapshot.CreateTrackingPoint(_textView.Selection.AnchorPoint.Position, PointTrackingMode.Positive); ITrackingPoint active = _textView.TextSnapshot.CreateTrackingPoint(_textView.Selection.ActivePoint.Position, PointTrackingMode.Positive); bool empty = _textView.Selection.IsEmpty; TextSelectionMode mode = _textView.Selection.Mode; using (var undo = _undoHistory.CreateTransaction("Untabify")) { _operations.AddBeforeTextBufferChangePrimitive(); if (!action()) { undo.Cancel(); return; } ITextSnapshot after = _textView.TextSnapshot; _operations.SelectAndMoveCaret(new VirtualSnapshotPoint(anchor.GetPoint(after)), new VirtualSnapshotPoint(active.GetPoint(after)), mode, EnsureSpanVisibleOptions.ShowStart); _operations.AddAfterTextBufferChangePrimitive(); undo.Complete(); } }
public StubTextSelection(StubWpfTextView textView) { _wpfTextView = textView; this._activePoint = this._anchorPoint = new VirtualSnapshotPoint(this._wpfTextView.TextSnapshot, 0); this._selectionMode = TextSelectionMode.Stream; }
private void EnterMode(SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { _textView.SelectAndUpdateCaret(span, mode); Assert.IsFalse(_context.IsEmpty); _context.RunAll(); Assert.IsTrue(_context.IsEmpty); }
public void EnterModeWithSelection(SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { _textView.SelectAndUpdateCaret(span, mode); Assert.IsFalse(_context.IsEmpty); _context.RunAll(); Assert.IsTrue(_context.IsEmpty); }
/// <summary> /// Constructs a BeforeTextBufferChangeUndoPrimitive. /// </summary> /// <param name="textView"> /// The text view that was responsible for causing this change. /// </param> /// <param name="undoHistory"> /// The <see cref="ITextUndoHistory" /> this primitive will be added to. /// </param> /// <exception cref="ArgumentNullException"><paramref name="textView"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="undoHistory"/> is null.</exception> public static BeforeTextBufferChangeUndoPrimitive Create(ITextView textView, ITextUndoHistory undoHistory) { if (textView == null) { throw new ArgumentNullException("textView"); } if (undoHistory == null) { throw new ArgumentNullException("undoHistory"); } // Store the ITextView for these changes in the ITextUndoHistory properties so we can retrieve it later. if (!undoHistory.Properties.ContainsProperty(typeof(ITextView))) { undoHistory.Properties[typeof(ITextView)] = textView; } CaretPosition caret = textView.Caret.Position; IMapEditToData map = BeforeTextBufferChangeUndoPrimitive.GetMap(textView); int oldCaretIndex = BeforeTextBufferChangeUndoPrimitive.MapToData(map, caret.BufferPosition); int oldCaretVirtualSpaces = caret.VirtualBufferPosition.VirtualSpaces; VirtualSnapshotPoint anchor = textView.Selection.AnchorPoint; int oldSelectionAnchorIndex = BeforeTextBufferChangeUndoPrimitive.MapToData(map, anchor.Position); int oldSelectionAnchorVirtualSpaces = anchor.VirtualSpaces; VirtualSnapshotPoint active = textView.Selection.ActivePoint; int oldSelectionActiveIndex = BeforeTextBufferChangeUndoPrimitive.MapToData(map, active.Position); int oldSelectionActiveVirtualSpaces = active.VirtualSpaces; TextSelectionMode oldSelectionMode = textView.Selection.Mode; if (oldCaretVirtualSpaces != 0 || oldSelectionAnchorIndex != oldCaretIndex || oldSelectionAnchorVirtualSpaces != 0 || oldSelectionActiveIndex != oldCaretIndex || oldSelectionActiveVirtualSpaces != 0 || oldSelectionMode != TextSelectionMode.Stream) { return(new GeneralBeforeTextBufferChangeUndoPrimitive (undoHistory, oldCaretIndex, caret.Affinity, oldCaretVirtualSpaces, oldSelectionAnchorIndex, oldSelectionAnchorVirtualSpaces, oldSelectionActiveIndex, oldSelectionActiveVirtualSpaces, oldSelectionMode)); } else { return(new BeforeTextBufferChangeUndoPrimitive(undoHistory, oldCaretIndex, caret.Affinity)); } }
public GeneralBeforeTextBufferChangeUndoPrimitive(ITextUndoHistory undoHistory, int oldCaretIndex, PositionAffinity oldCaretAffinity, int oldCaretVirtualSpaces, int oldSelectionAnchorIndex, int oldSelectionAnchorVirtualSpaces, int oldSelectionActiveIndex, int oldSelectionActiveVirtualSpaces, TextSelectionMode oldSelectionMode) : base(undoHistory, oldCaretIndex, oldCaretAffinity) { _oldCaretVirtualSpaces = oldCaretVirtualSpaces; _oldSelectionAnchorIndex = oldSelectionAnchorIndex; _oldSelectionAnchorVirtualSpaces = oldSelectionAnchorVirtualSpaces; _oldSelectionActiveIndex = oldSelectionActiveIndex; _oldSelectionActiveVirtualSpaces = oldSelectionActiveVirtualSpaces; _oldSelectionMode = oldSelectionMode; }
public GeneralAfterTextBufferChangeUndoPrimitive(ITextUndoHistory undoHistory, int newCaretIndex, PositionAffinity newCaretAffinity, int newCaretVirtualSpaces, int newSelectionAnchorIndex, int newSelectionAnchorVirtualSpaces, int newSelectionActiveIndex, int newSelectionActiveVirtualSpaces, TextSelectionMode newSelectionMode) : base(undoHistory, newCaretIndex, newCaretAffinity) { _newCaretVirtualSpaces = newCaretVirtualSpaces; _newSelectionAnchorIndex = newSelectionAnchorIndex; _newSelectionAnchorVirtualSpaces = newSelectionAnchorVirtualSpaces; _newSelectionActiveIndex = newSelectionActiveIndex; _newSelectionActiveVirtualSpaces = newSelectionActiveVirtualSpaces; _newSelectionMode = newSelectionMode; }
public TextSelection(IWpfTextView textView, IAdornmentLayer selectionLayer, IEditorFormatMap editorFormatMap) { if (selectionLayer == null) { throw new ArgumentNullException(nameof(selectionLayer)); } if (editorFormatMap == null) { throw new ArgumentNullException(nameof(editorFormatMap)); } TextView = textView ?? throw new ArgumentNullException(nameof(textView)); Mode = TextSelectionMode.Stream; activePoint = anchorPoint = new VirtualSnapshotPoint(TextView.TextSnapshot, 0); TextView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority; TextView.Options.OptionChanged += Options_OptionChanged; TextView.GotAggregateFocus += TextView_GotAggregateFocus; TextView.LostAggregateFocus += TextView_LostAggregateFocus; textSelectionLayer = new TextSelectionLayer(this, selectionLayer, editorFormatMap); ActivationTracksFocus = true; }
/// <summary> /// Constructs a new selection Element /// </summary> public SkiaTextSelection(SkiaTextView wpfTextView, IEditorFormatMap editorFormatMap, GuardedOperations guardedOperations) { // Verify Debug.Assert(wpfTextView != null); _wpfTextView = wpfTextView; _editorFormatMap = editorFormatMap; ActivationTracksFocus = true; // Initialize members _activePoint = _anchorPoint = new VirtualSnapshotPoint(_wpfTextView.TextSnapshot, 0); _selectionMode = TextSelectionMode.Stream; _selectionAdornmentLayer = _wpfTextView.GetAdornmentLayer(PredefinedAdornmentLayers.Selection); _guardedOperations = guardedOperations; this.CreateAndSetPainter("Selected Text", ref _focusedPainter, SKColors.Blue.WithAlpha(80)); this.CreateAndSetPainter("Inactive Selected Text", ref _unfocusedPainter, SKColors.Gray.WithAlpha(80)); this.Painter.Activate(); SubscribeToEvents(); }
public static void SelectAndUpdateCaret(this ITextView textView, SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { textView.Selection.Mode = mode; textView.Selection.Select(span, false); var point = span.Length > 0 ? span.End.Subtract(1) : span.Start; MoveCaretTo(textView, point); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions? scrollOptions) { throw new NotImplementedException(); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) { throw new NotImplementedException(); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) { throw new NotImplementedException(); }
public static void SelectAndUpdateCaret(this ITextView textView, SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { textView.Selection.Mode = mode; textView.Selection.Select(span, false); MoveCaretTo(textView, span.End.Position); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) => SelectAndMoveCaret(anchorPoint, activePoint, selectionMode, EnsureSpanVisibleOptions.MinimumScroll);
/// <summary> /// Sets text selection mode by words or chars /// </summary> /// <param name="mode">The parameter which indicates the text selection mode</param> /// <returns>An instance of the widget object</returns> public AnnotationWidget TextSelectionMode(TextSelectionMode mode) { _options.TextSelectionByCharModeEnabled = (mode == Options.TextSelectionMode.ByChars); return this; }
private void EnterMode(ModeKind kind, SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { EnterMode(span, mode); _buffer.SwitchMode(kind, ModeArgument.None); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode);
public void Clear() { Mode = TextSelectionMode.Stream; ClearInternal(); }
public TextSelection(IWpfTextView textView, IAdornmentLayer selectionLayer, IEditorFormatMap editorFormatMap) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (selectionLayer == null) throw new ArgumentNullException(nameof(selectionLayer)); if (editorFormatMap == null) throw new ArgumentNullException(nameof(editorFormatMap)); TextView = textView; Mode = TextSelectionMode.Stream; activePoint = anchorPoint = new VirtualSnapshotPoint(TextView.TextSnapshot, 0); TextView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority; TextView.Options.OptionChanged += Options_OptionChanged; TextView.GotAggregateFocus += TextView_GotAggregateFocus; TextView.LostAggregateFocus += TextView_LostAggregateFocus; textSelectionLayer = new TextSelectionLayer(this, selectionLayer, editorFormatMap); ActivationTracksFocus = true; }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions?scrollOptions) { throw new NotImplementedException(); }
/// <summary> /// Sets text selection mode by words or chars /// </summary> /// <param name="mode">The parameter which indicates the text selection mode</param> /// <returns>An instance of the widget object</returns> public AnnotationWidget TextSelectionMode(TextSelectionMode mode) { _options.TextSelectionByCharModeEnabled = (mode == Options.TextSelectionMode.ByChars); return(this); }
/// <summary> /// Sets text selection mode by words or chars /// </summary> /// <param name="mode">The parameter which indicates the text selection mode</param> /// <returns>An instance of the widget object</returns> public AnnotationWidget TextSelectionMode(TextSelectionMode mode) { _options.TextSelectionByCharModeEnabled = (mode == GroupDocs_Annotation_SharePoint_WebPart.BusinessLogic.Options.TextSelectionMode.ByChars); return(this); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions?scrollOptions) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode, scrollOptions);
public void Clear() { Mode = TextSelectionMode.Stream; ClearInternal(); }
/// <summary> /// Sets text selection mode by words or chars /// </summary> /// <param name="mode">The parameter which indicates the text selection mode</param> /// <returns>An instance of the widget object</returns> public AnnotationWidget TextSelectionMode(TextSelectionMode mode) { _options.TextSelectionByCharModeEnabled = (mode == GroupDocs.Demo.Annotation.Webforms.BusinessLogic.Options.TextSelectionMode.ByChars); return(this); }
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode);
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions? scrollOptions) => EditorOperations.SelectAndMoveCaret(anchorPoint, activePoint, selectionMode, scrollOptions);
public void SelectAndMoveCaret(VirtualSnapshotPoint anchorPoint, VirtualSnapshotPoint activePoint, TextSelectionMode selectionMode, EnsureSpanVisibleOptions? scrollOptions) { anchorPoint = anchorPoint.TranslateTo(Snapshot); activePoint = activePoint.TranslateTo(Snapshot); if (anchorPoint == activePoint) Selection.Clear(); else Selection.Select(anchorPoint, activePoint); Selection.Mode = selectionMode; activePoint = activePoint.TranslateTo(Snapshot); Caret.MoveTo(activePoint); if (scrollOptions == null) return; anchorPoint = anchorPoint.TranslateTo(Snapshot); activePoint = activePoint.TranslateTo(Snapshot); if (activePoint > anchorPoint) ViewScroller.EnsureSpanVisible(new SnapshotSpan(anchorPoint.Position, activePoint.Position), scrollOptions.Value & ~EnsureSpanVisibleOptions.ShowStart); else ViewScroller.EnsureSpanVisible(new SnapshotSpan(activePoint.Position, anchorPoint.Position), scrollOptions.Value | EnsureSpanVisibleOptions.ShowStart); }
public void EnterMode(ModeKind kind, SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream) { EnterModeWithSelection(span, mode); _buffer.SwitchMode(kind, ModeArgument.None); }