| 3 | using Row_t = Table::Row_t; |
| 4 | |
| 5 | int main() { |
| 6 | |
| 7 | Table readme; |
| 8 | readme.format().border_color(Color::yellow); |
| 9 | |
| 10 | readme.add_row(Row_t{"tabulate for Modern C++"}); |
| 11 | readme[0].format().font_align(FontAlign::center).font_color(Color::yellow); |
| 12 | |
| 13 | readme.add_row(Row_t{"https://github.com/p-ranav/tabulate"}); |
| 14 | readme[1] |
| 15 | .format() |
| 16 | .font_align(FontAlign::center) |
| 17 | .font_style({FontStyle::underline, FontStyle::italic}) |
| 18 | .font_color(Color::white) |
| 19 | .hide_border_top(); |
| 20 | |
| 21 | readme.add_row(Row_t{"Tabulate is a header-only library for printing aligned, formatted, and " |
| 22 | "colorized tables in Modern C++"}); |
| 23 | readme[2].format().font_style({FontStyle::italic}).font_color(Color::magenta); |
| 24 | |
| 25 | Table highlights; |
| 26 | highlights.add_row(Row_t{"Header-only Library", "Requires C++17", "MIT License"}); |
| 27 | readme.add_row(Row_t{highlights}); |
| 28 | readme[3].format().font_align(FontAlign::center).hide_border_top(); |
| 29 | |
| 30 | Table empty_row; |
| 31 | empty_row.format().hide_border(); |
| 32 | readme.add_row(Row_t{empty_row}); |
| 33 | readme[4].format().hide_border_left().hide_border_right(); |
| 34 | |
| 35 | readme.add_row(Row_t{"Easily format and align content within cells"}); |
| 36 | readme[5].format().font_align(FontAlign::center); |
| 37 | |
| 38 | Table format; |
| 39 | format.add_row(Row_t{"Horizontal Alignment", "Left aligned", "Center aligned", "Right aligned"}); |
| 40 | format[0].format().font_align(FontAlign::center); |
| 41 | format[0][0].format().font_color(Color::green).column_separator(":"); |
| 42 | |
| 43 | format.column(1).format().width(25).font_align(FontAlign::left); |
| 44 | format.column(2).format().width(25).font_align(FontAlign::center); |
| 45 | format.column(3).format().width(25).font_align(FontAlign::right); |
| 46 | |
| 47 | format.add_row({"Word-Wrapping algorithm taking shamelessly from StackOverflow", |
| 48 | "Long sentences automatically word-wrap based on the width of the " |
| 49 | "column", |
| 50 | "Word-wrapping also plays nicely with alignment rules. For instance, " |
| 51 | "this cell is center " |
| 52 | "aligned.", |
| 53 | "Enforce \ncustom word-wrapping \nby embedding '\\n' \ncharacters in " |
| 54 | "your cell\n content."}); |
| 55 | format[1][0].format().font_align(FontAlign::center); |
| 56 | format[1][2].format().font_align(FontAlign::center); |
| 57 | format[1][3].format().font_align(FontAlign::right); |
| 58 | |
| 59 | format.column(0).format().width(23); |
| 60 | format.column(1).format().border_left(":"); |
| 61 | |
| 62 | readme.add_row(Row_t{format}); |