diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-01-15 16:08:30 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-01-15 16:08:30 +0000 |
| commit | bae3c871bb6f05271adba8885b394b86ba0798a8 (patch) | |
| tree | b2b9b4dbdcc5f86438e5c9366d94f9a30f98520f | |
| parent | Merge branch 'xsnprintf' (diff) | |
term/vt/csi: break out cursor save/restore to dedicated functions
| -rw-r--r-- | csi.c | 6 | ||||
| -rw-r--r-- | terminal.c | 12 | ||||
| -rw-r--r-- | terminal.h | 1 | ||||
| -rw-r--r-- | vt.c | 6 |
4 files changed, 15 insertions, 10 deletions
@@ -1141,15 +1141,11 @@ csi_dispatch(struct terminal *term, uint8_t final) } case 's': - term->grid->saved_cursor = term->grid->cursor; - term->vt.saved_attrs = term->vt.attrs; - term->saved_charsets = term->charsets; + term_save_cursor(term); break; case 'u': term_restore_cursor(term, &term->grid->saved_cursor); - term->vt.attrs = term->vt.saved_attrs; - term->charsets = term->saved_charsets; break; case 't': { @@ -2255,12 +2255,24 @@ term_reset_view(struct terminal *term) } void +term_save_cursor(struct terminal *term) +{ + term->grid->saved_cursor = term->grid->cursor; + term->vt.saved_attrs = term->vt.attrs; + term->saved_charsets = term->charsets; +} + +void term_restore_cursor(struct terminal *term, const struct cursor *cursor) { int row = min(cursor->point.row, term->rows - 1); int col = min(cursor->point.col, term->cols - 1); + term_cursor_to(term, row, col); term->grid->cursor.lcf = cursor->lcf; + + term->vt.attrs = term->vt.saved_attrs; + term->charsets = term->saved_charsets; } void @@ -595,6 +595,7 @@ void term_reverse_index(struct terminal *term); void term_arm_blink_timer(struct terminal *term); +void term_save_cursor(struct terminal *term); void term_restore_cursor(struct terminal *term, const struct cursor *cursor); void term_visual_focus_in(struct terminal *term); @@ -366,15 +366,11 @@ action_esc_dispatch(struct terminal *term, uint8_t final) case 0: switch (final) { case '7': - term->grid->saved_cursor = term->grid->cursor; - term->vt.saved_attrs = term->vt.attrs; - term->saved_charsets = term->charsets; + term_save_cursor(term); break; case '8': term_restore_cursor(term, &term->grid->saved_cursor); - term->vt.attrs = term->vt.saved_attrs; - term->charsets = term->saved_charsets; break; case 'c': |
