return 1;
}
+DEF_CMD(global_set_command)
+{
+ struct editor *ed = container_of(ci->home, struct editor, root);
+
+ key_add(ed->commands, ci->str, ci->comm2);
+ return 1;
+}
+
struct pane *editor_new(void)
{
struct editor *ed = calloc(sizeof(*ed), 1);
if (!ed_map) {
ed_map = key_alloc();
key_add(ed_map, "global-set-attr", &global_set_attr);
+ key_add(ed_map, "global-set-command", &global_set_command);
}
pane_init(&ed->root, NULL, NULL);
return key_handle_focus(&ci);
}
+static inline int call_comm(char *key, struct pane *focus, int numeric, struct mark *m,
+ char *str, int extra, struct command *comm)
+{
+ struct cmd_info ci = {0};
+
+ ci.key = key;
+ ci.focus = focus;
+ ci.numeric = numeric;
+ ci.mark = m;
+ ci.str = str;
+ ci.extra = extra;
+ ci.comm2 = comm;
+ return key_handle_focus(&ci);
+}
+
static inline struct mark *call_mark(char *key, struct pane *focus, int numeric,
struct mark *m, int extra)
{
void edlib_init(struct editor *ed)
{
- key_add(ed->commands, "display-ncurses", &display_ncurses);
+ call_comm("global-set-command", &ed->root, 0, NULL, "display-ncurses",
+ 0, &display_ncurses);
}