]> git.neil.brown.name Git - edlib.git/commitdiff
Discard lib-keymap
authorNeilBrown <neil@brown.name>
Sun, 1 Oct 2023 23:50:31 +0000 (10:50 +1100)
committerNeilBrown <neil@brown.name>
Sun, 1 Oct 2023 23:53:17 +0000 (10:53 +1100)
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 <neil@brown.name>
Makefile
data/edlib.ini
data/modules.ini
lib-keymap.c [deleted file]
mode-emacs.c

index f258410f90d1787bb86e15478a07ab0611a48dd1..714ffc5a1d61af2efcad4df09f89a6982e40dc29 100644 (file)
--- 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 \
index 0b23e0938c7af08091bfb3acd60a2c5e89b354e6..8094a7a475a085f251b2a217577ed5ae0ad4fb94 100644 (file)
@@ -4,8 +4,8 @@ include = modules.ini
 [global]
 
 editor-initial-panes = input DISPLAY
-       " x11selection messageline"
-       " global-keymap"
+       " x11selection"
+       " messageline"
        " mode-emacs"
        " menubar"
        " tile"
index f4cf1a2a0ad693d597639830bf3121f2ce139d5f..efe12da40b78bad61fef30b31a13f1667e5c5e51 100644 (file)
@@ -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 (file)
index 80fb59e..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright Neil Brown ©2015-2023 <neil@brown.name>
- * 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 <stdlib.h>
-#include <string.h>
-#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");
-}
index 9061bc02f2e0bef9928baa1857db3dc18792bf92..7ec1765def4736ab44c5be17b7141c66047b3e4b 100644 (file)
@@ -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 <unistd.h>
@@ -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;
 }