diff options
| -rw-r--r-- | config.c | 35 | ||||
| -rw-r--r-- | config.h | 6 | ||||
| -rw-r--r-- | footrc | 3 | ||||
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | terminal.h | 4 |
5 files changed, 48 insertions, 1 deletions
@@ -182,11 +182,38 @@ parse_section_colors(const char *key, const char *value, struct config *conf, } static bool +parse_section_cursor(const char *key, const char *value, struct config *conf, + const char *path, unsigned lineno) +{ + 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, "underline") == 0) + conf->cursor.style = CURSOR_UNDERLINE; + + else { + LOG_ERR("%s:%d: invalid 'style': %s", path, lineno, value); + return false; + } + } + + else { + LOG_ERR("%s:%d: invalid key: %s", path, lineno, key); + return false; + } + + return true; +} + +static bool parse_config_file(FILE *f, struct config *conf, const char *path) { enum section { SECTION_MAIN, SECTION_COLORS, + SECTION_CURSOR, } section = SECTION_MAIN; /* Function pointer, called for each key/value line */ @@ -198,12 +225,14 @@ parse_config_file(FILE *f, struct config *conf, const char *path) static const parser_fun_t section_parser_map[] = { [SECTION_MAIN] = &parse_section_main, [SECTION_COLORS] = &parse_section_colors, + [SECTION_CURSOR] = &parse_section_cursor, }; #if defined(_DEBUG) && defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG static const char *const section_names[] = { [SECTION_MAIN] = "main", [SECTION_COLORS] = "colors", + [SECTION_CURSOR] = "cursor", }; #endif @@ -257,6 +286,8 @@ parse_config_file(FILE *f, struct config *conf, const char *path) if (strcmp(&line[1], "colors") == 0) section = SECTION_COLORS; + else if (strcmp(&line[1], "cursor") == 0) + section = SECTION_CURSOR; else { LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &line[1]); goto err; @@ -354,6 +385,10 @@ config_load(struct config *conf) default_bright[7], }, }, + + .cursor = { + .style = CURSOR_BLOCK, + }, }; char *path = get_config_path(); @@ -3,6 +3,8 @@ #include <stdint.h> #include <stdbool.h> +#include "terminal.h" + struct config { char *term; char *shell; @@ -14,6 +16,10 @@ struct config { uint32_t regular[8]; uint32_t bright[8]; } colors; + + struct { + enum cursor_style style; + } cursor; }; bool config_load(struct config *conf); @@ -2,6 +2,9 @@ # shell=/usr/bin/zsh # font=monospace +[cursor] +# style=block + [colors] # foreground=dcdccc # background=111111 @@ -371,6 +371,7 @@ main(int argc, char *const *argv) conf.colors.bright[7], }, }, + .cursor_style = conf.cursor.style, .selection = { .start = {-1, -1}, .end = {-1, -1}, @@ -222,6 +222,8 @@ struct font { struct glyph_cache glyph_cache[256]; }; +enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR }; + struct terminal { pid_t slave; int ptmx; @@ -291,7 +293,7 @@ struct terminal { struct coord cursor; struct coord saved_cursor; struct coord alt_saved_cursor; - enum { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR } cursor_style; + enum cursor_style cursor_style; bool cursor_blinking; uint32_t input_serial; |
