Problem with setting the cursor position on the right screen edge when drawing. (#831)

When moving the cursor back to its original location, a problem arises when cursor placed in the right edge column, where an off by one error occur. This pull request will resolve this problem.

Co-authored-by: Jørn Gustav Larsen <jgl@fasttracksoftware.com>
Co-authored-by: Jørn Gustav Larsen <jgl@adminbyrequest.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Jørn Gustav Larsen 2024-04-03 21:32:19 +02:00 committed by GitHub
parent f609c12846
commit 2216f3a5da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -23,6 +23,7 @@ current (development)
- Bugfix: `Input` `onchange` was not called on backspace or delete key. - Bugfix: `Input` `onchange` was not called on backspace or delete key.
Fixed by @chrysante in chrysante in PR #776. Fixed by @chrysante in chrysante in PR #776.
- Bugfix: Propertly restore cursor shape on exit. See #792. - Bugfix: Propertly restore cursor shape on exit. See #792.
- Bugfix: Fix cursor position in when in the last column. See #831.
### Dom ### Dom
- Feature: Add `hscroll_indicator`. It display an horizontal indicator - Feature: Add `hscroll_indicator`. It display an horizontal indicator

View File

@ -844,10 +844,18 @@ void ScreenInteractive::Draw(Component component) {
const int dx = dimx_ - 1 - cursor_.x + int(dimx_ != terminal.dimx); const int dx = dimx_ - 1 - cursor_.x + int(dimx_ != terminal.dimx);
const int dy = dimy_ - 1 - cursor_.y; const int dy = dimy_ - 1 - cursor_.y;
set_cursor_position = "\x1B[" + std::to_string(dy) + "A" + // set_cursor_position.clear();
"\x1B[" + std::to_string(dx) + "D"; reset_cursor_position.clear();
reset_cursor_position = "\x1B[" + std::to_string(dy) + "B" + //
"\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 (dx != 0) {
set_cursor_position += "\x1B[" + std::to_string(dx) + "D";
reset_cursor_position += "\x1B[" + std::to_string(dx) + "C";
}
if (cursor_.shape == Cursor::Hidden) { if (cursor_.shape == Cursor::Hidden) {
set_cursor_position += "\033[?25l"; set_cursor_position += "\033[?25l";