From: NeilBrown Date: Sun, 1 Oct 2023 23:50:31 +0000 (+1100) Subject: Discard lib-keymap X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=7fdf861845c5d7b09e41dff86e4d491902be6f3c;p=edlib.git Discard lib-keymap lib-keymap was an idea that turned out not to be useful. Discard it and make 'mode-emacs' into a regular pane. Signed-off-by: NeilBrown --- diff --git a/Makefile b/Makefile index f258410f..714ffc5a 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ SHOBJ = O/doc-text.o O/doc-dir.o O/doc-docs.o \ O/render-hex.o O/render-lines.o \ O/render-format.o O/render-complete.o \ O/render-imageview.o \ - O/lib-view.o O/lib-tile.o O/lib-popup.o O/lib-linecount.o O/lib-keymap.o \ + O/lib-view.o O/lib-tile.o O/lib-popup.o O/lib-linecount.o \ O/lib-search.o O/lib-messageline.o O/lib-input.o O/lib-libevent.o \ O/lib-history.o O/lib-crop.o O/lib-markup.o O/lib-rfc822header.o \ O/lib-viewer.o O/lib-base64.o O/lib-qprint.o O/lib-utf8.o \ diff --git a/data/edlib.ini b/data/edlib.ini index 0b23e093..8094a7a4 100644 --- a/data/edlib.ini +++ b/data/edlib.ini @@ -4,8 +4,8 @@ include = modules.ini [global] editor-initial-panes = input DISPLAY - " x11selection messageline" - " global-keymap" + " x11selection" + " messageline" " mode-emacs" " menubar" " tile" diff --git a/data/modules.ini b/data/modules.ini index f4cf1a2a..efe12da4 100644 --- a/data/modules.ini +++ b/data/modules.ini @@ -139,7 +139,6 @@ lib-base64 = attach-base64 lib-crop = attach-crop lib-history = attach-history lib-input = attach-input -lib-keymap = attach-keymap lib-libevent = attach-libevent lib-linefilter = attach-linefilter lib-markup = attach-markup @@ -152,7 +151,6 @@ lib-renderline = attach-renderline lib-rfc822header = attach-rfc822header lib-tile = attach-tile lib-view = attach-view -lib-keymap = attach-global-keymap lib-glibevents = attach-glibevents lib-shellcmd = attach-shellcmd diff --git a/lib-keymap.c b/lib-keymap.c deleted file mode 100644 index 80fb59e4..00000000 --- a/lib-keymap.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright Neil Brown ©2015-2023 - * May be distributed under terms of GPLv2 - see file:COPYING - * - * Keymap management panes for edlib. - * - * A keymap pane makes it easy to attach keymaps into a pane tree. - * global-set-keymap - * is given a command which is used to as all incoming requests. - */ - -#include -#include -#define PANE_DATA_TYPE struct key_data -#include "core.h" - -struct key_data { - struct command *globalcmd; -}; -#include "core-pane.h" - -static struct pane *safe do_keymap_attach(struct pane *p safe); - -DEF_CMD_CLOSED(keymap_handle) -{ - struct key_data *kd = ci->home->data; - - if (strcmp(ci->key, "Close") == 0) { - command_put(kd->globalcmd); - return 1; - } - if (ci->home->damaged & DAMAGED_CLOSED) - return Efallthrough; - - if (strcmp(ci->key, "Clone") == 0) { - struct pane *p = do_keymap_attach(ci->focus); - struct key_data *kd_old = ci->home->data; - struct key_data *kd_new; - if (!p) - return Efail; - kd_new = p->data; - if (kd_old->globalcmd) - kd_new->globalcmd = command_get(kd_old->globalcmd); - - pane_clone_children(ci->home, p); - return 1; - } - - if (kd->globalcmd) { - int ret; - ((struct cmd_info*)ci)->comm = kd->globalcmd; - ret = kd->globalcmd->func(ci); - if (ret) - return ret; - } - if (strcmp(ci->key, "global-set-keymap") == 0) { - struct command *cm = ci->comm2; - if (!cm) - return Enoarg; - command_put(kd->globalcmd); - kd->globalcmd = command_get(cm); - return 1; - } - - return Efallthrough; -} - -static struct pane *safe do_keymap_attach(struct pane *p safe) -{ - return pane_register(p, 0, &keymap_handle); -} - -DEF_CMD(keymap_attach) -{ - struct pane *p = do_keymap_attach(ci->focus); - if (p) - return comm_call(ci->comm2, "callback:attach", p); - return Efail; -} - -void edlib_init(struct pane *ed safe) -{ - call_comm("global-set-command", ed, &keymap_attach, 0, NULL, - "attach-global-keymap"); -} diff --git a/mode-emacs.c b/mode-emacs.c index 9061bc02..7ec1765d 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -5,8 +5,6 @@ * Define some keystrokes to create an editor with an * "emacs" feel. * - * We register an 'emacs' mode and associate keys with that - * in the global keymap. */ #define _GNU_SOURCE /* for asprintf */ #include @@ -3605,7 +3603,11 @@ DEF_LOOKUP_CMD(mode_emacs, emacs_map); DEF_CMD(attach_mode_emacs) { - call_comm("global-set-keymap", ci->focus, &mode_emacs.c); + struct pane *p = pane_register(ci->focus, 0, &mode_emacs.c, NULL); + + if (!p) + return Efail; + comm_call(ci->comm2, "cb", p); return 1; }