File src/engine/keys.c changed (mode: 100644) (index b40db994d..1c1d49df6) |
... |
... |
free_chunk_data(key_chunk_t *chunk) |
305 |
305 |
{ |
{ |
306 |
306 |
free(chunk->conf.data.cmd); |
free(chunk->conf.data.cmd); |
307 |
307 |
} |
} |
|
308 |
|
|
|
309 |
|
if(chunk->foreign) |
|
310 |
|
{ |
|
311 |
|
free((char *)chunk->conf.descr); |
|
312 |
|
} |
308 |
313 |
} |
} |
309 |
314 |
|
|
310 |
315 |
void |
void |
|
... |
... |
vle_keys_foreign_add(const wchar_t lhs[], const key_conf_t *info, |
1015 |
1020 |
return -1; |
return -1; |
1016 |
1021 |
} |
} |
1017 |
1022 |
|
|
|
1023 |
|
key_conf_t conf = *info; |
|
1024 |
|
if(conf.descr != NULL) |
|
1025 |
|
{ |
|
1026 |
|
conf.descr = strdup(conf.descr); |
|
1027 |
|
if(conf.descr == NULL) |
|
1028 |
|
{ |
|
1029 |
|
return -1; |
|
1030 |
|
} |
|
1031 |
|
} |
|
1032 |
|
|
1018 |
1033 |
key_chunk_t *curr = add_keys_inner(root, lhs); |
key_chunk_t *curr = add_keys_inner(root, lhs); |
1019 |
1034 |
if(curr == NULL) |
if(curr == NULL) |
1020 |
1035 |
{ |
{ |
|
1036 |
|
free((char *)conf.descr); |
1021 |
1037 |
return -1; |
return -1; |
1022 |
1038 |
} |
} |
1023 |
1039 |
|
|
1024 |
1040 |
curr->type = (info->followed == FOLLOWED_BY_NONE) ? BUILTIN_KEYS |
curr->type = (info->followed == FOLLOWED_BY_NONE) ? BUILTIN_KEYS |
1025 |
1041 |
: BUILTIN_WAIT_POINT; |
: BUILTIN_WAIT_POINT; |
1026 |
1042 |
curr->foreign = 1; |
curr->foreign = 1; |
1027 |
|
curr->conf = *info; |
|
|
1043 |
|
curr->conf = conf; |
1028 |
1044 |
return 0; |
return 0; |
1029 |
1045 |
} |
} |
1030 |
1046 |
|
|
File src/engine/keys.h changed (mode: 100644) (index 967fc894f..1d1a0ec5e) |
... |
... |
typedef struct |
129 |
129 |
|
|
130 |
130 |
vle_suggest_func suggest; /* Suggestion function (can be NULL). Invoked for |
vle_suggest_func suggest; /* Suggestion function (can be NULL). Invoked for |
131 |
131 |
multikeys. */ |
multikeys. */ |
132 |
|
const char *descr; /* Brief description of the key (can be NULL). */ |
|
|
132 |
|
const char *descr; /* Brief description of the key (can be NULL). |
|
133 |
|
Not a literal for foreign keys, but needs |
|
134 |
|
to be `const` for arrays of builtin keys. */ |
133 |
135 |
void *user_data; /* User data for the key (can be NULL). */ |
void *user_data; /* User data for the key (can be NULL). */ |
134 |
136 |
} |
} |
135 |
137 |
key_conf_t; |
key_conf_t; |
|
... |
... |
int vle_keys_add(keys_add_info_t cmds[], size_t len, int mode); |
180 |
182 |
int vle_keys_add_selectors(keys_add_info_t cmds[], size_t len, int mode); |
int vle_keys_add_selectors(keys_add_info_t cmds[], size_t len, int mode); |
181 |
183 |
|
|
182 |
184 |
/* Registers a foreign builtin-like key (but among user's keys) or a selector |
/* Registers a foreign builtin-like key (but among user's keys) or a selector |
183 |
|
* (among builtin selectors, so they can't clash). Returns non-zero on error, |
|
184 |
|
* otherwise zero is returned. */ |
|
|
185 |
|
* (among builtin selectors, so they can't clash). The string pointed to by |
|
186 |
|
* info->descr field is copied. Returns non-zero on error, otherwise zero is |
|
187 |
|
* returned. */ |
185 |
188 |
int vle_keys_foreign_add(const wchar_t lhs[], const key_conf_t *info, |
int vle_keys_foreign_add(const wchar_t lhs[], const key_conf_t *info, |
186 |
189 |
int is_selector, int mode); |
int is_selector, int mode); |
187 |
190 |
|
|
File src/lua/vifm_keys.c changed (mode: 100644) (index 9a26c6369..63283d4dc) |
... |
... |
VLUA_API(keys_add)(lua_State *lua) |
80 |
80 |
wcscpy(lhs, tmp_lhs); |
wcscpy(lhs, tmp_lhs); |
81 |
81 |
free(tmp_lhs); |
free(tmp_lhs); |
82 |
82 |
|
|
83 |
|
const char *descr = ""; |
|
|
83 |
|
const char *descr = NULL; |
84 |
84 |
if(vlua_cmn_check_opt_field(lua, 1, "description", LUA_TSTRING)) |
if(vlua_cmn_check_opt_field(lua, 1, "description", LUA_TSTRING)) |
85 |
85 |
{ |
{ |
86 |
|
descr = vlua_state_store_string(vlua, lua_tostring(lua, -1)); |
|
|
86 |
|
descr = lua_tostring(lua, -1); |
87 |
87 |
} |
} |
88 |
88 |
|
|
89 |
89 |
int is_selector = 0; |
int is_selector = 0; |