/// <summary> /// Appends the specified line to this instance. /// </summary> /// <param name="slice">The slice.</param> /// <param name="column">The column.</param> /// <param name="line">The line.</param> /// <param name="sourceLinePosition"></param> public void AppendLine(ref StringSlice slice, int column, int line, int sourceLinePosition) { if (Lines.Lines == null) { Lines = new StringLineGroup(4); } var stringLine = new StringLine(ref slice, line, column, sourceLinePosition); // Regular case, we are not in the middle of a tab if (slice.CurrentChar != '\t' || !CharHelper.IsAcrossTab(column)) { Lines.Add(ref stringLine); } else { // We need to expand tabs to spaces var builder = StringBuilderCache.Local(); for (int i = column; i < CharHelper.AddTab(column); i++) { builder.Append(' '); } builder.Append(slice.Text, slice.Start + 1, slice.Length - 1); stringLine.Slice = new StringSlice(builder.ToString()); Lines.Add(ref stringLine); } }
/// <summary> /// Returns the next character in the line taking into space taken by tabs. Update <see cref="Start"/> and <see cref="Column"/>. /// </summary> public void NextColumn() { var c = Line.CurrentChar; // If we are across a tab, we should just add 1 column if (c == '\t' && CharHelper.IsAcrossTab(Column)) { Column++; } else { Line.NextChar(); Column++; } }