return ret;
}
+DEF_CMD(pane_callback)
+{
+ struct call_return *cr = container_of(ci->comm, struct call_return, c);
+ cr->p = ci->focus;
+ return 1;
+}
+
struct pane *render_attach(char *name, struct pane *parent)
{
char buf[100];
struct cmd_info ci = {0};
int ret;
+ struct call_return cr;
+
+ cr.c = pane_callback;
+ cr.p = NULL;
/* always attach a renderer as a leaf */
parent = pane_final_child(parent);
sprintf(buf, "render-%s-attach", name);
ci.key = buf;
ci.focus = parent;
+ ci.comm2 = &cr.c;
ret = key_lookup(pane2ed(parent)->commands, &ci);
if (ret)
- return ci.focus;
+ return cr.p;
sprintf(buf, "render-%s", name);
editor_load_module(pane2ed(parent), buf);
sprintf(buf, "render-%s-attach", name);
ret = key_lookup(pane2ed(parent)->commands, &ci);
if (ret)
- return ci.focus;
+ return cr.p;
return NULL;
}
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)
{
pane_check_size(complete);
cd->prefix = strdup("");
- ci->focus = complete;
- return 1;
+ return comm_call(ci->comm2, "callback:attach", complete, 0, NULL, NULL, 0);
}
void edlib_init(struct editor *ed)
int fields;
};
-DEF_CMD(render_format_attach);
-
DEF_CMD(render_line)
{
char *body = pane_attr_get(ci->focus, "line-format");
return 1;
}
+static struct pane *do_render_format_attach(struct pane *parent);
DEF_CMD(format_clone)
{
struct pane *c;
+ struct pane *p;
- render_format_attach_func(ci);
+ p = do_render_format_attach(ci->focus);
c = pane_child(ci->home);
if (c)
- return pane_clone(c, ci->focus);
+ return pane_clone(c, p);
return 1;
}
DEF_LOOKUP_CMD(render_format_handle, rf_map);
-REDEF_CMD(render_format_attach)
+static struct pane *do_render_format_attach(struct pane *parent)
{
struct rf_data *rf = malloc(sizeof(*rf));
struct pane *p;
- struct pane *parent = ci->focus;
if (!rf_map)
render_format_register_map();
p = pane_register(parent, 0, &render_format_handle.c, rf, NULL);
attr_set_str(&p->attrs, "render-wrap", "no", -1);
render_attach("lines", p);
+ return p;
+}
- ci->focus = p;
- return 1;
+DEF_CMD(render_format_attach)
+{
+ struct pane *p;
+
+ p = do_render_format_attach(ci->focus);
+
+ return comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0);
}
void edlib_init(struct editor *ed)
DEF_CMD(render_hex_attach)
{
- ci->focus = do_render_hex_attach(ci->focus);
- return 1;
+ return comm_call(ci->comm2, "callback:attach",
+ do_render_hex_attach(ci->focus),
+ 0, NULL, NULL, 0);
}
void edlib_init(struct editor *ed)
rl->typenum = doc_add_view(ci->focus, &rl->type, 0);
rl->pane = pane_register(ci->focus, 0, &render_lines_handle.c, rl, NULL);
- ci->focus = rl->pane;
- return 1;
+ return comm_call(ci->comm2, "callback:attach", rl->pane,
+ 0, NULL, NULL, 0);
}
void edlib_init(struct editor *ed)