diff --git a/csi.c b/csi.c index 3337e7fd..497b82f4 100644 --- a/csi.c +++ b/csi.c @@ -329,6 +329,8 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) int UNUSED final = enable ? 'h' : 'l'; #endif + /* Note: update XTSAVE/XTRESTORE if adding/removing things here */ + switch (param) { case 1: /* DECCKM */ @@ -524,6 +526,35 @@ decrst(struct terminal *term, unsigned param) decset_decrst(term, param, false); } +static void +xtsave(struct terminal *term, unsigned param) +{ + switch (param) { + case 1: term->xtsave.cursor_keys_mode = term->cursor_keys_mode; break; + case 3: break; + case 4: break; + case 5: term->xtsave.reverse = term->reverse; break; + case 6: term->xtsave.origin = term->origin; break; + case 7: term->xtsave.auto_margin = term->auto_margin; break; + case 9: if (term->mouse_tracking == MOUSE_X10) term->xtsave.mouse_tracking = MOUSE_X10; break; + case 12: break; + case 25: term->xtsave.hide_cursor = term->hide_cursor; break; + case 1000: if (term->mouse_tracking == MOUSE_CLICK) term->xtsave.mouse_tracking = MOUSE_CLICK; break; + case 1001: break; + case 1002: if (term->mouse_tracking == MOUSE_DRAG) term->xtsave.mouse_tracking = MOUSE_DRAG; break; + case 1003: if (term->mouse_tracking == MOUSE_MOTION) term->xtsave.mouse_tracking = MOUSE_MOTION; break; + case 1004: term->xtsave.focus_events = term->focus_events; break; + case 1005: /* if (term->mouse_reporting == MOUSE_UTF8) term->xtsave.mouse_reporting = MOUSE_UTF8; break; */ + case 1006: if (term->mouse_reporting == MOUSE_SGR) term->xtsave.mouse_reporting = MOUSE_SGR; break; + case 1007: term->xtsave.alt_scrolling = term->alt_scrolling; break; + case 1015: if (term->mouse_reporting == MOUSE_URXVT) term->xtsave.mouse_reporting = MOUSE_URXVT; break; + case 1034: term->xtsave.meta.eight_bit = term->meta.eight_bit; break; + case 1036: term->xtsave.meta.esc_prefix = term->meta.esc_prefix; break; + case 1049: term->xtsave.alt_screen = term->grid == &term->alt; break; + case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break; + } +} + void csi_dispatch(struct terminal *term, uint8_t final) { diff --git a/terminal.h b/terminal.h index 983c80a0..22cea4bf 100644 --- a/terminal.h +++ b/terminal.h @@ -228,6 +228,7 @@ struct terminal { tll(struct ptmx_buffer) ptmx_buffer; + enum cursor_origin origin; enum cursor_keys cursor_keys_mode; enum keypad_keys keypad_keys_mode; bool reverse; @@ -240,6 +241,32 @@ struct terminal { enum mouse_tracking mouse_tracking; enum mouse_reporting mouse_reporting; + struct { + bool esc_prefix; + bool eight_bit; + } meta; + + /* Saved DECSET modes */ + struct { + enum cursor_origin origin; + enum cursor_keys cursor_keys_mode; + //enum keypad_keys keypad_keys_mode; + bool reverse; + bool hide_cursor; + bool auto_margin; + bool insert_mode; + bool bracketed_paste; + bool focus_events; + bool alt_scrolling; + enum mouse_tracking mouse_tracking; + enum mouse_reporting mouse_reporting; + struct { + bool esc_prefix; + bool eight_bit; + } meta; + bool alt_screen; + } xtsave; + struct charsets charsets; struct charsets saved_charsets; /* For save/restore cursor + attributes */ @@ -288,7 +315,6 @@ struct terminal { uint32_t default_table[256]; } colors; - enum cursor_origin origin; enum cursor_style default_cursor_style; enum cursor_style cursor_style; struct { @@ -328,11 +354,6 @@ struct terminal { size_t match_len; } search; - struct { - bool esc_prefix; - bool eight_bit; - } meta; - tll(int) tab_stops; struct wayland *wl;