VSTF.TextBounds?TryGetNormalizedTextBounds(VST.Span lineSpan) { if (!IsValid) { throw new ObjectDisposedException(nameof(HexFormattedLineImpl)); } var span = lineExtent.Intersection(lineSpan); if (span is null) { return(null); } var startBounds = GetFirstTextBounds(span.Value.Start); var endBounds = GetLastTextBounds(span.Value.End); if (span.Value.End > TextSpan.End) { endBounds = new VSTF.TextBounds( endBounds.Trailing + EndOfLineWidth, endBounds.Top, 0, endBounds.Height, endBounds.TextTop, endBounds.TextHeight); } return(new VSTF.TextBounds(startBounds.Left, startBounds.Top, endBounds.Left - startBounds.Left, startBounds.Height, startBounds.TextTop, startBounds.TextHeight)); }
/// <summary> /// Determines whether two <see cref="TextBounds"/> objects are the same. /// </summary> public override bool Equals(object obj) { // Check for the obvious if (obj == null || !(obj is TextBounds)) { return(false); } TextBounds bounds = (TextBounds)obj; return(bounds == this); }
IList <VSTF.TextBounds> GetTextBounds(HexViewLine line) { if (lineSpan.IsTextSpan) { if (lineSpan.TextSpan !.Value.Length == 0) { if (line.BufferSpan.Contains(lineSpan.BufferSpan)) { var bounds = line.GetCharacterBounds(lineSpan.TextSpan.Value.Start); // It's just a point, so use zero width bounds = new VSTF.TextBounds(bounds.Leading, bounds.Top, 0, bounds.Height, bounds.TextTop, bounds.TextHeight); return(new VSTF.TextBounds[] { bounds }); } return(Array.Empty <VSTF.TextBounds>()); } else { return(line.GetNormalizedTextBounds(lineSpan)); } }
public Collection <TF.TextBounds> GetNormalizedTextBounds(SnapshotSpan bufferSpan) { if (!IsValid) { throw new ObjectDisposedException(nameof(WpfTextViewLine)); } if (bufferSpan.Snapshot != Snapshot) { throw new ArgumentException(); } var span = ExtentIncludingLineBreak.Intersection(bufferSpan); var list = new List <TF.TextBounds>(); if (span == null) { return(new Collection <TF.TextBounds>(list)); } //TODO: Handle RTL text and adornments var startBounds = GetFirstTextBounds(span.Value.Start); var endBounds = GetLastTextBounds(span.Value.End); if (span.Value.End > End) { endBounds = new TF.TextBounds( endBounds.Trailing + EndOfLineWidth, endBounds.Top, 0, endBounds.Height, endBounds.TextTop, endBounds.TextHeight); } list.Add(new TF.TextBounds(startBounds.Left, startBounds.Top, endBounds.Left - startBounds.Left, startBounds.Height, startBounds.TextTop, startBounds.TextHeight)); return(new Collection <TF.TextBounds>(list)); }
void UpdateAdornmentUIState(HexViewLine line, AdornmentTagInfo adornmentInfo, VSTF.TextBounds bounds) { double verticalScale = line.LineTransform.VerticalScale; adornmentInfo.TopUIElement.SetScale(verticalScale); Canvas.SetTop(adornmentInfo.TopUIElement, bounds.TextTop + line.Baseline - verticalScale * adornmentInfo.Tag.Baseline); Canvas.SetLeft(adornmentInfo.TopUIElement, bounds.Left); }
public Collection<TF.TextBounds> GetNormalizedTextBounds(SnapshotSpan bufferSpan) { if (!IsValid) throw new ObjectDisposedException(nameof(WpfTextViewLine)); if (bufferSpan.Snapshot != Snapshot) throw new ArgumentException(); var span = ExtentIncludingLineBreak.Intersection(bufferSpan); var list = new List<TF.TextBounds>(); if (span == null) return new Collection<TF.TextBounds>(list); var startBounds = GetFirstTextBounds(span.Value.Start); var endBounds = GetLastTextBounds(span.Value.End); if (span.Value.End > End) { endBounds = new TF.TextBounds( endBounds.Trailing + EndOfLineWidth, endBounds.Top, 0, endBounds.Height, endBounds.TextTop, endBounds.TextHeight); } list.Add(new TF.TextBounds(startBounds.Left, startBounds.Top, endBounds.Left - startBounds.Left, startBounds.Height, startBounds.TextTop, startBounds.TextHeight)); return new Collection<TF.TextBounds>(list); }
private void InternalMoveCaret(VirtualSnapshotPoint bufferPosition, PositionAffinity caretAffinity, ITextViewLine textLine, bool captureHorizontalPosition, bool captureVerticalPosition, bool raiseEvent) { CaretPosition oldPosition = this.Position; _caretAffinity = caretAffinity; _insertionPoint = bufferPosition; _forceVirtualSpace = _insertionPoint.IsInVirtualSpace && !this.IsVirtualSpaceOrBoxSelectionEnabled; _emptySelection = _wpfTextView.Selection.IsEmpty; _isContainedByView = (textLine.VisibilityState != VisibilityState.Unattached); double xCoordinate; double width; if (bufferPosition.IsInVirtualSpace || textLine.End == bufferPosition.Position) { //Never show overwrite caret when at the physical end of a line. this.OverwriteMode = false; } else { //Position is in the interior of the line ... preferred position is based strictly on the bufferPosition. this.OverwriteMode = _wpfTextView.Options.IsOverwriteModeEnabled() && _emptySelection; } // if we're in overwrite mode, draw a rectangle covering the text element, otherwise, just // draw a thin line if (_overwriteMode) { Microsoft.VisualStudio.Text.Formatting.TextBounds bounds = textLine.GetExtendedCharacterBounds(bufferPosition); xCoordinate = bounds.Left; width = bounds.Width; } else { xCoordinate = GetXCoordinateFromVirtualBufferPosition(textLine, bufferPosition); width = 10;//TODO: SystemParameters.CaretWidth; } _bounds = new SKRect((float)xCoordinate, (float)textLine.TextTop, (float)(xCoordinate + width), (float)textLine.TextBottom); CapturePreferredPositions(captureHorizontalPosition, captureVerticalPosition); CaretPosition newPosition = this.Position; if (newPosition != oldPosition) { this.UpdateBlinkTimer(); if (raiseEvent) { if (_selection.IsEmpty) { //Empty selections are logically located at the caret position, so force a selection changed event to be raised //before any of the caret position changed events. _selection.RaiseChangedEvent(emptyBefore: true, emptyAfter: true, moved: true); } // Inform this change to interested parties EventHandler <CaretPositionChangedEventArgs> positionChanged = this.PositionChanged; if (positionChanged != null) { _guardedOperations.RaiseEvent <CaretPositionChangedEventArgs>(this, positionChanged, new CaretPositionChangedEventArgs(_wpfTextView, oldPosition, newPosition)); } } } this.InvalidateVisual(); _updateNeeded = true; }
IList<VSTF.TextBounds> GetTextBounds(HexViewLine line) { if (lineSpan.IsTextSpan) { if (lineSpan.TextSpan.Value.Length == 0) { if (line.BufferSpan.Contains(lineSpan.BufferSpan)) { var bounds = line.GetCharacterBounds(lineSpan.TextSpan.Value.Start); // It's just a point, so use zero width bounds = new VSTF.TextBounds(bounds.Leading, bounds.Top, 0, bounds.Height, bounds.TextTop, bounds.TextHeight); return new VSTF.TextBounds[] { bounds }; } return Array.Empty<VSTF.TextBounds>(); } else return line.GetNormalizedTextBounds(lineSpan); } else { var fullSpan = lineSpan.BufferSpan; if (fullSpan.Length == 0) { if (line.BufferSpan.Contains(fullSpan)) return line.GetNormalizedTextBounds(fullSpan, lineSpan.SelectionFlags.Value); return Array.Empty<VSTF.TextBounds>(); } else return line.GetNormalizedTextBounds(lineSpan); } }