1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

document: Turn options' default_fg, default_bg to default_style

...as struct text_style. This way it might be possible later to
add other default formatting attributes by CSS and it allows
quite a code simplification in the DOM renderer.
This commit is contained in:
Petr Baudis 2007-08-28 21:16:44 +02:00 committed by Petr Baudis
parent db9431465f
commit 55495ab655
9 changed files with 17 additions and 20 deletions

View File

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

View File

@ -214,8 +214,8 @@ dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
for (type = 0; type < RSS_STYLES; type++) { for (type = 0; type < RSS_STYLES; type++) {
struct screen_char *template = &data->styles[type]; struct screen_char *template = &data->styles[type];
color_T background = document->options.default_bg; color_T background = document->options.default_style.bg;
color_T foreground = document->options.default_fg; color_T foreground = document->options.default_style.fg;
static int i_want_struct_module_for_dom; static int i_want_struct_module_for_dom;
static unsigned char *names[RSS_STYLES] = { "title", "aux" }; static unsigned char *names[RSS_STYLES] = { "title", "aux" };

View File

@ -342,8 +342,8 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *
for (type = 0; type < DOM_NODES; type++) { for (type = 0; type < DOM_NODES; type++) {
struct screen_char *template = &data->styles[type]; struct screen_char *template = &data->styles[type];
color_T background = document->options.default_bg; color_T background = document->options.default_style.bg;
color_T foreground = document->options.default_fg; color_T foreground = document->options.default_style.fg;
static int i_want_struct_module_for_dom; static int i_want_struct_module_for_dom;
struct dom_string *name = get_dom_node_type_name(type); struct dom_string *name = get_dom_node_type_name(type);

View File

@ -292,7 +292,7 @@ add_dom_link(struct dom_renderer *renderer, unsigned char *string, int length,
link->npoints = length; link->npoints = length;
link->type = LINK_HYPERTEXT; link->type = LINK_HYPERTEXT;
link->where = where; link->where = where;
link->color.background = document->options.default_bg; link->color.background = document->options.default_style.bg;
link->color.foreground = fgcolor; link->color.foreground = fgcolor;
link->number = document->nlinks; link->number = document->nlinks;

View File

@ -801,8 +801,7 @@ init_html_parser(struct uri *uri, struct document_options *options,
format.form = NULL; format.form = NULL;
format.title = NULL; format.title = NULL;
format.style.fg = options->default_fg; format.style = options->default_style;
format.style.bg = options->default_bg;
format.clink = options->default_link; format.clink = options->default_link;
format.vlink = options->default_vlink; format.vlink = options->default_vlink;
#ifdef CONFIG_BOOKMARKS #ifdef CONFIG_BOOKMARKS
@ -819,7 +818,7 @@ init_html_parser(struct uri *uri, struct document_options *options,
par_format.dd_margin = options->margin; par_format.dd_margin = options->margin;
par_format.flags = P_NONE; par_format.flags = P_NONE;
par_format.bgcolor = options->default_bg; par_format.bgcolor = options->default_style.bg;
html_top->invisible = 0; html_top->invisible = 0;
html_top->name = NULL; html_top->name = NULL;

View File

@ -197,7 +197,7 @@ html_apply_canvas_bgcolor(struct html_context *html_context)
} }
if (html_context->has_link_lines if (html_context->has_link_lines
&& par_format.bgcolor != html_context->options->default_bg && par_format.bgcolor != html_context->options->default_style.bg
&& !search_html_stack(html_context, "BODY")) { && !search_html_stack(html_context, "BODY")) {
html_context->special_f(html_context, SP_COLOR_LINK_LINES); html_context->special_f(html_context, SP_COLOR_LINK_LINES);
} }

View File

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

View File

@ -1,6 +1,7 @@
#ifndef EL__DOCUMENT_OPTIONS_H #ifndef EL__DOCUMENT_OPTIONS_H
#define EL__DOCUMENT_OPTIONS_H #define EL__DOCUMENT_OPTIONS_H
#include "document/format.h"
#include "terminal/color.h" #include "terminal/color.h"
#include "util/color.h" #include "util/color.h"
#include "util/box.h" #include "util/box.h"
@ -34,8 +35,7 @@ struct document_options {
/** @name The default (fallback) colors. /** @name The default (fallback) colors.
* @{ */ * @{ */
color_T default_fg; struct text_style default_style;
color_T default_bg;
color_T default_link; color_T default_link;
color_T default_vlink; color_T default_vlink;
#ifdef CONFIG_BOOKMARKS #ifdef CONFIG_BOOKMARKS

View File

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