9

I would like to use screen (from GNOME Terminal, via ssh) like I use GNOME Terminal without screen, or as close as possible to that. Specifically:

In GNOME Terminal, I can scroll back using the mouse wheel, the scrollbar or Shift+PgUp/PgDn. In screen, I have to go to copy mode (Ctrl+A,[) to be able to scroll back (mouse wheel works after that). Scrolling behavior can be changed (see this answer and this answer) but this solution has the following flaws:

  1. When I open a file with less or vim, I can scroll above the editor 'window' with my mouse wheel and see the previous contents of the terminal.
  2. When I close the editor, its contents stay in the scrollback buffer (sometimes in several copies) instead of disappearing.

This behavior can be changed using altscreen on (see this answer) but the only effect is that when the editor is closed, the old terminal contents are appended to the scrollback buffer in my terminal window so I can still see the editor crap when I scroll back using my mouse wheel.

Does this mean it's not possible to have nice scrolling in screen? Basically, all I'd like is being able to scroll just like in copy mode (using the mouse wheel, and scrollbar if possible) but without having to enter copy mode.

1 Answers1

4

Perhaps you cannot have what you are asking.

From the terminal's standpoint:

  • screen is a full-screen (no pun) application just like vi or less.
  • the terminal implements scrolling and an alternate screen.
  • when the terminal is in alternate-screen mode, it does not add to its scrollback area as it would in normal mode.
  • in gnome-terminal (and perhaps some others — an option in xterm), the terminal will send up/down arrow keys to the application when it is in alternate-screen mode.
  • when not in alternate screen mode, your terminal will scroll through the visible screen and the terminal's scrollback area without any notification to the application running inside it.

From screen:

  • screen does not know anything about mice or scrolling; it passes that information to the application running inside screen.
  • screen simulates an alternate screen; it has no way to access the alternate screen of the terminal.
  • you can disable the alternate screen feature of the terminal, as indicated in the question.

In short, because screen does not have any way to access the scrollback of the terminal, your available choices are those that the terminal provides.

Thomas Dickey
  • 76,765
  • So screen runs in alternate screen mode by default but when I put altscreen on in .screenrc, screen tries to simulate one and turns it off in the terminal, right? And termcapinfo xterm* ti@:te@ tells screen not to capture the mouse wheel so it's caught by the terminal and used for scrolling? – ondra.cifka Apr 18 '16 at 23:56
  • yes - except that screen's altscreen is simulated, whether or not the terminal supports the feature. – Thomas Dickey Apr 18 '16 at 23:58
  • I'm trying to map mouse events using Termion (a Rust library) on an alternate screen. I'm using Terminator terminal, and it seems indeed it maps scrollwheel to up/down. Wondering if there's a way to avoid that and use my custom mappings. – madprops Aug 22 '19 at 06:17
  • But, in theory, it should be possible to have a keystroke in screen that
    • switches to not altscreen
    • dumps all content of currently active window to the terminal (to fill scrollback)
    • from now on passes all output verbatim to the terminal while recording it internally in case of attaching later?

    Of course, only with a single window, and there would have to be an option to turn it off again so you can use copy mode or split mode again.

    – mihi Jul 15 '23 at 17:37