From 7ce767ab87ca915b2ac4023cc95dbda81fe87abd Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 30 Apr 2021 20:31:47 +0200 Subject: config: add ‘beam-thickness’ option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename cursor.style value ‘bar’ to ‘beam’. ‘bar’ remains recognized, but should eventually be deprecated and then removed. * Add ‘cursor.beam-thickness’ option, a pt-or-px value specifying the thickness of the beam cursor. Defaults to 1.5pt. * Rename (and export) pt_or_px_as_pixels() to term_pt_or_px_as_pixels() * Change term_pt_or_px_as_pixels() to round point values instead of truncating them. --- config.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index 3aed1e7d..f5446107 100644 --- a/config.c +++ b/config.c @@ -941,13 +941,14 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, if (strcmp(key, "style") == 0) { if (strcmp(value, "block") == 0) conf->cursor.style = CURSOR_BLOCK; - else if (strcmp(value, "bar") == 0) - conf->cursor.style = CURSOR_BAR; + else if (strcmp(value, "beam") == 0 || strcmp(value, "bar") == 0) + conf->cursor.style = CURSOR_BEAM; else if (strcmp(value, "underline") == 0) conf->cursor.style = CURSOR_UNDERLINE; else { - LOG_AND_NOTIFY_ERR("%s:%d: invalid 'style': %s", path, lineno, value); + LOG_AND_NOTIFY_ERR("%s:%d: style: one of block, beam or underline", + path, lineno); return false; } } @@ -967,6 +968,13 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, conf->cursor.color.cursor |= 1u << 31; } + else if (strcmp(key, "beam-thickness") == 0) { + if (!str_to_pt_or_px( + value, &conf->cursor.beam_thickness, + conf, path, lineno, "cursor", "beam-thickness")) + return false; + } + else { LOG_AND_NOTIFY_ERR("%s:%d: [cursor]: %s: invalid key", path, lineno, key); return false; @@ -2261,6 +2269,7 @@ config_load(struct config *conf, const char *conf_path, .text = 0, .cursor = 0, }, + .beam_thickness = {.pt = 1.5}, }, .mouse = { .hide_when_typing = false, -- cgit v1.3