Accept multiple parameters to SM/RM/DECSET/DECRST, based on a diff from

Hayaki Saito.
This commit is contained in:
nicm 2013-10-10 11:57:14 +00:00
parent fd1750af49
commit 81a548bcc4

151
input.c
View File

@ -70,6 +70,10 @@ int input_input(struct input_ctx *);
int input_c0_dispatch(struct input_ctx *); int input_c0_dispatch(struct input_ctx *);
int input_esc_dispatch(struct input_ctx *); int input_esc_dispatch(struct input_ctx *);
int input_csi_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 *); void input_csi_dispatch_sgr(struct input_ctx *);
int input_dcs_dispatch(struct input_ctx *); int input_dcs_dispatch(struct input_ctx *);
int input_utf8_open(struct input_ctx *); int input_utf8_open(struct input_ctx *);
@ -1071,7 +1075,6 @@ int
input_csi_dispatch(struct input_ctx *ictx) input_csi_dispatch(struct input_ctx *ictx)
{ {
struct screen_write_ctx *sctx = &ictx->ctx; struct screen_write_ctx *sctx = &ictx->ctx;
struct window_pane *wp = ictx->wp;
struct screen *s = sctx->s; struct screen *s = sctx->s;
struct input_table_entry *entry; struct input_table_entry *entry;
int n, m; int n, m;
@ -1230,7 +1233,60 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy); screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy);
break; break;
case INPUT_CSI_RM: 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 */ case 4: /* IRM */
screen_write_mode_clear(&ictx->ctx, MODE_INSERT); screen_write_mode_clear(&ictx->ctx, MODE_INSERT);
break; break;
@ -1238,10 +1294,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; 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); screen_write_mode_clear(&ictx->ctx, MODE_KCURSOR);
break; break;
case 3: /* DECCOLM */ case 3: /* DECCOLM */
@ -1271,10 +1335,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break; break;
case 47: case 47:
case 1047: case 1047:
window_pane_alternate_off(wp, &ictx->cell, 0); window_pane_alternate_off(ictx->wp, &ictx->cell, 0);
break; break;
case 1049: case 1049:
window_pane_alternate_off(wp, &ictx->cell, 1); window_pane_alternate_off(ictx->wp, &ictx->cell, 1);
break; break;
case 2004: case 2004:
screen_write_mode_clear(&ictx->ctx, MODE_BRACKETPASTE); 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); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; break;
} }
break; }
case INPUT_CSI_SCP: }
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
ictx->old_cx = s->cx; /* Handle CSI SM. */
ictx->old_cy = s->cy; void
break; input_csi_dispatch_sm(struct input_ctx *ictx)
case INPUT_CSI_SGR: {
input_csi_dispatch_sgr(ictx); u_int i;
break;
case INPUT_CSI_SM: for (i = 0; i < ictx->param_list_len; i++) {
switch (input_get(ictx, 0, 0, -1)) { switch (input_get(ictx, i, 0, -1)) {
case 4: /* IRM */ case 4: /* IRM */
screen_write_mode_set(&ictx->ctx, MODE_INSERT); screen_write_mode_set(&ictx->ctx, MODE_INSERT);
break; break;
@ -1301,10 +1365,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; 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); screen_write_mode_set(&ictx->ctx, MODE_KCURSOR);
break; break;
case 3: /* DECCOLM */ case 3: /* DECCOLM */
@ -1330,10 +1402,10 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY); screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY);
break; break;
case 1004: case 1004:
if (s->mode & MODE_FOCUSON) if (ictx->ctx.s->mode & MODE_FOCUSON)
break; break;
screen_write_mode_set(&ictx->ctx, MODE_FOCUSON); screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);
wp->flags |= PANE_FOCUSPUSH; /* force update */ ictx->wp->flags |= PANE_FOCUSPUSH; /* force update */
break; break;
case 1005: case 1005:
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8); screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);
@ -1343,10 +1415,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break; break;
case 47: case 47:
case 1047: case 1047:
window_pane_alternate_on(wp, &ictx->cell, 0); window_pane_alternate_on(ictx->wp, &ictx->cell, 0);
break; break;
case 1049: case 1049:
window_pane_alternate_on(wp, &ictx->cell, 1); window_pane_alternate_on(ictx->wp, &ictx->cell, 1);
break; break;
case 2004: case 2004:
screen_write_mode_set(&ictx->ctx, MODE_BRACKETPASTE); 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); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; 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. */ /* Handle CSI SGR. */