aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-23 15:57:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-23 15:57:07 +0000
commitf5a6304850fd7344f72355416cfbfd69b76482c4 (patch)
tree358ae1680be93f61d57b4aa4f8283acbba23e36b
parentgrid: swap rows doesn't mark rows as dirty (diff)
term: make sure to update 'current row' when restoring saved cursor
-rw-r--r--csi.c11
-rw-r--r--terminal.c8
-rw-r--r--terminal.h2
-rw-r--r--vt.c2
4 files changed, 20 insertions, 3 deletions
diff --git a/csi.c b/csi.c
index 4a4d321a..cfe66b93 100644
--- a/csi.c
+++ b/csi.c
@@ -576,6 +576,14 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
}
+ case 's':
+ term->saved_cursor = term->cursor;
+ break;
+
+ case 'u':
+ term_restore_cursor(term);
+ break;
+
case 't': {
unsigned param = vt_param_get(term, 0, 0);
@@ -794,8 +802,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
if (term->grid == &term->alt) {
term->grid = &term->normal;
- term->cursor = term->saved_cursor;
- term_cursor_to(term, term->cursor.row, term->cursor.col);
+ term_restore_cursor(term);
tll_free(term->alt.damage);
tll_free(term->alt.scroll_damage);
diff --git a/terminal.c b/terminal.c
index 84bfcc31..871e6dcb 100644
--- a/terminal.c
+++ b/terminal.c
@@ -268,6 +268,14 @@ term_reverse_index(struct terminal *term)
}
void
+term_restore_cursor(struct terminal *term)
+{
+ int row = min(term->saved_cursor.row, term->rows - 1);
+ int col = min(term->saved_cursor.col, term->cols - 1);
+ term_cursor_to(term, row, col);
+}
+
+void
term_focus_in(struct terminal *term)
{
if (!term->focus_events)
diff --git a/terminal.h b/terminal.h
index 71d66566..94e99215 100644
--- a/terminal.h
+++ b/terminal.h
@@ -346,6 +346,8 @@ void term_scroll_reverse_partial(
void term_linefeed(struct terminal *term);
void term_reverse_index(struct terminal *term);
+void term_restore_cursor(struct terminal *term);
+
void term_focus_in(struct terminal *term);
void term_focus_out(struct terminal *term);
void term_mouse_down(struct terminal *term, int button, int row, int col,
diff --git a/vt.c b/vt.c
index 1c71e4bc..7ee59acb 100644
--- a/vt.c
+++ b/vt.c
@@ -597,7 +597,7 @@ esc_dispatch(struct terminal *term, uint8_t final)
break;
case '8':
- term->cursor = term->saved_cursor;
+ term_restore_cursor(term);
term->vt.attrs = term->vt.saved_attrs;
break;