]> git.neil.brown.name Git - edlib.git/commitdiff
Rename pane_leaf() to pane_focus()
authorNeilBrown <neil@brown.name>
Sat, 9 Sep 2023 03:38:31 +0000 (13:38 +1000)
committerNeilBrown <neil@brown.name>
Mon, 11 Sep 2023 02:16:50 +0000 (12:16 +1000)
As the function follows the ->focus pointer up, this seems like a better
name.

The pane name ".leaf" becomes ".final_focus" as ".focus" is taken for
the immediate focus.

Signed-off-by: NeilBrown <neil@brown.name>
22 files changed:
DOC/TODO.md
core-pane.c
core-pane.h
core-window.c
display-ncurses.c
display-x11-xcb.c
lang-python.c
lib-autosave.c
lib-input.c
lib-linecount.c
lib-linefilter.c
lib-popup.c
lib-tile.c
lib-view.c
python/display-pygtk.py
python/lib-autospell.py
python/lib-make.py
python/lib-server.py
python/module-notmuch.py
python/render-c-mode.py
python/render-present.py
render-hex.c

index ec4eb61760a24a33ef781771ceb48cf86b0c9b1c..6fbb9ae77bcb1459cdf5b10a70da9b819680f572 100644 (file)
@@ -140,8 +140,8 @@ Core features
 - [ ] Make DEF_CB really different from DEF_CMD and ensure it is used properly.
 - [ ] is DocLeaf really a good idea?  Maybe panes should have 'leafward'
       pointer separate to 'focus'?  Maybe panes could have optional
-      'child' method which returns main child - pane_leaf() calls that.
-      Maybe pane_leaf() find a pane with z=0 and matching w,h ??
+      'child' method which returns main child - pane_focus() calls that.
+      Maybe pane_focus() find a pane with z=0 and matching w,h ??
 - [ ] support text-replace as easy as text-insert (doc:char...)
 - [ ] for doc:cmd transformation,  what about :Enter and BS TAB ESC ???
 - [ ] For a notify handler, returning non-zero doesn't stop other handlers
index 4df0de8a2ffe097286de57c135ee612ceb8e7028..b1da57dc91d20b4858c29310dec4fa4bb901bd0f 100644 (file)
@@ -324,7 +324,7 @@ static void pane_do_refresh(struct pane *p safe)
                return;
        p->damaged &= ~damage;
        if (damage & DAMAGED_REFRESH)
-               pane_call(p, "Refresh", pane_leaf(p));
+               pane_call(p, "Refresh", pane_focus(p));
 
        list_for_each_entry(c, &p->children, siblings)
                c->damaged |= DAMAGED_NOT_HANDLED;
@@ -356,7 +356,7 @@ static void pane_do_review(struct pane *p safe)
                return;
 
        if (damage & DAMAGED_VIEW)
-               pane_call(p, "Refresh:view", pane_leaf(p));
+               pane_call(p, "Refresh:view", pane_focus(p));
 
        list_for_each_entry(c, &p->children, siblings)
                c->damaged |= DAMAGED_NOT_HANDLED;
@@ -575,7 +575,7 @@ static void pane_refocus(struct pane *p safe)
                        break;
                }
        /* Tell the new focus to update - probably just a cursor update */
-       p = pane_leaf(p);
+       p = pane_focus(p);
        pt = call_ret(mark, "doc:point", p);
        call("view:changed", p, 0, pt);
 }
@@ -800,14 +800,14 @@ void pane_take_focus(struct pane *focus)
                        continue;
                p->parent->focus = p;
                if (old) {
-                       old = pane_leaf(old);
+                       old = pane_focus(old);
                        pt = call_ret(mark, "doc:point", old);
                        call("view:changed", old, 0, pt);
                        home_call(old, "pane:defocus", focus);
                }
        }
