From: NeilBrown Date: Sat, 9 Sep 2023 03:35:38 +0000 (+1000) Subject: Rename pane_focus() to pane_take_focus() X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=0ecf86d5d7aa94cb108d098a6a747b3232989f53;p=edlib.git Rename pane_focus() to pane_take_focus() This is more descriptive, matches the interface used in python, and leaves pane_focus() free for other uses. Signed-off-by: NeilBrown --- diff --git a/core-pane.c b/core-pane.c index 28bc14aa..4df0de8a 100644 --- a/core-pane.c +++ b/core-pane.c @@ -784,7 +784,7 @@ void pane_subsume(struct pane *p safe, struct pane *parent safe) pane_close(p); } -void pane_focus(struct pane *focus) +void pane_take_focus(struct pane *focus) { struct pane *p = focus; struct mark *pt; @@ -813,7 +813,7 @@ void pane_focus(struct pane *focus) bool do_pane_has_focus(struct pane *focus, struct pane *root) { - /* Would pane_focus change anything */ + /* Test inf pane_take_focus() would change anything. */ struct pane *p = focus; if (!p) diff --git a/core.h b/core.h index a60b939f..c166973a 100644 --- a/core.h +++ b/core.h @@ -477,7 +477,7 @@ void pane_move_after(struct pane *p safe, struct pane *after); void pane_subsume(struct pane *p safe, struct pane *parent safe); void pane_close(struct pane *p safe); bool pane_resize(struct pane *p safe, int x, int y, int w, int h); -void pane_focus(struct pane *p); +void pane_take_focus(struct pane *p); bool do_pane_has_focus(struct pane *p, struct pane *root); #define pane_has_focus(...) VFUNC(pane_has_focus, __VA_ARGS__) #define pane_has_focus1(p) do_pane_has_focus(p, NULL) diff --git a/doc-dir.c b/doc-dir.c index 778ceee4..749d1c34 100644 --- a/doc-dir.c +++ b/doc-dir.c @@ -824,7 +824,7 @@ static int dir_open(struct pane *focus safe, if (other) { par = home_call_ret(pane, focus, "DocPane", p); if (par) { - pane_focus(par); + pane_take_focus(par); return 1; } par = call_ret(pane, "OtherPane", focus); @@ -832,7 +832,7 @@ static int dir_open(struct pane *focus safe, par = call_ret(pane, "ThisPane", focus); if (par) { p = home_call_ret(pane, p, "doc:attach-view", par); - pane_focus(p); + pane_take_focus(p); } return 1; } @@ -884,7 +884,7 @@ static int dir_open_alt(struct pane *focus safe, p = home_call_ret(pane, doc, "doc:attach-view", p, 1); } free(fname); - pane_focus(p); + pane_take_focus(p); return 1; } diff --git a/doc-docs.c b/doc-docs.c index 8fe8bd3d..0b416577 100644 --- a/doc-docs.c +++ b/doc-docs.c @@ -594,7 +594,7 @@ static int docs_open(struct pane *home safe, struct pane *focus safe, if (other) { par = home_call_ret(pane, focus, "DocPane", dp); if (par) { - pane_focus(par); + pane_take_focus(par); return 1; } par = call_ret(pane, "OtherPane", focus); @@ -603,7 +603,7 @@ static int docs_open(struct pane *home safe, struct pane *focus safe, if (par) p = home_call_ret(pane, dp, "doc:attach-view", par, 1); if (p) { - pane_focus(p); + pane_take_focus(p); return 1; } else { return Efail; @@ -639,7 +639,7 @@ static int docs_open_alt(struct pane *home safe, struct pane *focus safe, return Efail; p = home_call_ret(pane, dp, "doc:attach-view", par, 1, NULL, buf+5); if (p) { - pane_focus(p); + pane_take_focus(p); return 1; } else { return Efail; diff --git a/emacs-search.c b/emacs-search.c index ff7ab0d9..6204f966 100644 --- a/emacs-search.c +++ b/emacs-search.c @@ -397,7 +397,7 @@ DEF_CMD(search_done) if (esi->replace_pane && strcmp(ci->key, "K:Enter") == 0) { /* if there is a replace pane, switch to it instead of closing */ - pane_focus(esi->replace_pane); + pane_take_focus(esi->replace_pane); return 1; } str = call_ret(str, "doc:get-str", ci->focus); @@ -462,7 +462,7 @@ DEF_CMD(search_replace) struct es_info *esi = ci->home->data; if (esi->replace_pane) { - pane_focus(esi->replace_pane); + pane_take_focus(esi->replace_pane); return 1; } @@ -487,9 +487,9 @@ DEF_CMD(search_replace) home_call(esi->target, "highlight:set-popup", p, 1); } if (strcmp(ci->key, "K:A-%") == 0) - pane_focus(ci->focus); + pane_take_focus(ci->focus); else - pane_focus(p); + pane_take_focus(p); return 1; } @@ -611,7 +611,7 @@ DEF_CMD(replace_to_search) { struct pane *sp = ci->home->_data; - pane_focus(sp); + pane_take_focus(sp); return 1; } diff --git a/lang-python.c b/lang-python.c index 3217cd22..0b144efb 100644 --- a/lang-python.c +++ b/lang-python.c @@ -865,12 +865,12 @@ static PyObject *Pane_clone_children(Pane *self safe, PyObject *args) return Py_None; } -static PyObject *Pane_focus(Pane *self safe, PyObject *args) +static PyObject *Pane_take_focus(Pane *self safe, PyObject *args) { if (!pane_valid(self)) return NULL; - pane_focus(self->pane); + pane_take_focus(self->pane); Py_INCREF(Py_None); return Py_None; } @@ -1509,7 +1509,7 @@ static const PyMethodDef pane_methods[] = { "provides an iterator which will iterate over all children"}, {"clone_children", (PyCFunction)Pane_clone_children, METH_VARARGS, "Clone all children onto the target"}, - {"take_focus", (PyCFunction)Pane_focus, METH_NOARGS, + {"take_focus", (PyCFunction)Pane_take_focus, METH_NOARGS, "Claim the focus for this pane"}, {"has_focus", (PyCFunction)Pane_has_focus, METH_VARARGS, "Check if pane is focus of display"}, diff --git a/lib-menubar.c b/lib-menubar.c index 63265905..9c4bbc74 100644 --- a/lib-menubar.c +++ b/lib-menubar.c @@ -285,7 +285,7 @@ DEF_CMD(menubar_done) struct mbinfo *mbi = home->data; if (mbi->child) - pane_focus(mbi->child); + pane_take_focus(mbi->child); call("Keystroke-sequence", home, 0, NULL, ci->str); return 1; } diff --git a/lib-messageline.c b/lib-messageline.c index 41e0f23b..090caffe 100644 --- a/lib-messageline.c +++ b/lib-messageline.c @@ -266,7 +266,7 @@ static struct pane *do_messageline_attach(struct pane *p safe) attr_set_str(&mlp->attrs, "render:wrap", "yes"); pane_damaged(ret, DAMAGED_VIEW); mli->line = mlp; - pane_focus(ret); + pane_take_focus(ret); if (!edlib_testing(p)) /* This can introduce unwanted variablitiy in tests */ call_comm("event:timer", ret, &force_refresh, 15000); diff --git a/lib-popup.c b/lib-popup.c index e0f4067a..06f78cec 100644 --- a/lib-popup.c +++ b/lib-popup.c @@ -138,7 +138,7 @@ DEF_CMD(popup_close) if (ci->num) /* Pane had focus, so give to target */ - pane_focus(ppi->target); + pane_take_focus(ppi->target); command_put(ppi->done); ppi->done = NULL; free(ppi->style); @@ -167,7 +167,7 @@ static void popup_finished(struct pane *focus safe, struct pane *home safe, const char *aux; struct command *done = ppi->done; - pane_focus(target); + pane_take_focus(target); key = pane_attr_get(focus, "done-key"); if (!key) key = "PopupDone"; @@ -296,7 +296,7 @@ DEF_CMD(popup_close_others) p = call_ret(pane, "OtherPane", ci->focus); if (p) { home_call(ci->home->focus, "doc:attach-view", p); - pane_focus(p); + pane_take_focus(p); } return 1; } @@ -318,7 +318,7 @@ DEF_CMD(popup_split) p = call_ret(pane, "OtherPane", p); if (p) { home_call(ci->home->focus, "doc:attach-view", p); - pane_focus(p); + pane_take_focus(p); } return 1; } @@ -519,7 +519,7 @@ DEF_CMD(popup_attach) if (ppi->parent_popup) pane_add_notify(p, ppi->parent_popup, "Notify:resize"); - pane_focus(p); + pane_take_focus(p); if (ci->str2) { struct pane *doc = diff --git a/lib-tile.c b/lib-tile.c index 77c83520..9d89a2e4 100644 --- a/lib-tile.c +++ b/lib-tile.c @@ -680,10 +680,10 @@ DEF_CMD(tile_window_next) if (p->focus && p->focus->z) { p2 = next_child(p, p->focus, 1); if (p2) { - pane_focus(p2); + pane_take_focus(p2); return 1; } else if (ti->leaf) { - pane_focus(ti->content); + pane_take_focus(ti->content); return 1; } t2 = tile_first(ti); @@ -692,17 +692,17 @@ DEF_CMD(tile_window_next) t2 = tile_next_named(ti, ci->str2); if (tile_is_first(t2) && (p2 = tile_root_popup(t2)) != NULL) { - pane_focus(p2); + pane_take_focus(p2); return 1; } } else t2 = tile_first(ti); } if (t2) { - pane_focus(t2->p); + pane_take_focus(t2->p); p2 = next_child(t2->p, NULL, 1); if (p2) - pane_focus(p2); + pane_take_focus(p2); } return 1; } @@ -716,7 +716,7 @@ DEF_CMD(tile_window_prev) if (wrong_pane(ci)) return Efallthrough; t2 = list_prev_entry(ti, tiles); - pane_focus(t2->p); + pane_take_focus(t2->p); return 1; } diff --git a/mode-emacs.c b/mode-emacs.c index 59c6623b..001469f2 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -1272,7 +1272,7 @@ DEF_CMD(emacs_findfile) struct pane *this = call_ret(pane, "ThisPane", ci->focus); par = home_call_ret(pane, ci->focus, "DocPane", p); if (par && par != this) { - pane_focus(par); + pane_take_focus(par); return 1; } par = call_ret(pane, "OtherPane", ci->focus); @@ -1288,7 +1288,7 @@ DEF_CMD(emacs_findfile) p = home_call_ret(pane, p, "doc:attach-view", par, 1); if (p) - pane_focus(p); + pane_take_focus(p); return p ? 1 : Efail; } @@ -1607,7 +1607,7 @@ DEF_CMD(emacs_finddoc) struct pane *this = call_ret(pane, "ThisPane", ci->focus); par = home_call_ret(pane, ci->focus, "DocPane", p); if (par && par != this) { - pane_focus(par); + pane_take_focus(par); return 1; } par = call_ret(pane, "OtherPane", ci->focus); @@ -1620,7 +1620,7 @@ DEF_CMD(emacs_finddoc) p = home_call_ret(pane, p, "doc:attach-view", par, 1); if (p) - pane_focus(p); + pane_take_focus(p); return p ? 1 : Efail; } @@ -1687,7 +1687,7 @@ DEF_CMD(emacs_viewdocs) struct pane *this = call_ret(pane, "ThisPane", ci->focus); par = home_call_ret(pane, ci->focus, "DocPane", docs); if (par && par != this) { - pane_focus(par); + pane_take_focus(par); return 1; } par = call_ret(pane, "OtherPane", ci->focus); @@ -2517,7 +2517,7 @@ DEF_CMD(emacs_press) clear_selection(ci->focus, pt, mk, 0); call("Move-to", ci->focus, 0, m); - pane_focus(ci->focus); + pane_take_focus(ci->focus); if (m2 && strcmp(ci->key, "M:DPress-1") == 0) { type = attr_find(m2->attrs, "emacs:selection-type"); @@ -2654,7 +2654,7 @@ DEF_CMD(emacs_paste) call("Replace", ci->focus, 0, NULL, str); - pane_focus(ci->focus); + pane_take_focus(ci->focus); return 1; } @@ -2669,7 +2669,7 @@ DEF_CMD(emacs_paste_direct) if (ci->key[0] == 'M') { call("Move-CursorXY", ci->focus, 0, NULL, NULL, 0, NULL, NULL, ci->x, ci->y); - pane_focus(ci->focus); + pane_take_focus(ci->focus); } s = call_ret(str, "Paste:get", ci->focus);