Merge branch 'obsd-master'

pull/1050/merge
Thomas Adam 2017-08-29 12:01:25 +01:00
commit 0f7160eb2f
3 changed files with 36 additions and 10 deletions

25
input.c
View File

@ -87,6 +87,7 @@ struct input_ctx {
struct utf8_data utf8data;
int ch;
int last;
int flags;
#define INPUT_DISCARD 0x1
@ -221,6 +222,7 @@ enum input_csi_type {
INPUT_CSI_ICH,
INPUT_CSI_IL,
INPUT_CSI_RCP,
INPUT_CSI_REP,
INPUT_CSI_RM,
INPUT_CSI_RM_PRIVATE,
INPUT_CSI_SCP,
@ -252,6 +254,7 @@ static const struct input_table_entry input_csi_table[] = {
{ 'S', "", INPUT_CSI_SU },
{ 'X', "", INPUT_CSI_ECH },
{ 'Z', "", INPUT_CSI_CBT },
{ 'b', "", INPUT_CSI_REP },
{ 'c', "", INPUT_CSI_DA },
{ 'c', ">", INPUT_CSI_DA_TWO },
{ 'd', "", INPUT_CSI_VPA },
@ -848,6 +851,8 @@ input_reset(struct window_pane *wp, int clear)
input_clear(ictx);
ictx->last = -1;
ictx->state = &input_state_ground;
ictx->flags = 0;
}
@ -1062,6 +1067,7 @@ input_print(struct input_ctx *ictx)
utf8_set(&ictx->cell.cell.data, ictx->ch);
screen_write_collect_add(&ictx->ctx, &ictx->cell.cell);
ictx->last = ictx->ch;
ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
@ -1168,6 +1174,7 @@ input_c0_dispatch(struct input_ctx *ictx)
break;
}
ictx->last = -1;
return (0);
}
@ -1245,6 +1252,7 @@ input_esc_dispatch(struct input_ctx *ictx)
break;
}
ictx->last = -1;
return (0);
}
@ -1255,7 +1263,7 @@ input_csi_dispatch(struct input_ctx *ictx)
struct screen_write_ctx *sctx = &ictx->ctx;
struct screen *s = sctx->s;
struct input_table_entry *entry;
int n, m;
int i, n, m;
u_int cx;
if (ictx->flags & INPUT_DISCARD)
@ -1421,6 +1429,15 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_insertline(sctx, input_get(ictx, 0, 1, 1),
ictx->cell.cell.bg);
break;
case INPUT_CSI_REP:
if (ictx->last == -1)
break;
ictx->ch = ictx->last;
n = input_get(ictx, 0, 1, 1);
for (i = 0; i < n; i++)
input_print(ictx);
break;
case INPUT_CSI_RCP:
memcpy(&ictx->cell, &ictx->old_cell, sizeof ictx->cell);
screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy);
@ -1473,6 +1490,7 @@ input_csi_dispatch(struct input_ctx *ictx)
break;
}
ictx->last = -1;
return (0);
}
@ -1877,6 +1895,7 @@ input_enter_dcs(struct input_ctx *ictx)
input_clear(ictx);
input_start_timer(ictx);
ictx->last = -1;
}
/* DCS terminator (ST) received. */
@ -1909,6 +1928,7 @@ input_enter_osc(struct input_ctx *ictx)
input_clear(ictx);
input_start_timer(ictx);
ictx->last = -1;
}
/* OSC terminator (ST) received. */
@ -1976,6 +1996,7 @@ input_enter_apc(struct input_ctx *ictx)
input_clear(ictx);
input_start_timer(ictx);
ictx->last = -1;
}
/* APC terminator (ST) received. */
@ -2000,6 +2021,7 @@ input_enter_rename(struct input_ctx *ictx)
input_clear(ictx);
input_start_timer(ictx);
ictx->last = -1;
}
/* Rename terminator (ST) received. */
@ -2029,6 +2051,7 @@ input_utf8_open(struct input_ctx *ictx)
fatalx("UTF-8 open invalid %#x", ictx->ch);
log_debug("%s %hhu", __func__, ud->size);
ictx->last = -1;
return (0);
}

View File

@ -162,7 +162,7 @@ server_lock_client(struct client *c)
return;
cmd = options_get_string(c->session->options, "lock-command");
if (strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
if (*cmd == '\0' || strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
return;
tty_stop_tty(&c->tty);

View File

@ -595,7 +595,17 @@ tty_keys_next(struct tty *tty)
}
first_key:
/* Handle keys starting with escape. */
/* Try to lookup complete key. */
n = tty_keys_next1(tty, buf, len, &key, &size, expired);
if (n == 0) /* found */
goto complete_key;
if (n == 1)
goto partial_key;
/*
* If not a complete key, look for key with an escape prefix (meta
* modifier).
*/
if (*buf == '\033') {
/* Look for a key without the escape. */
n = tty_keys_next1(tty, buf + 1, len - 1, &key, &size, expired);
@ -620,13 +630,6 @@ first_key:
goto partial_key;
}
/* Try to lookup key. */
n = tty_keys_next1(tty, buf, len, &key, &size, expired);
if (n == 0) /* found */
goto complete_key;
if (n == 1)
goto partial_key;
/*
* At this point, we know the key is not partial (with or without
* escape). So pass it through even if the timer has not expired.