[A] Added new style

This commit is contained in:
seleznevae 2018-05-07 23:25:45 +03:00
parent 0467409d6c
commit 917c74337b
6 changed files with 76 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);