summaryrefslogtreecommitdiffstats
path: root/examples/rlkeymaps.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:51:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:51:56 +0000
commitc77311c90aa045796b3adcd021e69901022f4649 (patch)
tree3a6c4cc9271c6f7f7c24feff0d1aea286eed0a06 /examples/rlkeymaps.c
parentInitial commit. (diff)
downloadreadline-c77311c90aa045796b3adcd021e69901022f4649.tar.xz
readline-c77311c90aa045796b3adcd021e69901022f4649.zip
Adding upstream version 8.2.upstream/8.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/rlkeymaps.c')
-rw-r--r--examples/rlkeymaps.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/examples/rlkeymaps.c b/examples/rlkeymaps.c
new file mode 100644
index 0000000..fef77b3
--- /dev/null
+++ b/examples/rlkeymaps.c
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
+
+int
+main (int c, char **v)
+{
+ Keymap nmap, emacsmap, newemacs;
+ int r, errs;
+
+ errs = 0;
+ nmap = rl_make_keymap ();
+
+ r = rl_set_keymap_name ("emacs", nmap);
+ if (r >= 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n");
+ errs++;
+ }
+
+ emacsmap = rl_get_keymap_by_name ("emacs");
+ r = rl_set_keymap_name ("newemacs", emacsmap);
+ if (r >= 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n");
+ errs++;
+ }
+
+ r = rl_set_keymap_name ("newemacs", nmap);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n");
+ errs++;
+ }
+
+ newemacs = rl_copy_keymap (emacsmap);
+ r = rl_set_keymap_name ("newemacs", newemacs);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n");
+ errs++;
+ }
+
+ r = rl_set_keymap_name ("emacscopy", newemacs);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n");
+ errs++;
+ }
+
+ exit (errs);
+}