-       pt = call_ret(mark, "doc:point", pane_leaf(focus));
-       call("view:changed", pane_leaf(focus), 0, pt);
+       pt = call_ret(mark, "doc:point", pane_focus(focus));
+       call("view:changed", pane_focus(focus), 0, pt);
        call("pane:refocus", focus);
 }
 
index 6bdaead030e427da1881a0606daccc4518f03c7d..335994ff93beb186f1ad1f9aa4bed61af545db43 100644 (file)
@@ -75,7 +75,7 @@ static inline bool times_up_fast(struct pane *p safe)
        return pane_root(p)->timestamp == 1;
 }
 
-static inline struct pane *safe pane_leaf(struct pane *p safe)
+static inline struct pane *safe pane_focus(struct pane *p safe)
 {
        struct pane *f;
 
index 2993c03fecc8272ebd548264ba7e8932417527f4..e763702b58a8bef4abd534020420c148e06d5912 100644 (file)
@@ -128,8 +128,8 @@ DEF_CMD(selection_discard)
        /* Don't require exactly same pane for sel_owner,
         * but ensure they have the same focus.
         */
-       op = pane_leaf(wd->sel_owner);
-       fp = pane_leaf(ci->focus);
+       op = pane_focus(wd->sel_owner);
+       fp = pane_focus(ci->focus);
        if (fp != op)
                return Efalse;
 
index b3ffe4ff2dc6ccd473166182c0c7275f9a6837f2..1bf5ba8c7019e773ed467116ce0bea1af4c904df 100644 (file)
@@ -1273,7 +1273,7 @@ DEF_CMD(nc_refresh_post)
                        dest.y, dest.x, destend.y-1, destend.x-1, 0);
        }
        /* place the cursor */
-       p1 = pane_leaf(p);
+       p1 = pane_focus(p);
        pan = NULL;
        while (p1 != p && (pan = pane_panel(p1, NULL)) == NULL)
                p1 = p1->parent;
index f3b8693fff63a62482996db11c08b362e3fc1db7..779ebe4a204bc4bea1639015533fe9d5ee061400 100644 (file)
@@ -1228,7 +1228,7 @@ static void handle_focus(struct pane *home safe, xcb_focus_in_event_t *fie safe)
        struct mark *pt;
 
        xd->in_focus = in;
-       p = pane_leaf(home);
+       p = pane_focus(home);
        pt = call_ret(mark, "doc:point", p);
        if (pt)
                call("view:changed", p, 0, pt);
@@ -1584,7 +1584,7 @@ static void handle_client_message(struct pane *home safe,
            cme->format == 32 &&
            cme->window == xd->win &&
            cme->data.data32[0] == xd->atoms[a_WM_DELETE_WINDOW]) {
-               call("window:close", pane_leaf(home));
+               call("window:close", pane_focus(home));
                return;
        }
 
index 0b144efbfe4c742718c841322221827304ede98c..ecd746e511913e85248f18bae3c610fcba21bdea 100644 (file)
@@ -1624,8 +1624,8 @@ static Pane *pane_getpane(Pane *p safe, char *which safe)
                new = p->pane->focus;
        if (*which == 'r')
                new = pane_root(p->pane);
