keymaps.h revision 285830
153405Sarchie/* keymaps.h -- Manipulation of readline keymaps. */ 252419Sjulian 352419Sjulian/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 452419Sjulian 552419Sjulian This file is part of the GNU Readline Library, a library for 652419Sjulian reading lines of text with interactive input and history editing. 752419Sjulian 852419Sjulian The GNU Readline Library is free software; you can redistribute it 952419Sjulian and/or modify it under the terms of the GNU General Public License 1052419Sjulian as published by the Free Software Foundation; either version 2, or 1152419Sjulian (at your option) any later version. 1252419Sjulian 1352419Sjulian The GNU Readline Library is distributed in the hope that it will be 1452419Sjulian useful, but WITHOUT ANY WARRANTY; without even the implied warranty 1552419Sjulian of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1652419Sjulian GNU General Public License for more details. 1752419Sjulian 1852419Sjulian The GNU General Public License is often shipped with GNU software, and 1952419Sjulian is generally kept in a file called COPYING or LICENSE. If you do not 2052419Sjulian have a copy of the license, write to the Free Software Foundation, 2152419Sjulian 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 2252419Sjulian 2352419Sjulian#ifndef _KEYMAPS_H_ 2452419Sjulian#define _KEYMAPS_H_ 2552419Sjulian 2652419Sjulian#ifdef __cplusplus 2752419Sjulianextern "C" { 2852419Sjulian#endif 2952419Sjulian 3052419Sjulian#if defined (READLINE_LIBRARY) 3152419Sjulian# include "rlstdc.h" 3252419Sjulian# include "chardefs.h" 3352419Sjulian# include "rltypedefs.h" 3452419Sjulian#else 3552419Sjulian# include <readline/rlstdc.h> 3652419Sjulian# include <readline/chardefs.h> 3767506Sjulian# include <readline/rltypedefs.h> 3852419Sjulian#endif 3952419Sjulian 4052752Sjulian/* A keymap contains one entry for each key in the ASCII set. 4152419Sjulian Each entry consists of a type and a pointer. 4252443Sjulian FUNCTION is the address of a function to run, or the 4352443Sjulian address of a keymap to indirect through. 4452510Sjulian TYPE says which kind of thing FUNCTION is. */ 4552443Sjuliantypedef struct _keymap_entry { 4652443Sjulian char type; 4752510Sjulian rl_command_func_t *function; 4852443Sjulian} KEYMAP_ENTRY; 4952419Sjulian 5052419Sjulian/* This must be large enough to hold bindings for all of the characters 5152419Sjulian in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, 5252419Sjulian and so on) plus one for subsequence matching. */ 5352419Sjulian#define KEYMAP_SIZE 257 5452419Sjulian#define ANYOTHERKEY KEYMAP_SIZE-1 5552419Sjulian 5652419Sjulian/* I wanted to make the above structure contain a union of: 5752419Sjulian union { rl_command_func_t *function; struct _keymap_entry *keymap; } value; 5852419Sjulian but this made it impossible for me to create a static array. 5952419Sjulian Maybe I need C lessons. */ 6068031Sbrian 6152419Sjuliantypedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; 6252419Sjuliantypedef KEYMAP_ENTRY *Keymap; 6353405Sarchie 6468031Sbrian/* The values that TYPE can have in a keymap entry. */ 6553405Sarchie#define ISFUNC 0 6652419Sjulian#define ISKMAP 1 6752419Sjulian#define ISMACR 2 6852419Sjulian 6952419Sjulianextern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; 7052419Sjulianextern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; 7152752Sjulian 7252752Sjulian/* Return a new, empty keymap. 7370700Sjulian Free it with free() when you are done. */ 7452752Sjulianextern Keymap rl_make_bare_keymap PARAMS((void)); 7552752Sjulian 7652752Sjulian/* Return a new keymap which is a copy of MAP. */ 7752752Sjulianextern Keymap rl_copy_keymap PARAMS((Keymap)); 7852419Sjulian 7968031Sbrian/* Return a new keymap with the printing characters bound to rl_insert, 8068845Sbrian the lowercase Meta characters bound to run their equivalents, and 8168031Sbrian the Meta digits bound to produce numeric arguments. */ 8268845Sbrianextern Keymap rl_make_keymap PARAMS((void)); 8368031Sbrian 8468845Sbrian/* Free the storage associated with a keymap. */ 8568031Sbrianextern void rl_discard_keymap PARAMS((Keymap)); 8668031Sbrian 8768031Sbrian/* These functions actually appear in bind.c */ 8868031Sbrian 8968031Sbrian/* Return the keymap corresponding to a given name. Names look like 9068031Sbrian `emacs' or `emacs-meta' or `vi-insert'. */ 9168031Sbrianextern Keymap rl_get_keymap_by_name PARAMS((const char *)); 9268031Sbrian 9368031Sbrian/* Return the current keymap. */ 9468031Sbrianextern Keymap rl_get_keymap PARAMS((void)); 9568031Sbrian 9668031Sbrian/* Set the current keymap to MAP. */ 9768031Sbrianextern void rl_set_keymap PARAMS((Keymap)); 9868031Sbrian 9968031Sbrian#ifdef __cplusplus 10068031Sbrian} 10168845Sbrian#endif 10268031Sbrian 10368031Sbrian#endif /* _KEYMAPS_H_ */ 10468031Sbrian