1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

style.(fg|bg) -> style.color.(fg|bg)

Introduce INIT_TEXT_STYLE() macro to initialize struct text_style.
This commit is contained in:
Laurent MONIN 2007-10-10 14:50:56 +02:00
parent ca6424595b
commit 944a8e7bd9
13 changed files with 40 additions and 36 deletions

View File

@ -46,7 +46,7 @@ css_apply_color(struct html_context *html_context, struct html_element *element,
assert(prop->value_type == CSS_VT_COLOR);
if (use_document_fg_colors(html_context->options))
element->attr.style.fg = prop->value.color;
element->attr.style.color.fg = prop->value.color;
}
static void
@ -57,7 +57,7 @@ css_apply_background_color(struct html_context *html_context,
assert(prop->value_type == CSS_VT_COLOR);
if (use_document_bg_colors(html_context->options))
element->attr.style.bg = prop->value.color;
element->attr.style.color.bg = prop->value.color;
}
static void

View File

@ -99,7 +99,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
init_dom_renderer(&renderer, document, buffer, convert_table);
document->bgcolor = document->options.default_style.bg;
document->bgcolor = document->options.default_style.color.bg;
#ifdef CONFIG_UTF8
document->options.utf8 = is_cp_utf8(document->options.cp);
#endif /* CONFIG_UTF8 */

View File

