Home | History | Annotate | Line # | Download | only in libedit
histedit.h revision 1.3
      1 /*	$NetBSD: histedit.h,v 1.3 1997/01/11 06:47:56 lukem Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Christos Zoulas of Cornell University.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)histedit.h	8.2 (Berkeley) 1/3/94
     39  */
     40 
     41 /*
     42  * histedit.h: Line editor and history interface.
     43  */
     44 #ifndef _h_editline
     45 #define _h_editline
     46 
     47 #include <sys/types.h>
     48 #include <stdio.h>
     49 
     50 /*
     51  * ==== Editing ====
     52  */
     53 typedef struct editline EditLine;
     54 
     55 /*
     56  * For user-defined function interface
     57  */
     58 typedef struct lineinfo {
     59     __const char *buffer;
     60     __const char *cursor;
     61     __const char *lastchar;
     62 } LineInfo;
     63 
     64 
     65 /*
     66  * EditLine editor function return codes.
     67  * For user-defined function interface
     68  */
     69 #define	CC_NORM		0
     70 #define	CC_NEWLINE	1
     71 #define	CC_EOF		2
     72 #define CC_ARGHACK	3
     73 #define CC_REFRESH	4
     74 #define	CC_CURSOR	5
     75 #define	CC_ERROR	6
     76 #define CC_FATAL	7
     77 
     78 /*
     79  * Initialization, cleanup, and resetting
     80  */
     81 EditLine	*el_init	__P((const char *, FILE *, FILE *));
     82 void		 el_reset	__P((EditLine *));
     83 void		 el_end		__P((EditLine *));
     84 
     85 
     86 /*
     87  * Get a line, a character or push a string back in the input queue
     88  */
     89 __const char    *el_gets	__P((EditLine *, int *));
     90 int		 el_getc	__P((EditLine *, char *));
     91 void		 el_push	__P((EditLine *, const char *));
     92 
     93 /*
     94  * High level function internals control
     95  * Parses argc, argv array and executes builtin editline commands
     96  */
     97 int		 el_parse	__P((EditLine *, int, char **));
     98 
     99 /*
    100  * Low level editline access function
    101  */
    102 int 		 el_set		__P((EditLine *, int, ...));
    103 
    104 /*
    105  * el_set/el_get parameters
    106  */
    107 #define EL_PROMPT	0	/* , el_pfunc_t);		*/
    108 #define EL_TERMINAL	1	/* , const char *);		*/
    109 #define EL_EDITOR	2	/* , const char *);		*/
    110 #define EL_SIGNAL	3	/* , int);			*/
    111 #define	EL_BIND		4	/* , const char *, ..., NULL);	*/
    112 #define	EL_TELLTC	5	/* , const char *, ..., NULL);	*/
    113 #define	EL_SETTC	6	/* , const char *, ..., NULL);	*/
    114 #define	EL_ECHOTC	7	/* , const char *, ..., NULL);	*/
    115 #define	EL_SETTY	8	/* , const char *, ..., NULL);	*/
    116 #define	EL_ADDFN	9	/* , const char *, const char *	*/
    117 				/* , el_func_t);		*/
    118 #define EL_HIST		10	/* , hist_fun_t, const char *);	*/
    119 
    120 /*
    121  * Source named file or $PWD/.editrc or $HOME/.editrc
    122  */
    123 int		el_source	__P((EditLine *, const char *));
    124 
    125 /*
    126  * Must be called when the terminal changes size; If EL_SIGNAL
    127  * is set this is done automatically otherwise it is the responsibility
    128  * of the application
    129  */
    130 void		 el_resize	__P((EditLine *));
    131 
    132 
    133 /*
    134  * User-defined function interface.
    135  */
    136 __const LineInfo *el_line	__P((EditLine *));
    137 int   		  el_insertstr	__P((EditLine *, char *));
    138 void		  el_deletestr	__P((EditLine *, int));
    139 
    140 /*
    141  * ==== History ====
    142  */
    143 
    144 typedef struct history History;
    145 
    146 typedef struct HistEvent {
    147     int 	  num;
    148     __const char *str;
    149 } HistEvent;
    150 
    151 /*
    152  * History access functions.
    153  */
    154 History *		history_init	__P((void));
    155 void 			history_end	__P((History *));
    156 
    157 __const HistEvent *	history		__P((History *, int, ...));
    158 
    159 #define H_FUNC		 0	/* , UTSL		*/
    160 #define H_EVENT		 1	/* , const int);	*/
    161 #define H_FIRST		 2	/* , void);		*/
    162 #define H_LAST		 3	/* , void);		*/
    163 #define H_PREV		 4	/* , void);		*/
    164 #define H_NEXT		 5	/* , void);		*/
    165 #define H_CURR		 6	/* , void);		*/
    166 #define H_ADD		 7	/* , const char*);	*/
    167 #define H_ENTER		 8	/* , const char*);	*/
    168 #define H_END		 9	/* , void);		*/
    169 #define H_NEXT_STR	10	/* , const char*);	*/
    170 #define H_PREV_STR	11	/* , const char*);	*/
    171 #define H_NEXT_EVENT	12	/* , const int);	*/
    172 #define H_PREV_EVENT	13	/* , const int);	*/
    173 #define H_LOAD		14	/* , const char *);	*/
    174 #define H_SAVE		15	/* , const char *);	*/
    175 #define H_CLEAR		16	/* , void);		*/
    176 
    177 #endif /* _h_editline */
    178