1 /* @(#)shedit.h	1.16 19/04/27 Copyright 2006-2019 J. Schilling */
2 /*
3  *	Definitions for libshedit, the history editor for the shell.
4  *
5  *	Copyright (c) 2006-2019 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License").  You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 #ifndef	_SCHILY_SHEDIT_H
22 #define	_SCHILY_SHEDIT_H
23 
24 #ifndef _SCHILY_MCONFIG_H
25 #include <schily/mconfig.h>
26 #endif
27 #ifndef	_SCHILY_TYPES_H
28 #include <schily/types.h>
29 #endif
30 #ifndef	_SCHILY_SCHILY_H
31 #include <schily/schily.h>
32 #endif
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Exported functions:
40  *
41  * shedit_egetc():	read one character from the edited input
42  * shedit_getdelim():	get input delimiter
43  * shedit_treset():	reset terminal modes to non-edit
44  * shedit_bhist():	the builtin history command
45  * shedit_bshist():	the builtin savehistory command
46  * shedit_append_line(): to append a line to the history
47  * shedit_remap():	the builtin to reread termcap/mapping defaults
48  * shedit_list_map():	the builtin to list mappings
49  * shedit_del_map():	the builtin to delete mappings
50  * shedit_add_map():	the builtin to add mappings
51  * shedit_getenv():	set up pointer to local getenv() from the shell
52  * shedit_putenv():	set up pointer to local putenv() from the shell
53  * shedit_igneof():	set up pointer to local ignoreeof() from the shell
54  */
55 extern	int	shedit_egetc	__PR((void));
56 extern	size_t	shedit_getlen	__PR((void));
57 extern	int	shedit_getdelim	__PR((void));
58 extern	void	shedit_treset	__PR((void));
59 extern	void	shedit_bhist	__PR((int **intrcpp));
60 extern	void	shedit_bshist	__PR((int **intrpp));
61 extern	void	shedit_append_line __PR((char *linep, unsigned int len,
62 						unsigned int pos));
63 extern	void	shedit_chghistory __PR((char *__val));
64 extern	void	shedit_histrange __PR((unsigned *firstp,
65 					unsigned *lastp, unsigned *nextp));
66 extern	void	shedit_remap	__PR((void));
67 extern	void	shedit_list_map	__PR((int *f));
68 extern	int	shedit_del_map	__PR((char *from));
69 extern	int	shedit_add_map	__PR((char *from, char *to, char *comment));
70 extern	void	shedit_getenv	__PR((char *(*genv)(char *name)));
71 extern	void	shedit_putenv	__PR((void (*penv) (char *name)));
72 extern	void	shedit_igneof	__PR((BOOL (*ieof) (void)));
73 extern	void	shedit_setprompts __PR((int promptidx, int nprompts,
74 							char *newprompts[]));
75 extern	void	shedit_spromptidx __PR((int promptidx));
76 extern	int	shedit_gpromptidx __PR((void));
77 
78 #define	SHEDIT_NPROMPTS	2	/* Number of supported prompts		*/
79 
80 /*
81  * Keep #defines in sync with bsh/bsh.h
82  */
83 #define	HI_NOINTR	0	/* History traversal noninterruptable	*/
84 #define	HI_INTR		1	/* History traversal is interruptable	*/
85 #define	HI_NONUM	2	/* Do not print numbers			*/
86 #define	HI_TAB		4	/* Print TABs				*/
87 #define	HI_REVERSE	8	/* Print in reverse order		*/
88 #define	HI_PRETTYP	16	/* Pretty Type non-printable chars	*/
89 #define	HI_ANSI_NL	32	/* Convert ASCII newlines to ANSI nl	*/
90 
91 extern	int	shedit_history		__PR((int *f, int **intrcpp, int flg,
92 					int _first, int _last, char *_subst));
93 extern	int	shedit_search_history	__PR((int **intrcpp, int flg,
94 					int _first, char *_pat));
95 extern	int	shedit_remove_history	__PR((int **intrcpp, int flg,
96 					int _first, char *_pat));
97 extern	int	shedit_read_history	__PR((int *f, int **intrcpp, int flg));
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif	/* _SCHILY_SHEDIT_H */
103