aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-23 13:03:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-06-23 13:03:22 +0000
commitde7dcf1a5c89bc296e5b96931cd0523b3b28c411 (patch)
treebed4cf46b7e06f47b2505380f231fc2986f1a386
parentvt: initial implementation of alt screen + 256 colors (diff)
csi: save and restore cursor when switching to and from alt screen
-rw-r--r--csi.c8
-rw-r--r--terminal.h4
2 files changed, 10 insertions, 2 deletions
diff --git a/csi.c b/csi.c
index 87886e66..b82b5c3b 100644
--- a/csi.c
+++ b/csi.c
@@ -423,7 +423,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
if (term->grid.cells != term->grid.alt_grid) {
term->grid.cells = term->grid.alt_grid;
- /* TODO: save cursor position */
+ term->grid.alt_saved_cursor.row = term->grid.cursor.row;
+ term->grid.alt_saved_cursor.col = term->grid.cursor.col;
tll_free(term->grid.damage);
grid_erase(&term->grid, 0, term->grid.cols * term->grid.rows);
@@ -455,7 +456,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
if (term->grid.cells == term->grid.alt_grid) {
term->grid.cells = term->grid.normal_grid;
- /* TODO: restore cursor position */
+ term->grid.cursor.row = term->grid.alt_saved_cursor.row;
+ term->grid.cursor.col = term->grid.alt_saved_cursor.col;
+ term->grid.linear_cursor = grid_cursor_linear(
+ &term->grid, term->grid.cursor.row, term->grid.cursor.col);
tll_free(term->grid.damage);
grid_damage_update(
diff --git a/terminal.h b/terminal.h
index ac5a50e4..28bfca17 100644
--- a/terminal.h
+++ b/terminal.h
@@ -63,6 +63,10 @@ struct grid {
struct cell *cells;
struct cell *normal_grid;
struct cell *alt_grid;
+ struct {
+ int row;
+ int col;
+ } alt_saved_cursor;
uint32_t foreground;
uint32_t background;