-       if (*which == 'L')
-               new = pane_leaf(p->pane);
+       if (*which == 'F')
+               new = pane_focus(p->pane);
        if (new == NULL) {
                Py_INCREF(Py_None);
                newpane = (Pane*)Py_None;
@@ -1711,9 +1711,9 @@ static const PyGetSetDef pane_getseters[] = {
        {"root",
         (getter)pane_getpane, (setter)pane_nosetpane,
         "Root pane", "r"},
-       {"leaf",
+       {"final_focus",
         (getter)pane_getpane, (setter)pane_nosetpane,
-        "Leaf pane", "L"},
+        "Leaf pane", "F"},
        {NULL}  /* Sentinel */
 };
 
index c02a97890bead9a524c8a969b10bb0af015477a3..313a0c0df15e61b356ae79777ea83919022a6833 100644 (file)
@@ -198,7 +198,7 @@ DEF_CMD(ask_autosave)
                /* No display!!! */
                return Efalse;
 
-       p2 = call_ret(pane, "PopupTile", pane_leaf(cr.p), 0, NULL, "DM3sta");
+       p2 = call_ret(pane, "PopupTile", pane_focus(cr.p), 0, NULL, "DM3sta");
        if (!p2)
                return Efalse;
 
index 66fdf55400ff2cb6bf54e6579885e6d3540de782..4b2200df20ac6e60f86ab2d948e0d419c47373af 100644 (file)
@@ -206,7 +206,7 @@ DEF_CMD(keystroke)
        }
 
        if (!im->focus || im->focus->focus) {
-               p = pane_leaf(ci->focus);
+               p = pane_focus(ci->focus);
                im->focus = p;
                pane_add_notify(ci->home, p, "Notify:Close");
        }
