src\Framework\MS\Internal\Documents\TextBoxLine.cs (8)
83switch (position.GetPointerContext(LogicalDirection.Forward))
121ITextPointer position = _owner.Host.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);
126int runLength = Math.Min(128, position.GetTextRunLength(LogicalDirection.Backward));
128position.GetTextInRun(LogicalDirection.Backward, text, 0, runLength);
433StaticTextPointer endOfRunPosition = _owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);
445TextDecorationCollection highlightDecorations = highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;
463&& highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue)
492int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);
src\Framework\MS\Internal\Documents\TextBoxView.cs (53)
637if (offset > 0 && position.LogicalDirection == LogicalDirection.Backward)
661if (position.LogicalDirection == LogicalDirection.Forward || position.Offset == 0)
668if (position.LogicalDirection == LogicalDirection.Backward && position.Offset > 0)
709firstLineIndex = Math.Max(firstLineIndex, GetLineIndexFromOffset(startOffset, LogicalDirection.Forward));
710lastLineIndex = Math.Min(lastLineIndex, GetLineIndexFromOffset(endOffset, LogicalDirection.Backward));
749ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].EndOffset, LogicalDirection.Backward);
750if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
789nextLinePosition = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex + linesMoved].Offset, LogicalDirection.Forward);
828if (position.LogicalDirection == LogicalDirection.Forward)
833else if (position.LogicalDirection == LogicalDirection.Backward)
858ITextPointer ITextView.GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
864if (position.Offset == 0 && direction == LogicalDirection.Backward)
866return position.GetFrozenPointer(LogicalDirection.Forward);
868else if (position.Offset == _host.TextContainer.SymbolCount && direction == LogicalDirection.Forward)
870return position.GetFrozenPointer(LogicalDirection.Backward);
880if (direction == LogicalDirection.Forward)
893LogicalDirection logicalDirection;
895direction == LogicalDirection.Forward)
901logicalDirection = LogicalDirection.Backward;
905logicalDirection = LogicalDirection.Forward;
909direction == LogicalDirection.Backward)
915logicalDirection = LogicalDirection.Forward;
919logicalDirection = LogicalDirection.Backward;
924logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
943return position.GetFrozenPointer(LogicalDirection.Forward);
946int lineIndex = GetLineIndexFromPosition(position, LogicalDirection.Backward);
956LogicalDirection logicalDirection;
963logicalDirection = LogicalDirection.Forward;
967logicalDirection = LogicalDirection.Backward;
972logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
990ITextPointer start = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].Offset, LogicalDirection.Forward);
991ITextPointer end = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[lineIndex].Offset + _lineMetrics[lineIndex].ContentLength, LogicalDirection.Forward);
1309ITextPointer start = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[0].Offset, LogicalDirection.Backward);
1310ITextPointer end = _host.TextContainer.CreatePointerAtOffset(_lineMetrics[_lineMetrics.Count-1].EndOffset, LogicalDirection.Forward);
1700private int GetLineIndexFromPosition(ITextPointer position, LogicalDirection direction)
1706private int GetLineIndexFromOffset(int offset, LogicalDirection direction)
1708if (offset > 0 && direction == LogicalDirection.Backward)
1754LogicalDirection logicalDirection;
1760logicalDirection = (charIndex.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
1935int firstLineIndex = GetLineIndexFromOffset(range.StartIndex, LogicalDirection.Forward);
1937int lastLineIndex = GetLineIndexFromOffset(endOffset, LogicalDirection.Backward);
2055ITextPointer position = _host.TextContainer.CreatePointerAtOffset(unclippedStartOffset, LogicalDirection.Backward);
2056if (TextPointerBase.IsNextToPlainLineBreak(position, LogicalDirection.Backward))
2100ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(endOffset, LogicalDirection.Backward);
2102if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
2151ITextPointer position = _host.TextContainer.CreatePointerAtOffset(unclippedStartOffset, LogicalDirection.Backward);
2152if (TextPointerBase.IsNextToPlainLineBreak(position, LogicalDirection.Backward))
2179ITextPointer endOfLinePosition = _host.TextContainer.CreatePointerAtOffset(endOffset, LogicalDirection.Backward);
2181if (TextPointerBase.IsNextToPlainLineBreak(endOfLinePosition, LogicalDirection.Backward))
2382int lineIndex = GetLineIndexFromOffset(range.StartIndex, LogicalDirection.Forward);
src\Framework\MS\Internal\Documents\TextContainerHelper.cs (23)
100_textContainer.CreatePointerAtOffset(_cpFirst, LogicalDirection.Forward),
101_textContainer.CreatePointerAtOffset(_cpLast, LogicalDirection.Backward),
110_textContainer.CreatePointerAtOffset(_ranges[i * 2], LogicalDirection.Forward),
111_textContainer.CreatePointerAtOffset(_ranges[i * 2 + 1], LogicalDirection.Backward),
129if (cpPos == _cpFirst && position.LogicalDirection == LogicalDirection.Backward ||
130cpPos == _cpLast && position.LogicalDirection == LogicalDirection.Forward)
146if (cpPos == _ranges[i * 2] && position.LogicalDirection == LogicalDirection.Backward ||
147cpPos == _ranges[i * 2 + 1] && position.LogicalDirection == LogicalDirection.Forward)
165startPosition = _textContainer.CreatePointerAtOffset(IsSimple ? _cpFirst : _ranges[0], LogicalDirection.Forward);
177endPosition = _textContainer.CreatePointerAtOffset(IsSimple ? _cpLast : _ranges[(_size - 1) * 2 + 1], LogicalDirection.Backward);
329if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
332element = start.GetAdjacentElement(LogicalDirection.Forward);
344start.MoveToNextContextPosition(LogicalDirection.Forward);
350else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement)
353element = start.GetAdjacentElement(LogicalDirection.Forward);
386if (!start.MoveToNextContextPosition(LogicalDirection.Forward))
414object element = position.GetAdjacentElement(LogicalDirection.Forward);
452element = position.GetAdjacentElement(LogicalDirection.Forward);
456positionsStart.Insert(0, position.CreatePointer(LogicalDirection.Forward));
468element = position.GetAdjacentElement(LogicalDirection.Backward);
472positionsEnd.Insert(0, position.CreatePointer(LogicalDirection.Backward));
557textPointer = textContainer.CreatePointerAtOffset(0, LogicalDirection.Forward); // Start
592internal static ITextPointer GetTextPointerFromCP(ITextContainer textContainer, int cp, LogicalDirection direction)
src\Framework\MS\Internal\Documents\TextDocumentView.cs (29)
306internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
489if (position.LogicalDirection == LogicalDirection.Forward)
499if (segment.Start.LogicalDirection == LogicalDirection.Backward)
508if (position.LogicalDirection == LogicalDirection.Backward)
518if (segment.End.LogicalDirection == LogicalDirection.Forward)
531if (position.TextContainer.Start.CompareTo(position) == 0 && position.LogicalDirection == LogicalDirection.Backward)
535else if (position.TextContainer.End.CompareTo(position) == 0 && position.LogicalDirection == LogicalDirection.Forward)
775position = paragraph.StartPosition.CreatePointer(LogicalDirection.Forward);
779position = paragraph.EndPosition.CreatePointer(LogicalDirection.Backward);
881position = blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward);
885position = blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward);
895position = paragraph.StartPosition.CreatePointer(LogicalDirection.Forward);
899position = paragraph.EndPosition.CreatePointer(LogicalDirection.Backward);
1584private ITextPointer GetNextCaretUnitPosition(ReadOnlyCollection<ParagraphResult> paragraphs, ReadOnlyCollection<ParagraphResult> floatingElements, ITextPointer position, LogicalDirection direction)
1621private ITextPointer GetNextCaretUnitPosition(ParagraphResult paragraph, ITextPointer position, LogicalDirection direction)
1693private ITextPointer GetNextCaretUnitPosition(ReadOnlyCollection<ColumnResult> columns, ReadOnlyCollection<ParagraphResult> floatingElements, ITextPointer position, LogicalDirection direction)
2410lineRange = new TextSegment(blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward), blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward));
2538positionOut = lines[lineIndex].StartPosition.CreatePointer(LogicalDirection.Forward);
2558positionOut = lines[0].StartPosition.CreatePointer(LogicalDirection.Forward);
2570positionOut = lines[lines.Count - 1].StartPosition.CreatePointer(LogicalDirection.Forward);
2914positionOut = blockUIContainer.ContentStart.CreatePointer(LogicalDirection.Forward);
2918positionOut = blockUIContainer.ContentEnd.CreatePointer(LogicalDirection.Backward);
3021positionOut = lines[lineIndex].StartPosition.CreatePointer(LogicalDirection.Forward);
3036positionOut = lines[0].StartPosition.CreatePointer(LogicalDirection.Forward);
3048positionOut = lines[lines.Count - 1].StartPosition.CreatePointer(LogicalDirection.Forward);
3299segmentEnd = _textContainer.Start.CreatePointer(backgroundFormatInfo.CPInterrupted, LogicalDirection.Backward);
3492if (textPointer.LogicalDirection == LogicalDirection.Forward && textPointer.CompareTo(textElement.ElementStart) == 0)
3497if (textPointer.LogicalDirection == LogicalDirection.Backward && textPointer.CompareTo(textElement.ElementEnd) == 0)
src\Framework\MS\Internal\PtsHost\TextParaClient.cs (56)
739RectFromDcpSimpleLines(0, 0, LogicalDirection.Forward, TextPointerContext.Text, ref textDetails.u.full, ref rect, ref vrBaseline);
744RectFromDcpCompositeLines(0, 0, LogicalDirection.Forward, TextPointerContext.Text, ref textDetails.u.full, ref rect, ref vrBaseline);
756internal ITextPointer GetTextPosition(int dcp, LogicalDirection direction)
785if (position.LogicalDirection == LogicalDirection.Backward && dcp > 0)
1006internal ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
1245LogicalDirection logicalDirection = (charHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
1838LogicalDirection orientation,
1890if (orientation == LogicalDirection.Forward)
1903if (orientation == LogicalDirection.Backward && originalDcp > 0 && (context == TextPointerContext.Text || context == TextPointerContext.EmbeddedElement))
1931LogicalDirection orientation,
1992if (orientation == LogicalDirection.Forward)
2002if (orientation == LogicalDirection.Backward && originalDcp > 0 && (context == TextPointerContext.Text || context == TextPointerContext.EmbeddedElement))
2254ITextPointer position = Paragraph.StructuralCache.TextContainer.CreatePointerAtOffset(Paragraph.ParagraphStartCharacterPosition + dcp, LogicalDirection.Forward);
2256return (TextPointerBase.IsNextToAnyBreak(position, LogicalDirection.Backward));
2626if (position.LogicalDirection == LogicalDirection.Backward)
2651else if (position.LogicalDirection == LogicalDirection.Forward)
2733if (position.LogicalDirection == LogicalDirection.Backward)
2780else if (position.LogicalDirection == LogicalDirection.Forward)
2820LogicalDirection direction,
2845if (dcp == lineDesc.dcpFirst && direction == LogicalDirection.Backward)
2860else if (dcp >= lineDesc.dcpLim - 1 && direction == LogicalDirection.Forward)
2889if (direction == LogicalDirection.Forward)
2898LogicalDirection logicalDirection;
2899if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == lineDesc.dcpLim) && direction == LogicalDirection.Forward)
2905logicalDirection = LogicalDirection.Backward;
2909logicalDirection = LogicalDirection.Forward;
2912else if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == lineDesc.dcpFirst) && direction == LogicalDirection.Backward)
2918logicalDirection = LogicalDirection.Forward;
2922logicalDirection = LogicalDirection.Backward;
2927logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
2949LogicalDirection direction,
2983if (dcp == element.dcpFirst && direction == LogicalDirection.Backward)
3024else if (dcp >= element.dcpLim - 1 && direction == LogicalDirection.Forward)
3057if (direction == LogicalDirection.Forward)
3066LogicalDirection logicalDirection;
3067if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == element.dcpLim) && direction == LogicalDirection.Forward)
3073logicalDirection = LogicalDirection.Backward;
3078logicalDirection = LogicalDirection.Forward;
3081else if ((nextCharacterHit.FirstCharacterIndex + nextCharacterHit.TrailingLength == element.dcpFirst) && direction == LogicalDirection.Backward)
3087logicalDirection = LogicalDirection.Forward;
3092logicalDirection = LogicalDirection.Backward;
3097logicalDirection = (nextCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
3177LogicalDirection logicalDirection;
3184logicalDirection = LogicalDirection.Forward;
3188logicalDirection = LogicalDirection.Backward;
3193logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
3307LogicalDirection logicalDirection;
3314logicalDirection = LogicalDirection.Forward;
3318logicalDirection = LogicalDirection.Backward;
3323logicalDirection = (backspaceCharacterHit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
src\Framework\MS\Internal\Text\ComplexLine.cs (17)
50switch (position.GetPointerContext(LogicalDirection.Forward))
97ITextPointer position = _owner.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward);
100while (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text &&
108string precedingTextString = position.GetTextInRun(LogicalDirection.Backward);
292position = new TextPointer(_owner.ContentStart, CalcPositionOffset(charHit), LogicalDirection.Forward);
299type = position.GetPointerContext(LogicalDirection.Forward);
304type = position.GetPointerContext(LogicalDirection.Backward);
315element = position.GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
343Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text, "TextPointer does not point to characters.");
363endOfRunPosition = _owner.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);
378int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);
391Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");
396TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
483Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd, "TextPointer does not point to element end edge.");
487TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
533Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");
536DependencyObject element = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
src\Framework\System\Windows\Controls\PasswordTextContainer.cs (19)
221ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
227ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
232ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
239return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
242TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
252int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
257object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
272StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
523return new PasswordTextPointer(this, LogicalDirection.Backward, 0);
537return new PasswordTextPointer(this, LogicalDirection.Forward, this.SymbolCount);
679textPosition = new PasswordTextPointer(this, LogicalDirection.Forward, offset);
716index = FindIndex(offset, LogicalDirection.Forward);
749if (position.LogicalDirection == LogicalDirection.Backward)
813private int FindIndex(int offset, LogicalDirection gravity)
827(position.LogicalDirection == gravity || gravity == LogicalDirection.Backward))
848LogicalDirection lastLogicalDirection;
851lastLogicalDirection = LogicalDirection.Backward;
863position.LogicalDirection == LogicalDirection.Backward &&
868Invariant.Assert(lastLogicalDirection != LogicalDirection.Forward);
src\Framework\System\Windows\Controls\TextBox.cs (24)
179TextPointer newStart = this.TextContainer.CreatePointerAtOffset(start, LogicalDirection.Forward);
183newStart = newStart.GetInsertionPosition(LogicalDirection.Forward);
191TextPointer newEnd = new TextPointer(newStart, length, LogicalDirection.Forward);
194newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
234return (textPointer.LogicalDirection == LogicalDirection.Backward) ? offset - 1 : offset;
286TextPointer position = this.TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Forward);
469TextPointer textPointer = TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Backward);
470textPointer = textPointer.GetInsertionPosition(LogicalDirection.Backward);
475textPointer = textPointer.GetNextInsertionPosition(LogicalDirection.Forward);
479textPointer = textPointer.GetPositionAtOffset(0, LogicalDirection.Backward);
484textPointer = textPointer.GetPositionAtOffset(0, LogicalDirection.Forward);
511TextPointer position = this.TextContainer.CreatePointerAtOffset(charIndex, LogicalDirection.Forward);
512SpellingError spellingError = this.TextEditor.GetSpellingErrorAtPosition(position, LogicalDirection.Forward);
516position = this.TextContainer.CreatePointerAtOffset(charIndex + 1, LogicalDirection.Forward);
517spellingError = this.TextEditor.GetSpellingErrorAtPosition(position, LogicalDirection.Backward);
577public int GetNextSpellingErrorCharacterIndex(int charIndex, LogicalDirection direction)
848TextPointer newEnd = new TextPointer(TextSelectionInternal.Start, value, LogicalDirection.Forward);
851newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
895TextPointer newStart = TextContainer.CreatePointerAtOffset(value, LogicalDirection.Forward);
899newStart = newStart.GetInsertionPosition(LogicalDirection.Forward);
907TextPointer newEnd = new TextPointer(newStart, selectionLength, LogicalDirection.Forward);
910newEnd = newEnd.GetInsertionPosition(LogicalDirection.Forward);
1474if (TextPointerBase.IsNextToPlainLineBreak(textPointer, LogicalDirection.Forward))
1476textPointer.MoveToNextInsertionPosition(LogicalDirection.Forward);
src\Framework\System\Windows\Controls\TextRangeAdaptor.cs (77)
490internal static bool MoveToInsertionPosition(ITextPointer position, LogicalDirection direction)
538TextPointerBase.MoveToNextInsertionPosition(_start, LogicalDirection.Backward);
542TextPointerBase.MoveToNextInsertionPosition(_end, LogicalDirection.Forward);
549MoveToNextWordBoundary(_start, LogicalDirection.Backward);
553MoveToNextWordBoundary(_end, LogicalDirection.Forward);
563TextPointerContext forwardContext = _start.GetPointerContext(LogicalDirection.Forward);
566TextPointerContext backwardContext = _start.GetPointerContext(LogicalDirection.Backward);
574_start.MoveToNextContextPosition(LogicalDirection.Backward);
580TextPointerContext backwardContext = _end.GetPointerContext(LogicalDirection.Backward);
583TextPointerContext forwardContext = _end.GetPointerContext(LogicalDirection.Forward);
591_end.MoveToNextContextPosition(LogicalDirection.Forward);
597_start.SetLogicalDirection(LogicalDirection.Forward);
598_end.SetLogicalDirection(LogicalDirection.Forward);
735private bool MoveToUnitBoundary(ITextPointer position, bool isStart, LogicalDirection direction, TextUnit unit)
773if (moved && direction == LogicalDirection.Forward)
777TextPointerContext context = position.GetPointerContext(LogicalDirection.Forward);
782position.MoveToNextContextPosition(LogicalDirection.Forward);
801if (direction == LogicalDirection.Forward)
819nextLineStart = GetInsertionPosition(nextLineStart, LogicalDirection.Forward);
824position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
846previousLineEnd = GetInsertionPosition(previousLineEnd, LogicalDirection.Backward);
851position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
864if (direction == LogicalDirection.Forward)
871if (nextParagraphStart.MoveToNextInsertionPosition(LogicalDirection.Forward))
881position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
892if (previousParagraphEnd.MoveToNextInsertionPosition(LogicalDirection.Backward))
902position.SetLogicalDirection(isStart ? LogicalDirection.Forward : LogicalDirection.Backward);
931if (direction == LogicalDirection.Forward)
935if (position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.ElementEnd)
941Invariant.Assert(position.MoveToNextContextPosition(LogicalDirection.Forward));
943MoveToInsertionPosition(position, LogicalDirection.Forward);
949if (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart)
955Invariant.Assert(position.MoveToNextContextPosition(LogicalDirection.Backward));
957MoveToInsertionPosition(position, LogicalDirection.Backward);
965if (direction == LogicalDirection.Forward)
967if (position.CompareTo(GetInsertionPosition(position.TextContainer.End, LogicalDirection.Backward)) != 0)
975if (position.CompareTo(GetInsertionPosition(position.TextContainer.Start, LogicalDirection.Forward)) != 0)
1005LogicalDirection direction = (count > 0) ? LogicalDirection.Forward : LogicalDirection.Backward;
1062if (direction == LogicalDirection.Backward)
1064while (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text)
1066if (!position.MoveToNextContextPosition(LogicalDirection.Backward))
1086position.SetLogicalDirection(LogicalDirection.Forward);
1103position.MoveToNextInsertionPosition(LogicalDirection.Backward);
1108MoveToInsertionPosition(position, LogicalDirection.Forward);
1123position.MoveToPosition(direction == LogicalDirection.Forward ? paragraphRange.End : paragraphRange.Start);
1154if (direction == LogicalDirection.Backward)
1157MoveToInsertionPosition(position, LogicalDirection.Backward);
1162MoveToInsertionPosition(position, LogicalDirection.Forward);
1174if (direction == LogicalDirection.Forward)
1207return (direction == LogicalDirection.Forward) ? moved : -moved;
1222while (IsElementBoundary(start.GetPointerContext(LogicalDirection.Forward)))
1224if (!start.MoveToNextContextPosition(LogicalDirection.Forward) || start.CompareTo(end) >= 0)
1229while (IsElementBoundary(end.GetPointerContext(LogicalDirection.Backward)))
1231if (!end.MoveToNextContextPosition(LogicalDirection.Backward) || start.CompareTo(end) >= 0)
1246if (!start.MoveToNextContextPosition(LogicalDirection.Forward) || start.CompareTo(end) > 0)
1457return TextPointerBase.IsAtWordBoundary(position, LogicalDirection.Forward);
1465private static bool MoveToNextWordBoundary(ITextPointer position, LogicalDirection direction)
1491position.SetLogicalDirection(LogicalDirection.Forward);
1516private ITextPointer GetInsertionPosition(ITextPointer position, LogicalDirection direction)
1655_end.MoveToNextInsertionPosition(LogicalDirection.Forward);
1693ITextPointer position = _end.CreatePointer(LogicalDirection.Backward);
1704attrEnd = position.CreatePointer(LogicalDirection.Backward);
1711attrStart = position.CreatePointer(LogicalDirection.Forward);
1715if (!position.MoveToNextContextPosition(LogicalDirection.Backward))
1724ITextPointer position = _start.CreatePointer(LogicalDirection.Forward);
1735attrStart = position.CreatePointer(LogicalDirection.Forward);
1742attrEnd = position.CreatePointer(LogicalDirection.Backward);
1746if (!position.MoveToNextContextPosition(LogicalDirection.Forward))
1932_end.MoveToNextInsertionPosition(LogicalDirection.Forward);
1970if (MoveToUnitBoundary(position, start, count < 0 ? LogicalDirection.Backward : LogicalDirection.Forward, unit))
src\Framework\System\Windows\Documents\DocumentSequenceTextContainer.cs (17)
115ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
121ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
126ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
133return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
136TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
146int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
151object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
166StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
888internal override object GetHighlightValue(StaticTextPointer textPosition, LogicalDirection direction, Type highlightLayerOwnerType)
909internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction)
931internal override StaticTextPointer GetNextHighlightChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
974internal override StaticTextPointer GetNextPropertyChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
999private bool EnsureParentPosition(StaticTextPointer textPosition, LogicalDirection direction, out StaticTextPointer parentPosition)
1013ITextPointer dynamicTextPointer = textPosition.CreateDynamicTextPointer(LogicalDirection.Forward);
1031private StaticTextPointer GetStaticPositionInChildContainer(StaticTextPointer textPosition, LogicalDirection direction, StaticTextPointer originalPosition)
1037DocumentSequenceTextPointer parentChangePosition = textPosition.CreateDynamicTextPointer(LogicalDirection.Forward) as DocumentSequenceTextPointer;
1050childTp = direction == LogicalDirection.Forward ?
src\Framework\System\Windows\Documents\DocumentSequenceTextPointer.cs (52)
59void ITextPointer.SetLogicalDirection(LogicalDirection direction)
92TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
101int ITextPointer.GetTextRunLength(LogicalDirection direction)
107string ITextPointer.GetTextInRun(LogicalDirection direction)
113/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
116int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
125object ITextPointer.GetAdjacentElement(LogicalDirection direction)
134Type ITextPointer.GetElementType(LogicalDirection direction)
202/// <see cref="ITextPointer.CreatePointer(LogicalDirection)"/>
204ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
210/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
212ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
226ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
255ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
270ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
281ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
290ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
371if (!isAtCaretUnitBoundary && ((ITextPointer)this).LogicalDirection == LogicalDirection.Backward)
379ITextPointer positionForwardGravity = ((ITextPointer)this).CreatePointer(LogicalDirection.Forward);
389LogicalDirection ITextPointer.LogicalDirection
455bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
488LogicalDirection gravity = this.ChildPointer.LogicalDirection;
518Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
523bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
528bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
643public static TextPointerContext GetPointerContext(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
654public static int GetTextRunLength(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
662/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
665public static int GetTextInRun(DocumentSequenceTextPointer thisTp, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
697public static object GetAdjacentElement(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
708public static Type GetElementType(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
787public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, LogicalDirection gravity)
793/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
795public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, int distance, LogicalDirection gravity)
840internal static bool iScan(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
845moved = xGapAwareScan(thisTp, (direction == LogicalDirection.Forward ? 1 : -1));
889private static DocumentSequenceTextPointer xGetClingDSTP(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
901if (direction == LogicalDirection.Forward)
914Debug.Assert(direction == LogicalDirection.Backward);
939private static TextPointerContext xGapAwareGetSymbolType(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
946private static object xGapAwareGetEmbeddedElement(DocumentSequenceTextPointer thisTp, LogicalDirection direction)
990if (tp1.ChildPointer.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None ||
991tp2.ChildPointer.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.None)
1000if (block.ChildContainer.Start.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None)
1055LogicalDirection scanDir = (distance > 0 ? LogicalDirection.Forward : LogicalDirection.Backward);
1083if (scanDir == LogicalDirection.Backward)
1091if (!((cdb.IsHead && scanDir == LogicalDirection.Backward)
1092|| (cdb.IsTail && scanDir == LogicalDirection.Forward)
1096cdb = (scanDir == LogicalDirection.Forward ? cdb.NextBlock : cdb.PreviousBlock);
1097childTn = (scanDir == LogicalDirection.Forward ?
src\Framework\System\Windows\Documents\FixedDocument.cs (11)
535fixedTextPointer = new FixedTextPointer(true, LogicalDirection.Forward, flowPosition);
1116if (!highlights.IsContentHighlighted(highlightTransitionPosition, LogicalDirection.Forward))
1118highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1129selected = highlights.GetHighlightValue(highlightTransitionPosition, LogicalDirection.Forward, typeof(TextSelection));
1147highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1150while (highlights.GetHighlightValue(highlightTransitionPosition, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue);
1159LogicalDirection.Forward, typeof(HighlightComponent)) as AnnotationHighlightLayer.HighlightSegment;
1163highlightTransitionPosition = highlights.GetNextHighlightChangePosition(highlightTransitionPosition, LogicalDirection.Forward);
1174this.FixedContainer.GetMultiHighlights((FixedTextPointer)highlightRangeStart.CreateDynamicTextPointer(LogicalDirection.Forward),
1175(FixedTextPointer)highlightTransitionPosition.CreateDynamicTextPointer(LogicalDirection.Forward),
1485return new FixedTextPointer(true, LogicalDirection.Forward, flowPosition);
src\Framework\System\Windows\Documents\FixedFindEngine.cs (12)
157end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber)));
158start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber)));
162start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber)));
163end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber)));
172end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber));
173start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber));
177start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber));
178end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber));
311new FixedTextPointer(false, LogicalDirection.Forward,pageStartFlowPosition));
317firstSearchPageStart = new FixedTextPointer(false, LogicalDirection.Forward, endAsFTP.FixedTextContainer.FixedTextBuilder.GetPageStartFlowPosition(pageNumber));
331new FixedTextPointer(false, LogicalDirection.Backward, pageEndFlowPosition));
337firstSearchPageEnd = new FixedTextPointer(false, LogicalDirection.Backward, startAsFTP.FixedTextContainer.FixedTextBuilder.GetPageEndFlowPosition(pageNumber));
src\Framework\System\Windows\Documents\FixedTextContainer.cs (12)
100ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
106ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
111ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
118return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
121TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
131int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
136object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
151StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
593_start = new FixedTextPointer(false, LogicalDirection.Backward, new FlowPosition(this, this.FixedTextBuilder.FixedFlowMap.FlowStartEdge, 1));
594_end = new FixedTextPointer(false, LogicalDirection.Forward, new FlowPosition(this, this.FixedTextBuilder.FixedFlowMap.FlowEndEdge, 0));
604FixedTextPointer eStart = new FixedTextPointer(false, LogicalDirection.Backward, pStart);
605FixedTextPointer eEnd = new FixedTextPointer(false, LogicalDirection.Forward, pEnd);
src\Framework\System\Windows\Documents\FixedTextPointer.cs (27)
40internal FixedTextPointer(bool mutable, LogicalDirection gravity, FlowPosition flow)
106TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
116int ITextPointer.GetTextRunLength(LogicalDirection direction)
127string ITextPointer.GetTextInRun(LogicalDirection direction)
133/// <see cref="ITextPointer.GetTextInRun(LogicalDirection,char[],int,int)"/>
136int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
159object ITextPointer.GetAdjacentElement(LogicalDirection direction)
174Type ITextPointer.GetElementType(LogicalDirection direction)
281/// <see cref="ITextPointer.CreatePointer(LogicalDirection)"/>
283ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
289/// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
291ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
315ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
324ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
342ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
356ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
368ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
388void ITextPointer.SetLogicalDirection(LogicalDirection direction)
398bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
485Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
493bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
501bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
594if (!isAtCaretUnitBoundary && this.LogicalDirection == LogicalDirection.Backward)
602ITextPointer positionForwardGravity = ((ITextPointer)this).CreatePointer(LogicalDirection.Forward);
612LogicalDirection ITextPointer.LogicalDirection
688internal LogicalDirection LogicalDirection
721private LogicalDirection _gravity;
src\Framework\System\Windows\Documents\FixedTextView.cs (43)
90textPos = _CreateTextPointer(fixedp, LogicalDirection.Backward);
114pos = _CreateTextPointer(fixedp, LogicalDirection.Forward);
122pos = _CreateTextPointer(fixedp, LogicalDirection.Forward);
193if (position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None)
354LogicalDirection edge = position.LogicalDirection;
355LogicalDirection scanDir = LogicalDirection.Forward;
376scanDir = LogicalDirection.Backward;
391linesMoved = (scanDir == LogicalDirection.Forward) ? 1 : -1;
416if (scanDir == LogicalDirection.Backward)
523internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction)
540CharacterHit next = (direction == LogicalDirection.Forward) ?
546LogicalDirection edge = LogicalDirection.Forward;
549edge = LogicalDirection.Backward;
627ITextPointer begin = _CreateTextPointer(new FixedPosition(fixedNodes[0], 0), LogicalDirection.Forward);
628ITextPointer end = _CreateTextPointer(new FixedPosition(lastNode, lastIndex), LogicalDirection.Backward);
660(tp.CompareTo(this.Start) == 0 && (tp.LogicalDirection == LogicalDirection.Forward || this.IsContainerStart)) ||
661(tp.CompareTo(this.End) == 0 && (tp.LogicalDirection == LogicalDirection.Backward || this.IsContainerEnd))
756_start = new FixedTextPointer(false, LogicalDirection.Forward, flowStart);
769_end = new FixedTextPointer(false, LogicalDirection.Backward, flowEnd);
809private void _GlyphRunHitTest(Glyphs g, double xoffset, out int charIndex, out LogicalDirection edge)
812edge = LogicalDirection.Forward;
830edge = (hit.TrailingLength > 0) ? LogicalDirection.Backward : LogicalDirection.Forward;
874LogicalDirection dir;
888itp = ((ITextPointer)this.Start).CreatePointer(LogicalDirection.Forward);
889itp.MoveToInsertionPosition(LogicalDirection.Forward);
893itp = ((ITextPointer)this.End).CreatePointer(LogicalDirection.Backward);
894itp.MoveToInsertionPosition(LogicalDirection.Backward);
903private bool _GetNextLineGlyphs(ref FixedPosition fixedp, ref LogicalDirection edge, double suggestedX, LogicalDirection scanDir)
908FixedNode[] fixedNodes = Container.FixedTextBuilder.GetNextLine(fixedp.Node, (scanDir == LogicalDirection.Forward), ref count);
1101LogicalDirection textdir = ftp.LogicalDirection;
1115textdir = LogicalDirection.Forward;
1118textdir = LogicalDirection.Backward;
1155LogicalDirection dir = LogicalDirection.Forward;
1159dir = LogicalDirection.Backward;
1188private ITextPointer _CreateTextPointer(FixedPosition fixedPosition, LogicalDirection edge)
1213LogicalDirection edge;
1223LogicalDirection dir = textPointer.LogicalDirection;
1224int increment = (dir == LogicalDirection.Forward ? +1 : -1);
src\Framework\System\Windows\Documents\ImmComposition.cs (25)
744caretNavigator = _caretOffset > 0 ? _startComposition.CreatePointer(_caretOffset, LogicalDirection.Forward) : _endComposition;
751ITextPointer startPosition = startNavigator.CreatePointer(LogicalDirection.Forward);
752ITextPointer endPosition = endNavigator.CreatePointer(LogicalDirection.Backward);
753ITextPointer caretPosition = caretNavigator.CreatePointer(LogicalDirection.Forward);
889rectCaret = view.GetRectangleFromTextPosition(_editor.Selection.End.CreatePointer(LogicalDirection.Backward));
1277start = range.Start.CreatePointer(resultLength, LogicalDirection.Forward);
1281ITextPointer caretPosition = _caretOffset >= 0 ? start.CreatePointer(_caretOffset, LogicalDirection.Forward) : end;
1320ITextPointer startAttribute = _startComposition.CreatePointer(startOffset, LogicalDirection.Backward);
1321ITextPointer endAttribute = _startComposition.CreatePointer(i + 1, LogicalDirection.Forward);
1566switch (navigator.GetPointerContext(LogicalDirection.Backward))
1570int copied = navigator.GetTextInRun(LogicalDirection.Backward, buffer, 0, buffer.Length);
1584if (!navigator.GetElementType(LogicalDirection.Backward).IsSubclassOf(typeof(Inline)))
1588navigator.MoveToNextContextPosition(LogicalDirection.Backward);
1597navigator.MoveToNextContextPosition(LogicalDirection.Backward);
1618switch (navigator.GetPointerContext(LogicalDirection.Forward))
1622int copied = navigator.GetTextInRun(LogicalDirection.Forward, buffer, 0, buffer.Length);
1635if (!navigator.GetElementType(LogicalDirection.Forward).IsSubclassOf(typeof(Inline)))
1639navigator.MoveToNextContextPosition(LogicalDirection.Forward);
1647navigator.MoveToNextContextPosition(LogicalDirection.Forward);
1694ITextPointer start = range.Start.CreatePointer(LogicalDirection.Backward);
1699ITextPointer end = start.CreatePointer(LogicalDirection.Forward);
1721switch (position.GetPointerContext(LogicalDirection.Backward))
1737switch (position.GetPointerContext(LogicalDirection.Forward))
1847positionNext.MoveToNextInsertionPosition(LogicalDirection.Forward);
1851positionNext.MoveToNextInsertionPosition(LogicalDirection.Backward);
src\Framework\System\Windows\Documents\ITextContainer.cs (7)
41ITextPointer CreatePointerAtOffset(int offset, LogicalDirection direction);
46ITextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction);
48ITextPointer CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction);
52TextPointerContext GetPointerContext(StaticTextPointer pointer, LogicalDirection direction);
56int GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count);
58object GetAdjacentElement(StaticTextPointer position, LogicalDirection direction);
64StaticTextPointer GetNextContextPosition(StaticTextPointer position, LogicalDirection direction);
src\Framework\System\Windows\Documents\NullTextContainer.cs (10)
42_start = new NullTextPointer(this, LogicalDirection.Backward);
43_end = new NullTextPointer(this, LogicalDirection.Forward);
87ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
93ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
98ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
105return new StaticTextPointer(this, ((ITextContainer)this).CreatePointerAtOffset(offset, LogicalDirection.Forward));
108TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
118int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
123object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
138StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
src\Framework\System\Windows\Documents\Speller.cs (46)
116internal SpellingError GetError(ITextPointer position, LogicalDirection direction, bool forceEvaluation)
150internal ITextPointer GetNextSpellingErrorPosition(ITextPointer position, LogicalDirection direction)
216ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out contentStart, out contextStart);
217ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out contentEnd, out contextEnd);
264if (_statusTable.GetError(pointer, LogicalDirection.Forward, out errorStart, out errorEnd))
274pointer = _statusTable.GetNextErrorTransition(pointer, LogicalDirection.Forward);
732end = GetNextLanguageTransition(start, LogicalDirection.Forward, language, end);
778wordBreakLeft = SearchForWordBreaks(caretPosition, LogicalDirection.Backward, language, 1, false /* stopOnError */);
779wordBreakRight = SearchForWordBreaks(caretPosition, LogicalDirection.Forward, language, 1, false /* stopOnError */);
794FindPositionInSegmentList(textMap, LogicalDirection.Backward, segments, out leftBreakOffset, out rightBreakOffset);
869ExpandToWordBreakAndContext(start, LogicalDirection.Backward, language, out contentStart, out contextStart);
870ExpandToWordBreakAndContext(end, LogicalDirection.Forward, language, out contentEnd, out contextEnd);
1164private void ExpandToWordBreakAndContext(ITextPointer position, LogicalDirection direction, XmlLanguage language,
1174LogicalDirection inwardDirection;
1200inwardDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
1206if (direction == LogicalDirection.Backward)
1241if (direction == LogicalDirection.Backward)
1258if (direction == LogicalDirection.Backward)
1285if (direction == LogicalDirection.Backward)
1314private int FindPositionInSegmentList(TextMap textMap, LogicalDirection direction, ArrayList segments,
1373if (direction == LogicalDirection.Backward)
1399private ITextPointer SearchForWordBreaks(ITextPointer position, LogicalDirection direction, XmlLanguage language, int minWordCount, bool stopOnError)
1417closestErrorPosition = nextErrorTransition.CreateDynamicTextPointer(LogicalDirection.Forward);
1425searchPosition.MoveByOffset(direction == LogicalDirection.Backward ? -ContextBlockSize : +ContextBlockSize);
1430if (direction == LogicalDirection.Backward && closestErrorPosition.CompareTo(searchPosition) > 0 ||
1431direction == LogicalDirection.Forward && closestErrorPosition.CompareTo(searchPosition) < 0)
1441if (direction == LogicalDirection.Backward && closestLanguageTransition.CompareTo(searchPosition) > 0 ||
1442direction == LogicalDirection.Forward && closestLanguageTransition.CompareTo(searchPosition) < 0)
1448if (direction == LogicalDirection.Backward)
1471private ITextPointer GetNextLanguageTransition(ITextPointer position, LogicalDirection direction, XmlLanguage language, ITextPointer haltPosition)
1475while ((direction == LogicalDirection.Forward && navigator.CompareTo(haltPosition) < 0) ||
1476(direction == LogicalDirection.Backward && navigator.CompareTo(haltPosition) > 0))
1485if ((direction == LogicalDirection.Forward && navigator.CompareTo(haltPosition) > 0) ||
1486(direction == LogicalDirection.Backward && navigator.CompareTo(haltPosition) < 0))
1563private void ScanPosition(ITextPointer position, LogicalDirection direction)
1568if (direction == LogicalDirection.Forward)
1790_basePosition = contextStart.GetFrozenPointer(LogicalDirection.Backward);
1817switch (position.GetPointerContext(LogicalDirection.Forward))
1820runCount = position.GetTextRunLength(LogicalDirection.Forward);
1824position.GetTextInRun(LogicalDirection.Forward, _text, _textLength, runCount);
1860position.MoveToNextContextPosition(LogicalDirection.Forward);
1868position.MoveToNextContextPosition(LogicalDirection.Forward);
1935context = pointer.GetPointerContext(LogicalDirection.Forward);
1938TextSchema.IsFormattingType(pointer.GetElementType(LogicalDirection.Forward)))
src\Framework\System\Windows\Documents\SpellerStatusTable.cs (20)
93for (index = FindIndex(searchStart.CreateStaticPointer(), LogicalDirection.Forward); index >= 0 && index < _runList.Count; index++)
129runIndex = FindIndex(start.CreateStaticPointer(), LogicalDirection.Forward);
165internal bool IsRunType(StaticTextPointer textPosition, LogicalDirection direction, RunType runType)
180internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction)
195else if (direction == LogicalDirection.Forward)
245internal bool GetError(StaticTextPointer textPosition, LogicalDirection direction,
265internal bool GetRun(StaticTextPointer position, LogicalDirection direction, out RunType runType, out StaticTextPointer end)
280end = (direction == LogicalDirection.Forward) ? GetRunEndPosition(index) : run.Position.CreateStaticPointer();
310private int GetErrorIndex(StaticTextPointer textPosition, LogicalDirection direction)
333private int FindIndex(StaticTextPointer position, LogicalDirection direction)
350if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 ||
351direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0)
356else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 ||
357direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0)
393startIndex = FindIndex(start.CreateStaticPointer(), LogicalDirection.Forward);
394endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);
429endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);
594index = FindIndex(position.CreateStaticPointer(), LogicalDirection.Backward);
754return GetRunEndPosition(index).CreateDynamicTextPointer(LogicalDirection.Forward);
802_position = position.GetFrozenPointer(LogicalDirection.Backward);
src\Framework\System\Windows\Documents\TextContainer.cs (36)
449ITextPointer ITextContainer.CreatePointerAtOffset(int offset, LogicalDirection direction)
457internal TextPointer CreatePointerAtOffset(int offset, LogicalDirection direction)
466ITextPointer ITextContainer.CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
480internal TextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
493ITextPointer ITextContainer.CreateDynamicTextPointer(StaticTextPointer position, LogicalDirection direction)
520TextPointerContext ITextContainer.GetPointerContext(StaticTextPointer pointer, LogicalDirection direction)
531else if (direction == LogicalDirection.Forward)
533edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Forward);
538edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Backward);
570int ITextContainer.GetTextInRun(StaticTextPointer position, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
586object ITextContainer.GetAdjacentElement(StaticTextPointer position, LogicalDirection direction)
633StaticTextPointer ITextContainer.GetNextContextPosition(StaticTextPointer position, LogicalDirection direction)
650edge = (direction == LogicalDirection.Backward) ? ElementEdge.AfterStart : ElementEdge.BeforeEnd;
656TextTreeTextNode nextTextNode = ((direction == LogicalDirection.Forward) ? node.GetNextNode() : node.GetPreviousNode()) as TextTreeTextNode;
661edge = (direction == LogicalDirection.Backward) ? ElementEdge.BeforeStart : ElementEdge.AfterEnd;
665else if (direction == LogicalDirection.Forward)
667edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Forward);
672edge = node.GetEdgeFromOffset(nodeOffset, LogicalDirection.Backward);
844LogicalDirection direction;
878originalPosition = this.HasListeners ? new TextPointer(position, LogicalDirection.Backward) : null;
890direction = LogicalDirection.Backward;
894direction = LogicalDirection.Forward;
903if ((direction == LogicalDirection.Backward && textNode.AfterEndReferenceCount) ||
904(direction == LogicalDirection.Forward && textNode.BeforeStartReferenceCount))
1064newFirstIMEVisibleNode = startPosition.GetAdjacentTextElementNodeSibling(LogicalDirection.Forward);
1286deletePosition = new TextPointer(startPosition, LogicalDirection.Forward);
1612if (!_rootNode.CaretUnitBoundaryCache && position.LogicalDirection == LogicalDirection.Backward)
1620TextPointer positionForwardGravity = position.GetPositionAtOffset(0, LogicalDirection.Forward);
1655startPosition = new TextPointer(this, _rootNode, ElementEdge.AfterStart, LogicalDirection.Backward);
1686endPosition = new TextPointer(this, _rootNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
2452node = startPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
2453stopNode = endPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
2808startPosition = new TextPointer(this, elementNode, ElementEdge.BeforeStart, LogicalDirection.Backward);
2813endPosition = new TextPointer(this, elementNode, ElementEdge.AfterEnd, LogicalDirection.Backward);
3438TextElement adjacentElement = startPosition.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
3441nextIMEVisibleNode = (TextTreeTextElementNode)endPosition.GetAdjacentSiblingNode(LogicalDirection.Forward);
src\Framework\System\windows\Documents\TextEditorSelection.cs (91)
136ITextPointer lineStart = position.CreatePointer(LogicalDirection.Forward);
138ITextPointer lineEnd = position.CreatePointer(LogicalDirection.Backward);
211LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
227LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
244LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
260LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
336ITextPointer nextPosition = lineEndPosition.GetNextInsertionPosition(LogicalDirection.Forward);
426ITextPointer previousPosition = lineStartPosition.GetNextInsertionPosition(LogicalDirection.Backward);
487if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Forward))
491This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
496This.Selection.SetCaretToPosition(paragraphRange.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
540This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
545if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Backward))
549This.Selection.SetCaretToPosition(paragraphRange.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
827ITextPointer caretPosition = lineRange.Start.GetFrozenPointer(LogicalDirection.Forward);
830This.Selection.SetCaretToPosition(caretPosition, LogicalDirection.Forward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
876LogicalDirection orientation = TextPointerBase.IsNextToPlainLineBreak(lineRange.End, LogicalDirection.Backward) ? LogicalDirection.Forward : LogicalDirection.Backward;
910This.Selection.SetCaretToPosition(This.TextContainer.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
939This.Selection.SetCaretToPosition(This.TextContainer.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
970LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
986LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
1002LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Backward : LogicalDirection.Forward;
1018LogicalDirection movementDirection = IsFlowDirectionRightToLeftThenTopToBottom(This) ? LogicalDirection.Forward : LogicalDirection.Backward;
1036if (This.Selection.ExtendToNextTableRow(LogicalDirection.Forward))
1094ITextPointer nextPosition = lineEndPosition.GetNextInsertionPosition(LogicalDirection.Forward);
1146if (TextPointerBase.IsNextToAnyBreak(newMovingPosition, LogicalDirection.Forward) ||
1147newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null)
1156newMovingPosition = newMovingPosition.GetInsertionPosition(LogicalDirection.Forward);
1157newMovingPosition = newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward);
1166newMovingPosition = newMovingPosition.GetFrozenPointer(LogicalDirection.Backward);
1184if (newMovingPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null)
1208if (This.Selection.ExtendToNextTableRow(LogicalDirection.Backward))
1284ITextPointer previousPosition = lineStartPosition.GetNextInsertionPosition(LogicalDirection.Backward);
1345if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Forward))
1393if (movingPointer.MoveToNextInsertionPosition(LogicalDirection.Backward))
1627ExtendSelectionAndBringIntoView(lineRange.Start.CreatePointer(LogicalDirection.Forward), This);
1679if (TextPointerBase.IsNextToPlainLineBreak(destination, LogicalDirection.Forward) ||
1680TextPointerBase.IsNextToRichLineBreak(destination, LogicalDirection.Forward))
1689destination = destination.GetNextInsertionPosition(LogicalDirection.Forward);
1693else if (TextPointerBase.IsNextToParagraphBreak(destination, LogicalDirection.Forward) &&
1694TextPointerBase.IsNextToParagraphBreak(This.Selection.AnchorPosition, LogicalDirection.Backward))
1698ITextPointer newDestination = destination.GetNextInsertionPosition(LogicalDirection.Forward);
1712destination = destination.GetFrozenPointer(LogicalDirection.Backward);
2061private static void MoveToCharacterLogicalDirection(TextEditor textEditor, LogicalDirection direction, bool extend)
2081ITextPointer movingEnd = (direction == LogicalDirection.Forward ? textEditor.Selection.End : textEditor.Selection.Start);
2091LogicalDirection contentDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
2122private static void NavigateWordLogicalDirection(TextEditor textEditor, LogicalDirection direction)
2139if (direction == LogicalDirection.Forward)
2142if (!textEditor.Selection.IsEmpty && TextPointerBase.IsAtWordBoundary(textEditor.Selection.End, LogicalDirection.Forward))
2145textEditor.Selection.SetCaretToPosition(textEditor.Selection.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2152TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Forward);
2154textEditor.Selection.SetCaretToPosition(wordBoundary, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2162if (!textEditor.Selection.IsEmpty && TextPointerBase.IsAtWordBoundary(textEditor.Selection.Start, LogicalDirection.Forward))
2165textEditor.Selection.SetCaretToPosition(textEditor.Selection.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2172TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Backward);
2174textEditor.Selection.SetCaretToPosition(wordBoundary, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2197private static void ExtendWordLogicalDirection(TextEditor textEditor, LogicalDirection direction)
2218wordBoundary.SetLogicalDirection(direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward);
2330movingPosition.LogicalDirection == LogicalDirection.Backward &&
2332TextPointerBase.IsNextToAnyBreak(movingPosition, LogicalDirection.Backward))
2334movingPosition = movingPosition.GetNextInsertionPosition(LogicalDirection.Backward);
2338if (TextPointerBase.IsNextToPlainLineBreak(movingPosition, LogicalDirection.Backward))
2340movingPosition = movingPosition.GetFrozenPointer(LogicalDirection.Forward);
2357return This.Selection.IsEmpty ? This.Selection.Start : This.Selection.Start.GetFrozenPointer(LogicalDirection.Forward);
2420ITextPointer position = This.Selection.Start.GetNextInsertionPosition(LogicalDirection.Backward);
2423This.Selection.SetCaretToPosition(position, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
2436ITextPointer cellEnd = position.GetNextInsertionPosition(LogicalDirection.Backward);
src\Framework\System\windows\Documents\TextEditorSpelling.cs (22)
39internal static SpellingError GetSpellingErrorAtPosition(TextEditor This, ITextPointer position, LogicalDirection direction)
62LogicalDirection direction = This.Selection.IsEmpty ? This.Selection.Start.LogicalDirection : LogicalDirection.Forward;
70direction = (direction == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward;
85direction = (direction == LogicalDirection.Forward) ? LogicalDirection.Backward : LogicalDirection.Forward;
90direction = LogicalDirection.Forward;
94direction = LogicalDirection.Backward;
104internal static ITextPointer GetNextSpellingErrorPosition(TextEditor This, ITextPointer position, LogicalDirection direction)
151caretPosition = textStart.CreatePointer(+correctedText.Length, LogicalDirection.Forward);
187textStart = spellingError.Start.CreatePointer(LogicalDirection.Backward);
189textStart.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text)
191textStart.MoveToNextContextPosition(LogicalDirection.Forward);
195textEnd.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text)
197textEnd.MoveToNextContextPosition(LogicalDirection.Backward);
200if (textStart.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text ||
205Invariant.Assert(textEnd.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
256private static ITextPointer GetNextTextPosition(ITextPointer position, ITextPointer limit, LogicalDirection direction, out char character)
319position = GetNextTextPosition(position, limit, LogicalDirection.Forward, out character);
src\Framework\System\windows\Documents\TextEditorTyping.cs (36)
568ITextPointer deletePosition = position.GetNextInsertionPosition(LogicalDirection.Forward);
591This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Forward);
645ITextPointer deletePosition = position.GetNextInsertionPosition(LogicalDirection.Backward);
670position = position.GetFrozenPointer(LogicalDirection.Backward);
677position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text)
699This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Backward);
707else if (backspacePosition.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text)
716This.Selection.ExtendToNextInsertionPosition(LogicalDirection.Backward);
748This.Selection.SetCaretToPosition(position, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/true);
764LogicalDirection directionOfDelete = position.CompareTo(deletePosition) < 0 ? LogicalDirection.Forward : LogicalDirection.Backward;
771if (directionOfDelete == LogicalDirection.Forward)
799if (directionOfDelete == LogicalDirection.Backward)
836position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
837position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
842while (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
849position = position.GetNextContextPosition(LogicalDirection.Backward);
850if (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
858position = position.GetNextContextPosition(LogicalDirection.Backward);
869if (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart)
875position.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.ElementEnd)
883while (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
890if (!(navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
939TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Forward);
998TextPointerBase.MoveToNextWordBoundary(wordBoundary, LogicalDirection.Backward);
1107This.Selection.SetCaretToPosition(This.Selection.End, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1198This.Selection.SetCaretToPosition(range.Start, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1370if (HandleTabInTables(This, LogicalDirection.Forward))
1402if (HandleTabInTables(This, LogicalDirection.Backward))
1423private static bool HandleTabInTables(TextEditor This, LogicalDirection direction)
1434This.Selection.SetCaretToPosition(This.Selection.Start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1447if (direction == LogicalDirection.Forward)
1484if (direction == LogicalDirection.Forward)
1582ITextPointer caretPosition = This.Selection.End.CreatePointer(LogicalDirection.Backward);
1585This.Selection.SetCaretToPosition(caretPosition, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
src\Framework\System\Windows\Documents\TextElement.cs (7)
308TextPointer contentStart = new TextPointer(tree, _textElementNode, ElementEdge.AfterStart, LogicalDirection.Backward);
311TextPointer contentEnd = new TextPointer(tree, _textElementNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
334elementStart = new TextPointer(tree, _textElementNode, ElementEdge.BeforeStart, LogicalDirection.Forward);
367contentStart = new TextPointer(tree, _textElementNode, ElementEdge.AfterStart, LogicalDirection.Backward);
400contentEnd = new TextPointer(tree, _textElementNode, ElementEdge.BeforeEnd, LogicalDirection.Forward);
441elementEnd = new TextPointer(tree, _textElementNode, ElementEdge.AfterEnd, LogicalDirection.Backward);
1054beforeStart = new TextPointer(tree, _textElementNode, ElementEdge.BeforeStart, LogicalDirection.Forward);
src\Framework\System\Windows\Documents\TextPointer.cs (91)
284internal TextPointer(TextPointer position, LogicalDirection direction)
290internal TextPointer(TextPointer position, int offset, LogicalDirection direction)
296internal TextPointer(TextContainer textContainer, int offset, LogicalDirection direction)
314Initialize(tree, node, edge, LogicalDirection.Forward, tree.PositionGeneration, false, false, tree.LayoutGeneration);
318internal TextPointer(TextContainer tree, TextTreeNode node, ElementEdge edge, LogicalDirection direction)
330internal TextPointer CreatePointer(LogicalDirection gravity)
512/// is <see cref="System.Windows.Documents.LogicalDirection.Backward"/>, or if it is positioned
514/// <see cref="System.Windows.Documents.LogicalDirection.Forward"/>.</para>
555public TextPointerContext GetPointerContext(LogicalDirection direction)
563return (direction == LogicalDirection.Forward) ? GetPointerContextForward(_node, this.Edge) : GetPointerContextBackward(_node, this.Edge);
577public int GetTextRunLength(LogicalDirection direction)
598if (direction == LogicalDirection.Forward)
614textNode = ((direction == LogicalDirection.Forward) ? textNode.GetNextNode() : textNode.GetPreviousNode()) as TextTreeTextNode;
748public string GetTextInRun(LogicalDirection direction)
786public int GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
820public DependencyObject GetAdjacentElement(LogicalDirection direction)
913public TextPointer GetPositionAtOffset(int offset, LogicalDirection direction)
1001public TextPointer GetNextContextPosition(LogicalDirection direction)
1074public TextPointer GetInsertionPosition(LogicalDirection direction)
1082return GetInsertionPosition(LogicalDirection.Forward);
1101/// "insertion position" in the <see cref="TextPointer.GetInsertionPosition(LogicalDirection)"/>
1141public TextPointer GetNextInsertionPosition(LogicalDirection direction)
1238position.SetLogicalDirection(LogicalDirection.Forward);
1259public Rect GetCharacterRect(LogicalDirection direction)
1344LogicalDirection direction = count < 0 ? LogicalDirection.Backward : LogicalDirection.Forward;
1549public LogicalDirection LogicalDirection
1629TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1633TextSchema.IsFormattingType(position.GetAdjacentElement(LogicalDirection.Backward).GetType()))
1635position.MoveToNextContextPosition(LogicalDirection.Backward);
1636backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1764internal static int GetTextInRun(TextContainer textContainer, int symbolOffset, TextTreeTextNode textNode, int nodeOffset, LogicalDirection direction, char[] textBuffer, int startIndex, int count)
1799skipCount = (direction == LogicalDirection.Forward) ? nodeOffset : textNode.SymbolCount - nodeOffset;
1816textNode = ((direction == LogicalDirection.Forward) ? textNode.GetNextNode() : textNode.GetPreviousNode()) as TextTreeTextNode;
1820if (direction == LogicalDirection.Backward)
1833internal static DependencyObject GetAdjacentElement(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
1989internal bool MoveToNextContextPosition(LogicalDirection direction)
2002if (direction == LogicalDirection.Forward)
2049internal bool MoveToInsertionPosition(LogicalDirection direction)
2092internal bool MoveToNextInsertionPosition(LogicalDirection direction)
2188internal TextElement GetAdjacentElementFromOuterPosition(LogicalDirection direction)
2206internal void SetLogicalDirection(LogicalDirection direction)
2359internal TextPointer GetFrozenPointer(LogicalDirection logicalDirection)
2368void ITextPointer.SetLogicalDirection(LogicalDirection direction)
2408TextPointerContext ITextPointer.GetPointerContext(LogicalDirection direction)
2413int ITextPointer.GetTextRunLength(LogicalDirection direction)
2419string ITextPointer.GetTextInRun(LogicalDirection direction)
2424int ITextPointer.GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count)
2429object ITextPointer.GetAdjacentElement(LogicalDirection direction)
2434Type ITextPointer.GetElementType(LogicalDirection direction)
2471ITextPointer ITextPointer.GetNextContextPosition(LogicalDirection direction)
2486ITextPointer ITextPointer.GetInsertionPosition(LogicalDirection direction)
2497ITextPointer ITextPointer.GetFormatNormalizedPosition(LogicalDirection direction)
2506ITextPointer ITextPointer.GetNextInsertionPosition(LogicalDirection direction)
2606ITextPointer ITextPointer.CreatePointer(LogicalDirection gravity)
2611ITextPointer ITextPointer.CreatePointer(int offset, LogicalDirection gravity)
2622ITextPointer ITextPointer.GetFrozenPointer(LogicalDirection logicalDirection)
2628bool ITextPointer.MoveToNextContextPosition(LogicalDirection direction)
2685Rect ITextPointer.GetCharacterRect(LogicalDirection direction)
2690bool ITextPointer.MoveToInsertionPosition(LogicalDirection direction)
2695bool ITextPointer.MoveToNextInsertionPosition(LogicalDirection direction)
2841internal TextTreeTextNode GetAdjacentTextNodeSibling(LogicalDirection direction)
2848internal static TextTreeTextNode GetAdjacentTextNodeSibling(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
2855internal TextTreeTextElementNode GetAdjacentTextElementNodeSibling(LogicalDirection direction)
2862internal TextTreeTextElementNode GetAdjacentTextElementNode(LogicalDirection direction)
2869internal TextTreeNode GetAdjacentSiblingNode(LogicalDirection direction)
2876internal static TextTreeNode GetAdjacentSiblingNode(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
2880if (direction == LogicalDirection.Forward)
3036if (GetGravityInternal() == LogicalDirection.Forward)
3467symbolType = node.GetPointerContext(LogicalDirection.Forward);
3474symbolType = firstContainedNode.GetPointerContext(LogicalDirection.Forward);
3492symbolType = nextNode.GetPointerContext(LogicalDirection.Forward);
3524symbolType = previousNode.GetPointerContext(LogicalDirection.Backward);
3544symbolType = lastChildNode.GetPointerContext(LogicalDirection.Backward);
3553symbolType = node.GetPointerContext(LogicalDirection.Backward);
3704LogicalDirection ITextPointer.LogicalDirection
3919private void InitializeOffset(TextPointer position, int distance, LogicalDirection direction)
3956private void Initialize(TextContainer tree, TextTreeNode node, ElementEdge edge, LogicalDirection gravity, uint generation,
4016private static void RepositionForGravity(ref TextTreeNode node, ref ElementEdge edge, LogicalDirection gravity)
4027if (gravity == LogicalDirection.Backward)
4040if (gravity == LogicalDirection.Forward)
4053if (gravity == LogicalDirection.Backward)
4066if (gravity == LogicalDirection.Forward)
4084private LogicalDirection GetGravityInternal()
4086return (this.Edge == ElementEdge.BeforeStart || this.Edge == ElementEdge.BeforeEnd) ? LogicalDirection.Forward : LogicalDirection.Backward;
4099internal TextTreeNode GetAdjacentNode(LogicalDirection direction)
4104internal static TextTreeNode GetAdjacentNode(TextTreeNode node, ElementEdge edge, LogicalDirection direction)
4148private TextElement GetElement(LogicalDirection direction)
4167if (GetGravityInternal() == LogicalDirection.Forward)
src\Framework\System\Windows\Documents\TextPointerBase.cs (111)
60internal static string GetTextInRun(ITextPointer position, LogicalDirection direction)
78internal static int GetTextWithLimit(ITextPointer thisPointer, LogicalDirection direction, char[] textBuffer, int startIndex, int count, ITextPointer limit)
87else if (direction == LogicalDirection.Forward && limit.CompareTo(thisPointer) <= 0)
92else if (direction == LogicalDirection.Backward && limit.CompareTo(thisPointer) >= 0)
104if (direction == LogicalDirection.Forward)
186Type forwardType = forwardPosition.GetElementType(LogicalDirection.Forward);
187Type backwardType = backwardPosition.GetElementType(LogicalDirection.Backward);
190TextPointerContext forwardContext = forwardPosition.GetPointerContext(LogicalDirection.Forward);
191TextPointerContext backwardContext = backwardPosition.GetPointerContext(LogicalDirection.Backward);
232TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
233TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
256TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
257TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
261typeof(Table).IsAssignableFrom(position.GetElementType(LogicalDirection.Forward)));
274position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart;
280position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd;
325BorderingElementCategory category = GetBorderingElementCategory(navigator, LogicalDirection.Forward);
332navigator.MoveToNextContextPosition(LogicalDirection.Forward);
334while (GetBorderingElementCategory(navigator, LogicalDirection.Forward) == BorderingElementCategory.MergeableScopingInline);
340elementType = navigator.GetElementType(LogicalDirection.Forward);
344navigator.MoveToNextContextPosition(LogicalDirection.Forward);
361elementType = navigator.GetElementType(LogicalDirection.Forward);
364navigator.MoveToNextInsertionPosition(LogicalDirection.Forward);
377navigator.MoveToNextContextPosition(LogicalDirection.Forward);
379while (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
390return IsAtNonMergeableInlineEdge(position, LogicalDirection.Backward);
396return IsAtNonMergeableInlineEdge(position, LogicalDirection.Forward);
406internal static bool IsAtFormatNormalizedPosition(ITextPointer position, LogicalDirection direction)
411internal static bool IsAtInsertionPosition(ITextPointer position, LogicalDirection direction)
416internal static bool IsAtNormalizedPosition(ITextPointer position, LogicalDirection direction, bool respectCaretUnitBoundaries)
425if (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
426position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
471internal static bool IsAtWordBoundary(ITextPointer thisPosition, LogicalDirection insideWordDirection)
514return GetWordRange(thisPosition, LogicalDirection.Forward);
526internal static TextSegment GetWordRange(ITextPointer thisPosition, LogicalDirection direction)
549if (moved && IsAtWordBoundary(thisPosition, /*insideWordDirection:*/LogicalDirection.Forward))
556MoveToNextWordBoundary(navigator, direction == LogicalDirection.Backward ? LogicalDirection.Forward : LogicalDirection.Backward);
560if (direction == LogicalDirection.Backward)
569wordStart = RestrictWithinBlock(thisPosition, wordStart, LogicalDirection.Backward);
570wordEnd = RestrictWithinBlock(thisPosition, wordEnd, LogicalDirection.Forward);
575wordStart = wordStart.GetFrozenPointer(LogicalDirection.Backward);
576wordEnd = wordEnd.GetFrozenPointer(LogicalDirection.Forward);
580wordStart = wordEnd.GetFrozenPointer(LogicalDirection.Backward);
588private static ITextPointer RestrictWithinBlock(ITextPointer position, ITextPointer limit, LogicalDirection direction)
590Invariant.Assert(!(direction == LogicalDirection.Backward) || position.CompareTo(limit) >= 0, "for backward direction position must be >= than limit");
591Invariant.Assert(!(direction == LogicalDirection.Forward) || position.CompareTo(limit) <= 0, "for forward direcion position must be <= than linit");
593while (direction == LogicalDirection.Backward ? position.CompareTo(limit) > 0 : position.CompareTo(limit) < 0)
614return limit.GetInsertionPosition(direction == LogicalDirection.Backward ? LogicalDirection.Forward : LogicalDirection.Backward);
623internal static bool IsNextToPlainLineBreak(ITextPointer thisPosition, LogicalDirection direction)
633(direction == LogicalDirection.Backward && IsCharUnicodeNewLine(textBuffer[1]))
635(direction == LogicalDirection.Forward && IsCharUnicodeNewLine(textBuffer[0]))
654internal static bool IsNextToRichLineBreak(ITextPointer thisPosition, LogicalDirection direction)
663internal static bool IsNextToParagraphBreak(ITextPointer thisPosition, LogicalDirection direction)
674internal static bool IsNextToAnyBreak(ITextPointer thisPosition, LogicalDirection direction)
704bool isAtLineWrappingPosition = position.LogicalDirection == LogicalDirection.Forward
719thisPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd &&
720thisPosition.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart;
730return thisPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.None &&
731thisPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd &&
732!typeof(Inline).IsAssignableFrom(thisPosition.GetElementType(LogicalDirection.Backward));
746while (pointer.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
752pointer = pointer.GetNextContextPosition(LogicalDirection.Backward);
784paragraphOrBlockUIContainer.ElementStart.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
861internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection direction)
867internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection direction, bool transformToUiScope)
928internal static bool MoveToFormatNormalizedPosition(ITextPointer thisNavigator, LogicalDirection direction)
941internal static bool MoveToInsertionPosition(ITextPointer thisNavigator, LogicalDirection direction)
964internal static bool MoveToNextInsertionPosition(ITextPointer thisNavigator, LogicalDirection direction)
970int increment = direction == LogicalDirection.Forward ? +1 : -1;
987if ((direction == LogicalDirection.Forward && initialPosition.CompareTo(thisNavigator) < 0) ||
988(direction == LogicalDirection.Backward && thisNavigator.CompareTo(initialPosition) < 0))
1018if (direction == LogicalDirection.Backward)
1031while (TextSchema.IsFormattingType(thisNavigator.GetElementType(LogicalDirection.Forward))
1042if (direction == LogicalDirection.Forward)
1072internal static bool MoveToNextWordBoundary(ITextPointer thisNavigator, LogicalDirection movingDirection)
1093if (IsAtWordBoundary(thisNavigator, /*insideWordDirection:*/LogicalDirection.Forward))
1104internal static ITextPointer GetFrozenPointer(ITextPointer thisPointer, LogicalDirection logicalDirection)
1143private static bool NormalizePosition(ITextPointer thisNavigator, LogicalDirection direction, bool respectCaretUnitBoundaries)
1149LogicalDirection oppositeDirection;
1153if (direction == LogicalDirection.Forward)
1156oppositeDirection = LogicalDirection.Backward;
1163oppositeDirection = LogicalDirection.Forward;
1259private static int LeaveNonMergeableInlineBoundary(ITextPointer thisNavigator, LogicalDirection direction, int symbolCount)
1263if (direction == LogicalDirection.Forward && IsAtNonMergeableInlineEnd(thisNavigator))
1265symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Forward);
1269symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Backward);
1274if (direction == LogicalDirection.Backward && IsAtNonMergeableInlineStart(thisNavigator))
1276symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Backward);
1280symbolCount += LeaveNonMergeableAncestor(thisNavigator, LogicalDirection.Forward);
1288private static int LeaveNonMergeableAncestor(ITextPointer thisNavigator, LogicalDirection direction)
1291int increment = (direction == LogicalDirection.Forward) ? +1 : -1;
1336TextPointerContext forwardContext = position.GetPointerContext(LogicalDirection.Forward);
1337TextPointerContext backwardContext = position.GetPointerContext(LogicalDirection.Backward);
1372if (position.GetTextInRun(LogicalDirection.Backward, neighborhood, 0, 1) == 1 &&
1373position.GetTextInRun(LogicalDirection.Forward, neighborhood, 1, 1) == 1)
1431runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Backward), SelectionWordBreaker.MinContextLength - preceedingCount);
1435navigator.GetTextInRun(LogicalDirection.Forward, preceedingText, SelectionWordBreaker.MinContextLength - preceedingCount, runLength);
1441navigator.MoveToInsertionPosition(LogicalDirection.Backward);
1443while (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text);
1450runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Forward), SelectionWordBreaker.MinContextLength - followingCount);
1452navigator.GetTextInRun(LogicalDirection.Forward, followingText, followingCount, runLength);
1461navigator.MoveToInsertionPosition(LogicalDirection.Forward);
1463while (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text);
1474private static bool IsAtNonMergeableInlineEdge(ITextPointer position, LogicalDirection direction)
1494private static BorderingElementCategory GetBorderingElementCategory(ITextPointer position, LogicalDirection direction)
1496TextPointerContext context = (direction == LogicalDirection.Forward) ? TextPointerContext.ElementEnd : TextPointerContext.ElementStart;
1520private static bool IsNextToRichBreak(ITextPointer thisPosition, LogicalDirection direction, Type lineBreakType)
src\Framework\System\Windows\Documents\TextRangeBase.cs (68)
82textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Forward);
86textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Backward);
203normalizedPosition.MoveToInsertionPosition(LogicalDirection.Backward);
218!TextPointerBase.IsAtWordBoundary(thisRange.Start, LogicalDirection.Forward) && //
219!TextPointerBase.IsAtWordBoundary(thisRange.Start, LogicalDirection.Backward))
297!TextPointerBase.IsNextToAnyBreak(thisRange.End, LogicalDirection.Forward))
303nextPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
316(TextPointerBase.IsNextToAnyBreak(thisRange.End, LogicalDirection.Backward) ||
319ITextPointer newEnd = thisRange.End.GetNextInsertionPosition(LogicalDirection.Backward);
347SkipParagraphContent(start, LogicalDirection.Backward);
348SkipParagraphContent(end, LogicalDirection.Forward);
355private static void SkipParagraphContent(ITextPointer navigator, LogicalDirection direction)
364(nextContext == TextPointerContext.ElementStart && direction == LogicalDirection.Forward || //
365nextContext == TextPointerContext.ElementEnd && direction == LogicalDirection.Backward) && //
369(nextContext == TextPointerContext.ElementEnd && direction == LogicalDirection.Forward || //
370nextContext == TextPointerContext.ElementStart && direction == LogicalDirection.Backward) && //
425if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
427moved = position.MoveToNextContextPosition(LogicalDirection.Forward);
431moved = position.MoveToInsertionPosition(LogicalDirection.Forward);
436moved = position.MoveToNextInsertionPosition(LogicalDirection.Forward);
486position.MoveToNextContextPosition(LogicalDirection.Backward)) ;
507moved = position.MoveToNextContextPosition(LogicalDirection.Forward);
530endNavigator.MoveToInsertionPosition(LogicalDirection.Backward);
692TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
708navigator.MoveToNextContextPosition(LogicalDirection.Forward);
718navigator.MoveToNextContextPosition(LogicalDirection.Forward);
723navigator.MoveToNextContextPosition(LogicalDirection.Forward);
726elementType = navigator.GetElementType(LogicalDirection.Forward);
746navigator.MoveToNextContextPosition(LogicalDirection.Forward);
762int runLength = navigator.GetTextRunLength(LogicalDirection.Forward);
764runLength = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, charArray, 0, runLength, endPosition);
766navigator.MoveToNextContextPosition(LogicalDirection.Forward);
776bool theParagraphIsTheFirstInCollection = navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart;
777navigator.MoveToNextContextPosition(LogicalDirection.Forward);
779TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
786navigator.MoveToNextContextPosition(LogicalDirection.Forward);
787symbolType = navigator.GetPointerContext(LogicalDirection.Forward);
810List list = (List)navigator.GetAdjacentElement(LogicalDirection.Forward);
831navigator.MoveToNextContextPosition(LogicalDirection.Forward);
841ListItem listItem = (ListItem)navigator.GetAdjacentElement(LogicalDirection.Forward);
873object element = navigator.GetAdjacentElement(LogicalDirection.Forward);
1265while (start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1269start = start.GetNextContextPosition(LogicalDirection.Backward);
1328if (thisRange.Start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
1329thisRange.End.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
1375(insertPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.None ||
1376insertPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) &&
1377(insertPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.None ||
1378insertPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd);
1389ITextPointer newStart = insertPosition.GetFrozenPointer(LogicalDirection.Backward);
1390ITextPointer newEnd = insertPosition.CreatePointer(LogicalDirection.Forward);
1395TextPointer insertionPosition = (TextPointer)newStart.CreatePointer(LogicalDirection.Forward);
1433newEnd = newEnd.GetNextInsertionPosition(LogicalDirection.Forward);
1648TextPointerContext context = start.GetPointerContext(LogicalDirection.Forward);
1651start.MoveToNextContextPosition(LogicalDirection.Forward);
1652context = start.GetPointerContext(LogicalDirection.Forward);
1657context = end.GetPointerContext(LogicalDirection.Backward);
1660end.MoveToNextContextPosition(LogicalDirection.Backward);
1661context = end.GetPointerContext(LogicalDirection.Backward);
1665return start.GetAdjacentElement(LogicalDirection.Forward) as UIElement;
1746start = GetNormalizedPosition(thisRange, start, LogicalDirection.Forward);
1753end = GetNormalizedPosition(thisRange, end, LogicalDirection.Backward);
1760if (start.LogicalDirection == LogicalDirection.Backward)
1763start = end.GetFrozenPointer(LogicalDirection.Backward);
1815private static bool IsAtNormalizedPosition(ITextRange thisRange, ITextPointer position, LogicalDirection direction)
1831private static ITextPointer GetNormalizedPosition(ITextRange thisRange, ITextPointer position, LogicalDirection direction)
1989!TextPointerBase.IsAtInsertionPosition(start, LogicalDirection.Forward) ||
1990!TextPointerBase.IsAtInsertionPosition(end, LogicalDirection.Backward))
src\Framework\System\Windows\Documents\TextRangeSerialization.cs (54)
84range.End.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.ElementStart;
217while (rangeEnd.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
219rangeEnd = rangeEnd.GetNextContextPosition(LogicalDirection.Backward);
225TextPointerContext runType = textReader.GetPointerContext(LogicalDirection.Forward);
230TextElement nextElement = (TextElement)textReader.GetAdjacentElement(LogicalDirection.Forward);
239textReader.MoveToNextContextPosition(LogicalDirection.Forward);
259textReader.MoveToNextContextPosition(LogicalDirection.Forward);
267textReader.MoveToNextContextPosition(LogicalDirection.Forward);
277if (ignoreWriteHyperlinkEnd && (textReader.GetAdjacentElement(LogicalDirection.Forward) is Hyperlink))
281textReader.MoveToNextContextPosition(LogicalDirection.Forward);
294textReader.MoveToNextContextPosition(LogicalDirection.Forward);
311textReader.MoveToNextContextPosition(LogicalDirection.Forward);
315int textLength = textReader.GetTextRunLength(LogicalDirection.Forward);
318textLength = TextPointerBase.GetTextWithLimit(textReader, LogicalDirection.Forward, text, 0, textLength, rangeEnd);
325textReader.MoveToNextContextPosition(LogicalDirection.Forward);
329object embeddedObject = textReader.GetAdjacentElement(LogicalDirection.Forward);
330textReader.MoveToNextContextPosition(LogicalDirection.Forward);
337textReader.MoveToNextContextPosition(LogicalDirection.Forward);
558InlineUIContainer inlineUIContainer = textReader.GetAdjacentElement(LogicalDirection.Backward) as InlineUIContainer;
559BlockUIContainer blockUIContainer = textReader.GetAdjacentElement(LogicalDirection.Backward) as BlockUIContainer;
1256TextElement uiContainer = fragment.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
1362fragmentEnd = fragment.ElementEnd.GetPositionAtOffset(0, LogicalDirection.Forward); // need forward orientation to stick with the following content during merge at fragmentStart position
1390fragmentEnd = fragmentEnd.GetInsertionPosition(LogicalDirection.Forward);
1444while (positionBeforeParagraph.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1447positionBeforeParagraph = positionBeforeParagraph.GetNextContextPosition(LogicalDirection.Backward);
1449while (positionBeforeParagraph.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
1453positionBeforeParagraph = positionBeforeParagraph.GetNextContextPosition(LogicalDirection.Backward);
1487if (navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd)
1489navigator = navigator.GetNextContextPosition(LogicalDirection.Backward);
1505if (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
1507navigator = navigator.GetNextContextPosition(LogicalDirection.Forward);
1542TextPointerContext forwardFromStart = start.GetPointerContext(LogicalDirection.Forward);
1543TextPointerContext backwardFromEnd = end.GetPointerContext(LogicalDirection.Backward);
1546Invariant.Assert(itemType.IsAssignableFrom(start.GetAdjacentElement(LogicalDirection.Forward).GetType()), "The first pasted fragment item is expected to be a " + itemType.Name);
1547Invariant.Assert(itemType.IsAssignableFrom(end.GetAdjacentElement(LogicalDirection.Backward).GetType()), "The last pasted fragment item is expected to be a " + itemType.Name);
1550TextPointerContext backwardFromStart = start.GetPointerContext(LogicalDirection.Backward);
1551TextPointerContext forwardFromEnd = end.GetPointerContext(LogicalDirection.Forward);
1553Invariant.Assert(!(backwardFromStart == TextPointerContext.ElementEnd) || itemType.IsAssignableFrom(start.GetAdjacentElement(LogicalDirection.Backward).GetType()), "An element preceding a pasted fragment is expected to be a " + itemType.Name);
1555Invariant.Assert(!(forwardFromEnd == TextPointerContext.ElementStart) || itemType.IsAssignableFrom(end.GetAdjacentElement(LogicalDirection.Forward).GetType()), "An element following a pasted fragment is expected to be a " + itemType.Name);
1576((Section)fragment).HasTrailingParagraphBreakOnPaste = range.End.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.None;
1632start = start.GetNextContextPosition(LogicalDirection.Forward);
1636TextPointerContext passedContext = start.GetPointerContext(LogicalDirection.Backward);
1676start = start.GetNextContextPosition(LogicalDirection.Forward);
1683start = start.GetNextContextPosition(LogicalDirection.Forward);
1873Invariant.Assert(textReader.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
1878elementEnd.MoveToNextContextPosition(LogicalDirection.Forward);
1900Invariant.Assert(textReader.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
1901Invariant.Assert(typeof(Hyperlink).IsAssignableFrom(textReader.GetElementType(LogicalDirection.Forward)));
1906Hyperlink hyperlink = (Hyperlink)textReader.GetAdjacentElement(LogicalDirection.Forward);
1911hyperlinkEnd.MoveToNextContextPosition(LogicalDirection.Forward);
1926InlineUIContainer inlineUIContainer = hyperlinkNavigation.GetAdjacentElement(LogicalDirection.Forward) as InlineUIContainer;
1933hyperlinkNavigation.MoveToNextContextPosition(LogicalDirection.Forward);
1948hyperlinkStart = range.Start.CreatePointer(LogicalDirection.Forward);
1949while (hyperlinkStart.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart &&
src\Framework\System\windows\Documents\TextSelection.cs (64)
306((ITextSelection)this).SetCaretToPosition(((ITextRange)this).End, LogicalDirection.Forward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
457void ITextSelection.SetCaretToPosition(ITextPointer caretPosition, LogicalDirection direction, bool allowStopAtLineEnd, bool allowStopNearSpace)
472ITextPointer reversePosition = caretPosition.CreatePointer(direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward);
478TextPointerBase.IsNextToPlainLineBreak(caretPosition, LogicalDirection.Backward) ||
479TextSchema.IsBreak(caretPosition.GetElementType(LogicalDirection.Backward))))
483caretPosition.SetLogicalDirection(LogicalDirection.Forward);
487if (caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text &&
488caretPosition.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
510LogicalDirection oppositeDirection = direction == LogicalDirection.Forward ? LogicalDirection.Backward : LogicalDirection.Forward;
587bool ITextSelection.ExtendToNextInsertionPosition(LogicalDirection direction)
622if (newMovingPosition == null && direction == LogicalDirection.Forward)
642LogicalDirection contentDirection = (anchorPosition.CompareTo(newMovingPosition) <= 0) ?
643LogicalDirection.Backward : LogicalDirection.Forward;
659private ITextPointer GetNextTextSegmentInsertionPosition(LogicalDirection direction)
846startPosition = anchorWordRange.Start.GetFrozenPointer(LogicalDirection.Forward);
847movingPosition = cursorWordRange.End.GetFrozenPointer(LogicalDirection.Backward); ;
851startPosition = anchorWordRange.End.GetFrozenPointer(LogicalDirection.Backward);
852movingPosition = cursorWordRange.Start.GetFrozenPointer(LogicalDirection.Forward); ;
968anchorWordRange.Contains(cursorPosition.GetInsertionPosition(LogicalDirection.Forward)) ||
969anchorWordRange.Contains(cursorPosition.GetInsertionPosition(LogicalDirection.Backward)))
981TextPointerBase.IsAtWordBoundary(anchorPosition, /*insideWordDirection:*/LogicalDirection.Forward))
995TextPointerBase.IsAtWordBoundary(cursorPosition, /*insideWordDirection:*/LogicalDirection.Forward))
1030bool ITextSelection.ExtendToNextTableRow(LogicalDirection direction)
1058if (direction == LogicalDirection.Forward)
1087movingPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
1187internal void SetCaretToPosition(TextPointer caretPosition, LogicalDirection direction, bool allowStopAtLineEnd, bool allowStopNearSpace)
1195internal bool ExtendToNextInsertionPosition(LogicalDirection direction)
1392this.SetCaretToPosition(cellStart, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false);
1556Invariant.Assert(this.Start.LogicalDirection == LogicalDirection.Backward);
1557Invariant.Assert(this.End.LogicalDirection == LogicalDirection.Forward);
1767return (This.Start.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text &&
1768This.End.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text &&
1769This.Start.GetNextInsertionPosition(LogicalDirection.Backward) == null &&
1770This.End.GetNextInsertionPosition(LogicalDirection.Forward) == null);
2005(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X < cursorMousePoint.X ||
2006cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X < objectEdgeRect.X))
2011(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X > cursorMousePoint.X ||
2012cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X > objectEdgeRect.X))
2020(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X > cursorMousePoint.X ||
2021cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X > objectEdgeRect.X))
2026(cursorPosition.LogicalDirection == LogicalDirection.Forward && objectEdgeRect.X < cursorMousePoint.X ||
2027cursorPosition.LogicalDirection == LogicalDirection.Backward && cursorMousePoint.X < objectEdgeRect.X))
2189if ((caretPosition.LogicalDirection == LogicalDirection.Backward && //
2190caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) || //
2197caretPosition.MoveToNextInsertionPosition(LogicalDirection.Backward);
2198caretPosition.SetLogicalDirection(LogicalDirection.Forward);
2206if (caretPosition.LogicalDirection == LogicalDirection.Backward && //
2207caretPosition.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart && //
2208(caretPosition.GetNextInsertionPosition(LogicalDirection.Backward) == null || //
2209TextPointerBase.IsNextToAnyBreak(caretPosition, LogicalDirection.Backward)))
2212caretPosition.SetLogicalDirection(LogicalDirection.Forward);
2286nextCharacterPosition = focusedTextSelection.Start.CreatePointer(LogicalDirection.Forward);
2291nextCharacterPosition.MoveToNextInsertionPosition(LogicalDirection.Forward);
2292nextCharacterPosition.SetLogicalDirection(LogicalDirection.Backward);
2300nextCharacterPosition = focusedTextSelection.End.CreatePointer(LogicalDirection.Backward);
2305nextCharacterPosition.MoveToNextInsertionPosition(LogicalDirection.Backward);
2306nextCharacterPosition.SetLogicalDirection(LogicalDirection.Forward);
2771private LogicalDirection _movingPositionDirection;
src\Framework\System\Windows\Documents\TextStore.cs (73)
271this.TextSelection.SetCaretToPosition(start, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
311navigator = CreatePointerAtCharOffset(startIndex, LogicalDirection.Forward);
312limit = (endIndex >= 0) ? CreatePointerAtCharOffset(endIndex, LogicalDirection.Forward) : null;
319TextPointerContext context = navigator.GetPointerContext(LogicalDirection.Forward);
333TextElement element = (TextElement)((TextPointer)navigator).GetAdjacentElement(LogicalDirection.Forward);
342navigator.MoveToNextContextPosition(LogicalDirection.Forward);
348navigator.MoveToNextContextPosition(LogicalDirection.Forward);
381start = start.GetNextInsertionPosition(LogicalDirection.Forward);
564startNavigator.SetLogicalDirection(LogicalDirection.Backward);
566endNavigator.SetLogicalDirection(LogicalDirection.Forward);
739position = CreatePointerAtCharOffset(index, LogicalDirection.Forward);
861ITextPointer positionCur = position.CreatePointer(LogicalDirection.Backward);
862ITextPointer positionPrev = position.CreatePointer(LogicalDirection.Forward);
863positionPrev.MoveToNextInsertionPosition(LogicalDirection.Backward);
921startPointer = CreatePointerAtCharOffset(startIndex, LogicalDirection.Forward);
922startPointer.MoveToInsertionPosition(LogicalDirection.Forward);
932Rect rectStart = startPointer.GetCharacterRect(LogicalDirection.Forward);
940endPointer = CreatePointerAtCharOffset(endIndex, LogicalDirection.Backward);
941endPointer.MoveToInsertionPosition(LogicalDirection.Backward);
963lineRect = navigator.GetCharacterRect(LogicalDirection.Forward);
964moved = navigator.MoveToNextInsertionPosition(LogicalDirection.Forward);
1362navigator.MoveToInsertionPosition(LogicalDirection.Forward);
1367if (navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
1373navigator.GetTextInRun(LogicalDirection.Forward, nextChars, 0, nextChars.Length);
1379TextSelection.ExtendToNextInsertionPosition(LogicalDirection.Forward);
1797internal ITextPointer CreatePointerAtCharOffset(int charOffset, LogicalDirection direction)
1900this.TextSelection.SetCaretToPosition(range.End, LogicalDirection.Backward, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true);
2261_previousCompositionStart = (_previousCompositionStartOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionStartOffset, LogicalDirection.Backward);
2262_previousCompositionEnd = (_previousCompositionEndOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionEndOffset, LogicalDirection.Forward);
2280_previousCompositionStart = (_previousCompositionStartOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionStartOffset, LogicalDirection.Backward);
2281_previousCompositionEnd = (_previousCompositionEndOffset == -1) ? null : textEditor.TextContainer.CreatePointerAtOffset(_previousCompositionEndOffset, LogicalDirection.Forward);
2318Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text);
2325runCount = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, text, charsCopied, Math.Min(cchReq, text.Length - charsCopied), limit);
2334runCount = navigator.GetTextRunLength(LogicalDirection.Forward);
2335navigator.MoveToNextContextPosition(LogicalDirection.Forward);
2377Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement);
2387navigator.MoveToNextContextPosition(LogicalDirection.Forward);
2419Invariant.Assert(navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart || navigator.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd);
2437char ch = (navigator.GetAdjacentElement(LogicalDirection.Forward) is TableCell) ? UnsafeNativeMethods.TS_CHAR_REGION : '\n';
2802start = CreatePointerAtCharOffset(startIndex, LogicalDirection.Backward);
2803end = CreatePointerAtCharOffset(startIndex + length, LogicalDirection.Forward);
2805while (start.CompareTo(end) < 0 && start.GetPointerContext(LogicalDirection.Forward) != TextPointerContext.Text)
2807start.MoveToNextContextPosition(LogicalDirection.Forward);
2949positionNext.MoveToNextInsertionPosition(LogicalDirection.Forward);
2953positionNext.MoveToNextInsertionPosition(LogicalDirection.Backward);
3093Rect lineBounds = start.GetCharacterRect(LogicalDirection.Forward);
3094lineBounds.Union(end.GetCharacterRect(LogicalDirection.Backward));
3097ITextPointer navigator = start.CreatePointer(LogicalDirection.Forward);
3098while (navigator.MoveToNextContextPosition(LogicalDirection.Forward) == true && navigator.CompareTo(end) < 0)
3100TextPointerContext context = navigator.GetPointerContext(LogicalDirection.Backward);
3104lineBounds.Union(navigator.GetCharacterRect(LogicalDirection.Backward));
3109lineBounds.Union(navigator.GetCharacterRect(LogicalDirection.Backward));
3340TextPointer previousPosition = start.GetNextInsertionPosition(LogicalDirection.Backward);
3353if (start.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
3355start = start.GetNextInsertionPosition(LogicalDirection.Backward);
3359start = start.GetNextInsertionPosition(LogicalDirection.Forward);
3367start = start.GetNextInsertionPosition(LogicalDirection.Forward);
3387start = CreatePointerAtCharOffset(startCharOffset, LogicalDirection.Forward);
3388end = (startCharOffset == endCharOffset) ? start : CreatePointerAtCharOffset(endCharOffset, LogicalDirection.Backward);
3393TextPointerContext forwardContext = start.GetPointerContext(LogicalDirection.Forward);
3397TextElement element = start.GetAdjacentElement(LogicalDirection.Forward) as TextElement;
3409start.MoveToNextContextPosition(LogicalDirection.Forward);
3420start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
3425start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
3426end = end.GetFormatNormalizedPosition(LogicalDirection.Backward);
3548ITextPointer start = this.TextContainer.CreatePointerAtOffset(record.StartOffsetBefore, LogicalDirection.Backward);
3549ITextPointer end = this.TextContainer.CreatePointerAtOffset(record.EndOffsetBefore, LogicalDirection.Forward);
3669start = end.GetFrozenPointer(LogicalDirection.Backward);
3808ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(appSelectionAnchorOffset, LogicalDirection.Forward);
3809ITextPointer moving = this.TextContainer.CreatePointerAtOffset(appSelectionMovingOffset, LogicalDirection.Forward);
3829ITextPointer anchor = this.TextContainer.CreatePointerAtOffset(imeSelectionAnchorOffset, LogicalDirection.Backward);
3830ITextPointer moving = this.TextContainer.CreatePointerAtOffset(imeSelectionMovingOffset, LogicalDirection.Backward);