el.h revision 148814
1193326Sed/*-
2193326Sed * Copyright (c) 1992, 1993
3193326Sed *	The Regents of the University of California.  All rights reserved.
4193326Sed *
5193326Sed * This code is derived from software contributed to Berkeley by
6193326Sed * Christos Zoulas of Cornell University.
7193326Sed *
8193326Sed * Redistribution and use in source and binary forms, with or without
9193326Sed * modification, are permitted provided that the following conditions
10193326Sed * are met:
11193326Sed * 1. Redistributions of source code must retain the above copyright
12193326Sed *    notice, this list of conditions and the following disclaimer.
13193326Sed * 2. Redistributions in binary form must reproduce the above copyright
14193326Sed *    notice, this list of conditions and the following disclaimer in the
15193326Sed *    documentation and/or other materials provided with the distribution.
16193326Sed * 3. All advertising materials mentioning features or use of this software
17193326Sed *    must display the following acknowledgement:
18193326Sed *	This product includes software developed by the University of
19193326Sed *	California, Berkeley and its contributors.
20193326Sed * 4. Neither the name of the University nor the names of its contributors
21193326Sed *    may be used to endorse or promote products derived from this software
22193326Sed *    without specific prior written permission.
23193326Sed *
24193326Sed * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25193326Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26193326Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27193326Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28193326Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29193326Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30193326Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31193326Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32193326Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33205408Srdivacky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34193326Sed * SUCH DAMAGE.
35193326Sed *
36193326Sed *	@(#)el.h	8.1 (Berkeley) 6/4/93
37218893Sdim *	$NetBSD: el.h,v 1.7 2000/11/11 22:18:57 christos Exp $
38218893Sdim * $FreeBSD: head/lib/libedit/el.h 148814 2005-08-07 08:35:39Z stefanf $
39218893Sdim */
40193326Sed
41218893Sdim/*
42193326Sed * el.h: Internal structures.
43206084Srdivacky */
44249423Sdim#ifndef _h_el
45193326Sed#define	_h_el
46249423Sdim/*
47249423Sdim * Local defaults
48193326Sed */
49193326Sed#define	KSHVI
50206084Srdivacky#define	VIDEFAULT
51249423Sdim#define	ANCHOR
52193326Sed
53249423Sdim#include <stdio.h>
54193326Sed#include <sys/types.h>
55193326Sed
56206084Srdivacky#define	EL_BUFSIZ	1024		/* Maximum line size		*/
57249423Sdim
58193326Sed#define	HANDLE_SIGNALS	1<<0
59249423Sdim#define	NO_TTY		1<<1
60249423Sdim#define	EDIT_DISABLED	1<<2
61193326Sed
62193326Sedtypedef int bool_t;			/* True or not			*/
63206084Srdivacky
64249423Sdimtypedef unsigned char el_action_t;	/* Index to command array	*/
65193326Sed
66249423Sdimtypedef struct coord_t {		/* Position on the screen	*/
67193326Sed	int	h;
68193326Sed	int	v;
69206084Srdivacky} coord_t;
70249423Sdim
71193326Sedtypedef struct el_line_t {
72249423Sdim	char	*buffer;		/* Input line			*/
73249423Sdim	char	*cursor;		/* Cursor position		*/
74193326Sed	char	*lastchar;		/* Last character		*/
75193326Sed	const char	*limit;			/* Max position			*/
76206084Srdivacky} el_line_t;
77249423Sdim
78193326Sed/*
79249423Sdim * Editor state
80193326Sed */
81193326Sedtypedef struct el_state_t {
82206084Srdivacky	int		inputmode;	/* What mode are we in?		*/
83249423Sdim	int		doingarg;	/* Are we getting an argument?	*/
84193326Sed	int		argument;	/* Numeric argument		*/
85249423Sdim	int		metanext;	/* Is the next char a meta char */
86249423Sdim	el_action_t	lastcmd;	/* Previous command		*/
87193326Sed} el_state_t;
88193326Sed
89206084Srdivacky/*
90249423Sdim * Until we come up with something better...
91193326Sed */
92249423Sdim#define	el_malloc(a)	malloc(a)
93193326Sed#define	el_realloc(a,b)	realloc(a, b)
94193326Sed#define	el_free(a)	free(a)
95206084Srdivacky
96249423Sdim#include "tty.h"
97193326Sed#include "prompt.h"
98249423Sdim#include "key.h"
99249423Sdim#include "term.h"
100193326Sed#include "refresh.h"
101193326Sed#include "chared.h"
102206084Srdivacky#include "common.h"
103249423Sdim#include "search.h"
104193326Sed#include "hist.h"
105249423Sdim#include "map.h"
106193326Sed#include "parse.h"
107193326Sed#include "sig.h"
108206084Srdivacky#include "help.h"
109249423Sdim
110193326Sedstruct editline {
111249423Sdim	char		 *el_prog;	/* the program name		*/
112249423Sdim	FILE		 *el_outfile;	/* Stdio stuff			*/
113193326Sed	FILE		 *el_errfile;	/* Stdio stuff			*/
114193326Sed	int		  el_infd;	/* Input file descriptor	*/
115206084Srdivacky	int		  el_flags;	/* Various flags.		*/
116249423Sdim	coord_t		  el_cursor;	/* Cursor location		*/
117193326Sed	char		**el_display;	/* Real screen image = what is there */
118249423Sdim	char		**el_vdisplay;	/* Virtual screen image = what we see */
119193326Sed	el_line_t	  el_line;	/* The current line information	*/
120193326Sed	el_state_t	  el_state;	/* Current editor state		*/
121206084Srdivacky	el_term_t	  el_term;	/* Terminal dependent stuff	*/
122249423Sdim	el_tty_t	  el_tty;	/* Tty dependent stuff		*/
123193326Sed	el_refresh_t	  el_refresh;	/* Refresh stuff		*/
124249423Sdim	el_prompt_t	  el_prompt;	/* Prompt stuff			*/
125249423Sdim	el_prompt_t	  el_rprompt;	/* Prompt stuff			*/
126193326Sed	el_chared_t	  el_chared;	/* Characted editor stuff	*/
127193326Sed	el_map_t	  el_map;	/* Key mapping stuff		*/
128206084Srdivacky	el_key_t	  el_key;	/* Key binding stuff		*/
129249423Sdim	el_history_t	  el_history;	/* History stuff		*/
130193326Sed	el_search_t	  el_search;	/* Search stuff			*/
131249423Sdim	el_signal_t	  el_signal;	/* Signal handling stuff	*/
132193326Sed
133193326Sed	void		 *data;		/* user data */
134206084Srdivacky};
135249423Sdim
136193326Sedprotected int	el_editmode(EditLine *, int, char **);
137249423Sdim
138193326Sed#ifdef DEBUG
139193326Sed#define EL_ABORT(a)	(void) (fprintf(el->el_errfile, "%s, %d: ", \
140206084Srdivacky				__FILE__, __LINE__), fprintf a, abort())
141249423Sdim#else
142193326Sed#define EL_ABORT(a)	abort()
143249423Sdim#endif
144193326Sed#endif /* _h_el */
145193326Sed