This will allow other module loaders to register.
Signed-off-by: NeilBrown <neil@brown.name>
DEF_CMD(editor_load_module)
{
+ struct map *map = ci->home->data;
char *name = ci->str;
char buf[PATH_MAX];
void *h;
*
*/
h = dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
- if (!h)
- return 0;
- s = dlsym(h, "edlib_init");
- if (!s)
- return 0;
- s(ci->home);
- return 1;
+ if (h) {
+ s = dlsym(h, "edlib_init");
+ if (s) {
+ s(ci->home);
+ return 1;
+ }
+ }
+ return key_lookup_prefix(map, ci);
}
struct pane *editor_new(void)
return ed;
}
-
return comm->func(ci);
}
+int key_lookup_prefix(struct map *m, const struct cmd_info *ci)
+{
+ int pos = key_find(m, ci->key);
+ struct command *comm, *prev = NULL;
+ int len = strlen(ci->key);
+
+ while (pos < m->size && strncmp(m->keys[pos], ci->key, len) == 0) {
+ comm = GETCOMM(m->comms[pos]);
+ if (comm && comm != prev) {
+ int ret;
+ ((struct cmd_info*)ci)->comm = comm;
+ ret = comm->func(ci);
+ if (ret)
+ return ret;
+ prev = comm;
+ }
+ }
+ return 0;
+}
+
int key_lookup_cmd_func(const struct cmd_info *ci)
{
struct lookup_cmd *l = container_of(ci->comm, struct lookup_cmd, c);
void key_free(struct map *m);
int key_handle(const struct cmd_info *ci);
int key_lookup(struct map *m, const const struct cmd_info *ci);
+int key_lookup_prefix(struct map *m, const const struct cmd_info *ci);
struct command *key_lookup_cmd(struct map *m, char *c);
void key_add(struct map *map, char *k, struct command *comm);
void key_add_range(struct map *map, char *first, char *last,