Clear terminal on resize. (#99)

This commit is contained in:
Arthur Sonzogni
2021-05-17 00:44:37 +02:00
committed by GitHub
parent e520ac59f9
commit 30a85c4c5b
3 changed files with 22 additions and 11 deletions

View File

@@ -382,11 +382,6 @@ void ScreenInteractive::Loop(Component component) {
// The main loop.
while (!quit_) {
if (!event_receiver_->HasPending()) {
std::cout << reset_cursor_position << ResetPosition();
static int i = -2;
if (i % 10 == 0)
std::cout << DeviceStatusReport(DSRMode::kCursor);
++i;
Draw(component);
std::cout << ToString() << set_cursor_position;
Flush();
@@ -442,8 +437,11 @@ void ScreenInteractive::Draw(Component component) {
break;
}
bool resized = (dimx != dimx_) || (dimy != dimy_);
std::cout << reset_cursor_position << ResetPosition(/*clear=*/resized);
// Resize the screen if needed.
if (dimx != dimx_ || dimy != dimy_) {
if (resized) {
dimx_ = dimx;
dimy_ = dimy;
pixels_ = std::vector<std::vector<Pixel>>(dimy, std::vector<Pixel>(dimx));
@@ -451,6 +449,11 @@ void ScreenInteractive::Draw(Component component) {
cursor_.y = dimy_ - 1;
}
static int i = -2;
if (i % 10 == 0)
std::cout << DeviceStatusReport(DSRMode::kCursor);
++i;
Render(*this, document);
// Set cursor position for user using tools to insert CJK characters.