keymaps.h revision 21308
150397Sobrien/* keymaps.h -- Manipulation of readline keymaps. */
290075Sobrien
3169689Skan/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
4117395Skan
550397Sobrien   This file is part of the GNU Readline Library, a library for
6132718Skan   reading lines of text with interactive input and history editing.
750397Sobrien
8132718Skan   The GNU Readline Library is free software; you can redistribute it
950397Sobrien   and/or modify it under the terms of the GNU General Public License
1050397Sobrien   as published by the Free Software Foundation; either version 1, or
1150397Sobrien   (at your option) any later version.
1250397Sobrien
13132718Skan   The GNU Readline Library is distributed in the hope that it will be
1450397Sobrien   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
1550397Sobrien   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1650397Sobrien   GNU General Public License for more details.
1750397Sobrien
1850397Sobrien   The GNU General Public License is often shipped with GNU software, and
19132718Skan   is generally kept in a file called COPYING or LICENSE.  If you do not
20169689Skan   have a copy of the license, write to the Free Software Foundation,
21169689Skan   675 Mass Ave, Cambridge, MA 02139, USA. */
2250397Sobrien
23132718Skan#ifndef _KEYMAPS_H_
24132718Skan#define _KEYMAPS_H_
2550397Sobrien
26132718Skan#if defined (READLINE_LIBRARY)
27117395Skan#  include "chardefs.h"
28117395Skan#else
29117395Skan#  include <readline/chardefs.h>
30117395Skan#endif
31117395Skan
32132718Skan#if !defined (_FUNCTION_DEF)
33132718Skan#  define _FUNCTION_DEF
34132718Skantypedef int Function ();
35117395Skantypedef void VFunction ();
36117395Skantypedef char *CPFunction ();
3750397Sobrientypedef char **CPPFunction ();
38132718Skan#endif
39132718Skan
4050397Sobrien/* A keymap contains one entry for each key in the ASCII set.
41132718Skan   Each entry consists of a type and a pointer.
4290075Sobrien   POINTER is the address of a function to run, or the
4390075Sobrien   address of a keymap to indirect through.
4450397Sobrien   TYPE says which kind of thing POINTER is. */
4552284Sobrientypedef struct _keymap_entry {
46117395Skan  char type;
4752284Sobrien  Function *function;
4850397Sobrien} KEYMAP_ENTRY;
4950397Sobrien
5050397Sobrien/* This must be large enough to hold bindings for all of the characters
5190075Sobrien   in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
5252284Sobrien   and so on). */
5350397Sobrien#define KEYMAP_SIZE 256
5450397Sobrien
5590075Sobrien/* I wanted to make the above structure contain a union of:
5690075Sobrien   union { Function *function; struct _keymap_entry *keymap; } value;
5790075Sobrien   but this made it impossible for me to create a static array.
5890075Sobrien   Maybe I need C lessons. */
5990075Sobrien
6090075Sobrientypedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
6190075Sobrientypedef KEYMAP_ENTRY *Keymap;
6290075Sobrien
6390075Sobrien/* The values that TYPE can have in a keymap entry. */
6450397Sobrien#define ISFUNC 0
6590075Sobrien#define ISKMAP 1
66117395Skan#define ISMACR 2
6750397Sobrien
6850397Sobrienextern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
6990075Sobrienextern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
7090075Sobrien
7150397Sobrien/* Return a new, empty keymap.
72169689Skan   Free it with free() when you are done. */
73169689Skanextern Keymap rl_make_bare_keymap ();
74169689Skan
75169689Skan/* Return a new keymap which is a copy of MAP. */
76169689Skanextern Keymap rl_copy_keymap ();
77169689Skan
78169689Skan/* Return a new keymap with the printing characters bound to rl_insert,
7950397Sobrien   the lowercase Meta characters bound to run their equivalents, and
8090075Sobrien   the Meta digits bound to produce numeric arguments. */
81132718Skanextern Keymap rl_make_keymap ();
82117395Skan
8390075Sobrienextern void rl_discard_keymap ();
84117395Skan
85117395Skan/* Return the keymap corresponding to a given name.  Names look like
86117395Skan   `emacs' or `emacs-meta' or `vi-insert'. */
87117395Skanextern Keymap rl_get_keymap_by_name ();
88117395Skan
89117395Skan/* Return the current keymap. */
90117395Skanextern Keymap rl_get_keymap ();
91117395Skan
92117395Skan/* Set the current keymap to MAP. */
93117395Skanextern void rl_set_keymap ();
94117395Skan
95117395Skan#endif /* _KEYMAPS_H_ */
96117395Skan