Skip to content

Commit 3b01a5a

Browse files
committed
Remove unused variable, allow clear on resize for Windows
1 parent faf7d7e commit 3b01a5a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

include/ftxui/component/screen_interactive.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class ScreenInteractive : public Screen {
121121
bool mouse_captured = false;
122122
bool previous_frame_resized_ = false;
123123

124-
bool validated_ = false;
125124
bool frame_valid_ = false;
126125

127126
bool force_handle_ctrl_c_ = true;

src/ftxui/component/screen_interactive.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,15 +858,12 @@ void ScreenInteractive::Draw(Component component) {
858858
ResetCursorPosition();
859859
std::cout << ResetPosition(/*clear=*/resized);
860860

861-
// clear terminal output if screen dimx decreases
862-
// only on primary screen
863-
// only on POSIX systems (linux/macos)
864-
#if !defined(_WIN32)
865-
if ((dimx < dimx_) && validated_ && !use_alternative_screen_) {
866-
std::cout << "\033[J"; // clear
861+
// If the terminal width decrease, the terminal emulator will start wrapping
862+
// lines and make the display dirty. We should clear it completely.
863+
if ((dimx < dimx_) && !use_alternative_screen_) {
864+
std::cout << "\033[J"; // clear terminal output
867865
std::cout << "\033[H"; // move cursor to home position
868866
}
869-
#endif
870867

871868
// Resize the screen if needed.
872869
if (resized) {
@@ -934,7 +931,6 @@ void ScreenInteractive::Draw(Component component) {
934931
std::cout << ToString() << set_cursor_position;
935932
Flush();
936933
Clear();
937-
validated_ = true;
938934
frame_valid_ = true;
939935
}
940936

0 commit comments

Comments
 (0)