Skip to content

Propose a different way to organize the code #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ internal override void ProcessPayload(FormatEntryData fed)
alignment[k] = TextAlignment.Left; // hard coded default
}
}
this.Writer.GenerateRow(values, this.InnerCommand._lo, tre.multiLine, alignment, InnerCommand._lo.DisplayCells);
this.Writer.GenerateRow(values, this.InnerCommand._lo, tre.multiLine, alignment, InnerCommand._lo.DisplayCells, generatedRows: null);
_rowCount++;
}

Expand Down Expand Up @@ -1278,7 +1278,7 @@ private void WriteStringBuffer()
else
values[k] = string.Empty;
}
this.Writer.GenerateRow(values, this.InnerCommand._lo, false, null, InnerCommand._lo.DisplayCells);
this.Writer.GenerateRow(values, this.InnerCommand._lo, false, null, InnerCommand._lo.DisplayCells, generatedRows: null);
_buffer.Reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ internal int GenerateHeader(string[] values, LineOutput lo)
return _header.Count;
}

var header = new List<string>();
_header = new List<string>();

// generate the row with the header labels
header = GenerateRow(values, lo, true, null, lo.DisplayCells);
GenerateRow(values, lo, true, null, lo.DisplayCells, _header);

// generate an array of "--" as header markers below
// the column header labels
Expand All @@ -188,17 +188,14 @@ internal int GenerateHeader(string[] values, LineOutput lo)
breakLine[k] = StringUtil.DashPadding(count);
}

header.AddRange(GenerateRow(breakLine, lo, false, null, lo.DisplayCells));
_header = header;
GenerateRow(breakLine, lo, false, null, lo.DisplayCells, _header);
return _header.Count;
}

internal List<string> GenerateRow(string[] values, LineOutput lo, bool multiLine, ReadOnlySpan<int> alignment, DisplayCells dc)
internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, ReadOnlySpan<int> alignment, DisplayCells dc, List<string> generatedRows)
{
List<string> lines = new List<string>();

if (_disabled)
return lines;
return;

// build the current row alignment settings
int cols = _si.columnInfo.Length;
Expand Down Expand Up @@ -226,18 +223,15 @@ internal List<string> GenerateRow(string[] values, LineOutput lo, bool multiLine
{
foreach (string line in GenerateTableRow(values, currentAlignment, lo.DisplayCells))
{
lines.Add(line);
generatedRows?.Add(line);
lo.WriteLine(line);
}

return lines;
}
else
{
string line = GenerateRow(values, currentAlignment, dc);
generatedRows?.Add(line);
lo.WriteLine(line);
lines.Add(line);
return lines;
}
}

Expand Down