Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how=2 also clear the entire display #399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryuukk
Copy link

@ryuukk ryuukk commented Aug 13, 2023

0 = clear display from cursor to end, therefore it needs history

however

2 = clear entire display

On windows when using git bash, clear didn't clear the entire display, it put back the history therefore you could always scroll back

If you use the provided terminal emulator (from msys), calling clear clear the entire display, so that's the proper behavior, same when using Windows Terminal

With this PR clear now behaves properly with Terminus

Fix #120, #340 and probable some other issues

There is also this line in the code base that looks suspicious:

https://github.com/randy3k/Terminus/pull/399/files#diff-1ff8d95a5f63ac2d193b501633246f1211a04d98c4ef04782ddd5a9a1dc327b3R390-R392

@randy3k
Copy link
Owner

randy3k commented Aug 15, 2023

It is working as intended. 2 should only erase the viewport and 3 would erase the scrollback history.
See https://xtermjs.org/docs/api/vtfeatures/#csi



0 | Erase from the cursor through the end of the viewport.
-- | --
1 | Erase from the beginning of the viewport through the cursor.
2 | Erase complete viewport.
3 | Erase scrollback.

@ryuukk
Copy link
Author

ryuukk commented Aug 15, 2023

Who is right? xtermjs, or windows terminal, msys terminal and other tools?

@randy3k
Copy link
Owner

randy3k commented Aug 15, 2023

vt510 doesn't have the concept of scrollback history. We should unleast reference xterm.
image
https://www.xfree86.org/current/ctlseqs.html

Of course, Windows terminal may have evolved differently as xterm and inconsistency is expected. Terminus would follow xterm's standard in case of having any inconsistency.

@randy3k
Copy link
Owner

randy3k commented Aug 15, 2023

By the way, it also depends on the clear program that you use. Some clear program will emit \e[3J and some will emit \e[2J.

@ryuukk
Copy link
Author

ryuukk commented Aug 15, 2023

Options from clear

Options:
  -T TERM     use this instead of $TERM
  -V          print curses-version
  -x          do not try to clear scrollback

If -x tries to not clear scrollback, what does not calling it with -x supposed to do according to clear?

it prints:

\033[H\033[2J\033[3J 

So 3 is there, why does terminus stops at 2?

Calling it with -x prints

\033[H\033[2J

So you may be right, however, terminus stopping at 2 and not handling 3, wich is present, is a bug right?

@randy3k
Copy link
Owner

randy3k commented Aug 15, 2023

printf '\033[H\033[2J\033[3J' does clear the scroll back history for me (in bash and zsh / macOS).

@raypanjaitan
Copy link

I am using Windows, in cmd to clear the entire cmd I have to use "cls" instead of "clear".
However, in terminus "cls" only scroll down to the cursor instead of clearing all the display.

@mataha
Copy link
Contributor

mataha commented May 21, 2024

I am using Windows, in cmd to clear the entire cmd I have to use "cls" instead of "clear". However, in terminus "cls" only scroll down to the cursor instead of clearing all the display.

That's because cls prints ASCII 0x0C (<FF> - form feed) unless cmd.exe is connected to stdout:

printf("\014"); // ^L
return 0;

Neither Windows Terminal nor conhost.exe implement CSI 3 J. CSI 2 J works as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"clear" command only scrolls the output
4 participants