xref: /dflybsd-src/contrib/libedit/src/map.h (revision 12db70c8662d940c359926621f5dcef8a2365781)
1*12db70c8Szrj /*	$NetBSD: map.h,v 1.13 2016/05/09 21:46:56 christos Exp $	*/
232fe07f8SJohn Marino 
332fe07f8SJohn Marino /*-
432fe07f8SJohn Marino  * Copyright (c) 1992, 1993
532fe07f8SJohn Marino  *	The Regents of the University of California.  All rights reserved.
632fe07f8SJohn Marino  *
732fe07f8SJohn Marino  * This code is derived from software contributed to Berkeley by
832fe07f8SJohn Marino  * Christos Zoulas of Cornell University.
932fe07f8SJohn Marino  *
1032fe07f8SJohn Marino  * Redistribution and use in source and binary forms, with or without
1132fe07f8SJohn Marino  * modification, are permitted provided that the following conditions
1232fe07f8SJohn Marino  * are met:
1332fe07f8SJohn Marino  * 1. Redistributions of source code must retain the above copyright
1432fe07f8SJohn Marino  *    notice, this list of conditions and the following disclaimer.
1532fe07f8SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
1632fe07f8SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
1732fe07f8SJohn Marino  *    documentation and/or other materials provided with the distribution.
1832fe07f8SJohn Marino  * 3. Neither the name of the University nor the names of its contributors
1932fe07f8SJohn Marino  *    may be used to endorse or promote products derived from this software
2032fe07f8SJohn Marino  *    without specific prior written permission.
2132fe07f8SJohn Marino  *
2232fe07f8SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2332fe07f8SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2432fe07f8SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2532fe07f8SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2632fe07f8SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2732fe07f8SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2832fe07f8SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2932fe07f8SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3032fe07f8SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3132fe07f8SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232fe07f8SJohn Marino  * SUCH DAMAGE.
3332fe07f8SJohn Marino  *
3432fe07f8SJohn Marino  *	@(#)map.h	8.1 (Berkeley) 6/4/93
3532fe07f8SJohn Marino  */
3632fe07f8SJohn Marino 
3732fe07f8SJohn Marino /*
3832fe07f8SJohn Marino  * el.map.h:	Editor maps
3932fe07f8SJohn Marino  */
4032fe07f8SJohn Marino #ifndef _h_el_map
4132fe07f8SJohn Marino #define	_h_el_map
4232fe07f8SJohn Marino 
43*12db70c8Szrj typedef el_action_t (*el_func_t)(EditLine *, wint_t);
4432fe07f8SJohn Marino 
45*12db70c8Szrj typedef struct el_bindings_t {	/* for the "bind" shell command */
46*12db70c8Szrj 	const wchar_t	*name;		/* function name for bind command */
47*12db70c8Szrj 	int		 func;		/* function numeric value */
48*12db70c8Szrj 	const wchar_t	*description;	/* description of function */
49*12db70c8Szrj } el_bindings_t;
5032fe07f8SJohn Marino 
5132fe07f8SJohn Marino typedef struct el_map_t {
5232fe07f8SJohn Marino 	el_action_t	*alt;		/* The current alternate key map */
5332fe07f8SJohn Marino 	el_action_t	*key;		/* The current normal key map	*/
5432fe07f8SJohn Marino 	el_action_t	*current;	/* The keymap we are using	*/
5532fe07f8SJohn Marino 	const el_action_t *emacs;	/* The default emacs key map	*/
5632fe07f8SJohn Marino 	const el_action_t *vic;		/* The vi command mode key map	*/
5732fe07f8SJohn Marino 	const el_action_t *vii;		/* The vi insert mode key map	*/
5832fe07f8SJohn Marino 	int		 type;		/* Emacs or vi			*/
5932fe07f8SJohn Marino 	el_bindings_t	*help;		/* The help for the editor functions */
6032fe07f8SJohn Marino 	el_func_t	*func;		/* List of available functions	*/
61a0c9eb18SJohn Marino 	size_t		 nfunc;		/* The number of functions/help items */
6232fe07f8SJohn Marino } el_map_t;
6332fe07f8SJohn Marino 
6432fe07f8SJohn Marino #define	MAP_EMACS	0
6532fe07f8SJohn Marino #define	MAP_VI		1
6632fe07f8SJohn Marino 
6732fe07f8SJohn Marino #define N_KEYS      256
6832fe07f8SJohn Marino 
69*12db70c8Szrj libedit_private int	map_bind(EditLine *, int, const wchar_t **);
70*12db70c8Szrj libedit_private int	map_init(EditLine *);
71*12db70c8Szrj libedit_private void	map_end(EditLine *);
72*12db70c8Szrj libedit_private void	map_init_vi(EditLine *);
73*12db70c8Szrj libedit_private void	map_init_emacs(EditLine *);
74*12db70c8Szrj libedit_private int	map_set_editor(EditLine *, wchar_t *);
75*12db70c8Szrj libedit_private int	map_get_editor(EditLine *, const wchar_t **);
76*12db70c8Szrj libedit_private int	map_addfunc(EditLine *, const wchar_t *, const wchar_t *,
77*12db70c8Szrj     el_func_t);
7832fe07f8SJohn Marino 
7932fe07f8SJohn Marino #endif /* _h_el_map */
80