This is a request for the display to close - may be rejected if it is
the only display left.
-## Display:set-noclose
+## Display:set:no-close
This comes with a reason in str1. If a Display:close request arrives
when the most recent set-noclose request contained a non-empty string,
## Display management commands
Display:close
-Display:set-noclose
+Display:set:no-close
Display:external-viewer
Display:fullscreen
Display:new
SCREEN *scr;
FILE *scr_file;
int is_xterm;
- char *noclose;
struct col_hash *col_hash;
int report_position;
long last_event;
{
/* If this is only display, then refuse to close this one */
struct call_return cr;
- struct display_data *dd = &ci->home->data;
+ char *nc = attr_find(ci->home->attrs, "no-close");
- if (dd->noclose) {
- call("Message", ci->focus, 0, NULL, dd->noclose);
+ if (nc) {
+ call("Message", ci->focus, 0, NULL, nc);
return 1;
}
DEF_CMD(nc_set_noclose)
{
- struct display_data *dd = &ci->home->data;
-
- free(dd->noclose);
- dd->noclose = NULL;
- if (ci->str)
- dd->noclose = strdup(ci->str);
+ attr_set_str(&ci->home->attrs, "no-close", ci->str);
return 1;
}
nc_map = key_alloc();
key_add(nc_map, "Display:refresh", &force_redraw);
key_add(nc_map, "Display:close", &nc_close_display);
- key_add(nc_map, "Display:set-noclose", &nc_set_noclose);
+ key_add(nc_map, "Display:set:no-close", &nc_set_noclose);
key_add(nc_map, "Display:external-viewer", &nc_external_viewer);
key_add(nc_map, "Close", &nc_close);
key_add(nc_map, "Draw:clear", &nc_clear);
cairo_t *cairo safe;
cairo_surface_t *surface safe;
PangoFontDescription *fd safe;
- char *noclose;
int charwidth, lineheight;
cairo_region_t *need_update;
{
/* If this is only display, then refuse to close this one */
struct call_return cr;
- struct xcb_data *xd = &ci->home->data;
+ char *nc = attr_find(ci->home->attrs, "no-close");
- if (xd->noclose) {
- call("Message", ci->focus, 0, NULL, xd->noclose);
+ if (nc) {
+ call("Message", ci->focus, 0, NULL, nc);
return 1;
}
cr.c = cnt_disp;
DEF_CMD(xcb_set_noclose)
{
- struct xcb_data *xd = &ci->home->data;
-
- free(xd->noclose);
- xd->noclose = NULL;
- if (ci->str)
- xd->noclose = strdup(ci->str);
+ attr_set_str(&ci->home->attrs, "no-close", ci->str);
return 1;
}
cairo_surface_destroy(xd->surface);
free(xd->display);
free(xd->disp_auth);
- free(xd->noclose);
xcb_disconnect(xd->conn);
if (xd->need_update)
cairo_region_destroy(xd->need_update);
xcb_map = key_alloc();
key_add(xcb_map, "Display:close", &xcb_close_display);
- key_add(xcb_map, "Display:set-noclose", &xcb_set_noclose);
+ key_add(xcb_map, "Display:set:no-close", &xcb_set_noclose);
key_add(xcb_map, "Display:external-viewer", &xcb_external_viewer);
key_add(xcb_map, "Display:fullscreen", &xcb_fullscreen);
key_add(xcb_map, "Display:new", &xcb_new_display);
0, NULL, getenv("XAUTHORITY"));
if (!first_window)
first_window = p;
- call("Display:set-noclose", p, 1, NULL,
+ call("Display:set:no-close", p, 1, NULL,
"Cannot close primary display");
}
}
self.w = int(self.charwidth * 80.0)
self.h = int(self.lineheight * 24.0)
self.call("editor:request:all-displays")
- self.noclose = None
self.last_event = 0
self.win.show()
def handle_close_window(self, key, focus, **a):
"handle:Display:close"
- if self.noclose:
- focus.call("Message", self.noclose)
+ nc = self['no-close']
+ if nc:
+ focus.call("Message", nc)
return 1
x = []
focus.call("editor:notify:all-displays", lambda key,**a:x.append(1))
focus.call("Message", "Cannot close only window.")
return 1
- def handle_set_noclose(self, key, str, **a):
- "handle:Display:set-noclose"
- self.noclose = str
+ def handle_set_noclose(self, key, str1, **a):
+ "handle:Display:set:no-close"
+ self['no-close'] = str1
return 1
def handle_fullscreen(self, key, num, **a):
self.add_notify(d, "Notify:Close")
self.doc = d
if self.term:
- self.term.call("Display:set-noclose",
+ self.term.call("Display:set:no-close",
"Cannot close display until document done - use 'C-x #'")
self.sock.send(b"OK")
return 1
return 1
if cmd == "close":
if self.disp:
- self.disp.call("Display:set-noclose")
+ self.disp.call("Display:set:no-close")
self.disp.call("Display:close")
self.disp = None
self.call("event:free", self.read)
# same as doc:done
self.doc = None
if self.term:
- self.term.call("Display:set-noclose")
+ self.term.call("Display:set:no-close")
self.term.call("Display:close")
self.sock.send(b"Done")
return 1
"handle:doc:done"
if str != "test":
if self.term:
- self.term.call("Display:set-noclose")
+ self.term.call("Display:set:no-close")
self.term.call("Display:close")
self.sock.send(b"Done")
return 1