alloc(dd, pane);
p = pane_register(parent, 0, &doc_handle.c, dd);
- pane_damaged(p, DAMAGED_VIEW);
if (!p)
return NULL;
+ pane_damaged(p, DAMAGED_VIEW);
m = point_new(doc);
if (!m) {
ei->cmd = ed_handle;
ei->cmd.m = &ei->map;
ed = pane_register_root(&ei->cmd.c, ei, sizeof(ei));
+ if (!ed)
+ return NULL;
+
+ doc_setup(ed);
+ log_setup(ed);
+ window_setup(ed);
- if (ed) {
- doc_setup(ed);
- log_setup(ed);
- window_setup(ed);
- }
return ed;
}
INIT_LIST_HEAD(&log_doc->log);
log_pane = doc_register(ed, &log_handle.c, log_doc);
+ if (!log_pane)
+ return;
+
fname = getenv("EDLIB_LOG");
if (!fname || !*fname)
return;
INIT_LIST_HEAD(&dr->ents);
dr->fname = NULL;
p = doc_register(ci->home, &dir_handle.c, dr);
- if (p)
- return comm_call(ci->comm2, "callback:doc", p);
- return Efail;
+ if (!p)
+ return Efail;
+
+ return comm_call(ci->comm2, "callback:doc", p);
}
DEF_CMD(dir_new2)
struct pane *p;
p = pane_register(ci->focus, 0, &dirview_handle.c);
- if (p)
- pane_clone_children(ci->home, p);
+ if (!p)
+ return Efail;
+
+ pane_clone_children(ci->home, p);
return 1;
}
alloc(l, pane);
INIT_LIST_HEAD(&l->content);
p = doc_register(ci->home, &list_handle.c, l);
- if (p)
- return comm_call(ci->comm2, "callback:doc", p);
- return Efail;
+ if (!p)
+ return Efail;
+
+ return comm_call(ci->comm2, "callback:doc", p);
}
static void list_init_map(void)
alloc(mpi, pane);
h = doc_register(ci->home, &mp_handle.c, mpi);
- if (h) {
- mpi->doc.refcnt = mp_mark_refcnt;
- attr_set_str(&h->attrs, "render-default", "text");
- return comm_call(ci->comm2, "callback:doc", h);
+ if (!h) {
+ unalloc(mpi, pane);
+ return Efail;
}
- free(mpi);
- return Efail;
+ mpi->doc.refcnt = mp_mark_refcnt;
+ attr_set_str(&h->attrs, "render-default", "text");
+ return comm_call(ci->comm2, "callback:doc", h);
}
void edlib_init(struct pane *ed safe)
t->as.last_change = 0;
text_new_alloc(t, 0);
p = doc_register(ci->home, &text_handle.c, t);
- if (p)
- return comm_call(ci->comm2, "callback:doc", p);
- return Efail;
+ if (!p)
+ return Efail;
+
+ return comm_call(ci->comm2, "callback:doc", p);
}
DEF_CMD(text_new2)
esi->backwards = ci->num & 1;
p = pane_register(ci->focus, 0, &search_handle.c, esi);
- if (p) {
- call("doc:request:doc:replaced", p);
- attr_set_str(&p->attrs, "status-line", " Search: case insensitive ");
- comm_call(ci->comm2, "callback:attach", p);
- pane_add_notify(p, esi->target, "Notify:Close");
+ if (!p)
+ return Efail;
+
+ call("doc:request:doc:replaced", p);
+ attr_set_str(&p->attrs, "status-line", " Search: case insensitive ");
+ comm_call(ci->comm2, "callback:attach", p);
+ pane_add_notify(p, esi->target, "Notify:Close");
+
+ if (ci->num & 2)
+ call("K:A-%", p);
- if (ci->num & 2)
- call("K:A-%", p);
- }
return 1;
}
alloc(hi, pane);
p = pane_register(ci->focus, 0, &highlight_handle.c, hi);
- if (p) {
- hi->view = home_call(ci->focus, "doc:add-view", p) - 1;
- hi->replace_view = home_call(ci->focus, "doc:add-view", p) - 1;
- comm_call(ci->comm2, "callback:attach", p);
- }
+ if (!p)
+ return Efail;
+
+ hi->view = home_call(ci->focus, "doc:add-view", p) - 1;
+ hi->replace_view = home_call(ci->focus, "doc:add-view", p) - 1;
+ comm_call(ci->comm2, "callback:attach", p);
+
return 1;
}
*/
Py_INCREF(self);
self->pane = pane_register(parent->pane, z, &self->cmd, self);
- if (self->pane)
- pane_get(self->pane);
+ if (!self->pane)
+ return -1;
+
+ pane_get(self->pane);
return 0;
}
alloc(as, pane);
as->speller = safe_cast to_aspell_speller(ret);
p = pane_register(ci->focus, 0, &aspell_handle.c, as);
- if (p) {
- call("doc:request:aspell:check", p);
- call("doc:request:aspell:suggest", p);
- call("doc:request:aspell:set-dict", p);
- call("doc:request:aspell:add-word", p);
- call("doc:request:aspell:save", p);
- }
+ if (!p)
+ return Efail;
+
+ call("doc:request:aspell:check", p);
+ call("doc:request:aspell:suggest", p);
+ call("doc:request:aspell:set-dict", p);
+ call("doc:request:aspell:add-word", p);
+ call("doc:request:aspell:save", p);
+
return 1;
}
p2 = NULL;
if (p2)
p2 = pane_register(p2, 0, &autosave_handle.c);
- if (p2) {
- attr_set_str(&p2->attrs, "orig_name", f);
- attr_set_str(&p2->attrs, "autosave_name", a);
- attr_set_str(&p2->attrs, "autosave_type", autosave_type);
- if (doc)
- pane_add_notify(p2, doc, "doc:replaced");
- }
+ if (!p2)
+ return Efail;
+
+ attr_set_str(&p2->attrs, "orig_name", f);
+ attr_set_str(&p2->attrs, "autosave_name", a);
+ attr_set_str(&p2->attrs, "autosave_type", autosave_type);
+ if (doc)
+ pane_add_notify(p2, doc, "doc:replaced");
return 1;
}
im->num2 = 0;
p = pane_register(ci->focus, 0, &input_handle.c, im);
- if (p)
- return comm_call(ci->comm2, "callback:attach", p);
- return Efail;
+ if (!p)
+ return Efail;
+
+ return comm_call(ci->comm2, "callback:attach", p);
}
void edlib_init(struct pane *ed safe)
0, NULL, "popup:close");
if (p)
p = pane_register(p, 0, &find_handle.c, "shellcmd");
- if (p && ci->comm2)
+ if (!p)
+ return Efail;
+ if (ci->comm2)
comm_call(ci->comm2, "cb", p);
return 1;
}
alloc(rf, pane);
p = pane_register(parent, 0, &render_format2_handle.c, rf);
- if (p && !pane_attr_get(parent, "format:no-linecount")) {
+ if (!p)
+ return p;
+ if (!pane_attr_get(parent, "format:no-linecount")) {
struct pane *p2 = call_ret(pane, "attach-line-count", p);
if (p2)
p = p2;