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

document: Move text_style-related stuff to dedicated format.*

We will need to include it from options.h and the include chain just
wouldn't work. And it feels like a hack to have it in renderer.h anyway.
This commit is contained in:
Petr Baudis 2007-08-28 21:05:00 +02:00 committed by Petr Baudis
parent b66d2bec67
commit db9431465f
11 changed files with 82 additions and 56 deletions

View File

@ -6,6 +6,6 @@ SUBDIRS-$(CONFIG_DOM) += dom
SUBDIRS = html plain
OBJS = docdata.o document.o forms.o options.o refresh.o renderer.o
OBJS = docdata.o document.o format.o forms.o options.o refresh.o renderer.o
include $(top_srcdir)/Makefile.lib

View File

@ -21,6 +21,7 @@
#include "document/css/property.h"
#include "document/css/scanner.h"
#include "document/css/stylesheet.h"
#include "document/format.h"
#include "document/html/parser/parse.h"
#include "document/options.h"
#include "util/align.h"

View File

@ -2,7 +2,8 @@
#ifndef EL__DOCUMENT_CSS_PROPERTY_H
#define EL__DOCUMENT_CSS_PROPERTY_H
#include "document/html/parser.h"
#include "document/format.h"
#include "util/align.h"
#include "util/color.h"
#include "util/lists.h"

View File

@ -2,6 +2,7 @@
#ifndef EL__DOCUMENT_CSS_STYLESHEET_H
#define EL__DOCUMENT_CSS_STYLESHEET_H
#include "protocol/uri.h"
#include "util/lists.h"
/* #define DEBUG_CSS */

View File

@ -17,6 +17,7 @@
#include "document/docdata.h"
#include "document/document.h"
#include "document/dom/util.h"
#include "document/format.h"
#include "intl/charsets.h"
#include "globhist/globhist.h" /* get_global_history_item() */
#include "protocol/uri.h"

46
src/document/format.c Normal file
View File

@ -0,0 +1,46 @@
/** Format attributes utilities
* @file */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "elinks.h"
#include "document/format.h"
#include "document/options.h"
#include "terminal/draw.h"
#include "util/color.h"
void
get_screen_char_template(struct screen_char *template,
struct document_options *options,
struct text_style style)
{
template->attr = 0;
template->data = ' ';
if (style.attr) {
if (style.attr & AT_UNDERLINE) {
template->attr |= SCREEN_ATTR_UNDERLINE;
}
if (style.attr & AT_BOLD) {
template->attr |= SCREEN_ATTR_BOLD;
}
if (style.attr & AT_ITALIC) {
template->attr |= SCREEN_ATTR_ITALIC;
}
if (style.attr & AT_GRAPHICS) {
template->attr |= SCREEN_ATTR_FRAME;
}
}
{
struct color_pair colors = INIT_COLOR_PAIR(style.bg, style.fg);
set_term_color(template, &colors, options->color_flags, options->color_mode);
}
}

28
src/document/format.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef EL__DOCUMENT_FORMAT_H
#define EL__DOCUMENT_FORMAT_H
#include "util/color.h"
struct document_options;
struct screen_char;
enum text_style_format {
AT_BOLD = 1,
AT_ITALIC = 2,
AT_UNDERLINE = 4,
AT_FIXED = 8,
AT_GRAPHICS = 16,
AT_PREFORMATTED = 32,
};
struct text_style {
enum text_style_format attr;
color_T fg;
color_T bg;
};
void get_screen_char_template(struct screen_char *template, struct document_options *options, struct text_style style);
#endif

View File

@ -2,7 +2,7 @@
#ifndef EL__DOCUMENT_HTML_PARSER_H
#define EL__DOCUMENT_HTML_PARSER_H
#include "document/renderer.h"
#include "document/format.h"
#include "intl/charsets.h" /* unicode_val_T */
#include "util/align.h"
#include "util/color.h"

View File

@ -14,6 +14,7 @@
#include "config/options.h"
#include "document/docdata.h"
#include "document/document.h"
#include "document/format.h"
#include "document/options.h"
#include "document/plain/renderer.h"
#include "document/renderer.h"

View File

@ -31,7 +31,6 @@
#include "protocol/uri.h"
#include "session/location.h"
#include "session/session.h"
#include "terminal/draw.h"
#include "terminal/terminal.h"
#include "terminal/window.h"
#include "util/error.h"
@ -625,36 +624,3 @@ get_convert_table(unsigned char *head, int to_cp,
return get_translation_table(cp_index, to_cp);
}
void
get_screen_char_template(struct screen_char *template,
struct document_options *options,
struct text_style style)
{
template->attr = 0;
template->data = ' ';
if (style.attr) {
if (style.attr & AT_UNDERLINE) {
template->attr |= SCREEN_ATTR_UNDERLINE;
}
if (style.attr & AT_BOLD) {
template->attr |= SCREEN_ATTR_BOLD;
}
if (style.attr & AT_ITALIC) {
template->attr |= SCREEN_ATTR_ITALIC;
}
if (style.attr & AT_GRAPHICS) {
template->attr |= SCREEN_ATTR_FRAME;
}
}
{
struct color_pair colors = INIT_COLOR_PAIR(style.bg, style.fg);
set_term_color(template, &colors, options->color_flags, options->color_mode);
}
}

View File

@ -10,25 +10,6 @@ struct session;
struct view_state;
struct screen_char;
enum text_style_format {
AT_BOLD = 1,
AT_ITALIC = 2,
AT_UNDERLINE = 4,
AT_FIXED = 8,
AT_GRAPHICS = 16,
AT_PREFORMATTED = 32,
};
struct text_style {
enum text_style_format attr;
color_T fg;
color_T bg;
};
void get_screen_char_template(struct screen_char *template, struct document_options *options, struct text_style style);
void render_document(struct view_state *, struct document_view *, struct document_options *);
void render_document_frames(struct session *ses, int no_cache);
struct conv_table *get_convert_table(unsigned char *head, int to_cp, int default_cp, int *from_cp, enum cp_status *cp_status, int ignore_server_cp);