Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Greg Wooledge
On Wed, Jun 21, 2017 at 03:39:42PM +0530, Avinash Sonawane wrote:
> On Wed, Jun 21, 2017 at 1:36 PM, Christian Seiler  wrote:
> Furthermore, this also suggests that the 'clear' and 'tput clear' in
> Stretch clear the scrollback buffer. But this isn't true either.
> 'clear' or 'tput clear' doesn't clear the scrollback buffer. I can
> still see the screenful of scrollback. (Please see the screenshots
> attached in the original post)
> 
> So 'clear' in Stretch doesn't do what it sets on to do.
> 
> I tried gnome-terminal, xfce4-terminal and terminator with the same
> observations as above.

If we're collecting data: in stretch, in rxvt-unicode, 'clear' and
'tput clear' do NOT erase the scrollback buffer.

In stretch, in xterm, both 'clear' and 'tput clear' DO erase the
scrollback buffer.

Yet another reason for me to continue using rxvt-unicode. :-)



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Avinash Sonawane
On Wed, Jun 21, 2017 at 1:36 PM, Christian Seiler  wrote:

> So what happened is that 'tput clear' in Stretch now behaves the
> same as 'clear', while the version in Jessie of 'tput clear'
> wouldn't clear the scrollback buffer.

Furthermore, this also suggests that the 'clear' and 'tput clear' in
Stretch clear the scrollback buffer. But this isn't true either.
'clear' or 'tput clear' doesn't clear the scrollback buffer. I can
still see the screenful of scrollback. (Please see the screenshots
attached in the original post)

So 'clear' in Stretch doesn't do what it sets on to do.

I tried gnome-terminal, xfce4-terminal and terminator with the same
observations as above.

-- 
Avinash Sonawane (rootKea)
PICT, Pune
https://rootkea.wordpress.com



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Christian Seiler

Hi,

Am 2017-06-21 11:57, schrieb Avinash Sonawane:
On Wed, Jun 21, 2017 at 1:36 PM, Christian Seiler  
wrote:

So what happened is that 'tput clear' in Stretch now behaves the
same as 'clear', while the version in Jessie of 'tput clear'
wouldn't clear the scrollback buffer.


