el.h revision 84260
1263426Sbr/*-
2263426Sbr * Copyright (c) 1992, 1993
3263426Sbr *	The Regents of the University of California.  All rights reserved.
4263426Sbr *
5263426Sbr * This code is derived from software contributed to Berkeley by
6263426Sbr * Christos Zoulas of Cornell University.
7263426Sbr *
8263426Sbr * Redistribution and use in source and binary forms, with or without
9263426Sbr * modification, are permitted provided that the following conditions
10263426Sbr * are met:
11263426Sbr * 1. Redistributions of source code must retain the above copyright
12263426Sbr *    notice, this list of conditions and the following disclaimer.
13263426Sbr * 2. Redistributions in binary form must reproduce the above copyright
14263426Sbr *    notice, this list of conditions and the following disclaimer in the
15263426Sbr *    documentation and/or other materials provided with the distribution.
16263426Sbr * 3. All advertising materials mentioning features or use of this software
17263426Sbr *    must display the following acknowledgement:
18263426Sbr *	This product includes software developed by the University of
19263426Sbr *	California, Berkeley and its contributors.
20263426Sbr * 4. Neither the name of the University nor the names of its contributors
21263426Sbr *    may be used to endorse or promote products derived from this software
22263426Sbr *    without specific prior written permission.
23263426Sbr *
24263426Sbr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25263426Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26263426Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27263426Sbr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28263426Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29263426Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30263426Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31263426Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32263426Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33263426Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34263426Sbr * SUCH DAMAGE.
35263426Sbr *
36263426Sbr *	@(#)el.h	8.1 (Berkeley) 6/4/93
37263426Sbr *	$NetBSD: el.h,v 1.7 2000/11/11 22:18:57 christos Exp $
38263426Sbr * $FreeBSD: head/lib/libedit/el.h 84260 2001-10-01 08:41:27Z obrien $
39263426Sbr */
40263426Sbr
41263426Sbr/*
42263426Sbr * el.h: Internal structures.
43263426Sbr */
44263426Sbr#ifndef _h_el
45263426Sbr#define	_h_el
46263426Sbr/*
47263426Sbr * Local defaults
48263426Sbr */
49263426Sbr#define	KSHVI
50263426Sbr#define	VIDEFAULT
51263426Sbr#define	ANCHOR
52263426Sbr
53263426Sbr#include <stdio.h>
54263426Sbr#include <sys/types.h>
55263426Sbr
56263426Sbr#define	EL_BUFSIZ	1024		/* Maximum line size		*/
57263426Sbr
58263426Sbr#define	HANDLE_SIGNALS	1<<0
59263426Sbr#define	NO_TTY		1<<1
60263426Sbr#define	EDIT_DISABLED	1<<2
61263426Sbr
62263426Sbrtypedef int bool_t;			/* True or not			*/
63263426Sbr
64263426Sbrtypedef unsigned char el_action_t;	/* Index to command array	*/
65263426Sbr
66263426Sbrtypedef struct coord_t {		/* Position on the screen	*/
67263426Sbr	int	h;
68263426Sbr	int	v;
69263426Sbr} coord_t;
70263426Sbr
71263426Sbrtypedef struct el_line_t {
72263426Sbr	char	*buffer;		/* Input line			*/
73263426Sbr	char	*cursor;		/* Cursor position		*/
74263426Sbr	char	*lastchar;		/* Last character		*/
75263426Sbr	const char	*limit;			/* Max position			*/
76263426Sbr} el_line_t;
77263426Sbr
78263426Sbr/*
79263426Sbr * Editor state
80263426Sbr */
81263426Sbrtypedef struct el_state_t {
82263426Sbr	int		inputmode;	/* What mode are we in?		*/
83263426Sbr	int		doingarg;	/* Are we getting an argument?	*/
84263426Sbr	int		argument;	/* Numeric argument		*/
85263426Sbr	int		metanext;	/* Is the next char a meta char */
86263426Sbr	el_action_t	lastcmd;	/* Previous command		*/
87263426Sbr} el_state_t;
88263426Sbr
89263426Sbr/*
90263426Sbr * Until we come up with something better...
91263426Sbr */
92263426Sbr#define	el_malloc(a)	malloc(a)
93263426Sbr#define	el_realloc(a,b)	realloc(a, b)
94263426Sbr#define el_reallocf(a,b) reallocf(a, b)
95263426Sbr#define	el_free(a)	free(a)
96263426Sbr
97263426Sbr#include "tty.h"
98263426Sbr#include "prompt.h"
99263426Sbr#include "key.h"
100263426Sbr#include "term.h"
101263426Sbr#include "refresh.h"
102263426Sbr#include "chared.h"
103263426Sbr#include "common.h"
104263426Sbr#include "search.h"
105263426Sbr#include "hist.h"
106263426Sbr#include "map.h"
107263426Sbr#include "parse.h"
108263426Sbr#include "sig.h"
109263426Sbr#include "help.h"
110263426Sbr
111263426Sbrstruct editline {
112263426Sbr	char		 *el_prog;	/* the program name		*/
113263426Sbr	FILE		 *el_outfile;	/* Stdio stuff			*/
114263426Sbr	FILE		 *el_errfile;	/* Stdio stuff			*/
115263426Sbr	int		  el_infd;	/* Input file descriptor	*/
116263426Sbr	int		  el_flags;	/* Various flags.		*/
117263426Sbr	coord_t		  el_cursor;	/* Cursor location		*/
118263426Sbr	char		**el_display;	/* Real screen image = what is there */
119263426Sbr	char		**el_vdisplay;	/* Virtual screen image = what we see */
120263426Sbr	el_line_t	  el_line;	/* The current line information	*/
121263426Sbr	el_state_t	  el_state;	/* Current editor state		*/
122263426Sbr	el_term_t	  el_term;	/* Terminal dependent stuff	*/
123263426Sbr	el_tty_t	  el_tty;	/* Tty dependent stuff		*/
124263426Sbr	el_refresh_t	  el_refresh;	/* Refresh stuff		*/
125263426Sbr	el_prompt_t	  el_prompt;	/* Prompt stuff			*/
126263426Sbr	el_prompt_t	  el_rprompt;	/* Prompt stuff			*/
127263426Sbr	el_chared_t	  el_chared;	/* Characted editor stuff	*/
128263426Sbr	el_map_t	  el_map;	/* Key mapping stuff		*/
129263426Sbr	el_key_t	  el_key;	/* Key binding stuff		*/
130263426Sbr	el_history_t	  el_history;	/* History stuff		*/
131263426Sbr	el_search_t	  el_search;	/* Search stuff			*/
132263426Sbr	el_signal_t	  el_signal;	/* Signal handling stuff	*/
133263426Sbr
134263426Sbr	void		 *data;		/* user data */
135263426Sbr};
136263426Sbr
137263426Sbrprotected int	el_editmode(EditLine *, int, char **);
138263426Sbr
139263426Sbr#ifdef DEBUG
140263426Sbr#define EL_ABORT(a)	(void) (fprintf(el->el_errfile, "%s, %d: ", \
141263426Sbr				__FILE__, __LINE__), fprintf a, abort())
142263426Sbr#else
143263426Sbr#define EL_ABORT(a)	abort()
144263426Sbr#endif
145263426Sbr#endif /* _h_el */
146263426Sbr