From: NeilBrown Date: Wed, 28 Jun 2023 20:40:20 +0000 (+1000) Subject: Finish attach-display-foo commands with doc:attach-view X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=1440b09f17909f3143da65a065f2cf8f5fd194c0;p=edlib.git Finish attach-display-foo commands with doc:attach-view And attach-display-* command must now be called on a document or on the root. If it was on a document, that document is viewed in the created display using doc:attach-view. This makes it easier for a caller to create a useful window in a single command. Signed-off-by: NeilBrown --- diff --git a/display-ncurses.c b/display-ncurses.c index e3162453..1577ae0a 100644 --- a/display-ncurses.c +++ b/display-ncurses.c @@ -1796,15 +1796,19 @@ REDEF_CMD(input_handle) DEF_CMD(display_ncurses) { struct pane *p; + struct pane *ed = pane_root(ci->focus); const char *tty = ci->str; const char *term = ci->str2; if (!term) term = "xterm-256color"; - p = ncurses_init(ci->focus, tty, term); + p = ncurses_init(ed, tty, term); if (p) p = call_ret(pane, "editor:activate-display", p); + if (p && ci->focus != ed) + /* Assume ci->focus is a document */ + p = home_call_ret(pane, ci->focus, "doc:attach-view", p, 1); if (p) return comm_call(ci->comm2, "callback:display", p); diff --git a/display-x11-xcb.c b/display-x11-xcb.c index 6248ab5f..497ae3f1 100644 --- a/display-x11-xcb.c +++ b/display-x11-xcb.c @@ -1918,11 +1918,15 @@ abort: DEF_CMD(display_xcb) { struct pane *p; + struct pane *ed = pane_root(ci->focus); const char *d = ci->str; if (!d) return Enoarg; - p = xcb_display_init(d, ci->str2, ci->focus); + p = xcb_display_init(d, ci->str2, ed); + if (p && ci->focus != ed) + /* Assume ci->focus is a document */ + p = home_call_ret(pane, ci->focus, "doc:attach-view", p, 1); if (p) return comm_call(ci->comm2, "cb", p); return Efail; diff --git a/edlib.c b/edlib.c index be6b596b..c7c21007 100644 --- a/edlib.c +++ b/edlib.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) if (term) { char *TERM = getenv("TERM"); - p = call_ret(pane, "attach-display-ncurses", ed, + p = call_ret(pane, "attach-display-ncurses", doc, 0, NULL, "-", 0, NULL, TERM); if (p) { char *e; @@ -118,34 +118,24 @@ int main(int argc, char *argv[]) 0, NULL, getenv("DISPLAY")); call("window:set:XAUTHORITY", p, 0, NULL, getenv("XAUTHORITY")); - } - if (p) - p = home_call_ret(pane, doc, "doc:attach-view", - p, 1); - if (!first_window) - first_window = p; - if (p) + if (!first_window) + first_window = p; call("Display:set-noclose", p, 1, NULL, "Cannot close primary display"); + } } if (gtk) { p = call_ret(pane, "attach-display-gtk", - ed, 0, NULL, getenv("DISPLAY")); - if (p) - p = home_call_ret(pane, doc, "doc:attach-view", - p, 1); + doc, 0, NULL, getenv("DISPLAY")); if (!first_window) first_window = p; } if (x11) { p = call_ret(pane, "attach-display-x11", - ed, 0, NULL, getenv("DISPLAY"), + doc, 0, NULL, getenv("DISPLAY"), 0, NULL, getenv("XAUTHORITY")); - if (p) - p = home_call_ret(pane, doc, "doc:attach-view", - p, 1); if (!first_window) first_window = p; } diff --git a/python/display-pygtk.py b/python/display-pygtk.py index efa699f4..6638c2c4 100644 --- a/python/display-pygtk.py +++ b/python/display-pygtk.py @@ -740,6 +740,7 @@ def new_display(key, focus, comm2, str1, **a): if not str1: return None focus.call("attach-glibevents") + ed = focus.root if 'SCALE' in os.environ: sc = int(os.environ['SCALE']) @@ -748,6 +749,8 @@ def new_display(key, focus, comm2, str1, **a): disp = EdDisplay(focus, str1) p = disp.call("editor:activate-display", ret='pane') + if p and focus != ed: + p = focus.call("doc:attach-view", p, 1) comm2('callback', p) return 1