xref: /netbsd/lib/libedit/readline/readline.h (revision bf9ec67e)
1 /*	$NetBSD: readline.h,v 1.2 2002/03/18 16:01:03 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jaromir Dolecek.
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 NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 #ifndef _READLINE_H_
39 #define	_READLINE_H_
40 
41 #include <sys/types.h>
42 
43 /* list of readline stuff supported by editline library's readline wrapper */
44 
45 /* typedefs */
46 typedef int	  Function(const char *, int);
47 typedef void	  VFunction(void);
48 typedef char	 *CPFunction(const char *, int);
49 typedef char	**CPPFunction(const char *, int, int);
50 
51 typedef struct _hist_entry {
52 	const char	*line;
53 	const char	*data;
54 } HIST_ENTRY;
55 
56 /* global variables used by readline enabled applications */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 extern const char	*rl_library_version;
61 extern char		*rl_readline_name;
62 extern FILE		*rl_instream;
63 extern FILE		*rl_outstream;
64 extern char		*rl_line_buffer;
65 extern int		 rl_point, rl_end;
66 extern int		 history_base, history_length;
67 extern int		 max_input_history;
68 extern char		*rl_basic_word_break_characters;
69 extern char		*rl_completer_word_break_characters;
70 extern char		*rl_completer_quote_characters;
71 extern CPFunction	*rl_completion_entry_function;
72 extern CPPFunction	*rl_attempted_completion_function;
73 extern int		rl_completion_type;
74 extern int		rl_completion_query_items;
75 extern char		*rl_special_prefixes;
76 extern int		rl_completion_append_character;
77 
78 /* supported functions */
79 char		*readline(const char *);
80 int		 rl_initialize(void);
81 
82 void		 using_history(void);
83 int		 add_history(const char *);
84 void		 clear_history(void);
85 void		 stifle_history(int);
86 int		 unstifle_history(void);
87 int		 history_is_stifled(void);
88 int		 where_history(void);
89 HIST_ENTRY	*current_history(void);
90 HIST_ENTRY	*history_get(int);
91 int		 history_total_bytes(void);
92 int		 history_set_pos(int);
93 HIST_ENTRY	*previous_history(void);
94 HIST_ENTRY	*next_history(void);
95 int		 history_search(const char *, int);
96 int		 history_search_prefix(const char *, int);
97 int		 history_search_pos(const char *, int, int);
98 int		 read_history(const char *);
99 int		 write_history(const char *);
100 int		 history_expand(char *, char **);
101 char	       **history_tokenize(const char *);
102 
103 char		*tilde_expand(char *);
104 char		*filename_completion_function(const char *, int);
105 char		*username_completion_function(const char *, int);
106 int		 rl_complete(int, int);
107 int		 rl_read_key(void);
108 char	       **completion_matches(const char *, CPFunction *);
109 void		 rl_display_match_list(char **, int, int);
110 
111 int		 rl_insert(int, int);
112 void		 rl_reset_terminal(const char *);
113 int		 rl_bind_key(int, int (*)(int, int));
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* _READLINE_H_ */
119