[F] Fixed reset style tag
This commit is contained in:
@@ -25,26 +25,6 @@ static const char *fg_colors[] = {
|
||||
"\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[] = {
|
||||
"",
|
||||
"\033[40m",
|
||||
@@ -65,27 +45,6 @@ static const char *bg_colors[] = {
|
||||
"\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[] = {
|
||||
"",
|
||||
"\033[1m",
|
||||
@@ -97,17 +56,7 @@ static const char *text_styles[] = {
|
||||
"\033[8m",
|
||||
};
|
||||
|
||||
static const char *reset_text_styles[] = {
|
||||
"",
|
||||
"\033[21m",
|
||||
"\033[22m",
|
||||
"\033[23m",
|
||||
"\033[24m",
|
||||
"\033[25m",
|
||||
"\033[27m",
|
||||
"\033[28m",
|
||||
};
|
||||
|
||||
#define UNIVERSAL_RESET_TAG "\033[0m"
|
||||
|
||||
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]);
|
||||
@@ -163,7 +112,8 @@ void get_reset_style_tag_for_cell(const fort_table_properties_t *props,
|
||||
if (text_style < (1U << n_styles)) {
|
||||
for (i = 0; i < n_styles; ++i) {
|
||||
if (text_style & (1 << i)) {
|
||||
strcat(reset_style_tag, reset_text_styles[i]);
|
||||
if (i != 0) // FT_TSTYLE_DEFAULT
|
||||
goto reset_style;
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
strcat(reset_style_tag, reset_bg_colors[bg_color_number]);
|
||||
if (bg_color_number)
|
||||
goto reset_style;
|
||||
} else {
|
||||
goto error;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
reset_style:
|
||||
strcat(reset_style_tag, UNIVERSAL_RESET_TAG);
|
||||
return;
|
||||
|
||||
error:
|
||||
/* shouldn't be here */
|
||||
assert(0);
|
||||
@@ -209,7 +165,8 @@ void get_style_tag_for_content(const fort_table_properties_t *props,
|
||||
}
|
||||
|
||||
if (fg_color_number < n_fg_colors) {
|
||||
strcat(style_tag, fg_colors[fg_color_number]);
|
||||
if (fg_color_number)
|
||||
strcat(style_tag, fg_colors[fg_color_number]);
|
||||
} else {
|
||||
goto error;
|
||||
}
|
||||
@@ -234,6 +191,7 @@ void get_reset_style_tag_for_content(const fort_table_properties_t *props,
|
||||
{
|
||||
(void)sz;
|
||||
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 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)) {
|
||||
for (i = 0; i < n_styles; ++i) {
|
||||
if (text_style & (1 << i)) {
|
||||
strcat(reset_style_tag, reset_text_styles[i]);
|
||||
if (i != 0) // FT_TSTYLE_DEFAULT
|
||||
goto reset_style;
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
strcat(reset_style_tag, reset_fg_colors[fg_color_number]);
|
||||
if (fg_color_number)
|
||||
goto reset_style;
|
||||
} else {
|
||||
goto error;
|
||||
}
|
||||
|
||||
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 {
|
||||
goto error;
|
||||
}
|
||||
|
||||
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:
|
||||
/* shouldn't be here */
|
||||
assert(0);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#define PROP_SET(ft_props, property) ((ft_props) |=(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
|
||||
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);
|
||||
|
||||
|
||||
/* TABLE BORDER DESRIPTION
|
||||
/* TABLE BORDER DESСRIPTION
|
||||
*
|
||||
*
|
||||
* TL TT TT TT TV TT TT TT TT TT TT TT TR
|
||||
|
Reference in New Issue
Block a user