summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-05-20 19:03:58 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-05-20 19:03:58 +0000
commit944b5e6fa04e014501f465e3898315c84d10bd9e (patch)
tree84bf7b9489fc4105d7c5a4c59df7058c867a19fe /input.c
parent96e7f33da3078facc504c6c66d42956bc44b2e54 (diff)
Support xterm(1) cursor colour change sequences through terminfo(5) Cc
(set) and Cr (reset) extensions. Originally by Sean Estabrooks, tweaked by me and Ailin Nemui.
Diffstat (limited to 'input.c')
-rw-r--r--input.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/input.c b/input.c
index 3da950d5..86d34b74 100644
--- a/input.c
+++ b/input.c
@@ -1445,17 +1445,39 @@ input_enter_osc(struct input_ctx *ictx)
void
input_exit_osc(struct input_ctx *ictx)
{
- if (ictx->flags & INPUT_DISCARD)
- return;
- log_debug("%s: \"%s\"", __func__, ictx->input_buf);
+ u_char *p = ictx->input_buf;
+ int option;
- if (ictx->input_len < 2 || ictx->input_buf[1] != ';')
+ if (ictx->flags & INPUT_DISCARD)
return;
- if (ictx->input_buf[0] != '0' && ictx->input_buf[0] != '2')
+ if (ictx->input_len < 1 || *p < '0' || *p > '9')
return;
- screen_set_title(ictx->ctx.s, ictx->input_buf + 2);
- server_status_window(ictx->wp->window);
+ log_debug("%s: \"%s\"", __func__, p);
+
+ option = 0;
+ while (*p >= '0' && *p <= '9')
+ option = option * 10 + *p++ - '0';
+ if (*p == ';')
+ p++;
+
+ switch (option) {
+ case 0:
+ case 2:
+ screen_set_title(ictx->ctx.s, p);
+ server_status_window(ictx->wp->window);
+ break;
+ case 12:
+ screen_set_cursor_colour(ictx->ctx.s, p);
+ break;
+ case 112:
+ if (*p == '\0') /* No arguments allowed. */
+ screen_set_cursor_colour(ictx->ctx.s, "");
+ break;
+ default:
+ log_debug("%s: unknown '%u'", __func__, option);
+ break;
+ }
}
/* APC string started. */