From 56d31ac22b5a9c5afb94ab474ec6b1421aa2cedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Gustav=20Larsen?= Date: Mon, 25 Mar 2024 13:05:17 +0100 Subject: [PATCH] Problem with setting the cursor position on the right screen edge when drawing has been fixed. --- src/ftxui/component/screen_interactive.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index c446f2ee..fa1cf2c8 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -844,10 +844,18 @@ void ScreenInteractive::Draw(Component component) { const int dx = dimx_ - 1 - cursor_.x + int(dimx_ != terminal.dimx); const int dy = dimy_ - 1 - cursor_.y; - set_cursor_position = "\x1B[" + std::to_string(dy) + "A" + // - "\x1B[" + std::to_string(dx) + "D"; - reset_cursor_position = "\x1B[" + std::to_string(dy) + "B" + // - "\x1B[" + std::to_string(dx) + "C"; + set_cursor_position.clear(); + reset_cursor_position.clear(); + + if (dx != 0) { + set_cursor_position += "\x1B[" + std::to_string(dx) + "D"; + reset_cursor_position += "\x1B[" + std::to_string(dx) + "C"; + } + + if (dy != 0) { + set_cursor_position += "\x1B[" + std::to_string(dy) + "A"; + reset_cursor_position += "\x1B[" + std::to_string(dy) + "B"; + } if (cursor_.shape == Cursor::Hidden) { set_cursor_position += "\033[?25l";