From d11d374252e4a45e98a38b741c74e0eda539deca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 29 Jul 2020 17:41:24 +0200 Subject: [PATCH] config: add scrollback section * Move 'scrollback' to 'scrollback.lines' * Move (the new) 'scrollback-indicator-*' options to 'scrollback.indicator-*' Log a deprecation warning when the old 'scrollback' option is used, but don't remove it, yet. --- CHANGELOG.md | 5 +++++ config.c | 34 ++++++++++++++++++++++++++++++---- doc/footrc.5.scd | 23 +++++++++++++---------- footrc | 8 +++++--- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1fe1c3..7fe85d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ ### Deprecated + +* **scrollback** option in `footrc`. Use the **lines** option in the + **[scrollback]** section instead. + + ### Removed ### Changed diff --git a/config.c b/config.c index 5220f8fb..fc029884 100644 --- a/config.c +++ b/config.c @@ -306,6 +306,9 @@ parse_section_main(const char *key, const char *value, struct config *conf, } else if (strcmp(key, "scrollback") == 0) { + LOG_WARN("deprecated: 'scrollback' option, " + "use 'lines' in the '[scrollback]' section instead'"); + unsigned long lines; if (!str_to_ulong(value, 10, &lines)) { LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); @@ -314,7 +317,28 @@ parse_section_main(const char *key, const char *value, struct config *conf, conf->scrollback.lines = lines; } - else if (strcmp(key, "scrollback-indicator-position") == 0) { + else { + LOG_ERR("%s:%u: invalid key: %s", path, lineno, key); + return false; + } + + return true; +} + +static bool +parse_section_scrollback(const char *key, const char *value, struct config *conf, + const char *path, unsigned lineno) +{ + if (strcmp(key, "lines") == 0) { + unsigned long lines; + if (!str_to_ulong(value, 10, &lines)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + conf->scrollback.lines = lines; + } + + else if (strcmp(key, "indicator-position") == 0) { if (strcmp(value, "none") == 0) conf->scrollback.indicator.position = SCROLLBACK_INDICATOR_POSITION_NONE; else if (strcmp(value, "fixed") == 0) @@ -322,14 +346,14 @@ parse_section_main(const char *key, const char *value, struct config *conf, else if (strcmp(value, "relative") == 0) conf->scrollback.indicator.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE; else { - LOG_ERR("%s:%d: scrollback-indicator-position must be one of " + LOG_ERR("%s:%d: indicator-position must be one of " "'none', 'fixed' or 'moving'", path, lineno); return false; } } - else if (strcmp(key, "scrollback-indicator-format") == 0) { + else if (strcmp(key, "indicator-format") == 0) { if (strcmp(value, "percentage") == 0) { conf->scrollback.indicator.format = SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE; @@ -342,7 +366,7 @@ parse_section_main(const char *key, const char *value, struct config *conf, size_t len = mbstowcs(NULL, value, -1); if (len < 0) { - LOG_ERRNO("%s:%d: invalid scrollback-indicator-format value", path, lineno); + LOG_ERRNO("%s:%d: invalid indicator-format value", path, lineno); return false; } @@ -894,6 +918,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) { enum section { SECTION_MAIN, + SECTION_SCROLLBACK, SECTION_COLORS, SECTION_CURSOR, SECTION_CSD, @@ -914,6 +939,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) const char *name; } section_info[] = { [SECTION_MAIN] = {&parse_section_main, "main"}, + [SECTION_SCROLLBACK] = {&parse_section_scrollback, "scrollback"}, [SECTION_COLORS] = {&parse_section_colors, "colors"}, [SECTION_CURSOR] = {&parse_section_cursor, "cursor"}, [SECTION_CSD] = {&parse_section_csd, "csd"}, diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index 4ab6f7ce..c148d27f 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -65,10 +65,19 @@ in this order: compositor can use this value to e.g. group multiple windows, or apply window management rules. Default: _foot_. -*scrollback* +*workers* + Number of threads to use for rendering. Set to 0 to disable + multithreading. Default: the number of available logical CPUs + (including SMT). Note that this is not always the best value. In + some cases, the number of physical _cores_ is better. + + +# SECTION: scrollback + +*lines* Number of scrollback lines. Default: _1000_. -*scrollback-indicator-position* +*indicator-position* Configures the style of the scrollback position indicator. One of *none*, *fixed* or *relative*. *none* disables the indicator completely. *fixed* always renders the indicator near the top at @@ -76,17 +85,11 @@ in this order: corresponding to the current scrollback position. Default: _relative_. -*scrollback-indicator-format* +*indicator-format* Which format to use when displaying the scrollback position 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 - multithreading. Default: the number of available logical CPUs - (including SMT). Note that this is not always the best value. In - some cases, the number of physical _cores_ is better. + *indicator-position=none*. Default: _empty string_. # SECTION: cursor diff --git a/footrc b/footrc index 3336cb2e..b088c165 100644 --- a/footrc +++ b/footrc @@ -1,9 +1,6 @@ # -*- conf -*- # font=monospace -# scrollback=1000 -# scrollback-indicator-position=relative -# scrollback-indicator-format= # geometry=700x500 # pad=2x2 # initial-window-mode=windowed @@ -12,6 +9,11 @@ # login-shell=no # workers= +[scrollback] +# lines=1000 +# indicator-position=relative +# indicator-format= + [cursor] # style=block # color=111111 dcdccc