Core features
-------------
+- [ ] Do I want "Display" as in "Display:close", or "window" as in
+ "window:notify". Decide, and make everything consistent.
- [ ] Do I really need global-multicall- or can I just use
notifications.
It would mean more modules would need a private pane, but might
return 1;
}
+DEF_CMD(window_close)
+{
+ pane_close(ci->home);
+ return 1;
+}
+
void window_setup(struct pane *ed safe)
{
window_map = key_alloc();
key_add_prefix(window_map, "window:request:", &request_notify);
key_add_prefix(window_map, "window:notify:", &send_notify);
+ key_add(window_map, "Display:close", &window_close);
+
key_add(window_map, "selection:claim", &selection_claim);
key_add(window_map, "selection:commit", &selection_commit);
key_add(window_map, "selection:discard", &selection_discard);
call_comm("editor:notify:all-displays", ci->focus, &cr.c);
if (cr.i > 1) {
/* Need to call ncurses_end() before we send a Notify:Close
- * notification, else server exists too early
+ * notification, else server exits too early
*/
ncurses_end(ci->home);
- pane_close(ci->home);
+ return Efallthrough;
} else
call("Message", ci->focus, 0, NULL,
"Cannot close only window.");
/* If this is only display, then refuse to close this one */
struct call_return cr;
struct xcb_data *xd = ci->home->data;
+
if (xd->noclose) {
call("Message", ci->focus, 0, NULL, xd->noclose);
return 1;
cr.i = 0;
call_comm("editor:notify:all-displays", ci->focus, &cr.c);
if (cr.i > 1)
- pane_close(ci->home);
+ return Efallthrough;
else
call("Message", ci->focus, 0, NULL,
"Cannot close only window.");
cme->format == 32 &&
cme->window == xd->win &&
cme->data.data32[0] == xd->atoms[a_WM_DELETE_WINDOW]) {
- pane_call(home, "Display:close", pane_leaf(home));
+ call("Display:close", pane_leaf(home));
return;
}
}
xcb_flush(xd->conn);
}
- if (xcb_connection_has_error(xd->conn))
+ if (xcb_connection_has_error(xd->conn)) {
+ call("Display:close", ci->home->parent);
pane_close(ci->home);
+ }
return ret;
}
self.panes = {}
self.bg = {}
self.win.set_title("EDLIB")
- self.win.connect('destroy', self.close_win)
+ self.win.connect('destroy', self.destroy_win)
+ self.win.connect('delete-event', self.close_win)
self.create_ui()
# report approximate size of an "M"
self["scale:M"] = "%dx%d" % (self.charwidth, self.lineheight)
x = []
focus.call("editor:notify:all-displays", lambda key,**a:x.append(1))
if len(x) > 1:
- self.close_win()
+ return edlib.Efallthrough
else:
focus.call("Message", "Cannot close only window.")
return 1
# This must not happen. What should I do?
def close_win(self, *a):
- self.close()
+ self.call("Display:close")
+ return True
+
+ def destroy_win(self, *a):
+ self.parent("Display:close")
+ return False
def create_ui(self):
text = Gtk.DrawingArea()