mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05: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
|
||||
= SCROLLBACK_INDICATOR_FORMAT_LINENO;
|
||||
} else {
|
||||
LOG_ERR("%s:%d: 'scrollback-indicator-format must be one "
|
||||
"of 'percent' or 'line'",
|
||||
path, lineno);
|
||||
return false;
|
||||
free(conf->scrollback.indicator.text);
|
||||
conf->scrollback.indicator.text = NULL;
|
||||
|
||||
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,
|
||||
.indicator = {
|
||||
.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE,
|
||||
.format = SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
|
||||
.format = SCROLLBACK_INDICATOR_FORMAT_TEXT,
|
||||
.text = wcsdup(L""),
|
||||
},
|
||||
},
|
||||
.colors = {
|
||||
|
|
@ -1119,6 +1127,7 @@ config_free(struct config conf)
|
|||
free(conf.shell);
|
||||
free(conf.title);
|
||||
free(conf.app_id);
|
||||
free(conf.scrollback.indicator.text);
|
||||
tll_foreach(conf.fonts, it)
|
||||
config_font_destroy(&it->item);
|
||||
tll_free(conf.fonts);
|
||||
|
|
|
|||
5
config.h
5
config.h
|
|
@ -51,8 +51,11 @@ struct config {
|
|||
|
||||
enum {
|
||||
SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
|
||||
SCROLLBACK_INDICATOR_FORMAT_LINENO
|
||||
SCROLLBACK_INDICATOR_FORMAT_LINENO,
|
||||
SCROLLBACK_INDICATOR_FORMAT_TEXT,
|
||||
} format;
|
||||
|
||||
wchar_t *text;
|
||||
} indicator;
|
||||
} scrollback;
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ in this order:
|
|||
|
||||
*scrollback-indicator-format*
|
||||
Which format to use when displaying the scrollback position
|
||||
indicator. Either _percentage_ or _line_. This option is ignored
|
||||
if *scrollback-indicator-position=none*. Default: _percentage_.
|
||||
indicator. Either _percentage_, _line_, or a custom fixed
|
||||
string. This option is ignored if
|
||||
*scrollback-indicator-position=none*. Default: _empty string_.
|
||||
|
||||
*workers*
|
||||
Number of threads to use for rendering. Set to 0 to disable
|
||||
|
|
|
|||
2
footrc
2
footrc
|
|
@ -3,7 +3,7 @@
|
|||
# font=monospace
|
||||
# scrollback=1000
|
||||
# scrollback-indicator-position=relative
|
||||
# scrollback-indicator-format=percentage
|
||||
# scrollback-indicator-format=
|
||||
# geometry=700x500
|
||||
# pad=2x2
|
||||
# initial-window-mode=windowed
|
||||
|
|
|
|||
12
render.c
12
render.c
|
|
@ -1358,20 +1358,26 @@ render_scrollback_position(struct terminal *term)
|
|||
? 1.0
|
||||
: (double)rebased_view / term->grid->num_rows;
|
||||
|
||||
wchar_t text[64];
|
||||
wchar_t _text[64];
|
||||
const wchar_t *text = _text;
|
||||
int cell_count;
|
||||
|
||||
/* *What* to render */
|
||||
switch (term->conf->scrollback.indicator.format) {
|
||||
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;
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
case SCROLLBACK_INDICATOR_FORMAT_TEXT:
|
||||
text = term->conf->scrollback.indicator.text;
|
||||
cell_count = wcslen(text);
|
||||
break;
|
||||
}
|
||||
|
||||
const int scale = term->scale;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue