Skip to content

Commit

Permalink
support tmux (sixel enabled) (#29)
Browse files Browse the repository at this point in the history
* support tmux (sixel enabled)

* add comment
  • Loading branch information
mattn authored Feb 22, 2024
1 parent 7cf0f18 commit daa3dc1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions term/sixel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ func checkSixel() bool {
return true
}
s, err := terminal.MakeRaw(1)
if err != nil {
return false
if err == nil {
defer terminal.Restore(1, s)
}
defer terminal.Restore(1, s)
_, err = os.Stdout.Write([]byte("\x1b[c"))
if err != nil {
return false
Expand All @@ -40,6 +39,13 @@ func checkSixel() bool {
if err != nil {
return false
}
// Check tmux (sixel enabled)
// See: CSI Ps c, Ps = 4 (Sixel graphics)
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
// NOTE: tmux does not return VT name.
if bytes.HasPrefix(b[:n], []byte("\x1b[?1;2;4c")) {
return true
}
var supportedTerminals = []string{
"\x1b[?62;", // VT240
"\x1b[?63;", // wsltty
Expand Down

0 comments on commit daa3dc1

Please sign in to comment.