From 0f99bcbc1eb53298abbdf425786417b890b41737 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 28 Jun 2017 11:36:39 +0000 Subject: [PATCH] Apply the xterm key flag when needed for send-keys, fixes problem reported by Franky Spamschleuder. --- usr.bin/tmux/cmd-send-keys.c | 4 +++- usr.bin/tmux/input-keys.c | 4 ++-- usr.bin/tmux/tmux.h | 6 +++--- usr.bin/tmux/window.c | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 82312d6aa5f..2d602bac226 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.41 2017/05/10 10:46:59 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.42 2017/06/28 11:36:39 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -64,6 +64,8 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key) struct key_binding *bd, bd_find; if (wp->mode == NULL || wp->mode->key_table == NULL) { + if (options_get_number(wp->window->options, "xterm-keys")) + key |= KEYC_XTERM; window_pane_key(wp, NULL, s, key, NULL); return; } diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c index 6bd06689e98..86810a73c30 100644 --- a/usr.bin/tmux/input-keys.c +++ b/usr.bin/tmux/input-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input-keys.c,v 1.61 2017/06/12 07:04:24 nicm Exp $ */ +/* $OpenBSD: input-keys.c,v 1.62 2017/06/28 11:36:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -177,7 +177,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m) * If this is a normal 7-bit key, just send it, with a leading escape * if necessary. If it is a UTF-8 key, split it and send it. */ - justkey = (key & ~KEYC_ESCAPE); + justkey = (key & ~(KEYC_XTERM|KEYC_ESCAPE)); if (justkey <= 0x7f) { if (key & KEYC_ESCAPE) bufferevent_write(wp->event, "\033", 1); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index bdff96144c3..848b312c330 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.787 2017/06/23 15:36:52 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.788 2017/06/28 11:36:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -94,8 +94,8 @@ struct tmuxproc; /* Key modifier bits. */ #define KEYC_ESCAPE 0x200000000000ULL -#define KEYC_CTRL 0x400000000000ULL -#define KEYC_SHIFT 0x800000000000ULL +#define KEYC_CTRL 0x400000000000ULL +#define KEYC_SHIFT 0x800000000000ULL #define KEYC_XTERM 0x1000000000000ULL /* Mask to obtain key w/o modifiers. */ diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index a890801a498..9330bbcd31d 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.198 2017/06/04 09:02:36 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.199 2017/06/28 11:36:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1226,7 +1226,7 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s, if (wp->mode != NULL) { wp->modelast = time(NULL); if (wp->mode->key != NULL) - wp->mode->key(wp, c, s, key, m); + wp->mode->key(wp, c, s, (key & ~KEYC_XTERM), m); return; } -- 2.20.1