00001 /* keymaps.h -- Manipulation of readline keymaps. */ 00002 00003 /* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 00004 00005 This file is part of the GNU Readline Library, a library for 00006 reading lines of text with interactive input and history editing. 00007 00008 The GNU Readline Library is free software; you can redistribute it 00009 and/or modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2, or 00011 (at your option) any later version. 00012 00013 The GNU Readline Library is distributed in the hope that it will be 00014 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00015 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 The GNU General Public License is often shipped with GNU software, and 00019 is generally kept in a file called COPYING or LICENSE. If you do not 00020 have a copy of the license, write to the Free Software Foundation, 00021 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 00022 00023 #ifndef _KEYMAPS_H_ 00024 #define _KEYMAPS_H_ 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 #if defined (READLINE_LIBRARY) 00031 # include "rlstdc.h" 00032 # include "chardefs.h" 00033 # include "rltypedefs.h" 00034 #else 00035 # include <readline/rlstdc.h> 00036 # include <readline/chardefs.h> 00037 # include <readline/rltypedefs.h> 00038 #endif 00039 00040 /* A keymap contains one entry for each key in the ASCII set. 00041 Each entry consists of a type and a pointer. 00042 FUNCTION is the address of a function to run, or the 00043 address of a keymap to indirect through. 00044 TYPE says which kind of thing FUNCTION is. */ 00045 typedef struct _keymap_entry { 00046 char type; 00047 rl_command_func_t *function; 00048 } KEYMAP_ENTRY; 00049 00050 /* This must be large enough to hold bindings for all of the characters 00051 in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, 00052 and so on) plus one for subsequence matching. */ 00053 #define KEYMAP_SIZE 257 00054 #define ANYOTHERKEY KEYMAP_SIZE-1 00055 00056 /* I wanted to make the above structure contain a union of: 00057 union { rl_command_func_t *function; struct _keymap_entry *keymap; } value; 00058 but this made it impossible for me to create a static array. 00059 Maybe I need C lessons. */ 00060 00061 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; 00062 typedef KEYMAP_ENTRY *Keymap; 00063 00064 /* The values that TYPE can have in a keymap entry. */ 00065 #define ISFUNC 0 00066 #define ISKMAP 1 00067 #define ISMACR 2 00068 00069 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; 00070 extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; 00071 00072 /* Return a new, empty keymap. 00073 Free it with free() when you are done. */ 00074 extern Keymap rl_make_bare_keymap PARAMS((void)); 00075 00076 /* Return a new keymap which is a copy of MAP. */ 00077 extern Keymap rl_copy_keymap PARAMS((Keymap)); 00078 00079 /* Return a new keymap with the printing characters bound to rl_insert, 00080 the lowercase Meta characters bound to run their equivalents, and 00081 the Meta digits bound to produce numeric arguments. */ 00082 extern Keymap rl_make_keymap PARAMS((void)); 00083 00084 /* Free the storage associated with a keymap. */ 00085 extern void rl_discard_keymap PARAMS((Keymap)); 00086 00087 /* These functions actually appear in bind.c */ 00088 00089 /* Return the keymap corresponding to a given name. Names look like 00090 `emacs' or `emacs-meta' or `vi-insert'. */ 00091 extern Keymap rl_get_keymap_by_name PARAMS((const char *)); 00092 00093 /* Return the current keymap. */ 00094 extern Keymap rl_get_keymap PARAMS((void)); 00095 00096 /* Set the current keymap to MAP. */ 00097 extern void rl_set_keymap PARAMS((Keymap)); 00098 00099 #ifdef __cplusplus 00100 } 00101 #endif 00102 00103 #endif /* _KEYMAPS_H_ */