mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Support paste key in copy mode input (for search etc). Also clamp length
to screen width.
This commit is contained in:
parent
d23561f381
commit
7d3d996383
@ -750,8 +750,10 @@ window_copy_key_input(struct window_pane *wp, int key)
|
|||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
size_t inputlen;
|
size_t inputlen, n;
|
||||||
int np;
|
int np;
|
||||||
|
struct paste_buffer *pb;
|
||||||
|
u_char ch;
|
||||||
|
|
||||||
switch (mode_key_lookup(&data->mdata, key, NULL)) {
|
switch (mode_key_lookup(&data->mdata, key, NULL)) {
|
||||||
case MODEKEYEDIT_CANCEL:
|
case MODEKEYEDIT_CANCEL:
|
||||||
@ -765,6 +767,20 @@ window_copy_key_input(struct window_pane *wp, int key)
|
|||||||
case MODEKEYEDIT_DELETELINE:
|
case MODEKEYEDIT_DELETELINE:
|
||||||
*data->inputstr = '\0';
|
*data->inputstr = '\0';
|
||||||
break;
|
break;
|
||||||
|
case MODEKEYEDIT_PASTE:
|
||||||
|
if ((pb = paste_get_top(&global_buffers)) == NULL)
|
||||||
|
break;
|
||||||
|
for (n = 0; n < pb->size; n++) {
|
||||||
|
ch = (u_char) pb->data[n];
|
||||||
|
if (ch < 32 || ch == 127)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
inputlen = strlen(data->inputstr);
|
||||||
|
|
||||||
|
data->inputstr = xrealloc(data->inputstr, 1, inputlen + n + 1);
|
||||||
|
memcpy(data->inputstr + inputlen, pb->data, n);
|
||||||
|
data->inputstr[inputlen + n] = '\0';
|
||||||
|
break;
|
||||||
case MODEKEYEDIT_ENTER:
|
case MODEKEYEDIT_ENTER:
|
||||||
np = data->numprefix;
|
np = data->numprefix;
|
||||||
if (np <= 0)
|
if (np <= 0)
|
||||||
@ -1154,8 +1170,8 @@ window_copy_write_line(
|
|||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
struct options *oo = &wp->window->options;
|
struct options *oo = &wp->window->options;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
char hdr[32];
|
char hdr[512];
|
||||||
size_t last, xoff = 0, size = 0;
|
size_t last, xoff = 0, size = 0, limit;
|
||||||
|
|
||||||
window_mode_attrs(&gc, oo);
|
window_mode_attrs(&gc, oo);
|
||||||
|
|
||||||
@ -1168,11 +1184,14 @@ window_copy_write_line(
|
|||||||
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
|
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
|
||||||
screen_write_puts(ctx, &gc, "%s", hdr);
|
screen_write_puts(ctx, &gc, "%s", hdr);
|
||||||
} else if (py == last && data->inputtype != WINDOW_COPY_OFF) {
|
} else if (py == last && data->inputtype != WINDOW_COPY_OFF) {
|
||||||
|
limit = sizeof hdr;
|
||||||
|
if (limit > screen_size_x(s))
|
||||||
|
limit = screen_size_x(s);
|
||||||
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
|
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
|
||||||
xoff = size = xsnprintf(hdr, sizeof hdr,
|
xoff = size = xsnprintf(hdr, limit,
|
||||||
"Repeat: %u", data->numprefix);
|
"Repeat: %u", data->numprefix);
|
||||||
} else {
|
} else {
|
||||||
xoff = size = xsnprintf(hdr, sizeof hdr,
|
xoff = size = xsnprintf(hdr, limit,
|
||||||
"%s: %s", data->inputprompt, data->inputstr);
|
"%s: %s", data->inputprompt, data->inputstr);
|
||||||
}
|
}
|
||||||
screen_write_cursormove(ctx, 0, last);
|
screen_write_cursormove(ctx, 0, last);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user