Skip to content

Commit daa3dc1

Browse files
authored
support tmux (sixel enabled) (#29)
* support tmux (sixel enabled) * add comment
1 parent 7cf0f18 commit daa3dc1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

term/sixel.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ func checkSixel() bool {
2525
return true
2626
}
2727
s, err := terminal.MakeRaw(1)
28-
if err != nil {
29-
return false
28+
if err == nil {
29+
defer terminal.Restore(1, s)
3030
}
31-
defer terminal.Restore(1, s)
3231
_, err = os.Stdout.Write([]byte("\x1b[c"))
3332
if err != nil {
3433
return false
@@ -40,6 +39,13 @@ func checkSixel() bool {
4039
if err != nil {
4140
return false
4241
}
42+
// Check tmux (sixel enabled)
43+
// See: CSI Ps c, Ps = 4 (Sixel graphics)
44+
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
45+
// NOTE: tmux does not return VT name.
46+
if bytes.HasPrefix(b[:n], []byte("\x1b[?1;2;4c")) {
47+
return true
48+
}
4349
var supportedTerminals = []string{
4450
"\x1b[?62;", // VT240
4551
"\x1b[?63;", // wsltty

0 commit comments

Comments
 (0)