1 /** Document options/setup workshop
13 #include "config/options.h"
14 #include "dialogs/document.h"
15 #include "document/options.h"
16 #include "document/view.h"
17 #include "session/session.h"
18 #include "terminal/window.h"
19 #include "util/color.h"
20 #include "util/string.h"
21 #include "viewer/text/draw.h"
25 init_document_options(struct document_options
*doo
)
27 /* Ensure that any padding bytes are cleared. */
28 memset(doo
, 0, sizeof(*doo
));
30 doo
->assume_cp
= get_opt_codepage("document.codepage.assume");
31 doo
->hard_assume
= get_opt_bool("document.codepage.force_assumed");
33 doo
->use_document_colors
= get_opt_int("document.colors.use_document_colors");
34 doo
->margin
= get_opt_int("document.browse.margin_width");
35 doo
->num_links_key
= get_opt_int("document.browse.links.number_keys_select_link");
36 doo
->meta_link_display
= get_opt_int("document.html.link_display");
37 doo
->default_form_input_size
= get_opt_int("document.browse.forms.input_size");
40 doo
->default_style
.fg
= get_opt_color("document.colors.text");
41 doo
->default_style
.bg
= get_opt_color("document.colors.background");
42 doo
->default_link
= get_opt_color("document.colors.link");
43 doo
->default_vlink
= get_opt_color("document.colors.vlink");
44 #ifdef CONFIG_BOOKMARKS
45 doo
->default_bookmark_link
= get_opt_color("document.colors.bookmark");
47 doo
->default_image_link
= get_opt_color("document.colors.image");
49 doo
->active_link
.fg
= get_opt_color("document.browse.links.active_link.colors.text");
50 doo
->active_link
.bg
= get_opt_color("document.browse.links.active_link.colors.background");
52 if (get_opt_bool("document.colors.increase_contrast"))
53 doo
->color_flags
|= COLOR_INCREASE_CONTRAST
;
55 if (get_opt_bool("document.colors.ensure_contrast"))
56 doo
->color_flags
|= COLOR_ENSURE_CONTRAST
;
58 /* Boolean options. */
60 doo
->css_enable
= get_opt_bool("document.css.enable");
61 doo
->css_import
= get_opt_bool("document.css.import");
64 doo
->plain_display_links
= get_opt_bool("document.plain.display_links");
65 doo
->plain_compress_empty_lines
= get_opt_bool("document.plain.compress_empty_lines");
66 doo
->underline_links
= get_opt_bool("document.html.underline_links");
67 doo
->wrap_nbsp
= get_opt_bool("document.html.wrap_nbsp");
68 doo
->use_tabindex
= get_opt_bool("document.browse.links.use_tabindex");
69 doo
->links_numbering
= get_opt_bool("document.browse.links.numbering");
71 doo
->active_link
.color
= get_opt_bool("document.browse.links.active_link.enable_color");
72 doo
->active_link
.invert
= get_opt_bool("document.browse.links.active_link.invert");
73 doo
->active_link
.underline
= get_opt_bool("document.browse.links.active_link.underline");
74 doo
->active_link
.bold
= get_opt_bool("document.browse.links.active_link.bold");
76 doo
->table_order
= get_opt_bool("document.browse.table_move_order");
77 doo
->tables
= get_opt_bool("document.html.display_tables");
78 doo
->frames
= get_opt_bool("document.html.display_frames");
79 doo
->images
= get_opt_bool("document.browse.images.show_as_links");
80 doo
->display_subs
= get_opt_bool("document.html.display_subs");
81 doo
->display_sups
= get_opt_bool("document.html.display_sups");
85 doo
->image_link
.prefix
= "";
86 doo
->image_link
.suffix
= "";
87 doo
->image_link
.filename_maxlen
= get_opt_int("document.browse.images.filename_maxlen");
88 doo
->image_link
.label_maxlen
= get_opt_int("document.browse.images.label_maxlen");
89 doo
->image_link
.display_style
= get_opt_int("document.browse.images.display_style");
90 doo
->image_link
.tagging
= get_opt_int("document.browse.images.image_link_tagging");
91 doo
->image_link
.show_any_as_links
= get_opt_bool("document.browse.images.show_any_as_links");
95 compare_opt(struct document_options
*o1
, struct document_options
*o2
)
97 return memcmp(o1
, o2
, offsetof(struct document_options
, framename
))
98 || strcasecmp(o1
->framename
, o2
->framename
)
99 || (o1
->box
.x
!= o2
->box
.x
)
100 || (o1
->box
.y
!= o2
->box
.y
)
101 || ((o1
->needs_height
|| o2
->needs_height
)
102 && o1
->box
.height
!= o2
->box
.height
)
103 || ((o1
->needs_width
|| o2
->needs_width
)
104 && o1
->box
.width
!= o2
->box
.width
);
108 copy_opt(struct document_options
*o1
, struct document_options
*o2
)
111 o1
->framename
= stracpy(o2
->framename
);
112 o1
->image_link
.prefix
= stracpy(get_opt_str("document.browse.images.image_link_prefix"));
113 o1
->image_link
.suffix
= stracpy(get_opt_str("document.browse.images.image_link_suffix"));
117 done_document_options(struct document_options
*options
)
119 mem_free_if(options
->framename
);
120 mem_free(options
->image_link
.prefix
);
121 mem_free(options
->image_link
.suffix
);
125 toggle_document_option(struct session
*ses
, unsigned char *option_name
)
127 struct option
*option
;
129 assert(ses
&& ses
->doc_view
&& ses
->tab
&& ses
->tab
->term
);
130 if_assert_failed
return;
132 if (!ses
->doc_view
->vs
) {
133 nowhere_box(ses
->tab
->term
, NULL
);
137 option
= get_opt_rec(config_options
, option_name
);
139 /* TODO: toggle per document. --Zas */
140 toggle_option(ses
, option
);
142 draw_formatted(ses
, 1);