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