diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-10 02:16:12 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-10 02:16:12 +0900 |
| commit | ae274158de38181bca27f2ce54c8b4fc0b688eff (patch) | |
| tree | 1bcecf4123c33640a0d6c57147b17920aea0ee7e /src/options.go | |
| parent | 340af463cd9c52c0a3a7ea5688035bba1cd29f6a (diff) | |
| download | fzf-ae274158de38181bca27f2ce54c8b4fc0b688eff.tar.gz | |
Add experimental support for 24-bit colors
Diffstat (limited to 'src/options.go')
| -rw-r--r-- | src/options.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/options.go b/src/options.go index cbb0155c..bcd2458d 100644 --- a/src/options.go +++ b/src/options.go @@ -493,6 +493,7 @@ func dupeTheme(theme *tui.ColorTheme) *tui.ColorTheme { func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme { theme := dupeTheme(defaultTheme) + rrggbb := regexp.MustCompile("^#[0-9a-fA-F]{6}$") for _, str := range strings.Split(strings.ToLower(str), ",") { switch str { case "dark": @@ -516,11 +517,17 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme { if len(pair) != 2 { fail() } - ansi32, err := strconv.Atoi(pair[1]) - if err != nil || ansi32 < -1 || ansi32 > 255 { - fail() + + var ansi tui.Color + if rrggbb.MatchString(pair[1]) { + ansi = tui.HexToColor(pair[1]) + } else { + ansi32, err := strconv.Atoi(pair[1]) + if err != nil || ansi32 < -1 || ansi32 > 255 { + fail() + } + ansi = tui.Color(ansi32) } - ansi := tui.Color(ansi32) switch pair[0] { case "fg": theme.Fg = ansi |
