Change pasting to bypass the output key processing entirely and write

what was originally received. Fixes problems with pasted text being
interpreted as extended keys reported by Mark Kelly.
This commit is contained in:
nicm
2024-10-01 06:15:47 +00:00
parent 89adec0ca5
commit 17bab32794
7 changed files with 106 additions and 40 deletions

View File

@ -1154,6 +1154,24 @@ window_pane_reset_mode_all(struct window_pane *wp)
window_pane_reset_mode(wp);
}
static void
window_pane_copy_paste(struct window_pane *wp, char *buf, size_t len)
{
struct window_pane *loop;
TAILQ_FOREACH(loop, &wp->window->panes, entry) {
if (loop != wp &&
TAILQ_EMPTY(&loop->modes) &&
loop->fd != -1 &&
(~loop->flags & PANE_INPUTOFF) &&
window_pane_visible(loop) &&
options_get_number(loop->options, "synchronize-panes")) {
log_debug("%s: %.*s", __func__, (int)len, buf);
bufferevent_write(loop->event, buf, len);
}
}
}
static void
window_pane_copy_key(struct window_pane *wp, key_code key)
{
@ -1170,6 +1188,22 @@ window_pane_copy_key(struct window_pane *wp, key_code key)
}
}
void
window_pane_paste(struct window_pane *wp, char *buf, size_t len)
{
if (!TAILQ_EMPTY(&wp->modes))
return;
if (wp->fd == -1 || wp->flags & PANE_INPUTOFF)
return;
log_debug("%s: %.*s", __func__, (int)len, buf);
bufferevent_write(wp->event, buf, len);
if (options_get_number(wp->options, "synchronize-panes"))
window_pane_copy_paste(wp, buf, len);
}
int
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
struct winlink *wl, key_code key, struct mouse_event *m)