This suggests that the version of 'clear' in Jessie used to clear the
scrollback buffer.
But that's untrue. I have always used 'clear' to clear the screen in
Jessie. And it never cleared the scrollback buffer. (I'm not sure
about 'tput clear' though. Haven't used that much)


I see two possible explanations for the behavior you're seeing:

 a. The terminal program you're using doesn't like the additional ';'
character in the escape sequence that 'clear' on Jessie was
sending, so ignored the escape sequence entirely. In that case
it only interpreted '\033[H\033[2J'.

Reminder: 'clear' on Jessie would send:   \033[3;J\033[H\033[2J
  'clear' on Stretch would send:  \033[3J\033[H\033[2J
  On the Linux text console \033[3J and \033[3;J both
  clear the scrollback buffer completely, at least with
  kernel 4.9.

 b. The terminal program you're using changed behavior between
Jessie and Stretch. For example, KDE's 'konsole' terminal program
will _not_ clear the scrollback buffer with either one of these
commands:

  printf '\033[3J\033[H\033[2J'
  tput clear
  clear

It may be that your terminal program used to ignore the sequence
as well in Jessie, but implemented it in Stretch.

(Funnily enough, just found out, KDE's 'konsole' will clear it
if you just issue \033[3J - but once you issue a \033[2J again,
it will restore the buffer once more. Really weird.)

You can test which one of these is the case by using the following
commands:

printf '\033[3;J\033[H\033[2J'

printf '\033[3J\033[H\033[2J'

If the first one doesn't erase the scrollback buffer, but the second
one does, then you know that your program doesn't support the escape
sequence that Jessie's clear sent, but does support the one that
Stretch sent. (Case a.) If in both cases the scrollback buffer is
erased, then it's likely that the behavior of your terminal program
changed between Jessie and Stretch. (Case b.)

Regards,
Christian



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Avinash Sonawane
First of all, thank you very much for that informative email!

On Wed, Jun 21, 2017 at 1:36 PM, Christian Seiler  wrote:

> So what happened is that 'tput clear' in Stretch now behaves the
> same as 'clear', while the version in Jessie of 'tput clear'
> wouldn't clear the scrollback buffer.

This suggests that the version of 'clear' in Jessie used to clear the
scrollback buffer.
But that's untrue. I have always used 'clear' to clear the screen in
Jessie. And it never cleared the scrollback buffer. (I'm not sure
about 'tput clear' though. Haven't used that much)

Regards,
Avinash Sonawane (rootKea)
PICT, Pune
https://rootkea.wordpress.com



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Avinash Sonawane
On Wed, Jun 21, 2017 at 2:02 PM, Sven Joachim  wrote:

> I just want to add that every reasonable shell lets you clear the screen
> while preserving the scrollback buffer, simply press Control-L.

Thank you! I had completely forgotten the form feed!
-- 
Avinash Sonawane (rootKea)
PICT, Pune
https://rootkea.wordpress.com



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Sven Joachim
On 2017-06-20 17:20 +0530, Avinash Sonawane wrote:

> I just upgraded to Stretch from Jessie and I'm experiencing this weird
> issue with xfce4-terminal. Whenever I type "clear" on terminal it
> clears the terminal (that's expected!) *but* now I can scrollback only
> a screenful. Earlier text n terminal is just can't be scrollbacked to.
> Here are the screenshots https://imgur.com/a/aPD4F Please observe the
> scrollbar.
>
> xfce4 -terminal version 0.8.3
>
>
> Any pointers?

Others have already answered your question about the "clear" command, I
just want to add that every reasonable shell lets you clear the screen
while preserving the scrollback buffer, simply press Control-L.

Cheers,
   Sven



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Christian Seiler

Am 2017-06-21 10:06, schrieb Christian Seiler:

'clear' and 'tput clear' are identical in Stretch, both are from
ncurses-bin. This was not true in Jessie though, ncurses did
change behavior between Jessie and Stretch.


By the way. in case anyone was wondering:

Upstream changelog about how clear and tput clear are now
identical:
http://invisible-island.net/ncurses/NEWS.html#t20161022

Clearing the scrollback buffer is actually desired behavior,
see also:

http://invisible-island.net/ncurses/NEWS.html#t20130622
https://bugzilla.redhat.com/show_bug.cgi?id=815790
https://unix.stackexchange.com/questions/87469/clearing-the-old-scrollback-buffer

And this is apparently documented now:

http://invisible-island.net/ncurses/NEWS.html#t20161119
https://manpages.debian.org/stretch/ncurses-bin/clear.1.en.html

Regards,
Christian



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread Christian Seiler

Am 2017-06-21 05:57, schrieb Avinash Sonawane:
On Wed, Jun 21, 2017 at 3:26 AM, Larry Dighera  
wrote:



Try: tput clear


Right. My bad! I already did that. But I have always considered
`clear` and `tput clear` to be the same so I didn't mention it before.
Anyways I got exactly same behavior with `tput clear`.


'clear' and 'tput clear' are identical in Stretch, both are from
ncurses-bin. This was not true in Jessie though, ncurses did
change behavior between Jessie and Stretch.

The following escape sequences are printed by clear / tput clear:

|  Jessie |  Stretch
+-+
clear   |  \033[3;J\033[H\033[2J  |  \033[3J\033[H\033[2J
tput clear  |  \033[H\033[2J  |  \033[3J\033[H\033[2J


To decode them (man 4 console_codes):

 \033[3J or \033[3;J
   clear the entire scrollback buffer
 \033[H
   go to position on the screen,
   default: top left corner
 \033[2J
   clear entire screen

So what happened is that 'tput clear' in Stretch now behaves the
same as 'clear', while the version in Jessie of 'tput clear'
wouldn't clear the scrollback buffer.

Furthermore, whether the scrollback buffer is actually cleared is
also up to the program managing the buffer; the Linux text console
respects that, but e.g. 'Konsole' from KDE doesn't, there \033[3J
has the same effect as \033[2J - the scrollback buffer remains
intact regardless. (At least in the default settings, haven't
checked if that behavior can be changed.) It could also be that
the terminal emulator you're using has also changed it's behavior.

In any case: if you want 'clear' to act the same way 'tput clear'
acted in Jessie, you can simply add

alias clear="printf '\033[H\033[2J'"

to your .bashrc (or similar if you're using a different shell),
that should get you the behavior you had beforehand. [1]

Regards,
Christian

[1] Technically this alias is not 100% correct, as both 'clear'
and 'tput clear' will interpret the TERM environment variable and
make sure that the sequences they send out are actually understood
by the terminal. However, in practice any terminal you're going to
use this on is going to support this specific sequence, so you
don't need to worry about these details. In case you're accessing
from ancient terminal hardware (think 70s mainframes or similar)
this alias might not work though.



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-21 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wed, Jun 21, 2017 at 09:27:45AM +0530, Avinash Sonawane wrote:
> On Wed, Jun 21, 2017 at 3:26 AM, Larry Dighera  wrote:
> 
> > Try: tput clear
> 
> Right. My bad! I already did that. But I have always considered
> `clear` and `tput clear` to be the same so I didn't mention it before.
> Anyways I got exactly same behavior with `tput clear`.

They do *nearly* the same:

  tomas@rasputin:~$ clear | hexdump -C
    1b 5b 33 3b 4a 1b 5b 48  1b 5b 32 4a  |.[3;J.[H.[2J|
  000c
  tomas@rasputin:~$ tput clear | hexdump -C
    1b 5b 48 1b 5b 32 4a  |.[H.[2J|
  0007

(FWIW: my terminal is a straight xterm, and TERM=xterm).

Mystery? Well, clear's manpage says:

   clear  clears your screen if this is possible, including its
   scrollback buffer (if the extended "E3" capability is defined)
   [...]

so this "ESC[3;J" at the beginning of clear seem to be this magical
scrollback buffer thingy. Too pressed to actually look things up,
though :)

cheers
- -- t
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAllKJTYACgkQBcgs9XrR2kb5gwCcCkb8iye1W7XvZQV/f/Yel3WT
PXgAn3RZj8lGXq40FsI4dFykeIp8YuWH
=dByB
-END PGP SIGNATURE-



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-20 Thread Avinash Sonawane
On Wed, Jun 21, 2017 at 3:26 AM, Larry Dighera  wrote:

> Try: tput clear

Right. My bad! I already did that. But I have always considered
`clear` and `tput clear` to be the same so I didn't mention it before.
Anyways I got exactly same behavior with `tput clear`.

-- 
Avinash Sonawane (rootKea)
PICT, Pune
https://rootkea.wordpress.com



Re: [Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-20 Thread Larry Dighera
On Tue, 20 Jun 2017 17:20:25 +0530, you wrote:

>Any pointers?

Try: tput clear



[Stretch]Typing ""clear" on terminal restricts the scrollback to only a screenful

2017-06-20 Thread Avinash Sonawane
Hello

I just upgraded to Stretch from Jessie and I'm experiencing this weird
issue with xfce4-terminal. Whenever I type "clear" on terminal it
clears the terminal (that's expected!) *but* now I can scrollback only
a screenful. Earlier text n terminal is just can't be scrollbacked to.
Here are the screenshots https://imgur.com/a/aPD4F Please observe the
scrollbar.

xfce4 -terminal version 0.8.3


Any pointers?

Ps - While replying please keep me in loop as I'm not subscribed to the list.

Thanks,
Avinash Sonawane (rootKea)
PICT, Pune
https://rootkea.wordpress.com