This effectively reverts an earlier patch.
That patch caused x11 selection to stop working because
the relevant pane was attached before DISPLAY had been set.
So now we create the display first, then have the opportunity to set
attributes, then call window-active-display which adds all the extra
panes and attaches a document.
Signed-off-by: NeilBrown <neil@brown.name>
### Triage
+- [ ] in filename competion, TAB might add a '/' to a partial name and
+ then get confused.
- [X] when search succeeds on final line then trying again loops back to
there, redraw is strange
- [ ] There is a "window:close" and a "Window:close" and they are
return key_lookup_prefix(map, ci, False);
}
-DEF_CMD(editor_activate_display)
-{
- /* Given a display attached to the root, integrate it
- * into a full initial stack of panes.
- */
- struct pane *disp = ci->focus;
- struct pane *p, *p2;
- char *ip = attr_find(ci->home->attrs, "editor-initial-panes");
- char *save, *t, *m;
-
- if (!ip)
- return Efail;
- ip = strsave(ci->home, ip);
- p = pane_root(ci->focus);
-
- p2 = call_ret(pane, "attach-window-core", p);
- if (!p2)
- return Efail;
- p = p2;
-
- for (t = strtok_r(ip, " \t\n", &save);
- t;
- t = strtok_r(NULL, " \t\n", &save)) {
- if (!*t)
- continue;
- if (strcmp(t, "DISPLAY") == 0) {
- if (disp) {
- pane_reparent(disp, p);
- p = disp;
- disp = NULL;
- }
- continue;
- }
- m = strconcat(NULL, "attach-", t);
- p2 = call_ret(pane, m, p);
- free(m);
- if (p2)
- p = p2;
- }
- comm_call(ci->comm2, "cb", p);
- return 1;
-}
-
DEF_CMD(editor_multicall)
{
struct ed_info *ei = ci->home->data;
&editor_request_notify);
key_add_prefix(ed_map, "editor:notify:",
&editor_send_notify);
- key_add(ed_map, "editor:activate-display",
- &editor_activate_display);
key_add(ed_map, "Close", &editor_close);
}
ed = pane_register_root(&ed_handle.c, NULL, sizeof(*ei));
return 1;
}
+DEF_CMD(window_activate_display)
+{
+ /* Given a display attached to the root, integrate it
+ * into a full initial stack of panes.
+ * The display is the focus of this pane. This doc to
+ * attach there is the focus in the command.
+ */
+ struct pane *disp = ci->home->focus;
+ struct pane *p, *p2;
+ bool display_added = False;
+ char *ip;
+ char *save, *t, *m;
+
+ if (!disp || !list_empty(&disp->children))
+ return Efail;
+ ip = pane_attr_get(disp, "window-initial-panes");
+ if (!ip)
+ return Efail;
+ ip = strdup(ip);
+ p = ci->home;
+
+ for (t = strtok_r(ip, " \t\n", &save);
+ t;
+ t = strtok_r(NULL, " \t\n", &save)) {
+ if (!*t)
+ continue;
+ if (strcmp(t, "DISPLAY") == 0) {
+ if (!display_added) {
+ pane_reparent(disp, p);
+ p = disp;
+ display_added = True;
+ }
+ } else {
+ m = strconcat(NULL, "attach-", t);
+ p2 = call_ret(pane, m, p);
+ free(m);
+ if (p2)
+ p = p2;
+ }
+ }
+ free(ip);
+ if (p && ci->focus != disp)
+ p = home_call_ret(pane, ci->focus, "doc:attach-view", p, 1);
+ if (p)
+ comm_call(ci->comm2, "cb", p);
+ return 1;
+}
+
DEF_CMD(close_notify)
{
struct window_data *wd = ci->home->data;
{
struct pane *p;
- p = pane_register(ci->focus, 0, &window_handle.c);
+ p = pane_register(pane_root(ci->focus), 0, &window_handle.c);
if (!p)
return Efail;
comm_call(ci->comm2, "cb", p);
key_add(window_map, "Notify:Close", &close_notify);
key_add(window_map, "Draw:scale-image", &scale_image);
+ key_add(window_map, "window:activate-display",
+ &window_activate_display);
call_comm("global-set-command", ed, &window_attach, 0, NULL,
"attach-window-core");
[global]
-editor-initial-panes = input DISPLAY
+window-initial-panes = input DISPLAY
" x11selection"
" messageline"
" mode-basic"
if (!term)
term = "xterm-256color";
- 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);
+ p = call_ret(pane, "attach-window-core", ed);
+ if (!p)
+ return Efail;
+
+ p = ncurses_init(p, tty, term);
if (p)
return comm_call(ci->comm2, "callback:display", p);
if (xcb_connection_has_error(conn))
return NULL;
- p = pane_register(pane_root(focus), 1, &xcb_handle.c);
+ p = call_ret(pane, "attach-window-core", focus);
+ if (!p)
+ return NULL;
+ p = pane_register(p, 1, &xcb_handle.c);
if (!p)
return NULL;
xd = p->data;
attr_set_str(&p->attrs, "scale:M", scale);
xd->last_event = time(NULL);
call("editor:request:all-displays", p);
- p = call_ret(pane, "editor:activate-display", p);
return p;
abort:
kbd_free(xd);
if (!d)
return Enoarg;
p = xcb_display_init(d, disp_auth, ci->focus);
- if (p)
- home_call_ret(pane, ci->focus, "doc:attach-view", p, 1);
+ if (strcmp(ci->key, "interactive-cmd-x11window") == 0)
+ p = home_call_ret(pane, p,
+ "window:activate-display", ci->focus);
if (p)
comm_call(ci->comm2, "cb", p);
return 1;
if (term) {
char *TERM = getenv("TERM");
- p = call_ret(pane, "attach-display-ncurses", doc,
+ p = call_ret(pane, "attach-display-ncurses", ed,
0, NULL, "-", 0, NULL, TERM);
if (p) {
char *e;
first_window = p;
call("window:set:no-close", p, 1, NULL,
"Cannot close primary display");
+ home_call(p, "window:activate-display", doc);
}
}
if (gtk) {
p = call_ret(pane, "attach-display-gtk",
- doc, 0, NULL, getenv("DISPLAY"));
+ ed, 0, NULL, getenv("DISPLAY"));
+ home_call(p, "window:activate-display", doc);
if (!first_window)
first_window = p;
}
if (x11) {
p = call_ret(pane, "attach-display-x11",
- doc, 0, NULL, getenv("DISPLAY"),
+ ed, 0, NULL, getenv("DISPLAY"),
0, NULL, getenv("XAUTHORITY"));
+ home_call(p, "window:activate-display", doc);
if (!first_window)
first_window = p;
}
def handle_new(self, key, focus, **a):
"handle:window:new"
- newdisp = EdDisplay(edlib.editor, self['DISPLAY'])
- p = newdisp.call("editor:activate-display", ret='pane')
- if p:
- focus.call("doc:attach-view", p, 1)
+ p = focus.call("attach-window-core", ret='pane')
+ if not p:
+ return edlib.Efail
+ newdisp = EdDisplay(p, self['DISPLAY'])
+ newdisp.call("window:activate-display", focus)
return 1
def handle_external(self, key, str, **a):
self.im.focus_out()
self.in_focus = False
f = self.final_focus
- pt = f.call("doc:point", ret='mark')
- f.call("view:changed", pt)
+ try:
+ pt = f.call("doc:point", ret='mark')
+ f.call("view:changed", pt)
+ except edlib.commandfailed:
+ pass
edlib.time_stop(edlib.TIME_WINDOW)
def reconfigure(self, w, ev):
return None
focus.call("attach-glibevents")
- ed = focus.root
if 'SCALE' in os.environ:
sc = int(os.environ['SCALE'])
s = Gtk.settings_get_default()
s.set_long_property("Gtk-xft-dpi",sc*Pango.SCALE, "code")
- disp = EdDisplay(ed, display)
- p = disp.call("editor:activate-display", ret='pane')
- if p and focus != ed:
- p = focus.call("doc:attach-view", p, 1, ret='pane')
+ p = focus.call("attach-window-core", ret='pane')
+ if not p:
+ return edlib.Efail;
+ disp = EdDisplay(p, display)
+ if key == "interactive-cmd-gtkwindow":
+ p = disp.call("window:activate-display", focus, ret='pane')
if comm2:
comm2('callback', p)
return 1
p = edlib.editor
p = p.call("attach-display-ncurses", path, env['TERM'],
ret='pane')
- self.term = p
for v in env:
- self.term.call("window:set:", env[v], v)
+ p.call("window:set:", env[v], v)
+ p = p.call("window:activate-display", ret='pane')
+ self.term = p
self.disp = self.term
self.add_notify(self.disp, "Notify:Close")
self.sock.send(b"OK")