mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-27 07:58:07 -04:00
config: add free-form text variant to 'scrollback-indicator-format'
And make the empty string the new default.
This commit is contained in:
parent
eadb5a4a88
commit
2882fbb537
5 changed files with 31 additions and 12 deletions
19
config.c
19
config.c
|
|
@ -314,10 +314,17 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
conf->scrollback.indicator.format
|
conf->scrollback.indicator.format
|
||||||
= SCROLLBACK_INDICATOR_FORMAT_LINENO;
|
= SCROLLBACK_INDICATOR_FORMAT_LINENO;
|
||||||
} else {
|
} else {
|
||||||
LOG_ERR("%s:%d: 'scrollback-indicator-format must be one "
|
free(conf->scrollback.indicator.text);
|
||||||
"of 'percent' or 'line'",
|
conf->scrollback.indicator.text = NULL;
|
||||||
path, lineno);
|
|
||||||
return false;
|
size_t len = mbstowcs(NULL, value, -1);
|
||||||
|
if (len < 0) {
|
||||||
|
LOG_ERRNO("%s:%d: invalid scrollback-indicator-format value", path, lineno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf->scrollback.indicator.text = calloc(len + 1, sizeof(wchar_t));
|
||||||
|
mbstowcs(conf->scrollback.indicator.text, value, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -967,7 +974,8 @@ config_load(struct config *conf, const char *conf_path)
|
||||||
.lines = 1000,
|
.lines = 1000,
|
||||||
.indicator = {
|
.indicator = {
|
||||||
.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE,
|
.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE,
|
||||||
.format = SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
|
.format = SCROLLBACK_INDICATOR_FORMAT_TEXT,
|
||||||
|
.text = wcsdup(L""),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.colors = {
|
.colors = {
|
||||||
|
|
@ -1119,6 +1127,7 @@ config_free(struct config conf)
|
||||||
free(conf.shell);
|
free(conf.shell);
|
||||||
free(conf.title);
|
free(conf.title);
|
||||||
free(conf.app_id);
|
free(conf.app_id);
|
||||||
|
free(conf.scrollback.indicator.text);
|
||||||
tll_foreach(conf.fonts, it)
|
tll_foreach(conf.fonts, it)
|
||||||
config_font_destroy(&it->item);
|
config_font_destroy(&it->item);
|
||||||
tll_free(conf.fonts);
|
tll_free(conf.fonts);
|
||||||
|
|
|
||||||
5
config.h
5
config.h
|
|
@ -51,8 +51,11 @@ struct config {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
|
SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
|
||||||
SCROLLBACK_INDICATOR_FORMAT_LINENO
|
SCROLLBACK_INDICATOR_FORMAT_LINENO,
|
||||||
|
SCROLLBACK_INDICATOR_FORMAT_TEXT,
|
||||||
} format;
|
} format;
|
||||||
|
|
||||||
|
wchar_t *text;
|
||||||
} indicator;
|
} indicator;
|
||||||
} scrollback;
|
} scrollback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,9 @@ in this order:
|
||||||
|
|
||||||
*scrollback-indicator-format*
|
*scrollback-indicator-format*
|
||||||
Which format to use when displaying the scrollback position
|
Which format to use when displaying the scrollback position
|
||||||
indicator. Either _percentage_ or _line_. This option is ignored
|
indicator. Either _percentage_, _line_, or a custom fixed
|
||||||
if *scrollback-indicator-position=none*. Default: _percentage_.
|
string. This option is ignored if
|
||||||
|
*scrollback-indicator-position=none*. Default: _empty string_.
|
||||||
|
|
||||||
*workers*
|
*workers*
|
||||||
Number of threads to use for rendering. Set to 0 to disable
|
Number of threads to use for rendering. Set to 0 to disable
|
||||||
|
|
|
||||||
2
footrc
2
footrc
|
|
@ -3,7 +3,7 @@
|
||||||
# font=monospace
|
# font=monospace
|
||||||
# scrollback=1000
|
# scrollback=1000
|
||||||
# scrollback-indicator-position=relative
|
# scrollback-indicator-position=relative
|
||||||
# scrollback-indicator-format=percentage
|
# scrollback-indicator-format=
|
||||||
# geometry=700x500
|
# geometry=700x500
|
||||||
# pad=2x2
|
# pad=2x2
|
||||||
# initial-window-mode=windowed
|
# initial-window-mode=windowed
|
||||||
|
|
|
||||||
12
render.c
12
render.c
|
|
@ -1358,20 +1358,26 @@ render_scrollback_position(struct terminal *term)
|
||||||
? 1.0
|
? 1.0
|
||||||
: (double)rebased_view / term->grid->num_rows;
|
: (double)rebased_view / term->grid->num_rows;
|
||||||
|
|
||||||
wchar_t text[64];
|
wchar_t _text[64];
|
||||||
|
const wchar_t *text = _text;
|
||||||
int cell_count;
|
int cell_count;
|
||||||
|
|
||||||
/* *What* to render */
|
/* *What* to render */
|
||||||
switch (term->conf->scrollback.indicator.format) {
|
switch (term->conf->scrollback.indicator.format) {
|
||||||
case SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE:
|
case SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE:
|
||||||
swprintf(text, sizeof(text) / sizeof(text[0]), L"%u%%", (int)(100 * percent));
|
swprintf(_text, sizeof(_text) / sizeof(_text[0]), L"%u%%", (int)(100 * percent));
|
||||||
cell_count = 3;
|
cell_count = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLLBACK_INDICATOR_FORMAT_LINENO:
|
case SCROLLBACK_INDICATOR_FORMAT_LINENO:
|
||||||
swprintf(text, sizeof(text) / sizeof(text[0]), L"%d", rebased_view + 1);
|
swprintf(_text, sizeof(_text) / sizeof(_text[0]), L"%d", rebased_view + 1);
|
||||||
cell_count = 1 + (int)log10(term->grid->num_rows);
|
cell_count = 1 + (int)log10(term->grid->num_rows);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SCROLLBACK_INDICATOR_FORMAT_TEXT:
|
||||||
|
text = term->conf->scrollback.indicator.text;
|
||||||
|
cell_count = wcslen(text);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int scale = term->scale;
|
const int scale = term->scale;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue