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"
11 /** Active link coloring options */
12 struct active_link_options
{
14 unsigned int underline
:1;
16 unsigned int invert
:1;
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
;
32 int use_document_colors
;
33 int meta_link_display
;
34 int default_form_input_size
;
36 /** @name The default (fallback) colors.
38 struct text_style default_style
;
40 color_T default_vlink
;
41 #ifdef CONFIG_BOOKMARKS
42 color_T default_bookmark_link
;
44 color_T default_image_link
;
47 /** Color model/optimizations */
48 enum color_flags color_flags
;
50 /* XXX: Keep boolean options grouped to save padding */
54 unsigned int css_enable
:1;
55 unsigned int css_import
:1;
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;
73 /** @name Plain rendering stuff
75 unsigned int plain_display_links
:1;
76 unsigned int plain_compress_empty_lines
:1;
79 /** @name Link navigation
81 unsigned int links_numbering
:1;
82 unsigned int use_tabindex
: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.
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
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.
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;
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 */
130 unsigned char *prefix
;
131 unsigned char *suffix
;
136 unsigned int show_any_as_links
:1;
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
);