Skip to content

Commit

Permalink
Clear terminal output of interactive screen on resize if alternate sc…
Browse files Browse the repository at this point in the history
…reen not in use (#952)
  • Loading branch information
dangooddd authored and ArthurSonzogni committed Dec 26, 2024
1 parent aae4e55 commit a015d8b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ftxui/component/screen_interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,13 @@ void ScreenInteractive::Draw(Component component) {
ResetCursorPosition();
std::cout << ResetPosition(/*clear=*/resized);

// If the terminal width decrease, the terminal emulator will start wrapping
// lines and make the display dirty. We should clear it completely.
if ((dimx < dimx_) && !use_alternative_screen_) {
std::cout << "\033[J"; // clear terminal output
std::cout << "\033[H"; // move cursor to home position
}

// Resize the screen if needed.
if (resized) {
dimx_ = dimx;
Expand Down

0 comments on commit a015d8b

Please sign in to comment.