blob: d8cba233c0a86a2abcd6c9b01c8e43055dfeb594 [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
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
Jari Aaltobb706242000-03-17 21:46:59 +000010 as published by the Free Software Foundation; either version 2, or
Jari Aalto726f6381996-08-26 18:22:31 +000011 (at your option) any later version.
12
13 The GNU Readline Library is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
Jari Aaltobb706242000-03-17 21:46:59 +000021 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
Jari Aalto726f6381996-08-26 18:22:31 +000022
23#ifndef _KEYMAPS_H_
24#define _KEYMAPS_H_
25
Jari Aaltobb706242000-03-17 21:46:59 +000026#ifdef __cplusplus
27extern "C" {
28#endif
29
Jari Aalto726f6381996-08-26 18:22:31 +000030#if defined (READLINE_LIBRARY)
Jari Aaltob72432f1999-02-19 17:11:39 +000031# include "rlstdc.h"
Jari Aalto726f6381996-08-26 18:22:31 +000032# include "chardefs.h"
Jari Aalto28ef6c32001-04-06 19:14:31 +000033# include "rltypedefs.h"
Jari Aalto726f6381996-08-26 18:22:31 +000034#else
Jari Aaltob72432f1999-02-19 17:11:39 +000035# include <readline/rlstdc.h>
Jari Aalto726f6381996-08-26 18:22:31 +000036# include <readline/chardefs.h>
Jari Aalto28ef6c32001-04-06 19:14:31 +000037# include <readline/rltypedefs.h>
Jari Aalto726f6381996-08-26 18:22:31 +000038#endif
39
40/* A keymap contains one entry for each key in the ASCII set.
41 Each entry consists of a type and a pointer.
Jari Aaltocce855b1998-04-17 19:52:44 +000042 FUNCTION is the address of a function to run, or the
Jari Aalto726f6381996-08-26 18:22:31 +000043 address of a keymap to indirect through.
Jari Aaltocce855b1998-04-17 19:52:44 +000044 TYPE says which kind of thing FUNCTION is. */
Jari Aalto726f6381996-08-26 18:22:31 +000045typedef struct _keymap_entry {
46 char type;
Jari Aalto28ef6c32001-04-06 19:14:31 +000047 rl_command_func_t *function;
Jari Aalto726f6381996-08-26 18:22:31 +000048} KEYMAP_ENTRY;
49
50/* This must be large enough to hold bindings for all of the characters
51 in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
52 and so on). */
53#define KEYMAP_SIZE 256
54
55/* I wanted to make the above structure contain a union of:
Jari Aalto28ef6c32001-04-06 19:14:31 +000056 union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
Jari Aalto726f6381996-08-26 18:22:31 +000057 but this made it impossible for me to create a static array.
58 Maybe I need C lessons. */
59
60typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
61typedef KEYMAP_ENTRY *Keymap;
62
63/* The values that TYPE can have in a keymap entry. */
64#define ISFUNC 0
65#define ISKMAP 1
66#define ISMACR 2
67
68extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
69extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
70
71/* Return a new, empty keymap.
72 Free it with free() when you are done. */
Jari Aaltob72432f1999-02-19 17:11:39 +000073extern Keymap rl_make_bare_keymap __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000074
75/* Return a new keymap which is a copy of MAP. */
Jari Aaltob72432f1999-02-19 17:11:39 +000076extern Keymap rl_copy_keymap __P((Keymap));
Jari Aalto726f6381996-08-26 18:22:31 +000077
78/* Return a new keymap with the printing characters bound to rl_insert,
79 the lowercase Meta characters bound to run their equivalents, and
80 the Meta digits bound to produce numeric arguments. */
Jari Aaltob72432f1999-02-19 17:11:39 +000081extern Keymap rl_make_keymap __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000082
Jari Aaltob72432f1999-02-19 17:11:39 +000083/* Free the storage associated with a keymap. */
84extern void rl_discard_keymap __P((Keymap));
85
86/* These functions actually appear in bind.c */
Jari Aalto726f6381996-08-26 18:22:31 +000087
88/* Return the keymap corresponding to a given name. Names look like
Jari Aaltob72432f1999-02-19 17:11:39 +000089 `emacs' or `emacs-meta' or `vi-insert'. */
Jari Aalto28ef6c32001-04-06 19:14:31 +000090extern Keymap rl_get_keymap_by_name __P((const char *));
Jari Aalto726f6381996-08-26 18:22:31 +000091
92/* Return the current keymap. */
Jari Aaltob72432f1999-02-19 17:11:39 +000093extern Keymap rl_get_keymap __P((void));
Jari Aalto726f6381996-08-26 18:22:31 +000094
95/* Set the current keymap to MAP. */
Jari Aaltob72432f1999-02-19 17:11:39 +000096extern void rl_set_keymap __P((Keymap));
Jari Aalto726f6381996-08-26 18:22:31 +000097
Jari Aaltobb706242000-03-17 21:46:59 +000098#ifdef __cplusplus
99}
100#endif
101
Jari Aalto726f6381996-08-26 18:22:31 +0000102#endif /* _KEYMAPS_H_ */