public IncrementalSearch(TextArea textArea, LogicalDirection direction) { if (textArea == null) throw new ArgumentNullException("textArea"); this.textArea = textArea; this.direction = direction; }
/// <summary> /// 1. When wordBreakDirection = Forward, returns a position at the end of the word, /// i.e. a position with a wordBreak character (space) following it. /// 2. When wordBreakDirection = Backward, returns a position at the start of the word, /// i.e. a position with a wordBreak character (space) preceeding it. /// 3. Returns null when there is no workbreak in the requested direction. /// </summary> private static TextPointer GetPositionAtWordBoundary(TextPointer position, LogicalDirection wordBreakDirection) { if (!position.IsAtInsertionPosition) { position = position.GetInsertionPosition(wordBreakDirection); } TextPointer navigator = position; while (navigator != null && !IsPositionNextToWordBreak(navigator, wordBreakDirection)) { navigator = navigator.GetNextInsertionPosition(wordBreakDirection); } return navigator; }
// Returns true iff the indicated content has scoping highlights. internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction) { int segmentCount; TextSegment textSegment; // No highlight when the selection is for interim character. if (_selection.IsInterimSelection) { return false; } // Check all segments of selection List<TextSegment> textSegments = _selection.TextSegments; segmentCount = textSegments.Count; for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || // (direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0)) { return true; } } return false; }
// Helper for GetPositionAtWordBoundary. // Returns true when passed TextPointer is next to a wordBreak in requested direction. private static bool IsPositionNextToWordBreak(TextPointer position, LogicalDirection wordBreakDirection) { bool isAtWordBoundary = false; // Skip over any formatting. if (position.GetPointerContext(wordBreakDirection) != TextPointerContext.Text) { position = position.GetInsertionPosition(wordBreakDirection); } if (position.GetPointerContext(wordBreakDirection) == TextPointerContext.Text) { LogicalDirection oppositeDirection = (wordBreakDirection == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward; char[] runBuffer = new char[1]; char[] oppositeRunBuffer = new char[1]; position.GetTextInRun(wordBreakDirection, runBuffer, /*startIndex*/0, /*count*/1); position.GetTextInRun(oppositeDirection, oppositeRunBuffer, /*startIndex*/0, /*count*/1); if (runBuffer[0] == ' ' && !(oppositeRunBuffer[0] == ' ')) { isAtWordBoundary = true; } } else { // If we're not adjacent to text then we always want to consider this position a "word break". // In practice, we're most likely next to an embedded object or a block boundary. isAtWordBoundary = true; } return isAtWordBoundary; }
// Throws an ArgumentException if direction is not a valid enum. internal static void VerifyDirection(LogicalDirection direction, string argumentName) { if (direction != LogicalDirection.Forward && direction != LogicalDirection.Backward) { throw new InvalidEnumArgumentException(argumentName, (int)direction, typeof(LogicalDirection)); } }
/// <summary>Creates a new <see cref="BplReferenceValue"/> instance.</summary> public BplReferenceValue(LogicalDirection direction, BplReferenceKind kind, string property, object reference) { Direction = direction; Kind = kind; Property = property; if (reference.IsA<BplObject>()) { Path = new BplPropertyPath(reference).ToString(); } }
/// <inheritdoc/> public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode) { int textOffset = parentVisualLine.StartOffset + this.RelativeTextOffset; int pos = TextUtilities.GetNextCaretPosition(parentVisualLine.Document, textOffset + visualColumn - this.VisualColumn, direction, mode); if (pos < textOffset || pos > textOffset + this.DocumentLength) return -1; else return this.VisualColumn + pos - textOffset; }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; AttributeRange attributeRange; int i; transitionPosition = StaticTextPointer.Null; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } } } } return transitionPosition; }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors // Creates a new PasswordTextPointer instance. internal PasswordTextPointer(PasswordTextContainer container, LogicalDirection gravity, int offset) { Debug.Assert(offset >= 0 && offset <= container.SymbolCount, "Bad PasswordTextPointer offset!"); _container = container; _gravity = gravity; _offset = offset; container.AddPosition(this); }
public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode) { // only place a caret stop before the newline, no caret stop after it if (visualColumn > this.VisualColumn && direction == LogicalDirection.Backward || visualColumn < this.VisualColumn && direction == LogicalDirection.Forward) { return this.VisualColumn; } else { return -1; } }
// Worker for GetText, accepts any ITextPointer. internal static string GetTextInRun(ITextPointer position, LogicalDirection direction) { char[] text; int textLength; int getTextLength; textLength = position.GetTextRunLength(direction); text = new char[textLength]; getTextLength = position.GetTextInRun(direction, text, 0, textLength); Invariant.Assert(getTextLength == textLength, "textLengths returned from GetTextRunLength and GetTextInRun are innconsistent"); return new string(text); }
/// <summary>Creates a new <see cref="TextGlyph"/> instance from the given parameters.</summary> public TextGlyph(string text, Font font, TextOverflow textOverflow, LogicalDirection textOverflowDirection, Vector sharpnessVector) { Text = text; Font = font; TextOverflow = textOverflow; TextOverflowDirection = textOverflowDirection; SharpnessVector = sharpnessVector; _prepareVisualText(Text); var result = _buildGlyph(false, Double.PositiveInfinity); if (result != null) { _fullRun = result.GlyphRun; Size = new Size(result.Width, result.Height); Baseline = result.Baseline; } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Returns the value of a property stored on scoping highlight, if any. // // If no property value is set, returns DependencyProperty.UnsetValue. internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction) { object value; if (IsContentHighlighted(textPosition, direction)) { value = _selectedValue; } else { value = DependencyProperty.UnsetValue; } return value; }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Returns the value of a property stored on scoping highlight, if any. // // If no property value is set, returns DependencyProperty.UnsetValue. internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction) { AttributeRange attributeRange; object value; value = DependencyProperty.UnsetValue; attributeRange = GetRangeAtPosition(textPosition, direction); if (attributeRange != null) { value = attributeRange.TextDecorations; } return value; }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// <see cref="ITextPointer.SetLogicalDirection"/> /// </summary> void ITextPointer.SetLogicalDirection(LogicalDirection direction) { Debug.Assert(!_isFrozen, "Can't reposition a frozen pointer!"); if (direction != _gravity) { // We need to remove the position from the container since we're // going to change its gravity, which changes its internal sort order. this.Container.RemovePosition(this); _gravity = direction; // Now start tracking the position again, at it's new sort order. this.Container.AddPosition(this); } }
// Like GetText, excepts also accepts a limit parameter -- no text is returned past // this second position. // limit may be null, in which case it is ignored. internal static int GetTextWithLimit(ITextPointer thisPointer, LogicalDirection direction, char[] textBuffer, int startIndex, int count, ITextPointer limit) { int charsCopied; if (limit == null) { // No limit, just call GetText. charsCopied = thisPointer.GetTextInRun(direction, textBuffer, startIndex, count); } else if (direction == LogicalDirection.Forward && limit.CompareTo(thisPointer) <= 0) { // Limit completely blocks the read. charsCopied = 0; } else if (direction == LogicalDirection.Backward && limit.CompareTo(thisPointer) >= 0) { // Limit completely blocks the read. charsCopied = 0; } else { int maxCount; // Get an upper bound on the amount of text to copy. // Since GetText always stops on non-text boundaries, it's // ok if the count too high, it will get truncated anyways. if (direction == LogicalDirection.Forward) { maxCount = Math.Min(count, thisPointer.GetOffsetToPosition(limit)); } else { maxCount = Math.Min(count, limit.GetOffsetToPosition(thisPointer)); } maxCount = Math.Min(count, maxCount); charsCopied = thisPointer.GetTextInRun(direction, textBuffer, startIndex, maxCount); } return charsCopied; }
public WordParser(string text, LogicalDirection direction) { __Text = text; __DirectionToSearch = direction; if (direction == LogicalDirection.Backward) __State = WordParserState.WitespacesBeforeWord; else { if (text.Length == 0) __State = WordParserState.WitespacesBeforeWord; else { if (symbols.Contains(__Text[0])) __State = WordParserState.ParsingSymbol; else if (whitespaces.Contains(__Text[0])) __State = WordParserState.WitespacesBeforeWord; else __State = WordParserState.ParsingText; } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Returns true if position points to a word break in the supplied // char array. position is an inter-character offset -- 0 points // to the space preceeding the first char, 1 points between the // first and second char, etc. // // insideWordDirection specifies whether we're looking for a word start // or word end. If insideWordDirection == LogicalDirection.Forward, then // text = "abc def", position = 4 will return true, but if the direction is // backward, no word boundary will be found (looking backward position is // at the edge of whitespace, not a word). // // This method requires at least MinContextLength chars ahead of and // following position to give accurate results, but no more. internal static bool IsAtWordBoundary(char[] text, int position, LogicalDirection insideWordDirection) { CharClass[] classes = GetClasses(text); // If the inside text is blank, it's not a word boundary. if (insideWordDirection == LogicalDirection.Backward) { if (position == text.Length) { return true; } if (position == 0 || IsWhiteSpace(text[position - 1], classes[position - 1])) { return false; } } else { if (position == 0) { return true; } if (position == text.Length || IsWhiteSpace(text[position], classes[position])) { return false; } } UInt16[] charType3 = new UInt16[2]; SafeNativeMethods.GetStringTypeEx(0 /* ignored */, SafeNativeMethods.CT_CTYPE3, new char[] { text[position - 1], text[position] }, 2, charType3); // Otherwise we're at a word boundary if the classes of the surrounding text differ. return IsWordBoundary(text[position - 1], text[position]) || ( !IsSameClass(charType3[0], classes[position - 1], charType3[1], classes[position]) && !IsMidLetter(text, position - 1, classes) && !IsMidLetter(text, position, classes) ); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Returns the value of a property stored on scoping highlight, if any. /// </summary> /// <param name="textPosition"> /// Position to query. /// </param> /// <param name="direction"> /// Direction of content to query. /// </param> /// <param name="highlightLayerOwnerType"> /// Type of the matching highlight layer owner. /// </param> /// <returns> /// The highlight value if set on any scoping highlight. If no property /// value is set, returns DependencyProperty.UnsetValue. /// </returns> internal virtual object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction, Type highlightLayerOwnerType) { int layerIndex; object value; HighlightLayer layer; value = DependencyProperty.UnsetValue; // Take the value on the closest layer. "Closest" == added first. for (layerIndex = 0; layerIndex < this.LayerCount; layerIndex++) { layer = GetLayer(layerIndex); if (layer.OwnerType == highlightLayerOwnerType) { value = layer.GetHighlightValue(textPosition, direction); if (value != DependencyProperty.UnsetValue) break; } } return value; }
/// <summary> /// <see cref="ITextView.GetNextCaretUnitPosition"/> /// </summary> ITextPointer ITextView.GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction) { return(GetNextCaretUnitPosition(position, direction)); }
/// <summary> /// Gets the next caret position. /// </summary> /// <param name="textSource">The text source.</param> /// <param name="offset">The start offset inside the text source.</param> /// <param name="direction">The search direction (forwards or backwards).</param> /// <param name="mode">The mode for caret positioning.</param> /// <returns> /// The offset of the next caret position, or -1 if there is no further caret position /// in the text source. /// </returns> /// <remarks> /// This method is NOT equivalent to the actual caret movement when using VisualLine.GetNextCaretPosition. /// In real caret movement, there are additional caret stops at line starts and ends. This method /// treats linefeeds as simple whitespace. /// </remarks> public static int GetNextCaretPosition(ITextSource textSource, int offset, LogicalDirection direction, CaretPositioningMode mode) { if (textSource == null) { throw new ArgumentNullException("textSource"); } switch (mode) { case CaretPositioningMode.Normal: case CaretPositioningMode.EveryCodepoint: case CaretPositioningMode.WordBorder: case CaretPositioningMode.WordBorderOrSymbol: case CaretPositioningMode.WordStart: case CaretPositioningMode.WordStartOrSymbol: break; // OK default: throw new ArgumentException("Unsupported CaretPositioningMode: " + mode, "mode"); } if (direction != LogicalDirection.Backward && direction != LogicalDirection.Forward) { throw new ArgumentException("Invalid LogicalDirection: " + direction, "direction"); } var textLength = textSource.TextLength; if (textLength <= 0) { // empty document? has a normal caret position at 0, though no word borders if (IsNormal(mode)) { if (offset > 0 && direction == LogicalDirection.Backward) { return(0); } if (offset < 0 && direction == LogicalDirection.Forward) { return(0); } } return(-1); } while (true) { var nextPos = direction == LogicalDirection.Backward ? offset - 1 : offset + 1; // return -1 if there is no further caret position in the text source // we also need this to handle offset values outside the valid range if (nextPos < 0 || nextPos > textLength) { return(-1); } // check if we've run against the textSource borders. // a 'textSource' usually isn't the whole document, but a single VisualLineElement. if (nextPos == 0) { // at the document start, there's only a word border // if the first character is not whitespace if (IsNormal(mode) || !char.IsWhiteSpace(textSource.GetCharAt(0))) { return(nextPos); } } else if (nextPos == textLength) { // at the document end, there's never a word start if (mode != CaretPositioningMode.WordStart && mode != CaretPositioningMode.WordStartOrSymbol) { // at the document end, there's only a word border // if the last character is not whitespace if (IsNormal(mode) || !char.IsWhiteSpace(textSource.GetCharAt(textLength - 1))) { return(nextPos); } } } else { var charBefore = textSource.GetCharAt(nextPos - 1); var charAfter = textSource.GetCharAt(nextPos); // Don't stop in the middle of a surrogate pair if (!char.IsSurrogatePair(charBefore, charAfter)) { var classBefore = GetCharacterClass(charBefore); var classAfter = GetCharacterClass(charAfter); // get correct class for characters outside BMP: if (char.IsLowSurrogate(charBefore) && nextPos >= 2) { classBefore = GetCharacterClass(textSource.GetCharAt(nextPos - 2), charBefore); } if (char.IsHighSurrogate(charAfter) && nextPos + 1 < textLength) { classAfter = GetCharacterClass(charAfter, textSource.GetCharAt(nextPos + 1)); } if (StopBetweenCharacters(mode, classBefore, classAfter)) { return(nextPos); } } } // we'll have to continue searching... offset = nextPos; } }
/// <summary> /// Returns the position of the next highlight start or end in an /// indicated direction, or null if there is no such position. /// </summary> /// <param name="textPosition"> /// Position to query. /// </param> /// <param name="direction"> /// Direction of content to query. /// </param> internal virtual StaticTextPointer GetNextHighlightChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer changePosition; StaticTextPointer closestChangePosition; int i; closestChangePosition = StaticTextPointer.Null; // Calculate the min of the layers' transitions. for (i = 0; i < this.LayerCount; i++) { changePosition = GetLayer(i).GetNextChangePosition(textPosition, direction); if (!changePosition.IsNull) { if (closestChangePosition.IsNull) { closestChangePosition = changePosition; } else if (direction == LogicalDirection.Forward) { closestChangePosition = StaticTextPointer.Min(closestChangePosition, changePosition); } else { closestChangePosition = StaticTextPointer.Max(closestChangePosition, changePosition); } } } return(closestChangePosition); }
/// <summary>Returns a <see cref="T:System.Windows.Documents.TextPointer" /> that points to the next spelling error in the contents of the <see cref="T:System.Windows.Controls.RichTextBox" />.</summary> /// <param name="position">A <see cref="T:System.Windows.Documents.TextPointer" /> indicating a position from which to search for the next spelling error.</param> /// <param name="direction">A <see cref="T:System.Windows.Documents.LogicalDirection" /> in which to search for the next spelling error, starting at the specified <paramref name="posision" />.</param> /// <returns>A <see cref="T:System.Windows.Documents.TextPointer" /> that points to the next spelling error in the contents of the <see cref="T:System.Windows.Controls.RichTextBox" />, or <see langword="null" /> if no next spelling error exists.</returns> // Token: 0x060054BC RID: 21692 RVA: 0x0017744E File Offset: 0x0017564E public TextPointer GetNextSpellingErrorPosition(TextPointer position, LogicalDirection direction) { ValidationHelper.VerifyPosition(base.TextContainer, position); return((TextPointer)base.TextEditor.GetNextSpellingErrorPosition(position, direction)); }
public System.Windows.DependencyObject GetAdjacentElement(LogicalDirection direction) { return default(System.Windows.DependencyObject); }
string System.Windows.Documents.ITextPointer.GetTextInRun(LogicalDirection direction) { return default(string); }
// Token: 0x06002EF2 RID: 12018 RVA: 0x000D4194 File Offset: 0x000D2394 private bool _GetNextLineGlyphs(ref FixedPosition fixedp, ref LogicalDirection edge, double suggestedX, LogicalDirection scanDir) { int num = 1; int page = fixedp.Page; bool result = false; FixedNode[] nextLine = this.Container.FixedTextBuilder.GetNextLine(fixedp.Node, scanDir == LogicalDirection.Forward, ref num); if (nextLine != null && nextLine.Length != 0) { FixedPage fixedPage = this.Container.FixedDocument.SyncGetPage(page, false); if (double.IsInfinity(suggestedX)) { suggestedX = 0.0; } Point point = new Point(suggestedX, 0.0); Point point2 = new Point(suggestedX, 1000.0); FixedNode fixedNode = nextLine[0]; Glyphs g = null; double num2 = double.MaxValue; double xoffset = 0.0; for (int i = nextLine.Length - 1; i >= 0; i--) { FixedNode fixedNode2 = nextLine[i]; Glyphs glyphsElement = fixedPage.GetGlyphsElement(fixedNode2); if (glyphsElement != null) { GeneralTransform generalTransform = fixedPage.TransformToDescendant(glyphsElement); Point inPoint = point; Point inPoint2 = point2; if (generalTransform != null) { generalTransform.TryTransform(inPoint, out inPoint); generalTransform.TryTransform(inPoint2, out inPoint2); } double num3 = (inPoint2.X - inPoint.X) / (inPoint2.Y - inPoint.Y); GlyphRun glyphRun = glyphsElement.ToGlyphRun(); Rect rect = glyphRun.ComputeAlignmentBox(); rect.Offset(glyphsElement.OriginX, glyphsElement.OriginY); double num4; double num5; if (num3 > 1000.0 || num3 < -1000.0) { num4 = 0.0; num5 = ((inPoint.Y > rect.Y) ? (inPoint.Y - rect.Bottom) : (rect.Y - inPoint.Y)); } else { double num6 = (rect.Top + rect.Bottom) / 2.0; num4 = inPoint.X + num3 * (num6 - inPoint.Y); num5 = ((num4 > rect.X) ? (num4 - rect.Right) : (rect.X - num4)); } if (num5 < num2) { num2 = num5; xoffset = num4; fixedNode = fixedNode2; g = glyphsElement; if (num5 <= 0.0) { break; } } } } int offset; this._GlyphRunHitTest(g, xoffset, out offset, out edge); fixedp = new FixedPosition(fixedNode, offset); result = true; } return(result); }
// Token: 0x06002EE3 RID: 12003 RVA: 0x000D3B5C File Offset: 0x000D1D5C internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction) { FixedTextPointer ftp = this.Container.VerifyPosition(position); FixedPosition fixedPosition; if (this._GetFixedPosition(ftp, out fixedPosition)) { DependencyObject element = this.FixedPage.GetElement(fixedPosition.Node); if (element is Glyphs) { Glyphs glyphs = (Glyphs)element; GlyphRun glyphRun = glyphs.ToGlyphRun(); int num = (glyphRun.Characters == null) ? 0 : glyphRun.Characters.Count; CharacterHit characterHit = (fixedPosition.Offset == num) ? new CharacterHit(fixedPosition.Offset - 1, 1) : new CharacterHit(fixedPosition.Offset, 0); CharacterHit obj = (direction == LogicalDirection.Forward) ? glyphRun.GetNextCaretCharacterHit(characterHit) : glyphRun.GetPreviousCaretCharacterHit(characterHit); if (!characterHit.Equals(obj)) { LogicalDirection edge = LogicalDirection.Forward; if (obj.TrailingLength > 0) { edge = LogicalDirection.Backward; } int offset = obj.FirstCharacterIndex + obj.TrailingLength; return(this._CreateTextPointer(new FixedPosition(fixedPosition.Node, offset), edge)); } } } ITextPointer textPointer = position.CreatePointer(); textPointer.MoveToNextInsertionPosition(direction); return(textPointer); }
// Token: 0x06002EE1 RID: 12001 RVA: 0x000D397C File Offset: 0x000D1B7C internal override ITextPointer GetPositionAtNextLine(ITextPointer position, double suggestedX, int count, out double newSuggestedX, out int linesMoved) { newSuggestedX = suggestedX; linesMoved = 0; LogicalDirection logicalDirection = position.LogicalDirection; LogicalDirection logicalDirection2 = LogicalDirection.Forward; FixedTextPointer fixedTextPointer = this.Container.VerifyPosition(position); FixedTextPointer fixedTextPointer2 = new FixedTextPointer(true, logicalDirection, (FlowPosition)fixedTextPointer.FlowPosition.Clone()); this._SkipFormattingTags(fixedTextPointer2); FixedPosition fixedPosition; bool flag; if (count == 0 || ((flag = this._GetFixedPosition(fixedTextPointer2, out fixedPosition)) && fixedPosition.Page != this.PageIndex)) { return(position); } if (count < 0) { count = -count; logicalDirection2 = LogicalDirection.Backward; } if (!flag) { if (this.Contains(position)) { fixedTextPointer2 = new FixedTextPointer(true, logicalDirection2, (FlowPosition)fixedTextPointer.FlowPosition.Clone()); ((ITextPointer)fixedTextPointer2).MoveToInsertionPosition(logicalDirection2); ((ITextPointer)fixedTextPointer2).MoveToNextInsertionPosition(logicalDirection2); if (this.Contains(fixedTextPointer2)) { linesMoved = ((logicalDirection2 == LogicalDirection.Forward) ? 1 : -1); return(fixedTextPointer2); } } return(position); } if (DoubleUtil.IsNaN(suggestedX)) { suggestedX = 0.0; } while (count > linesMoved && this._GetNextLineGlyphs(ref fixedPosition, ref logicalDirection, suggestedX, logicalDirection2)) { linesMoved++; } if (linesMoved == 0) { return(position.CreatePointer()); } if (logicalDirection2 == LogicalDirection.Backward) { linesMoved = -linesMoved; } ITextPointer textPointer = this._CreateTextPointer(fixedPosition, logicalDirection); if (textPointer.CompareTo(position) == 0) { linesMoved = 0; } return(textPointer); }
/// <summary> /// Gets the next possible caret position after visualColumn, or -1 if there is no caret position. /// </summary> public int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode, bool allowVirtualSpace) { if (!HasStopsInVirtualSpace(mode)) { allowVirtualSpace = false; } if (elements.Count == 0) { // special handling for empty visual lines: if (allowVirtualSpace) { if (direction == LogicalDirection.Forward) { return(Math.Max(0, visualColumn + 1)); } else if (visualColumn > 0) { return(visualColumn - 1); } else { return(-1); } } else { // even though we don't have any elements, // there's a single caret stop at visualColumn 0 if (visualColumn < 0 && direction == LogicalDirection.Forward) { return(0); } else if (visualColumn > 0 && direction == LogicalDirection.Backward) { return(0); } else { return(-1); } } } int i; if (direction == LogicalDirection.Backward) { // Search Backwards: // If the last element doesn't handle line borders, return the line end as caret stop if (visualColumn > this.VisualLength && !elements[elements.Count - 1].HandlesLineBorders && HasImplicitStopAtLineEnd(mode)) { if (allowVirtualSpace) { return(visualColumn - 1); } else { return(this.VisualLength); } } // skip elements that start after or at visualColumn for (i = elements.Count - 1; i >= 0; i--) { if (elements[i].VisualColumn < visualColumn) { break; } } // search last element that has a caret stop for (; i >= 0; i--) { int pos = elements[i].GetNextCaretPosition( Math.Min(visualColumn, elements[i].VisualColumn + elements[i].VisualLength + 1), direction, mode); if (pos >= 0) { return(pos); } } // If we've found nothing, and the first element doesn't handle line borders, // return the line start as normal caret stop. if (visualColumn > 0 && !elements[0].HandlesLineBorders && HasImplicitStopAtLineStart(mode)) { return(0); } } else { // Search Forwards: // If the first element doesn't handle line borders, return the line start as caret stop if (visualColumn < 0 && !elements[0].HandlesLineBorders && HasImplicitStopAtLineStart(mode)) { return(0); } // skip elements that end before or at visualColumn for (i = 0; i < elements.Count; i++) { if (elements[i].VisualColumn + elements[i].VisualLength > visualColumn) { break; } } // search first element that has a caret stop for (; i < elements.Count; i++) { int pos = elements[i].GetNextCaretPosition( Math.Max(visualColumn, elements[i].VisualColumn - 1), direction, mode); if (pos >= 0) { return(pos); } } // if we've found nothing, and the last element doesn't handle line borders, // return the line end as caret stop if ((allowVirtualSpace || !elements[elements.Count - 1].HandlesLineBorders) && HasImplicitStopAtLineEnd(mode)) { if (visualColumn < this.VisualLength) { return(this.VisualLength); } else if (allowVirtualSpace) { return(visualColumn + 1); } } } // we've found nothing, return -1 and let the caret search continue in the next line return(-1); }
// Token: 0x06002FFC RID: 12284 internal abstract object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction);
// Token: 0x06002FFE RID: 12286 internal abstract StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction);
ITextPointer System.Windows.Documents.ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection) { return default(ITextPointer); }
TextPointerContext System.Windows.Documents.ITextPointer.GetPointerContext(LogicalDirection direction) { return default(TextPointerContext); }
/// <summary> /// Gets the next caret position. /// </summary> /// <param name="textSource">The text source.</param> /// <param name="offset">The start offset inside the text source.</param> /// <param name="direction">The search direction (forwards or backwards).</param> /// <param name="mode">The mode for caret positioning.</param> /// <returns>The offset of the next caret position, or -1 if there is no further caret position /// in the text source.</returns> /// <remarks> /// This method is NOT equivalent to the actual caret movement when using VisualLine.GetNextCaretPosition. /// In real caret movement, there are additional caret stops at line starts and ends. However, this method /// doesn't know anything about lines: it is often called with a textSource that represents only a single VisualTextElement. /// </remarks> public static int GetNextCaretPosition(ITextSource textSource, int offset, LogicalDirection direction, CaretPositioningMode mode) { if (textSource == null) { throw new ArgumentNullException("textSource"); } if (mode != CaretPositioningMode.Normal && mode != CaretPositioningMode.WordBorder && mode != CaretPositioningMode.WordStart && mode != CaretPositioningMode.WordBorderOrSymbol && mode != CaretPositioningMode.WordStartOrSymbol) { throw new ArgumentException("Unsupported CaretPositioningMode: " + mode, "mode"); } if (direction != LogicalDirection.Backward && direction != LogicalDirection.Forward) { throw new ArgumentException("Invalid LogicalDirection: " + direction, "direction"); } int textLength = textSource.TextLength; if (textLength <= 0) { // empty document? has a normal caret position at 0, though no word borders if (mode == CaretPositioningMode.Normal) { if (offset > 0 && direction == LogicalDirection.Backward) { return(0); } if (offset < 0 && direction == LogicalDirection.Forward) { return(0); } } return(-1); } while (true) { int nextPos = (direction == LogicalDirection.Backward) ? offset - 1 : offset + 1; // return -1 if there is no further caret position in the text source // we also need this to handle offset values outside the valid range if (nextPos < 0 || nextPos > textLength) { return(-1); } // stop at every caret position? we can stop immediately. if (mode == CaretPositioningMode.Normal) { return(nextPos); } // not normal mode? we're looking for word borders... // check if we've run against the textSource borders. // a 'textSource' usually isn't the whole document, but a single VisualLineElement. if (nextPos == 0) { // at the document start, there's only a word border // if the first character is not whitespace if (!char.IsWhiteSpace(textSource.GetCharAt(0))) { return(nextPos); } } else if (nextPos == textLength) { // at the document end, there's never a word start if (mode != CaretPositioningMode.WordStart && mode != CaretPositioningMode.WordStartOrSymbol) { // at the document end, there's only a word border // if the last character is not whitespace if (!char.IsWhiteSpace(textSource.GetCharAt(textLength - 1))) { return(nextPos); } } } else { CharacterClass charBefore = GetCharacterClass(textSource.GetCharAt(nextPos - 1)); CharacterClass charAfter = GetCharacterClass(textSource.GetCharAt(nextPos)); if (charBefore == charAfter) { if (charBefore == CharacterClass.Other && (mode == CaretPositioningMode.WordBorderOrSymbol || mode == CaretPositioningMode.WordStartOrSymbol)) { // With the "OrSymbol" modes, there's a word border and start between any two unknown characters return(nextPos); } } else { // this looks like a possible border // if we're looking for word starts, check that this is a word start (and not a word end) // if we're just checking for word borders, accept unconditionally if (!((mode == CaretPositioningMode.WordStart || mode == CaretPositioningMode.WordStartOrSymbol) && (charAfter == CharacterClass.Whitespace || charAfter == CharacterClass.LineTerminator))) { return(nextPos); } } } // we'll have to continue searching... offset = nextPos; } }
bool System.Windows.Documents.ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction) { return default(bool); }
// Token: 0x06002EBC RID: 11964 RVA: 0x000D3198 File Offset: 0x000D1398 ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity) { return(((ITextPointer)this).CreatePointer(0, gravity)); }
// Token: 0x06002FFD RID: 12285 internal abstract bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction);
// Token: 0x06002EBF RID: 11967 RVA: 0x000C7D89 File Offset: 0x000C5F89 ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection) { return(TextPointerBase.GetFrozenPointer(this, logicalDirection)); }
// Token: 0x06002EC4 RID: 11972 RVA: 0x000D3294 File Offset: 0x000D1494 void ITextPointer.SetLogicalDirection(LogicalDirection direction) { this.LogicalDirection = direction; }
// Token: 0x06002EC5 RID: 11973 RVA: 0x000D329D File Offset: 0x000D149D bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction) { ValidationHelper.VerifyDirection(direction, "direction"); return(this._flowPosition.Move(direction)); }
/// <summary> /// Returns the closest neighboring TextPointer in an indicated /// direction where a property value calculated from an embedded /// object, scoping text element, or scoping highlight could /// change. /// </summary> /// <param name="textPosition"> /// Position to query. /// </param> /// <param name="direction"> /// Direction of content to query. /// </param> /// <returns> /// If the following symbol is TextPointerContext.EmbeddedElement, /// TextPointerContext.ElementBegin, or TextPointerContext.ElementEnd, returns /// a TextPointer exactly one symbol distant. /// /// If the following symbol is TextPointerContext.Text, the distance /// of the returned TextPointer is the minimum of the value returned /// by textPosition.GetTextLength and the distance to any highlight /// start or end edge. /// /// If the following symbol is TextPointerContext.None, returns null. /// </returns> internal virtual StaticTextPointer GetNextPropertyChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer changePosition; StaticTextPointer characterRunEndPosition; switch (textPosition.GetPointerContext(direction)) { case TextPointerContext.None: changePosition = StaticTextPointer.Null; break; case TextPointerContext.Text: changePosition = GetNextHighlightChangePosition(textPosition, direction); characterRunEndPosition = textPosition.GetNextContextPosition(LogicalDirection.Forward); if (changePosition.IsNull || characterRunEndPosition.CompareTo(changePosition) < 0) { changePosition = characterRunEndPosition; } break; case TextPointerContext.EmbeddedElement: case TextPointerContext.ElementStart: case TextPointerContext.ElementEnd: default: changePosition = textPosition.CreatePointer(+1); break; } return(changePosition); }
public TextPointer GetNextInsertionPosition(LogicalDirection direction) { return default(TextPointer); }
// Returns the TextPointerContext of the node. internal override TextPointerContext GetPointerContext(LogicalDirection direction) { return(TextPointerContext.EmbeddedElement); }
// Token: 0x060039BC RID: 14780 RVA: 0x00106178 File Offset: 0x00104378 private static int SetFindTextAndFindTextPositionMap(ITextPointer startPosition, ITextPointer endPosition, ITextPointer navigator, LogicalDirection direction, bool matchLast, char[] findText, int[] findTextPositionMap) { Invariant.Assert(startPosition.CompareTo(navigator) <= 0); Invariant.Assert(endPosition.CompareTo(navigator) >= 0); int num = 0; int num2 = 0; if (matchLast && num2 == 0) { findTextPositionMap[findTextPositionMap.Length - 1] = 0; } while ((matchLast ? startPosition.CompareTo(navigator) : navigator.CompareTo(endPosition)) < 0) { switch (navigator.GetPointerContext(direction)) { case TextPointerContext.None: case TextPointerContext.ElementStart: case TextPointerContext.ElementEnd: if (TextFindEngine.IsAdjacentToFormatElement(navigator, direction)) { num++; } else if (!matchLast) { findText[num2] = '\n'; findTextPositionMap[num2] = num2 + num; num2++; } else { num2++; findText[findText.Length - num2] = '\n'; findTextPositionMap[findText.Length - num2] = num2 + num; } navigator.MoveToNextContextPosition(direction); break; case TextPointerContext.Text: { int num3 = navigator.GetTextRunLength(direction); num3 = Math.Min(num3, findText.Length - num2); if (!matchLast) { num3 = Math.Min(num3, navigator.GetOffsetToPosition(endPosition)); navigator.GetTextInRun(direction, findText, num2, num3); for (int i = num2; i < num2 + num3; i++) { findTextPositionMap[i] = i + num; } } else { num3 = Math.Min(num3, startPosition.GetOffsetToPosition(navigator)); navigator.GetTextInRun(direction, findText, findText.Length - num2 - num3, num3); int num4 = findText.Length - num2 - 1; for (int j = num2; j < num2 + num3; j++) { findTextPositionMap[num4--] = j + num + 1; } } navigator.MoveByOffset(matchLast ? (-num3) : num3); num2 += num3; break; } case TextPointerContext.EmbeddedElement: if (!matchLast) { findText[num2] = ''; findTextPositionMap[num2] = num2 + num; num2++; } else { num2++; findText[findText.Length - num2] = ''; findTextPositionMap[findText.Length - num2] = num2 + num; } navigator.MoveToNextContextPosition(direction); break; } if (num2 >= findText.Length) { break; } } if (!matchLast) { if (num2 > 0) { findTextPositionMap[num2] = findTextPositionMap[num2 - 1] + 1; } else { findTextPositionMap[0] = 0; } } return(num2); }
/// <summary> /// <see cref="ITextView.GetNextCaretUnitPosition"/> /// </summary> internal abstract ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction);
// Token: 0x06002EAF RID: 11951 RVA: 0x000D2F5B File Offset: 0x000D115B TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction) { ValidationHelper.VerifyDirection(direction, "direction"); return(this._flowPosition.GetPointerContext(direction)); }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; AttributeRange attributeRange; int i; transitionPosition = StaticTextPointer.Null; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } } } } return(transitionPosition); }
// Token: 0x06002EB1 RID: 11953 RVA: 0x000C7CFE File Offset: 0x000C5EFE string ITextPointer.GetTextInRun(LogicalDirection direction) { return(TextPointerBase.GetTextInRun(this, direction)); }
ITextPointer System.Windows.Documents.ITextPointer.GetNextInsertionPosition(LogicalDirection direction) { return default(ITextPointer); }
// Token: 0x06002EAA RID: 11946 RVA: 0x000D2ED9 File Offset: 0x000D10D9 internal FixedTextPointer(bool mutable, LogicalDirection gravity, FlowPosition flow) { this._isFrozen = !mutable; this._gravity = gravity; this._flowPosition = flow; }
int System.Windows.Documents.ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count) { return default(int); }
// Token: 0x06002B9D RID: 11165 RVA: 0x0000C238 File Offset: 0x0000A438 internal override object GetHighlightValue(StaticTextPointer staticTextPointer, LogicalDirection direction) { return(null); }
int System.Windows.Documents.ITextPointer.GetTextRunLength(LogicalDirection direction) { return default(int); }
// Token: 0x06002B9E RID: 11166 RVA: 0x000C7237 File Offset: 0x000C5437 internal override bool IsContentHighlighted(StaticTextPointer staticTextPointer, LogicalDirection direction) { return(this._docSeqContainer.Highlights.IsContentHighlighted(staticTextPointer, direction)); }
void System.Windows.Documents.ITextPointer.SetLogicalDirection(LogicalDirection direction) { }
// Token: 0x06002B9F RID: 11167 RVA: 0x000C724B File Offset: 0x000C544B internal override StaticTextPointer GetNextChangePosition(StaticTextPointer staticTextPointer, LogicalDirection direction) { return(this._docSeqContainer.Highlights.GetNextHighlightChangePosition(staticTextPointer, direction)); }
public System.Windows.Rect GetCharacterRect(LogicalDirection direction) { return default(System.Windows.Rect); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="direction"></param> /// <returns></returns> internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction) { Debug.Assert(false); return(null); }
// Token: 0x06002ECA RID: 11978 RVA: 0x000C7FCC File Offset: 0x000C61CC Rect ITextPointer.GetCharacterRect(LogicalDirection direction) { return(TextPointerBase.GetCharacterRect(this, direction)); }
// Token: 0x06002ECC RID: 11980 RVA: 0x000C7FDE File Offset: 0x000C61DE bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction) { return(TextPointerBase.MoveToNextInsertionPosition(this, direction)); }