diff --git a/include/ftxui/component/screen_interactive.hpp b/include/ftxui/component/screen_interactive.hpp index 6c799136..999fbbca 100644 --- a/include/ftxui/component/screen_interactive.hpp +++ b/include/ftxui/component/screen_interactive.hpp @@ -121,6 +121,7 @@ class ScreenInteractive : public Screen { bool mouse_captured = false; bool previous_frame_resized_ = false; + bool validated_ = false; bool frame_valid_ = false; bool force_handle_ctrl_c_ = true; diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index b5643ed9..b49b8b86 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -858,6 +858,14 @@ void ScreenInteractive::Draw(Component component) { ResetCursorPosition(); std::cout << ResetPosition(/*clear=*/resized); + // clear terminal output if non-fullscreen interactive screen dimx decreases +#if !defined(_WIN32) + if ((dimx < dimx_) && validated_ && !use_alternative_screen_) { + std::cout << "\033[J"; + std::cout << "\033[H"; + } +#endif + // Resize the screen if needed. if (resized) { dimx_ = dimx;