]> git.neil.brown.name Git - edlib.git/commitdiff
add window:set: and use it to set attributes for displays.
authorNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 09:04:01 +0000 (19:04 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 21:03:47 +0000 (07:03 +1000)
We sometimes need to set DISPLAY etc so it is visible to the display
handler, particularly for ncurses.
Use new window:set: to set these on the window-core pane.
This means that editor:active-display is now always immediately after
the display pane is created, so we are closer to letting that be called
as part of creating the display pane.

Signed-off-by: NeilBrown <neil@brown.name>
core-window.c
edlib.c
python/lib-server.py

index 31c02dcdae6b55cf7d74b0740e0dbba0f3d4e25d..55ff948b5316486633ada6724a234ae375f3dd96 100644 (file)
@@ -7,6 +7,7 @@
  * Provide a pane that is instantiated between the root and any window
  * stack, to provide common functionality.  These includes:
  *
+ * - setting per-window attributes
  * - registering and forwarding per-window notifications
  * - Being an intermediary for per-window selections.
  *
@@ -72,6 +73,21 @@ DEF_CMD(send_notify)
                                ci->num2, ci->mark2, ci->str2, ci->comm2);
 }
 
+DEF_CMD(window_set)
+{
+       const char *val = ksuffix(ci, "window:set:");
+
+       if (!*val)
+               val = ci->str2;
+       if (!val)
+               return Enoarg;
+
+       if (ci->str)
+               attr_set_str(&ci->home->attrs, val, ci->str);
+
+       return 1;
+}
+
 DEF_CMD(selection_claim)
 {
        struct window_data *wd = ci->home->data;
@@ -166,6 +182,8 @@ void window_setup(struct pane *ed safe)
 
        key_add(window_map, "Display:close", &window_close);
 
+       key_add_prefix(window_map, "window:set:", &window_set);
+
        key_add(window_map, "selection:claim", &selection_claim);
        key_add(window_map, "selection:commit", &selection_commit);
        key_add(window_map, "selection:discard", &selection_discard);
diff --git a/edlib.c b/edlib.c
index 0fdfafac427158116fda6500373c069512e139a1..de4cbe4adaf42998c45db92e3731f47157ac53cc 100644 (file)
--- a/edlib.c
+++ b/edlib.c
@@ -107,15 +107,19 @@ int main(int argc, char *argv[])
 
                p = call_ret(pane, "attach-display-ncurses", ed,
                             0, NULL, "-", 0, NULL, TERM);
+               if (p)
+                       p = call_ret(pane, "editor:activate-display", p);
                if (p) {
                        char *e;
                        e = getenv("SSH_CONNECTION");
                        if (e && *e)
-                               attr_set_str(&p->attrs, "REMOTE_SESSION", "yes");
+                               call("window:set:REMOTE_SESSION", p,
+                                    0, NULL, "yes");
 
-                       attr_set_str(&p->attrs, "DISPLAY", getenv("DISPLAY"));
-                       attr_set_str(&p->attrs, "XAUTHORITY", getenv("XAUTHORITY"));
-                       p = call_ret(pane, "editor:activate-display", p);
+                       call("window:set:DISPLAY", p,
+                            0, NULL, getenv("DISPLAY"));
+                       call("window:set:XAUTHORITY", p,
+                            0, NULL, getenv("XAUTHORITY"));
                }
                if (p)
                        p = home_call_ret(pane, doc, "doc:attach-view",
index 821d0714c878a3c132526b62529202c7bf522b55..bb8d14ce726b32b2d86e8a21cada794c69fb6fc1 100755 (executable)
@@ -145,10 +145,10 @@ try:
                     p = edlib.editor
                     p = p.call("attach-display-ncurses", path, env['TERM'],
                                ret='pane')
+                    self.term = p.call("editor:activate-display", ret='pane')
                     for v in env:
-                        p[v] = env[v]
+                        self.term.call("window:set:", env[v], v)
                     self.disp = p
-                    self.term = self.disp.call("editor:activate-display", ret='pane')
                     self.add_notify(self.disp, "Notify:Close")
                     self.sock.send(b"OK")
                     return 1