0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-06-30 22:19:29 -04:00

[browse] Added bool option document.browse.margin_auto . Refs #360

When set together with document.browse.preferred_document_width
and document.browse.use_preferred_document_width margins are set
automatically.
This commit is contained in:
Witold Filipczyk 2025-01-10 15:40:19 +01:00
parent 5de7ef17e3
commit 02aeda8bc1
2 changed files with 12 additions and 0 deletions

View File

@ -497,6 +497,10 @@ static union option_info config_options_info[] = {
"2 automatically starts typeahead searching thru all document\n"
" text")),
INIT_OPT_BOOL("document.browse", N_("Whether to set margin automatically"),
"margin_auto", OPT_ZERO, 0,
N_("Whether to set margins automatically. Note, that preferred_document_width, "
"and use_preferred_document_width must be non-zero.")),
INIT_OPT_INT("document.browse", N_("Horizontal text margin"),
"margin_width", OPT_ZERO, 0, 100, 3,

View File

@ -38,6 +38,14 @@ init_document_options(struct session *ses, struct document_options *doo)
doo->document_width = get_opt_int("document.browse.preferred_document_width", ses);
if (ses) {
if (doo->document_width > 0 && get_opt_bool("document.browse.margin_auto", ses)) {
int margin = (ses->tab->term->width - doo->document_width) / 2;
if (margin >= 0) {
doo->margin = margin;
}
}
if (doo->document_width <= 0 || doo->document_width > ses->tab->term->width) {
doo->document_width = ses->tab->term->width - 2 * doo->margin;