mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 23:06:38 +02:00
core: display new key name using aliases in output of /key command
This commit is contained in:
+15
-3
@@ -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);
|
||||
|
||||
+6
-1
@@ -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])
|
||||
|
||||
+2
-1
@@ -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 ":") */
|
||||
|
||||
Reference in New Issue
Block a user