From 64135ae365b55d207bc071738f0a90b71becb435 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 21 Jul 2019 17:48:06 +0200 Subject: csi: implement CSI 22t and CSI 23t 22;0|1|2t pushes the current window title/icon to the stack, while 23 pops it. The second parameter, 0|1|2 has the following meaning: 0 - push/pop icon+title 1 - push/pop icon 2 - push/pop title --- csi.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'csi.c') diff --git a/csi.c b/csi.c index 3fcda546..067ecf4a 100644 --- a/csi.c +++ b/csi.c @@ -546,11 +546,39 @@ csi_dispatch(struct terminal *term, uint8_t final) break; } - case 't': - /* 22 - save window title */ - /* 23 - restore window title */ - LOG_WARN("ignoring %s", csi_as_string(term, final)); + case 't': { + unsigned param = vt_param_get(term, 0, 0); + + switch (param) { + case 22: { /* push window title */ + /* 0 - icon + title, 1 - icon, 2 - title */ + unsigned what = vt_param_get(term, 1, 0); + if (what == 0 || what == 2) { + tll_push_back( + term->window_title_stack, strdup(term->window_title)); + } + break; + } + + case 23: { /* pop window title */ + /* 0 - icon + title, 1 - icon, 2 - title */ + unsigned what = vt_param_get(term, 1, 0); + if (what == 0 || what == 2) { + if (tll_length(term->window_title_stack) > 0) { + char *title = tll_pop_back(term->window_title_stack); + term_set_window_title(term, title); + free(title); + } + } + break; + } + + default: + LOG_WARN("ignoring %s", csi_as_string(term, final)); + break; + } break; + } case 'n': { if (term->vt.params.idx > 0) { -- cgit v1.3