call5("Mode:set-extra", p, 0, NULL, NULL, extra);
}
+DEF_CMD(pane_callback)
+{
+ struct call_return *cr = container_of(ci->comm, struct call_return, c);
+ cr->p = ci->focus;
+ return 1;
+}
+
struct pane *pane_attach(struct pane *p, char *type, struct pane *dp,
char *arg)
{
struct cmd_info ci = {0};
struct editor *ed = pane2ed(p);
char *com;
+ struct call_return cr;
+
+ cr.c = pane_callback;
+ cr.p = NULL;
asprintf(&com, "attach-%s", type);
ci.key = com;
ci.home = dp;
ci.focus = p;
ci.str = arg;
+ ci.comm2 = &cr.c;
if (!key_lookup(ed->commands, &ci)) {
char *mod;
if (strcmp(type, "global-keymap")==0)
asprintf(&mod, "lib-%s", type);
editor_load_module(ed, mod);
free(mod);
- if (!key_lookup(ed->commands, &ci))
- ci.focus = NULL;
+ key_lookup(ed->commands, &ci);
}
free(com);
- return ci.focus;
+ return cr.p;
}
void pane_clear(struct pane *p, char *attrs)
struct command c;
struct mark *m;
char *s;
+ struct pane *p;
};
static inline int call_comm(char *key, struct pane *focus, int numeric, struct mark *m,
{
struct cmd_info ci = {0};
+ if (!comm)
+ return -1;
ci.key = key;
ci.focus = focus;
ci.numeric = numeric;
esi->watch = search_again;
doc_add_view(ci->focus, &esi->watch, 0);
- ci->focus = pane_final_child(ci->focus);
- p = pane_register(ci->focus, 0, &search_handle.c, esi, NULL);
- ci->focus = p;
+ p = pane_final_child(ci->focus);
+ p = pane_register(p, 0, &search_handle.c, esi, NULL);
+ if (p)
+ comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
return 1;
}
DEF_CMD(input_attach)
{
struct input_mode *im = malloc(sizeof(*im));
+ struct pane *p;
register_map();
im->numeric = NO_NUMERIC;
im->extra = 0;
- ci->focus = pane_register(ci->focus, 0, &input_handle.c, im, NULL);
- return 1;
+ p = pane_register(ci->focus, 0, &input_handle.c, im, NULL);
+ if (p)
+ return comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
+ return -1;
}
void edlib_init(struct editor *ed)
p = pane_final_child(p);
p = pane_register(p, 0, &keymap_handle, kd, NULL);
pane_check_size(p);
- ci->focus = p;
- return 1;
+ if (p)
+ return comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
+ return -1;
}
void edlib_init(struct editor *ed)
{
struct mlinfo *mli = malloc(sizeof(*mli));
struct pane *p = ci->focus;
+ struct pane *ret;
mli->message = NULL;
- ci->focus = pane_register(p, 0, &messageline_handle, mli, NULL);
+ ret = pane_register(p, 0, &messageline_handle, mli, NULL);
mli->line = pane_register(p, 1, &messageline_handle, mli, NULL);
pane_focus(ci->focus);
- return 1;
+ return comm_call(ci->comm2, "callback:attach", ret, 0, NULL, NULL, 0);
}
ci2.str2 = "Abort";
key_handle_focus(&ci2);
- ci->focus = ppi->popup;
- return 1;
+ return comm_call(ci->comm2, "callback:attach", ppi->popup, 0, NULL, NULL, 0);
}
void edlib_init(struct editor *ed)
ti->direction = Neither;
INIT_LIST_HEAD(&ti->tiles);
pane_check_size(p);
- ci->focus = p;
attr_set_str(&p->attrs, "borders", "BL", -1);
- return 1;
+ return comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
}
static struct pane *tile_split(struct pane *p, int horiz, int after)
if (strchr(borderstr, 'L')) borders |= BORDER_LEFT;
if (strchr(borderstr, 'R')) borders |= BORDER_RIGHT;
- ci->focus = do_view_attach(ci->focus, borders);
- return ci->focus != NULL;
+ return comm_call(ci->comm2, "callback:attach", do_view_attach(ci->focus, borders),
+ 0, NULL, NULL, 0);
}
DEF_CMD(view_click)