summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-11-14 07:55:01 +0000
committernicm <nicm@openbsd.org>2019-11-14 07:55:01 +0000
commitfdd8dc918b0bd5a01daff43667799980fe8d1042 (patch)
treef5be25d05815113d705573ae59213c1505620a8f
parentavoid a use after free in if_delgroup. (diff)
downloadwireguard-openbsd-fdd8dc918b0bd5a01daff43667799980fe8d1042.tar.xz
wireguard-openbsd-fdd8dc918b0bd5a01daff43667799980fe8d1042.zip
Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.
-rw-r--r--usr.bin/tmux/input-keys.c12
-rw-r--r--usr.bin/tmux/key-string.c14
-rw-r--r--usr.bin/tmux/options-table.c8
-rw-r--r--usr.bin/tmux/spawn.c11
-rw-r--r--usr.bin/tmux/tmux.18
5 files changed, 38 insertions, 15 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index e59854f4490..79f8246441b 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.64 2019/07/09 14:03:12 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.65 2019/11/14 07:55:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -43,9 +43,6 @@ struct input_key_ent {
};
static const struct input_key_ent input_keys[] = {
- /* Backspace key. */
- { KEYC_BSPACE, "\177", 0 },
-
/* Paste keys. */
{ KEYC_PASTE_START, "\033[200~", 0 },
{ KEYC_PASTE_END, "\033[201~", 0 },
@@ -180,6 +177,13 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
return;
}
+ /* Is this backspace? */
+ if ((key & KEYC_MASK_KEY) == KEYC_BSPACE) {
+ key = options_get_number(global_options, "backspace");
+ if (key >= 0x7f)
+ key = '\177';
+ }
+
/*
* 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.
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index 49095e01dd2..bd6b4b8f662 100644
--- a/usr.bin/tmux/key-string.c
+++ b/usr.bin/tmux/key-string.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-string.c,v 1.51 2019/07/09 14:03:12 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.52 2019/11/14 07:55:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -159,7 +159,7 @@ key_string_get_modifiers(const char **string)
key_code
key_string_lookup_string(const char *string)
{
- static const char *other = "!#()+,-.0123456789:;<=>?'\r\t";
+ static const char *other = "!#()+,-.0123456789:;<=>'\r\t";
key_code key;
u_int u;
key_code modifiers;
@@ -196,7 +196,7 @@ key_string_lookup_string(const char *string)
/* Is this a standard ASCII key? */
if (string[1] == '\0' && (u_char)string[0] <= 127) {
key = (u_char)string[0];
- if (key < 32 || key == 127)
+ if (key < 32)
return (KEYC_UNKNOWN);
} else {
/* Try as a UTF-8 key. */
@@ -226,6 +226,8 @@ key_string_lookup_string(const char *string)
key -= 64;
else if (key == 32)
key = 0;
+ else if (key == '?')
+ key = 127;
else if (key == 63)
key = KEYC_BSPACE;
else
@@ -329,7 +331,7 @@ key_string_lookup_key(key_code key)
}
/* Invalid keys are errors. */
- if (key == 127 || key > 255) {
+ if (key > 255) {
snprintf(out, sizeof out, "Invalid#%llx", key);
return (out);
}
@@ -343,7 +345,9 @@ key_string_lookup_key(key_code key)
} else if (key >= 32 && key <= 126) {
tmp[0] = key;
tmp[1] = '\0';
- } else if (key >= 128)
+ } else if (key == 127)
+ xsnprintf(tmp, sizeof tmp, "C-?");
+ else if (key >= 128)
xsnprintf(tmp, sizeof tmp, "\\%llo", key);
strlcat(out, tmp, sizeof out);
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index 78d302194a7..1f3830a2b0a 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.111 2019/09/19 09:02:30 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.112 2019/11/14 07:55:01 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -147,6 +147,12 @@ static const char *options_table_status_format_default[] = {
/* Top-level options. */
const struct options_table_entry options_table[] = {
/* Server options. */
+ { .name = "backspace",
+ .type = OPTIONS_TABLE_KEY,
+ .scope = OPTIONS_TABLE_SERVER,
+ .default_num = '\177',
+ },
+
{ .name = "buffer-limit",
.type = OPTIONS_TABLE_NUMBER,
.scope = OPTIONS_TABLE_SERVER,
diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c
index 0b5ec462c53..8b5c3349753 100644
--- a/usr.bin/tmux/spawn.c
+++ b/usr.bin/tmux/spawn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spawn.c,v 1.10 2019/10/07 07:14:07 nicm Exp $ */
+/* $OpenBSD: spawn.c,v 1.11 2019/11/14 07:55:01 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -217,6 +217,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
u_int hlimit;
struct winsize ws;
sigset_t set, oldset;
+ key_code key;
spawn_log(__func__, sc);
@@ -378,13 +379,17 @@ spawn_pane(struct spawn_context *sc, char **cause)
/*
* Update terminal escape characters from the session if available and
- * force VERASE to tmux's \177.
+ * force VERASE to tmux's backspace.
*/
if (tcgetattr(STDIN_FILENO, &now) != 0)
_exit(1);
if (s->tio != NULL)
memcpy(now.c_cc, s->tio->c_cc, sizeof now.c_cc);
- now.c_cc[VERASE] = '\177';
+ key = options_get_number(global_options, "backspace");
+ if (key >= 0x7f)
+ now.c_cc[VERASE] = '\177';
+ else
+ now.c_cc[VERASE] = key;
if (tcsetattr(STDIN_FILENO, TCSANOW, &now) != 0)
_exit(1);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 89558a70785..08196d97450 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.694 2019/11/07 07:11:25 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.695 2019/11/14 07:55:01 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 7 2019 $
+.Dd $Mdocdate: November 14 2019 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -2925,6 +2925,10 @@ omitted to toggle).
.Pp
Available server options are:
.Bl -tag -width Ds
+.It Ic backspace Ar key
+Set the key sent by
+.Nm
+for backspace.
.It Ic buffer-limit Ar number
Set the number of buffers; as new buffers are added to the top of the stack,
old ones are removed from the bottom if necessary to maintain this maximum