]> git.neil.brown.name Git - edlib.git/commitdiff
Introduce generic Display:set:
authorNeilBrown <neil@brown.name>
Fri, 25 Aug 2023 05:04:28 +0000 (15:04 +1000)
committerNeilBrown <neil@brown.name>
Fri, 25 Aug 2023 05:35:37 +0000 (15:35 +1000)
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>
DOC/Calls
display-ncurses.c
display-x11-xcb.c
python/display-pygtk.py

index 84c20e8262846f160e6e39415ed7874ef461dffd..a9400513fefe9f4b417175506406bb27d7269d4c 100644 (file)
--- a/DOC/Calls
+++ b/DOC/Calls
@@ -152,12 +152,13 @@ display can be awkward.
 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
 
index 167048cd8c2fcd3c5a861b74b0ff8ff0975e06c9..3178b355046602879a026af8004c19054b7f8381 100644 (file)
@@ -463,9 +463,13 @@ DEF_CMD(nc_close_display)
        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;
 }
 
@@ -1818,7 +1822,7 @@ void edlib_init(struct pane *ed safe)
        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);
index 63c0e875dcdcc3bd08af72e47a084c8ddc927cc1..fe3fd37705728f15e9d7dc03c0bcec99cd6a3386 100644 (file)
@@ -463,9 +463,13 @@ DEF_CMD(xcb_close_display)
        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;
 }
 
@@ -2003,7 +2007,7 @@ void edlib_init(struct pane *ed safe)
        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);
index 7d2c9954f9f27f4be910f2e3b7d0bc2d24c2b18d..bb09ca96539beffde93060b6467e8ad59dfb5833 100644 (file)
@@ -85,9 +85,12 @@ class EdDisplay(edlib.Pane):
             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):