diff options
| author | Michael Kelley <michael.a.kelley@gmail.com> | 2020-09-01 21:47:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-02 13:47:13 +0900 |
| commit | ae15eda5467543bdab178d5bcf56eb301a870ec7 (patch) | |
| tree | 0e4c371cfeaf3846494f46cb8723297bb348cf16 /src | |
| parent | f2d44ab5a793906457f3d3384f09af085096138d (diff) | |
| download | fzf-ae15eda5467543bdab178d5bcf56eb301a870ec7.tar.gz | |
Add truecolor support for Windows, if available (#2156)
- Update to latest tcell which has 24 bit Windows support
- light renderer under Windows defaults to Dark256, if possible
- Respect TCELL_TRUECOLOR
- Remove tcell 1.3 references
Diffstat (limited to 'src')
| -rw-r--r-- | src/tui/light.go | 12 | ||||
| -rw-r--r-- | src/tui/light_unix.go | 13 | ||||
| -rw-r--r-- | src/tui/light_windows.go | 8 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index a2a0515c..9af19b83 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -3,7 +3,6 @@ package tui import ( "fmt" "os" - "os/exec" "regexp" "strconv" "strings" @@ -126,17 +125,6 @@ func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop in return &r } -func (r *LightRenderer) defaultTheme() *ColorTheme { - if strings.Contains(os.Getenv("TERM"), "256") { - return Dark256 - } - colors, err := exec.Command("tput", "colors").Output() - if err == nil && atoi(strings.TrimSpace(string(colors)), 16) > 16 { - return Dark256 - } - return Default16 -} - func repeat(r rune, times int) string { if times > 0 { return strings.Repeat(string(r), times) diff --git a/src/tui/light_unix.go b/src/tui/light_unix.go index e4ce6313..18788702 100644 --- a/src/tui/light_unix.go +++ b/src/tui/light_unix.go @@ -5,6 +5,8 @@ package tui import ( "fmt" "os" + "os/exec" + "strings" "syscall" "github.com/junegunn/fzf/src/util" @@ -15,6 +17,17 @@ func IsLightRendererSupported() bool { return true } +func (r *LightRenderer) defaultTheme() *ColorTheme { + if strings.Contains(os.Getenv("TERM"), "256") { + return Dark256 + } + colors, err := exec.Command("tput", "colors").Output() + if err == nil && atoi(strings.TrimSpace(string(colors)), 16) > 16 { + return Dark256 + } + return Default16 +} + func (r *LightRenderer) fd() int { return int(r.ttyin.Fd()) } diff --git a/src/tui/light_windows.go b/src/tui/light_windows.go index 6f876af2..aa15a8a9 100644 --- a/src/tui/light_windows.go +++ b/src/tui/light_windows.go @@ -34,6 +34,14 @@ func IsLightRendererSupported() bool { return canSetVt100 } +func (r *LightRenderer) defaultTheme() *ColorTheme { + // the getenv check is borrowed from here: https://github.com/gdamore/tcell/commit/0c473b86d82f68226a142e96cc5a34c5a29b3690#diff-b008fcd5e6934bf31bc3d33bf49f47d8R178: + if !IsLightRendererSupported() || os.Getenv("ConEmuPID") != "" || os.Getenv("TCELL_TRUECOLOR") == "disable" { + return Default16 + } + return Dark256 +} + func (r *LightRenderer) initPlatform() error { //outHandle := windows.Stdout outHandle, _ := syscall.Open("CONOUT$", syscall.O_RDWR, 0) |
