1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-13 05:43:37 -04:00

[kbd] enum keymap_id -> keymap_id_T

This commit is contained in:
Witold Filipczyk 2022-01-28 14:20:06 +01:00
parent f706afe8d0
commit ee6e9caa6a
6 changed files with 56 additions and 54 deletions

View File

@ -773,7 +773,7 @@ input_line_event_handler(struct dialog_data *dlg_data)
{
struct input_line *input_line = (struct input_line *)dlg_data->dlg->udata;
input_line_handler_T handler = input_line->handler;
enum edit_action action_id;
action_id_T action_id;
struct widget_data *widget_data = dlg_data->widgets_data;
struct term_event *ev = dlg_data->term_event;

View File

@ -536,7 +536,7 @@ static int keybinding_text_toggle;
static struct listbox_item *action_box_items[KEYMAP_MAX][ACTION_BOX_SIZE];
struct listbox_item *
get_keybinding_action_box_item(enum keymap_id keymap_id, action_id_T action_id)
get_keybinding_action_box_item(keymap_id_T keymap_id, action_id_T action_id)
{
assert(action_id < ACTION_BOX_SIZE);
if_assert_failed return NULL;
@ -751,7 +751,7 @@ static const struct listbox_ops keybinding_listbox_ops = {
struct kbdbind_add_hop {
struct terminal *term;
action_id_T action_id;
enum keymap_id keymap_id;
keymap_id_T keymap_id;
struct term_event_keyboard kbd;
struct widget_data *widget_data;
};

View File

@ -19,7 +19,7 @@ void write_config_dialog(struct terminal *term, char *config_file,
void options_manager(struct session *);
void keybinding_manager(struct session *);
struct listbox_item *get_keybinding_action_box_item(enum keymap_id keymap_id, action_id_T action_id);
struct listbox_item *get_keybinding_action_box_item(keymap_id_T keymap_id, action_id_T action_id);
void init_keybinding_listboxes(struct keymap keymap_table[KEYMAP_MAX],
const struct action_list actions[]);
void done_keybinding_listboxes(void);

View File

@ -67,7 +67,7 @@ static LIST_OF(struct keybinding) keymaps[KEYMAP_MAX];
static void add_default_keybindings(void);
static int
delete_keybinding(enum keymap_id keymap_id, struct term_event_keyboard *kbd)
delete_keybinding(keymap_id_T keymap_id, struct term_event_keyboard *kbd)
{
struct keybinding *keybinding;
@ -97,7 +97,7 @@ delete_keybinding(enum keymap_id keymap_id, struct term_event_keyboard *kbd)
static int keybinding_is_default(struct keybinding *keybinding);
struct keybinding *
add_keybinding(enum keymap_id keymap_id, action_id_T action_id,
add_keybinding(keymap_id_T keymap_id, action_id_T action_id,
struct term_event_keyboard *kbd, int event)
{
struct keybinding *keybinding;
@ -162,7 +162,7 @@ free_keybinding(struct keybinding *keybinding)
}
int
keybinding_exists(enum keymap_id keymap_id, struct term_event_keyboard *kbd,
keybinding_exists(keymap_id_T keymap_id, struct term_event_keyboard *kbd,
action_id_T *action_id)
{
struct keybinding *keybinding;
@ -184,7 +184,7 @@ keybinding_exists(enum keymap_id keymap_id, struct term_event_keyboard *kbd,
action_id_T
kbd_action(enum keymap_id keymap_id, struct term_event *ev, int *event)
kbd_action(keymap_id_T keymap_id, struct term_event *ev, int *event)
{
struct keybinding *keybinding;
@ -195,7 +195,7 @@ kbd_action(enum keymap_id keymap_id, struct term_event *ev, int *event)
}
struct keybinding *
kbd_ev_lookup(enum keymap_id keymap_id, struct term_event_keyboard *kbd, int *event)
kbd_ev_lookup(keymap_id_T keymap_id, struct term_event_keyboard *kbd, int *event)
{
struct keybinding *keybinding;
@ -216,7 +216,7 @@ kbd_ev_lookup(enum keymap_id keymap_id, struct term_event_keyboard *kbd, int *ev
}
static struct keybinding *
kbd_act_lookup(enum keymap_id keymap_id, action_id_T action_id)
kbd_act_lookup(keymap_id_T keymap_id, action_id_T action_id)
{
struct keybinding *keybinding;
@ -231,7 +231,7 @@ kbd_act_lookup(enum keymap_id keymap_id, action_id_T action_id)
}
struct keybinding *
kbd_nm_lookup(enum keymap_id keymap_id, char *name)
kbd_nm_lookup(keymap_id_T keymap_id, char *name)
{
action_id_T action_id = get_action_from_string(keymap_id, name);
@ -241,7 +241,7 @@ kbd_nm_lookup(enum keymap_id keymap_id, char *name)
}
static struct keybinding *
kbd_stroke_lookup(enum keymap_id keymap_id, const char *keystroke_str)
kbd_stroke_lookup(keymap_id_T keymap_id, const char *keystroke_str)
{
struct term_event_keyboard kbd;
@ -259,7 +259,7 @@ kbd_stroke_lookup(enum keymap_id keymap_id, const char *keystroke_str)
*/
static const struct action *
get_action_from_keystroke(enum keymap_id keymap_id,
get_action_from_keystroke(keymap_id_T keymap_id,
const char *keystroke_str)
{
struct keybinding *keybinding = kbd_stroke_lookup(keymap_id,
@ -269,7 +269,7 @@ get_action_from_keystroke(enum keymap_id keymap_id,
}
char *
get_action_name_from_keystroke(enum keymap_id keymap_id,
get_action_name_from_keystroke(keymap_id_T keymap_id,
const char *keystroke_str)
{
const struct action *action = get_action_from_keystroke(keymap_id,
@ -279,7 +279,7 @@ get_action_name_from_keystroke(enum keymap_id keymap_id,
}
action_id_T
get_action_from_string(enum keymap_id keymap_id, char *str)
get_action_from_string(keymap_id_T keymap_id, char *str)
{
const struct action *action;
@ -293,7 +293,7 @@ get_action_from_string(enum keymap_id keymap_id, char *str)
}
const struct action *
get_action(enum keymap_id keymap_id, action_id_T action_id)
get_action(keymap_id_T keymap_id, action_id_T action_id)
{
assert(keymap_id >= 0 && keymap_id < KEYMAP_MAX);
@ -304,7 +304,7 @@ get_action(enum keymap_id keymap_id, action_id_T action_id)
}
char *
get_action_name(enum keymap_id keymap_id, action_id_T action_id)
get_action_name(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -312,7 +312,7 @@ get_action_name(enum keymap_id keymap_id, action_id_T action_id)
}
static char *
get_action_desc(enum keymap_id keymap_id, action_id_T action_id)
get_action_desc(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -322,14 +322,14 @@ get_action_desc(enum keymap_id keymap_id, action_id_T action_id)
static struct keymap *
get_keymap(enum keymap_id keymap_id)
get_keymap(keymap_id_T keymap_id)
{
assert(keymap_id >= 0 && keymap_id < KEYMAP_MAX);
return &keymap_table[keymap_id];
}
static enum keymap_id
static keymap_id_T
get_keymap_id(char *keymap_str)
{
int keymap_id;
@ -342,7 +342,7 @@ get_keymap_id(char *keymap_str)
}
char *
get_keymap_name(enum keymap_id keymap_id)
get_keymap_name(keymap_id_T keymap_id)
{
return get_keymap(keymap_id)->str;
}
@ -504,7 +504,7 @@ add_keystroke_to_string(struct string *str, struct term_event_keyboard *kbd,
void
add_keystroke_action_to_string(struct string *string, action_id_T action_id,
enum keymap_id keymap_id)
keymap_id_T keymap_id)
{
struct keybinding *keybinding = kbd_act_lookup(keymap_id, action_id);
@ -513,7 +513,7 @@ add_keystroke_action_to_string(struct string *string, action_id_T action_id,
}
char *
get_keystroke(action_id_T action_id, enum keymap_id keymap_id)
get_keystroke(action_id_T action_id, keymap_id_T keymap_id)
{
struct string keystroke;
@ -529,7 +529,7 @@ get_keystroke(action_id_T action_id, enum keymap_id keymap_id)
void
add_actions_to_string(struct string *string, action_id_T action_ids[],
enum keymap_id keymap_id, struct terminal *term)
keymap_id_T keymap_id, struct terminal *term)
{
int i;
@ -587,7 +587,7 @@ bind_key_to_event(char *ckmap, const char *ckey, int event)
{
struct term_event_keyboard kbd;
action_id_T action_id;
enum keymap_id keymap_id = get_keymap_id(ckmap);
keymap_id_T keymap_id = get_keymap_id(ckmap);
if (keymap_id == KEYMAP_INVALID)
return gettext("Unrecognised keymap");
@ -887,7 +887,7 @@ static const struct action_alias *action_aliases[KEYMAP_MAX] = {
};
static action_id_T
get_aliased_action(enum keymap_id keymap_id, char *action_str)
get_aliased_action(keymap_id_T keymap_id, char *action_str)
{
assert(keymap_id >= 0 && keymap_id < KEYMAP_MAX);
@ -907,7 +907,7 @@ int
bind_do(char *keymap_str, const char *keystroke_str,
char *action_str, int is_system_conf)
{
enum keymap_id keymap_id;
keymap_id_T keymap_id;
action_id_T action_id;
struct term_event_keyboard kbd;
struct keybinding *keybinding;
@ -930,7 +930,7 @@ bind_do(char *keymap_str, const char *keystroke_str,
char *
bind_act(char *keymap_str, const char *keystroke_str)
{
enum keymap_id keymap_id;
keymap_id_T keymap_id;
char *action;
struct keybinding *keybinding;
@ -950,7 +950,7 @@ bind_act(char *keymap_str, const char *keystroke_str)
}
static void
single_bind_config_string(struct string *file, enum keymap_id keymap_id,
single_bind_config_string(struct string *file, keymap_id_T keymap_id,
struct keybinding *keybinding)
{
char *keymap_str = get_keymap_name(keymap_id);

View File

@ -17,6 +17,8 @@ struct module;
/* Used for holding enum <keymap>_action values. */
typedef long action_id_T;
typedef long keymap_id_T;
enum keymap_id {
KEYMAP_INVALID = -1,
KEYMAP_MAIN,
@ -28,7 +30,7 @@ enum keymap_id {
struct action {
char *str;
action_id_T num;
enum keymap_id keymap_id;
keymap_id_T keymap_id;
char *desc;
unsigned int flags;
};
@ -39,7 +41,7 @@ struct action_list {
};
struct keymap {
char *str;
enum keymap_id keymap_id;
keymap_id_T keymap_id;
char *desc;
};
@ -95,7 +97,7 @@ enum kbdbind_flags {
struct keybinding {
OBJECT_HEAD(struct keybinding);
enum keymap_id keymap_id;
keymap_id_T keymap_id;
action_id_T action_id;
struct term_event_keyboard kbd;
int event;
@ -104,18 +106,18 @@ struct keybinding {
};
struct keybinding *add_keybinding(enum keymap_id keymap_id, action_id_T action_id, struct term_event_keyboard *kbd, int event);
int keybinding_exists(enum keymap_id keymap_id, struct term_event_keyboard *kbd, action_id_T *action_id);
struct keybinding *add_keybinding(keymap_id_T keymap_id, action_id_T action_id, struct term_event_keyboard *kbd, int event);
int keybinding_exists(keymap_id_T keymap_id, struct term_event_keyboard *kbd, action_id_T *action_id);
void free_keybinding(struct keybinding *);
const struct action *get_action(enum keymap_id keymap_id, action_id_T action_id);
char *get_action_name(enum keymap_id keymap_id, action_id_T action_id);
action_id_T get_action_from_string(enum keymap_id keymap_id, char *str);
char *get_action_name_from_keystroke(enum keymap_id keymap_id,
const struct action *get_action(keymap_id_T keymap_id, action_id_T action_id);
char *get_action_name(keymap_id_T keymap_id, action_id_T action_id);
action_id_T get_action_from_string(keymap_id_T keymap_id, char *str);
char *get_action_name_from_keystroke(keymap_id_T keymap_id,
const char *keystroke_str);
static inline unsigned int
action_is_anonymous_safe(enum keymap_id keymap_id, action_id_T action_id)
action_is_anonymous_safe(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -123,7 +125,7 @@ action_is_anonymous_safe(enum keymap_id keymap_id, action_id_T action_id)
}
static inline unsigned int
action_requires_view_state(enum keymap_id keymap_id, action_id_T action_id)
action_requires_view_state(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -131,7 +133,7 @@ action_requires_view_state(enum keymap_id keymap_id, action_id_T action_id)
}
static inline unsigned int
action_requires_location(enum keymap_id keymap_id, action_id_T action_id)
action_requires_location(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -139,7 +141,7 @@ action_requires_location(enum keymap_id keymap_id, action_id_T action_id)
}
static inline unsigned int
action_prefix_is_link_number(enum keymap_id keymap_id, action_id_T action_id)
action_prefix_is_link_number(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -147,7 +149,7 @@ action_prefix_is_link_number(enum keymap_id keymap_id, action_id_T action_id)
}
static inline unsigned int
action_requires_link(enum keymap_id keymap_id, action_id_T action_id)
action_requires_link(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -155,7 +157,7 @@ action_requires_link(enum keymap_id keymap_id, action_id_T action_id)
}
static inline unsigned int
action_requires_form(enum keymap_id keymap_id, action_id_T action_id)
action_requires_form(keymap_id_T keymap_id, action_id_T action_id)
{
const struct action *action = get_action(keymap_id, action_id);
@ -163,7 +165,7 @@ action_requires_form(enum keymap_id keymap_id, action_id_T action_id)
}
term_event_key_T read_key(const char *);
char *get_keymap_name(enum keymap_id);
char *get_keymap_name(keymap_id_T);
int parse_keystroke(const char *, struct term_event_keyboard *);
void add_keystroke_to_string(struct string *str, struct term_event_keyboard *kbd, int escape);
@ -182,9 +184,9 @@ void add_keystroke_to_string(struct string *str, struct term_event_keyboard *kbd
add_keystroke_to_string(str, &kbd, 0); \
} while (0)
action_id_T kbd_action(enum keymap_id, struct term_event *, int *);
struct keybinding *kbd_ev_lookup(enum keymap_id, struct term_event_keyboard *kbd, int *);
struct keybinding *kbd_nm_lookup(enum keymap_id, char *);
action_id_T kbd_action(keymap_id_T, struct term_event *, int *);
struct keybinding *kbd_ev_lookup(keymap_id_T, struct term_event_keyboard *kbd, int *);
struct keybinding *kbd_nm_lookup(keymap_id_T, char *);
int bind_do(char *, const char *, char *, int);
char *bind_act(char *, const char *);
@ -195,11 +197,11 @@ int bind_key_to_event_name(char *, const char *, char *,
char **);
#endif
void add_keystroke_action_to_string(struct string *string, action_id_T action_id, enum keymap_id keymap_id);
char *get_keystroke(action_id_T action_id, enum keymap_id keymap_id);
void add_keystroke_action_to_string(struct string *string, action_id_T action_id, keymap_id_T keymap_id);
char *get_keystroke(action_id_T action_id, keymap_id_T keymap_id);
void add_actions_to_string(struct string *string, action_id_T actions[],
enum keymap_id keymap_id, struct terminal *term);
keymap_id_T keymap_id, struct terminal *term);
extern struct module kbdbind_module;

View File

@ -66,7 +66,7 @@ keymap_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:
keystroke_str = jsval_to_string(ctx, r_tmp);
if (!keystroke_str) goto ret_null;
action_str = get_action_name_from_keystroke((enum keymap_id) *data,
action_str = get_action_name_from_keystroke((keymap_id_T) *data,
keystroke_str);
if (!action_str || !strcmp(action_str, "none")) goto ret_null;
@ -128,7 +128,7 @@ keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:
/* Ugly fact: we need to get the string from the id to give to bind_do,
* which will of course then convert the string back to an id... */
keymap_str = get_keymap_name((enum keymap_id) *data);
keymap_str = get_keymap_name((keymap_id_T) *data);
if (!keymap_str) return false;
@ -214,7 +214,7 @@ keymap_finalize(JSFreeOp *op, JSObject *obj)
}
static JSObject *
smjs_get_keymap_object(enum keymap_id keymap_id)
smjs_get_keymap_object(keymap_id_T keymap_id)
{
int *data;
JSObject *keymap_object;