//============================================================ private static int SeekWithoutClamping(this StringView str, int start, SeekMode mode, Ward1D ward) { if (mode == SeekMode.MoveOneChar) { return(start + ward.GetOffset()); } else if (mode == SeekMode.UntilNewline) { if (ward == Ward1D.Backward) { return(str.FindLast('\n', start + 1)); } else if (ward == Ward1D.Forward) { return(str.FindFirst('\n', start)); } } else { Debug.Assert((mode & (SeekMode.LiterallySpaced | SeekMode.PassingQuotation | SeekMode.BracketBalanced)) != 0); if (ward == Ward1D.Backward) { return(str.SeekToSpaceBalanced(start, mode, -1, -1) - 1); } else if (ward == Ward1D.Forward) { return(str.SeekToSpaceBalanced(start + 1, mode, 1, 0)); } } throw new Exception(); }
public static int GetLastSpaceBoundary(this StringView str) { return(str.FindLast(ChrCategory.WhitespacePredicate.InvertCondition())); }
public static int FindLast(this StringView str, char c, int start) { return(str.FindLast((char chr) => chr == c, start)); }
public static int FindLast(this StringView str, char c) { return(str.FindLast((char chr) => chr == c, str.Length)); }
public static int FindLast(this StringView str, System.Predicate <char> pred) { return(str.FindLast(pred, str.Length)); }