summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authornicm <nicm>2013-10-10 11:57:14 +0000
committernicm <nicm>2013-10-10 11:57:14 +0000
commit81a548bcc4bf4e85935ce8ee65217b41d094d990 (patch)
tree0559a736303730cc3c7a8b51f3123d53a74f53b6 /input.c
parentfd1750af490f837405eb688ed82b3f8b18d29e26 (diff)
Accept multiple parameters to SM/RM/DECSET/DECRST, based on a diff from
Hayaki Saito.
Diffstat (limited to 'input.c')
-rw-r--r--input.c151
1 files changed, 99 insertions, 52 deletions
diff --git a/input.c b/input.c
index 5f70f872..e27250ed 100644
--- a/input.c
+++ b/input.c
@@ -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. */