diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-11-26 00:36:38 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-11-26 00:36:38 +0900 |
commit | de1c6b87272581eec4bfd39771e573c2bb772b60 (patch) | |
tree | ec5eedb97d634bd2cdb11fb918b7377df7d64fb1 /src/tui | |
parent | 6f17f412bad6447520dd3487aa5235887cb1fd19 (diff) |
[tcell] 24-bit color support
TAGS=tcell make install
printf "\x1b[38;2;100;200;250mTRUECOLOR\x1b[m\n" |
TERM=xterm-truecolor fzf --ansi
Diffstat (limited to 'src/tui')
-rw-r--r-- | src/tui/ncurses.go | 4 | ||||
-rw-r--r-- | src/tui/tcell.go | 5 | ||||
-rw-r--r-- | src/tui/tui.go | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/tui/ncurses.go b/src/tui/ncurses.go index 051a042c..6a09b24d 100644 --- a/src/tui/ncurses.go +++ b/src/tui/ncurses.go @@ -295,6 +295,10 @@ func RefreshWindows(windows []*Window) { } func PairFor(fg Color, bg Color) ColorPair { + // ncurses does not support 24-bit colors + if fg.is24() || bg.is24() { + return ColDefault + } key := (int(fg) << 8) + int(bg) if found, prs := _colorMap[key]; prs { return found diff --git a/src/tui/tcell.go b/src/tui/tcell.go index 3fe1161d..4a8f502d 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -11,8 +11,9 @@ import ( "runtime" - "github.com/gdamore/tcell" - "github.com/gdamore/tcell/encoding" + // https://github.com/gdamore/tcell/pull/135 + "github.com/junegunn/tcell" + "github.com/junegunn/tcell/encoding" "github.com/junegunn/go-runewidth" ) diff --git a/src/tui/tui.go b/src/tui/tui.go index 6fcaaa44..125611cf 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -93,7 +93,11 @@ const ( doubleClickDuration = 500 * time.Millisecond ) -type Color int16 +type Color int32 + +func (c Color) is24() bool { + return c > 0 && (c&(1<<24)) > 0 +} const ( colUndefined Color = -2 |