From: NeilBrown Date: Fri, 11 Dec 2015 00:21:52 +0000 (+1100) Subject: Start changing rules about ->focus and ->home X-Git-Tag: lca2016~66 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=1898f1ac80248904f4f04c7df562d5e04692b2b3;p=edlib.git Start changing rules about ->focus and ->home I'm still thinking this through.... 'home' must always be the pane where the command was found. 'focus' should be where the action happens. Previously 'home' would always end up being a parent of 'focus' but sometimes, particularly calls from popup to target, we want something else. So allow the caller to set 'focus' to themselves and 'home' to where to start looking for the command. If either is home is not set, focuses it moved out to a leaf first. This still seems a bit clumsy... Signed-off-by: NeilBrown --- diff --git a/core-keymap.c b/core-keymap.c index 60f60948..2170e997 100644 --- a/core-keymap.c +++ b/core-keymap.c @@ -295,7 +295,7 @@ int key_lookup_cmd_func(const struct cmd_info *ci) int key_handle(const struct cmd_info *ci) { struct cmd_info *vci = (struct cmd_info*)ci; - struct pane *p = ci->focus; + struct pane *p; int ret = 0; if (ci->comm) @@ -304,6 +304,13 @@ int key_handle(const struct cmd_info *ci) vci->hx = ci->x; vci->hy = ci->y; + /* If 'home' is set, search from there, else search + * from focus + */ + p = ci->home; + if (!p) + p = ci->focus; + while (ret == 0 && p) { if (p->handle) { vci->home = p; @@ -325,7 +332,11 @@ int key_handle(const struct cmd_info *ci) static int __key_handle_focus(struct cmd_info *ci, int savepoint) { /* Handle this in the focus pane, so x,y are irrelevant */ - struct pane *p = ci->focus; + struct pane *p = ci->home; + if (!p) + p = ci->focus; + if (!p) + return -1; ci->x = -1; ci->y = -1; while (p->focus) { @@ -333,7 +344,9 @@ static int __key_handle_focus(struct cmd_info *ci, int savepoint) if (savepoint && p->pointer) ci->mark = p->pointer; } - ci->focus = p; + if (!ci->home || !ci->focus) + ci->focus = p; + ci->home = p; ci->comm = NULL; return key_handle(ci); }