dvdhrm / kmscon

Linux KMS/DRM based virtual Console Emulator
http://www.freedesktop.org/wiki/Software/kmscon
Other
433 stars 81 forks source link

Feature request: support alternate screen buffer #45

Closed bluetech closed 11 years ago

bluetech commented 11 years ago

xterm (and compatible) have a feature called "Alternate Screen Buffer" that's used by most "full screen" terminal applications, like vi, less, man, mutt and screen - it's in the default termcap init/deinit called ti/te or rmcup/smcup. When the application starts, it switches to an alternate screen buffer, which doesn't have a scroll buffer, and the original screen is left untouched. When the application quits/suspends, the original buffer is restored as if the the application never existed on the terminal. There's only one alternate screen, they're not stacked or something like that.

Some application allow to disable this, because some people don't like it (vim has t_ti and t_te, less has LESS=X, and xterm has the titeInhibit resource). Also some terminal emulators like the linux VT don't support it at all.

Someone did an illustration here: http://fixlog.blogspot.co.il/2006/09/stop-gnome-terminal-screen-clear.html

Here's the xterm reference: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#The Alternate Screen Buffer The relevant DEC control sequences are 47, 1047, 1048, 1049. Applications only use 1049 as far as I can tell.

Here's the xterm source code: http://anonscm.debian.org/gitweb/?p=pkg-xorg/app/xterm.git;a=blob;f=charproc.c;h=ec5f498d714615595832a3764d31f8f77232fe54;hb=HEAD#l4340

This feature is a bit annoying to implement, I think, but should basically boil down to toggling two tsm_screen's. When I tried it I got into some trouble, but with some refactoring it seems doable.

dvdhrm commented 11 years ago

Yeah, I know, the alternate-screen-buffer would be nice to have. And yes, TSM-screen (was kmscon_console) isn't that simple anymore. But I think it should be fairly easy to implement.

I wanted to work on my wl-system-compositor this week but thought "hey, lets first finish Ran's previous request, then I have an empty bugtracker for the week". And I did fix it! But it probably was a bit naive to think that there wouldn't be any new report this week ;) So if this takes more work than I think, it might get delayed for one/two weeks.

Thanks a lot for the links and for investigating into this! David

dvdhrm commented 11 years ago

I have pushed several commits that implement everything that is needed for alternate-screen support. The main commit probably is b194ba8340c303e931102a25462e7d172a0bbc96

I have also fixed some bugs with it and pushed session-support, so some stuff might break. But it works all quite well here on my machine.

Regards David