Fix compilation using --enable-html-highlight.
[elinks.git] / src / document / options.h
blob19ad801e8438859ffb9c40585c561e1a9b68cfdb
1 #ifndef EL__DOCUMENT_OPTIONS_H
2 #define EL__DOCUMENT_OPTIONS_H
4 #include "document/format.h"
5 #include "terminal/color.h"
6 #include "util/color.h"
7 #include "util/box.h"
9 struct session;
11 /** Active link coloring options */
12 struct active_link_options {
13 unsigned int color:1;
14 unsigned int underline:1;
15 unsigned int bold:1;
16 unsigned int invert:1;
17 color_T fg;
18 color_T bg;
21 /** This mostly acts as a option cache so rendering will be faster. However it
22 * is also used to validate and invalidate documents in the format cache as to
23 * whether they satisfy the current state of the document options. */
24 struct document_options {
25 enum color_mode color_mode;
26 /** cp is the codepage for which the document is being formatted;
27 * typically it is the codepage of a terminal. It is set in
28 * render_document_frames(). */
29 int cp, assume_cp, hard_assume;
30 int margin;
31 int num_links_key;
32 int use_document_colors;
33 int meta_link_display;
34 int default_form_input_size;
36 /** @name The default (fallback) colors.
37 * @{ */
38 struct text_style default_style;
39 color_T default_link;
40 color_T default_vlink;
41 #ifdef CONFIG_BOOKMARKS
42 color_T default_bookmark_link;
43 #endif
44 color_T default_image_link;
45 /** @} */
47 /** Color model/optimizations */
48 enum color_flags color_flags;
50 /* XXX: Keep boolean options grouped to save padding */
51 #ifdef CONFIG_CSS
52 /** @name CSS stuff
53 * @{ */
54 unsigned int css_enable:1;
55 unsigned int css_import:1;
56 /** @} */
57 #endif
59 /** @name HTML stuff
60 * @{ */
61 unsigned int tables:1;
62 unsigned int table_order:1;
63 unsigned int frames:1;
64 unsigned int images:1;
66 unsigned int display_subs:1;
67 unsigned int display_sups:1;
68 unsigned int underline_links:1;
70 unsigned int wrap_nbsp:1;
71 /** @} */
73 /** @name Plain rendering stuff
74 * @{ */
75 unsigned int plain_display_links:1;
76 unsigned int plain_compress_empty_lines:1;
77 /** @} */
79 /** @name Link navigation
80 * @{ */
81 unsigned int links_numbering:1;
82 unsigned int use_tabindex:1;
83 /** @} */
85 unsigned int plain:1;
86 unsigned int wrap:1;
88 /* XXX: Everything past this comment is specialy handled by compare_opt() */
89 unsigned char *framename;
91 /** The location of the window in which the document is rendered.
93 * <dl>
94 * <dt>The position of the window (box.x and box.y)
96 * <dd>This is not compared at all since it doesn't make any
97 * difference what position the document will fit into a frameset
98 * or so.
100 * <dt>The width of the window (box.width)
102 * <dd>This controls how wide tables can be rendered and so on. It is
103 * thus also to blame for the extra memory consumption when
104 * resizing because all documents has to be rerendered. We only
105 * need to compare it if not #plain.
107 * <dt>The height of the window (box.height)
109 * <dd>Only documents containing textarea or frames uses it and we
110 * only compare it if #needs_height is set.
111 * </dl> */
112 struct box box;
113 unsigned int needs_height:1;
114 unsigned int needs_width:1;
116 /** Internal flag for rerendering */
117 unsigned int no_cache:1;
118 unsigned int gradual_rerendering:1;
120 #ifdef CONFIG_UTF8
121 unsigned int utf8:1;
122 #endif /* CONFIG_UTF8 */
123 /** Active link coloring.
124 * This is mostly here to make use of this option cache so
125 * link drawing is faster. --jonas */
126 struct active_link_options active_link;
128 /** Options related with IMG tag */
129 struct {
130 unsigned char *prefix;
131 unsigned char *suffix;
132 int filename_maxlen;
133 int label_maxlen;
134 int display_style;
135 int tagging;
136 unsigned int show_any_as_links:1;
137 } image_link;
140 /** Fills the structure with values from the option system.
141 * @relates document_options */
142 void init_document_options(struct document_options *doo);
144 /** Free allocated document options.
145 * @relates document_options */
146 void done_document_options(struct document_options *options);
148 /** Copies the values of one struct @a from to the other @a to.
149 * Note that the document_options.framename is dynamically allocated.
150 * @relates document_options */
151 void copy_opt(struct document_options *to, struct document_options *from);
153 /* Compares comparable values from the two structures according to
154 * the comparable members described in the struct definition.
155 * @relates document_options */
156 int compare_opt(struct document_options *o1, struct document_options *o2);
158 #define use_document_fg_colors(o) \
159 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors >= 1)
161 #define use_document_bg_colors(o) \
162 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors == 2)
164 /** Increments the numeric value of the option identified by @a option_name,
165 * resetting it to the minimum value when it is already at the maximum value,
166 * and redraws the document. */
167 void toggle_document_option(struct session *ses, unsigned char *option_name);
169 #endif