Hi, On 2025-05-22 at 16:17 -0400, Nicolas Pitre <[email protected]> wrote: > It's a question of implementation. Everything is already in place for VT > switching. So this might be the easiest path.
If we are talking about alternate screen support (and not scrollback), then this is probably not an optimal solution, because switching back and forth between the alternate and the main screens should not change terminal state (except screen contents and cursor position – to be honest, I don't know about cursor shape). The general idea is that all other terminal state (such as flow control, input mode, character echo, special control characters, terminal size, etc.) are shared by main and alternate screens. So if free VTs are used as alternate screens then terminal state synchronization between two VTs needs to be implemented. Also ttyname(3) should return the same thing both in the main and in the alternate screen. If I was implementing this (into a fictional kernel with no pre-existing console driver), I would allocate two buffers for screen contents (text, text colours, text attributes, cursor position) and have one pointer named current_screen which points to either of those buffers. All writes (and reads) to the terminal would use the current_screen pointer and the afforementioned escape sequences could be used to change the target of current_screen. After every terminal contents update (and screen switch) a selective redraw of the real display would occur. In Linux this would probably need to be a bit more complicated, if it still supports VGA text mode. Maybe one of the buffers can reside in the real VGA memory and on each screen switch the contents of this memory are swapped with a backup buffer. There is one more quirk that came up when I read about alternate screen: this seems to be a controversial feature. Even though most people like it a lot, there are people who don't. It is handy to get back to the screen contents as they were before starting an application, but some people prefer not to have this feature – for example to be able to more easily manually copy data from the file they just viewed with a pager. For this reason many terminal emulators allow configuring this feature. If alternate screen support is added to Linux, there probably should be a way to disable it – maybe sysctl or kernel command line option. -- Aura _______________________________________________ This message was sent via the BRLTTY mailing list. To post a message, send an e-mail to: [email protected] For general information, go to: http://brltty.app/mailman/listinfo/brltty
