aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-21 15:48:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-21 15:48:06 +0000
commit64135ae365b55d207bc071738f0a90b71becb435 (patch)
tree5b5999179c4d1d9092126234f9e6b366b8dba8d9 /csi.c
parentterm: track current window title in terminal struct (diff)
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
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c36
1 files changed, 32 insertions, 4 deletions
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) {