From: NeilBrown Date: Sat, 9 Sep 2023 03:38:31 +0000 (+1000) Subject: Rename pane_leaf() to pane_focus() X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=03dbd597a16c5bb38cf5921925ceeef863f86aa0;p=edlib.git Rename pane_leaf() to pane_focus() 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 --- diff --git a/DOC/TODO.md b/DOC/TODO.md index ec4eb617..6fbb9ae7 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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 diff --git a/core-pane.c b/core-pane.c index 4df0de8a..b1da57dc 100644 --- a/core-pane.c +++ b/core-pane.c @@ -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); } diff --git a/core-pane.h b/core-pane.h index 6bdaead0..335994ff 100644 --- a/core-pane.h +++ b/core-pane.h @@ -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; diff --git a/core-window.c b/core-window.c index 2993c03f..e763702b 100644 --- a/core-window.c +++ b/core-window.c @@ -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; diff --git a/display-ncurses.c b/display-ncurses.c index b3ffe4ff..1bf5ba8c 100644 --- a/display-ncurses.c +++ b/display-ncurses.c @@ -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; diff --git a/display-x11-xcb.c b/display-x11-xcb.c index f3b8693f..779ebe4a 100644 --- a/display-x11-xcb.c +++ b/display-x11-xcb.c @@ -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; } diff --git a/lang-python.c b/lang-python.c index 0b144efb..ecd746e5 100644 --- a/lang-python.c +++ b/lang-python.c @@ -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 */ }; diff --git a/lib-autosave.c b/lib-autosave.c index c02a9789..313a0c0d 100644 --- a/lib-autosave.c +++ b/lib-autosave.c @@ -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; diff --git a/lib-input.c b/lib-input.c index 66fdf554..4b2200df 100644 --- a/lib-input.c +++ b/lib-input.c @@ -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"); } diff --git a/lib-linecount.c b/lib-linecount.c index ba233228..98ef67dc 100644 --- a/lib-linecount.c +++ b/lib-linecount.c @@ -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; } diff --git a/lib-linefilter.c b/lib-linefilter.c index cfdcdee0..88dcb967 100644 --- a/lib-linefilter.c +++ b/lib-linefilter.c @@ -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; diff --git a/lib-popup.c b/lib-popup.c index 06f78cec..eb2683dc 100644 --- a/lib-popup.c +++ b/lib-popup.c @@ -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"); diff --git a/lib-tile.c b/lib-tile.c index 9d89a2e4..b48f1466 100644 --- a/lib-tile.c +++ b/lib-tile.c @@ -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", diff --git a/lib-view.c b/lib-view.c index 177516af..47bee083 100644 --- a/lib-view.c +++ b/lib-view.c @@ -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; } diff --git a/python/display-pygtk.py b/python/display-pygtk.py index 9f8cddb1..b979ac6b 100644 --- a/python/display-pygtk.py +++ b/python/display-pygtk.py @@ -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) diff --git a/python/lib-autospell.py b/python/lib-autospell.py index c19e7b8b..f68d4d36 100644 --- a/python/lib-autospell.py +++ b/python/lib-autospell.py @@ -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 diff --git a/python/lib-make.py b/python/lib-make.py index 222e4789..ed9ea341 100644 --- a/python/lib-make.py +++ b/python/lib-make.py @@ -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): diff --git a/python/lib-server.py b/python/lib-server.py index 4b2e03b2..295e278d 100755 --- a/python/lib-server.py +++ b/python/lib-server.py @@ -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: diff --git a/python/module-notmuch.py b/python/module-notmuch.py index 5be60715..a24115f2 100644 --- a/python/module-notmuch.py +++ b/python/module-notmuch.py @@ -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): diff --git a/python/render-c-mode.py b/python/render-c-mode.py index 27feea27..0b92dd18 100644 --- a/python/render-c-mode.py +++ b/python/render-c-mode.py @@ -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 diff --git a/python/render-present.py b/python/render-present.py index 9189a71d..287b9add 100644 --- a/python/render-present.py +++ b/python/render-present.py @@ -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): diff --git a/render-hex.c b/render-hex.c index 80f41693..3f1adf80 100644 --- a/render-hex.c +++ b/render-hex.c @@ -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; }