Annotation of embedaddon/readline/examples/rlkeymaps.c, revision 1.1

1.1     ! misho       1: #include <stdlib.h>
        !             2: #include <unistd.h>
        !             3: #include <stdio.h>
        !             4: #include <string.h>
        !             5: 
        !             6: #if defined (READLINE_LIBRARY)
        !             7: #  include "readline.h"
        !             8: #  include "history.h"
        !             9: #else
        !            10: #  include <readline/readline.h>
        !            11: #  include <readline/history.h>
        !            12: #endif
        !            13: 
        !            14: int
        !            15: main (int c, char **v)
        !            16: {
        !            17:   Keymap nmap, emacsmap, newemacs;
        !            18:   int r, errs;
        !            19: 
        !            20:   errs = 0;
        !            21:   nmap = rl_make_keymap ();
        !            22: 
        !            23:   r = rl_set_keymap_name ("emacs", nmap);
        !            24:   if (r >= 0)
        !            25:     {
        !            26:       fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n");
        !            27:       errs++;
        !            28:     }
        !            29: 
        !            30:   emacsmap = rl_get_keymap_by_name ("emacs");
        !            31:   r = rl_set_keymap_name ("newemacs", emacsmap);
        !            32:   if (r >= 0)
        !            33:     {
        !            34:       fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n");
        !            35:       errs++;
        !            36:     }
        !            37: 
        !            38:   r = rl_set_keymap_name ("newemacs", nmap);
        !            39:   if (r < 0)
        !            40:     {
        !            41:       fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n");
        !            42:       errs++;
        !            43:     }
        !            44: 
        !            45:   newemacs = rl_copy_keymap (emacsmap);
        !            46:   r = rl_set_keymap_name ("newemacs", newemacs);
        !            47:   if (r < 0)
        !            48:     {
        !            49:       fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n");
        !            50:       errs++;
        !            51:     }
        !            52: 
        !            53:   r = rl_set_keymap_name ("emacscopy", newemacs);
        !            54:   if (r < 0)
        !            55:     {
        !            56:       fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n");
        !            57:       errs++;
        !            58:     }
        !            59: 
        !            60:   exit (errs);
        !            61: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>