]> git.neil.brown.name Git - edlib.git/commitdiff
Rename pane_focus() to pane_take_focus()
authorNeilBrown <neil@brown.name>
Sat, 9 Sep 2023 03:35:38 +0000 (13:35 +1000)
committerNeilBrown <neil@brown.name>
Mon, 11 Sep 2023 02:16:50 +0000 (12:16 +1000)
This is more descriptive, matches the interface used in python, and
leaves pane_focus() free for other uses.

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c
core.h
doc-dir.c
doc-docs.c
emacs-search.c
lang-python.c
lib-menubar.c
lib-messageline.c
lib-popup.c
lib-tile.c
mode-emacs.c

index 28bc14aa03783e71345ea95925f52913a503044a..4df0de8a2ffe097286de57c135ee612ceb8e7028 100644 (file)
@@ -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 a60b939f3bfe4d40eaa6e5ea0c706904e110d4c4..c166973a99a874348b24fdfdd44e83c249206b44 100644 (file)
--- 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)
index 778ceee4554403b166e44d406557807ec0468348..749d1c34a261ee874d1937181f661bb37972b68c 100644 (file)
--- 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;
 }
 
index 8fe8bd3dbc35c4e82448a566bd4b1f9f823ab23a..0b4165772eb43e306bbff5a8568284dcf4a0e958 100644 (file)
@@ -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;
index ff7ab0d9fa6f442e736fed8ea4ae557872dda26f..6204f966a0ce3d4a0e36c6edac5812ba78f57e53 100644 (file)
@@ -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;
 }
 
index 3217cd22d34af6b2b3adad89df7e43d1a4c4d58b..0b144efbfe4c742718c841322221827304ede98c 100644 (file)
@@ -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"},
index 632659056ad5956d0681bfa0d69e97b4d7cc41a5..9c4bbc741689bc598813a380b44529763fb2bc5c 100644 (file)
@@ -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;
 }
index 41e0f23baa3dff9ba66138c0ffa509c94ed35b22..090caffed4dfdff3f6ca13a997bab29a9b2ae232 100644 (file)
@@ -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);
index e0f4067a0c3f92dda191aef1294216914486d88a..06f78cecbff6974d089184b19ee72d9baaf061c9 100644 (file)
@@ -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 =
index 77c8352072938e7fc2ae72851cc0eaee57337c15..9d89a2e40c21e3e50adcdf99e7295775c8277260 100644 (file)
@@ -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;
 }
 
index 59c6623b62416e6a089886ca7d405bd7e3222c0a..001469f2729d10760b2f8d213c1e18a3d038a6a9 100644 (file)
@@ -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);