Skip to content
Myr

[tcell] 24-bit color support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

TAGS=tcell make install printf "\x1b[38;2;100;200;250mTRUECOLOR\x1b[m\n" | TERM=xterm-truecolor fzf --ansi

authored by Junegunn Choi · committed by Junegunn Choi · parent 6f17f41 · Browse files · 4 files+26 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+26 added−3 removed

  • other:+26 added−3 removed

4 files+26 added−3 removed

modified:src/tui/ncurses.go+4 added
293 unmodified lines
294 C.doupdate()295}296297func PairFor(fg Color, bg Color) ColorPair {298 // ncurses does not support 24-bit colors299 if fg.is24() || bg.is24() {300 return ColDefault301 }302 key := (int(fg) << 8) + int(bg)303 if found, prs := _colorMap[key]; prs {304 return found305 }
173 unmodified lines
modified:src/tui/tcell.go+3 added-2 removed
9 unmodified lines
10 "os"1112 "runtime"1314 // https://github.com/gdamore/tcell/pull/13514 "github.com/gdamore/tcell"15 "github.com/gdamore/tcell/encoding"15 "github.com/junegunn/tcell"16 "github.com/junegunn/tcell/encoding"1718 "github.com/junegunn/go-runewidth"19)20
560 unmodified lines
modified:src/tui/tui.go+5 added-1 removed
91 unmodified lines
92const (93 doubleClickDuration = 500 * time.Millisecond94)9596type Color int1696type Color int329798func (c Color) is24() bool {99 return c > 0 && (c&(1<<24)) > 0100}101102const (103 colUndefined Color = -2104 colDefault = -1105)
155 unmodified lines
modified:src/ansi.go+14 added
167 unmodified lines
168 }169 }170 case 1:171 switch num {172 case 2:173 state256 = 10 // MAGIC174 case 5:175 state256++176 default:177 state256 = 0178 }179 case 2:180 *ptr = tui.Color(num)181 state256 = 0182 case 10:183 *ptr = tui.Color(1<<24) | tui.Color(num<<16)184 state256++185 case 11:186 *ptr = *ptr | tui.Color(num<<8)187 state256++188 case 12:189 *ptr = *ptr | tui.Color(num)190 state256 = 0191 }192 }193 }194 if state256 > 0 {195 *ptr = -1196 }197 return state198}