*/
if (!ci->home->parent)
return -1;
- return call_home(ci->home->parent, ci->key, ci->home, ci->numeric, ci->mark, NULL);
+ return call_home(ci->home->parent, ci->key, ci->home, ci->numeric, ci->mark);
}
DEF_CMD(doc_mymark)
}
if (strcmp(ci->key, "Replace") == 0) {
- return call_home7(dd->doc, "doc:replace", ci->focus, 1, ci->mark, ci->str,
- ci->extra, NULL, dd->point, NULL);
+ return call_home(dd->doc, "doc:replace", ci->focus, 1, ci->mark, ci->str,
+ ci->extra, dd->point);
}
if (strcmp(ci->key, "get-attr") == 0) {
strncmp(ci->key, "Notify:doc:", 11) != 0)
/* doesn't get sent to the doc */
return 0;
- return call_home9(dd->doc, ci->key, ci->focus, ci->numeric,
- ci->mark ?: dd->point, ci->str, ci->extra, ci->str2,
- ci->mark2, ci->comm2, ci->x, ci->y);
+ return call_home(dd->doc, ci->key, ci->focus, ci->numeric,
+ ci->mark ?: dd->point, ci->str,
+ ci->extra, ci->mark2, ci->str2,
+ ci->comm2, ci->x, ci->y);
}
static struct pane *doc_assign(struct pane *p safe, struct pane *doc safe,
snprintf(buf, sizeof(buf), "attach-doc-%s", type);
np = call_pane(buf, p, 0, NULL, 0);
if (np && parent)
- call_home(np, "doc:set-parent", parent, 0, NULL, NULL);
+ call_home(np, "doc:set-parent", parent);
return np;
}
#define call2(key, focus) \
do_call(key, focus, 0, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, NULL)
+/* Often the 'home' arg is not need and defaults to 'focus', so it is at the
+ * end of 'call'. Often enough it has an important place, so have a set of
+ * macros with 'home' first
+ */
+#define call_home(...) VFUNC(call_home, __VA_ARGS__)
+#define call_home12(home, key, focus, numeric, mark, str, extra, mark2, str2, comm2, x, y) \
+ do_call(key, focus, numeric, mark, str, extra, mark2, str2, comm2, x, y, home)
+#define call_home10(home, key, focus, numeric, mark, str, extra, mark2, str2, comm2) \
+ do_call(key, focus, numeric, mark, str, extra, mark2, str2, comm2, 0, 0, home)
+#define call_home9(home, key, focus, numeric, mark, str, extra, mark2, str2) \
+ do_call(key, focus, numeric, mark, str, extra, mark2, str2, NULL, 0, 0, home)
+#define call_home8(home, key, focus, numeric, mark, str, extra, mark2) \
+ do_call(key, focus, numeric, mark, str, extra, mark2, NULL, NULL, 0, 0, home)
+#define call_home7(home, key, focus, numeric, mark, str, extra) \
+ do_call(key, focus, numeric, mark, str, extra, NULL, NULL, NULL, 0, 0, home)
+#define call_home6(home, key, focus, numeric, mark, str) \
+ do_call(key, focus, numeric, mark, str, 0, NULL, NULL, NULL, 0, 0, home)
+#define call_home5(home, key, focus, numeric, mark) \
+ do_call(key, focus, numeric, mark, NULL, 0, NULL, NULL, NULL, 0, 0, home)
+#define call_home4(home, key, focus, numeric) \
+ do_call(key, focus, numeric, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, home)
+#define call_home3(home, key, focus) \
+ do_call(key, focus, 0, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, home)
static inline int do_call(char *key safe, struct pane *focus safe, int numeric, struct mark *m,
return key_handle(&ci);
}
-static inline int call_home7(struct pane *home safe, char *key safe, struct pane *focus safe,
- int numeric, struct mark *m, char *str, int extra, char *str2, struct mark *m2, struct command *comm)
-{
- struct cmd_info ci = {.key=key, .focus=focus, .home=home, .comm = safe_cast 0};
-
- ci.numeric = numeric;
- ci.mark = m;
- ci.str = str;
- ci.extra = extra;
- ci.str2 = str2;
- ci.mark2 = m2;
- ci.comm2 = comm;
- return key_handle(&ci);
-}
-
-static inline int call_home9(struct pane *home safe, char *key safe, struct pane *focus safe,
- int numeric, struct mark *m, char *str, int extra, char *str2, struct mark *m2, struct command *comm, int x, int y)
-{
- struct cmd_info ci = {.key=key, .focus=focus, .home=home, .comm = safe_cast 0};
-
- ci.numeric = numeric;
- ci.mark = m;
- ci.str = str;
- ci.extra = extra;
- ci.str2 = str2;
- ci.mark2 = m2;
- ci.comm2 = comm;
- ci.x = x;
- ci.y = y;
- return key_handle(&ci);
-}
-
-static inline int call_home(struct pane *home safe, char *key safe, struct pane *focus safe,
- int numeric, struct mark *m, struct command *comm)
-{
- struct cmd_info ci = {.key=key, .focus=focus, .home=home, .comm = safe_cast 0};
-
- ci.numeric = numeric;
- ci.mark = m;
- ci.comm2 = comm;
- return key_handle(&ci);
-}
-
-
static inline int call_xy(char *key safe, struct pane *focus safe, int numeric,
char *str, char *str2, int x, int y)
{
getmaxyx(stdscr, p->h, p->w);
- call_home(p, "event:read", p, 0, NULL, &input_handle);
- call_home(p, "event:signal", p, SIGWINCH, NULL, &handle_winch);
+ call_home(p, "event:read", p, 0, NULL, NULL, 0, NULL, NULL, &input_handle);
+ call_home(p, "event:signal", p, SIGWINCH, NULL, NULL, 0, NULL, NULL, &handle_winch);
pane_damaged(p, DAMAGED_SIZE);
return p;
}
call("Message", focus, 0, NULL,
"File not modified - no need to save.");
else
- call_home(p, "doc:save-file", focus, 0, NULL, NULL);
+ call_home(p, "doc:save-file", focus);
}
static void check_name(struct docs *docs safe, struct pane *pane safe)
if (p == doc->doc.home)
/* The docs doc is attached separately */
return 0;
- call_home(p, "doc:set-parent", doc->collection,
- 0, NULL, NULL);
- call_home(p, "Request:Notify:doc:status-changed", doc->collection,
- 0, NULL, NULL);
+ call_home(p, "doc:set-parent", doc->collection);
+ call_home(p, "Request:Notify:doc:status-changed", doc->collection);
if (p->parent)
doc_checkname(p, doc, ci->numeric);
return 0;
call_comm("global-set-command", ci->home, 0, NULL,
"doc:appeared-docs-register", 0, &doc->callback);
- call_home(p, "doc:set-parent", doc->collection,
- 0, NULL, NULL);
+ call_home(p, "doc:set-parent", doc->collection);
return comm_call(ci->comm2, "callback:doc", doc->doc.home, 0, NULL, NULL, 0);
}
else
attr_set_str(&h->attrs, "email:actions", "hide:open");
- call_home(mp, "multipart-add", h, hidden, NULL, NULL);
- call_home(mp, "multipart-add", spacer, 0, NULL, NULL);
+ call_home(mp, "multipart-add", h, hidden);
+ call_home(mp, "multipart-add", spacer, 0);
return 1;
}
if (!hdr)
break;
- call_home7(hdr, "get-header", hdr, 0, NULL, "content-type",
- 0, "cmd", NULL, NULL);
- call_home7(hdr, "get-header", hdr, 0, NULL, "content-transfer-encoding",
- 0, "cmd", NULL, NULL);
+ call_home(hdr, "get-header", hdr, 0, NULL, "content-type",
+ 0, NULL, "cmd");
+ call_home(hdr, "get-header", hdr, 0, NULL, "content-transfer-encoding",
+ 0, NULL, "cmd");
ptype = attr_find(hdr->attrs, "rfc822-content-type");
pxfer = attr_find(hdr->attrs, "rfc822-content-transfer-encoding");
point = vmark_new(doc, MARK_POINT);
if (!point)
goto out;
- call_home7(h2, "get-header", doc, 0, point, "From", 0, NULL, NULL, NULL);
- call_home7(h2, "get-header", doc, 0, point, "Date", 0, NULL, NULL, NULL);
- call_home7(h2, "get-header", doc, 0, point, "Subject", 0, "text", NULL, NULL);
- call_home7(h2, "get-header", doc, 0, point, "To", 0, "list", NULL, NULL);
- call_home7(h2, "get-header", doc, 0, point, "Cc", 0, "list", NULL, NULL);
-
- call_home7(h2, "get-header", h2, 0, NULL, "MIME-Version", 0, "cmd", NULL, NULL);
- call_home7(h2, "get-header", h2, 0, NULL, "content-type", 0, "cmd", NULL, NULL);
- call_home7(h2, "get-header", h2, 0, NULL, "content-transfer-encoding", 0, "cmd", NULL, NULL);
+ call_home(h2, "get-header", doc, 0, point, "From");
+ call_home(h2, "get-header", doc, 0, point, "Date");
+ call_home(h2, "get-header", doc, 0, point, "Subject", 0, NULL, "text");
+ call_home(h2, "get-header", doc, 0, point, "To", 0, NULL, "list");
+ call_home(h2, "get-header", doc, 0, point, "Cc", 0, NULL, "list");
+
+ call_home(h2, "get-header", h2, 0, NULL, "MIME-Version", 0, NULL, "cmd");
+ call_home(h2, "get-header", h2, 0, NULL, "content-type", 0, NULL, "cmd");
+ call_home(h2, "get-header", h2, 0, NULL, "content-transfer-encoding", 0, NULL, "cmd");
mime = attr_find(h2->attrs, "rfc822-mime-version");
if (mime)
mime = get_822_word(mime);
if (!p)
goto out;
attr_set_str(&doc->attrs, "email:actions", "hide");
- call_home(p, "multipart-add", doc, 0, NULL, NULL);
- call_home(p, "multipart-add", ei->spacer, 0, NULL, NULL);
+ call_home(p, "multipart-add", doc);
+ call_home(p, "multipart-add", ei->spacer);
call("doc:set:autoclose", doc, 1, NULL, NULL, 0);
if (handle_content(ei->email, type, xfer, start, end, p, ei->spacer, 0) == 0)
* Assume part is not empty...
*/
return 2;
- return call_home7(mpi->parts[ci->mark->ref.docnum].pane,
- "doc:mark-same", ci->focus, 0, d1.m, NULL,
- 0, NULL, d2.m, NULL);
+ return call_home(mpi->parts[ci->mark->ref.docnum].pane,
+ "doc:mark-same", ci->focus, 0, d1.m, NULL,
+ 0, d2.m);
}
/* Marks are in different visible documents.
!mpi->parts[m->ref.docnum].visible)
ret = -1;
else
- ret = call_home7(mpi->parts[m->ref.docnum].pane,
- ci->key, ci->focus, ci->numeric, m1, ci->str,
- ci->extra,ci->str2, NULL, ci->comm2);
+ ret = call_home(mpi->parts[m->ref.docnum].pane,
+ ci->key, ci->focus, ci->numeric, m1, ci->str,
+ ci->extra, NULL, ci->str2, ci->comm2);
while (ret == CHAR_RET(WEOF) || ret == -1) {
if (!ci->extra && m == ci->mark) {
/* don't change ci->mark when not moving */
!mpi->parts[m->ref.docnum].visible)
ret = -1;
else
- ret = call_home7(mpi->parts[m->ref.docnum].pane,
- ci->key, ci->focus, ci->numeric, m1, ci->str,
- ci->extra,ci->str2, NULL, ci->comm2);
+ ret = call_home(mpi->parts[m->ref.docnum].pane,
+ ci->key, ci->focus, ci->numeric, m1, ci->str,
+ ci->extra, NULL, ci->str2, ci->comm2);
}
if (ci->extra)
reset_mark(ci->mark);
(d > ci->mark->ref.docnum), m1);
}
- ret = call_home7(mpi->parts[d].pane,
- ci->key, ci->focus, ci->numeric, m1, ci->str,
- ci->extra,ci->str2, NULL, ci->comm2);
+ ret = call_home(mpi->parts[d].pane,
+ ci->key, ci->focus, ci->numeric, m1, ci->str,
+ ci->extra, NULL, ci->str2, ci->comm2);
if (d != ci->mark->ref.docnum)
mark_free(m1);
return ret;
change_part(mpi, ci->mark, n, 0);
pane_add_notify(ci->home, ci->focus, "Notify:Close");
- call_home(ci->focus, "Request:Notify:doc:viewers", ci->home, 0, NULL, NULL);
+ call_home(ci->focus, "Request:Notify:doc:viewers", ci->home);
return 1;
}
return 0;
if (strcmp(ci->key, "doc:write-file") == 0)
- return call_home7(p, ci->key, ci->focus, ci->numeric,
- ci->mark ?: cd->start,
- ci->str, ci->extra, ci->str2,
- ci->mark2 ?: cd->end,
- ci->comm2);
+ return call_home(p, ci->key, ci->focus, ci->numeric,
+ ci->mark ?: cd->start,
+ ci->str, ci->extra,
+ ci->mark2 ?: cd->end, ci->str2,
+ ci->comm2);
if (!ci->mark && !ci->mark2)
/* No mark, do give it straight to parent */
cli = calloc(1, sizeof(*cli));
cli->view_num = doc_add_view(ci->focus);
p = pane_register(NULL, 0, &handle_count_lines, cli, NULL);
- call_home(ci->focus, "Request:Notify:doc:Replace", p, 0, NULL, NULL);
- call_home(ci->focus, "Request:Notify:doc:CountLines", p,
- 0, NULL, NULL);
+ call_home(ci->focus, "Request:Notify:doc:Replace", p);
+ call_home(ci->focus, "Request:Notify:doc:CountLines", p);
call("Notify:doc:CountLines", ci->focus, 1, ci->mark);
}
if (ci->mark)
p = call_pane("doc:attach", doc, 0, NULL, 0);
if (!p)
return -1;
- call_home(p, "doc:assign", doc, 0, NULL, NULL);
+ call_home(p, "doc:assign", doc);
call_pane7("attach-shellcmd", p, 0, NULL, 0, ci->str, NULL);
doc_attach_view(par, doc, "default:viewer");
return 1;
if (call("Draw:image", focus, 1, NULL, s+6, 0) <= 0)
pane_clear(p, NULL);
} else if (strncmp(s, "call:", 5) == 0) {
- if (call_home(focus, s+5, p, 0, m, NULL) <= 0)
+ if (call_home(focus, s+5, p, 0, m) <= 0)
pane_clear(p, NULL);
} else
pane_clear(p, NULL);