Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:13

0001 /*  $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $   */
0002 
0003 /*-
0004  * Copyright (c) 1997 The NetBSD Foundation, Inc.
0005  * All rights reserved.
0006  *
0007  * This code is derived from software contributed to The NetBSD Foundation
0008  * by Jaromir Dolecek.
0009  *
0010  * Redistribution and use in source and binary forms, with or without
0011  * modification, are permitted provided that the following conditions
0012  * are met:
0013  * 1. Redistributions of source code must retain the above copyright
0014  *    notice, this list of conditions and the following disclaimer.
0015  * 2. Redistributions in binary form must reproduce the above copyright
0016  *    notice, this list of conditions and the following disclaimer in the
0017  *    documentation and/or other materials provided with the distribution.
0018  *
0019  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
0020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
0021  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0022  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
0023  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0029  * POSSIBILITY OF SUCH DAMAGE.
0030  */
0031 #ifndef _READLINE_H_
0032 #define _READLINE_H_
0033 
0034 #include <sys/types.h>
0035 #include <stdio.h>
0036 
0037 /* list of readline stuff supported by editline library's readline wrapper */
0038 
0039 /* typedefs */
0040 typedef int   rl_linebuf_func_t(const char *, int);
0041 typedef void      rl_voidfunc_t(void);
0042 typedef void      rl_vintfunc_t(int);
0043 typedef void      rl_vcpfunc_t(char *);
0044 typedef char    **rl_completion_func_t(const char *, int, int);
0045 typedef char     *rl_compentry_func_t(const char *, int);
0046 typedef void      rl_compdisp_func_t(char **, int, int);
0047 typedef int   rl_command_func_t(int, int);
0048 typedef int   rl_hook_func_t(void);
0049 typedef int       rl_icppfunc_t(char **);
0050 
0051 /* only supports length */
0052 typedef struct {
0053     int length;
0054 } HISTORY_STATE;
0055 
0056 typedef void *histdata_t;
0057 
0058 typedef struct _hist_entry {
0059     const char  *line;
0060     histdata_t   data;
0061 } HIST_ENTRY;
0062 
0063 typedef struct _keymap_entry {
0064     char type;
0065 #define ISFUNC  0
0066 #define ISKMAP  1
0067 #define ISMACR  2
0068     rl_linebuf_func_t *function;
0069 } KEYMAP_ENTRY;
0070 
0071 #define KEYMAP_SIZE 256
0072 
0073 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
0074 typedef KEYMAP_ENTRY *Keymap;
0075 
0076 #define control_character_threshold 0x20
0077 #define control_character_bit       0x40
0078 
0079 #ifndef CTRL
0080 #include <sys/ioctl.h>
0081 #if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
0082 #include <sys/ttydefaults.h>
0083 #endif
0084 #ifndef CTRL
0085 #define CTRL(c)     ((c) & 037)
0086 #endif
0087 #endif
0088 #ifndef UNCTRL
0089 #define UNCTRL(c)   (((c) - 'a' + 'A')|control_character_bit)
0090 #endif
0091 
0092 #define RUBOUT      0x7f
0093 #define ABORT_CHAR  CTRL('G')
0094 #define RL_READLINE_VERSION 0x0402
0095 #define RL_PROMPT_START_IGNORE  '\1'
0096 #define RL_PROMPT_END_IGNORE    '\2'
0097 
0098 #define RL_STATE_NONE       0x000000
0099 #define RL_STATE_DONE       0x000001
0100 
0101 #define RL_SETSTATE(x)      (rl_readline_state |= ((unsigned long) x))
0102 #define RL_UNSETSTATE(x)    (rl_readline_state &= ~((unsigned long) x))
0103 #define RL_ISSTATE(x)       (rl_readline_state & ((unsigned long) x))
0104 
0105 /* global variables used by readline enabled applications */
0106 #ifdef __cplusplus
0107 extern "C" {
0108 #endif
0109 extern const char   *rl_library_version;
0110 extern int      rl_readline_version;
0111 extern const char   *rl_readline_name;
0112 extern FILE     *rl_instream;
0113 extern FILE     *rl_outstream;
0114 extern char     *rl_line_buffer;
0115 extern int      rl_point, rl_end;
0116 extern const char   *rl_basic_quote_characters;
0117 extern const char   *rl_basic_word_break_characters;
0118 extern char     *rl_completer_word_break_characters;
0119 extern const char   *rl_completer_quote_characters;
0120 extern rl_compentry_func_t *rl_completion_entry_function;
0121 extern char     *(*rl_completion_word_break_hook)(void);
0122 extern rl_completion_func_t *rl_attempted_completion_function;
0123 extern int       rl_attempted_completion_over;
0124 extern int      rl_completion_type;
0125 extern int      rl_completion_query_items;
0126 extern const char   *rl_special_prefixes;
0127 extern int      rl_completion_append_character;
0128 extern int      rl_inhibit_completion;
0129 extern rl_hook_func_t   *rl_pre_input_hook;
0130 extern rl_hook_func_t   *rl_startup_hook;
0131 extern char     *rl_terminal_name;
0132 extern int      rl_already_prompted;
0133 extern char     *rl_prompt;
0134 extern int      rl_done;
0135 extern rl_vcpfunc_t *rl_linefunc;
0136 extern rl_hook_func_t   *rl_startup1_hook;
0137 extern char             *rl_prompt_saved;
0138 extern int      history_base, history_length;
0139 extern int      history_offset;
0140 extern char     history_expansion_char;
0141 extern char     history_subst_char;
0142 extern char     *history_no_expand_chars;
0143 extern rl_linebuf_func_t *history_inhibit_expansion_function;
0144 extern int      max_input_history;
0145 
0146 /*
0147  * The following is not implemented
0148  */
0149 extern unsigned long    rl_readline_state;
0150 extern int      rl_catch_signals;
0151 extern int      rl_catch_sigwinch;
0152 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
0153             emacs_meta_keymap,
0154             emacs_ctlx_keymap;
0155 extern int      rl_filename_completion_desired;
0156 extern int      rl_ignore_completion_duplicates;
0157 extern int      (*rl_getc_function)(FILE *);
0158 extern rl_voidfunc_t    *rl_redisplay_function;
0159 extern rl_compdisp_func_t *rl_completion_display_matches_hook;
0160 extern rl_vintfunc_t    *rl_prep_term_function;
0161 extern rl_voidfunc_t    *rl_deprep_term_function;
0162 extern rl_hook_func_t   *rl_event_hook;
0163 extern int      readline_echoing_p;
0164 extern int      _rl_print_completions_horizontally;
0165 extern int      _rl_complete_mark_directories;
0166 extern rl_icppfunc_t    *rl_directory_completion_hook;
0167 extern int      rl_completion_suppress_append;
0168 extern int      rl_sort_completion_matches;
0169 extern int      _rl_completion_prefix_display_length;
0170 extern int      _rl_echoing_p;
0171 extern int      history_max_entries;
0172 extern char     *rl_display_prompt;
0173 extern int      rl_erase_empty_line;
0174 
0175 /* supported functions */
0176 char        *readline(const char *);
0177 int      rl_initialize(void);
0178 
0179 void         using_history(void);
0180 int      add_history(const char *);
0181 void         clear_history(void);
0182 int      append_history(int, const char *);
0183 void         stifle_history(int);
0184 int      unstifle_history(void);
0185 int      history_is_stifled(void);
0186 int      where_history(void);
0187 HIST_ENTRY  *current_history(void);
0188 HIST_ENTRY  *history_get(int);
0189 HIST_ENTRY  *remove_history(int);
0190 HIST_ENTRY  *replace_history_entry(int, const char *, histdata_t);
0191 int      history_total_bytes(void);
0192 int      history_set_pos(int);
0193 HIST_ENTRY  *previous_history(void);
0194 HIST_ENTRY  *next_history(void);
0195 HIST_ENTRY     **history_list(void);
0196 int      history_search(const char *, int);
0197 int      history_search_prefix(const char *, int);
0198 int      history_search_pos(const char *, int, int);
0199 int      read_history(const char *);
0200 int      write_history(const char *);
0201 int      history_truncate_file(const char *, int);
0202 int      history_expand(char *, char **);
0203 char           **history_tokenize(const char *);
0204 const char  *get_history_event(const char *, int *, int);
0205 char        *history_arg_extract(int, int, const char *);
0206 
0207 char        *tilde_expand(char *);
0208 char        *filename_completion_function(const char *, int);
0209 char        *username_completion_function(const char *, int);
0210 int      rl_complete(int, int);
0211 int      rl_read_key(void);
0212 char           **completion_matches(/* const */ char *, rl_compentry_func_t *);
0213 void         rl_display_match_list(char **, int, int);
0214 
0215 int      rl_insert(int, int);
0216 int      rl_insert_text(const char *);
0217 int      rl_reset_terminal(const char *);
0218 void         rl_resize_terminal(void);
0219 int      rl_bind_key(int, rl_command_func_t *);
0220 int      rl_newline(int, int);
0221 void         rl_callback_read_char(void);
0222 void         rl_callback_handler_install(const char *, rl_vcpfunc_t *);
0223 void         rl_callback_handler_remove(void);
0224 void         rl_redisplay(void);
0225 int      rl_get_previous_history(int, int);
0226 void         rl_prep_terminal(int);
0227 void         rl_deprep_terminal(void);
0228 int      rl_read_init_file(const char *);
0229 int      rl_parse_and_bind(const char *);
0230 int      rl_variable_bind(const char *, const char *);
0231 int      rl_stuff_char(int);
0232 int      rl_add_defun(const char *, rl_command_func_t *, int);
0233 HISTORY_STATE   *history_get_history_state(void);
0234 void         rl_get_screen_size(int *, int *);
0235 void         rl_set_screen_size(int, int);
0236 char        *rl_filename_completion_function(const char *, int);
0237 int      _rl_abort_internal(void);
0238 int      _rl_qsort_string_compare(char **, char **);
0239 char           **rl_completion_matches(const char *, rl_compentry_func_t *);
0240 void         rl_forced_update_display(void);
0241 int      rl_set_prompt(const char *);
0242 int      rl_on_new_line(void);
0243 void         rl_reset_after_signal(void);
0244 void         rl_echo_signal_char(int);
0245 int      rl_crlf(void);
0246 int      rl_ding(void);
0247 char        *rl_copy_text(int, int);
0248 void         rl_replace_line(const char *, int);
0249 int      rl_delete_text(int, int);
0250 void         rl_message(const char *format, ...)
0251     __attribute__((__format__(__printf__, 1, 2)));
0252 void         rl_save_prompt(void);
0253 void         rl_restore_prompt(void);
0254 
0255 /*
0256  * The following are not implemented
0257  */
0258 int      rl_kill_text(int, int);
0259 Keymap       rl_get_keymap(void);
0260 void         rl_set_keymap(Keymap);
0261 Keymap       rl_make_bare_keymap(void);
0262 int      rl_generic_bind(int, const char *, const char *, Keymap);
0263 int      rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
0264 int      rl_set_key(const char *, rl_command_func_t *, Keymap);
0265 void         rl_cleanup_after_signal(void);
0266 void         rl_free_line_state(void);
0267 int      rl_set_keyboard_input_timeout(int);
0268 int      rl_abort(int, int);
0269 int          rl_set_keymap_name(const char *, Keymap);
0270 histdata_t   free_history_entry(HIST_ENTRY *);
0271 void         _rl_erase_entire_line(void);
0272 
0273 #ifdef __cplusplus
0274 }
0275 #endif
0276 
0277 #endif /* _READLINE_H_ */