Skip to content

Comments

Properly clear terminal on Cursive::clear()#828

Open
azat wants to merge 1 commit intogyscos:mainfrom
azat-rust:fix-clear
Open

Properly clear terminal on Cursive::clear()#828
azat wants to merge 1 commit intogyscos:mainfrom
azat-rust:fix-clear

Conversation

@azat
Copy link
Contributor

@azat azat commented Jul 5, 2025

Using buffer.write().clear() over printer.clear() (which is self.buffer.write().fill(" ")) helps with properly clear the cursive screen area after invoking side TUI apps within it (i.e. vim)

Note, that this is not enough to clear the complete screen in case of using ShadowView.

Using `buffer.write().clear()` over `printer.clear()` (which is
`self.buffer.write().fill(" ")`) helps with properly clear the cursive
screen area after invoking side TUI apps within it (i.e. vim)

Note, that this is not enough to clear the complete screen in case of
using ShadowView.
azat added a commit to azat/chdig that referenced this pull request Jul 5, 2025
@gyscos
Copy link
Owner

gyscos commented Jul 25, 2025

Hi, and thanks for the work!

I'm just concerned that this would cause excessive I/O in most cases. Maybe we need a different function specifically for when another application may have messed up the screen.

@azat
Copy link
Contributor Author

azat commented Jul 26, 2025

Hi @gyscos!

I will be OK with a separate method, but AFAICS the clear is not a hot path, and usually called explicitly by user

@azat
Copy link
Contributor Author

azat commented Jul 26, 2025

This is an example for a problem - #831 (press e then exit from editor and then c - nothing will be cleared), hope this will help

@gyscos
Copy link
Owner

gyscos commented Feb 16, 2026

I just tested, and there's a few main things that require clearing the screen:

  • Screen is resized. If this happens it's totally fine to drop the write buffer.
  • A layer is removed. In this case it's unfortunate if we need to flush the entire screen again, as it could require a very small "diff" instead.

I'd rather expose a dedicated function to call after coming back from a separate app.

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.

2 participants