public static int FindPrevWordStart(IDocument document, int offset) { if (offset > 0) { LineSegment lineSegmentForOffset = document.GetLineSegmentForOffset(offset); TextUtilities.CharacterType characterType = TextUtilities.GetCharacterType(document.GetCharAt(offset - 1)); while (offset > lineSegmentForOffset.Offset && TextUtilities.GetCharacterType(document.GetCharAt(offset - 1)) == characterType) { offset--; } if (characterType == TextUtilities.CharacterType.WhiteSpace && offset > lineSegmentForOffset.Offset) { characterType = TextUtilities.GetCharacterType(document.GetCharAt(offset - 1)); while (offset > lineSegmentForOffset.Offset && TextUtilities.GetCharacterType(document.GetCharAt(offset - 1)) == characterType) { offset--; } } } return(offset); }
public static int FindNextWordStart(IDocument document, int offset) { LineSegment lineSegmentForOffset = document.GetLineSegmentForOffset(offset); int num = lineSegmentForOffset.Offset + lineSegmentForOffset.Length; TextUtilities.CharacterType characterType = TextUtilities.GetCharacterType(document.GetCharAt(offset)); while (offset < num) { if (TextUtilities.GetCharacterType(document.GetCharAt(offset)) == characterType) { offset++; } else { break; } } while (offset < num && TextUtilities.GetCharacterType(document.GetCharAt(offset)) == TextUtilities.CharacterType.WhiteSpace) { offset++; } return(offset); }