diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-09-16 20:38:49 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-09-16 20:38:49 +0000 |
commit | d2fbbc297dd964a067f101c38e4898d94a5d2200 (patch) | |
tree | c6c888a61fd6120b15b41a575e17795fa455f433 | |
parent | d3629fb7f0e5555191c03e9e799d25183f0d4ba6 (diff) |
Change the behaviour of extended-keys always slightly so that
applications can still enter mode 2 if they want, they just cannot turn
extended keys off entirely. From Stanislav Kljuhhin.
-rw-r--r-- | usr.bin/tmux/input.c | 38 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 5 |
2 files changed, 25 insertions, 18 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 6cf28f68852..f1aa4f8aef5 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.228 2024/08/21 04:37:42 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.229 2024/09/16 20:38:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1349,7 +1349,7 @@ input_csi_dispatch(struct input_ctx *ictx) struct screen_write_ctx *sctx = &ictx->ctx; struct screen *s = sctx->s; struct input_table_entry *entry; - int i, n, m; + int i, n, m, ek; u_int cx, bg = ictx->cell.cell.bg; if (ictx->flags & INPUT_DISCARD) @@ -1407,30 +1407,36 @@ input_csi_dispatch(struct input_ctx *ictx) break; case INPUT_CSI_MODSET: n = input_get(ictx, 0, 0, 0); + if (n != 4) + break; m = input_get(ictx, 1, 0, 0); + /* - * Set the extended key reporting mode as per the client request, - * unless "extended-keys always" forces us into mode 1. + * Set the extended key reporting mode as per the client + * request, unless "extended-keys" is set to "off". */ - if (options_get_number(global_options, "extended-keys") != 1) + ek = options_get_number(global_options, "extended-keys"); + if (ek == 0) break; - screen_write_mode_clear(sctx, - MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2); - if (n == 4 && m == 1) - screen_write_mode_set(sctx, MODE_KEYS_EXTENDED); - if (n == 4 && m == 2) + screen_write_mode_clear(sctx, EXTENDED_KEY_MODES); + if (m == 2) screen_write_mode_set(sctx, MODE_KEYS_EXTENDED_2); + else if (m == 1 || ek == 2) + screen_write_mode_set(sctx, MODE_KEYS_EXTENDED); break; case INPUT_CSI_MODOFF: n = input_get(ictx, 0, 0, 0); + if (n != 4) + break; + /* - * Clear the extended key reporting mode as per the client request, - * unless "extended-keys always" forces us into mode 1. + * Clear the extended key reporting mode as per the client + * request, unless "extended-keys always" forces into mode 1. */ - if (n == 4) { - screen_write_mode_clear(sctx, - MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2); - } + screen_write_mode_clear(sctx, + MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2); + if (options_get_number(global_options, "extended-keys") == 2) + screen_write_mode_set(sctx, MODE_KEYS_EXTENDED); break; case INPUT_CSI_WINOPS: input_csi_dispatch_winops(ictx); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index c8a7d8bc4bb..897c052c6d7 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.955 2024/09/16 20:28:22 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.956 2024/09/16 20:38:48 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -3795,7 +3795,8 @@ the sequence for only keys which lack an existing well-known representation; or mode 2 which changes the sequence for all keys. When set to .Ic always , -mode 1 output is forced and the program cannot change it. +modes 1 and 2 can still be requested by applications, but mode 1 will be forced +instead of the standard mode. When set to .Ic off , this feature is disabled and only standard keys are reported. |