diff --git a/docs/images/color_table.png b/docs/images/color_table.png new file mode 100644 index 0000000..dda6a66 Binary files /dev/null and b/docs/images/color_table.png differ diff --git a/example/main.c b/example/main.c index dcdf15c..e4e8da2 100644 --- a/example/main.c +++ b/example/main.c @@ -152,7 +152,7 @@ void colorfull_table(void) setlocale(LC_CTYPE, ""); ft_table_t *table = ft_create_table(); - ft_set_border_style(table, FT_DOUBLE_STYLE); + ft_set_border_style(table, FT_NICE_STYLE); ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); /* Filling table with data */ @@ -170,7 +170,6 @@ void colorfull_table(void) ft_set_cell_span(table, 8, 0, 4); ft_wwrite_ln(table, L"Total result", L"", L"", L"", L"✖"); - /* Setting text styles */ ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); ft_set_cell_prop(table, 8, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); @@ -178,7 +177,6 @@ void colorfull_table(void) ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_ITALIC); - /* Set alignment */ ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); @@ -195,9 +193,13 @@ void colorfull_table(void) ft_set_cell_prop(table, 4, 3, FT_CPROP_CONT_BG_COLOR, FT_COLOR_LIGHT_RED); ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_FG_COLOR, FT_COLOR_LIGHT_BLUE); + /* Move table to the center of the screen */ + ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 1); + ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 10); + const wchar_t *table_wstr = ft_to_wstring(table); if (table_wstr) { - fwprintf(stderr, L"Table:\n%ls\n ", table_wstr); + fwprintf(stderr, L"Table:\n%ls\n\n ", table_wstr); } else { fwprintf(stderr, L"Table conversion failed !!!\n "); } diff --git a/lib/fort.c b/lib/fort.c index 0d326b9..78be372 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -535,6 +535,7 @@ extern struct fort_border_style FORT_DOT_STYLE; extern struct fort_border_style FORT_EMPTY_STYLE; extern struct fort_border_style FORT_SOLID_STYLE; extern struct fort_border_style FORT_SOLID_ROUND_STYLE; +extern struct fort_border_style FORT_NICE_STYLE; extern struct fort_border_style FORT_DOUBLE_STYLE; extern struct fort_border_style FORT_DOUBLE2_STYLE; extern struct fort_border_style FORT_BOLD_STYLE; @@ -1490,8 +1491,7 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ } - -#define DOUBLE_STYLE { \ +#define NICE_STYLE { \ /* border_chars */ \ { \ "╔", "═", "╦", "╗", \ @@ -1510,11 +1510,37 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ /* separator_chars */ \ { \ - "╠", "═", "╬", "╣", \ - "╦", "╩", \ + "╟", "─", "╫", "╢", \ + "╥", "╨", \ }, \ } +#define DOUBLE_STYLE { \ + /* border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "", "", "", "", \ + "╚", "═", "╩", "╝", \ + "┣", "┻", "┣", "┳", \ + }, \ + /* header_border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "╠", "═", "╬", "╣", \ + "╚", "═", "╩", "╝", \ + "┣", "╦", "┣", "╩", \ + }, \ + /* separator_chars */ \ + { \ + "╠", "═", "╬", "╣", \ + "╦", "╩", \ + }, \ +} + + + #define DOUBLE2_STYLE { \ /* border_chars */ \ @@ -1622,6 +1648,7 @@ struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE; struct fort_border_style FORT_SOLID_STYLE = SOLID_STYLE; struct fort_border_style FORT_SOLID_ROUND_STYLE = SOLID_ROUND_STYLE; +struct fort_border_style FORT_NICE_STYLE = NICE_STYLE; struct fort_border_style FORT_DOUBLE_STYLE = DOUBLE_STYLE; struct fort_border_style FORT_DOUBLE2_STYLE = DOUBLE2_STYLE; struct fort_border_style FORT_BOLD_STYLE = BOLD_STYLE; @@ -2919,6 +2946,7 @@ struct ft_border_style *FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYL struct ft_border_style *FT_EMPTY_STYLE = (struct ft_border_style *) &FORT_EMPTY_STYLE; struct ft_border_style *FT_SOLID_STYLE = (struct ft_border_style *) &FORT_SOLID_STYLE; struct ft_border_style *FT_SOLID_ROUND_STYLE = (struct ft_border_style *) &FORT_SOLID_ROUND_STYLE; +struct ft_border_style *FT_NICE_STYLE = (struct ft_border_style *) &FORT_NICE_STYLE; struct ft_border_style *FT_DOUBLE_STYLE = (struct ft_border_style *) &FORT_DOUBLE_STYLE; struct ft_border_style *FT_DOUBLE2_STYLE = (struct ft_border_style *) &FORT_DOUBLE2_STYLE; struct ft_border_style *FT_BOLD_STYLE = (struct ft_border_style *) &FORT_BOLD_STYLE; @@ -2937,6 +2965,7 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons || (struct fort_border_style *)style == &FORT_EMPTY_STYLE || (struct fort_border_style *)style == &FORT_SOLID_STYLE || (struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE + || (struct fort_border_style *)style == &FORT_NICE_STYLE || (struct fort_border_style *)style == &FORT_DOUBLE_STYLE || (struct fort_border_style *)style == &FORT_DOUBLE2_STYLE || (struct fort_border_style *)style == &FORT_BOLD_STYLE diff --git a/lib/fort.h b/lib/fort.h index 3f787b6..f70ff9e 100644 --- a/lib/fort.h +++ b/lib/fort.h @@ -624,6 +624,7 @@ extern struct ft_border_style *FT_DOT_STYLE; extern struct ft_border_style *FT_EMPTY_STYLE; extern struct ft_border_style *FT_SOLID_STYLE; extern struct ft_border_style *FT_SOLID_ROUND_STYLE; +extern struct ft_border_style *FT_NICE_STYLE; extern struct ft_border_style *FT_DOUBLE_STYLE; extern struct ft_border_style *FT_DOUBLE2_STYLE; extern struct ft_border_style *FT_BOLD_STYLE; diff --git a/src/fort_impl.c b/src/fort_impl.c index 826e9f6..d47c5fe 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -836,6 +836,7 @@ struct ft_border_style *FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYL struct ft_border_style *FT_EMPTY_STYLE = (struct ft_border_style *) &FORT_EMPTY_STYLE; struct ft_border_style *FT_SOLID_STYLE = (struct ft_border_style *) &FORT_SOLID_STYLE; struct ft_border_style *FT_SOLID_ROUND_STYLE = (struct ft_border_style *) &FORT_SOLID_ROUND_STYLE; +struct ft_border_style *FT_NICE_STYLE = (struct ft_border_style *) &FORT_NICE_STYLE; struct ft_border_style *FT_DOUBLE_STYLE = (struct ft_border_style *) &FORT_DOUBLE_STYLE; struct ft_border_style *FT_DOUBLE2_STYLE = (struct ft_border_style *) &FORT_DOUBLE2_STYLE; struct ft_border_style *FT_BOLD_STYLE = (struct ft_border_style *) &FORT_BOLD_STYLE; @@ -854,6 +855,7 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons || (struct fort_border_style *)style == &FORT_EMPTY_STYLE || (struct fort_border_style *)style == &FORT_SOLID_STYLE || (struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE + || (struct fort_border_style *)style == &FORT_NICE_STYLE || (struct fort_border_style *)style == &FORT_DOUBLE_STYLE || (struct fort_border_style *)style == &FORT_DOUBLE2_STYLE || (struct fort_border_style *)style == &FORT_BOLD_STYLE diff --git a/src/properties.c b/src/properties.c index 1f6fa45..26d4e7c 100644 --- a/src/properties.c +++ b/src/properties.c @@ -696,8 +696,7 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ } - -#define DOUBLE_STYLE { \ +#define NICE_STYLE { \ /* border_chars */ \ { \ "╔", "═", "╦", "╗", \ @@ -716,11 +715,37 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ /* separator_chars */ \ { \ - "╠", "═", "╬", "╣", \ - "╦", "╩", \ + "╟", "─", "╫", "╢", \ + "╥", "╨", \ }, \ } +#define DOUBLE_STYLE { \ + /* border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "", "", "", "", \ + "╚", "═", "╩", "╝", \ + "┣", "┻", "┣", "┳", \ + }, \ + /* header_border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "╠", "═", "╬", "╣", \ + "╚", "═", "╩", "╝", \ + "┣", "╦", "┣", "╩", \ + }, \ + /* separator_chars */ \ + { \ + "╠", "═", "╬", "╣", \ + "╦", "╩", \ + }, \ +} + + + #define DOUBLE2_STYLE { \ /* border_chars */ \ @@ -828,6 +853,7 @@ struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE; struct fort_border_style FORT_SOLID_STYLE = SOLID_STYLE; struct fort_border_style FORT_SOLID_ROUND_STYLE = SOLID_ROUND_STYLE; +struct fort_border_style FORT_NICE_STYLE = NICE_STYLE; struct fort_border_style FORT_DOUBLE_STYLE = DOUBLE_STYLE; struct fort_border_style FORT_DOUBLE2_STYLE = DOUBLE2_STYLE; struct fort_border_style FORT_BOLD_STYLE = BOLD_STYLE; diff --git a/src/properties.h b/src/properties.h index 094f999..dba27d7 100644 --- a/src/properties.h +++ b/src/properties.h @@ -162,6 +162,7 @@ extern struct fort_border_style FORT_DOT_STYLE; extern struct fort_border_style FORT_EMPTY_STYLE; extern struct fort_border_style FORT_SOLID_STYLE; extern struct fort_border_style FORT_SOLID_ROUND_STYLE; +extern struct fort_border_style FORT_NICE_STYLE; extern struct fort_border_style FORT_DOUBLE_STYLE; extern struct fort_border_style FORT_DOUBLE2_STYLE; extern struct fort_border_style FORT_BOLD_STYLE;