diff --git a/example/main.cpp b/example/main.cpp index 4b626a8..92dba67 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -2,6 +2,30 @@ #include #include "fort.hpp" +fort::Table create_basic_table(void) +{ + fort::Table table; + /* Set table border style */ + table.set_border_style(FT_BASIC_STYLE); + + // Fill table with data + table << fort::header + << "Rank" << "Title" << "Year" << "Rating" << fort::endr + << "1" << "The Shawshank Redemption" << "1994" << "9.5" << fort::endr + << "2" << "12 Angry Men" << "1957" << "8.8" << fort::endr + << "3" << "It's a Wonderful Life" << "1946" << "8.6" << fort::endr + << fort::separator + << "4" << "2001: A Space Odyssey" << "1968" << "8.5" << fort::endr + << "5" << "Blade Runner" << "1982" << "8.1" << fort::endr + << fort::endr; + + table.set_cell_text_align(FT_ANY_ROW, 0, fort::TextAlign::Center); + table.set_cell_text_align(FT_ANY_ROW, 1, fort::TextAlign::Left); + + std::cout << table.to_string() << std::endl; + return table; +} + void base_example(void) { fort::Table table; diff --git a/lib/fort.h b/lib/fort.h index a9d20b4..df09c6e 100644 --- a/lib/fort.h +++ b/lib/fort.h @@ -676,7 +676,7 @@ int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style); * @{ */ #define FT_COPT_MIN_WIDTH (0x01U << 0) /**< Minimum width */ -#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignmemnt */ +#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignment */ #define FT_COPT_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */ #define FT_COPT_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */ #define FT_COPT_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */ diff --git a/lib/fort.hpp b/lib/fort.hpp index c0e0af9..b5c773b 100644 --- a/lib/fort.hpp +++ b/lib/fort.hpp @@ -563,17 +563,18 @@ public: } /** - * Set default border style for all new formatted tables. + * Set current cell position. * - * @param style - * Pointer to border style. - * @return - * - True: Success; table border style was changed. - * - False: Error + * Current cell - cell that will be edited with all modifiing functions. + * + * @param row + * New row number for the current cell. + * @param col + * New row number for the current cell. */ - bool set_default_border_style(struct ft_border_style *style) + void set_cur_cell(size_t row, size_t col) { - return FT_IS_SUCCESS(ft_set_default_border_style(style)); + ft_set_cur_cell(table, row, col); } private: ft_table_t *table; @@ -628,7 +629,19 @@ public: }; - +/** + * Set default border style for all new formatted tables. + * + * @param style + * Pointer to border style. + * @return + * - True: Success; table border style was changed. + * - False: Error + */ +bool set_default_border_style(struct ft_border_style *style) +{ + return FT_IS_SUCCESS(ft_set_default_border_style(style)); +}