MS\Internal\Documents\TextBoxLine.cs (8)
74switch (position.GetPointerContext(LogicalDirection.Forward))
112ITextPointer position = _owner.Host.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);
117int runLength = Math.Min(128, position.GetTextRunLength(LogicalDirection.Backward));
119position.GetTextInRun(LogicalDirection.Backward, text, 0, runLength);
424StaticTextPointer endOfRunPosition = _owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);
436TextDecorationCollection highlightDecorations = highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;
454&& highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue)
483int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);
MS\Internal\Documents\TextBoxView.cs (53)
631if (offset > 0 && position.LogicalDirection == LogicalDirection.Backward)
655if (position.LogicalDirection == LogicalDirection.Forward || position.Offset == 0)
662if (position.LogicalDirection == LogicalDirection.Backward && position.Offset > 0)
703firstLineIndex = Math.Max(firstLineIndex, GetLineIndexFromOffset(startOffset, LogicalDirection.Forward));
704lastLineIndex = Math.Min(lastLineIndex, GetLineIndexFromOffset(endOffset, LogicalDirection.Backward));
743ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].EndOffset, LogicalDirection.Backward);
744if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
783nextLinePosition = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex + linesMoved].Offset, LogicalDirection.Forward);
822if (position.LogicalDirection == LogicalDirection.Forward)
827else if (position.LogicalDirection == LogicalDirection.Backward)
852ITextPointer ITextView.GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
858if (position.Offset == 0 && direction == LogicalDirection.Backward)
860return position.GetFrozenPointer(LogicalDirection.Forward);
862else if (position.Offset == _host.TextContainer.SymbolCount && direction == LogicalDirection.Forward)
864return position.GetFrozenPointer(LogicalDirection.Backward);
874if (direction == LogicalDirection.Forward)
887LogicalDirection logicalDirection;
889direction == LogicalDirection.Forward)
895logicalDirection = LogicalDirection.Backward;
899logicalDirection = LogicalDirection.Forward;
903direction == LogicalDirection.Backward)
909logicalDirection = LogicalDirection.Forward;
913logicalDirection = LogicalDirection.Backward;
918logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
937return position.GetFrozenPointer(LogicalDirection.Forward);
940int lineIndex = GetLineIndexFromPosition(position, LogicalDirection.Backward);
950LogicalDirection logicalDirection;
957logicalDirection = LogicalDirection.Forward;
961logicalDirection = LogicalDirection.Backward;
966logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
984ITextPointer start = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].Offset, LogicalDirection.Forward);
985ITextPointer end = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].Offset + _lineMetrics[lineIndex].ContentLength, LogicalDirection.Forward);
1307ITextPointer start = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[0].Offset, LogicalDirection.Backward);
1308ITextPointer end = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[_lineMetrics.Count - 1].EndOffset, LogicalDirection.Forward);
1702private int GetLineIndexFromPosition(ITextPointer position, LogicalDirection direction)
1708private int GetLineIndexFromOffset(int offset, LogicalDirection direction)
1710if (offset > 0 && direction == LogicalDirection.Backward)
1756LogicalDirection logicalDirection;
1762logicalDirection = (charIndex.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
1937int firstLineIndex = GetLineIndexFromOffset(range.StartIndex, LogicalDirection.Forward);
1939int lastLineIndex = GetLineIndexFromOffset(endOffset, LogicalDirection.Backward);
2059ITextPointer position = _host.TextContainer.CreatePointerAtOffset(unclippedStartOffset, LogicalDirection.Backward);
2060if (TextPointerBase.IsNextToPlainLineBreak(position, LogicalDirection.Backward))
2104ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(endOffset, LogicalDirection.Backward);
2106if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
2155ITextPointer position = _host.TextContainer.CreatePointerAtOffset(unclippedStartOffset, LogicalDirection.Backward);
2156if (TextPointerBase.IsNextToPlainLineBreak(position, LogicalDirection.Backward))
2183ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(endOffset, LogicalDirection.Backward);
2185if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
2386int lineIndex = GetLineIndexFromOffset(range.StartIndex, LogicalDirection.Forward);
MS\Internal\Documents\TextContainerHelper.cs (23)
92_textContainer.CreatePointerAtOffset(_cpFirst, LogicalDirection.Forward),
93_textContainer.CreatePointerAtOffset(_cpLast, LogicalDirection.Backward),
102_textContainer.CreatePointerAtOffset(_ranges[i * 2], LogicalDirection.Forward),
103_textContainer.CreatePointerAtOffset(_ranges[i * 2 + 1], LogicalDirection.Backward),
121if (cpPos == _cpFirst && position.LogicalDirection == LogicalDirection.Backward ||
122cpPos == _cpLast && position.LogicalDirection == LogicalDirection.Forward)
138if (cpPos == _ranges[i * 2] && position.LogicalDirection == LogicalDirection.Backward ||
139cpPos == _ranges[i * 2 + 1] && position.LogicalDirection == LogicalDirection.Forward)
157startPosition = _textContainer.CreatePointerAtOffset(IsSimple ? _cpFirst : _ranges[0], LogicalDirection.Forward);
169endPosition = _textContainer.CreatePointerAtOffset(IsSimple ? _cpLast : _ranges[(_size - 1) * 2 + 1], LogicalDirection.Backward);
321if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
324element = start.GetAdjacentElement(LogicalDirection.Forward);
336start.MoveToNextContextPosition(LogicalDirection.Forward);
342else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement)
345element = start.GetAdjacentElement(LogicalDirection.Forward);
378if (!start.MoveToNextContextPosition(LogicalDirection.Forward))
406object element = position.GetAdjacentElement(LogicalDirection.Forward);
444element = position.GetAdjacentElement(LogicalDirection.Forward);
448positionsStart.Insert(0, position.CreatePointer(LogicalDirection.Forward));
460element = position.GetAdjacentElement(LogicalDirection.Backward);
464positionsEnd.Insert(0, position.CreatePointer(LogicalDirection.Backward));
549textPointer = textContainer.CreatePointerAtOffset(0, LogicalDirection.Forward); // Start
584internal static ITextPointer GetTextPointerFromCP(ITextContainer textContainer, int cp, LogicalDirection direction)
MS\Internal\Documents\TextDocumentView.cs (29)
296internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
479if (position.LogicalDirection == LogicalDirection.Forward)
489if (segment.Start.LogicalDirection == LogicalDirection.Backward)
498if (position.LogicalDirection == LogicalDirection.Backward)
508if (segment.End.LogicalDirection == LogicalDirection.Forward)
521if (position.TextContainer.Start.CompareTo(position) == 0 && position.LogicalDirection == LogicalDirection.Backward)
525else if (position.TextContainer.End.CompareTo(position) == 0 && position.LogicalDirection == LogicalDirection.Forward)
764position = paragraph.StartPosition.CreatePointer(LogicalDirection.Forward);
768position = paragraph.EndPosition.CreatePointer(LogicalDirection.Backward);
867position = blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward);
871position = blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward);
881position = paragraph.StartPosition.CreatePointer(LogicalDirection.Forward);
885position = paragraph.EndPosition.CreatePointer(LogicalDirection.Backward);
1554private ITextPointer GetNextCaretUnitPosition(ReadOnlyCollection<ParagraphResult> paragraphs, ReadOnlyCollection<ParagraphResult> floatingElements, ITextPointer position, LogicalDirection direction)
1591private ITextPointer GetNextCaretUnitPosition(ParagraphResult paragraph, ITextPointer position, LogicalDirection direction)
1660private ITextPointer GetNextCaretUnitPosition(ReadOnlyCollection<ColumnResult> columns, ReadOnlyCollection<ParagraphResult> floatingElements, ITextPointer position, LogicalDirection direction)
2371lineRange = new TextSegment(blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward), blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward));
2499positionOut = lines[lineIndex].StartPosition.CreatePointer(LogicalDirection.Forward);
2519positionOut = lines[0].StartPosition.CreatePointer(LogicalDirection.Forward);
2531positionOut = lines[lines.Count - 1].StartPosition.CreatePointer(LogicalDirection.Forward);
2871positionOut = blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward);
2875positionOut = blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward);
2978positionOut = lines[lineIndex].StartPosition.CreatePointer(LogicalDirection.Forward);
2993positionOut = lines[0].StartPosition.CreatePointer(LogicalDirection.Forward);
3005positionOut = lines[lines.Count - 1].StartPosition.CreatePointer(LogicalDirection.Forward);
3253segmentEnd = _textContainer.Start.CreatePointer(backgroundFormatInfo.CPInterrupted, LogicalDirection.Backward);
3446if (textPointer.LogicalDirection == LogicalDirection.Forward && textPointer.CompareTo(textElement.ElementStart) == 0)
3451if (textPointer.LogicalDirection == LogicalDirection.Backward && textPointer.CompareTo(textElement.ElementEnd) == 0)
MS\Internal\PtsHost\TextParaClient.cs (56)
643RectFromDcpSimpleLines(0, 0, LogicalDirection.Forward, TextPointerContext.Text, ref textDetails.u.full, ref rect, ref vrBaseline);
648RectFromDcpCompositeLines(0, 0, LogicalDirection.Forward, TextPointerContext.Text, ref textDetails.u.full, ref rect, ref vrBaseline);
660internal ITextPointer GetTextPosition(int dcp, LogicalDirection direction)
679if (position.LogicalDirection == LogicalDirection.Backward && dcp > 0)
871internal ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
1091LogicalDirection logicalDirection = (charHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
1632LogicalDirection orientation,
1684if (orientation == LogicalDirection.Forward)
1697if (orientation == LogicalDirection.Backward && originalDcp > 0 && (context == TextPointerContext.Text || context == TextPointerContext.EmbeddedElement))
1720LogicalDirection orientation,
1781if (orientation == LogicalDirection.Forward)
1791if (orientation == LogicalDirection.Backward && originalDcp > 0 && (context == TextPointerContext.Text || context == TextPointerContext.EmbeddedElement))
2034ITextPointer position = Paragraph.StructuralCache.TextContainer.CreatePointerAtOffset(Paragraph.ParagraphStartCharacterPosition + dcp, LogicalDirection.Forward);
2036return (TextPointerBase.IsNextToAnyBreak(position, LogicalDirection.Backward));
2398if (position.LogicalDirection == LogicalDirection.Backward)
2423else if (position.LogicalDirection == LogicalDirection.Forward)
2501if (position.LogicalDirection == LogicalDirection.Backward)
2547else if (position.LogicalDirection == LogicalDirection.Forward)
2583LogicalDirection direction,
2608if (dcp == lineDesc.dcpFirst && direction == LogicalDirection.Backward)
2623else if (dcp >= lineDesc.dcpLim - 1 && direction == LogicalDirection.Forward)
2652if (direction == LogicalDirection.Forward)
2661LogicalDirection logicalDirection;
2662if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == lineDesc.dcpLim) && direction == LogicalDirection.Forward)
2668logicalDirection = LogicalDirection.Backward;
2672logicalDirection = LogicalDirection.Forward;
2675else if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == lineDesc.dcpFirst) && direction == LogicalDirection.Backward)
2681logicalDirection = LogicalDirection.Forward;
2685logicalDirection = LogicalDirection.Backward;
2690logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
2708LogicalDirection direction,
2742if (dcp == element.dcpFirst && direction == LogicalDirection.Backward)
2782else if (dcp >= element.dcpLim - 1 && direction == LogicalDirection.Forward)
2815if (direction == LogicalDirection.Forward)
2824LogicalDirection logicalDirection;
2825if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == element.dcpLim) && direction == LogicalDirection.Forward)
2831logicalDirection = LogicalDirection.Backward;
2836logicalDirection = LogicalDirection.Forward;
2839else if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == element.dcpFirst) && direction == LogicalDirection.Backward)
2845logicalDirection = LogicalDirection.Forward;
2850logicalDirection = LogicalDirection.Backward;
2855logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
2931LogicalDirection logicalDirection;
2938logicalDirection = LogicalDirection.Forward;
2942logicalDirection = LogicalDirection.Backward;
2947logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
3057LogicalDirection logicalDirection;
3064logicalDirection = LogicalDirection.Forward;
3068logicalDirection = LogicalDirection.Backward;
3073logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
MS\Internal\Text\ComplexLine.cs (17)
42switch (position.GetPointerContext(LogicalDirection.Forward))
89ITextPointer position = _owner.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);
92while (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text &&
100string precedingTextString = position.GetTextInRun(LogicalDirection.Backward);
283position = new TextPointer(_owner.ContentStart, CalcPositionOffset(charHit), LogicalDirection.Forward);
290type = position.GetPointerContext(LogicalDirection.Forward);
295type = position.GetPointerContext(LogicalDirection.Backward);
306element = position.GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
334Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text, "TextPointer does not point to characters.");
353endOfRunPosition = _owner.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);
368int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);
381Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");
385TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
472Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");
476TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
522Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");
525DependencyObject element = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
System\Windows\Controls\PasswordTextContainer.cs (20)
212ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
218ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
223ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
230return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
233TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
243int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
248object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
263StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
514return new PasswordTextPointer(this, LogicalDirection.Backward, 0);
528return new PasswordTextPointer(this, LogicalDirection.Forward, this.SymbolCount);
670textPosition = new PasswordTextPointer(this, LogicalDirection.Forward, offset);
707index = FindIndex(offset, LogicalDirection.Forward);
740if (position.LogicalDirection == LogicalDirection.Backward)
804private int FindIndex(int offset, LogicalDirection gravity)
818(position.LogicalDirection == gravity || gravity == LogicalDirection.Backward))
839LogicalDirection lastLogicalDirection;
842lastLogicalDirection = LogicalDirection.Backward;
854position.LogicalDirection == LogicalDirection.Backward &&
859Invariant.Assert(lastLogicalDirection != LogicalDirection.Forward);
910Debug.Write($"({position.DebugId}) {position.Offset}/{((position.LogicalDirection == LogicalDirection.Forward) ? "f " : "b ")}");
System\Windows\Controls\TextBox.cs (24)
161TextPointer newStart = this.TextContainer.CreatePointerAtOffset(start, LogicalDirection.Forward);
165newStart = newStart.GetInsertionPosition(LogicalDirection.Forward);
173TextPointer newEnd = new TextPointer(newStart, length, LogicalDirection.Forward);
176newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
216return (textPointer.LogicalDirection == LogicalDirection.Backward) ? offset - 1 : offset;
264TextPointer position = this.TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Forward);
439TextPointer textPointer = TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Backward);
440textPointer = textPointer.GetInsertionPosition(LogicalDirection.Backward);
445textPointer = textPointer.GetNextInsertionPosition(LogicalDirection.Forward);
449textPointer = textPointer.GetPositionAtOffset(0, LogicalDirection.Backward);
454textPointer = textPointer.GetPositionAtOffset(0, LogicalDirection.Forward);
479TextPointer position = this.TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Forward);
480SpellingError spellingError = this.TextEditor.GetSpellingErrorAtPosition(position, LogicalDirection.Forward);
484position = this.TextContainer.CreatePointerAtOffset(charIndex + 1, LogicalDirection.Forward);
485spellingError = this.TextEditor.GetSpellingErrorAtPosition(position, LogicalDirection.Backward);
545public int GetNextSpellingErrorCharacterIndex(int charIndex, LogicalDirection direction)
811TextPointer newEnd = new TextPointer(TextSelectionInternal.Start, value, LogicalDirection.Forward);
814newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
855TextPointer newStart = TextContainer.CreatePointerAtOffset(value, LogicalDirection.Forward);
859newStart = newStart.GetInsertionPosition(LogicalDirection.Forward);
867TextPointer newEnd = new TextPointer(newStart, selectionLength, LogicalDirection.Forward);
870newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
1477if (TextPointerBase.IsNextToPlainLineBreak(textPointer, LogicalDirection.Forward))
1479textPointer.MoveToNextInsertionPosition(LogicalDirection.Forward);
System\Windows\Controls\TextRangeAdaptor.cs (77)
480internal static bool MoveToInsertionPosition(ITextPointer position, LogicalDirection direction)
528TextPointerBase.MoveToNextInsertionPosition(_start, LogicalDirection.Backward);
532TextPointerBase.MoveToNextInsertionPosition(_end, LogicalDirection.Forward);
539MoveToNextWordBoundary(_start, LogicalDirection.Backward);
543MoveToNextWordBoundary(_end, LogicalDirection.Forward);
553TextPointerContext forwardContext = _start.GetPointerContext(LogicalDirection.Forward);
556TextPointerContext backwardContext = _start.GetPointerContext(LogicalDirection.Backward);
564_start.MoveToNextContextPosition(LogicalDirection.Backward);
570TextPointerContext backwardContext = _end.GetPointerContext(LogicalDirection.Backward);
573TextPointerContext forwardContext = _end.GetPointerContext(LogicalDirection.Forward);
581_end.MoveToNextContextPosition(LogicalDirection.Forward);
587_start.SetLogicalDirection(LogicalDirection.Forward);
588_end.SetLogicalDirection(LogicalDirection.Forward);
725private bool MoveToUnitBoundary(ITextPointer position, bool isStart, LogicalDirection direction, TextUnit unit)
763if (moved && direction == LogicalDirection.Forward)
767TextPointerContext context = position.GetPointerContext(LogicalDirection.Forward);
772position.MoveToNextContextPosition(LogicalDirection.Forward);
791if (direction == LogicalDirection.Forward)
809nextLineStart = GetInsertionPosition(nextLineStart, LogicalDirection.Forward);
814position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
836previousLineEnd = GetInsertionPosition(previousLineEnd, LogicalDirection.Backward);
841position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
854if (direction == LogicalDirection.Forward)
861if (nextParagraphStart.MoveToNextInsertionPosition(LogicalDirection.Forward))
871position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
882if (previousParagraphEnd.MoveToNextInsertionPosition(LogicalDirection.Backward))
892position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
921if (direction == LogicalDirection.Forward)
925if (position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.ElementEnd)
931Invariant.Assert(position.MoveToNextContextPosition(LogicalDirection.Forward));
933MoveToInsertionPosition(position, LogicalDirection.Forward);
939if (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart)
945Invariant.Assert(position.MoveToNextContextPosition(LogicalDirection.Backward));
947MoveToInsertionPosition(position, LogicalDirection.Backward);
954if (direction == LogicalDirection.Forward)
956if (position.CompareTo(GetInsertionPosition(position.TextContainer.End, LogicalDirection.Backward)) != 0)
964if (position.CompareTo(GetInsertionPosition(position.TextContainer.Start, LogicalDirection.Forward)) != 0)
994LogicalDirection direction = (count > 0) ? LogicalDirection.Forward : LogicalDirection.Backward;
1051if (direction == LogicalDirection.Backward)
1053while (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text)
1055if (!position.MoveToNextContextPosition(LogicalDirection.Backward))
1075position.SetLogicalDirection(LogicalDirection.Forward);
1092position.MoveToNextInsertionPosition(LogicalDirection.Backward);
1097MoveToInsertionPosition(position, LogicalDirection.Forward);
1112position.MoveToPosition(direction == LogicalDirection.Forward ? paragraphRange.End : paragraphRange.Start);
1143if (direction == LogicalDirection.Backward)
1146MoveToInsertionPosition(position, LogicalDirection.Backward);
1151MoveToInsertionPosition(position, LogicalDirection.Forward);
1163if (direction == LogicalDirection.Forward)
1196return (direction == LogicalDirection.Forward) ? moved : -moved;
1211while (IsElementBoundary(start.GetPointerContext(LogicalDirection.Forward)))
1213if (!start.MoveToNextContextPosition(LogicalDirection.Forward) || start.CompareTo(end) >= 0)
1218while (IsElementBoundary(end.GetPointerContext(LogicalDirection.Backward)))
1220if (!end.MoveToNextContextPosition(LogicalDirection.Backward) || start.CompareTo(end) >= 0)
1235if (!start.MoveToNextContextPosition(LogicalDirection.Forward) || start.CompareTo(end) > 0)
1446return TextPointerBase.IsAtWordBoundary(position, LogicalDirection.Forward);
1454private static bool MoveToNextWordBoundary(ITextPointer position, LogicalDirection direction)
1480position.SetLogicalDirection(LogicalDirection.Forward);
1505private ITextPointer GetInsertionPosition(ITextPointer position, LogicalDirection direction)
1638_end.MoveToNextInsertionPosition(LogicalDirection.Forward);
1673ITextPointer position = _end.CreatePointer(LogicalDirection.Backward);
1684attrEnd = position.CreatePointer(LogicalDirection.Backward);
1691attrStart = position.CreatePointer(LogicalDirection.Forward);
1695if (!position.MoveToNextContextPosition(LogicalDirection.Backward))
1704ITextPointer position = _start.CreatePointer(LogicalDirection.Forward);
1715attrStart = position.CreatePointer(LogicalDirection.Forward);
1722attrEnd = position.CreatePointer(LogicalDirection.Backward);
1726if (!position.MoveToNextContextPosition(LogicalDirection.Forward))
1909_end.MoveToNextInsertionPosition(LogicalDirection.Forward);
1947if (MoveToUnitBoundary(position, start, count < 0 ? LogicalDirection.Backward : LogicalDirection.Forward, unit))
System\Windows\Documents\DocumentSequenceTextContainer.cs (25)
95ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
101ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
106ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
113return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
116TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
126int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
131object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
146StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
660if (!highlights.IsContentHighlighted(highlightTransitionPosition, LogicalDirection.Forward))
662highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
670selected = highlights.GetHighlightValue(highlightTransitionPosition, LogicalDirection.Forward, typeof(TextSelection));
674highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
681if (highlightRangeStart.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text)
688TextPointerBase.GetTextWithLimit(highlightRangeStart.CreateDynamicTextPointer(LogicalDirection.Forward), LogicalDirection.Forward, sb, 0, 256, highlightTransitionPosition.CreateDynamicTextPointer(LogicalDirection.Forward));
863internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction, Type highlightLayerOwnerType)
884internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction)
906internal override StaticTextPointer GetNextHighlightChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
949internal override StaticTextPointer GetNextPropertyChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
974private bool EnsureParentPosition(StaticTextPointer textPosition, LogicalDirection direction, out StaticTextPointer parentPosition)
988ITextPointer dynamicTextPointer = textPosition.CreateDynamicTextPointer(LogicalDirection.Forward);
1006private StaticTextPointer GetStaticPositionInChildContainer(StaticTextPointer textPosition, LogicalDirection direction, StaticTextPointer originalPosition)
1012DocumentSequenceTextPointer parentChangePosition = textPosition.CreateDynamicTextPointer(LogicalDirection.Forward) as DocumentSequenceTextPointer;
1025childTp = direction == LogicalDirection.Forward ?
System\Windows\Documents\DocumentSequenceTextPointer.cs (52)
47void ITextPointer.SetLogicalDirection(LogicalDirection direction)
80TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
89int ITextPointer.GetTextRunLength(LogicalDirection direction)
95string ITextPointer.GetTextInRun(LogicalDirection direction)
101/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
104int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
113object ITextPointer.GetAdjacentElement(LogicalDirection direction)
122Type ITextPointer.GetElementType(LogicalDirection direction)
190/// <see cref="ITextPointer.CreatePointer(LogicalDirection)"/>
192ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
198/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
200ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
214ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
243ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
258ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
269ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
278ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
359if (!isAtCaretUnitBoundary && ((ITextPointer)this).LogicalDirection == LogicalDirection.Backward)
367ITextPointer positionForwardGravity = ((ITextPointer)this).CreatePointer(LogicalDirection.Forward);
377LogicalDirection ITextPointer.LogicalDirection
442bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
475LogicalDirection gravity = this.ChildPointer.LogicalDirection;
505Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
510bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
515bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
630public static TextPointerContext GetPointerContext(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
641public static int GetTextRunLength(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
649/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
652public static int GetTextInRun(DocumentSequenceTextPointer thisTp, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
681public static object GetAdjacentElement(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
692public static Type GetElementType(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
765public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, LogicalDirection gravity)
771/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
773public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, int distance, LogicalDirection gravity)
818internal static bool iScan(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
823moved = xGapAwareScan(thisTp, (direction == LogicalDirection.Forward ? 1 : -1));
863private static DocumentSequenceTextPointer xGetClingDSTP(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
875if (direction == LogicalDirection.Forward)
888Debug.Assert(direction == LogicalDirection.Backward);
913private static TextPointerContext xGapAwareGetSymbolType(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
920private static object xGapAwareGetEmbeddedElement(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
964if (tp1.ChildPointer.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None ||
965tp2.ChildPointer.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.None)
974if (block.ChildContainer.Start.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None)
1029LogicalDirection scanDir = (distance > 0 ? LogicalDirection.Forward : LogicalDirection.Backward);
1057if (scanDir == LogicalDirection.Backward)
1065if (!((cdb.IsHead && scanDir == LogicalDirection.Backward)
1066|| (cdb.IsTail && scanDir == LogicalDirection.Forward)
1070cdb = (scanDir == LogicalDirection.Forward ? cdb.NextBlock : cdb.PreviousBlock);
1071childTn = (scanDir == LogicalDirection.Forward ?
System\Windows\Documents\FixedDocument.cs (11)
498fixedTextPointer = new FixedTextPointer(true, LogicalDirection.Forward, flowPosition);
1071if (!highlights.IsContentHighlighted(highlightTransitionPosition, LogicalDirection.Forward))
1073highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1084selected = highlights.GetHighlightValue(highlightTransitionPosition, LogicalDirection.Forward, typeof(TextSelection));
1102highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1105while (highlights.GetHighlightValue(highlightTransitionPosition, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue);
1114LogicalDirection.Forward, typeof(HighlightComponent)) as AnnotationHighlightLayer.HighlightSegment;
1118highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1128this.FixedContainer.GetMultiHighlights((FixedTextPointer)highlightRangeStart.CreateDynamicTextPointer(LogicalDirection.Forward),
1129(FixedTextPointer)highlightTransitionPosition.CreateDynamicTextPointer(LogicalDirection.Forward),
1434return new FixedTextPointer(true, LogicalDirection.Forward, flowPosition);
System\Windows\Documents\FixedFindEngine.cs (12)
151end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber)));
152start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber)));
156start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber)));
157end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber)));
166end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber));
167start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber));
171start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber));
172end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber));
304new FixedTextPointer(false, LogicalDirection.Forward,pageStartFlowPosition));
310firstSearchPageStart = new FixedTextPointer(false, LogicalDirection.Forward, endAsFTP.FixedTextContainer.FixedTextBuilder.GetPageStartFlowPosition(pageNumber));
324new FixedTextPointer(false, LogicalDirection.Backward, pageEndFlowPosition));
330firstSearchPageEnd = new FixedTextPointer(false, LogicalDirection.Backward, startAsFTP.FixedTextContainer.FixedTextBuilder.GetPageEndFlowPosition(pageNumber));
System\Windows\Documents\FixedTextContainer.cs (12)
80ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
86ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
91ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
98return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
101TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
111int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
116object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
131StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
569_start = new FixedTextPointer(false, LogicalDirection.Backward, new FlowPosition(this, this.FixedTextBuilder.FixedFlowMap.FlowStartEdge, 1));
570_end = new FixedTextPointer(false, LogicalDirection.Forward, new FlowPosition(this, this.FixedTextBuilder.FixedFlowMap.FlowEndEdge, 0));
579FixedTextPointer eStart = new FixedTextPointer(false, LogicalDirection.Backward, pStart);
580FixedTextPointer eEnd = new FixedTextPointer(false, LogicalDirection.Forward, pEnd);
System\Windows\Documents\FixedTextPointer.cs (27)
31internal FixedTextPointer(bool mutable, LogicalDirection gravity, FlowPosition flow)
93TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
103int ITextPointer.GetTextRunLength(LogicalDirection direction)
114string ITextPointer.GetTextInRun(LogicalDirection direction)
120/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
123int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
143object ITextPointer.GetAdjacentElement(LogicalDirection direction)
158Type ITextPointer.GetElementType(LogicalDirection direction)
259/// <see cref="ITextPointer.CreatePointer(LogicalDirection)"/>
261ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
267/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
269ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
293ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
302ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
320ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
334ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
346ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
366void ITextPointer.SetLogicalDirection(LogicalDirection direction)
376bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
463Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
471bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
479bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
569if (!isAtCaretUnitBoundary && this.LogicalDirection == LogicalDirection.Backward)
577ITextPointer positionForwardGravity = ((ITextPointer)this).CreatePointer(LogicalDirection.Forward);
587LogicalDirection ITextPointer.LogicalDirection
662internal LogicalDirection LogicalDirection
695private LogicalDirection _gravity;
System\Windows\Documents\FixedTextView.cs (43)
75textPos = _CreateTextPointer(fixedp, LogicalDirection.Backward);
98pos = _CreateTextPointer(fixedp, LogicalDirection.Forward);
105pos = _CreateTextPointer(fixedp, LogicalDirection.Forward);
176if (position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None)
335LogicalDirection edge = position.LogicalDirection;
336LogicalDirection scanDir = LogicalDirection.Forward;
357scanDir = LogicalDirection.Backward;
371linesMoved = (scanDir == LogicalDirection.Forward) ? 1 : -1;
396if (scanDir == LogicalDirection.Backward)
502internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
518CharacterHit next = (direction == LogicalDirection.Forward) ?
524LogicalDirection edge = LogicalDirection.Forward;
527edge = LogicalDirection.Backward;
605ITextPointer begin = _CreateTextPointer(new FixedPosition(fixedNodes[0], 0), LogicalDirection.Forward);
606ITextPointer end = _CreateTextPointer(new FixedPosition(lastNode, lastIndex), LogicalDirection.Backward);
638(tp.CompareTo(this.Start) == 0 && (tp.LogicalDirection == LogicalDirection.Forward || this.IsContainerStart)) ||
639(tp.CompareTo(this.End) == 0 && (tp.LogicalDirection == LogicalDirection.Backward || this.IsContainerEnd))
733_start = new FixedTextPointer(false, LogicalDirection.Forward, flowStart);
746_end = new FixedTextPointer(false, LogicalDirection.Backward, flowEnd);
785private void _GlyphRunHitTest(Glyphs g, double xoffset, out int charIndex, out LogicalDirection edge)
788edge = LogicalDirection.Forward;
806edge = (hit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
849LogicalDirection dir;
863itp = ((ITextPointer)this.Start).CreatePointer(LogicalDirection.Forward);
864itp.MoveToInsertionPosition(LogicalDirection.Forward);
868itp = ((ITextPointer)this.End).CreatePointer(LogicalDirection.Backward);
869itp.MoveToInsertionPosition(LogicalDirection.Backward);
878private bool _GetNextLineGlyphs(ref FixedPosition fixedp, ref LogicalDirection edge, double suggestedX, LogicalDirection scanDir)
883FixedNode[] fixedNodes = Container.FixedTextBuilder.GetNextLine(fixedp.Node, (scanDir == LogicalDirection.Forward), ref count);
1076LogicalDirection textdir = ftp.LogicalDirection;
1090textdir = LogicalDirection.Forward;
1093textdir = LogicalDirection.Backward;
1130LogicalDirection dir = LogicalDirection.Forward;
1134dir = LogicalDirection.Backward;
1163private ITextPointer _CreateTextPointer(FixedPosition fixedPosition, LogicalDirection edge)
1188LogicalDirection edge;
1198LogicalDirection dir = textPointer.LogicalDirection;
1199int increment = (dir == LogicalDirection.Forward ? +1 : -1);
System\Windows\Documents\ImmComposition.cs (25)
625caretNavigator = _caretOffset > 0 ? _startComposition.CreatePointer(_caretOffset, LogicalDirection.Forward) : _endComposition;
632ITextPointer startPosition = startNavigator.CreatePointer(LogicalDirection.Forward);
633ITextPointer endPosition = endNavigator.CreatePointer(LogicalDirection.Backward);
634ITextPointer caretPosition = caretNavigator.CreatePointer(LogicalDirection.Forward);
754rectCaret = view.GetRectangleFromTextPosition(_editor.Selection.End.CreatePointer(LogicalDirection.Backward));
1124start = range.Start.CreatePointer(resultLength, LogicalDirection.Forward);
1128ITextPointer caretPosition = _caretOffset >= 0 ? start.CreatePointer(_caretOffset, LogicalDirection.Forward) : end;
1167ITextPointer startAttribute = _startComposition.CreatePointer(startOffset, LogicalDirection.Backward);
1168ITextPointer endAttribute = _startComposition.CreatePointer(i + 1, LogicalDirection.Forward);
1398switch (navigator.GetPointerContext(LogicalDirection.Backward))
1402int copied = navigator.GetTextInRun(LogicalDirection.Backward, buffer, 0, buffer.Length);
1416if (!navigator.GetElementType(LogicalDirection.Backward).IsSubclassOf(typeof(Inline)))
1420navigator.MoveToNextContextPosition(LogicalDirection.Backward);
1429navigator.MoveToNextContextPosition(LogicalDirection.Backward);
1450switch (navigator.GetPointerContext(LogicalDirection.Forward))
1454int copied = navigator.GetTextInRun(LogicalDirection.Forward, buffer, 0, buffer.Length);
1467if (!navigator.GetElementType(LogicalDirection.Forward).IsSubclassOf(typeof(Inline)))
1471navigator.MoveToNextContextPosition(LogicalDirection.Forward);
1479navigator.MoveToNextContextPosition(LogicalDirection.Forward);
1522ITextPointer start = range.Start.CreatePointer(LogicalDirection.Backward);
1527ITextPointer end = start.CreatePointer(LogicalDirection.Forward);
1549switch (position.GetPointerContext(LogicalDirection.Backward))
1565switch (position.GetPointerContext(LogicalDirection.Forward))
1652positionNext.MoveToNextInsertionPosition(LogicalDirection.Forward);
1656positionNext.MoveToNextInsertionPosition(LogicalDirection.Backward);
System\Windows\Documents\ITextContainer.cs (7)
37ITextPointer CreatePointerAtOffset(int offset, LogicalDirection direction);
42ITextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction);
44ITextPointer CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction);
48TextPointerContext GetPointerContext(StaticTextPointer pointer, LogicalDirection direction);
52int GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count);
54object GetAdjacentElement(StaticTextPointer position, LogicalDirection direction);
60StaticTextPointer GetNextContextPosition(StaticTextPointer position, LogicalDirection direction);
System\Windows\Documents\NullTextContainer.cs (10)
35_start = new NullTextPointer(this, LogicalDirection.Backward);
36_end = new NullTextPointer(this, LogicalDirection.Forward);
80ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
86ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
91ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
98return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
101TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
111int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
116object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
131StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
System\Windows\Documents\Speller.cs (46)
107internal SpellingError GetError(ITextPointer position, LogicalDirection direction, bool forceEvaluation)
141internal ITextPointer GetNextSpellingErrorPosition(ITextPointer position, LogicalDirection direction)
190ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out ITextPointer contentStart, out ITextPointer contextStart);
191ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out ITextPointer contentEnd, out ITextPointer contextEnd);
236if (_statusTable.GetError(pointer, LogicalDirection.Forward, out errorStart, out errorEnd))
246pointer = _statusTable.GetNextErrorTransition(pointer, LogicalDirection.Forward);
666end = GetNextLanguageTransition(start, LogicalDirection.Forward, language, end);
707wordBreakLeft = SearchForWordBreaks(caretPosition, LogicalDirection.Backward, language, 1, false /* stopOnError */);
708wordBreakRight = SearchForWordBreaks(caretPosition, LogicalDirection.Forward, language, 1, false /* stopOnError */);
723FindPositionInSegmentList(textMap, LogicalDirection.Backward, segments, out leftBreakOffset, out rightBreakOffset);
793ExpandToWordBreakAndContext(start, LogicalDirection.Backward, language, out contentStart, out contextStart);
794ExpandToWordBreakAndContext(end, LogicalDirection.Forward, language, out contentEnd, out contextEnd);
1085private void ExpandToWordBreakAndContext(ITextPointer position, LogicalDirection direction, XmlLanguage language,
1095LogicalDirection inwardDirection;
1121inwardDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
1127if (direction == LogicalDirection.Backward)
1162if (direction == LogicalDirection.Backward)
1179if (direction == LogicalDirection.Backward)
1206if (direction == LogicalDirection.Backward)
1235private int FindPositionInSegmentList(TextMap textMap, LogicalDirection direction, ArrayList segments,
1294if (direction == LogicalDirection.Backward)
1315private ITextPointer SearchForWordBreaks(ITextPointer position, LogicalDirection direction, XmlLanguage language, int minWordCount, bool stopOnError)
1333closestErrorPosition = nextErrorTransition.CreateDynamicTextPointer(LogicalDirection.Forward);
1341searchPosition.MoveByOffset(direction == LogicalDirection.Backward ? -ContextBlockSize : +ContextBlockSize);
1346if (direction == LogicalDirection.Backward && closestErrorPosition.CompareTo(searchPosition) > 0 ||
1347direction == LogicalDirection.Forward && closestErrorPosition.CompareTo(searchPosition) < 0)
1357if (direction == LogicalDirection.Backward && closestLanguageTransition.CompareTo(searchPosition) > 0 ||
1358direction == LogicalDirection.Forward && closestLanguageTransition.CompareTo(searchPosition) < 0)
1364if (direction == LogicalDirection.Backward)
1387private ITextPointer GetNextLanguageTransition(ITextPointer position, LogicalDirection direction, XmlLanguage language, ITextPointer haltPosition)
1391while ((direction == LogicalDirection.Forward && navigator.CompareTo(haltPosition) < 0) ||
1392(direction == LogicalDirection.Backward && navigator.CompareTo(haltPosition) > 0))
1401if ((direction == LogicalDirection.Forward && navigator.CompareTo(haltPosition) > 0) ||
1402(direction == LogicalDirection.Backward && navigator.CompareTo(haltPosition) < 0))
1464private void ScanPosition(ITextPointer position, LogicalDirection direction)
1469if (direction == LogicalDirection.Forward)
1658_basePosition = contextStart.GetFrozenPointer(LogicalDirection.Backward);
1685switch (position.GetPointerContext(LogicalDirection.Forward))
1688runCount = position.GetTextRunLength(LogicalDirection.Forward);
1692position.GetTextInRun(LogicalDirection.Forward, _text, _textLength, runCount);
1728position.MoveToNextContextPosition(LogicalDirection.Forward);
1736position.MoveToNextContextPosition(LogicalDirection.Forward);
1803context = pointer.GetPointerContext(LogicalDirection.Forward);
1806TextSchema.IsFormattingType(pointer.GetElementType(LogicalDirection.Forward)))
System\Windows\Documents\SpellerStatusTable.cs (20)
91for (index = FindIndex(searchStart.CreateStaticPointer(), LogicalDirection.Forward); index >= 0 && index < _runList.Count; index++)
127runIndex = FindIndex(start.CreateStaticPointer(), LogicalDirection.Forward);
163internal bool IsRunType(StaticTextPointer textPosition, LogicalDirection direction, RunType runType)
178internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction)
193else if (direction == LogicalDirection.Forward)
243internal bool GetError(StaticTextPointer textPosition, LogicalDirection direction,
263internal bool GetRun(StaticTextPointer position, LogicalDirection direction, out RunType runType, out StaticTextPointer end)
278end = (direction == LogicalDirection.Forward) ? GetRunEndPosition(index) : run.Position.CreateStaticPointer();
308private int GetErrorIndex(StaticTextPointer textPosition, LogicalDirection direction)
331private int FindIndex(StaticTextPointer position, LogicalDirection direction)
348if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 ||
349direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0)
354else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 ||
355direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0)
391startIndex = FindIndex(start.CreateStaticPointer(), LogicalDirection.Forward);
392endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);
427endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);
592index = FindIndex(position.CreateStaticPointer(), LogicalDirection.Backward);
751return GetRunEndPosition(index).CreateDynamicTextPointer(LogicalDirection.Forward);
799_position = position.GetFrozenPointer(LogicalDirection.Backward);
System\Windows\Documents\TextContainer.cs (36)
429ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
437internal TextPointer CreatePointerAtOffset(int offset, LogicalDirection direction)
446ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
460internal TextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
473ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
500TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
511else if (direction == LogicalDirection.Forward)
513edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Forward);
518edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Backward);
550int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
566object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
613StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
630edge = (direction == LogicalDirection.Backward) ? ElementEdge.AfterStart : ElementEdge.BeforeEnd;
636TextTreeTextNode nextTextNode = ((direction == LogicalDirection.Forward) ? node.GetNextNode() : node.GetPreviousNode()) as TextTreeTextNode;
641edge = (direction == LogicalDirection.Backward) ? ElementEdge.BeforeStart : ElementEdge.AfterEnd;
645else if (direction == LogicalDirection.Forward)
647edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Forward);
652edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Backward);
824LogicalDirection direction;
858originalPosition = this.HasListeners ? new TextPointer(position, LogicalDirection.Backward) : null;
870direction = LogicalDirection.Backward;
874direction = LogicalDirection.Forward;
883if ((direction == LogicalDirection.Backward && textNode.AfterEndReferenceCount) ||
884(direction == LogicalDirection.Forward && textNode.BeforeStartReferenceCount))
1044newFirstIMEVisibleNode = startPosition.GetAdjacentTextElementNodeSibling(LogicalDirection.Forward);
1266deletePosition = new TextPointer(startPosition, LogicalDirection.Forward);
1592if (!_rootNode.CaretUnitBoundaryCache && position.LogicalDirection == LogicalDirection.Backward)
1600TextPointer positionForwardGravity = position.GetPositionAtOffset(0, LogicalDirection.Forward);
1635startPosition = new TextPointer(this, _rootNode, ElementEdge.AfterStart, LogicalDirection.Backward);
1666endPosition = new TextPointer(this, _rootNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
2432node = startPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
2433stopNode = endPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
2788startPosition = new TextPointer(this, elementNode, ElementEdge.BeforeStart, LogicalDirection.Backward);
2793endPosition = new TextPointer(this, elementNode, ElementEdge.AfterEnd, LogicalDirection.Backward);
3417TextElement adjacentElement = startPosition.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
3420nextIMEVisibleNode = (TextTreeTextElementNode)endPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
System\windows\Documents\TextEditorSelection.cs (91)
113ITextPointer lineStart = position.CreatePointer(LogicalDirection.Forward);
115ITextPointer lineEnd = position.CreatePointer(LogicalDirection.Backward);
188LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
204LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
221LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
237LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
313ITextPointer nextPosition = lineEndPosition.GetNextInsertionPosition(LogicalDirection.Forward);
403ITextPointer previousPosition = lineStartPosition.GetNextInsertionPosition(LogicalDirection.Backward);
464if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Forward))
468This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
473This.Selection.SetCaretToPosition(paragraphRange.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
517This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
522if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Backward))
526This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
803ITextPointer caretPosition = lineRange.Start.GetFrozenPointer(LogicalDirection.Forward);
806This.Selection.SetCaretToPosition(caretPosition, LogicalDirection.Forward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
852LogicalDirection orientation = TextPointerBase.IsNextToPlainLineBreak(lineRange.End, LogicalDirection.Backward) ? LogicalDirection.Forward : LogicalDirection.Backward;
886This.Selection.SetCaretToPosition(This.TextContainer.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
915This.Selection.SetCaretToPosition(This.TextContainer.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
946LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
962LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
978LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
994LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
1012if (This.Selection.ExtendToNextTableRow(LogicalDirection.Forward))
1070ITextPointer nextPosition = lineEndPosition.GetNextInsertionPosition(LogicalDirection.Forward);
1122if (TextPointerBase.IsNextToAnyBreak(newMovingPosition, LogicalDirection.Forward) ||
1123newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null)
1132newMovingPosition = newMovingPosition.GetInsertionPosition(LogicalDirection.Forward);
1133newMovingPosition = newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward);
1142newMovingPosition = newMovingPosition.GetFrozenPointer(LogicalDirection.Backward);
1160if (newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null)
1184if (This.Selection.ExtendToNextTableRow(LogicalDirection.Backward))
1260ITextPointer previousPosition = lineStartPosition.GetNextInsertionPosition(LogicalDirection.Backward);
1321if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Forward))
1369if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Backward))
1603ExtendSelectionAndBringIntoView(lineRange.Start.CreatePointer(LogicalDirection.Forward), This);
1655if (TextPointerBase.IsNextToPlainLineBreak(destination, LogicalDirection.Forward) ||
1656TextPointerBase.IsNextToRichLineBreak(destination, LogicalDirection.Forward))
1665destination = destination.GetNextInsertionPosition(LogicalDirection.Forward);
1669else if (TextPointerBase.IsNextToParagraphBreak(destination, LogicalDirection.Forward) &&
1670TextPointerBase.IsNextToParagraphBreak(This.Selection.AnchorPosition, LogicalDirection.Backward))
1674ITextPointer newDestination = destination.GetNextInsertionPosition(LogicalDirection.Forward);
1688destination = destination.GetFrozenPointer(LogicalDirection.Backward);
2037private static void MoveToCharacterLogicalDirection(TextEditor textEditor, LogicalDirection direction, bool extend)
2057ITextPointer movingEnd = (direction == LogicalDirection.Forward ? textEditor.Selection.End : textEditor.Selection.Start);
2067LogicalDirection contentDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
2098private static void NavigateWordLogicalDirection(TextEditor textEditor, LogicalDirection direction)
2115if (direction == LogicalDirection.Forward)
2118if (!textEditor.Selection.IsEmpty && TextPointerBase.IsAtWordBoundary(textEditor.Selection.End, LogicalDirection.Forward))
2121textEditor.Selection.SetCaretToPosition(textEditor.Selection.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2128TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Forward);
2130textEditor.Selection.SetCaretToPosition(wordBoundary, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2138if (!textEditor.Selection.IsEmpty && TextPointerBase.IsAtWordBoundary(textEditor.Selection.Start, LogicalDirection.Forward))
2141textEditor.Selection.SetCaretToPosition(textEditor.Selection.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2148TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Backward);
2150textEditor.Selection.SetCaretToPosition(wordBoundary, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2173private static void ExtendWordLogicalDirection(TextEditor textEditor, LogicalDirection direction)
2194wordBoundary.SetLogicalDirection(direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward);
2306movingPosition.LogicalDirection == LogicalDirection.Backward &&
2308TextPointerBase.IsNextToAnyBreak(movingPosition, LogicalDirection.Backward))
2310movingPosition = movingPosition.GetNextInsertionPosition(LogicalDirection.Backward);
2314if (TextPointerBase.IsNextToPlainLineBreak(movingPosition, LogicalDirection.Backward))
2316movingPosition = movingPosition.GetFrozenPointer(LogicalDirection.Forward);
2333return This.Selection.IsEmpty ? This.Selection.Start : This.Selection.Start.GetFrozenPointer(LogicalDirection.Forward);
2396ITextPointer position = This.Selection.Start.GetNextInsertionPosition(LogicalDirection.Backward);
2399This.Selection.SetCaretToPosition(position, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2412ITextPointer cellEnd = position.GetNextInsertionPosition(LogicalDirection.Backward);
System\windows\Documents\TextEditorSpelling.cs (22)
36internal static SpellingError GetSpellingErrorAtPosition(TextEditor This, ITextPointer position, LogicalDirection direction)
59LogicalDirection direction = This.Selection.IsEmpty ? This.Selection.Start.LogicalDirection : LogicalDirection.Forward;
67direction = (direction == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward;
82direction = (direction == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward;
87direction = LogicalDirection.Forward;
91direction = LogicalDirection.Backward;
101internal static ITextPointer GetNextSpellingErrorPosition(TextEditor This, ITextPointer position, LogicalDirection direction)
148caretPosition = textStart.CreatePointer(+correctedText.Length, LogicalDirection.Forward);
184textStart = spellingError.Start.CreatePointer(LogicalDirection.Backward);
186textStart.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text)
188textStart.MoveToNextContextPosition(LogicalDirection.Forward);
192textEnd.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text)
194textEnd.MoveToNextContextPosition(LogicalDirection.Backward);
197if (textStart.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text ||
202Invariant.Assert(textEnd.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
253private static ITextPointer GetNextTextPosition(ITextPointer position, ITextPointer limit, LogicalDirection direction, out char character)
316position = GetNextTextPosition(position, limit, LogicalDirection.Forward, out character);
System\windows\Documents\TextEditorTyping.cs (36)
543ITextPointer deletePosition = position.GetNextInsertionPosition(LogicalDirection.Forward);
566This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Forward);
620ITextPointer deletePosition = position.GetNextInsertionPosition(LogicalDirection.Backward);
645position = position.GetFrozenPointer(LogicalDirection.Backward);
652position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text)
674This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Backward);
682else if (backspacePosition.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text)
691This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Backward);
723This.Selection.SetCaretToPosition(position, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/true);
739LogicalDirection directionOfDelete = position.CompareTo(deletePosition) < 0 ? LogicalDirection.Forward : LogicalDirection.Backward;
746if (directionOfDelete == LogicalDirection.Forward)
773if (directionOfDelete == LogicalDirection.Backward)
810position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
811position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
816while (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
823position = position.GetNextContextPosition(LogicalDirection.Backward);
824if (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
832position = position.GetNextContextPosition(LogicalDirection.Backward);
843if (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart)
849position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.ElementEnd)
857while (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
864if (!(navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
913TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Forward);
972TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Backward);
1081This.Selection.SetCaretToPosition(This.Selection.End, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1172This.Selection.SetCaretToPosition(range.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1344if (HandleTabInTables(This, LogicalDirection.Forward))
1376if (HandleTabInTables(This, LogicalDirection.Backward))
1397private static bool HandleTabInTables(TextEditor This, LogicalDirection direction)
1408This.Selection.SetCaretToPosition(This.Selection.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1421if (direction == LogicalDirection.Forward)
1458if (direction == LogicalDirection.Forward)
1556ITextPointer caretPosition = This.Selection.End.CreatePointer(LogicalDirection.Backward);
1559This.Selection.SetCaretToPosition(caretPosition, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
System\Windows\Documents\TextElement.cs (7)
288TextPointer contentStart = new TextPointer(tree, _textElementNode, ElementEdge.AfterStart, LogicalDirection.Backward);
291TextPointer contentEnd = new TextPointer(tree, _textElementNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
314elementStart = new TextPointer(tree, _textElementNode, ElementEdge.BeforeStart, LogicalDirection.Forward);
347contentStart = new TextPointer(tree, _textElementNode, ElementEdge.AfterStart, LogicalDirection.Backward);
380contentEnd = new TextPointer(tree, _textElementNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
421elementEnd = new TextPointer(tree, _textElementNode, ElementEdge.AfterEnd, LogicalDirection.Backward);
994beforeStart = new TextPointer(tree, _textElementNode, ElementEdge.BeforeStart, LogicalDirection.Forward);
System\Windows\Documents\TextPointer.cs (97)
271internal TextPointer(TextPointer position, LogicalDirection direction)
277internal TextPointer(TextPointer position, int offset, LogicalDirection direction)
283internal TextPointer(TextContainer textContainer, int offset, LogicalDirection direction)
301Initialize(tree, node, edge, LogicalDirection.Forward, tree.PositionGeneration, false, false, tree.LayoutGeneration);
305internal TextPointer(TextContainer tree, TextTreeNode node, ElementEdge edge, LogicalDirection direction)
317internal TextPointer CreatePointer(LogicalDirection gravity)
496/// is <see cref="System.Windows.Documents.LogicalDirection.Backward"/>, or if it is positioned
498/// <see cref="System.Windows.Documents.LogicalDirection.Forward"/>.</para>
539public TextPointerContext GetPointerContext(LogicalDirection direction)
547return (direction == LogicalDirection.Forward) ? GetPointerContextForward(_node, this.Edge) : GetPointerContextBackward(_node, this.Edge);
561public int GetTextRunLength(LogicalDirection direction)
582if (direction == LogicalDirection.Forward)
598textNode = ((direction == LogicalDirection.Forward) ? textNode.GetNextNode() : textNode.GetPreviousNode()) as TextTreeTextNode;
732public string GetTextInRun(LogicalDirection direction)
770public int GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
804public DependencyObject GetAdjacentElement(LogicalDirection direction)
897public TextPointer GetPositionAtOffset(int offset, LogicalDirection direction)
985public TextPointer GetNextContextPosition(LogicalDirection direction)
1058public TextPointer GetInsertionPosition(LogicalDirection direction)
1066return GetInsertionPosition(LogicalDirection.Forward);
1085/// "insertion position" in the <see cref="TextPointer.GetInsertionPosition(LogicalDirection)"/>
1125public TextPointer GetNextInsertionPosition(LogicalDirection direction)
1222position.SetLogicalDirection(LogicalDirection.Forward);
1243public Rect GetCharacterRect(LogicalDirection direction)
1325LogicalDirection direction = count < 0 ? LogicalDirection.Backward : LogicalDirection.Forward;
1530public LogicalDirection LogicalDirection
1610TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1614TextSchema.IsFormattingType(position.GetAdjacentElement(LogicalDirection.Backward).GetType()))
1616position.MoveToNextContextPosition(LogicalDirection.Backward);
1617backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1745internal static int GetTextInRun(TextContainer textContainer, int symbolOffset, TextTreeTextNode textNode, int nodeOffset, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
1777skipCount = (direction == LogicalDirection.Forward) ? nodeOffset : textNode.SymbolCount - nodeOffset;
1794textNode = ((direction == LogicalDirection.Forward) ? textNode.GetNextNode() : textNode.GetPreviousNode()) as TextTreeTextNode;
1798if (direction == LogicalDirection.Backward)
1811internal static DependencyObject GetAdjacentElement(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
1967internal bool MoveToNextContextPosition(LogicalDirection direction)
1980if (direction == LogicalDirection.Forward)
2027internal bool MoveToInsertionPosition(LogicalDirection direction)
2070internal bool MoveToNextInsertionPosition(LogicalDirection direction)
2163internal TextElement GetAdjacentElementFromOuterPosition(LogicalDirection direction)
2181internal void SetLogicalDirection(LogicalDirection direction)
2334internal TextPointer GetFrozenPointer(LogicalDirection logicalDirection)
2343void ITextPointer.SetLogicalDirection(LogicalDirection direction)
2383TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
2388int ITextPointer.GetTextRunLength(LogicalDirection direction)
2394string ITextPointer.GetTextInRun(LogicalDirection direction)
2399int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
2404object ITextPointer.GetAdjacentElement(LogicalDirection direction)
2409Type ITextPointer.GetElementType(LogicalDirection direction)
2446ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
2461ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
2472ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
2481ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
2575ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
2580ITextPointer ITextPointer.CreatePointer(int offset, LogicalDirection gravity)
2591ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
2597bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
2654Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
2659bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
2664bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
2674internal bool MoveToCaretPosition(LogicalDirection contentDirection)
2677LogicalDirection oppositeDirection;
2698oppositeDirection = (contentDirection == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward;
2709internal bool MoveToNextCaretPosition(LogicalDirection direction)
2810internal TextTreeTextNode GetAdjacentTextNodeSibling(LogicalDirection direction)
2817internal static TextTreeTextNode GetAdjacentTextNodeSibling(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
2824internal TextTreeTextElementNode GetAdjacentTextElementNodeSibling(LogicalDirection direction)
2831internal TextTreeTextElementNode GetAdjacentTextElementNode(LogicalDirection direction)
2838internal TextTreeNode GetAdjacentSiblingNode(LogicalDirection direction)
2845internal static TextTreeNode GetAdjacentSiblingNode(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
2849if (direction == LogicalDirection.Forward)
3005if (GetGravityInternal() == LogicalDirection.Forward)
3436symbolType = node.GetPointerContext(LogicalDirection.Forward);
3443symbolType = firstContainedNode.GetPointerContext(LogicalDirection.Forward);
3461symbolType = nextNode.GetPointerContext(LogicalDirection.Forward);
3493symbolType = previousNode.GetPointerContext(LogicalDirection.Backward);
3513symbolType = lastChildNode.GetPointerContext(LogicalDirection.Backward);
3522symbolType = node.GetPointerContext(LogicalDirection.Backward);
3673LogicalDirection ITextPointer.LogicalDirection
3888private void InitializeOffset(TextPointer position, int distance, LogicalDirection direction)
3925private void Initialize(TextContainer tree, TextTreeNode node, ElementEdge edge, LogicalDirection gravity, uint generation,
3985private static void RepositionForGravity(ref TextTreeNode node, ref ElementEdge edge, LogicalDirection gravity)
3996if (gravity == LogicalDirection.Backward)
4009if (gravity == LogicalDirection.Forward)
4022if (gravity == LogicalDirection.Backward)
4035if (gravity == LogicalDirection.Forward)
4053private LogicalDirection GetGravityInternal()
4055return (this.Edge == ElementEdge.BeforeStart || this.Edge == ElementEdge.BeforeEnd) ? LogicalDirection.Forward : LogicalDirection.Backward;
4068internal TextTreeNode GetAdjacentNode(LogicalDirection direction)
4073internal static TextTreeNode GetAdjacentNode(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
4117private TextElement GetElement(LogicalDirection direction)
4136if (GetGravityInternal() == LogicalDirection.Forward)
System\Windows\Documents\TextPointerBase.cs (111)
56internal static string GetTextInRun(ITextPointer position, LogicalDirection direction)
74internal static int GetTextWithLimit(ITextPointer thisPointer, LogicalDirection direction, char[] textBuffer, int startIndex, int count, ITextPointer limit)
83else if (direction == LogicalDirection.Forward && limit.CompareTo(thisPointer) <= 0)
88else if (direction == LogicalDirection.Backward && limit.CompareTo(thisPointer) >= 0)
100if (direction == LogicalDirection.Forward)
182Type forwardType = forwardPosition.GetElementType(LogicalDirection.Forward);
183Type backwardType = backwardPosition.GetElementType(LogicalDirection.Backward);
186TextPointerContext forwardContext = forwardPosition.GetPointerContext(LogicalDirection.Forward);
187TextPointerContext backwardContext = backwardPosition.GetPointerContext(LogicalDirection.Backward);
228TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
229TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
252TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
253TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
257typeof(Table).IsAssignableFrom(position.GetElementType(LogicalDirection.Forward)));
270position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart;
276position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd;
321BorderingElementCategory category = GetBorderingElementCategory(navigator, LogicalDirection.Forward);
328navigator.MoveToNextContextPosition(LogicalDirection.Forward);
330while (GetBorderingElementCategory(navigator, LogicalDirection.Forward) == BorderingElementCategory.MergeableScopingInline);
336elementType = navigator.GetElementType(LogicalDirection.Forward);
340navigator.MoveToNextContextPosition(LogicalDirection.Forward);
357elementType = navigator.GetElementType(LogicalDirection.Forward);
360navigator.MoveToNextInsertionPosition(LogicalDirection.Forward);
373navigator.MoveToNextContextPosition(LogicalDirection.Forward);
375while (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
386return IsAtNonMergeableInlineEdge(position, LogicalDirection.Backward);
392return IsAtNonMergeableInlineEdge(position, LogicalDirection.Forward);
402internal static bool IsAtFormatNormalizedPosition(ITextPointer position, LogicalDirection direction)
407internal static bool IsAtInsertionPosition(ITextPointer position, LogicalDirection direction)
412internal static bool IsAtNormalizedPosition(ITextPointer position, LogicalDirection direction, bool respectCaretUnitBoundaries)
421if (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
422position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
467internal static bool IsAtWordBoundary(ITextPointer thisPosition, LogicalDirection insideWordDirection)
510return GetWordRange(thisPosition, LogicalDirection.Forward);
522internal static TextSegment GetWordRange(ITextPointer thisPosition, LogicalDirection direction)
545if (moved && IsAtWordBoundary(thisPosition, /*insideWordDirection:*/LogicalDirection.Forward))
552MoveToNextWordBoundary(navigator, direction == LogicalDirection.Backward ? LogicalDirection.Forward : LogicalDirection.Backward);
556if (direction == LogicalDirection.Backward)
565wordStart = RestrictWithinBlock(thisPosition, wordStart, LogicalDirection.Backward);
566wordEnd = RestrictWithinBlock(thisPosition, wordEnd, LogicalDirection.Forward);
571wordStart = wordStart.GetFrozenPointer(LogicalDirection.Backward);
572wordEnd = wordEnd.GetFrozenPointer(LogicalDirection.Forward);
576wordStart = wordEnd.GetFrozenPointer(LogicalDirection.Backward);
584private static ITextPointer RestrictWithinBlock(ITextPointer position, ITextPointer limit, LogicalDirection direction)
586Invariant.Assert(!(direction == LogicalDirection.Backward) || position.CompareTo(limit) >= 0, "for backward direction position must be >= than limit");
587Invariant.Assert(!(direction == LogicalDirection.Forward) || position.CompareTo(limit) <= 0, "for forward direcion position must be <= than linit");
589while (direction == LogicalDirection.Backward ? position.CompareTo(limit) > 0 : position.CompareTo(limit) < 0)
610return limit.GetInsertionPosition(direction == LogicalDirection.Backward ? LogicalDirection.Forward : LogicalDirection.Backward);
619internal static bool IsNextToPlainLineBreak(ITextPointer thisPosition, LogicalDirection direction)
629(direction == LogicalDirection.Backward && IsCharUnicodeNewLine(textBuffer[1]))
631(direction == LogicalDirection.Forward && IsCharUnicodeNewLine(textBuffer[0]))
647internal static bool IsNextToRichLineBreak(ITextPointer thisPosition, LogicalDirection direction)
656internal static bool IsNextToParagraphBreak(ITextPointer thisPosition, LogicalDirection direction)
667internal static bool IsNextToAnyBreak(ITextPointer thisPosition, LogicalDirection direction)
697bool isAtLineWrappingPosition = position.LogicalDirection == LogicalDirection.Forward
712thisPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd &&
713thisPosition.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart;
723return thisPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.None &&
724thisPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd &&
725!typeof(Inline).IsAssignableFrom(thisPosition.GetElementType(LogicalDirection.Backward));
739while (pointer.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
745pointer = pointer.GetNextContextPosition(LogicalDirection.Backward);
777paragraphOrBlockUIContainer.ElementStart.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
854internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection direction)
860internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection direction, bool transformToUiScope)
921internal static bool MoveToFormatNormalizedPosition(ITextPointer thisNavigator, LogicalDirection direction)
934internal static bool MoveToInsertionPosition(ITextPointer thisNavigator, LogicalDirection direction)
957internal static bool MoveToNextInsertionPosition(ITextPointer thisNavigator, LogicalDirection direction)
963int increment = direction == LogicalDirection.Forward ? +1 : -1;
980if ((direction == LogicalDirection.Forward && initialPosition.CompareTo(thisNavigator) < 0) ||
981(direction == LogicalDirection.Backward && thisNavigator.CompareTo(initialPosition) < 0))
1011if (direction == LogicalDirection.Backward)
1024while (TextSchema.IsFormattingType(thisNavigator.GetElementType(LogicalDirection.Forward))
1035if (direction == LogicalDirection.Forward)
1065internal static bool MoveToNextWordBoundary(ITextPointer thisNavigator, LogicalDirection movingDirection)
1086if (IsAtWordBoundary(thisNavigator, /*insideWordDirection:*/LogicalDirection.Forward))
1097internal static ITextPointer GetFrozenPointer(ITextPointer thisPointer, LogicalDirection logicalDirection)
1136private static bool NormalizePosition(ITextPointer thisNavigator, LogicalDirection direction, bool respectCaretUnitBoundaries)
1142LogicalDirection oppositeDirection;
1146if (direction == LogicalDirection.Forward)
1149oppositeDirection = LogicalDirection.Backward;
1156oppositeDirection = LogicalDirection.Forward;
1252private static int LeaveNonMergeableInlineBoundary(ITextPointer thisNavigator, LogicalDirection direction, int symbolCount)
1256if (direction == LogicalDirection.Forward && IsAtNonMergeableInlineEnd(thisNavigator))
1258symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Forward);
1262symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Backward);
1267if (direction == LogicalDirection.Backward && IsAtNonMergeableInlineStart(thisNavigator))
1269symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Backward);
1273symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Forward);
1281private static int LeaveNonMergeableAncestor(ITextPointer thisNavigator, LogicalDirection direction)
1284int increment = (direction == LogicalDirection.Forward) ? +1 : -1;
1329TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
1330TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1365if (position.GetTextInRun(LogicalDirection.Backward, neighborhood, 0, 1) == 1 &&
1366position.GetTextInRun(LogicalDirection.Forward, neighborhood, 1, 1) == 1)
1424runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Backward), SelectionWordBreaker.MinContextLength - preceedingCount);
1428navigator.GetTextInRun(LogicalDirection.Forward, preceedingText, SelectionWordBreaker.MinContextLength - preceedingCount, runLength);
1434navigator.MoveToInsertionPosition(LogicalDirection.Backward);
1436while (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text);
1443runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Forward), SelectionWordBreaker.MinContextLength - followingCount);
1445navigator.GetTextInRun(LogicalDirection.Forward, followingText, followingCount, runLength);
1454navigator.MoveToInsertionPosition(LogicalDirection.Forward);
1456while (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text);
1467private static bool IsAtNonMergeableInlineEdge(ITextPointer position, LogicalDirection direction)
1487private static BorderingElementCategory GetBorderingElementCategory(ITextPointer position, LogicalDirection direction)
1489TextPointerContext context = (direction == LogicalDirection.Forward) ? TextPointerContext.ElementEnd : TextPointerContext.ElementStart;
1513private static bool IsNextToRichBreak(ITextPointer thisPosition, LogicalDirection direction, Type lineBreakType)
System\Windows\Documents\TextRangeBase.cs (68)
74textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Forward);
78textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Backward);
192normalizedPosition.MoveToInsertionPosition(LogicalDirection.Backward);
207!TextPointerBase.IsAtWordBoundary(thisRange.Start, LogicalDirection.Forward) && //
208!TextPointerBase.IsAtWordBoundary(thisRange.Start, LogicalDirection.Backward))
283!TextPointerBase.IsNextToAnyBreak(thisRange.End, LogicalDirection.Forward))
289nextPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
302(TextPointerBase.IsNextToAnyBreak(thisRange.End, LogicalDirection.Backward) ||
305ITextPointer newEnd = thisRange.End.GetNextInsertionPosition(LogicalDirection.Backward);
333SkipParagraphContent(start, LogicalDirection.Backward);
334SkipParagraphContent(end, LogicalDirection.Forward);
341private static void SkipParagraphContent(ITextPointer navigator, LogicalDirection direction)
350(nextContext == TextPointerContext.ElementStart && direction == LogicalDirection.Forward || //
351nextContext == TextPointerContext.ElementEnd && direction == LogicalDirection.Backward) && //
355(nextContext == TextPointerContext.ElementEnd && direction == LogicalDirection.Forward || //
356nextContext == TextPointerContext.ElementStart && direction == LogicalDirection.Backward) && //
411if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
413moved = position.MoveToNextContextPosition(LogicalDirection.Forward);
417moved = position.MoveToInsertionPosition(LogicalDirection.Forward);
422moved = position.MoveToNextInsertionPosition(LogicalDirection.Forward);
472position.MoveToNextContextPosition(LogicalDirection.Backward)) ;
493moved = position.MoveToNextContextPosition(LogicalDirection.Forward);
516endNavigator.MoveToInsertionPosition(LogicalDirection.Backward);
678TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
694navigator.MoveToNextContextPosition(LogicalDirection.Forward);
704navigator.MoveToNextContextPosition(LogicalDirection.Forward);
709navigator.MoveToNextContextPosition(LogicalDirection.Forward);
712elementType = navigator.GetElementType(LogicalDirection.Forward);
732navigator.MoveToNextContextPosition(LogicalDirection.Forward);
748int runLength = navigator.GetTextRunLength(LogicalDirection.Forward);
750runLength = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, charArray, 0, runLength, endPosition);
752navigator.MoveToNextContextPosition(LogicalDirection.Forward);
762bool theParagraphIsTheFirstInCollection = navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart;
763navigator.MoveToNextContextPosition(LogicalDirection.Forward);
765TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
772navigator.MoveToNextContextPosition(LogicalDirection.Forward);
773symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
796List list = (List)navigator.GetAdjacentElement(LogicalDirection.Forward);
817navigator.MoveToNextContextPosition(LogicalDirection.Forward);
827ListItem listItem = (ListItem)navigator.GetAdjacentElement(LogicalDirection.Forward);
859object element = navigator.GetAdjacentElement(LogicalDirection.Forward);
1251while (start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1255start = start.GetNextContextPosition(LogicalDirection.Backward);
1311if (thisRange.Start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
1312thisRange.End.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
1358(insertPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.None ||
1359insertPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) &&
1360(insertPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.None ||
1361insertPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd);
1372ITextPointer newStart = insertPosition.GetFrozenPointer(LogicalDirection.Backward);
1373ITextPointer newEnd = insertPosition.CreatePointer(LogicalDirection.Forward);
1378TextPointer insertionPosition = (TextPointer)newStart.CreatePointer(LogicalDirection.Forward);
1416newEnd = newEnd.GetNextInsertionPosition(LogicalDirection.Forward);
1617TextPointerContext context = start.GetPointerContext(LogicalDirection.Forward);
1620start.MoveToNextContextPosition(LogicalDirection.Forward);
1621context = start.GetPointerContext(LogicalDirection.Forward);
1626context = end.GetPointerContext(LogicalDirection.Backward);
1629end.MoveToNextContextPosition(LogicalDirection.Backward);
1630context = end.GetPointerContext(LogicalDirection.Backward);
1634return start.GetAdjacentElement(LogicalDirection.Forward) as UIElement;
1715start = GetNormalizedPosition(thisRange, start, LogicalDirection.Forward);
1722end = GetNormalizedPosition(thisRange, end, LogicalDirection.Backward);
1729if (start.LogicalDirection == LogicalDirection.Backward)
1732start = end.GetFrozenPointer(LogicalDirection.Backward);
1783private static bool IsAtNormalizedPosition(ITextRange thisRange, ITextPointer position, LogicalDirection direction)
1799private static ITextPointer GetNormalizedPosition(ITextRange thisRange, ITextPointer position, LogicalDirection direction)
1957!TextPointerBase.IsAtInsertionPosition(start, LogicalDirection.Forward) ||
1958!TextPointerBase.IsAtInsertionPosition(end, LogicalDirection.Backward))
System\Windows\Documents\TextRangeSerialization.cs (54)
76range.End.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart;
205while (rangeEnd.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
207rangeEnd = rangeEnd.GetNextContextPosition(LogicalDirection.Backward);
213TextPointerContext runType = textReader.GetPointerContext(LogicalDirection.Forward);
218TextElement nextElement = (TextElement)textReader.GetAdjacentElement(LogicalDirection.Forward);
227textReader.MoveToNextContextPosition(LogicalDirection.Forward);
247textReader.MoveToNextContextPosition(LogicalDirection.Forward);
255textReader.MoveToNextContextPosition(LogicalDirection.Forward);
265if (ignoreWriteHyperlinkEnd && (textReader.GetAdjacentElement(LogicalDirection.Forward) is Hyperlink))
269textReader.MoveToNextContextPosition(LogicalDirection.Forward);
282textReader.MoveToNextContextPosition(LogicalDirection.Forward);
299textReader.MoveToNextContextPosition(LogicalDirection.Forward);
303int textLength = textReader.GetTextRunLength(LogicalDirection.Forward);
306textLength = TextPointerBase.GetTextWithLimit(textReader, LogicalDirection.Forward, text, 0, textLength, rangeEnd);
313textReader.MoveToNextContextPosition(LogicalDirection.Forward);
317object embeddedObject = textReader.GetAdjacentElement(LogicalDirection.Forward);
318textReader.MoveToNextContextPosition(LogicalDirection.Forward);
325textReader.MoveToNextContextPosition(LogicalDirection.Forward);
546InlineUIContainer inlineUIContainer = textReader.GetAdjacentElement(LogicalDirection.Backward) as InlineUIContainer;
547BlockUIContainer blockUIContainer = textReader.GetAdjacentElement(LogicalDirection.Backward) as BlockUIContainer;
1226TextElement uiContainer = fragment.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
1332fragmentEnd = fragment.ElementEnd.GetPositionAtOffset(0, LogicalDirection.Forward); // need forward orientation to stick with the following content during merge at fragmentStart position
1360fragmentEnd = fragmentEnd.GetInsertionPosition(LogicalDirection.Forward);
1414while (positionBeforeParagraph.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1417positionBeforeParagraph = positionBeforeParagraph.GetNextContextPosition(LogicalDirection.Backward);
1419while (positionBeforeParagraph.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1423positionBeforeParagraph = positionBeforeParagraph.GetNextContextPosition(LogicalDirection.Backward);
1457if (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd)
1459navigator = navigator.GetNextContextPosition(LogicalDirection.Backward);
1475if (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
1477navigator = navigator.GetNextContextPosition(LogicalDirection.Forward);
1512TextPointerContext forwardFromStart = start.GetPointerContext(LogicalDirection.Forward);
1513TextPointerContext backwardFromEnd = end.GetPointerContext(LogicalDirection.Backward);
1516Invariant.Assert(itemType.IsAssignableFrom(start.GetAdjacentElement(LogicalDirection.Forward).GetType()),
1518Invariant.Assert(itemType.IsAssignableFrom(end.GetAdjacentElement(LogicalDirection.Backward).GetType()),
1522TextPointerContext backwardFromStart = start.GetPointerContext(LogicalDirection.Backward);
1523TextPointerContext forwardFromEnd = end.GetPointerContext(LogicalDirection.Forward);
1525Invariant.Assert(!(backwardFromStart == TextPointerContext.ElementEnd) || itemType.IsAssignableFrom(start.GetAdjacentElement(LogicalDirection.Backward).GetType()),
1528Invariant.Assert(!(forwardFromEnd == TextPointerContext.ElementStart) || itemType.IsAssignableFrom(end.GetAdjacentElement(LogicalDirection.Forward).GetType()),
1550((Section)fragment).HasTrailingParagraphBreakOnPaste = range.End.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None;
1606start = start.GetNextContextPosition(LogicalDirection.Forward);
1610TextPointerContext passedContext = start.GetPointerContext(LogicalDirection.Backward);
1650start = start.GetNextContextPosition(LogicalDirection.Forward);
1657start = start.GetNextContextPosition(LogicalDirection.Forward);
1847Invariant.Assert(textReader.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
1852elementEnd.MoveToNextContextPosition(LogicalDirection.Forward);
1874Invariant.Assert(textReader.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
1875Invariant.Assert(typeof(Hyperlink).IsAssignableFrom(textReader.GetElementType(LogicalDirection.Forward)));
1880Hyperlink hyperlink = (Hyperlink)textReader.GetAdjacentElement(LogicalDirection.Forward);
1885hyperlinkEnd.MoveToNextContextPosition(LogicalDirection.Forward);
1900InlineUIContainer inlineUIContainer = hyperlinkNavigation.GetAdjacentElement(LogicalDirection.Forward) as InlineUIContainer;
1907hyperlinkNavigation.MoveToNextContextPosition(LogicalDirection.Forward);
1922hyperlinkStart = range.Start.CreatePointer(LogicalDirection.Forward);
1923while (hyperlinkStart.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
System\windows\Documents\TextSelection.cs (64)
300((ITextSelection)this).SetCaretToPosition(((ITextRange)this).End, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
451void ITextSelection.SetCaretToPosition(ITextPointer caretPosition, LogicalDirection direction, bool allowStopAtLineEnd, bool allowStopNearSpace)
466ITextPointer reversePosition = caretPosition.CreatePointer(direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward);
472TextPointerBase.IsNextToPlainLineBreak(caretPosition, LogicalDirection.Backward) ||
473TextSchema.IsBreak(caretPosition.GetElementType(LogicalDirection.Backward))))
477caretPosition.SetLogicalDirection(LogicalDirection.Forward);
481if (caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
482caretPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
504LogicalDirection oppositeDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
581bool ITextSelection.ExtendToNextInsertionPosition(LogicalDirection direction)
616if (newMovingPosition == null && direction == LogicalDirection.Forward)
636LogicalDirection contentDirection = (anchorPosition.CompareTo(newMovingPosition) <= 0) ?
637LogicalDirection.Backward : LogicalDirection.Forward;
653private ITextPointer GetNextTextSegmentInsertionPosition(LogicalDirection direction)
840startPosition = anchorWordRange.Start.GetFrozenPointer(LogicalDirection.Forward);
841movingPosition = cursorWordRange.End.GetFrozenPointer(LogicalDirection.Backward);
845startPosition = anchorWordRange.End.GetFrozenPointer(LogicalDirection.Backward);
846movingPosition = cursorWordRange.Start.GetFrozenPointer(LogicalDirection.Forward);
962anchorWordRange.Contains(cursorPosition.GetInsertionPosition(LogicalDirection.Forward)) ||
963anchorWordRange.Contains(cursorPosition.GetInsertionPosition(LogicalDirection.Backward)))
975TextPointerBase.IsAtWordBoundary(anchorPosition, /*insideWordDirection:*/LogicalDirection.Forward))
989TextPointerBase.IsAtWordBoundary(cursorPosition, /*insideWordDirection:*/LogicalDirection.Forward))
1024bool ITextSelection.ExtendToNextTableRow(LogicalDirection direction)
1052if (direction == LogicalDirection.Forward)
1081movingPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
1181internal void SetCaretToPosition(TextPointer caretPosition, LogicalDirection direction, bool allowStopAtLineEnd, bool allowStopNearSpace)
1189internal bool ExtendToNextInsertionPosition(LogicalDirection direction)
1386this.SetCaretToPosition(cellStart, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1550Invariant.Assert(this.Start.LogicalDirection == LogicalDirection.Backward);
1551Invariant.Assert(this.End.LogicalDirection == LogicalDirection.Forward);
1756return (This.Start.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text &&
1757This.End.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text &&
1758This.Start.GetNextInsertionPosition(LogicalDirection.Backward) == null &&
1759This.End.GetNextInsertionPosition(LogicalDirection.Forward) == null);
1994(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X < cursorMousePoint.X ||
1995cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X < objectEdgeRect.X))
2000(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X > cursorMousePoint.X ||
2001cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X > objectEdgeRect.X))
2009(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X > cursorMousePoint.X ||
2010cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X > objectEdgeRect.X))
2015(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X < cursorMousePoint.X ||
2016cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X < objectEdgeRect.X))
2178if ((caretPosition.LogicalDirection == LogicalDirection.Backward && //
2179caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) || //
2186caretPosition.MoveToNextInsertionPosition(LogicalDirection.Backward);
2187caretPosition.SetLogicalDirection(LogicalDirection.Forward);
2195if (caretPosition.LogicalDirection == LogicalDirection.Backward && //
2196caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart && //
2197(caretPosition.GetNextInsertionPosition(LogicalDirection.Backward) == null || //
2198TextPointerBase.IsNextToAnyBreak(caretPosition, LogicalDirection.Backward)))
2201caretPosition.SetLogicalDirection(LogicalDirection.Forward);
2275nextCharacterPosition = focusedTextSelection.Start.CreatePointer(LogicalDirection.Forward);
2280nextCharacterPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
2281nextCharacterPosition.SetLogicalDirection(LogicalDirection.Backward);
2289nextCharacterPosition = focusedTextSelection.End.CreatePointer(LogicalDirection.Backward);
2294nextCharacterPosition.MoveToNextInsertionPosition(LogicalDirection.Backward);
2295nextCharacterPosition.SetLogicalDirection(LogicalDirection.Forward);
2757private LogicalDirection _movingPositionDirection;
System\Windows\Documents\TextStore.cs (73)
367this.TextSelection.SetCaretToPosition(start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
407navigator = CreatePointerAtCharOffset(startIndex, LogicalDirection.Forward);
408limit = (endIndex >= 0) ? CreatePointerAtCharOffset(endIndex, LogicalDirection.Forward) : null;
415TextPointerContext context = navigator.GetPointerContext(LogicalDirection.Forward);
429TextElement element = (TextElement)((TextPointer)navigator).GetAdjacentElement(LogicalDirection.Forward);
438navigator.MoveToNextContextPosition(LogicalDirection.Forward);
444navigator.MoveToNextContextPosition(LogicalDirection.Forward);
491start = start.GetNextInsertionPosition(LogicalDirection.Forward);
685startNavigator.SetLogicalDirection(LogicalDirection.Backward);
687endNavigator.SetLogicalDirection(LogicalDirection.Forward);
865position = CreatePointerAtCharOffset(index, LogicalDirection.Forward);
981ITextPointer positionCur = position.CreatePointer(LogicalDirection.Backward);
982ITextPointer positionPrev = position.CreatePointer(LogicalDirection.Forward);
983positionPrev.MoveToNextInsertionPosition(LogicalDirection.Backward);
1050startPointer = CreatePointerAtCharOffset(startIndex, LogicalDirection.Forward);
1051startPointer.MoveToInsertionPosition(LogicalDirection.Forward);
1061Rect rectStart = startPointer.GetCharacterRect(LogicalDirection.Forward);
1069endPointer = CreatePointerAtCharOffset(endIndex, LogicalDirection.Backward);
1070endPointer.MoveToInsertionPosition(LogicalDirection.Backward);
1091lineRect = navigator.GetCharacterRect(LogicalDirection.Forward);
1092moved = navigator.MoveToNextInsertionPosition(LogicalDirection.Forward);
1486navigator.MoveToInsertionPosition(LogicalDirection.Forward);
1491if (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
1497navigator.GetTextInRun(LogicalDirection.Forward, nextChars, 0, nextChars.Length);
1503TextSelection.ExtendToNextInsertionPosition(LogicalDirection.Forward);
1902internal ITextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
2011this.TextSelection.SetCaretToPosition(range.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
2385_previousCompositionStart = (_previousCompositionStartOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionStartOffset, LogicalDirection.Backward);
2386_previousCompositionEnd = (_previousCompositionEndOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionEndOffset, LogicalDirection.Forward);
2404_previousCompositionStart = (_previousCompositionStartOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionStartOffset, LogicalDirection.Backward);
2405_previousCompositionEnd = (_previousCompositionEndOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionEndOffset, LogicalDirection.Forward);
2452Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text);
2459runCount = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, text, charsCopied, Math.Min(cchReq, text.Length - charsCopied), limit);
2468runCount = navigator.GetTextRunLength(LogicalDirection.Forward);
2469navigator.MoveToNextContextPosition(LogicalDirection.Forward);
2511Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement);
2521navigator.MoveToNextContextPosition(LogicalDirection.Forward);
2553Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart || navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd);
2571char ch = (navigator.GetAdjacentElement(LogicalDirection.Forward) is TableCell) ? UnsafeNativeMethods.TS_CHAR_REGION : '\n';
2904start = CreatePointerAtCharOffset(startIndex, LogicalDirection.Backward);
2905end = CreatePointerAtCharOffset(startIndex + length, LogicalDirection.Forward);
2907while (start.CompareTo(end) < 0 && start.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text)
2909start.MoveToNextContextPosition(LogicalDirection.Forward);
3032positionNext.MoveToNextInsertionPosition(LogicalDirection.Forward);
3036positionNext.MoveToNextInsertionPosition(LogicalDirection.Backward);
3175Rect lineBounds = start.GetCharacterRect(LogicalDirection.Forward);
3176lineBounds.Union(end.GetCharacterRect(LogicalDirection.Backward));
3179ITextPointer navigator = start.CreatePointer(LogicalDirection.Forward);
3180while (navigator.MoveToNextContextPosition(LogicalDirection.Forward) == true && navigator.CompareTo(end) < 0)
3182TextPointerContext context = navigator.GetPointerContext(LogicalDirection.Backward);
3186lineBounds.Union(navigator.GetCharacterRect(LogicalDirection.Backward));
3191lineBounds.Union(navigator.GetCharacterRect(LogicalDirection.Backward));
3409TextPointer previousPosition = start.GetNextInsertionPosition(LogicalDirection.Backward);
3422if (start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
3424start = start.GetNextInsertionPosition(LogicalDirection.Backward);
3428start = start.GetNextInsertionPosition(LogicalDirection.Forward);
3436start = start.GetNextInsertionPosition(LogicalDirection.Forward);
3456start = CreatePointerAtCharOffset(startCharOffset, LogicalDirection.Forward);
3457end = (startCharOffset == endCharOffset) ? start : CreatePointerAtCharOffset(endCharOffset, LogicalDirection.Backward);
3462TextPointerContext forwardContext = start.GetPointerContext(LogicalDirection.Forward);
3466TextElement element = start.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
3478start.MoveToNextContextPosition(LogicalDirection.Forward);
3489start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
3494start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
3495end = end.GetFormatNormalizedPosition(LogicalDirection.Backward);
3637ITextPointer start = this.TextContainer.CreatePointerAtOffset(record.StartOffsetBefore, LogicalDirection.Backward);
3638ITextPointer end = this.TextContainer.CreatePointerAtOffset(record.EndOffsetBefore, LogicalDirection.Forward);
3799start = end.GetFrozenPointer(LogicalDirection.Backward);
3956ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(appSelectionAnchorOffset, LogicalDirection.Forward);
3957ITextPointer moving = this.TextContainer.CreatePointerAtOffset(appSelectionMovingOffset, LogicalDirection.Forward);
3977ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(imeSelectionAnchorOffset, LogicalDirection.Backward);
3978ITextPointer moving = this.TextContainer.CreatePointerAtOffset(imeSelectionMovingOffset, LogicalDirection.Backward);