]> git.neil.brown.name Git - edlib.git/commitdiff
config: allow initial panes to be set in config file.
authorNeilBrown <neil@brown.name>
Tue, 27 Jun 2023 22:35:47 +0000 (08:35 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:41 +0000 (17:51 +1000)
Changing the initial panes for a display give lots of control to the
user, and particularly will allow alternate key mapping to emacs.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
core-editor.c
edlib.ini

index f28b2141d560805951291cac625d6153ced0576f..3578c0cc711a01902f967ae9fc6e81b7651dc986 100644 (file)
@@ -767,7 +767,7 @@ Module features
 
 - [X] C config module that reads an ini-style file to set attributes
       based on path
-- [ ] configure "initial_panes"
+- [X] configure "initial_panes"
 - [X] discard old auto-load??
 - [ ] file patterns for "complete" to (optionally) ignore
 - [ ] read .gitignore and add to "ignore" list
index 4b9277ee4b8c325bc9138895ae199988a2a6c0ae..26b516080c3e04f7026b4e9b27a0f8fb589bab45 100644 (file)
@@ -217,15 +217,6 @@ DEF_CMD(editor_auto_event)
        return key_lookup_prefix(map, ci);
 }
 
-static const char *initial_panes[] = {
-       "attach-x11selection",
-       "attach-messageline",
-       "attach-global-keymap",
-       "attach-mode-emacs",
-       "attach-tile",
-       NULL
-};
-
 DEF_CMD(editor_activate_display)
 {
        /* Given a display attached to the root, integrate it
@@ -233,17 +224,30 @@ DEF_CMD(editor_activate_display)
         */
        struct pane *disp = ci->focus;
        struct pane *p, *p2;
-       int i;
+       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-input", p);
-       if (p2)
-               pane_reparent(disp, p2);
-       p = disp;
-       for (i = 0; initial_panes[i]; i++) {
-               const char *cmd = initial_panes[i];
-               if (cmd)
-                       p2 = call_ret(pane, cmd, p);
+
+       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;
        }
index b4e071ce9078646819fce8df4338d9715ee13635..449612cdf0d981835cc08792b591f6d05e0e4090 100644 (file)
--- a/edlib.ini
+++ b/edlib.ini
@@ -1,6 +1,11 @@
 [include]
 include = modules.ini
 
+[global]
+
+editor-initial-panes = input DISPLAY
+       " x11selection messageline"
+       " global-keymap mode-emacs tile"
 [file:COMMIT_EDITMSG*]
 APPEND view-default = ,textfill,whitespace,autospell
 fill-width = 72