From: NeilBrown Date: Wed, 28 Jun 2023 09:04:01 +0000 (+1000) Subject: add window:set: and use it to set attributes for displays. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=b3a639d4af4aff94b9eb4757ff314d1aa28df4c9;p=edlib.git add window:set: and use it to set attributes for displays. 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 --- diff --git a/core-window.c b/core-window.c index 31c02dcd..55ff948b 100644 --- a/core-window.c +++ b/core-window.c @@ -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 0fdfafac..de4cbe4a 100644 --- 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", diff --git a/python/lib-server.py b/python/lib-server.py index 821d0714..bb8d14ce 100755 --- a/python/lib-server.py +++ b/python/lib-server.py @@ -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