diff options
Diffstat (limited to 'vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go')
-rw-r--r-- | vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go b/vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go index fbc9efafe..7e17352cc 100644 --- a/vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go +++ b/vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go @@ -1,4 +1,4 @@ -// Copyright 2020 The TCell Authors +// Copyright 2021 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -217,7 +217,9 @@ type Terminfo struct { PasteStart string PasteEnd string Modifiers int - TrueColor bool // true if the terminal supports direct color + InsertChar string // string to insert a character (ich1) + AutoMargin bool // true if writing to last cell in line advances + TrueColor bool // true if the terminal supports direct color } const ( @@ -742,6 +744,7 @@ func LookupTerminfo(name string) (*Terminfo, error) { } addtruecolor := false + add256color := false switch os.Getenv("COLORTERM") { case "truecolor", "24bit", "24-bit": addtruecolor = true @@ -771,6 +774,21 @@ func LookupTerminfo(name string) (*Terminfo, error) { } } + // If the name ends in -256color, maybe fabricate using the xterm 256 color sequences + if t == nil && strings.HasSuffix(name, "-256color") { + suffixes := []string{ + "-88color", + "-color", + } + base := name[:len(name)-len("-256color")] + for _, s := range suffixes { + if t, _ = LookupTerminfo(base + s); t != nil { + add256color = true + break + } + } + } + if t == nil { return nil, ErrTermNotFound } @@ -798,5 +816,12 @@ func LookupTerminfo(name string) (*Terminfo, error) { "48;2;%p4%d;%p5%d;%p6%dm" } + if add256color { + t.Colors = 256 + t.SetFg = "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" + t.SetBg = "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" + t.SetFgBg = "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m" + t.ResetFgBg = "\x1b[39;49m" + } return t, nil } |