Re: [PATCH v7 0/3] console: Add persistent scrollback buffers for all VGA consoles

Andrey Utkin
2016-11-28T00:02:15Z

On Mon, Nov 28, 2016 at 12:15:48AM +0100, Adam Borowski wrote:
> On Sun, Nov 27, 2016 at 09:37:30PM +0000, Andrey Utkin wrote:
> > I've just patched next-20161125 with this set and given it a run.
> >
> > Scrollback persistence works fine, just as in earlier versions.
> >
> > This time I didn't forget to test clear operation.
> >
> > The only important concern is that after logout, the scrollback is not
> > wiped by /bin/login or /sbin/agetty (not sure who of them is responsible
> > for that). What do you see on your workstations in this case?
>
> If you're on Debian or a derivative, that's clear_console. It uses a
> switch-vt-then-back hack which obviously doesn't work with scrollback
> persistence. Reported as https://bugs.debian.org/845177 -- I'll molest the
> maintainer if the patch doesn't get applied soon, so we can have the fix in
> time for stretch (then Ubuntu zesty).

I'm on Gentoo.

> Because of a sad lack of a time machine, old systems will use clear_console
> with that hack until they die, that's why
> CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT defaults to n; in a few years it'll
> be ok to flip it.
>
> > I guess we need to do something of the following:
> > - catch some control character sequences to wipe the scrollback
>
> \e[3J
>
> > - indicate (by some flag) some feature capability for this
>
> Terminfo calls this flag "E3".
>
> > - request update in terminfo database or whatever, to let ncurses know
> > that it is capable of scrollback wiping by some control charater
> > sequences
>
> Already there for quite a while.
>
> > clear(1) doesn't wipe the scrollback at all, it is still reachable, all
> > of it.
>
> It does for me on the console. The man page says:
>
> # clear clears your screen if this is possible, including its scrollback
> # buffer (if the extended "E3" capability is defined). clear looks in the
> # environment for the terminal type and then in the terminfo database to
> # determine how to clear the screen.
>
> Because of its reliance on terminfo, you need to have TERM=linux in your
> environment; also, screen/tmux obviously breaks this.

I wonder whether my ncurses is not bleeding-edge enough, or I have some
non-standard config. Anyway, thanks for explanation.

> > echo -e "\e[3J" seems to wipe the scrollback, but if you do it several
> > times in a row, every time you (or at last I do) get your prompt a bit
> > lower, so after many times you end up with blank screen and the prompt
> > at the bottom of the screen.
>
> Yeah, none of \e[J subcommands move the cursor at all. As you use echo
> without -n, you move two lines lower, and even with -n the command you typed
> takes a line. You want to move the cursor explicitly, add "\e[H".

Thanks for explanation.