GNOME Bugzilla – Bug 678042
support CSI 3J ?
Last modified: 2014-12-28 22:55:01 UTC
Linux console supports CSI J with parameter 3 to clear the scrollback as well [1]; maybe vte should support that too? Code is in vte_sequence_handler_erase_in_display(). [1] https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=commit;h=f8df13e0a901fe55631fed66562369b4dba40f8b
xterm also supports this, and ncurses emits it from the 'clear' command. CSI Ps J Erase in Display (ED). Ps = 0 -> Erase Below (default). Ps = 1 -> Erase Above. Ps = 2 -> Erase All. Ps = 3 -> Erase Saved Lines (xterm).
Relevant: https://bugzilla.redhat.com/show_bug.cgi?id=1035807 Apparently Fedora's "clear" command emits this escape sequence.
Note: Linux console and xterm differ in behavior. Linux console clears the scrollback and the onscreen contents. Xterm clears the scrolled out contents only, leaves the onscreen bits intact. Putty and konsole also follows xterm; I think we should too. Also note that only the first numeric argument is taken into account, e.g. "CSI 3;J", "CSI 3;0J", "CSI 3;1J" etc. are all equivalent to "CSI 3J", i.e. leave the onscreen contents unchanged (following the spirit of bug 741402).
Created attachment 293341 [details] [review] Add support for CSI 3J Here's an implementation. I've verified that the streams are actually reset, i.e. even with the infinite scrollback case the files are truncated to 0 size. In combination with bug 506438 the behavior of the "clear" command is a bit weird, effectively it leaves one pageful of data in the scrollback. (First it emits CSI 3;J which wipes out the scrollback. Then with CSI H it homes the cursor. Finally with CSI 2J it clears everything under the cursor - which in vte scrolls by a pageful of lines.) This deviates from xterm, and is the same as konsole.
Review of attachment 293341 [details] [review]: ::: src/ring.c @@ +628,3 @@ +_vte_ring_drop_scrollback (VteRing * ring, gulong position) +{ + g_assert(ring->writable <= position); clear; maximize window; clear => this fails Instead of assertion we'd need an ensure_writable
Created attachment 293351 [details] [review] Add support for CSI 3J, v2
Split change into two; submitted.