diff --git a/CHANGELOG.md b/CHANGELOG.md index 464faa9f..0f6a9fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,20 @@ CHANGELOG 0.62.0 ------ +- Relaxed the `--color` option syntax to allow whitespace-separated entries (in addition to commas), making multi-line definitions easier to write and read + ```sh + # seoul256-light + fzf --style full --color=' + fg:#616161 fg+:#616161 + bg:#ffffff bg+:#e9e9e9 alt-bg:#f1f1f1 + hl:#719872 hl+:#719899 + pointer:#e12672 marker:#e17899 + header:#719872 + spinner:#719899 info:#727100 + prompt:#0099bd query:#616161 + border:#e1e1e1 + ' + ``` - Added `alt-bg` color to create striped lines to visually separate rows ```sh fzf --color bg:237,alt-bg:238,current-bg:236 --highlight-line diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index 2159cf36..e7a71c57 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -242,7 +242,7 @@ Apply a style preset [default|minimal|full[:BORDER_STYLE]] .TP .BI "\-\-color=" "[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]..." Color configuration. The name of the base color scheme is followed by custom -color mappings. +color mappings. Each entry is separated by a comma and/or whitespaces. .RS .B BASE SCHEME: @@ -338,7 +338,19 @@ color mappings. # Seoul256 theme with 24-bit colors fzf \-\-color='bg:#4B4B4B,bg+:#3F3F3F,info:#BDBB72,border:#6B6B6B,spinner:#98BC99' \\ \-\-color='hl:#719872,fg:#D9D9D9,header:#719872,fg+:#D9D9D9' \\ - \-\-color='pointer:#E12672,marker:#E17899,prompt:#98BEDE,hl+:#98BC99'\fR + \-\-color='pointer:#E12672,marker:#E17899,prompt:#98BEDE,hl+:#98BC99' + + # Seoul256 light theme with 24-bit colors, each entry separated by whitespaces + fzf \-\-style full \-\-color=' + fg:#616161 fg+:#616161 + bg:#ffffff bg+:#e9e9e9 alt-bg:#f1f1f1 + hl:#719872 hl+:#719899 + pointer:#e12672 marker:#e17899 + header:#719872 + spinner:#719899 info:#727100 + prompt:#0099bd query:#616161 + border:#e1e1e1 + '\fR .RE .TP .B "\-\-no\-color" diff --git a/src/options.go b/src/options.go index 1e4c8904..030368fa 100644 --- a/src/options.go +++ b/src/options.go @@ -1184,7 +1184,12 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, erro var err error theme := dupeTheme(defaultTheme) rrggbb := regexp.MustCompile("^#[0-9a-fA-F]{6}$") - for _, str := range strings.Split(strings.ToLower(str), ",") { + comma := regexp.MustCompile(`[\s,]+`) + for _, str := range comma.Split(strings.ToLower(str), -1) { + str = strings.TrimSpace(str) + if len(str) == 0 { + continue + } switch str { case "dark": theme = dupeTheme(tui.Dark256) diff --git a/src/options_test.go b/src/options_test.go index 5c9a789a..2105322e 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -333,7 +333,7 @@ func TestColorSpec(t *testing.T) { t.Errorf("colors should now be equivalent: %v, %v", tui.Dark256, customized) } - customized, _ = parseTheme(theme, "fg:231,dark,bg:232") + customized, _ = parseTheme(theme, "fg:231,dark bg:232") if customized.Fg != tui.Dark256.Fg || customized.Bg == tui.Dark256.Bg { t.Errorf("color not customized") }