-
Notifications
You must be signed in to change notification settings - Fork 13
Muti line text support #21
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
Changes from all commits
8aee213
d075c7a
9821611
32cc584
c26a642
6196922
2b68eac
b557561
d801f5a
52dd737
cbf3413
e72257d
56a1fc9
3765a59
935a9c2
34e06b9
2edbaa0
d898830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # V2.2.0 | ||
|
|
||
| ## Multi-line support | ||
| Cell content can contain newlines and the table will adjust row height accordingly, in headers, rows and footers. | ||
|
|
||
| ## Bug fix | ||
| - Edge case drawing issues of cell borders miss alligned when having empty rows or empty cell content fixed | ||
| - Performance improvements | ||
|
|
||
|
|
||
| ```csharp | ||
| using ConsoleTable.Text; | ||
|
|
||
| // Setup the table | ||
| var table = new Table | ||
| { | ||
| RowTextAlignmentRight = false, | ||
| HeaderTextAlignmentRight = false, | ||
| FooterTextAlignmentRight = false, | ||
| Padding = 2, | ||
| Headers = new string[] { "Name", $"Age{Environment.NewLine}&{Environment.NewLine}Birthyear", "City" }, | ||
| Rows = new List<string[]> | ||
| { | ||
| new string[] { "Alice Cooper", $"30{Environment.NewLine}1995", "New York" }, | ||
| new string[] { "Bob", $"25{Environment.NewLine}2000", "Los Angeles" }, | ||
| new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" }, | ||
| new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally from Bogota, Colombia" } | ||
| }, | ||
|
Comment on lines
+26
to
+28
|
||
| Footers = new string[] { $"Total: 4{Environment.NewLine}3 Male - 1 Female", "Total Age: 162" } | ||
| }; | ||
|
|
||
| // Display the table | ||
| Console.WriteLine(table.ToTable()); | ||
| ``` | ||
|
|
||
| Output: | ||
| ``` | ||
| ┌─────────────────────┬──────────────────┬────────────────────────────────────┐ | ||
| │ Name │ Age │ City │ | ||
| │ │ & │ │ | ||
| │ │ Birthyear │ │ | ||
| ├═════════════════════┼══════════════════┼════════════════════════════════════┤ | ||
| │ Alice Cooper │ 30 │ New York │ | ||
| │ │ 1995 │ │ | ||
| ├─────────────────────┼──────────────────┼────────────────────────────────────┤ | ||
| │ Bob │ 25 │ Los Angeles │ | ||
| │ │ 2000 │ │ | ||
| ├─────────────────────┼──────────────────┼────────────────────────────────────┤ | ||
| │ Charlie Brown │ 67 │ Chicago │ | ||
| │ │ 1958 │ │ | ||
| ├─────────────────────┼──────────────────┼────────────────────────────────────┤ | ||
| │ Gloria │ 40 │ Chicago │ | ||
| │ │ 1985 │ Originally from Bogota, Colombia │ | ||
| └─────────────────────┴──────────────────┴────────────────────────────────────┘ | ||
| Total: 4 Total Age: 162 | ||
| 3 Male - 1 Female | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,10 @@ static void Main(string[] args) | |||||
|
|
||||||
| WriteTableFluent(); | ||||||
|
|
||||||
| WriteMultiLineTable(false); | ||||||
|
|
||||||
| WriteMultiLineTable(true); | ||||||
|
|
||||||
| WriteTableWithoutBorders(); | ||||||
|
|
||||||
| //WriteBigTable(); | ||||||
|
|
@@ -74,6 +78,35 @@ private static void WriteDefaultTable() | |||||
| Console.WriteLine(); | ||||||
| } | ||||||
|
|
||||||
| private static void WriteMultiLineTable(bool textAlignRight) | ||||||
| { | ||||||
| Console.WriteLine(); | ||||||
| Console.WriteLine("Multi line table:"); | ||||||
|
||||||
| Console.WriteLine("Multi line table:"); | |
| Console.WriteLine("Multi-line table:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog snippet uses
Environment.NewLineandList<string[]>, but only importsConsoleTable.Text. Consider addingusing System;andusing System.Collections.Generic;so the example compiles without relying on implicit global usings.