index ba233228d103589b20fe015bec6f0b0e1c7b83cc..98ef67dcefe48ae35b98a69c8bd000bd047940ee 100644 (file)
@@ -168,7 +168,7 @@ static void do_count(struct pane *p safe, struct pane *owner safe,
 
 DEF_CMD(linecount_restart)
 {
-       pane_call(ci->home, "CountLinesAsync", pane_leaf(ci->focus), 1);
+       pane_call(ci->home, "CountLinesAsync", pane_focus(ci->focus), 1);
        return Efalse;
 }
 
index cfdcdee02ed1d78a677e7cbfe2972d10e1aa98fd..88dcb967456d79b3589959ca92a8bb7e536dbb04 100644 (file)
@@ -337,7 +337,7 @@ DEF_CMD(filter_changed)
        if (strcmp(ci->key, "Filter:set") == 0) {
                if (!ci->str)
                        return Enoarg;
-               call("view:changed", pane_leaf(ci->home));
+               call("view:changed", pane_focus(ci->home));
                comm = ci->comm2;
                fd->explicit_set = True;
                free(fd->match);
@@ -352,7 +352,7 @@ DEF_CMD(filter_changed)
                fd->implicit_set = False;
                if (check_settings(ci->focus, fd))
                        /* Something changed */
-                       call("view:changed", pane_leaf(ci->home));
+                       call("view:changed", pane_focus(ci->home));
        }
        if (!fd->match)
                return 1;
index 06f78cecbff6974d089184b19ee72d9baaf061c9..eb2683dc8992b6137fabc03902b5211b42a139fd 100644 (file)
@@ -82,12 +82,12 @@ static void popup_resize(struct pane *p safe, const char *style safe,
 
        /* First find the size */
        lh = line_height(p, xyscale.x);
-       bhs = pane_attr_get(pane_leaf(p), "border-height");
+       bhs = pane_attr_get(pane_focus(p), "border-height");
        if (bhs)
                bh = atoi(bhs);
        if (bh <= 0)
                bh = line_height(p, 0); /* border height */
-       bws = pane_attr_get(pane_leaf(p), "border-width");
+       bws = pane_attr_get(pane_focus(p), "border-width");
        if (bws)
                bw = atoi(bhs);
        if (bw <= 0)
@@ -249,7 +249,7 @@ DEF_CMD(popup_refresh_size)
 {
        struct popup_info *ppi = ci->home->data;
        char *prompt, *dflt, *prefix;
-       struct pane *focus = pane_leaf(ci->home);
+       struct pane *focus = pane_focus(ci->home);
 
        prefix = pane_attr_get(focus, "prefix");
        prompt = pane_attr_get(focus, "prompt");
index 9d89a2e40c21e3e50adcdf99e7295775c8277260..b48f1466dd0a0278daf5c407a05952caf0852ef7 100644 (file)
@@ -951,7 +951,7 @@ DEF_CMD(tile_doc)
                t = list_next_entry(t, tiles);
                f = t->content;
                if (f) {
-                       f = pane_leaf(f);
+                       f = pane_focus(f);
                        n = pane_attr_get(f, "doc-name");
                        if (name && n && strcmp(n, name) == 0)
                                return comm_call(ci->comm2, "callback:pane",
index 177516af91820b4bd4f09a669347fcae3dea9b9c..47bee0837bc13737f288daf6779492b944a909bd 100644 (file)
@@ -486,7 +486,7 @@ DEF_CMD(view_click)
                /* big scroll down */
                scale = 900;
        }
-       call("Move-View", pane_leaf(ci->focus), num * scale);
+       call("Move-View", pane_focus(ci->focus), num * scale);
        return 1;
 }
 
@@ -503,9 +503,9 @@ DEF_CMD(view_release)
 DEF_CMD(view_scroll)
 {
        if (strcmp(ci->key, "M:Press-4") == 0)
-               call("Move-View", pane_leaf(ci->focus), -200);
+               call("Move-View", pane_focus(ci->focus), -200);
        else
-               call("Move-View", pane_leaf(ci->focus), 200);
+               call("Move-View", pane_focus(ci->focus), 200);
        return 1;
 }
 
index 9f8cddb15e4ec30b8a3af0666c821d7ebd664df1..b979ac6bb417984a98e9a7b1f93df6b4d10557da 100644 (file)
@@ -572,7 +572,7 @@ class EdDisplay(edlib.Pane):
         edlib.time_start(edlib.TIME_WINDOW)
         self.im.focus_in()
         self.in_focus = True
-        f = self.leaf
+        f = self.final_focus
         pt = f.call("doc:point", ret='mark')
         f.call("view:changed", pt)
         self.call("pane:refocus")
@@ -582,7 +582,7 @@ class EdDisplay(edlib.Pane):
         edlib.time_start(edlib.TIME_WINDOW)
         self.im.focus_out()
         self.in_focus = False
-        f = self.leaf
+        f = self.final_focus
         pt = f.call("doc:point", ret='mark')
         f.call("view:changed", pt)
         edlib.time_stop(edlib.TIME_WINDOW)
index c19e7b8b26d22a72221c32a3cbef1992b4a88c16..f68d4d36bd645c42e7dec3e8bacc3cf01827e47b 100644 (file)
@@ -321,7 +321,7 @@ class autospell_view(edlib.Pane):
             return edlib.Efalse
 
         self.set_time()
-        focus = focus.leaf
+        focus = focus.final_focus
 
         if edlib.testing:
             remain = 20
index 222e47895fe1e266c3affd2e1f181dea5266cdc6..ed9ea341543286dffdb6f4a7d7d3faa846475f5f 100644 (file)
@@ -685,7 +685,7 @@ class makeprompt(edlib.Pane):
         self['done-key'] = "N:%s:%s:%s" % (self['autosave'], self['mode'], d)
         # FIXME this only damaged the board content, not doc content
         # Is there a way I can communicate that?
-        focus.leaf.call("view:changed")
+        focus.final_focus.call("view:changed")
         return 1
 
     def down(self, key, focus, **a):
@@ -702,7 +702,7 @@ class makeprompt(edlib.Pane):
         self['dirname'] = d
         self['pane-title'] = "%s in %s" % (self['cmd'],d)
         self['done-key'] = "N:%s:%s:%s" % (self['autosave'], self['mode'], d)
-        focus.leaf.call("view:changed")
+        focus.final_focus.call("view:changed")
         return 1
 
 def isword(c):
index 4b2e03b2e30d0f9efff5f5f583ca9c8143b9d449..295e278deb0a3f3363dfaed4a19f6b3ee9809002 100755 (executable)
@@ -90,7 +90,7 @@ if sys.argv[0] == "":
                         self.sock.send(b"FAIL")
                         return 1
                     if self.term:
-                        p = self.term.leaf.call("ThisPane", ret='pane')
+                        p = self.term.final_focus.call("ThisPane", ret='pane')
                         p = d.call("doc:attach-view", p, 1, ret='pane')
                         self.term.take_focus()
                         self.sock.send(b"OK")
@@ -219,7 +219,7 @@ if sys.argv[0] == "":
             self.destpane = None
             self.call("editor:notify:all-displays", self.display_callback)
             if self.destpane:
-                p = self.destpane.leaf
+                p = self.destpane.final_focus
                 self.destpane = None
                 # Need to avoid transient popups
                 if p:
index 5be60715d65991f14d938f3c2f0fab0b3a8669ab..a24115f2580c2d86ea4bde9df44e1ea483f0de8e 100644 (file)
@@ -2709,8 +2709,8 @@ class notmuch_query_view(edlib.Pane):
         if self.thread_start:
             # Possible insertion before thread_end - recalc.
             self.thread_end = self.thread_start.dup()
-            self.leaf.call("doc:step-thread", 1, 1, self.thread_end)
-        self.leaf.call("view:changed")
+            self.final_focus.call("doc:step-thread", 1, 1, self.thread_end)
+        self.final_focus.call("view:changed")
         self.call("doc:notify:doc:status-changed")
         return edlib.Efallthrough
 
@@ -2719,17 +2719,17 @@ class notmuch_query_view(edlib.Pane):
             return None
         # old thread is disappearing.  If it is not gone, clip marks
         # to start, else clip to next thread.
-        self.leaf.call("Notify:clip", self.thread_start, self.thread_end,
+        self.final_focus.call("Notify:clip", self.thread_start, self.thread_end,
                        0 if gone else 1)
         if self.whole_thread:
             # And clip anything after (at eof) to thread_end
             eof = edlib.Mark(self)
-            self.leaf.call("doc:set-ref", eof, 0)
+            self.final_focus.call("doc:set-ref", eof, 0)
             eof.step(1)
             eof.index = 1 # make sure all eof marks are different
-            self.leaf.call("Notify:clip", self.thread_end, eof, 1)
+            self.final_focus.call("Notify:clip", self.thread_end, eof, 1)
             eof.index = 0
-        self.leaf.call("view:changed", self.thread_start, self.thread_end)
+        self.final_focus.call("view:changed", self.thread_start, self.thread_end)
         self.selected = None
         self.thread_start = None
         self.thread_end = None
@@ -2745,7 +2745,7 @@ class notmuch_query_view(edlib.Pane):
         # might be where thread used to be.
         self.thread_end = self.thread_start.dup()
         self.call("doc:step-thread", self.thread_end, 1, 1)
-        self.leaf.call("view:changed", self.thread_start, self.thread_end)
+        self.final_focus.call("view:changed", self.thread_start, self.thread_end)
         return 1
 
     def find_message(self, key, focus, mark, str, str2, **a):
@@ -2771,12 +2771,12 @@ class notmuch_query_view(edlib.Pane):
             if mt != "True":
                 m2 = m.dup()
                 self.call("doc:step-matched", m2, 1, 1)
-                self.leaf.call("Notify:clip", m, m2)
+                self.final_focus.call("Notify:clip", m, m2)
                 m = m2
             if not self.thread_matched:
                 self.thread_matched = m.dup()
             self.parent.next(m)
-        self.leaf.call("view:changed", self.thread_start, self.thread_end)
+        self.final_focus.call("view:changed", self.thread_start, self.thread_end)
 
     def handle_notify_thread(self, key, str, num, **a):
         "handle:notmuch:thread-changed"
@@ -2966,10 +2966,10 @@ class notmuch_query_view(edlib.Pane):
                 focus.call("Notify:clip", self.thread_start, self.thread_end)
             # everything after to EOF moves to thread_end.
             eof = edlib.Mark(self)
-            self.leaf.call("doc:set-ref", eof, 0)
+            self.final_focus.call("doc:set-ref", eof, 0)
             eof.step(1)
             eof.offset = 1 # make sure all eof marks are different
-            self.leaf.call("Notify:clip", self.thread_end, eof, 1)
+            self.final_focus.call("Notify:clip", self.thread_end, eof, 1)
             eof.offset = 0
 
             self['doc-status'] = "Query: %s" % self['qname']
@@ -3389,7 +3389,7 @@ class notmuch_message_view(edlib.Pane):
                 m['quote-hidden'] = "no"
             else:
                 m['quote-hidden'] = "yes"
-            self.leaf.call("view:changed", m, m.next())
+            self.final_focus.call("view:changed", m, m.next())
             return 1
 
     def handle_vis(self, focus, mark, which):
index 27feea27427eebccf951b6880c094a82f92ceae2..0b92dd18b91f13f484e58b66c808e9a394d93e09 100644 (file)
@@ -898,9 +898,9 @@ class CModePane(edlib.Pane):
 
     def handle_replace(self, key, focus, **a):
         "handle:doc:replaced"
-        self.update(self.leaf, self.pre_paren)
+        self.update(self.final_focus, self.pre_paren)
         self.pre_paren = None
-        self.update(self.leaf, self.post_paren)
+        self.update(self.final_focus, self.post_paren)
         self.post_paren = None
         self.damaged(edlib.DAMAGED_VIEW)
         return 1
index 9189a71d22a1860444a8c32803e39c7d0fddda6a..287b9addbcbcc82e53eb84235a288cc643d1815b 100644 (file)
@@ -164,7 +164,7 @@ class PresenterPane(edlib.Pane):
                             self['background'] = 'call:Present-BG:'+globals['background']
                         if 'scale' in globals:
                             self['scale'] = globals['scale']
-                        self.leaf.call("view:changed")
+                        self.final_focus.call("view:changed")
                     return maybe
             else:
                 # not part of start-of-page block
@@ -401,7 +401,7 @@ class PresenterPane(edlib.Pane):
             first.release()
         if extra_change:
             # force full refresh
-            self.leaf.call("view:changed")
+            self.final_focus.call("view:changed")
 
     def get_local_attr(self, m, attr, page):
         t = 'attr:' + attr
@@ -625,7 +625,7 @@ class PresenterPane(edlib.Pane):
                 self.first_valid = False
                 page['valid'] = 'no'
             # attributes probably changed so...
-            self.leaf.call("view:changed")
+            self.final_focus.call("view:changed")
         else:
             page['valid'] = 'no'
             page['next-valid'] = 'no'
@@ -643,7 +643,7 @@ class PresenterPane(edlib.Pane):
                 l['type'] = 'unknown'
                 l = l.prev()
             if l['type'] and l['type'][0:5] == "attr:":
-                self.leaf.call("view:changed")
+                self.final_focus.call("view:changed")
             l['type'] = 'unknown'
             l = l.next()
             if l:
@@ -670,7 +670,7 @@ class PresenterPane(edlib.Pane):
                 m2.to_mark(m)
                 if comm2 is not None:
                     comm2("callback", focus, m)
-        self.leaf.call("Move-View-Pos", m2)
+        self.final_focus.call("Move-View-Pos", m2)
         return 1
 
     def handle_clone(self, key, **a):
index 80f41693c0d3e98ec0a1ae90b64be412a4cda7e1..3f1adf80ea7a6a6ccc83d9df94237baed8ef4188 100644 (file)
@@ -58,7 +58,7 @@ DEF_CMD(render_hex_notify_replace)
         * However we cannot currently access the view port, so
         * always signal damage. FIXME.
         */
-       call("view:changed", pane_leaf(ci->home));
+       call("view:changed", pane_focus(ci->home));
        return 1;
 }