Home | History | Annotate | Line # | Download | only in readline
readline.h revision 1.13
      1 /*	$NetBSD: readline.h,v 1.13 2005/04/12 22:01:40 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 typedef struct _keymap_entry {
     57 	char type;
     58 #define ISFUNC	0
     59 #define ISKMAP	1
     60 #define ISMACR	2
     61 	Function *function;
     62 } KEYMAP_ENTRY;
     63 
     64 #define KEYMAP_SIZE	256
     65 
     66 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
     67 typedef KEYMAP_ENTRY *Keymap;
     68 
     69 #define control_character_threshold	0x20
     70 #define control_character_bit		0x40
     71 
     72 #ifndef CTRL
     73 #include <sys/ioctl.h>
     74 #if !defined(__sun__) && !defined(__hpux__)
     75 #include <sys/ttydefaults.h>
     76 #endif
     77 #ifndef CTRL
     78 #define CTRL(c)		((c) & 037)
     79 #endif
     80 #endif
     81 #ifndef UNCTRL
     82 #define UNCTRL(c)	(((c) - 'a' + 'A')|control_character_bit)
     83 #endif
     84 
     85 #define RUBOUT		0x7f
     86 #define ABORT_CHAR	CTRL('G')
     87 
     88 /* global variables used by readline enabled applications */
     89 #ifdef __cplusplus
     90 extern "C" {
     91 #endif
     92 extern const char	*rl_library_version;
     93 extern char		*rl_readline_name;
     94 extern FILE		*rl_instream;
     95 extern FILE		*rl_outstream;
     96 extern char		*rl_line_buffer;
     97 extern int		 rl_point, rl_end;
     98 extern int		 history_base, history_length;
     99 extern int		 max_input_history;
    100 extern char		*rl_basic_word_break_characters;
    101 extern char		*rl_completer_word_break_characters;
    102 extern char		*rl_completer_quote_characters;
    103 extern Function		*rl_completion_entry_function;
    104 extern CPPFunction	*rl_attempted_completion_function;
    105 extern int		 rl_attempted_completion_over;
    106 extern int		rl_completion_type;
    107 extern int		rl_completion_query_items;
    108 extern char		*rl_special_prefixes;
    109 extern int		rl_completion_append_character;
    110 extern int		rl_inhibit_completion;
    111 extern Function		*rl_pre_input_hook;
    112 extern Function		*rl_startup_hook;
    113 extern char		*rl_terminal_name;
    114 extern int		rl_already_prompted;
    115 extern char		*rl_prompt;
    116 /*
    117  * The following is not implemented
    118  */
    119 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
    120 			emacs_meta_keymap,
    121 			emacs_ctlx_keymap;
    122 extern int		rl_filename_completion_desired;
    123 extern int		rl_ignore_completion_duplicates;
    124 extern Function		*rl_getc_function;
    125 extern VFunction	*rl_redisplay_function;
    126 extern VFunction	*rl_completion_display_matches_hook;
    127 extern VFunction	*rl_prep_term_function;
    128 extern VFunction	*rl_deprep_term_function;
    129 
    130 /* supported functions */
    131 char		*readline(const char *);
    132 int		 rl_initialize(void);
    133 
    134 void		 using_history(void);
    135 int		 add_history(const char *);
    136 void		 clear_history(void);
    137 void		 stifle_history(int);
    138 int		 unstifle_history(void);
    139 int		 history_is_stifled(void);
    140 int		 where_history(void);
    141 HIST_ENTRY	*current_history(void);
    142 HIST_ENTRY	*history_get(int);
    143 int		 history_total_bytes(void);
    144 int		 history_set_pos(int);
    145 HIST_ENTRY	*previous_history(void);
    146 HIST_ENTRY	*next_history(void);
    147 int		 history_search(const char *, int);
    148 int		 history_search_prefix(const char *, int);
    149 int		 history_search_pos(const char *, int, int);
    150 int		 read_history(const char *);
    151 int		 write_history(const char *);
    152 int		 history_expand(char *, char **);
    153 char	       **history_tokenize(const char *);
    154 const char	*get_history_event(const char *, int *, int);
    155 char		*history_arg_extract(int, int, const char *);
    156 
    157 char		*tilde_expand(char *);
    158 char		*filename_completion_function(const char *, int);
    159 char		*username_completion_function(const char *, int);
    160 int		 rl_complete(int, int);
    161 int		 rl_read_key(void);
    162 char	       **completion_matches(const char *, CPFunction *);
    163 void		 rl_display_match_list(char **, int, int);
    164 
    165 int		 rl_insert(int, int);
    166 void		 rl_reset_terminal(const char *);
    167 int		 rl_bind_key(int, int (*)(int, int));
    168 int		 rl_newline(int, int);
    169 void		 rl_callback_read_char(void);
    170 void		 rl_callback_handler_install(const char *, VFunction *);
    171 void		 rl_callback_handler_remove(void);
    172 void		 rl_redisplay(void);
    173 int		 rl_get_previous_history(int, int);
    174 void		 rl_prep_terminal(int);
    175 void		 rl_deprep_terminal(void);
    176 int		 rl_read_init_file(const char *);
    177 int		 rl_parse_and_bind(const char *);
    178 int		 rl_variable_bind(const char *, const char *);
    179 void		 rl_stuff_char(int);
    180 int		 rl_add_defun(const char *, Function *, int);
    181 
    182 /*
    183  * The following are not implemented
    184  */
    185 Keymap		 rl_get_keymap(void);
    186 Keymap		 rl_make_bare_keymap(void);
    187 int		 rl_generic_bind(int, const char *, const char *, Keymap);
    188 int		 rl_bind_key_in_map(int, Function *, Keymap);
    189 #ifdef __cplusplus
    190 }
    191 #endif
    192 
    193 #endif /* _READLINE_H_ */
    194