summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-02-16 20:30:52 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-03-16 20:42:18 +0100
commit31bf962bba5c8b81a59f4173405e48a2f3887c1e (patch)
tree3b3937e6276bdabca51af9fbb054f9e752afb1b2
parent15587ac72f8cb432e03439e8f5b09754cfab20b3 (diff)
downloadweechat-31bf962bba5c8b81a59f4173405e48a2f3887c1e.zip
core: display new key name using aliases in output of `/key` command
-rw-r--r--src/core/wee-command.c18
-rw-r--r--src/gui/gui-key.c7
-rw-r--r--src/gui/gui-key.h3
3 files changed, 23 insertions, 5 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 259e53ac7..530383264 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -3759,14 +3759,25 @@ COMMAND_CALLBACK(item)
void
command_key_display (struct t_gui_key *key, struct t_gui_key *default_key)
{
- char *expanded_name;
+ char *expanded_name, str_key_name[1024];
+
+ str_key_name[0] = '\0';
+ if (key->key_name && (strcmp (key->key, key->key_name) != 0))
+ {
+ snprintf (str_key_name, sizeof (str_key_name),
+ "%s -> %s%s",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ key->key_name);
+ }
expanded_name = gui_key_expand_legacy (key->key);
if (default_key)
{
- gui_chat_printf (NULL, " %s%s => %s%s %s(%s%s %s%s)",
+ gui_chat_printf (NULL, " %s%s%s => %s%s %s(%s%s %s%s)",
(expanded_name) ? expanded_name : key->key,
+ str_key_name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
key->command,
@@ -3778,8 +3789,9 @@ command_key_display (struct t_gui_key *key, struct t_gui_key *default_key)
}
else
{
- gui_chat_printf (NULL, " %s%s => %s%s",
+ gui_chat_printf (NULL, " %s%s%s => %s%s",
(expanded_name) ? expanded_name : key->key,
+ str_key_name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
key->command);
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 8cdd79999..3cd12ae92 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -1176,7 +1176,7 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
const char *command)
{
struct t_gui_key *new_key;
- char *internal_code, *expanded_name;
+ char *internal_code, *expanded_name, *key_name;
if (!key || !command)
return NULL;
@@ -1197,11 +1197,14 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
return NULL;
}
+ key_name = gui_key_legacy_to_alias (key);
+
new_key = malloc (sizeof (*new_key));
if (!new_key)
return NULL;
new_key->key = internal_code;
+ new_key->key_name = key_name;
new_key->command = strdup (command);
gui_key_set_areas (new_key);
gui_key_set_score (new_key);
@@ -2064,6 +2067,8 @@ gui_key_free (struct t_gui_key **keys, struct t_gui_key **last_key,
/* free memory */
if (key->key)
free (key->key);
+ if (key->key_name)
+ free (key->key_name);
for (i = 0; i < 2; i++)
{
if (key->area_name[i])
diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h
index 52d3ee326..f49653bbe 100644
--- a/src/gui/gui-key.h
+++ b/src/gui/gui-key.h
@@ -54,7 +54,8 @@ enum t_gui_key_focus
struct t_gui_key
{
- char *key; /* key combo (ex: a, ^W, ^W^C, meta-a) */
+ char *key; /* raw key (eg: \001w, \001[[1;3D) */
+ char *key_name; /* key name (eg: ctrl-w, meta-left) */
int area_type[2]; /* type of areas (for cursor/mouse) */
char *area_name[2]; /* name of areas (for cursor/mouse) */
char *area_key; /* key after area (after ":") */