From 573f1046ac1056e8947a70df56018863be5f7ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 1 May 2024 13:38:17 +0200 Subject: core: execute command as user data for local keys in buffer (issue #2066) If buffer->input_get_any_user_data is set to 1, any command executed via a buffer local key is considered as user input and then sent to the buffer callback, instead of being executed directly. This is used on relay remote buffers, to execute the command on the remote instead of locally. --- src/gui/gui-key.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 3e5a552fa..3e74d7c91 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -2343,6 +2343,7 @@ gui_key_pressed (const char *key_str) { int i, insert_into_input, context, length, length_key, signal_sent; int rc, rc_expand, exact_match, chunks1_count, chunks2_count, event_size; + int buffer_key; struct t_gui_key *ptr_key; char saved_char, signal_name[128], **commands; char *key_name, *key_name_alias, **chunks1, **chunks2; @@ -2438,6 +2439,7 @@ gui_key_pressed (const char *key_str) chunks2_count = 0; } + buffer_key = 0; context = gui_key_get_current_context (); switch (context) { @@ -2449,6 +2451,8 @@ gui_key_pressed (const char *key_str) (const char **)chunks1, chunks1_count, (const char **)chunks2, chunks2_count, &exact_match); + if (ptr_key) + buffer_key = 1; /* if key is not found for buffer, then look in general table */ if (!ptr_key) { @@ -2523,8 +2527,12 @@ gui_key_pressed (const char *key_str) { for (i = 0; commands[i]; i++) { - (void) input_data (gui_current_window->buffer, - commands[i], NULL, 0, 0); + (void) input_data ( + gui_current_window->buffer, + commands[i], + NULL, + 0, + (buffer_key) ? 1 : 0); } string_free_split (commands); } -- cgit v1.2.3