3 ms·
tmux, screen, emacs, and vim all have terminal emulators in them because it’s required, not because they’re crazy. Consider a really simple case. You are using
by db48x 3y ago
tmux, screen, emacs, and vim all have terminal emulators in them because it’s required, not because they’re crazy.
Consider a really simple case. You are using screen (or tmux, or emacs, or whatever) and you have your terminal divided in half so that you can use a program in one half and tail a log file in the other. The program sends a ^L to clear the screen. Screen (or tmux or whatever) must read the ^L and then _not_ send it on. If it sent it on, the whole screen would be cleared, not just the half with the program in it. Instead it has to send whatever control sequences would erase the text from just the right portion of the screen while leaving everything else alone. Virtually everything sent by the program(s) has to be intercepted and reinterpreted in order for it to work right.
- kps 3y agoNo, they're crazy. I already have a window manager I like; I don't need my terminal to implement their own half-assed one, and my multiplexer (running on the terminal) to implement their own half-assed one, and my editor (running on the multiplexer on the terminal) to implement their own half-assed one.
- hnlmorg 3y agoSo don't use tmux then. The entire reason most people use something like tmux is because they want a window manager in their terminal. This is one of the great joys of FOSS, if you don't like a terminal-based utility then you can bet there's a dozen other options available for you to use.
- db48x 3y agoIf you really want crazy, run `xterm -ti 340`, then run run an X server from the xserver-sixel repository <https://github.com/saitoha/xserver-SIXEL https://github.com/saitoha/xserver-SIXEL> in it. Now y ou can run as many terminal emulators, complete with real truetype fonts and all the colors you could want, inside the one terminal. Use a tiling window manager and you’ll be able to avoid using tmux entirely.
- matvore 3y ago> No, they're crazy. I already have a window manager I like; I don't need my > terminal to implement their own half-assed one, Basically agree, though note that ssh and dtach and similar tools need to create pty's on the server and client ends because they implement essentially an adapter between a tty and a byte stream.
- hnlmorg 3y agoI agree with your overall point but your example isn't a great one because ^L would be handled by the controlling process regardless of the terminal state. You don't need any special magic here. And blanking specific sections of a screen wouldn't need any special magic unless you're launching other processes and forwarding their output to the terminal. But if you're not forwarding the output of other processes then you can use standard ANSI escape sequences (or even just \s) to blank specific parts of the screen. \s is a bit hacky for blanking though, it can produce some undesired results in terms of copy/pasting from the terminal and resizing. But if you've got a "full screen" process like you're describing, you'd be trapping SIGWINCH for resize events anyway.
- hnlmorg 3y agoSince I'm getting downvoted so I'll evidence my point a little more: Bash source for the ^L hotkey: https://git.savannah.gnu.org/cgit/bash.git/tree/lib/readline/text.c#n589 https://git.savannah.gnu.org/cgit/bash.git/tree/lib/readline... Notice it's calling termcap: _rl_clear_screen (0); /* calls termcap function to clear screen */ So lets look at what termcap does: $ tput clear | hexdump -c 0000000 033 [ H 033 [ 2 J 0000007 Which isn't the ASCII character ^L (0xC) but instead an ANSI escape code (CSI sequence, to be exact) https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_... The actual ASCII character for ^L is form feed, (FF: https://www.ascii-code.net https://www.ascii-code.net) which does serve a similar function but designed for old printers: https://en.wikipedia.org/wiki/Page_break#Form_feed https://en.wikipedia.org/wiki/Page_break#Form_feed It doesn't actually clear the screen on modern TTYs. You can try this yourself: $ printf "\f" $ awk 'BEGIN{printf "%c", 12}' $ Notice how each time it's effectively doing the same as \n? So in conclusion, ^L clearing the screen isn't something built into the TTY. It's just a hot key like ^U. There are some hot keys are are driven by the TTY though. ^C, for example. When you press ^C you're not actually sending the 0x3 ASCII character to the controlling process, your TTY gobbles that up and sends a signal to the controlling process instead (albeit this behaviour can be changed by altering the TTYs mode, which requires making a SYSCALL). So here we've discussed ANSI escape codes, signals and SYSCALLs. However none of these interactions are ASCII characters despite how they're depicted in printed media. Suffice to say, terminals are complicated :)
- JdeBP 3y agoAmusingly, FF is almost never the control character for clearing the screen. The idea that it is, is widespread, and attributable to some home computers of the 1980s. But it was never the case for DEC VTs. It's equivalent to VT.