crossterm icon indicating copy to clipboard operation
crossterm copied to clipboard

Make Windows clear the whole buffer and not only the visible part.

Open TimonPost opened this issue 6 years ago • 9 comments
trafficstars

Task Description

If you call terminal.clear(ClearType::All) the whole buffer, the visible, and the invisible part should be cleared. This happens correctly on Linux, however, the winapi implementation only clears the visible buffer. The same as the command 'cls' works. The winai is used on windows versions <than 8.

Task Todo

Make terminal.clear(ClearType::All), clear the whole screen buffer instead of only the visible part.

  • [ ] Figure out how to get the screen buffer dimensions, not the visible part, but also the invisible part.
  • [ ] Replace the size here so that all screen contents are removed.

example Naamloos

TimonPost avatar Jun 22 '19 20:06 TimonPost

Can be closed since, this is not needed

TimonPost avatar Jul 25 '19 15:07 TimonPost

Why it is not needed? I am trying to use crossterm on Windows 10 and terminal.clear(ClearType::All) behaves weird compared to cls.

im-nefilim avatar Aug 18 '20 14:08 im-nefilim

Good question. The answer is not archived in my brain anymore. Let's reopen It until I know why ;)

TimonPost avatar Aug 19 '20 17:08 TimonPost

Bump, I have this issue on Windows 10 while using tui

scambier avatar Dec 27 '20 10:12 scambier

Only way to make the terminal.clear(ClearType::All) to clear the whole screenbuffer would require the usage of the legacy winapi instead of ANSI. And since modern unix terminals handle the ESC [2J inconsistently I don't think it should get handeled differently on windows. One way to make it more consisten across all ANSI supporting terminals would be to use ESC [H before the ESC [2J to set the cursor at the top-left of the viewport before clearing.

kallekankaanpaa avatar Feb 04 '21 18:02 kallekankaanpaa

Having the same issue on linux mint with gnome-terminal and alacritty. Adding another option (Purge for lack of a better name) as ANSI 3J seems to fix the issue for me

#591

Termina94 avatar Aug 10 '21 23:08 Termina94

@Termina94 Purge already is the name of a ClearType though. https://docs.rs/crossterm/0.21.0/crossterm/terminal/enum.ClearType.html#variant.Purge

tobiasvl avatar Sep 28 '21 17:09 tobiasvl

@tobiasvl this was merged in August https://github.com/crossterm-rs/crossterm/pull/591#issuecomment-898381852

Termina94 avatar Sep 28 '21 18:09 Termina94

Only winapi logic has yet to be implemented

TimonPost avatar Sep 29 '21 16:09 TimonPost