template -> template_ for C++ compatibility
[elinks.git] / src / document / options.h
blob9fc2baff1f870792cad024a5baab35f040840ee6
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_colors {
13 color_T foreground;
14 color_T background;
17 struct active_link_options {
18 unsigned int enable_color:1;
19 unsigned int underline:1;
20 unsigned int bold:1;
21 unsigned int invert:1;
22 struct active_link_options_colors color;
25 /** This mostly acts as a option cache so rendering will be faster. However it
26 * is also used to validate and invalidate documents in the format cache as to
27 * whether they satisfy the current state of the document options. */
28 struct document_options_colors {
29 color_T link;
30 color_T vlink;
31 #ifdef CONFIG_BOOKMARKS
32 color_T bookmark_link;
33 #endif
34 color_T image_link;
37 struct document_options_image_link {
38 unsigned char *prefix;
39 unsigned char *suffix;
40 int filename_maxlen;
41 int label_maxlen;
42 int display_style;
43 int tagging;
44 unsigned int show_any_as_links:1;
47 struct document_options {
48 enum color_mode color_mode;
49 /** cp is the codepage for which the document is being formatted;
50 * typically it is the codepage of a terminal. It is set in
51 * render_document_frames(). */
52 int cp, assume_cp, hard_assume;
53 int margin;
54 int num_links_key;
55 int use_document_colors;
56 int meta_link_display;
57 int default_form_input_size;
59 /** @name The default (fallback) colors.
60 * @{ */
61 struct text_style default_style;
62 struct document_options_colors default_color;
63 /** @} */
65 /** Color model/optimizations */
66 enum color_flags color_flags;
68 /* XXX: Keep boolean options grouped to save padding */
69 #ifdef CONFIG_CSS
70 /** @name CSS stuff
71 * @{ */
72 unsigned int css_enable:1;
73 unsigned int css_import:1;
74 unsigned int css_ignore_display_none:1;
75 /** @} */
76 #endif
78 /** @name HTML stuff
79 * @{ */
80 unsigned int tables:1;
81 unsigned int table_order:1;
82 unsigned int frames:1;
83 unsigned int images:1;
85 unsigned int display_subs:1;
86 unsigned int display_sups:1;
87 unsigned int underline_links:1;
89 unsigned int wrap_nbsp:1;
90 /** @} */
92 /** @name Plain rendering stuff
93 * @{ */
94 unsigned int plain_display_links:1;
95 unsigned int plain_compress_empty_lines:1;
96 /** @} */
98 /** @name Link navigation
99 * @{ */
100 unsigned int links_numbering:1;
101 unsigned int use_tabindex:1;
102 /** @} */
104 unsigned int plain:1;
105 unsigned int wrap:1;
107 /* XXX: Everything past this comment is specialy handled by compare_opt() */
108 unsigned char *framename;
110 /** The location of the window in which the document is rendered.
112 * <dl>
113 * <dt>The position of the window (box.x and box.y)
115 * <dd>This is not compared at all since it doesn't make any
116 * difference what position the document will fit into a frameset
117 * or so.
119 * <dt>The width of the window (box.width)
121 * <dd>This controls how wide tables can be rendered and so on. It is
122 * thus also to blame for the extra memory consumption when
123 * resizing because all documents has to be rerendered. We only
124 * need to compare it if not #plain.
126 * <dt>The height of the window (box.height)
128 * <dd>Only documents containing textarea or frames uses it and we
129 * only compare it if #needs_height is set.
130 * </dl> */
131 struct box box;
132 unsigned int needs_height:1;
133 unsigned int needs_width:1;
135 /** Internal flag for rerendering */
136 unsigned int no_cache:1;
137 unsigned int gradual_rerendering:1;
139 #ifdef CONFIG_UTF8
140 unsigned int utf8:1;
141 #endif /* CONFIG_UTF8 */
142 /** Active link coloring.
143 * This is mostly here to make use of this option cache so
144 * link drawing is faster. --jonas */
145 struct active_link_options active_link;
147 /** Options related with IMG tag */
148 struct document_options_image_link image_link;
151 /** Fills the structure with values from the option system.
152 * @relates document_options */
153 void init_document_options(struct session *ses, struct document_options *doo);
155 /** Free allocated document options.
156 * @relates document_options */
157 void done_document_options(struct document_options *options);
159 /** Copies the values of one struct @a from to the other @a to.
160 * Note that the document_options.framename is dynamically allocated.
161 * @relates document_options */
162 void copy_opt(struct document_options *to, struct document_options *from);
164 /* Compares comparable values from the two structures according to
165 * the comparable members described in the struct definition.
166 * @relates document_options */
167 int compare_opt(struct document_options *o1, struct document_options *o2);
169 #define use_document_fg_colors(o) \
170 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors >= 1)
172 #define use_document_bg_colors(o) \
173 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors == 2)
175 /** Increments the numeric value of the option identified by @a option_name,
176 * resetting it to the minimum value when it is already at the maximum value,
177 * and redraws the document. */
178 void toggle_document_option(struct session *ses, unsigned char *option_name);
180 #endif