keymaps.h revision 58310
121308Sache/* keymaps.h -- Manipulation of readline keymaps. */ 221308Sache 321308Sache/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 421308Sache 521308Sache This file is part of the GNU Readline Library, a library for 621308Sache reading lines of text with interactive input and history editing. 721308Sache 821308Sache The GNU Readline Library is free software; you can redistribute it 921308Sache and/or modify it under the terms of the GNU General Public License 1058310Sache as published by the Free Software Foundation; either version 2, or 1121308Sache (at your option) any later version. 1221308Sache 1321308Sache The GNU Readline Library is distributed in the hope that it will be 1421308Sache useful, but WITHOUT ANY WARRANTY; without even the implied warranty 1521308Sache of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1621308Sache GNU General Public License for more details. 1721308Sache 1821308Sache The GNU General Public License is often shipped with GNU software, and 1921308Sache is generally kept in a file called COPYING or LICENSE. If you do not 2021308Sache have a copy of the license, write to the Free Software Foundation, 2158310Sache 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 2221308Sache 2321308Sache#ifndef _KEYMAPS_H_ 2421308Sache#define _KEYMAPS_H_ 2521308Sache 2658310Sache#ifdef __cplusplus 2758310Sacheextern "C" { 2858310Sache#endif 2958310Sache 3021308Sache#if defined (READLINE_LIBRARY) 3147558Sache# include "rlstdc.h" 3221308Sache# include "chardefs.h" 3321308Sache#else 3447558Sache# include <readline/rlstdc.h> 3521308Sache# include <readline/chardefs.h> 3621308Sache#endif 3721308Sache 3821308Sache#if !defined (_FUNCTION_DEF) 3921308Sache# define _FUNCTION_DEF 4021308Sachetypedef int Function (); 4121308Sachetypedef void VFunction (); 4221308Sachetypedef char *CPFunction (); 4321308Sachetypedef char **CPPFunction (); 4421308Sache#endif 4521308Sache 4621308Sache/* A keymap contains one entry for each key in the ASCII set. 4721308Sache Each entry consists of a type and a pointer. 4835486Sache FUNCTION is the address of a function to run, or the 4921308Sache address of a keymap to indirect through. 5035486Sache TYPE says which kind of thing FUNCTION is. */ 5121308Sachetypedef struct _keymap_entry { 5221308Sache char type; 5321308Sache Function *function; 5421308Sache} KEYMAP_ENTRY; 5521308Sache 5621308Sache/* This must be large enough to hold bindings for all of the characters 5721308Sache in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, 5821308Sache and so on). */ 5921308Sache#define KEYMAP_SIZE 256 6021308Sache 6121308Sache/* I wanted to make the above structure contain a union of: 6221308Sache union { Function *function; struct _keymap_entry *keymap; } value; 6321308Sache but this made it impossible for me to create a static array. 6421308Sache Maybe I need C lessons. */ 6521308Sache 6621308Sachetypedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; 6721308Sachetypedef KEYMAP_ENTRY *Keymap; 6821308Sache 6921308Sache/* The values that TYPE can have in a keymap entry. */ 7021308Sache#define ISFUNC 0 7121308Sache#define ISKMAP 1 7221308Sache#define ISMACR 2 7321308Sache 7421308Sacheextern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; 7521308Sacheextern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; 7621308Sache 7721308Sache/* Return a new, empty keymap. 7821308Sache Free it with free() when you are done. */ 7947558Sacheextern Keymap rl_make_bare_keymap __P((void)); 8021308Sache 8121308Sache/* Return a new keymap which is a copy of MAP. */ 8247558Sacheextern Keymap rl_copy_keymap __P((Keymap)); 8321308Sache 8421308Sache/* Return a new keymap with the printing characters bound to rl_insert, 8521308Sache the lowercase Meta characters bound to run their equivalents, and 8621308Sache the Meta digits bound to produce numeric arguments. */ 8747558Sacheextern Keymap rl_make_keymap __P((void)); 8821308Sache 8947558Sache/* Free the storage associated with a keymap. */ 9047558Sacheextern void rl_discard_keymap __P((Keymap)); 9121308Sache 9247558Sache/* These functions actually appear in bind.c */ 9347558Sache 9421308Sache/* Return the keymap corresponding to a given name. Names look like 9547558Sache `emacs' or `emacs-meta' or `vi-insert'. */ 9647558Sacheextern Keymap rl_get_keymap_by_name __P((char *)); 9721308Sache 9821308Sache/* Return the current keymap. */ 9947558Sacheextern Keymap rl_get_keymap __P((void)); 10021308Sache 10121308Sache/* Set the current keymap to MAP. */ 10247558Sacheextern void rl_set_keymap __P((Keymap)); 10321308Sache 10458310Sache#ifdef __cplusplus 10558310Sache} 10658310Sache#endif 10758310Sache 10821308Sache#endif /* _KEYMAPS_H_ */ 109