config: rename scrollback-indicator to scrollback-indicator-style

And turn it from a boolean to an enum. It can be set to:

* `none` - disables the indicator
* `static` - always rendered near the top of the window
* `moving` - position reflects the scrollback position
This commit is contained in:
Daniel Eklöf 2020-07-25 14:31:45 +02:00
parent 5b868fd0c9
commit c4679e474e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 54 additions and 20 deletions

View file

@ -288,21 +288,33 @@ parse_section_main(const char *key, const char *value, struct config *conf,
LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value);
return false; return false;
} }
conf->scrollback_lines = lines; conf->scrollback.lines = lines;
} }
else if (strcmp(key, "scrollback-indicator") == 0) else if (strcmp(key, "scrollback-indicator") == 0) {
conf->scrollback_indicator = str_to_bool(value); if (strcmp(value, "none") == 0)
conf->scrollback.indicator.style = SCROLLBACK_INDICATOR_STYLE_NONE;
else if (strcmp(value, "static") == 0)
conf->scrollback.indicator.style = SCROLLBACK_INDICATOR_STYLE_STATIC;
else if (strcmp(value, "moving") == 0)
conf->scrollback.indicator.style = SCROLLBACK_INDICATOR_STYLE_MOVING;
else {
LOG_ERR("%s:%d: scrollback-indicator-style must be one of "
"'none', 'static' or 'moving'",
path, lineno);
return false;
}
}
else if (strcmp(key, "scrollback-indicator-format") == 0) { else if (strcmp(key, "scrollback-indicator-format") == 0) {
if (strcmp(value, "percent") == 0) if (strcmp(value, "percent") == 0)
conf->scrollback_indicator_format = SCROLLBACK_INDICATOR_PERCENT; conf->scrollback.indicator.format = SCROLLBACK_INDICATOR_FORMAT_PERCENT;
else if (strcmp(value, "line") == 0) else if (strcmp(value, "line") == 0)
conf->scrollback_indicator_format = SCROLLBACK_INDICATOR_LINENO; conf->scrollback.indicator.format = SCROLLBACK_INDICATOR_FORMAT_LINENO;
else { else {
LOG_ERR("%s:%d: 'scrollback-indicator-format must be one " LOG_ERR("%s:%d: 'scrollback-indicator-format must be one "
"of 'percent' or 'line', not %s", "of 'percent' or 'line'",
path, lineno, value); path, lineno);
return false; return false;
} }
} }
@ -933,10 +945,13 @@ config_load(struct config *conf, const char *conf_path)
.pad_y = 2, .pad_y = 2,
.startup_mode = STARTUP_WINDOWED, .startup_mode = STARTUP_WINDOWED,
.fonts = tll_init(), .fonts = tll_init(),
.scrollback_lines = 1000, .scrollback = {
.scrollback_indicator = true, .lines = 1000,
.scrollback_indicator_format = SCROLLBACK_INDICATOR_PERCENT, .indicator = {
.style = SCROLLBACK_INDICATOR_STYLE_MOVING,
.format = SCROLLBACK_INDICATOR_FORMAT_PERCENT,
},
},
.colors = { .colors = {
.fg = default_foreground, .fg = default_foreground,
.bg = default_background, .bg = default_background,

View file

@ -39,9 +39,22 @@ struct config {
tll(struct config_font) fonts; tll(struct config_font) fonts;
int scrollback_lines; struct {
bool scrollback_indicator; int lines;
enum {SCROLLBACK_INDICATOR_PERCENT, SCROLLBACK_INDICATOR_LINENO} scrollback_indicator_format;
struct {
enum {
SCROLLBACK_INDICATOR_STYLE_NONE,
SCROLLBACK_INDICATOR_STYLE_STATIC,
SCROLLBACK_INDICATOR_STYLE_MOVING
} style;
enum {
SCROLLBACK_INDICATOR_FORMAT_PERCENT,
SCROLLBACK_INDICATOR_FORMAT_LINENO
} format;
} indicator;
} scrollback;
struct { struct {
uint32_t fg; uint32_t fg;

View file

@ -68,14 +68,18 @@ in this order:
*scrollback* *scrollback*
Number of scrollback lines. Default: _1000_. Number of scrollback lines. Default: _1000_.
*scrollback-indicator* *scrollback-indicator-style*
Boolean. Enables a position indicator when the viewport is not at Configures the style of the scrollback position indicator. One of
the bottom of the scrollback history. Default: _yes_. *none*, *static* or *moving*. *none* disables the indicator
completely. *static* always renders the indicator near the top at
the window, and *moving* renders the indicator at the position
corresponding to the current scrollback position. Default:
_moving_.
*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 _percent_ or _line_. This option is ignored if indicator. Either _percent_ or _line_. This option is ignored if
*scrollback-indicator=no*. Default: _percent_. *scrollback-indicator-style=none*. Default: _percent_.
*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
View file

@ -2,6 +2,8 @@
# font=monospace # font=monospace
# scrollback=1000 # scrollback=1000
# scrollback-indicator-style=moving
# scrollback-indicator-format=percent
# geometry=700x500 # geometry=700x500
# pad=2x2 # pad=2x2
# initial-window-mode=windowed # initial-window-mode=windowed

View file

@ -1290,7 +1290,7 @@ render_csd(struct terminal *term)
static void static void
render_scrollback_position(struct terminal *term) render_scrollback_position(struct terminal *term)
{ {
if (!term->conf->scrollback_indicator) if (term->conf->scrollback.indicator.style == SCROLLBACK_INDICATOR_STYLE_NONE)
return; return;
/* Find absolute row number of the scrollback start */ /* Find absolute row number of the scrollback start */

View file

@ -909,7 +909,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.tab_stops = tll_init(), .tab_stops = tll_init(),
.wl = wayl, .wl = wayl,
.render = { .render = {
.scrollback_lines = conf->scrollback_lines, .scrollback_lines = conf->scrollback.lines,
.app_sync_updates.timer_fd = app_sync_updates_fd, .app_sync_updates.timer_fd = app_sync_updates_fd,
.workers = { .workers = {
.count = conf->render_worker_count, .count = conf->render_worker_count,