1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

[config] trick with union { const char *, char * }

This commit is contained in:
Witold Filipczyk 2022-01-30 15:22:18 +01:00
parent 5f56b97a34
commit bcc911019d
2 changed files with 12 additions and 6 deletions

View File

@ -27,7 +27,7 @@
#define table table_elinks
#define ACTION_(map, name, action, caption, flags) \
{ name, ACT_##map##_##action, KEYMAP_ID, caption, flags }
{ {name}, ACT_##map##_##action, KEYMAP_ID, {caption}, flags }
#undef KEYMAP_ID
#define KEYMAP_ID KEYMAP_MAIN
@ -275,7 +275,7 @@ get_action_name_from_keystroke(keymap_id_T keymap_id,
const struct action *action = get_action_from_keystroke(keymap_id,
keystroke_str);
return action ? action->str : NULL;
return action ? action->astr : NULL;
}
action_id_T
@ -308,7 +308,7 @@ get_action_name(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
return action ? action->str : NULL;
return action ? action->astr : NULL;
}
static char *
@ -316,7 +316,7 @@ get_action_desc(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
return action ? (action->desc ? action->desc : action->str)
return action ? (action->adesc ? action->adesc : action->astr)
: NULL;
}

View File

@ -28,10 +28,16 @@ enum keymap_id {
};
struct action {
char *str;
union {
const char *str;
char *astr;
};
action_id_T num;
keymap_id_T keymap_id;
char *desc;
union {
const char *desc;
char *adesc;
};
unsigned int flags;
};