jpayne@69: /* keymaps.h -- Manipulation of readline keymaps. */
jpayne@69:
jpayne@69: /* Copyright (C) 1987, 1989, 1992-2021 Free Software Foundation, Inc.
jpayne@69:
jpayne@69: This file is part of the GNU Readline Library (Readline), a library
jpayne@69: for reading lines of text with interactive input and history editing.
jpayne@69:
jpayne@69: Readline is free software: you can redistribute it and/or modify
jpayne@69: it under the terms of the GNU General Public License as published by
jpayne@69: the Free Software Foundation, either version 3 of the License, or
jpayne@69: (at your option) any later version.
jpayne@69:
jpayne@69: Readline is distributed in the hope that it will be useful,
jpayne@69: but WITHOUT ANY WARRANTY; without even the implied warranty of
jpayne@69: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jpayne@69: GNU General Public License for more details.
jpayne@69:
jpayne@69: You should have received a copy of the GNU General Public License
jpayne@69: along with Readline. If not, see .
jpayne@69: */
jpayne@69:
jpayne@69: #ifndef _KEYMAPS_H_
jpayne@69: #define _KEYMAPS_H_
jpayne@69:
jpayne@69: #ifdef __cplusplus
jpayne@69: extern "C" {
jpayne@69: #endif
jpayne@69:
jpayne@69: #if defined (READLINE_LIBRARY)
jpayne@69: # include "rlstdc.h"
jpayne@69: # include "chardefs.h"
jpayne@69: # include "rltypedefs.h"
jpayne@69: #else
jpayne@69: # include
jpayne@69: # include
jpayne@69: # include
jpayne@69: #endif
jpayne@69:
jpayne@69: /* A keymap contains one entry for each key in the ASCII set.
jpayne@69: Each entry consists of a type and a pointer.
jpayne@69: FUNCTION is the address of a function to run, or the
jpayne@69: address of a keymap to indirect through.
jpayne@69: TYPE says which kind of thing FUNCTION is. */
jpayne@69: typedef struct _keymap_entry {
jpayne@69: char type;
jpayne@69: rl_command_func_t *function;
jpayne@69: } KEYMAP_ENTRY;
jpayne@69:
jpayne@69: /* This must be large enough to hold bindings for all of the characters
jpayne@69: in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
jpayne@69: and so on) plus one for subsequence matching. */
jpayne@69: #define KEYMAP_SIZE 257
jpayne@69: #define ANYOTHERKEY KEYMAP_SIZE-1
jpayne@69:
jpayne@69: typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
jpayne@69: typedef KEYMAP_ENTRY *Keymap;
jpayne@69:
jpayne@69: /* The values that TYPE can have in a keymap entry. */
jpayne@69: #define ISFUNC 0
jpayne@69: #define ISKMAP 1
jpayne@69: #define ISMACR 2
jpayne@69:
jpayne@69: extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
jpayne@69: extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
jpayne@69:
jpayne@69: /* Return a new, empty keymap.
jpayne@69: Free it with free() when you are done. */
jpayne@69: extern Keymap rl_make_bare_keymap (void);
jpayne@69:
jpayne@69: /* Return a new keymap which is a copy of MAP. */
jpayne@69: extern Keymap rl_copy_keymap (Keymap);
jpayne@69:
jpayne@69: /* Return a new keymap with the printing characters bound to rl_insert,
jpayne@69: the lowercase Meta characters bound to run their equivalents, and
jpayne@69: the Meta digits bound to produce numeric arguments. */
jpayne@69: extern Keymap rl_make_keymap (void);
jpayne@69:
jpayne@69: /* Free the storage associated with a keymap. */
jpayne@69: extern void rl_discard_keymap (Keymap);
jpayne@69:
jpayne@69: /* These functions actually appear in bind.c */
jpayne@69:
jpayne@69: /* Return the keymap corresponding to a given name. Names look like
jpayne@69: `emacs' or `emacs-meta' or `vi-insert'. */
jpayne@69: extern Keymap rl_get_keymap_by_name (const char *);
jpayne@69:
jpayne@69: /* Return the current keymap. */
jpayne@69: extern Keymap rl_get_keymap (void);
jpayne@69:
jpayne@69: /* Set the current keymap to MAP. */
jpayne@69: extern void rl_set_keymap (Keymap);
jpayne@69:
jpayne@69: /* Set the name of MAP to NAME */
jpayne@69: extern int rl_set_keymap_name (const char *, Keymap);
jpayne@69:
jpayne@69: #ifdef __cplusplus
jpayne@69: }
jpayne@69: #endif
jpayne@69:
jpayne@69: #endif /* _KEYMAPS_H_ */