[F] Fixed reset style tag

This commit is contained in:
seleznevae 2019-07-17 22:33:56 +03:00
parent bb6002ec0b
commit b19479c228
6 changed files with 132 additions and 196 deletions

View File

@ -396,7 +396,7 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz
#define PROP_SET(ft_props, property) ((ft_props) |=(property)) #define PROP_SET(ft_props, property) ((ft_props) |=(property))
#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property))) #define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property)))
#define TEXT_STYLE_TAG_MAX_SIZE 64 #define TEXT_STYLE_TAG_MAX_SIZE (64 * 2)
FT_INTERNAL FT_INTERNAL
void get_style_tag_for_cell(const fort_table_properties_t *props, void get_style_tag_for_cell(const fort_table_properties_t *props,
@ -460,7 +460,7 @@ FT_INTERNAL
fort_status_t set_default_cell_property(uint32_t property, int value); fort_status_t set_default_cell_property(uint32_t property, int value);
/* TABLE BORDER DESRIPTION /* TABLE BORDER DESСRIPTION
* *
* *
* TL TT TT TT TV TT TT TT TT TT TT TT TR * TL TT TT TT TV TT TT TT TT TT TT TT TR
@ -2476,26 +2476,6 @@ static const char *fg_colors[] = {
"\033[97m", "\033[97m",
}; };
static const char *reset_fg_colors[] = {
"",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
};
static const char *bg_colors[] = { static const char *bg_colors[] = {
"", "",
"\033[40m", "\033[40m",
@ -2516,27 +2496,6 @@ static const char *bg_colors[] = {
"\033[107m", "\033[107m",
}; };
static const char *reset_bg_colors[] = {
"",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
};
static const char *text_styles[] = { static const char *text_styles[] = {
"", "",
"\033[1m", "\033[1m",
@ -2548,17 +2507,7 @@ static const char *text_styles[] = {
"\033[8m", "\033[8m",
}; };
static const char *reset_text_styles[] = { #define UNIVERSAL_RESET_TAG "\033[0m"
"",
"\033[21m",
"\033[22m",
"\033[23m",
"\033[24m",
"\033[25m",
"\033[27m",
"\033[28m",
};
static const size_t n_fg_colors = sizeof(fg_colors) / sizeof(fg_colors[0]); static const size_t n_fg_colors = sizeof(fg_colors) / sizeof(fg_colors[0]);
static const size_t n_bg_colors = sizeof(bg_colors) / sizeof(bg_colors[0]); static const size_t n_bg_colors = sizeof(bg_colors) / sizeof(bg_colors[0]);
@ -2614,7 +2563,8 @@ void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
if (text_style < (1U << n_styles)) { if (text_style < (1U << n_styles)) {
for (i = 0; i < n_styles; ++i) { for (i = 0; i < n_styles; ++i) {
if (text_style & (1 << i)) { if (text_style & (1 << i)) {
strcat(reset_style_tag, reset_text_styles[i]); if (i != 0) // FT_TSTYLE_DEFAULT
goto reset_style;
} }
} }
} else { } else {
@ -2622,13 +2572,19 @@ void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
} }
if (bg_color_number < n_bg_colors) { if (bg_color_number < n_bg_colors) {
strcat(reset_style_tag, reset_bg_colors[bg_color_number]); if (bg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
return; return;
reset_style:
strcat(reset_style_tag, UNIVERSAL_RESET_TAG);
return;
error: error:
/* shouldn't be here */ /* shouldn't be here */
assert(0); assert(0);
@ -2660,6 +2616,7 @@ void get_style_tag_for_content(const fort_table_properties_t *props,
} }
if (fg_color_number < n_fg_colors) { if (fg_color_number < n_fg_colors) {
if (fg_color_number)
strcat(style_tag, fg_colors[fg_color_number]); strcat(style_tag, fg_colors[fg_color_number]);
} else { } else {
goto error; goto error;
@ -2685,6 +2642,7 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
{ {
(void)sz; (void)sz;
size_t i = 0; size_t i = 0;
size_t len = 0;
unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE); unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE);
unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR); unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR);
@ -2695,7 +2653,8 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
if (text_style < (1U << n_styles)) { if (text_style < (1U << n_styles)) {
for (i = 0; i < n_styles; ++i) { for (i = 0; i < n_styles; ++i) {
if (text_style & (1 << i)) { if (text_style & (1 << i)) {
strcat(reset_style_tag, reset_text_styles[i]); if (i != 0) // FT_TSTYLE_DEFAULT
goto reset_style;
} }
} }
} else { } else {
@ -2703,19 +2662,28 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
} }
if (fg_color_number < n_fg_colors) { if (fg_color_number < n_fg_colors) {
strcat(reset_style_tag, reset_fg_colors[fg_color_number]); if (fg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
if (bg_color_number < n_bg_colors) { if (bg_color_number < n_bg_colors) {
strcat(reset_style_tag, reset_bg_colors[bg_color_number]); if (bg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
return; return;
reset_style:
strcat(reset_style_tag, UNIVERSAL_RESET_TAG);
len = strlen(reset_style_tag);
get_style_tag_for_cell(props, row, col, reset_style_tag + len, sz - len);
return;
error: error:
/* shouldn't be here */ /* shouldn't be here */
assert(0); assert(0);

View File

@ -25,26 +25,6 @@ static const char *fg_colors[] = {
"\033[97m", "\033[97m",
}; };
static const char *reset_fg_colors[] = {
"",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
"\033[39m",
};
static const char *bg_colors[] = { static const char *bg_colors[] = {
"", "",
"\033[40m", "\033[40m",
@ -65,27 +45,6 @@ static const char *bg_colors[] = {
"\033[107m", "\033[107m",
}; };
static const char *reset_bg_colors[] = {
"",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
"\033[49m",
};
static const char *text_styles[] = { static const char *text_styles[] = {
"", "",
"\033[1m", "\033[1m",
@ -97,17 +56,7 @@ static const char *text_styles[] = {
"\033[8m", "\033[8m",
}; };
static const char *reset_text_styles[] = { #define UNIVERSAL_RESET_TAG "\033[0m"
"",
"\033[21m",
"\033[22m",
"\033[23m",
"\033[24m",
"\033[25m",
"\033[27m",
"\033[28m",
};
static const size_t n_fg_colors = sizeof(fg_colors) / sizeof(fg_colors[0]); static const size_t n_fg_colors = sizeof(fg_colors) / sizeof(fg_colors[0]);
static const size_t n_bg_colors = sizeof(bg_colors) / sizeof(bg_colors[0]); static const size_t n_bg_colors = sizeof(bg_colors) / sizeof(bg_colors[0]);
@ -163,7 +112,8 @@ void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
if (text_style < (1U << n_styles)) { if (text_style < (1U << n_styles)) {
for (i = 0; i < n_styles; ++i) { for (i = 0; i < n_styles; ++i) {
if (text_style & (1 << i)) { if (text_style & (1 << i)) {
strcat(reset_style_tag, reset_text_styles[i]); if (i != 0) // FT_TSTYLE_DEFAULT
goto reset_style;
} }
} }
} else { } else {
@ -171,13 +121,19 @@ void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
} }
if (bg_color_number < n_bg_colors) { if (bg_color_number < n_bg_colors) {
strcat(reset_style_tag, reset_bg_colors[bg_color_number]); if (bg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
return; return;
reset_style:
strcat(reset_style_tag, UNIVERSAL_RESET_TAG);
return;
error: error:
/* shouldn't be here */ /* shouldn't be here */
assert(0); assert(0);
@ -209,6 +165,7 @@ void get_style_tag_for_content(const fort_table_properties_t *props,
} }
if (fg_color_number < n_fg_colors) { if (fg_color_number < n_fg_colors) {
if (fg_color_number)
strcat(style_tag, fg_colors[fg_color_number]); strcat(style_tag, fg_colors[fg_color_number]);
} else { } else {
goto error; goto error;
@ -234,6 +191,7 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
{ {
(void)sz; (void)sz;
size_t i = 0; size_t i = 0;
size_t len = 0;
unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE); unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE);
unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR); unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR);
@ -244,7 +202,8 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
if (text_style < (1U << n_styles)) { if (text_style < (1U << n_styles)) {
for (i = 0; i < n_styles; ++i) { for (i = 0; i < n_styles; ++i) {
if (text_style & (1 << i)) { if (text_style & (1 << i)) {
strcat(reset_style_tag, reset_text_styles[i]); if (i != 0) // FT_TSTYLE_DEFAULT
goto reset_style;
} }
} }
} else { } else {
@ -252,19 +211,28 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
} }
if (fg_color_number < n_fg_colors) { if (fg_color_number < n_fg_colors) {
strcat(reset_style_tag, reset_fg_colors[fg_color_number]); if (fg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
if (bg_color_number < n_bg_colors) { if (bg_color_number < n_bg_colors) {
strcat(reset_style_tag, reset_bg_colors[bg_color_number]); if (bg_color_number)
goto reset_style;
} else { } else {
goto error; goto error;
} }
return; return;
reset_style:
strcat(reset_style_tag, UNIVERSAL_RESET_TAG);
len = strlen(reset_style_tag);
get_style_tag_for_cell(props, row, col, reset_style_tag + len, sz - len);
return;
error: error:
/* shouldn't be here */ /* shouldn't be here */
assert(0); assert(0);

View File

@ -9,7 +9,7 @@
#define PROP_SET(ft_props, property) ((ft_props) |=(property)) #define PROP_SET(ft_props, property) ((ft_props) |=(property))
#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property))) #define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property)))
#define TEXT_STYLE_TAG_MAX_SIZE 64 #define TEXT_STYLE_TAG_MAX_SIZE (64 * 2)
FT_INTERNAL FT_INTERNAL
void get_style_tag_for_cell(const fort_table_properties_t *props, void get_style_tag_for_cell(const fort_table_properties_t *props,
@ -73,7 +73,7 @@ FT_INTERNAL
fort_status_t set_default_cell_property(uint32_t property, int value); fort_status_t set_default_cell_property(uint32_t property, int value);
/* TABLE BORDER DESRIPTION /* TABLE BORDER DESСRIPTION
* *
* *
* TL TT TT TT TV TT TT TT TT TT TT TT TR * TL TT TT TT TV TT TT TT TT TT TT TT TR

View File

@ -748,9 +748,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[33m\033[39m |\n" "|\033[33m\033[0m |\n"
"| \033[33m42\033[39m |\n" "| \033[33m42\033[0m |\n"
"|\033[33m\033[39m |\n" "|\033[33m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -767,9 +767,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[33m\033[39m |\n" L"|\033[33m\033[0m |\n"
L"| \033[33m42\033[39m |\n" L"| \033[33m42\033[0m |\n"
L"|\033[33m\033[39m |\n" L"|\033[33m\033[0m |\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -786,9 +786,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[43m\033[49m |\n" "|\033[43m\033[0m |\n"
"| \033[43m42\033[49m |\n" "| \033[43m42\033[0m |\n"
"|\033[43m\033[49m |\n" "|\033[43m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -805,9 +805,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[43m\033[49m |\n" L"|\033[43m\033[0m |\n"
L"| \033[43m42\033[49m |\n" L"| \033[43m42\033[0m |\n"
L"|\033[43m\033[49m |\n" L"|\033[43m\033[0m |\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -824,9 +824,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[43m \033[49m|\n" "|\033[43m \033[0m|\n"
"|\033[43m 42 \033[49m|\n" "|\033[43m 42 \033[0m|\n"
"|\033[43m \033[49m|\n" "|\033[43m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -843,9 +843,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[43m \033[49m|\n" L"|\033[43m \033[0m|\n"
L"|\033[43m 42 \033[49m|\n" L"|\033[43m 42 \033[0m|\n"
L"|\033[43m \033[49m|\n" L"|\033[43m \033[0m|\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -862,9 +862,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[4m\033[24m |\n" "|\033[4m\033[0m |\n"
"| \033[4m42\033[24m |\n" "| \033[4m42\033[0m |\n"
"|\033[4m\033[24m |\n" "|\033[4m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -881,9 +881,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[4m\033[24m |\n" L"|\033[4m\033[0m |\n"
L"| \033[4m42\033[24m |\n" L"| \033[4m42\033[0m |\n"
L"|\033[4m\033[24m |\n" L"|\033[4m\033[0m |\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -901,9 +901,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[1m\033[4m\033[21m\033[24m |\n" "|\033[1m\033[4m\033[0m |\n"
"| \033[1m\033[4m42\033[21m\033[24m |\n" "| \033[1m\033[4m42\033[0m |\n"
"|\033[1m\033[4m\033[21m\033[24m |\n" "|\033[1m\033[4m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -921,9 +921,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[1m\033[4m\033[21m\033[24m |\n" L"|\033[1m\033[4m\033[0m |\n"
L"| \033[1m\033[4m42\033[21m\033[24m |\n" L"| \033[1m\033[4m42\033[0m |\n"
L"|\033[1m\033[4m\033[21m\033[24m |\n" L"|\033[1m\033[4m\033[0m |\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -940,9 +940,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[4m \033[24m|\n" "|\033[4m \033[0m|\n"
"|\033[4m 42 \033[24m|\n" "|\033[4m 42 \033[0m|\n"
"|\033[4m \033[24m|\n" "|\033[4m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -959,9 +959,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[4m \033[24m|\n" L"|\033[4m \033[0m|\n"
L"|\033[4m 42 \033[24m|\n" L"|\033[4m 42 \033[0m|\n"
L"|\033[4m \033[24m|\n" L"|\033[4m \033[0m|\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -979,9 +979,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[1m\033[4m \033[21m\033[24m|\n" "|\033[1m\033[4m \033[0m|\n"
"|\033[1m\033[4m 42 \033[21m\033[24m|\n" "|\033[1m\033[4m 42 \033[0m|\n"
"|\033[1m\033[4m \033[21m\033[24m|\n" "|\033[1m\033[4m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -999,9 +999,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[1m\033[4m \033[21m\033[24m|\n" L"|\033[1m\033[4m \033[0m|\n"
L"|\033[1m\033[4m 42 \033[21m\033[24m|\n" L"|\033[1m\033[4m 42 \033[0m|\n"
L"|\033[1m\033[4m \033[21m\033[24m|\n" L"|\033[1m\033[4m \033[0m|\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -1023,9 +1023,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const char *table_str_etalon = const char *table_str_etalon =
"+----+\n" "+----+\n"
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" "|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
"|\033[41m \033[4m\033[33m42\033[24m\033[39m \033[49m|\n" "|\033[41m \033[4m\033[33m42\033[0m\033[41m \033[0m|\n"
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" "|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_str_equal(table_str, table_str_etalon); assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);
@ -1046,9 +1046,9 @@ void test_table_text_styles(void)
assert_true(table_str != NULL); assert_true(table_str != NULL);
const wchar_t *table_str_etalon = const wchar_t *table_str_etalon =
L"+----+\n" L"+----+\n"
L"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" L"|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
L"|\033[41m \033[4m\033[33m42\033[24m\033[39m \033[49m|\n" L"|\033[41m \033[4m\033[33m42\033[0m\033[41m \033[0m|\n"
L"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" L"|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
L"+----+\n"; L"+----+\n";
assert_wcs_equal(table_str, table_str_etalon); assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table); ft_destroy_table(table);

View File

@ -558,9 +558,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[33m\033[39m |\n" "|\033[33m\033[0m |\n"
"| \033[33m42\033[39m |\n" "| \033[33m42\033[0m |\n"
"|\033[33m\033[39m |\n" "|\033[33m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -574,9 +574,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[43m\033[49m |\n" "|\033[43m\033[0m |\n"
"| \033[43m42\033[49m |\n" "| \033[43m42\033[0m |\n"
"|\033[43m\033[49m |\n" "|\033[43m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -590,9 +590,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[43m \033[49m|\n" "|\033[43m \033[0m|\n"
"|\033[43m 42 \033[49m|\n" "|\033[43m 42 \033[0m|\n"
"|\033[43m \033[49m|\n" "|\033[43m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -606,9 +606,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[4m\033[24m |\n" "|\033[4m\033[0m |\n"
"| \033[4m42\033[24m |\n" "| \033[4m42\033[0m |\n"
"|\033[4m\033[24m |\n" "|\033[4m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -623,9 +623,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[1m\033[4m\033[21m\033[24m |\n" "|\033[1m\033[4m\033[0m |\n"
"| \033[1m\033[4m42\033[21m\033[24m |\n" "| \033[1m\033[4m42\033[0m |\n"
"|\033[1m\033[4m\033[21m\033[24m |\n" "|\033[1m\033[4m\033[0m |\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -639,9 +639,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[4m \033[24m|\n" "|\033[4m \033[0m|\n"
"|\033[4m 42 \033[24m|\n" "|\033[4m 42 \033[0m|\n"
"|\033[4m \033[24m|\n" "|\033[4m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -656,9 +656,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[1m\033[4m \033[21m\033[24m|\n" "|\033[1m\033[4m \033[0m|\n"
"|\033[1m\033[4m 42 \033[21m\033[24m|\n" "|\033[1m\033[4m 42 \033[0m|\n"
"|\033[1m\033[4m \033[21m\033[24m|\n" "|\033[1m\033[4m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }
@ -674,9 +674,9 @@ void test_cpp_table_text_styles(void)
std::string table_str = table.to_string(); std::string table_str = table.to_string();
std::string table_str_etalon = std::string table_str_etalon =
"+----+\n" "+----+\n"
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" "|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
"|\033[41m \033[4m\033[33m42\033[24m\033[39m \033[49m|\n" "|\033[41m \033[4m\033[33m42\033[0m\033[41m \033[0m|\n"
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n" "|\033[41m\033[4m\033[33m\033[0m\033[41m \033[0m|\n"
"+----+\n"; "+----+\n";
assert_string_equal(table_str, table_str_etalon); assert_string_equal(table_str, table_str_etalon);
} }

View File

@ -12,11 +12,11 @@ void test_cpp_table_text_styles(void);
struct test_case bb_test_suite [] = { struct test_case bb_test_suite [] = {
// {"test_cpp_table_basic", test_cpp_table_basic}, {"test_cpp_table_basic", test_cpp_table_basic},
{"test_cpp_table_write", test_cpp_table_write}, {"test_cpp_table_write", test_cpp_table_write},
// {"test_cpp_table_tbl_properties", test_cpp_table_tbl_properties}, {"test_cpp_table_tbl_properties", test_cpp_table_tbl_properties},
// {"test_cpp_table_cell_properties", test_cpp_table_cell_properties}, {"test_cpp_table_cell_properties", test_cpp_table_cell_properties},
// {"test_cpp_table_text_styles", test_cpp_table_text_styles}, {"test_cpp_table_text_styles", test_cpp_table_text_styles},
}; };