1296435Spfg/*	$NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $	*/
2276881Sbapt
31573Srgrimes/*-
41573Srgrimes * Copyright (c) 1992, 1993
51573Srgrimes *	The Regents of the University of California.  All rights reserved.
61573Srgrimes *
71573Srgrimes * This code is derived from software contributed to Berkeley by
81573Srgrimes * Christos Zoulas of Cornell University.
91573Srgrimes *
101573Srgrimes * Redistribution and use in source and binary forms, with or without
111573Srgrimes * modification, are permitted provided that the following conditions
121573Srgrimes * are met:
131573Srgrimes * 1. Redistributions of source code must retain the above copyright
141573Srgrimes *    notice, this list of conditions and the following disclaimer.
151573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161573Srgrimes *    notice, this list of conditions and the following disclaimer in the
171573Srgrimes *    documentation and/or other materials provided with the distribution.
18148834Sstefanf * 3. Neither the name of the University nor the names of its contributors
191573Srgrimes *    may be used to endorse or promote products derived from this software
201573Srgrimes *    without specific prior written permission.
211573Srgrimes *
221573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251573Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321573Srgrimes * SUCH DAMAGE.
331573Srgrimes *
341573Srgrimes *	@(#)el.h	8.1 (Berkeley) 6/4/93
3584260Sobrien * $FreeBSD: releng/11.0/lib/libedit/el.h 296435 2016-03-06 21:32:54Z pfg $
361573Srgrimes */
371573Srgrimes
381573Srgrimes/*
391573Srgrimes * el.h: Internal structures.
401573Srgrimes */
411573Srgrimes#ifndef _h_el
4284260Sobrien#define	_h_el
431573Srgrimes/*
441573Srgrimes * Local defaults
451573Srgrimes */
4684260Sobrien#define	KSHVI
4784260Sobrien#define	VIDEFAULT
4884260Sobrien#define	ANCHOR
491573Srgrimes
50276881Sbapt#include "histedit.h"
51276881Sbapt#include "chartype.h"
52296435Spfg#include <stdio.h>
53296435Spfg#include <sys/types.h>
541573Srgrimes
55276881Sbapt#define	EL_BUFSIZ	((size_t)1024)	/* Maximum line size		*/
561573Srgrimes
57148834Sstefanf#define	HANDLE_SIGNALS	0x01
58148834Sstefanf#define	NO_TTY		0x02
59148834Sstefanf#define	EDIT_DISABLED	0x04
60148834Sstefanf#define	UNBUFFERED	0x08
61276881Sbapt#define	CHARSET_IS_UTF8 0x10
62296435Spfg#define	IGNORE_EXTCHARS 0x20            /* Ignore characters read > 0xff */
63276881Sbapt#define	NARROW_HISTORY	0x40
64296435Spfg#define	NARROW_READ	0x80
651573Srgrimes
66296435Spfgtypedef int bool_t;			/* True or not			*/
67296435Spfg
681573Srgrimestypedef unsigned char el_action_t;	/* Index to command array	*/
691573Srgrimes
701573Srgrimestypedef struct coord_t {		/* Position on the screen	*/
7184260Sobrien	int	h;
7284260Sobrien	int	v;
731573Srgrimes} coord_t;
741573Srgrimes
751573Srgrimestypedef struct el_line_t {
76296435Spfg	Char 		*buffer;	/* Input line			*/
77276881Sbapt	Char	        *cursor;	/* Cursor position		*/
78276881Sbapt	Char	        *lastchar;	/* Last character		*/
79276881Sbapt	const Char	*limit;		/* Max position			*/
801573Srgrimes} el_line_t;
811573Srgrimes
821573Srgrimes/*
831573Srgrimes * Editor state
841573Srgrimes */
851573Srgrimestypedef struct el_state_t {
8684260Sobrien	int		inputmode;	/* What mode are we in?		*/
8784260Sobrien	int		doingarg;	/* Are we getting an argument?	*/
8884260Sobrien	int		argument;	/* Numeric argument		*/
8984260Sobrien	int		metanext;	/* Is the next char a meta char */
9084260Sobrien	el_action_t	lastcmd;	/* Previous command		*/
91296435Spfg	el_action_t	thiscmd;	/* this command 		*/
92276881Sbapt	Char		thisch;		/* char that generated it	*/
931573Srgrimes} el_state_t;
941573Srgrimes
951573Srgrimes/*
961573Srgrimes * Until we come up with something better...
971573Srgrimes */
9884260Sobrien#define	el_malloc(a)	malloc(a)
9984260Sobrien#define	el_realloc(a,b)	realloc(a, b)
10084260Sobrien#define	el_free(a)	free(a)
1011573Srgrimes
1021573Srgrimes#include "tty.h"
1031573Srgrimes#include "prompt.h"
104276881Sbapt#include "keymacro.h"
105276881Sbapt#include "terminal.h"
1061573Srgrimes#include "refresh.h"
1071573Srgrimes#include "chared.h"
108296435Spfg#include "common.h"
1091573Srgrimes#include "search.h"
1101573Srgrimes#include "hist.h"
1111573Srgrimes#include "map.h"
112296435Spfg#include "parse.h"
1131573Srgrimes#include "sig.h"
114296435Spfg#include "help.h"
115148834Sstefanf#include "read.h"
1161573Srgrimes
1171573Srgrimesstruct editline {
118276881Sbapt	Char		 *el_prog;	/* the program name		*/
119170511Sstefanf	FILE		 *el_infile;	/* Stdio stuff			*/
12084260Sobrien	FILE		 *el_outfile;	/* Stdio stuff			*/
12184260Sobrien	FILE		 *el_errfile;	/* Stdio stuff			*/
12284260Sobrien	int		  el_infd;	/* Input file descriptor	*/
123276881Sbapt	int		  el_outfd;	/* Output file descriptor	*/
124276881Sbapt	int		  el_errfd;	/* Error file descriptor	*/
12584260Sobrien	int		  el_flags;	/* Various flags.		*/
126238378Spfg	int		  el_errno;	/* Local copy of errno		*/
12784260Sobrien	coord_t		  el_cursor;	/* Cursor location		*/
128276881Sbapt	Char		**el_display;	/* Real screen image = what is there */
129276881Sbapt	Char		**el_vdisplay;	/* Virtual screen image = what we see */
130148834Sstefanf	void		 *el_data;	/* Client data			*/
13184260Sobrien	el_line_t	  el_line;	/* The current line information	*/
13284260Sobrien	el_state_t	  el_state;	/* Current editor state		*/
133276881Sbapt	el_terminal_t	  el_terminal;	/* Terminal dependent stuff	*/
13484260Sobrien	el_tty_t	  el_tty;	/* Tty dependent stuff		*/
13584260Sobrien	el_refresh_t	  el_refresh;	/* Refresh stuff		*/
13684260Sobrien	el_prompt_t	  el_prompt;	/* Prompt stuff			*/
13784260Sobrien	el_prompt_t	  el_rprompt;	/* Prompt stuff			*/
13884260Sobrien	el_chared_t	  el_chared;	/* Characted editor stuff	*/
13984260Sobrien	el_map_t	  el_map;	/* Key mapping stuff		*/
140276881Sbapt	el_keymacro_t	  el_keymacro;	/* Key binding stuff		*/
14184260Sobrien	el_history_t	  el_history;	/* History stuff		*/
14284260Sobrien	el_search_t	  el_search;	/* Search stuff			*/
14384260Sobrien	el_signal_t	  el_signal;	/* Signal handling stuff	*/
144148834Sstefanf	el_read_t	  el_read;	/* Character reading stuff	*/
145276881Sbapt#ifdef WIDECHAR
146276881Sbapt	ct_buffer_t       el_scratch;   /* Scratch conversion buffer    */
147276881Sbapt	ct_buffer_t       el_lgcyconv;  /* Buffer for legacy wrappers   */
148276881Sbapt	LineInfo          el_lgcylinfo; /* Legacy LineInfo buffer       */
149276881Sbapt#endif
1501573Srgrimes};
1511573Srgrimes
152276881Sbaptprotected int	el_editmode(EditLine *, int, const Char **);
15384260Sobrien
15484260Sobrien#ifdef DEBUG
155148834Sstefanf#define	EL_ABORT(a)	do { \
156148834Sstefanf				fprintf(el->el_errfile, "%s, %d: ", \
157148834Sstefanf					 __FILE__, __LINE__); \
158148834Sstefanf				fprintf a; \
159148834Sstefanf				abort(); \
160148834Sstefanf			} while( /*CONSTCOND*/0);
16184260Sobrien#else
16284260Sobrien#define EL_ABORT(a)	abort()
16384260Sobrien#endif
1641573Srgrimes#endif /* _h_el */
165