summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-10-10 11:57:15 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-10-10 11:57:15 +0000
commit0a8cea6e9a66cb0b22a8497bf6c35844e478f83d (patch)
treee0b2b3be6639eeb886ef72fdef3bfc71aeda02be
parent66f367304416c4afdc8c01210d57c1eef7f4c636 (diff)
Accept multiple parameters to SM/RM/DECSET/DECRST, based on a diff from
Hayaki Saito.
-rw-r--r--usr.bin/tmux/input.c153
1 files changed, 100 insertions, 53 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 5b5abe8e3c3..a7e7be4fc3e 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.63 2013/06/23 12:51:28 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.64 2013/10/10 11:57:14 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -70,6 +70,10 @@ int input_input(struct input_ctx *);
int input_c0_dispatch(struct input_ctx *);
int input_esc_dispatch(struct input_ctx *);
int input_csi_dispatch(struct input_ctx *);
+void input_csi_dispatch_rm(struct input_ctx *);
+void input_csi_dispatch_rm_private(struct input_ctx *);
+void input_csi_dispatch_sm(struct input_ctx *);
+void input_csi_dispatch_sm_private(struct input_ctx *);
void input_csi_dispatch_sgr(struct input_ctx *);
int input_dcs_dispatch(struct input_ctx *);
int input_utf8_open(struct input_ctx *);
@@ -1071,7 +1075,6 @@ int
input_csi_dispatch(struct input_ctx *ictx)
{
struct screen_write_ctx *sctx = &ictx->ctx;
- struct window_pane *wp = ictx->wp;
struct screen *s = sctx->s;
struct input_table_entry *entry;
int n, m;
@@ -1230,7 +1233,60 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy);
break;
case INPUT_CSI_RM:
- switch (input_get(ictx, 0, 0, -1)) {
+ input_csi_dispatch_rm(ictx);
+ break;
+ case INPUT_CSI_RM_PRIVATE:
+ input_csi_dispatch_rm_private(ictx);
+ break;
+ case INPUT_CSI_SCP:
+ memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
+ ictx->old_cx = s->cx;
+ ictx->old_cy = s->cy;
+ break;
+ case INPUT_CSI_SGR:
+ input_csi_dispatch_sgr(ictx);
+ break;
+ case INPUT_CSI_SM:
+ input_csi_dispatch_sm(ictx);
+ break;
+ case INPUT_CSI_SM_PRIVATE:
+ input_csi_dispatch_sm_private(ictx);
+ break;
+ case INPUT_CSI_TBC:
+ switch (input_get(ictx, 0, 0, 0)) {
+ case 0:
+ if (s->cx < screen_size_x(s))
+ bit_clear(s->tabs, s->cx);
+ break;
+ case 3:
+ bit_nclear(s->tabs, 0, screen_size_x(s) - 1);
+ break;
+ default:
+ log_debug("%s: unknown '%c'", __func__, ictx->ch);
+ break;
+ }
+ break;
+ case INPUT_CSI_VPA:
+ n = input_get(ictx, 0, 1, 1);
+ screen_write_cursormove(sctx, s->cx, n - 1);
+ break;
+ case INPUT_CSI_DECSCUSR:
+ n = input_get(ictx, 0, 0, 0);
+ screen_set_cursor_style(s, n);
+ break;
+ }
+
+ return (0);
+}
+
+/* Handle CSI RM. */
+void
+input_csi_dispatch_rm(struct input_ctx *ictx)
+{
+ u_int i;
+
+ for (i = 0; i < ictx->param_list_len; i++) {
+ switch (input_get(ictx, i, 0, -1)) {
case 4: /* IRM */
screen_write_mode_clear(&ictx->ctx, MODE_INSERT);
break;
@@ -1238,10 +1294,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
- break;
- case INPUT_CSI_RM_PRIVATE:
- switch (input_get(ictx, 0, 0, -1)) {
- case 1: /* GATM */
+ }
+}
+
+/* Handle CSI private RM. */
+void
+input_csi_dispatch_rm_private(struct input_ctx *ictx)
+{
+ u_int i;
+
+ for (i = 0; i < ictx->param_list_len; i++) {
+ switch (input_get(ictx, i, 0, -1)) {
+ case 1: /* DECCKM */
screen_write_mode_clear(&ictx->ctx, MODE_KCURSOR);
break;
case 3: /* DECCOLM */
@@ -1271,10 +1335,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break;
case 47:
case 1047:
- window_pane_alternate_off(wp, &ictx->cell, 0);
+ window_pane_alternate_off(ictx->wp, &ictx->cell, 0);
break;
case 1049:
- window_pane_alternate_off(wp, &ictx->cell, 1);
+ window_pane_alternate_off(ictx->wp, &ictx->cell, 1);
break;
case 2004:
screen_write_mode_clear(&ictx->ctx, MODE_BRACKETPASTE);
@@ -1283,17 +1347,17 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
- break;
- case INPUT_CSI_SCP:
- memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
- ictx->old_cx = s->cx;
- ictx->old_cy = s->cy;
- break;
- case INPUT_CSI_SGR:
- input_csi_dispatch_sgr(ictx);
- break;
- case INPUT_CSI_SM:
- switch (input_get(ictx, 0, 0, -1)) {
+ }
+}
+
+/* Handle CSI SM. */
+void
+input_csi_dispatch_sm(struct input_ctx *ictx)
+{
+ u_int i;
+
+ for (i = 0; i < ictx->param_list_len; i++) {
+ switch (input_get(ictx, i, 0, -1)) {
case 4: /* IRM */
screen_write_mode_set(&ictx->ctx, MODE_INSERT);
break;
@@ -1301,10 +1365,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
- break;
- case INPUT_CSI_SM_PRIVATE:
- switch (input_get(ictx, 0, 0, -1)) {
- case 1: /* GATM */
+ }
+}
+
+/* Handle CSI private SM. */
+void
+input_csi_dispatch_sm_private(struct input_ctx *ictx)
+{
+ u_int i;
+
+ for (i = 0; i < ictx->param_list_len; i++) {
+ switch (input_get(ictx, i, 0, -1)) {
+ case 1: /* DECCKM */
screen_write_mode_set(&ictx->ctx, MODE_KCURSOR);
break;
case 3: /* DECCOLM */
@@ -1330,10 +1402,10 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY);
break;
case 1004:
- if (s->mode & MODE_FOCUSON)
+ if (ictx->ctx.s->mode & MODE_FOCUSON)
break;
screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);
- wp->flags |= PANE_FOCUSPUSH; /* force update */
+ ictx->wp->flags |= PANE_FOCUSPUSH; /* force update */
break;
case 1005:
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);
@@ -1343,10 +1415,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break;
case 47:
case 1047:
- window_pane_alternate_on(wp, &ictx->cell, 0);
+ window_pane_alternate_on(ictx->wp, &ictx->cell, 0);
break;
case 1049:
- window_pane_alternate_on(wp, &ictx->cell, 1);
+ window_pane_alternate_on(ictx->wp, &ictx->cell, 1);
break;
case 2004:
screen_write_mode_set(&ictx->ctx, MODE_BRACKETPASTE);
@@ -1355,32 +1427,7 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
- break;
- case INPUT_CSI_TBC:
- switch (input_get(ictx, 0, 0, 0)) {
- case 0:
- if (s->cx < screen_size_x(s))
- bit_clear(s->tabs, s->cx);
- break;
- case 3:
- bit_nclear(s->tabs, 0, screen_size_x(s) - 1);
- break;
- default:
- log_debug("%s: unknown '%c'", __func__, ictx->ch);
- break;
- }
- break;
- case INPUT_CSI_VPA:
- n = input_get(ictx, 0, 1, 1);
- screen_write_cursormove(sctx, s->cx, n - 1);
- break;
- case INPUT_CSI_DECSCUSR:
- n = input_get(ictx, 0, 0, 0);
- screen_set_cursor_style(s, n);
- break;
}
-
- return (0);
}
/* Handle CSI SGR. */