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 \
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
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
+++ /dev/null
-/*
- * 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");
-}
* 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>
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;
}