MCPcopy Create free account
hub / github.com/p-ranav/tabulate / main

Function main

samples/ansi_escape_width.cpp:5–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using Row_t = Table::Row_t;
4
5int main() {
6 // Cell contents that already carry their own ANSI escape sequences, e.g.
7 // strings colored by the application or produced by a nested table
8 const std::string red = "\x1b[31mred\x1b[0m";
9 const std::string naive = "\x1b[1mnaïve\x1b[0m";
10
11 Table table;
12 table.add_row(Row_t{"content", "visible width"});
13 table.add_row(Row_t{red, "3"});
14 table.add_row(Row_t{naive, "5"});
15 table.format().multi_byte_characters(true);
16
17 // The escape sequences occupy no columns, so the first column is three
18 // characters wide and the borders line up with what the terminal shows
19 std::cout << table << std::endl;
20}

Callers

nothing calls this directly

Calls 2

add_rowMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected