This makes sense and means we don't need to find the 'ed'.
Signed-off-by: NeilBrown <neil@brown.name>
struct map *ed_map;
-DEF_LOOKUP_CMD(ed_handle, ed_map);
+DEF_CMD(ed_handle)
+{
+ struct editor *ed = container_of(ci->home, struct editor, root);
+ int ret;
+
+ ret = key_lookup(ed_map, ci);
+ if (ret)
+ return ret;
+ return key_lookup(ed->commands, ci);
+}
DEF_CMD(null_display_handle)
{
}
pane_init(&ed->root, NULL, NULL);
- ed->root.handle = &ed_handle.c;
+ ed->root.handle = &ed_handle;
ed->root.data = NULL;
/* The first child of the root is the 'null_display'
cr.c = take_pane;
cr.p = NULL;
ci.comm2 = &cr.c;
- if (!key_lookup(ed->commands, &ci))
+ if (key_handle(&ci) <= 0)
exit(1);
root = cr.p;
global = pane_attach(root, "messageline", NULL, NULL);
ci.home = ci.focus = p;
ci.key = "python-load";
ci.str = "python/test.py";
- key_lookup(ed->commands, &ci);
+ key_handle(&ci);
pane_refresh(&ed->root);
event_base_dispatch(base);
str = doc_getstr(esi->search, NULL);
ci2.str = str;
ci2.key = "text-search";
- ret = key_lookup(pane2ed(esi->target)->commands, &ci2);
+ ret = key_handle(&ci2);
if (ret == 0)
pfx = "Search (unavailable): ";
else if (ret == -2) {
Ed = Pane_Frompane(&ed->root);
PyDict_SetItemString(globals, "editor", Ed);
- PyDict_SetItemString(globals, "pane", Pane_Frompane(ci->home));
+ PyDict_SetItemString(globals, "pane", Pane_Frompane(ci->focus));
PyDict_SetItemString(globals, "edlib", EdlibModule);
PyRun_FileExFlags(fp, fname, Py_file_input, globals, globals, 0, NULL);
PyErr_Print();
DEF_CMD(count_lines)
{
- struct doc *d = doc_from_pane(ci->home);
+ struct doc *d = doc_from_pane(ci->focus);
/* FIXME optimise this away most of the time */
count_calculate(d, NULL, NULL);
char msg[100];
int i;
int mid;
- struct editor *ed = pane2ed(ci->home);
struct doc *d = doc_from_pane(ci->home);
pane_check_size(p);
ci2.key = "CountLines";
ci2.home = ci2.focus = p;
ci2.mark = m;
- key_lookup(ed->commands, &ci2);
+ key_handle(&ci2);
ln = attr_find_int(*mark_attr(m), "lines");
l = attr_find_int(d->attrs, "lines");
ci2.mark = m;
ci2.str = ci->str;
ci2.key = "text-search";
- ret = key_lookup(pane2ed(ci->focus)->commands, &ci2);
+ ret = key_handle(&ci2);
if (ret > 1)
call3("Move-to", ci->focus, 0, m);
DEF_CMD(render_hex_eol)
{
struct doc *d = doc_from_pane(ci->home);
- struct editor *ed = pane2ed(ci->home);
wint_t ch = 1;
int rpt = RPT_NUM(ci);
int pos;
ci2.key = "CountLines";
ci2.home = ci2.focus = ci->home;
ci2.mark = ci->mark;
- key_lookup(ed->commands, &ci2);
+ key_handle(&ci2);
pos = attr_find_int(*mark_attr(ci->mark), "chars");
pos = attr_find_int(*mark_attr(ci->mark), "chars");
ci2.key = "CountLines";
ci2.home = ci2.focus = ci->home;
ci2.mark = ci->mark;
- key_lookup(d->ed->commands, &ci2);
+ key_handle(&ci2);
pos = attr_find_int(*mark_attr(ci->mark), "chars");
buf_init(&ret);
ci2.key = "CountLines";
ci2.home = ci2.focus = ci->home;
ci2.mark = ci->mark;
- key_lookup(d->ed->commands, &ci2);
+ key_handle(&ci2);
from = attr_find_int(*mark_attr(ci->mark), "chars");
to = from & ~0xF;