return p;
}
+DEF_CMD(take_pane)
+{
+ struct call_return *cr = container_of(ci->comm, struct call_return, c);
+ cr->p = ci->focus;
+ return 1;
+}
+
struct doc *doc_new(struct editor *ed, char *type)
{
char buf[100];
struct cmd_info ci = {0};
+ struct call_return cr;
struct doc_data *dd;
init_doc_defaults();
sprintf(buf, "doc-%s", type);
ci.key = buf;
ci.focus = ci.home = &ed->root;
+ cr.c = take_pane;
+ cr.p = NULL;
+ ci.comm2 = &cr.c;
if (!key_lookup(ed->commands, &ci)) {
editor_load_module(ed, buf);
if (!key_lookup(ed->commands, &ci))
return NULL;
}
- dd = ci.focus->data;
+ dd = cr.p->data;
return dd->doc;
}
{
struct directory *dr = malloc(sizeof(*dr));
struct editor *ed = pane2ed(ci->focus);
+ struct pane *p;
doc_init(&dr->doc);
dr->doc.map = doc_map;
INIT_LIST_HEAD(&dr->ents);
dr->fname = NULL;
- ci->focus = doc_attach(ed->root.focus, &dr->doc);
- return 1;
+ p = doc_attach(ed->root.focus, &dr->doc);
+ if (p)
+ return comm_call(ci->comm2, "callback:doc", p, 0, NULL, NULL, 0);
+ return -1;
}
DEF_CMD(dir_load_file)
{
struct text *t = malloc(sizeof(*t));
struct editor *ed = pane2ed(ci->focus);
+ struct pane *p;
t->alloc = NULL;
INIT_LIST_HEAD(&t->text);
t->doc.map = text_map;
t->fname = NULL;
text_new_alloc(t, 0);
- ci->focus = doc_attach(ed->root.focus, &t->doc);
- return 1;
+ p = doc_attach(ed->root.focus, &t->doc);
+ if (p)
+ return comm_call(ci->comm2, "callback:doc", p, 0, NULL, NULL, 0);
+ return -1;
}
static int count_bytes(struct text *t, struct mark *from, struct mark *to)