@ -31,7 +31,7 @@ static inline void
init_template(struct screen_char *template, struct document_options *options,
enum screen_char_attr attr, color_T foreground, color_T background)
{
struct text_style style = { attr, foreground, background };
struct text_style style = INIT_TEXT_STYLE(attr, foreground, background);
get_screen_char_template(template, options, style);
}
@ -50,10 +50,10 @@ init_template_by_style(struct screen_char *template, struct document_options *op
case CSS_PT_BACKGROUND_COLOR:
case CSS_PT_BACKGROUND:
if (property->value_type == CSS_VT_COLOR)
style.bg = property->value.color;
style.color.bg = property->value.color;
break;
case CSS_PT_COLOR:
style.fg = property->value.color;
style.color.fg = property->value.color;
break;
case CSS_PT_FONT_WEIGHT:
case CSS_PT_FONT_STYLE:
@ -288,7 +288,7 @@ add_dom_link(struct dom_renderer *renderer, unsigned char *string, int length,
link->npoints = length;
link->type = LINK_HYPERTEXT;
link->where = where;
link->color.background = document->options.default_style.bg;
link->color.background = document->options.default_style.color.bg;
link->color.foreground = fgcolor;
link->number = document->nlinks;

View File

@ -40,7 +40,7 @@ get_screen_char_template(struct screen_char *template,
}
{
struct color_pair colors = INIT_COLOR_PAIR(style.bg, style.fg);
struct color_pair colors = INIT_COLOR_PAIR(style.color.bg, style.color.fg);
set_term_color(template, &colors, options->color_flags, options->color_mode);
}
}

View File

@ -18,10 +18,14 @@ enum text_style_format {
struct text_style {
enum text_style_format attr;
color_T fg;
color_T bg;
struct {
color_T fg;
color_T bg;
} color;
};
#define INIT_TEXT_STYLE(attr, fg, bg) { attr, {fg, bg}}
void get_screen_char_template(struct screen_char *template, struct document_options *options, struct text_style style);
#endif

View File

@ -915,7 +915,7 @@ init_html_parser(struct uri *uri, struct document_options *options,
par_format.dd_margin = options->margin;
par_format.flags = P_NONE;
par_format.bgcolor = options->default_style.bg;
par_format.bgcolor = options->default_style.color.bg;
html_top->invisible = 0;
html_top->name = NULL;

View File

@ -158,18 +158,18 @@ html_font(struct html_context *html_context, unsigned char *a,
}
mem_free(al);
}
get_color(html_context, a, "color", &format.style.fg);
get_color(html_context, a, "color", &format.style.color.fg);
}
void
html_body(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
get_color(html_context, a, "text", &format.style.fg);
get_color(html_context, a, "text", &format.style.color.fg);
get_color(html_context, a, "link", &format.color.clink);
get_color(html_context, a, "vlink", &format.color.vlink);
if (get_bgcolor(html_context, a, &format.style.bg) != -1)
if (get_bgcolor(html_context, a, &format.style.color.bg) != -1)
html_context->was_body_background = 1;
html_context->was_body = 1; /* this will be used by "meta inside body" */
@ -187,17 +187,17 @@ html_apply_canvas_bgcolor(struct html_context *html_context)
&html_context->stack);
#endif
if (par_format.bgcolor != format.style.bg) {
if (par_format.bgcolor != format.style.color.bg) {
/* Modify the root HTML element - format_html_part() will take
* this from there. */
struct html_element *e = html_bottom;
html_context->was_body_background = 1;
e->parattr.bgcolor = e->attr.style.bg = par_format.bgcolor = format.style.bg;
e->parattr.bgcolor = e->attr.style.color.bg = par_format.bgcolor = format.style.color.bg;
}
if (html_context->has_link_lines
&& par_format.bgcolor != html_context->options->default_style.bg
&& par_format.bgcolor != html_context->options->default_style.color.bg
&& !search_html_stack(html_context, "BODY")) {
html_context->special_f(html_context, SP_COLOR_LINK_LINES);
}
@ -416,8 +416,8 @@ html_html(struct html_context *html_context, unsigned char *a,
* this from there. */
struct html_element *e = html_bottom;
if (par_format.bgcolor != format.style.bg)
e->parattr.bgcolor = e->attr.style.bg = par_format.bgcolor = format.style.bg;
if (par_format.bgcolor != format.style.color.bg)
e->parattr.bgcolor = e->attr.style.color.bg = par_format.bgcolor = format.style.color.bg;
}
void

View File

@ -66,19 +66,19 @@ html_a(struct html_context *html_context, unsigned char *a,
; /* Shut up compiler */
#ifdef CONFIG_GLOBHIST
} else if (get_global_history_item(format.link)) {
format.style.fg = format.color.vlink;
format.style.color.fg = format.color.vlink;
html_top->pseudo_class &= ~ELEMENT_LINK;
html_top->pseudo_class |= ELEMENT_VISITED;
#endif
#ifdef CONFIG_BOOKMARKS
} else if (get_bookmark(format.link)) {
format.style.fg = format.color.bookmark_link;
format.style.color.fg = format.color.bookmark_link;
html_top->pseudo_class &= ~ELEMENT_VISITED;
/* XXX: Really set ELEMENT_LINK? --pasky */
html_top->pseudo_class |= ELEMENT_LINK;
#endif
} else {
format.style.fg = format.color.clink;
format.style.color.fg = format.color.clink;
html_top->pseudo_class &= ~ELEMENT_VISITED;
html_top->pseudo_class |= ELEMENT_LINK;
}
@ -198,10 +198,10 @@ put_image_label(unsigned char *a, unsigned char *label,
* extension to the standard. After all, it makes sense. */
html_focusable(html_context, a);
fg = format.style.fg;
format.style.fg = format.color.image_link;
fg = format.style.color.fg;
format.style.color.fg = format.color.image_link;
put_chrs(html_context, label, strlen(label));
format.style.fg = fg;
format.style.color.fg = fg;
}
static void
@ -367,7 +367,7 @@ put_link_line(unsigned char *prefix, unsigned char *linkname,
put_chrs(html_context, prefix, strlen(prefix));
format.link = join_urls(html_context->base_href, link);
format.target = stracpy(target);
format.style.fg = format.color.clink;
format.style.color.fg = format.color.clink;
/* FIXME: linkname typically comes from get_attr_val, which
* has already converted it from the document charset to the
* terminal charset and expanded character entity references.

View File

@ -887,7 +887,7 @@ start_element(struct element_info *ei,
/* XXX: Put something better to format.link. --pasky */
mem_free_set(&format.link, stracpy("javascript:void(0);"));
mem_free_set(&format.target, stracpy(html_context->base_target));
format.style.fg = format.color.clink;
format.style.color.fg = format.color.clink;
html_top->pseudo_class = ELEMENT_LINK;
mem_free_set(&format.title, stracpy("onClick placeholder"));
/* Er. I know. Well, double html_focusable()s shouldn't

View File

@ -329,7 +329,7 @@ static inline struct screen_char *
get_format_screen_char(struct html_context *html_context,
enum link_state link_state)
{
static struct text_style ta_cache = { -1, 0x0, 0x0 };
static struct text_style ta_cache = INIT_TEXT_STYLE(-1, 0x0, 0x0);
static struct screen_char schar_cache;
if (memcmp(&ta_cache, &format.style, sizeof(ta_cache))) {
@ -1304,9 +1304,9 @@ new_link(struct html_context *html_context, unsigned char *name, int namelen)
link->target = null_or_stracpy(form ? form->target : NULL);
}
link->color.background = format.style.bg;
link->color.background = format.style.color.bg;
link->color.foreground = link_is_textinput(link)
? format.style.fg : format.color.clink;
? format.style.color.fg : format.color.clink;
init_link_event_hooks(html_context, link);

View File

@ -872,7 +872,7 @@ draw_table_cell(struct table *table, int col, int row, int x, int y,
if (cell->is_header) format.style.attr |= AT_BOLD;
format.style.bg = cell->bgcolor;
format.style.color.bg = cell->bgcolor;
par_format.bgcolor = cell->bgcolor;
if (cell->valign == VALIGN_MIDDLE)

View File

@ -37,8 +37,8 @@ init_document_options(struct session *ses, struct document_options *doo)
doo->default_form_input_size = get_opt_int("document.browse.forms.input_size", ses);
/* Color options. */
doo->default_style.fg = get_opt_color("document.colors.text", ses);
doo->default_style.bg = get_opt_color("document.colors.background", ses);
doo->default_style.color.fg = get_opt_color("document.colors.text", ses);
doo->default_style.color.bg = get_opt_color("document.colors.background", ses);
doo->default_link = get_opt_color("document.colors.link", ses);
doo->default_vlink = get_opt_color("document.colors.vlink", ses);
#ifdef CONFIG_BOOKMARKS

View File

@ -93,7 +93,7 @@ add_document_link(struct document *document, unsigned char *uri, int length,
link->npoints = length;
link->type = LINK_HYPERTEXT;
link->where = uri;
link->color.background = document->options.default_style.bg;
link->color.background = document->options.default_style.color.bg;
link->color.foreground = document->options.default_link;
link->number = document->nlinks;
@ -214,7 +214,7 @@ print_document_link(struct plain_renderer *renderer, int lineno,
line[link_end] = saved_char;
new_link->color.background = doc_opts->default_style.bg;
new_link->color.background = doc_opts->default_style.color.bg;
set_term_color(&template, &new_link->color,
doc_opts->color_flags, doc_opts->color_mode);
@ -637,7 +637,7 @@ render_plain_document(struct cache_entry *cached, struct document *document,
renderer.max_width = document->options.wrap ? document->options.box.width
: INT_MAX;
document->bgcolor = document->options.default_style.bg;
document->bgcolor = document->options.default_style.color.bg;
document->width = 0;
#ifdef CONFIG_UTF8
document->options.utf8 = is_cp_utf8(document->options.cp);