From fd054bec0d768d88ed9030b4f5d8cc7092aba3d9 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 16 Aug 2018 14:04:03 +0000 Subject: [PATCH] Add the KEYC_XTERM flag to all function keys that imply a modifier so that they are correctly translated into xterm(1)-style keys. GitHub issue 1437. --- usr.bin/tmux/input.c | 4 +- usr.bin/tmux/tty-keys.c | 124 ++++++++++++++++++++-------------------- 2 files changed, 65 insertions(+), 63 deletions(-) diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 0e29839fe42..b657d6d5cc2 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.135 2018/07/31 10:32:19 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.136 2018/08/16 14:04:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2235,7 +2235,7 @@ bad: free(copy); } -/* Handle the OSC 10 sequence for setting background colour. */ +/* Handle the OSC 10 sequence for setting foreground colour. */ static void input_osc_10(struct window_pane *wp, const char *p) { diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index baa63f9c714..ad02d2f5a04 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.102 2017/10/09 11:35:35 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.103 2018/08/16 14:04:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -171,7 +171,12 @@ static const struct tty_default_key_raw tty_default_raw_keys[] = { { "\033[201~", KEYC_PASTE_END }, }; -/* Default terminfo(5) keys. */ +/* + * Default terminfo(5) keys. Any keys that have builtin modifiers + * (that is, where the key itself contains the modifiers) has the + * KEYC_XTERM flag set so a leading escape is not treated as meta (and + * probably removed). + */ struct tty_default_key_code { enum tty_code_code code; key_code key; @@ -191,61 +196,61 @@ static const struct tty_default_key_code tty_default_code_keys[] = { { TTYC_KF11, KEYC_F11 }, { TTYC_KF12, KEYC_F12 }, - { TTYC_KF13, KEYC_F1|KEYC_SHIFT }, - { TTYC_KF14, KEYC_F2|KEYC_SHIFT }, - { TTYC_KF15, KEYC_F3|KEYC_SHIFT }, - { TTYC_KF16, KEYC_F4|KEYC_SHIFT }, - { TTYC_KF17, KEYC_F5|KEYC_SHIFT }, - { TTYC_KF18, KEYC_F6|KEYC_SHIFT }, - { TTYC_KF19, KEYC_F7|KEYC_SHIFT }, - { TTYC_KF20, KEYC_F8|KEYC_SHIFT }, - { TTYC_KF21, KEYC_F9|KEYC_SHIFT }, - { TTYC_KF22, KEYC_F10|KEYC_SHIFT }, - { TTYC_KF23, KEYC_F11|KEYC_SHIFT }, - { TTYC_KF24, KEYC_F12|KEYC_SHIFT }, - - { TTYC_KF25, KEYC_F1|KEYC_CTRL }, - { TTYC_KF26, KEYC_F2|KEYC_CTRL }, - { TTYC_KF27, KEYC_F3|KEYC_CTRL }, - { TTYC_KF28, KEYC_F4|KEYC_CTRL }, - { TTYC_KF29, KEYC_F5|KEYC_CTRL }, - { TTYC_KF30, KEYC_F6|KEYC_CTRL }, - { TTYC_KF31, KEYC_F7|KEYC_CTRL }, - { TTYC_KF32, KEYC_F8|KEYC_CTRL }, - { TTYC_KF33, KEYC_F9|KEYC_CTRL }, - { TTYC_KF34, KEYC_F10|KEYC_CTRL }, - { TTYC_KF35, KEYC_F11|KEYC_CTRL }, - { TTYC_KF36, KEYC_F12|KEYC_CTRL }, - - { TTYC_KF37, KEYC_F1|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF38, KEYC_F2|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF39, KEYC_F3|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF40, KEYC_F4|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF41, KEYC_F5|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF42, KEYC_F6|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF43, KEYC_F7|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF44, KEYC_F8|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF45, KEYC_F9|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF46, KEYC_F10|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL }, - { TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL }, - - { TTYC_KF49, KEYC_F1|KEYC_ESCAPE }, - { TTYC_KF50, KEYC_F2|KEYC_ESCAPE }, - { TTYC_KF51, KEYC_F3|KEYC_ESCAPE }, - { TTYC_KF52, KEYC_F4|KEYC_ESCAPE }, - { TTYC_KF53, KEYC_F5|KEYC_ESCAPE }, - { TTYC_KF54, KEYC_F6|KEYC_ESCAPE }, - { TTYC_KF55, KEYC_F7|KEYC_ESCAPE }, - { TTYC_KF56, KEYC_F8|KEYC_ESCAPE }, - { TTYC_KF57, KEYC_F9|KEYC_ESCAPE }, - { TTYC_KF58, KEYC_F10|KEYC_ESCAPE }, - { TTYC_KF59, KEYC_F11|KEYC_ESCAPE }, - { TTYC_KF60, KEYC_F12|KEYC_ESCAPE }, - - { TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT }, - { TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT }, - { TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT }, + { TTYC_KF13, KEYC_F1|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF14, KEYC_F2|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF15, KEYC_F3|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF16, KEYC_F4|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF17, KEYC_F5|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF18, KEYC_F6|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF19, KEYC_F7|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF20, KEYC_F8|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF21, KEYC_F9|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF22, KEYC_F10|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF23, KEYC_F11|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF24, KEYC_F12|KEYC_SHIFT|KEYC_XTERM }, + + { TTYC_KF25, KEYC_F1|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF26, KEYC_F2|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF27, KEYC_F3|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF28, KEYC_F4|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF29, KEYC_F5|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF30, KEYC_F6|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF31, KEYC_F7|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF32, KEYC_F8|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF33, KEYC_F9|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF34, KEYC_F10|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF35, KEYC_F11|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF36, KEYC_F12|KEYC_CTRL|KEYC_XTERM }, + + { TTYC_KF37, KEYC_F1|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF38, KEYC_F2|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF39, KEYC_F3|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF40, KEYC_F4|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF41, KEYC_F5|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF42, KEYC_F6|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF43, KEYC_F7|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF44, KEYC_F8|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF45, KEYC_F9|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF46, KEYC_F10|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, + + { TTYC_KF49, KEYC_F1|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF50, KEYC_F2|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF51, KEYC_F3|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF52, KEYC_F4|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF53, KEYC_F5|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF54, KEYC_F6|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF55, KEYC_F7|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF56, KEYC_F8|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF57, KEYC_F9|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF58, KEYC_F10|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF59, KEYC_F11|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF60, KEYC_F12|KEYC_ESCAPE|KEYC_XTERM }, + + { TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, { TTYC_KICH1, KEYC_IC }, { TTYC_KDCH1, KEYC_DC }, @@ -261,10 +266,7 @@ static const struct tty_default_key_code tty_default_code_keys[] = { { TTYC_KCUB1, KEYC_LEFT }, { TTYC_KCUF1, KEYC_RIGHT }, - /* - * Key and modifier capabilities. We set the xterm flag to mark that - * any leading escape means an escape key press and not the modifier. - */ + /* Key and modifier capabilities. */ { TTYC_KDC2, KEYC_DC|KEYC_SHIFT|KEYC_XTERM }, { TTYC_KDC3, KEYC_DC|KEYC_ESCAPE|KEYC_XTERM }, { TTYC_KDC4, KEYC_DC|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, -- 2.20.1