From 985e36cc5b9ff54313d89f6b75191cc6fa45728b Mon Sep 17 00:00:00 2001
From: Johannes Altmanninger <aclopte@gmail.com>
Date: Wed, 9 Oct 2024 08:03:26 +0200
Subject: [PATCH 2/3] Ticket #4597: recognize CSI u encoding for ctrl-o
If a subshell (like fish 4.0) wishes to use "Disambiguate control keys"
from https://sw.kovidgoyal.net/kitty/keyboard-protocol/, ctrl-o sends
a multi-byte sequence. Let's make sure we can intercept that too so
we can suspend the shell.
Note that the shell already disables "Disambiguate control keys"
while it's suspended, so no other changes should be necessary.
Unfortunately there is one bug left: when I start "SHELL=$(which
fish) mc" and type `ctrl-o`, fish does not recognize CSI u bindings
(such as `bind ctrl-2 'echo hello'`) yet. It only works after the
second prompt. I haven't had time to figure that out.
---
src/subshell/common.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/subshell/common.c b/src/subshell/common.c
index 72f001569..85eef1181 100644
a
|
b
|
static int subshell_pty_slave = -1; |
180 | 180 | /* The key for switching back to MC from the subshell */ |
181 | 181 | /* *INDENT-OFF* */ |
182 | 182 | static const char subshell_switch_key = XCTRL ('o') & 255; |
| 183 | static const char subshell_switch_key_csi_u[] = "\x1b[111;5u"; |
183 | 184 | /* *INDENT-ON* */ |
184 | 185 | |
185 | 186 | /* For reading/writing on the subshell's pty */ |
… |
… |
feed_subshell (int how, gboolean fail_on_error) |
864 | 865 | } |
865 | 866 | |
866 | 867 | for (i = 0; i < bytes; ++i) |
867 | | if (pty_buffer[i] == subshell_switch_key) |
| 868 | if (pty_buffer[i] == subshell_switch_key || |
| 869 | (strlen(subshell_switch_key_csi_u) <= (size_t)bytes - i && |
| 870 | !memcmp( |
| 871 | &pty_buffer[i], subshell_switch_key_csi_u, |
| 872 | strlen(subshell_switch_key_csi_u)))) |
868 | 873 | { |
869 | 874 | write_all (mc_global.tty.subshell_pty, pty_buffer, i); |
870 | 875 | |