From: NeilBrown Date: Tue, 27 Jun 2023 22:35:47 +0000 (+1000) Subject: config: allow initial panes to be set in config file. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=62ac3069d20909a3a72b0c777290e947fcabf063;p=edlib.git config: allow initial panes to be set in config file. 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 --- diff --git a/DOC/TODO.md b/DOC/TODO.md index f28b2141..3578c0cc 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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 diff --git a/core-editor.c b/core-editor.c index 4b9277ee..26b51608 100644 --- a/core-editor.c +++ b/core-editor.c @@ -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; } diff --git a/edlib.ini b/edlib.ini index b4e071ce..449612cd 100644 --- 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