summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-06-26 19:30:42 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-06-26 21:21:12 +0200
commit5e0ca4740bd7df4746b5187c74696dc5e1c42396 (patch)
tree1381492dc274dcdf41bf8503e990a87f6b451844 /src/gui
parent70c41f614ad57613a1ff9642fb78fb889aa990f3 (diff)
downloadweechat-5e0ca4740bd7df4746b5187c74696dc5e1c42396.zip
core: display actual key name and command with key Alt+k
Key Alt+K (upper K) is removed as well as commands `/input grab_raw_key` and `/input grab_raw_key_command`.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-key.c1
-rw-r--r--src/gui/gui-input.c5
-rw-r--r--src/gui/gui-input.h4
-rw-r--r--src/gui/gui-key.c33
-rw-r--r--src/gui/gui-key.h3
5 files changed, 20 insertions, 26 deletions
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c
index e249277a4..eeedbb27b 100644
--- a/src/gui/curses/gui-curses-key.c
+++ b/src/gui/curses/gui-curses-key.c
@@ -134,7 +134,6 @@ gui_key_default_bindings (int context, int create_option)
BIND("meta-h,meta-r", "/hotlist restore");
BIND("meta-h,meta-R", "/hotlist restore -all");
BIND("meta-k", "/input grab_key_command");
- BIND("meta-K", "/input grab_raw_key_command");
BIND("meta-s", "/mute spell toggle");
BIND("meta-u", "/window scroll_unread");
BIND("ctrl-s,ctrl-u", "/allbuf /buffer set unread");
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index bbe27dd30..29f89bf32 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1729,11 +1729,10 @@ gui_input_history_global_next (struct t_gui_buffer *buffer)
*/
void
-gui_input_grab_key (struct t_gui_buffer *buffer, int raw_key, int command,
- const char *delay)
+gui_input_grab_key (struct t_gui_buffer *buffer, int command, const char *delay)
{
if (buffer->input)
- gui_key_grab_init (raw_key, command, delay);
+ gui_key_grab_init (command, delay);
}
/*
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index a75459f3b..b176ea424 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -78,8 +78,8 @@ extern void gui_input_history_local_previous (struct t_gui_buffer *buffer);
extern void gui_input_history_local_next (struct t_gui_buffer *buffer);
extern void gui_input_history_global_previous (struct t_gui_buffer *buffer);
extern void gui_input_history_global_next (struct t_gui_buffer *buffer);
-extern void gui_input_grab_key (struct t_gui_buffer *buffer, int raw_key,
- int command, const char *delay);
+extern void gui_input_grab_key (struct t_gui_buffer *buffer, int command,
+ const char *delay);
extern void gui_input_grab_mouse (struct t_gui_buffer *buffer, int area);
extern void gui_input_insert (struct t_gui_buffer *buffer, const char *args);
extern void gui_input_undo (struct t_gui_buffer *buffer);
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 1737d2bad..19aa00f0f 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -87,7 +87,6 @@ int gui_key_verbose = 0; /* 1 to see some messages */
char gui_key_combo[1024]; /* buffer used for combos */
int gui_key_grab = 0; /* 1 if grab mode enabled (alt-k) */
-int gui_key_grab_raw = 0; /* grab raw key code? */
int gui_key_grab_count = 0; /* number of keys pressed in grab mode */
int gui_key_grab_command = 0; /* grab command bound to key? */
int gui_key_grab_delay = 0; /* delay for grab (default is 500) */
@@ -185,13 +184,12 @@ gui_key_get_current_context ()
*/
void
-gui_key_grab_init (int grab_raw_key, int grab_command, const char *delay)
+gui_key_grab_init (int grab_command, const char *delay)
{
long milliseconds;
char *error;
gui_key_grab = 1;
- gui_key_grab_raw = grab_raw_key;
gui_key_grab_count = 0;
gui_key_grab_command = grab_command;
@@ -217,8 +215,7 @@ int
gui_key_grab_end_timer_cb (const void *pointer, void *data, int remaining_calls)
{
char *key_name, *key_name_alias, *key_utf8;
- const char *ptr_key_name;
- struct t_gui_key *ptr_key;
+ struct t_gui_key *ptr_key_raw, *ptr_key;
int rc;
/* make C compiler happy */
@@ -264,23 +261,23 @@ gui_key_grab_end_timer_cb (const void *pointer, void *data, int remaining_calls)
}
}
- ptr_key_name = (gui_key_grab_raw) ? key_name : key_name_alias;
-
/* add expanded key to input buffer */
if (gui_current_window->buffer->input)
{
- gui_input_insert_string (gui_current_window->buffer, ptr_key_name);
- if (gui_key_grab_command)
+ ptr_key_raw = gui_key_search (gui_keys[GUI_KEY_CONTEXT_DEFAULT],
+ key_name);
+ ptr_key = gui_key_search (gui_keys[GUI_KEY_CONTEXT_DEFAULT],
+ key_name_alias);
+ gui_input_insert_string (gui_current_window->buffer,
+ (ptr_key_raw) ? key_name : key_name_alias);
+ /* add command bound to key (if found) */
+ if (gui_key_grab_command && (ptr_key_raw || ptr_key))
{
- /* add command bound to key (if found) */
- ptr_key = gui_key_search (gui_keys[GUI_KEY_CONTEXT_DEFAULT],
- ptr_key_name);
- if (ptr_key)
- {
- gui_input_insert_string (gui_current_window->buffer, " ");
- gui_input_insert_string (gui_current_window->buffer,
- ptr_key->command);
- }
+ gui_input_insert_string (gui_current_window->buffer, " ");
+ gui_input_insert_string (
+ gui_current_window->buffer,
+ (ptr_key_raw) ?
+ ptr_key_raw->command : ptr_key->command);
}
gui_input_text_changed_modifier_and_signal (
gui_current_window->buffer,
diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h
index e767c6150..b0aeb2ad8 100644
--- a/src/gui/gui-key.h
+++ b/src/gui/gui-key.h
@@ -90,8 +90,7 @@ extern time_t gui_key_last_activity_time;
extern void gui_key_init ();
extern int gui_key_search_context (const char *context);
-extern void gui_key_grab_init (int grab_raw_key, int grab_command,
- const char *delay);
+extern void gui_key_grab_init (int grab_command, const char *delay);
extern int gui_key_expand (const char *key,
char **key_name, char **key_name_alias);
extern char *gui_key_legacy_to_alias (const char *key);