xref: /original-bsd/lib/libedit/histedit.h (revision 333da485)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Christos Zoulas of Cornell University.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)histedit.h	8.2 (Berkeley) 01/03/94
11  */
12 
13 /*
14  * histedit.h: Line editor and history interface.
15  */
16 #ifndef _h_editline
17 #define _h_editline
18 
19 #include <sys/types.h>
20 #include <stdio.h>
21 
22 /*
23  * ==== Editing ====
24  */
25 typedef struct editline EditLine;
26 
27 /*
28  * For user-defined function interface
29  */
30 typedef struct lineinfo {
31     __const char *buffer;
32     __const char *cursor;
33     __const char *lastchar;
34 } LineInfo;
35 
36 
37 /*
38  * EditLine editor function return codes.
39  * For user-defined function interface
40  */
41 #define	CC_NORM		0
42 #define	CC_NEWLINE	1
43 #define	CC_EOF		2
44 #define CC_ARGHACK	3
45 #define CC_REFRESH	4
46 #define	CC_CURSOR	5
47 #define	CC_ERROR	6
48 #define CC_FATAL	7
49 
50 /*
51  * Initialization, cleanup, and resetting
52  */
53 EditLine	*el_init	__P((const char *, FILE *, FILE *));
54 void		 el_reset	__P((EditLine *));
55 void		 el_end		__P((EditLine *));
56 
57 
58 /*
59  * Get a line, a character or push a string back in the input queue
60  */
61 __const char    *el_gets	__P((EditLine *, int *));
62 int		 el_getc	__P((EditLine *, char *));
63 void		 el_push	__P((EditLine *, const char *));
64 
65 /*
66  * High level function internals control
67  * Parses argc, argv array and executes builtin editline commands
68  */
69 int		 el_parse	__P((EditLine *, int, char **));
70 
71 /*
72  * Low level editline access function
73  */
74 int 		 el_set		__P((EditLine *, int, ...));
75 
76 /*
77  * el_set/el_get parameters
78  */
79 #define EL_PROMPT	0	/* , el_pfunc_t);		*/
80 #define EL_TERMINAL	1	/* , const char *);		*/
81 #define EL_EDITOR	2	/* , const char *);		*/
82 #define EL_SIGNAL	3	/* , int);			*/
83 #define	EL_BIND		4	/* , const char *, ..., NULL);	*/
84 #define	EL_TELLTC	5	/* , const char *, ..., NULL);	*/
85 #define	EL_SETTC	6	/* , const char *, ..., NULL);	*/
86 #define	EL_ECHOTC	7	/* , const char *, ..., NULL);	*/
87 #define	EL_SETTY	8	/* , const char *, ..., NULL);	*/
88 #define	EL_ADDFN	9	/* , const char *, const char *	*/
89 				/* , el_func_t);		*/
90 #define EL_HIST		10	/* , hist_fun_t, const char *);	*/
91 
92 /*
93  * Source named file or $PWD/.editrc or $HOME/.editrc
94  */
95 int		el_source	__P((EditLine *, const char *));
96 
97 /*
98  * Must be called when the terminal changes size; If EL_SIGNAL
99  * is set this is done automatically otherwise it is the responsibility
100  * of the application
101  */
102 void		 el_resize	__P((EditLine *));
103 
104 
105 /*
106  * User-defined function interface.
107  */
108 __const LineInfo *el_line	__P((EditLine *));
109 int   		  el_insertstr	__P((EditLine *, char *));
110 void		  el_deletestr	__P((EditLine *, int));
111 
112 /*
113  * ==== History ====
114  */
115 
116 typedef struct history History;
117 
118 typedef struct HistEvent {
119     int 	  num;
120     __const char *str;
121 } HistEvent;
122 
123 /*
124  * History access functions.
125  */
126 History *		history_init	__P((void));
127 void 			history_end	__P((History *));
128 
129 __const HistEvent *	history		__P((History *, int, ...));
130 
131 #define H_FUNC		 0	/* , UTSL		*/
132 #define H_EVENT		 1	/* , const int);	*/
133 #define H_FIRST		 2	/* , void);		*/
134 #define H_LAST		 3	/* , void);		*/
135 #define H_PREV		 4	/* , void);		*/
136 #define H_NEXT		 5	/* , void);		*/
137 #define H_CURR		 6	/* , void);		*/
138 #define H_ADD		 7	/* , const char*);	*/
139 #define H_ENTER		 8	/* , const char*);	*/
140 #define H_END		 9	/* , void);		*/
141 #define H_NEXT_STR	10	/* , const char*);	*/
142 #define H_PREV_STR	11	/* , const char*);	*/
143 #define H_NEXT_EVENT	12	/* , const int);	*/
144 #define H_PREV_EVENT	13	/* , const int);	*/
145 
146 #endif /* _h_editline */
147