Display:set: can be used to set any attribute on the display pane.
The attr name can be in str2, or following Display:set: in the key.
Signed-off-by: NeilBrown <neil@brown.name>
This is a request for the display to close - may be rejected if it is
the only display left.
-## Display:set:no-close
+## Display:set:ATTR
-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,
-that string should be reported via a message, an the close should be
-rejected.
+Set any attribute on the display pane.
+
+The attribute "no-close" affects closing. If a Display:close request
+arrives when "no-close" attribute is a non-empty string, that string
+should be reported via a message, and the close should be rejected.
## Display:external-viewer
return 1;
}
-DEF_CMD(nc_set_noclose)
+DEF_CMD(nc_set_attr)
{
- attr_set_str(&ci->home->attrs, "no-close", ci->str);
+ const char *attr = ci->str2;
+
+ if (!attr)
+ attr = ksuffix(ci, "Display:set:");
+ attr_set_str(&ci->home->attrs, attr, 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:no-close", &nc_set_noclose);
+ key_add_prefix(nc_map, "Display:set:", &nc_set_attr);
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);
return 1;
}
-DEF_CMD(xcb_set_noclose)
+DEF_CMD(xcb_set_attr)
{
- attr_set_str(&ci->home->attrs, "no-close", ci->str);
+ const char *attr = ci->str2;
+
+ if (!attr)
+ attr = ksuffix(ci, "Display:set:");
+ attr_set_str(&ci->home->attrs, attr, ci->str);
return 1;
}
xcb_map = key_alloc();
key_add(xcb_map, "Display:close", &xcb_close_display);
- key_add(xcb_map, "Display:set:no-close", &xcb_set_noclose);
+ key_add_prefix(xcb_map, "Display:set:", &xcb_set_attr);
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);
focus.call("Message", "Cannot close only window.")
return 1
- def handle_set_noclose(self, key, str1, **a):
- "handle:Display:set:no-close"
- self['no-close'] = str1
+ def handle_set_noclose(self, key, str1, str2, **a):
+ "handle-prefix:Display:set:"
+ attr = str2
+ if not attr:
+ attr = key[12:]
+ self[attr] = str1
return 1
def handle_fullscreen(self, key, num, **a):