public static int GetLineLength(this StringBuilder sb, int line) { int lineIndex = sb.FindLineIndex(line); int afterLineIndex = sb.FindLineIndex(line + 1); int length = afterLineIndex - lineIndex; return(length); }
public static StringBuilder MoveCursorToLineStart(this StringBuilder sb) { int cursorLine = sb.FindIndexLine(sb.FindCursorIndex()); int index = sb.FindLineIndex(cursorLine); sb.RemoveCursor().AddCursorIndex(index); return(sb); }
public static StringBuilder AddCursor(this StringBuilder sb, int line) { return(sb.Insert(sb.FindLineIndex(line + 1), cursor)); }
public static StringBuilder NewLine(this StringBuilder sb, int line, string value) { sb.RemoveCursor().Insert(sb.FindLineIndex(line), $"{Environment.NewLine}{value}").AddCursor(line + 1); return(sb); }
public static StringBuilder NewLine(this StringBuilder sb, int line) { return(sb.RemoveCursor().Insert(sb.FindLineIndex(line), Environment.NewLine).AddCursor(line + 1)); }