Home | History | Annotate | Line # | Download | only in libedit
      1  1.48    rillig /*	$NetBSD: el.h,v 1.48 2025/01/03 00:40:08 rillig Exp $	*/
      2   1.2     lukem 
      3   1.1       cgd /*-
      4   1.1       cgd  * Copyright (c) 1992, 1993
      5   1.1       cgd  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * This code is derived from software contributed to Berkeley by
      8   1.1       cgd  * Christos Zoulas of Cornell University.
      9   1.1       cgd  *
     10   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11   1.1       cgd  * modification, are permitted provided that the following conditions
     12   1.1       cgd  * are met:
     13   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18  1.14       agc  * 3. Neither the name of the University nor the names of its contributors
     19   1.1       cgd  *    may be used to endorse or promote products derived from this software
     20   1.1       cgd  *    without specific prior written permission.
     21   1.1       cgd  *
     22   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32   1.1       cgd  * SUCH DAMAGE.
     33   1.1       cgd  *
     34   1.1       cgd  *	@(#)el.h	8.1 (Berkeley) 6/4/93
     35   1.1       cgd  */
     36   1.1       cgd 
     37   1.1       cgd /*
     38   1.1       cgd  * el.h: Internal structures.
     39   1.1       cgd  */
     40   1.1       cgd #ifndef _h_el
     41   1.6     lukem #define	_h_el
     42   1.1       cgd /*
     43   1.1       cgd  * Local defaults
     44   1.1       cgd  */
     45   1.6     lukem #define	KSHVI
     46   1.6     lukem #define	VIDEFAULT
     47   1.6     lukem #define	ANCHOR
     48   1.1       cgd 
     49  1.29  christos #include "histedit.h"
     50  1.29  christos #include "chartype.h"
     51   1.1       cgd 
     52  1.25  christos #define	EL_BUFSIZ	((size_t)1024)	/* Maximum line size		*/
     53   1.1       cgd 
     54  1.46  christos #define	HANDLE_SIGNALS	0x001
     55  1.46  christos #define	NO_TTY		0x002
     56  1.46  christos #define	EDIT_DISABLED	0x004
     57  1.46  christos #define	UNBUFFERED	0x008
     58  1.46  christos #define	NARROW_HISTORY	0x040
     59  1.46  christos #define	NO_RESET	0x080
     60  1.46  christos #define	FIXIO		0x100
     61  1.47  christos #define	FROM_ELLINE	0x200
     62   1.1       cgd 
     63   1.1       cgd typedef unsigned char el_action_t;	/* Index to command array	*/
     64   1.1       cgd 
     65   1.1       cgd typedef struct coord_t {		/* Position on the screen	*/
     66   1.6     lukem 	int	h;
     67   1.6     lukem 	int	v;
     68   1.1       cgd } coord_t;
     69   1.1       cgd 
     70   1.1       cgd typedef struct el_line_t {
     71  1.36  christos 	wchar_t		*buffer;	/* Input line			*/
     72  1.36  christos 	wchar_t	        *cursor;	/* Cursor position		*/
     73  1.36  christos 	wchar_t	        *lastchar;	/* Last character		*/
     74  1.36  christos 	const wchar_t	*limit;		/* Max position			*/
     75   1.1       cgd } el_line_t;
     76   1.1       cgd 
     77   1.1       cgd /*
     78   1.1       cgd  * Editor state
     79   1.1       cgd  */
     80   1.1       cgd typedef struct el_state_t {
     81   1.6     lukem 	int		inputmode;	/* What mode are we in?		*/
     82   1.6     lukem 	int		doingarg;	/* Are we getting an argument?	*/
     83   1.6     lukem 	int		argument;	/* Numeric argument		*/
     84   1.6     lukem 	int		metanext;	/* Is the next char a meta char */
     85   1.6     lukem 	el_action_t	lastcmd;	/* Previous command		*/
     86  1.33  christos 	el_action_t	thiscmd;	/* this command			*/
     87  1.36  christos 	wchar_t		thisch;		/* char that generated it	*/
     88   1.1       cgd } el_state_t;
     89   1.1       cgd 
     90   1.1       cgd /*
     91   1.1       cgd  * Until we come up with something better...
     92   1.1       cgd  */
     93   1.6     lukem #define	el_malloc(a)	malloc(a)
     94  1.45  christos #define	el_calloc(a,b)	calloc(a, b)
     95   1.6     lukem #define	el_realloc(a,b)	realloc(a, b)
     96   1.6     lukem #define	el_free(a)	free(a)
     97   1.1       cgd 
     98   1.1       cgd #include "tty.h"
     99   1.1       cgd #include "prompt.h"
    100  1.42  christos #include "literal.h"
    101  1.24  christos #include "keymacro.h"
    102  1.23  christos #include "terminal.h"
    103   1.1       cgd #include "refresh.h"
    104   1.1       cgd #include "chared.h"
    105   1.1       cgd #include "search.h"
    106   1.1       cgd #include "hist.h"
    107   1.1       cgd #include "map.h"
    108   1.1       cgd #include "sig.h"
    109  1.38  christos 
    110  1.38  christos struct el_read_t;
    111   1.1       cgd 
    112   1.1       cgd struct editline {
    113  1.36  christos 	wchar_t		 *el_prog;	/* the program name		*/
    114  1.17  christos 	FILE		 *el_infile;	/* Stdio stuff			*/
    115   1.6     lukem 	FILE		 *el_outfile;	/* Stdio stuff			*/
    116   1.6     lukem 	FILE		 *el_errfile;	/* Stdio stuff			*/
    117   1.6     lukem 	int		  el_infd;	/* Input file descriptor	*/
    118  1.22  christos 	int		  el_outfd;	/* Output file descriptor	*/
    119  1.22  christos 	int		  el_errfd;	/* Error file descriptor	*/
    120   1.6     lukem 	int		  el_flags;	/* Various flags.		*/
    121   1.6     lukem 	coord_t		  el_cursor;	/* Cursor location		*/
    122  1.42  christos 	wint_t		**el_display;	/* Real screen image = what is there */
    123  1.42  christos 	wint_t		**el_vdisplay;	/* Virtual screen image = what we see */
    124  1.10  christos 	void		 *el_data;	/* Client data			*/
    125   1.6     lukem 	el_line_t	  el_line;	/* The current line information	*/
    126   1.6     lukem 	el_state_t	  el_state;	/* Current editor state		*/
    127  1.23  christos 	el_terminal_t	  el_terminal;	/* Terminal dependent stuff	*/
    128   1.6     lukem 	el_tty_t	  el_tty;	/* Tty dependent stuff		*/
    129   1.6     lukem 	el_refresh_t	  el_refresh;	/* Refresh stuff		*/
    130   1.6     lukem 	el_prompt_t	  el_prompt;	/* Prompt stuff			*/
    131   1.6     lukem 	el_prompt_t	  el_rprompt;	/* Prompt stuff			*/
    132  1.42  christos 	el_literal_t	  el_literal;	/* prompt literal bits		*/
    133   1.6     lukem 	el_chared_t	  el_chared;	/* Characted editor stuff	*/
    134   1.6     lukem 	el_map_t	  el_map;	/* Key mapping stuff		*/
    135  1.24  christos 	el_keymacro_t	  el_keymacro;	/* Key binding stuff		*/
    136   1.6     lukem 	el_history_t	  el_history;	/* History stuff		*/
    137   1.6     lukem 	el_search_t	  el_search;	/* Search stuff			*/
    138   1.6     lukem 	el_signal_t	  el_signal;	/* Signal handling stuff	*/
    139  1.38  christos 	struct el_read_t *el_read;	/* Character reading stuff	*/
    140  1.39  christos 	ct_buffer_t       el_visual;    /* Buffer for displayable str	*/
    141  1.19  christos 	ct_buffer_t       el_scratch;   /* Scratch conversion buffer    */
    142  1.19  christos 	ct_buffer_t       el_lgcyconv;  /* Buffer for legacy wrappers   */
    143  1.19  christos 	LineInfo          el_lgcylinfo; /* Legacy LineInfo buffer       */
    144   1.1       cgd };
    145   1.4     lukem 
    146  1.40  christos libedit_private int	el_editmode(EditLine *, int, const wchar_t **);
    147  1.43  christos libedit_private EditLine *el_init_internal(const char *, FILE *, FILE *,
    148  1.43  christos     FILE *, int, int, int, int);
    149   1.1       cgd 
    150   1.7  christos #ifdef DEBUG
    151  1.12  christos #define	EL_ABORT(a)	do { \
    152  1.12  christos 				fprintf(el->el_errfile, "%s, %d: ", \
    153  1.12  christos 					 __FILE__, __LINE__); \
    154  1.12  christos 				fprintf a; \
    155  1.12  christos 				abort(); \
    156  1.48    rillig 			} while (0)
    157   1.7  christos #else
    158   1.7  christos #define EL_ABORT(a)	abort()
    159   1.7  christos #endif
    160   1.1       cgd #endif /* _h_el */
    161