grafthistory: support curl
[elinks/elinks-j605.git] / src / document / options.h
blobe3eafc9c725ab5c6c2b3de84b0510b5a4220d0af
1 #ifndef EL__DOCUMENT_OPTIONS_H
2 #define EL__DOCUMENT_OPTIONS_H
4 #include "terminal/color.h"
5 #include "util/color.h"
6 #include "util/box.h"
8 struct session;
10 /* Active link coloring options */
11 struct active_link_options {
12 unsigned int color:1;
13 unsigned int underline:1;
14 unsigned int bold:1;
15 unsigned int invert:1;
16 color_T fg;
17 color_T bg;
20 /* This mostly acts as a option cache so rendering will be faster. However it
21 * is also used to validate and invalidate documents in the format cache as to
22 * whether they satisfy the current state of the document options. */
23 struct document_options {
24 enum color_mode color_mode;
25 /* cp is the codepage for which the document is being formatted;
26 * typically it is the codepage of a terminal. It is set in
27 * render_document_frames. */
28 int cp, assume_cp, hard_assume;
29 int margin;
30 int num_links_key;
31 int use_document_colors;
32 int meta_link_display;
33 int default_form_input_size;
35 /* The default (fallback) colors. */
36 color_T default_fg;
37 color_T default_bg;
38 color_T default_link;
39 color_T default_vlink;
40 #ifdef CONFIG_BOOKMARKS
41 color_T default_bookmark_link;
42 #endif
43 color_T default_image_link;
45 /* Color model/optimizations */
46 enum color_flags color_flags;
48 /* XXX: Keep boolean options grouped to save padding */
49 #ifdef CONFIG_CSS
50 /* CSS stuff */
51 unsigned int css_enable:1;
52 unsigned int css_import:1;
53 #endif
55 /* HTML stuff */
56 unsigned int tables:1;
57 unsigned int table_order:1;
58 unsigned int frames:1;
59 unsigned int images:1;
61 unsigned int display_subs:1;
62 unsigned int display_sups:1;
63 unsigned int underline_links:1;
65 unsigned int wrap_nbsp:1;
67 /* Plain rendering stuff */
68 unsigned int plain_display_links:1;
69 unsigned int plain_compress_empty_lines:1;
71 /* Link navigation */
72 unsigned int links_numbering:1;
73 unsigned int use_tabindex:1;
75 unsigned int plain:1;
76 unsigned int wrap:1;
78 /* XXX: Everything past this comment is specialy handled by compare_opt() */
79 unsigned char *framename;
81 /* The position of the window (box.x and box.y)
83 * This is not compared at all since it doesn't make any
84 * difference what position the document will fit into a frameset
85 * or so.
87 * The width of the window (box.width)
89 * This controls how wide tables can be rendered and so on. It is
90 * thus also to blame for the extra memory consumption when
91 * resizing because all documents has to be rerendered. We only
92 * need to compare it if not @plain.
94 * The height of the window (box.height)
96 * Only documents containing textarea or frames uses it and we
97 * only compare it if @needs_height is set.
99 struct box box;
100 unsigned int needs_height:1;
101 unsigned int needs_width:1;
103 /* Internal flag for rerendering */
104 unsigned int no_cache:1;
105 unsigned int gradual_rerendering:1;
107 /* Active link coloring */
108 /* This is mostly here to make use of this option cache so link
109 * drawing is faster. --jonas */
110 struct active_link_options active_link;
112 /* Options related with IMG tag */
113 struct {
114 unsigned char *prefix;
115 unsigned char *suffix;
116 int filename_maxlen;
117 int label_maxlen;
118 int display_style;
119 int tagging;
120 unsigned int show_any_as_links:1;
121 } image_link;
124 /* Fills the structure with values from the option system. */
125 void init_document_options(struct document_options *doo);
127 /* Free allocated document options. */
128 void done_document_options(struct document_options *options);
130 /* Copies the values of one struct @from to the other @to.
131 * Note that the framename is dynamically allocated. */
132 void copy_opt(struct document_options *to, struct document_options *from);
134 /* Compares comparable values from the two structures according to
135 * the comparable members described in the struct definition. */
136 int compare_opt(struct document_options *o1, struct document_options *o2);
138 #define use_document_fg_colors(o) \
139 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors >= 1)
141 #define use_document_bg_colors(o) \
142 ((o)->color_mode != COLOR_MODE_MONO && (o)->use_document_colors == 2)
144 /* Increments the numeric value of the option identified by option_name,
145 * resetting it to the minimum value when it is already at the maximum value,
146 * and redraws the document. */
147 void toggle_document_option(struct session *ses, unsigned char *option_name);
149 #endif