blob: af8d5d997d4b7de21ebc4f3bc13c3ea0169a6f31 [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* keymaps.h -- Manipulation of readline keymaps. */
2
3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
4
Jari Aalto31859422009-01-12 13:36:28 +00005 This file is part of the GNU Readline Library (Readline), a library
6 for reading lines of text with interactive input and history editing.
Jari Aalto726f6381996-08-26 18:22:31 +00007
Jari Aalto31859422009-01-12 13:36:28 +00008 Readline is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
Jari Aalto726f6381996-08-26 18:22:31 +000011 (at your option) any later version.
12
Jari Aalto31859422009-01-12 13:36:28 +000013 Readline is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Jari Aalto726f6381996-08-26 18:22:31 +000016 GNU General Public License for more details.
17
Jari Aalto31859422009-01-12 13:36:28 +000018 You should have received a copy of the GNU General Public License
19 along with Readline. If not, see <http://www.gnu.org/licenses/>.
20*/
Jari Aalto726f6381996-08-26 18:22:31 +000021
22#ifndef _KEYMAPS_H_
23#define _KEYMAPS_H_
24
Jari Aaltobb706242000-03-17 21:46:59 +000025#ifdef __cplusplus
26extern "C" {
27#endif
28
Jari Aalto726f6381996-08-26 18:22:31 +000029#if defined (READLINE_LIBRARY)
Jari Aaltob72432f1999-02-19 17:11:39 +000030# include "rlstdc.h"
Jari Aalto726f6381996-08-26 18:22:31 +000031# include "chardefs.h"
Jari Aalto28ef6c32001-04-06 19:14:31 +000032# include "rltypedefs.h"
Jari Aalto726f6381996-08-26 18:22:31 +000033#else
Jari Aaltob72432f1999-02-19 17:11:39 +000034# include <readline/rlstdc.h>
Jari Aalto726f6381996-08-26 18:22:31 +000035# include <readline/chardefs.h>
Jari Aalto28ef6c32001-04-06 19:14:31 +000036# include <readline/rltypedefs.h>
Jari Aalto726f6381996-08-26 18:22:31 +000037#endif
38
39/* A keymap contains one entry for each key in the ASCII set.
40 Each entry consists of a type and a pointer.
Jari Aaltocce855b1998-04-17 19:52:44 +000041 FUNCTION is the address of a function to run, or the
Jari Aalto726f6381996-08-26 18:22:31 +000042 address of a keymap to indirect through.
Jari Aaltocce855b1998-04-17 19:52:44 +000043 TYPE says which kind of thing FUNCTION is. */
Jari Aalto726f6381996-08-26 18:22:31 +000044typedef struct _keymap_entry {
45 char type;
Jari Aalto28ef6c32001-04-06 19:14:31 +000046 rl_command_func_t *function;
Jari Aalto726f6381996-08-26 18:22:31 +000047} KEYMAP_ENTRY;
48
49/* This must be large enough to hold bindings for all of the characters
50 in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
Jari Aalto7117c2d2002-07-17 14:10:11 +000051 and so on) plus one for subsequence matching. */
52#define KEYMAP_SIZE 257
53#define ANYOTHERKEY KEYMAP_SIZE-1
Jari Aalto726f6381996-08-26 18:22:31 +000054
Jari Aalto726f6381996-08-26 18:22:31 +000055typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
56typedef KEYMAP_ENTRY *Keymap;
57
58/* The values that TYPE can have in a keymap entry. */
59#define ISFUNC 0
60#define ISKMAP 1
61#define ISMACR 2
62
63extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
64extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
65
66/* Return a new, empty keymap.
67 Free it with free() when you are done. */
Jari Aaltof73dda02001-11-13 17:56:06 +000068extern Keymap rl_make_bare_keymap PARAMS((void));
Jari Aalto726f6381996-08-26 18:22:31 +000069
70/* Return a new keymap which is a copy of MAP. */
Jari Aaltof73dda02001-11-13 17:56:06 +000071extern Keymap rl_copy_keymap PARAMS((Keymap));
Jari Aalto726f6381996-08-26 18:22:31 +000072
73/* Return a new keymap with the printing characters bound to rl_insert,
74 the lowercase Meta characters bound to run their equivalents, and
75 the Meta digits bound to produce numeric arguments. */
Jari Aaltof73dda02001-11-13 17:56:06 +000076extern Keymap rl_make_keymap PARAMS((void));
Jari Aalto726f6381996-08-26 18:22:31 +000077
Jari Aaltob72432f1999-02-19 17:11:39 +000078/* Free the storage associated with a keymap. */
Jari Aaltof73dda02001-11-13 17:56:06 +000079extern void rl_discard_keymap PARAMS((Keymap));
Jari Aaltob72432f1999-02-19 17:11:39 +000080
81/* These functions actually appear in bind.c */
Jari Aalto726f6381996-08-26 18:22:31 +000082
83/* Return the keymap corresponding to a given name. Names look like
Jari Aaltob72432f1999-02-19 17:11:39 +000084 `emacs' or `emacs-meta' or `vi-insert'. */
Jari Aaltof73dda02001-11-13 17:56:06 +000085extern Keymap rl_get_keymap_by_name PARAMS((const char *));
Jari Aalto726f6381996-08-26 18:22:31 +000086
87/* Return the current keymap. */
Jari Aaltof73dda02001-11-13 17:56:06 +000088extern Keymap rl_get_keymap PARAMS((void));
Jari Aalto726f6381996-08-26 18:22:31 +000089
90/* Set the current keymap to MAP. */
Jari Aaltof73dda02001-11-13 17:56:06 +000091extern void rl_set_keymap PARAMS((Keymap));
Jari Aalto726f6381996-08-26 18:22:31 +000092
Jari Aaltobb706242000-03-17 21:46:59 +000093#ifdef __cplusplus
94}
95#endif
96
Jari Aalto726f6381996-08-26 18:22:31 +000097#endif /* _KEYMAPS_H_ */