diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-03-22 10:14:56 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-03-22 10:14:56 +0000 |
| commit | 48091966cb49d634b02562b137343c47d0710ad8 (patch) | |
| tree | f53fb3295e2b5df70eccafad83a400e236fbb389 | |
| parent | server: purge *all* buffers when a terminal shuts down (diff) | |
render: resize: update saved 'normal' cursor if we're in alt screen
When resizing in alt mode, we never updated the saved 'normal'
cursor. This meant that when we exited alt mode, the cursor would be
positioned where it was in the old pre-resize/reflow grid.
Now, we update the saved cursor in the same way we update visible
cursor. The result is that when we exit the alt screen, the cursor
is restored to the same coordinates it would have been updated to had
the resize been done in the 'normal' screen.
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | render.c | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0700e018..3a310289 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ * Sixel images moved or deleted on window resize. * Cursor sometimes incorrectly restored on exit from alternate screen. * 'Underline' cursor being invisible on underlined text. +* Restored cursor position in 'normal' screen when window was resized + while in 'alt' screen. ### Security @@ -1645,6 +1645,19 @@ maybe_resize(struct terminal *term, int width, int height, bool force) cursor_row, min(term->cursor.point.col, term->cols - 1)); + /* If in alt screen, update the saved 'normal' cursor too */ + if (term->grid == &term->alt) { + int cursor_row = last_normal_row - term->normal.offset; + + while (cursor_row < 0) + cursor_row += term->grid->num_rows; + + term->alt_saved_cursor.lcf = false; + term->alt_saved_cursor.point.row = cursor_row; + term->alt_saved_cursor.point.col = min( + term->alt_saved_cursor.point.col, term->cols - 1); + } + term->render.last_cursor.cell = NULL; damage_view: |
