Skip to content

TMUX eats SIXEL DCS header #1388

Description

@pagerc

Platform:
Windows 10 Pro 1803 Windows Subsystem for Linux Ubuntu 18.04 LTS (Bionic Beaver)
Terminal:
WSLtty - https://github.com/mintty/wsltty
Display Resolution 3840x2160
WSLtty terminal size 80x24
Font Pixels 13x24

Outside tmux:
echo $TERM
putty-256color

Inside tmux:
uname -sp && tmux -V && echo $TERM
Linux x86_64
tmux 2.6
screen

Empty ~/.tmux.conf

__dcs () { printf "\u1bP$1" ; }
__st() { printf "\u1b\" ; }
case "${TERM}" in
screen*|tmux*) __tmux_guard() { __dcs "tmux;" ; sed 's:\x1b:\x1b\x1b:g' ; __st; };;
*) alias __tmux_guard="cat";;
esac

GNUTERM="sixelgd size 600 400" \gnuplot -e "plot sin(x)" | __tmux_guard
SIXEL graphics rendered by parent terminal
image

GNUTERM="sixelgd size 700 400" \gnuplot -e "plot sin(x)" | __tmux_guard
SIXEL text strings to terminal
image

Activity

  1. nicm commented on Jun 30, 2018

    @nicm
    Member
  2. pagerc commented on Jun 30, 2018

    @pagerc
    Author

    Yes, that's what __tmux_guard does, it sends the DCS P tmux; followed by SIXEL DCS followed by ST. I got the wrapper code and modified it from iTerm2's imgcat.
    __tmux_guard() { __dcs "tmux;" ; sed 's:\x1b:\x1b\x1b:g' ; __st; };;

    rcpage@DESKTOP:$ GNUTERM="sixelgd size 800,400" \gnuplot -e "plot sin(x)" | __tmux_guard | hexdump | head
    00000000 1b 50 74 6d 75 78 3b 1b 1b 50 71 22 31 3b 31 3b |.Ptmux;..Pq"1;1;|
    00000010 38 30 30 3b 34 30 30 0a 23 32 35 3b 32 3b 32 3b |800;400.#25;2;2;|
    00000020 31 3b 32 23 38 35 3b 32 3b 35 32 3b 35 31 3b 35 |1;2#85;2;52;51;5|
    00000030 32 23 33 35 3b 32 3b 34 32 3b 31 3b 35 38 23 39 |2#35;2;42;1;58#9|
    00000040 30 3b 32 3b 32 30 3b 32 31 3b 32 30 23 31 31 39 |0;2;20;21;20#119|
    00000050 3b 32 3b 32 34 3b 31 3b 33 30 0a 23 38 34 3b 32 |;2;24;1;30.#84;2|
    00000060 3b 37 37 3b 37 36 3b 37 37 23 31 30 34 3b 32 3b |;77;76;77#104;2;|
    00000070 34 35 3b 32 36 3b 35 32 23 38 36 3b 32 3b 31 31 |45;26;52#86;2;11|
    00000080 3b 31 32 3b 31 31 23 37 31 3b 32 3b 31 34 3b 31 |;12;11#71;2;14;1|
    00000090 3b 31 37 23 31 30 35 3b 32 3b 35 32 3b 31 33 3b |;17#105;2;52;13;|
    rcpage@DESKTOP:
    $ GNUTERM="sixelgd size 800,400" \gnuplot -e "plot sin(x)" | _tmux_guard | hexdump | tail
    00008120 35 35 21 31 37 35 3f 43 3f 3f 3f 41 24 0a 23 35 |55!175?C???A$.#5|
    00008130 37 21 36 38 3f 67 23 33 38 5f 23 34 39 3f 3f 47 |7!68?g#38
    #49??G|
    00008140 23 34 32 21 31 37 31 3f 5f 23 35 32 21 31 37 30 |#42!171?#52!170|
    00008150 3f 40 23 34 39 3f 3f 3f 47 23 35 33 21 31 37 35 |?@#49???G#53!175|
    00008160 3f 4f 23 35 37 21 31 37 35 3f 67 23 33 38 5f 23 |?O#57!175?g#38
    #|
    00008170 34 39 3f 3f 47 24 0a 23 35 32 21 36 38 3f 40 23 |49??G$.#52!68?@#|
    00008180 35 33 21 31 37 35 3f 4f 23 35 32 21 35 32 36 3f |53!175?O#52!526?|
    00008190 40 2d 0a 23 32 35 21 38 30 30 7e 2d 0a 21 38 30 |@-.#25!800~-.!80|
    000081a0 30 7e 2d 0a 21 38 30 30 4e 2d 0a 1b 1b 5c 1b 5c |0~-.!800N-....|
    000081b0

  3. nicm commented on Jun 30, 2018

    @nicm
    Member
  4. pagerc commented on Jun 30, 2018

    @pagerc
    Author

    I was testing my plots, and when I run the plot from gnuplot, it sometimes renders and sometimes fails. I piped it to a file and to sha1sum, and I'm constantly getting the same sha1sum. However, when I cat the file that I piped the pixel plot with tmux DCS wrapper, that renders every time I cat the file. Could there be a buffering issue with the amount of data going through my shell script/sed?
    tmux-client-1550.log
    tmux-out-1552.log
    tmux-server-1552.log
    plot.sixel.tmux.gz

  5. nicm commented on Jun 30, 2018

    @nicm
    Member
  6. nicm commented on Jun 30, 2018

    @nicm
    Member
  7. pagerc commented on Jun 30, 2018

    @pagerc
    Author

    Yes, I ran gnuplot and it spat text to the screen, and I cat the plot.sixel.tmux file to render the image too. cat'ing the file seems to work reliably to render, running gnuplot in pipeline does not.
    I've gotten the gnuplot to render sometimes and do text garbage the next invocation, back to back just up-arrow/enter and I get different terminal behavior from tmux.
    I'm leaning towards some latency in gnuplot generating/piping data through sed vs cat'ing the image from disk to screen makes a difference in control sequence processing.

  8. pagerc commented on Jun 30, 2018

    @pagerc
    Author

    Is that a recompile to adjust the hardcoded timer, or can it be overwritten in a config?
    https://github.com/tmux/tmux/blob/master/input.c

  9. pagerc commented on Jun 30, 2018

    @pagerc
    Author

    I put a sleep 0.2 in my __tmux_guard before the DCS P tmux;, and I'm seeing the rendering be more reliable. Thanks for the assistance!

  10. lock commented on Feb 15, 2020

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  11. locked and limited conversation to collaborators on Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions