3 ms·
Terminal emulators (xterm, iterm2 etc) are emulating something like a VT220 which were called "glass terminals" to differentiate them from earlier terminals whi
by mprovost 7y ago
Terminal emulators (xterm, iterm2 etc) are emulating something like a VT220 which were called "glass terminals" to differentiate them from earlier terminals which were keyboards attached to printers. So there's still this underlying concept of an endless spool of paper, and that's what you see when you scroll back. A scroll is literally a long piece of paper.
Anyway that means if you cat some long file and then hit control-c, whatever was output before you aborted still has to be sent to your terminal emulator so it can write it to this paper (save it to the scrollback buffer). This sucks on a slow connection. mosh is running the emulator on the remote side of the connection and the client that you're interacting with locally just syncs periodically to whatever is currently being shown on the screen. So it doesn't have to send all of the output, which as you've seen, does break local scrollback. But it's a great solution for the problem it was designed to solve which is making terminals work over slow and/or unreliable network connections.
If you pair it with gnu screen or tmux, then they become the terminal emulator and maintain the scrollback buffer, so you can still scroll back and see all of the paper. You just can't do it with the slider on your local window because your local emulator doesn't have access to the full contents of the buffer. I turn off scrollbars in rxvt and just rely on screen to maintain the buffer and use command keys to go back when I need to.
- Dylan16807 7y agoMosh could easily load the skipped-over lines in the background. It's not incompatible with the design. It just requires a developer to put in the effort.
- mprovost 7y agoCan it though? How can a program manipulate the scrollback buffer of the terminal that it's running in? Other than by printing more output. But once it's updated the current line, it can't go back and add more lines - those lines have already been printed on the scroll.
- Dylan16807 7y agoEven if it had no way to communicate the lines to the local terminal, it could still load them and handle the scrollback itself, locally. I think that's what the eventual plan is, too. But it wouldn't be exceptionally difficult to figure out some way to stuff lines into the scroll buffer. Especially if you got a mosh-aware terminal.
- globular-toast 7y agoThe main trouble with using screen for scrollback is it introduces latency when I need to scroll, and that's exactly the problem I was trying to solve when using mosh in the first place! Maybe I could completely change the way I work, but for now I'll continue to put up with typing latency and other problems with ssh.