abcdef123xyz123
Joined 8 years ago
Joined 8 years ago
Mouse and scrollback and clipboard are some of the more complicated areas of terminal emulators and ones where applications like tmux have the least power so they will always have the potential to be a bit fiddly.
For tmux, it will look at VISUAL/EDITOR so for vi keys you could just try to remember to run it as "VISUAL=vi tmux" or to run "tmux set -g mode-keys vi" if you forget.
If send-keys didn't exist, a script could attach tmux in its own pty instead.
Detach/attach is a fundamental part of how tmux works, everyone must understand that it is fully available to anyone with access to your user.
GNU screen also has a similar feature to send-keys (they call it "stuff").
It has always been good practice to detach long-running root programs by starting a new tmux as root rather than running them in a non-root tmux, and to use sudo rather than su to run root commands inside tmux the same way as you would outside.
There is absolutely no reason that many terminal emulators couldn't translate key up events into an escape sequence and forward them on to the application. So long as they receive them somehow themselves (eg an X terminal emulator will be told of them by X).
It doesn't need to be out-of-band and it doesn't need to involve the tty driver.
The right way to do it is to make them only sent when the application requests them.
For example, this is how focus events work. If the application requests them with SM ?1004, \033[I is sent when the window gains focus and \033[O when the window loses it. There are not a lot of applications that use them, but some can (eg vim).
> There's already no particularly consistent standard for most terminal events
This is not really true anymore, almost all terminals still in use (and certainly all that are widely used) are VT100 compatible. In fact most are broadly compatible with xterm. So that is pretty much the standard now, and most new features being added to terminals don't take any account of other types of terminal at all.
> It seems like it would just be a matter of adding another termcap entry for your specific terminal emulator, and hoping other people care enough to start implementing it in theirs.
termcap was superseded by terminfo around the late 80s. A few applications still use it, but most are now terminfo. The termcap database on most systems is now derived from terminfo.
terminfo is centrally managed as part of ncurses and stuff doesn't really get added to it just to see. The way it usually works is that one or more terminals add a feature and if it makes sense and is popular, applications will use it, and if applications use it then often it will end up in terminfo entries. Definitely if ncurses uses it, possibly if not (this can be controversial).
You are right that there is no real reason a terminal couldn't send an escape sequence for key up, although it would certainly have to be something requested by the application - there are plenty of other escape sequences like that (eg the mouse, focus events).
The tty doesn't really come into it, nor does the kernel or drivers, except for its own console terminal, but not many people use that very much.
SGR mouse mode is an example of a terminal feature added relatively recently which has been taken up widely.
https://gist.githubusercontent.com/nicm/9acc00b67035b5f2b8a8...
Which does the basics of this:
- Bump the sequence timeout to 5 seconds instead of 100 ms for more time for SIXEL images but still not let the terminal hang forever. This could be made more sophisticated perhaps.
- Check the code in DA for SIXEL support and also check a terminfo(5) extension flag Sxl.
- Recognise SIXEL sequences and pass them through (like the 'tmux' passthrough escape sequence) and copy them to the attached outside terminals if they support SIXEL (DA or Sxl set).
I didn't try to disable the terminal-can't-keep-up code during DCS, that is more complicated because some panes may be inside DCS and some may not. I only have a small test SIXEL image so I would need a larger one that demonstrates the problem to look at that.
I probably won't move this any further forward unless someone tests this, but it may be a good start for further work on SIXEL.