// Token: 0x060035AE RID: 13742 RVA: 0x000F3B04 File Offset: 0x000F1D04 private int FindIndex(StaticTextPointer position, LogicalDirection direction) { int num = -1; int i = 0; int num2 = this._runList.Count; while (i < num2) { num = (i + num2) / 2; SpellerStatusTable.Run run = this.GetRun(num); if ((direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0) || (direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0)) { num2 = num; } else { if ((direction != LogicalDirection.Forward || position.CompareTo(this.GetRunEndPosition(num)) < 0) && (direction != LogicalDirection.Backward || position.CompareTo(this.GetRunEndPosition(num)) <= 0)) { break; } i = num + 1; } } if (i >= num2) { num = -1; } return(num); }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; AttributeRange attributeRange; int i; transitionPosition = StaticTextPointer.Null; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } } } } return(transitionPosition); }
// Returns the AttributeRange covering specified content, or null // if no such range exists. private AttributeRange GetRangeAtPosition(StaticTextPointer textPosition, LogicalDirection direction) { int i; AttributeRange attributeRange; AttributeRange attributeRangeAtPosition; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. attributeRangeAtPosition = null; if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { attributeRangeAtPosition = attributeRange; break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { attributeRangeAtPosition = attributeRange; break; } } } } return(attributeRangeAtPosition); }
// Token: 0x06003C67 RID: 15463 RVA: 0x0011732C File Offset: 0x0011552C internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer result = StaticTextPointer.Null; if (!this.IsTextRangeEmpty(this._selection) && !this._selection.IsInterimSelection) { List <TextSegment> textSegments = this._selection.TextSegments; int count = textSegments.Count; if (direction == LogicalDirection.Forward) { for (int i = 0; i < count; i++) { TextSegment textSegment = textSegments[i]; if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.Start) < 0) { result = textSegment.Start.CreateStaticPointer(); break; } if (textPosition.CompareTo(textSegment.End) < 0) { result = textSegment.End.CreateStaticPointer(); break; } } } } else { for (int j = count - 1; j >= 0; j--) { TextSegment textSegment = textSegments[j]; if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.End) > 0) { result = textSegment.End.CreateStaticPointer(); break; } if (textPosition.CompareTo(textSegment.Start) > 0) { result = textSegment.Start.CreateStaticPointer(); break; } } } } } return(result); }
// Finds the index of a run containing the specified content. // Returns -1 if there is no run in the indicated direction -- when // position is at the document edge pointing to nothing. private int FindIndex(StaticTextPointer position, LogicalDirection direction) { Run run; int index; int minIndex; int maxIndex; index = -1; minIndex = 0; maxIndex = _runList.Count; while (minIndex < maxIndex) { index = (minIndex + maxIndex) / 2; run = GetRun(index); if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 || direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0) { // Search to the left. maxIndex = index; } else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 || direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0) { // Search to the right. minIndex = index + 1; } else { // Got a match. break; } } if (minIndex >= maxIndex) { // We walked off the document edge searching. // position is at document start or end, and direction // points off into space, so there's no associated run. index = -1; } return(index); }
// Token: 0x060035AA RID: 13738 RVA: 0x000F3964 File Offset: 0x000F1B64 internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer staticTextPointer = StaticTextPointer.Null; int num = this.FindIndex(textPosition, direction); if (num != -1) { if (direction == LogicalDirection.Forward) { if (this.IsErrorRun(num)) { staticTextPointer = this.GetRunEndPosition(num); } else { for (int i = num + 1; i < this._runList.Count; i++) { if (this.IsErrorRun(i)) { staticTextPointer = this.GetRun(i).Position.CreateStaticPointer(); break; } } } } else if (this.IsErrorRun(num)) { staticTextPointer = this.GetRun(num).Position.CreateStaticPointer(); } else { for (int i = num - 1; i > 0; i--) { if (this.IsErrorRun(i)) { staticTextPointer = this.GetRunEndPosition(i); break; } } } } Invariant.Assert(staticTextPointer.IsNull || textPosition.CompareTo(staticTextPointer) != 0); return(staticTextPointer); }
// Token: 0x06003007 RID: 12295 RVA: 0x000D8070 File Offset: 0x000D6270 internal virtual StaticTextPointer GetNextPropertyChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer staticTextPointer; switch (textPosition.GetPointerContext(direction)) { case TextPointerContext.None: return(StaticTextPointer.Null); case TextPointerContext.Text: { staticTextPointer = this.GetNextHighlightChangePosition(textPosition, direction); StaticTextPointer nextContextPosition = textPosition.GetNextContextPosition(LogicalDirection.Forward); if (staticTextPointer.IsNull || nextContextPosition.CompareTo(staticTextPointer) < 0) { return(nextContextPosition); } return(staticTextPointer); } } staticTextPointer = textPosition.CreatePointer(1); return(staticTextPointer); }
// Finds the index of a run containing the specified content. // Returns -1 if there is no run in the indicated direction -- when // position is at the document edge pointing to nothing. private int FindIndex(StaticTextPointer position, LogicalDirection direction) { Run run; int index; int minIndex; int maxIndex; index = -1; minIndex = 0; maxIndex = _runList.Count; while (minIndex < maxIndex) { index = (minIndex + maxIndex) / 2; run = GetRun(index); if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 || direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0) { // Search to the left. maxIndex = index; } else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 || direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0) { // Search to the right. minIndex = index + 1; } else { // Got a match. break; } } if (minIndex >= maxIndex) { // We walked off the document edge searching. // position is at document start or end, and direction // points off into space, so there's no associated run. index = -1; } return index; }
// Returns the position of the next error start or end in an // indicated direction, or null if there is no such position. // Called by the SpellerHighlightLayer. internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; int index; int i; transitionPosition = StaticTextPointer.Null; index = FindIndex(textPosition, direction); if (index == -1) { // textPosition is at the document edge. // leave transitionPosition null. } else if (direction == LogicalDirection.Forward) { if (IsErrorRun(index)) { transitionPosition = GetRunEndPosition(index); } else { for (i = index+1; i < _runList.Count; i++) { if (IsErrorRun(i)) { transitionPosition = GetRun(i).Position.CreateStaticPointer(); break; } } } } else // direction == LogicalDirection.Backward { if (IsErrorRun(index)) { transitionPosition = GetRun(index).Position.CreateStaticPointer(); } else { for (i = index - 1; i > 0; i--) { if (IsErrorRun(i)) { transitionPosition = GetRunEndPosition(i); break; } } } } // If we ever had two consecuative errors (with touching borders) // we could return a transitionPosition == textPosition, which is illegal. // We rely on the fact that consecutive errors are always separated // by a word break to avoid this. // Invariant.Assert(transitionPosition.IsNull || textPosition.CompareTo(transitionPosition) != 0); return transitionPosition; }
/// <summary> /// Gets next change position in the backward direction /// </summary> /// <param name="pos"> start position</param> /// <returns>nex position if any</returns> private ITextPointer GetNextBackwardPosition(StaticTextPointer pos) { for (int i = _segments.Count - 1; i >= 0; i--) { HighlightSegment highlightSegment = _segments[i]; if (pos.CompareTo(highlightSegment.Segment.End) <= 0) { if (pos.CompareTo(highlightSegment.Segment.Start) > 0) return highlightSegment.Segment.Start; } else { return highlightSegment.Segment.End; } } return null; }
/// <summary> /// Gets next change position in the forward direction /// </summary> /// <param name="pos"> start position</param> /// <returns>next position if any</returns> private ITextPointer GetNextForwardPosition(StaticTextPointer pos) { for (int i = 0; i < _segments.Count; i++) { HighlightSegment highlightSegment = _segments[i]; if (pos.CompareTo(highlightSegment.Segment.Start) >= 0) { if (pos.CompareTo(highlightSegment.Segment.End) < 0) return highlightSegment.Segment.End; } else { return highlightSegment.Segment.Start; } } return null; }
internal static StaticTextPointer Max(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return(position1.CompareTo(position2) >= 0 ? position1 : position2); }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; transitionPosition = StaticTextPointer.Null; if (!IsTextRangeEmpty(_selection) && !_selection.IsInterimSelection) { int segmentCount; List <TextSegment> textSegments = _selection.TextSegments; TextSegment textSegment; segmentCount = textSegments.Count; if (direction == LogicalDirection.Forward) { for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; // Ignore empty segments. // if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.Start) < 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.End) < 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } } } } else { for (int segmentIndex = segmentCount - 1; segmentIndex >= 0; segmentIndex--) { textSegment = textSegments[segmentIndex]; if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.End) > 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.Start) > 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } } } } } return(transitionPosition); }
// Returns true iff the indicated content has scoping highlights. internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction) { int segmentCount; TextSegment textSegment; // No highlight when the selection is for interim character. if (_selection.IsInterimSelection) { return(false); } // Check all segments of selection List <TextSegment> textSegments = _selection.TextSegments; segmentCount = textSegments.Count; for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || // (direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0)) { return(true); } } return(false); }
internal static StaticTextPointer Max(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return position1.CompareTo(position2) >= 0 ? position1 : position2; }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; transitionPosition = StaticTextPointer.Null; if (!IsTextRangeEmpty(_selection) && !_selection.IsInterimSelection) { int segmentCount; List<TextSegment> textSegments = _selection.TextSegments; TextSegment textSegment; segmentCount = textSegments.Count; if (direction == LogicalDirection.Forward) { for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; // Ignore empty segments. // if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.Start) < 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.End) < 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } } } } else { for (int segmentIndex = segmentCount - 1; segmentIndex >= 0; segmentIndex--) { textSegment = textSegments[segmentIndex]; if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.End) > 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.Start) > 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } } } } } return transitionPosition; }
// Returns the position of the next error start or end in an // indicated direction, or null if there is no such position. // Called by the SpellerHighlightLayer. internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; int index; int i; transitionPosition = StaticTextPointer.Null; index = FindIndex(textPosition, direction); if (index == -1) { // textPosition is at the document edge. // leave transitionPosition null. } else if (direction == LogicalDirection.Forward) { if (IsErrorRun(index)) { transitionPosition = GetRunEndPosition(index); } else { for (i = index + 1; i < _runList.Count; i++) { if (IsErrorRun(i)) { transitionPosition = GetRun(i).Position.CreateStaticPointer(); break; } } } } else // direction == LogicalDirection.Backward { if (IsErrorRun(index)) { transitionPosition = GetRun(index).Position.CreateStaticPointer(); } else { for (i = index - 1; i > 0; i--) { if (IsErrorRun(i)) { transitionPosition = GetRunEndPosition(i); break; } } } } // If we ever had two consecuative errors (with touching borders) // we could return a transitionPosition == textPosition, which is illegal. // We rely on the fact that consecutive errors are always separated // by a word break to avoid this. // Invariant.Assert(transitionPosition.IsNull || textPosition.CompareTo(transitionPosition) != 0); return(transitionPosition); }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; AttributeRange attributeRange; int i; transitionPosition = StaticTextPointer.Null; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { transitionPosition = attributeRange.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { transitionPosition = attributeRange.Start.CreateStaticPointer(); break; } } } } return transitionPosition; }
// Returns the AttributeRange covering specified content, or null // if no such range exists. private AttributeRange GetRangeAtPosition(StaticTextPointer textPosition, LogicalDirection direction) { int i; AttributeRange attributeRange; AttributeRange attributeRangeAtPosition; // Use a simple iterative search since we don't ever have // more than a handful of attributes in a composition. attributeRangeAtPosition = null; if (direction == LogicalDirection.Forward) { for (i = 0; i < _attributeRanges.Count; i++) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.Start) < 0) { break; } else if (textPosition.CompareTo(attributeRange.End) < 0) { attributeRangeAtPosition = attributeRange; break; } } } } else { for (i = _attributeRanges.Count - 1; i >= 0; i--) { attributeRange = (AttributeRange)_attributeRanges[i]; if (attributeRange.Start.CompareTo(attributeRange.End) != 0) { if (textPosition.CompareTo(attributeRange.End) > 0) { break; } else if (textPosition.CompareTo(attributeRange.Start) > 0) { attributeRangeAtPosition = attributeRange; break; } } } } return attributeRangeAtPosition; }
// Token: 0x06003C66 RID: 15462 RVA: 0x0011729C File Offset: 0x0011549C internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction) { if (this._selection.IsInterimSelection) { return(false); } List <TextSegment> textSegments = this._selection.TextSegments; int count = textSegments.Count; for (int i = 0; i < count; i++) { TextSegment textSegment = textSegments[i]; if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || (direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0)) { return(true); } } return(false); }
// Returns true iff the indicated content has scoping highlights. internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction) { int segmentCount; TextSegment textSegment; // No highlight when the selection is for interim character. if (_selection.IsInterimSelection) { return false; } // Check all segments of selection List<TextSegment> textSegments = _selection.TextSegments; segmentCount = textSegments.Count; for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || // (direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0)) { return true; } } return false; }
// Returns the position of the next highlight start or end in an // indicated direction, or null if there is no such position. internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction) { StaticTextPointer transitionPosition; transitionPosition = StaticTextPointer.Null; if (!IsTextRangeEmpty(_selection) && !_selection.IsInterimSelection) { int segmentCount; List <TextSegment> textSegments = _selection.TextSegments; TextSegment textSegment; segmentCount = textSegments.Count; if (direction == LogicalDirection.Forward) { for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { textSegment = textSegments[segmentIndex]; // Ignore empty segments. // // Filtering out empty segments is a workaround. // The root problem is that table selections are not // always normalized, and in any case normalization // is problematic because the layout system // will call this code while computing layout and // the normalization code depends on a clean layout. // // We need to: // 1. Normalize table selections all the time. // 2. Remove the dependency on layout from our normalization code. // // Then we will never have empty segments. if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.Start) < 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.End) < 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } } } } else { for (int segmentIndex = segmentCount - 1; segmentIndex >= 0; segmentIndex--) { textSegment = textSegments[segmentIndex]; if (textSegment.Start.CompareTo(textSegment.End) != 0) { if (textPosition.CompareTo(textSegment.End) > 0) { transitionPosition = textSegment.End.CreateStaticPointer(); break; } else if (textPosition.CompareTo(textSegment.Start) > 0) { transitionPosition = textSegment.Start.CreateStaticPointer(); break; } } } } } return(transitionPosition); }