diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-04-28 20:14:18 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-04-28 20:14:18 +0200 |
| commit | 8af914fb6d17b149199e03bb6f5d4ad7e9ffc3c4 (patch) | |
| tree | 55ece7464315113e392e473fc979cd9a0562857a | |
| parent | 610cb4094fb1cf7fb7e4c6857c0bad813e18a17a (diff) | |
| download | vis-8af914fb6d17b149199e03bb6f5d4ad7e9ffc3c4.tar.gz vis-8af914fb6d17b149199e03bb6f5d4ad7e9ffc3c4.tar.xz | |
ui: ignore whitespace when parsing style options
| -rw-r--r-- | ui-terminal.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ui-terminal.c b/ui-terminal.c index e790785..6a4331f 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -154,12 +154,16 @@ static bool ui_style_define(UiWin *w, int id, const char *style) { if (!style) return true; CellStyle cell_style = tui->styles[win->id * UI_STYLE_MAX + UI_STYLE_DEFAULT]; - char *style_copy = strdup(style), *option = style_copy, *next, *p; + char *style_copy = strdup(style), *option = style_copy; while (option) { - if ((next = strchr(option, ','))) + while (*option == ' ') + option++; + char *next = strchr(option, ','); + if (next) *next++ = '\0'; - if ((p = strchr(option, ':'))) - *p++ = '\0'; + char *value = strchr(option, ':'); + if (value) + for (*value++ = '\0'; *value == ' '; value++); if (!strcasecmp(option, "reverse")) { cell_style.attr |= CELL_ATTR_REVERSE; } else if (!strcasecmp(option, "bold")) { @@ -179,9 +183,9 @@ static bool ui_style_define(UiWin *w, int id, const char *style) { } else if (!strcasecmp(option, "notblink")) { cell_style.attr &= ~CELL_ATTR_BLINK; } else if (!strcasecmp(option, "fore")) { - color_fromstring(win->ui, &cell_style.fg, p); + color_fromstring(win->ui, &cell_style.fg, value); } else if (!strcasecmp(option, "back")) { - color_fromstring(win->ui, &cell_style.bg, p); + color_fromstring(win->ui, &cell_style.bg, value); } option = next; } |
