diff --git a/lib/fort.c b/lib/fort.c index daa1b2f..66f796f 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -420,6 +420,7 @@ struct fort_border_style { const char *separator_chars[SepratorItemPosSize]; }; extern struct fort_border_style FORT_BASIC_STYLE; +extern struct fort_border_style FORT_BASIC2_STYLE; extern struct fort_border_style FORT_SIMPLE_STYLE; extern struct fort_border_style FORT_PLAIN_STYLE; extern struct fort_border_style FORT_DOT_STYLE; @@ -892,6 +893,27 @@ fort_status_t set_default_cell_option(uint32_t option, int value) }, \ } +#define BASIC2_STYLE { \ + /* border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+" \ + }, \ + /* header_border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+" \ + }, \ + /* separator_chars */ \ + { \ + "+", "-", "+", "+", \ + }, \ +} + #define SIMPLE_STYLE { \ /* border_chars */ \ { \ @@ -1129,6 +1151,7 @@ fort_status_t set_default_cell_option(uint32_t option, int value) struct fort_border_style FORT_BASIC_STYLE = BASIC_STYLE; +struct fort_border_style FORT_BASIC2_STYLE = BASIC2_STYLE; struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE; struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE; struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; @@ -2330,6 +2353,7 @@ int ft_add_separator(ft_table_t *table) struct ft_border_style *FT_BASIC_STYLE = (struct ft_border_style *) &FORT_BASIC_STYLE; +struct ft_border_style *FT_BASIC2_STYLE = (struct ft_border_style *) &FORT_BASIC2_STYLE; struct ft_border_style *FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT_SIMPLE_STYLE; struct ft_border_style *FT_PLAIN_STYLE = (struct ft_border_style *) &FORT_PLAIN_STYLE; struct ft_border_style *FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYLE; @@ -2347,6 +2371,7 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME static void set_border_options_for_options(fort_table_options_t *options, struct ft_border_style *style) { if ((struct fort_border_style *)style == &FORT_BASIC_STYLE + || (struct fort_border_style *)style == &FORT_BASIC2_STYLE || (struct fort_border_style *)style == &FORT_SIMPLE_STYLE || (struct fort_border_style *)style == &FORT_DOT_STYLE || (struct fort_border_style *)style == &FORT_PLAIN_STYLE diff --git a/lib/fort.h b/lib/fort.h index 7249d5a..5fc7e17 100644 --- a/lib/fort.h +++ b/lib/fort.h @@ -606,6 +606,7 @@ struct ft_border_style { * @{ */ extern struct ft_border_style *FT_BASIC_STYLE; +extern struct ft_border_style *FT_BASIC2_STYLE; extern struct ft_border_style *FT_SIMPLE_STYLE; extern struct ft_border_style *FT_PLAIN_STYLE; extern struct ft_border_style *FT_DOT_STYLE; diff --git a/src/fort_impl.c b/src/fort_impl.c index 0360cc8..2eec347 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -794,6 +794,7 @@ int ft_add_separator(ft_table_t *table) struct ft_border_style *FT_BASIC_STYLE = (struct ft_border_style *) &FORT_BASIC_STYLE; +struct ft_border_style *FT_BASIC2_STYLE = (struct ft_border_style *) &FORT_BASIC2_STYLE; struct ft_border_style *FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT_SIMPLE_STYLE; struct ft_border_style *FT_PLAIN_STYLE = (struct ft_border_style *) &FORT_PLAIN_STYLE; struct ft_border_style *FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYLE; @@ -811,6 +812,7 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME static void set_border_options_for_options(fort_table_options_t *options, struct ft_border_style *style) { if ((struct fort_border_style *)style == &FORT_BASIC_STYLE + || (struct fort_border_style *)style == &FORT_BASIC2_STYLE || (struct fort_border_style *)style == &FORT_SIMPLE_STYLE || (struct fort_border_style *)style == &FORT_DOT_STYLE || (struct fort_border_style *)style == &FORT_PLAIN_STYLE diff --git a/src/options.c b/src/options.c index 7083a51..82cd0bd 100644 --- a/src/options.c +++ b/src/options.c @@ -236,6 +236,27 @@ fort_status_t set_default_cell_option(uint32_t option, int value) }, \ } +#define BASIC2_STYLE { \ + /* border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+" \ + }, \ + /* header_border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+" \ + }, \ + /* separator_chars */ \ + { \ + "+", "-", "+", "+", \ + }, \ +} + #define SIMPLE_STYLE { \ /* border_chars */ \ { \ @@ -473,6 +494,7 @@ fort_status_t set_default_cell_option(uint32_t option, int value) struct fort_border_style FORT_BASIC_STYLE = BASIC_STYLE; +struct fort_border_style FORT_BASIC2_STYLE = BASIC2_STYLE; struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE; struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE; struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; diff --git a/src/options.h b/src/options.h index c85ad72..6e2eea7 100644 --- a/src/options.h +++ b/src/options.h @@ -111,6 +111,7 @@ struct fort_border_style { const char *separator_chars[SepratorItemPosSize]; }; extern struct fort_border_style FORT_BASIC_STYLE; +extern struct fort_border_style FORT_BASIC2_STYLE; extern struct fort_border_style FORT_SIMPLE_STYLE; extern struct fort_border_style FORT_PLAIN_STYLE; extern struct fort_border_style FORT_DOT_STYLE; diff --git a/tests/bb_tests/test_table_border_style.c b/tests/bb_tests/test_table_border_style.c index 6e526bb..d17bff4 100644 --- a/tests/bb_tests/test_table_border_style.c +++ b/tests/bb_tests/test_table_border_style.c @@ -175,6 +175,31 @@ void test_table_builtin_border_styles(void) assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); + /* *************************************************************** */ + + ft_set_default_border_style(FT_BASIC2_STYLE); + table = create_basic_table(); + table_str = ft_to_string(table); + assert_true(table_str != NULL); + + table_str_etalon = + "+------+--------------------------+------+--------+\n" + "| Rank | Title | Year | Rating |\n" + "+------+--------------------------+------+--------+\n" + "| 1 | The Shawshank Redemption | 1994 | 9.5 |\n" + "+------+--------------------------+------+--------+\n" + "| 2 | 12 Angry Men | 1957 | 8.8 |\n" + "+------+--------------------------+------+--------+\n" + "| 3 | It's a Wonderful Life | 1946 | 8.6 |\n" + "+------+--------------------------+------+--------+\n" + "| 4 | 2001: A Space Odyssey | 1968 | 8.5 |\n" + "+------+--------------------------+------+--------+\n" + "| 5 | Blade Runner | 1982 | 8.1 |\n" + "+------+--------------------------+------+--------+\n"; + assert_str_equal(table_str, table_str_etalon); + ft_destroy_table(table); + + /* *************************************************************** */ ft_set_default_border_style(FT_SIMPLE_STYLE);