1 /* rlprivate.h -- functions and variables global to the readline library,
2 but not intended for use by applications. */
4 /* Copyright (C) 1999-2020 Free Software Foundation, Inc.
6 This file is part of the GNU Readline Library (Readline), a library
7 for reading lines of text with interactive input and history editing.
9 Readline is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Readline is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Readline. If not, see <http://www.gnu.org/licenses/>.
23 #if !defined (_RL_PRIVATE_H_)
24 #define _RL_PRIVATE_H_
26 #include "rlconf.h" /* for VISIBLE_STATS */
28 #include "posixjmp.h" /* defines procenv_t */
29 #include "rlmbutil.h" /* for HANDLE_MULTIBYTE */
31 /*************************************************************************
33 * Convenience definitions *
35 *************************************************************************/
37 #define EMACS_MODE() (rl_editing_mode == emacs_mode)
38 #define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
39 #define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
41 #define RL_CHECK_SIGNALS() \
43 if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
46 #define RL_SIG_RECEIVED() (_rl_caught_signal != 0)
47 #define RL_SIGINT_RECEIVED() (_rl_caught_signal == SIGINT)
48 #define RL_SIGWINCH_RECEIVED() (_rl_caught_signal == SIGWINCH)
50 #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
51 #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
53 /*************************************************************************
55 * Global structs undocumented in texinfo manual and not in readline.h *
57 *************************************************************************/
59 #define RL_SEARCH_ISEARCH 0x01 /* incremental search */
60 #define RL_SEARCH_NSEARCH 0x02 /* non-incremental search */
61 #define RL_SEARCH_CSEARCH 0x04 /* intra-line char search */
64 #define SF_REVERSE 0x01
66 #define SF_FAILED 0x04
67 #define SF_CHGKMAP 0x08
68 #define SF_PATTERN 0x10
69 #define SF_NOCASE 0x20 /* unused so far */
71 typedef struct __rl_search_context
77 int search_string_index
;
78 int search_string_size
;
89 char *prev_line_found
;
91 UNDO_LIST
*save_undo_list
;
93 Keymap keymap
; /* used when dispatching commands in search string */
94 Keymap okeymap
; /* original keymap */
101 #if defined (HANDLE_MULTIBYTE)
103 char pmb
[MB_LEN_MAX
];
110 char *search_terminators
;
117 rl_command_func_t
*func
;
119 extern struct _rl_cmd _rl_pending_command
;
120 extern struct _rl_cmd
*_rl_command_to_execute
;
122 /* Callback data for reading numeric arguments */
123 #define NUM_SAWMINUS 0x01
124 #define NUM_SAWDIGITS 0x02
125 #define NUM_READONE 0x04
127 typedef int _rl_arg_cxt
;
129 /* A context for reading key sequences longer than a single character when
130 using the callback interface. */
131 #define KSEQ_DISPATCHED 0x01
132 #define KSEQ_SUBSEQ 0x02
133 #define KSEQ_RECURSIVE 0x04
135 typedef struct __rl_keyseq_context
139 int subseq_retval
; /* XXX */
145 struct __rl_keyseq_context
*ocxt
;
149 /* vi-mode commands that use result of motion command to define boundaries */
150 #define VIM_DELETE 0x01
151 #define VIM_CHANGE 0x02
152 #define VIM_YANK 0x04
154 /* various states for vi-mode commands that use motion commands. reflects
156 #define VMSTATE_READ 0x01
157 #define VMSTATE_NUMARG 0x02
159 typedef struct __rl_vimotion_context
163 int flags
; /* reserved */
166 int start
, end
; /* rl_point, rl_end */
167 int key
, motion
; /* initial key, motion command */
170 /* fill in more as needed */
171 /* `Generic' callback data and functions */
172 typedef struct __rl_callback_generic_arg
176 /* add here as needed */
177 } _rl_callback_generic_arg
;
179 typedef int _rl_callback_func_t
PARAMS((_rl_callback_generic_arg
*));
181 typedef void _rl_sigcleanup_func_t
PARAMS((int, void *));
183 /*************************************************************************
185 * Global functions undocumented in texinfo manual and not in readline.h *
187 *************************************************************************/
189 /*************************************************************************
191 * Global variables undocumented in texinfo manual and not in readline.h *
193 *************************************************************************/
196 extern int rl_complete_with_tilde_expansion
;
197 #if defined (VISIBLE_STATS)
198 extern int rl_visible_stats
;
199 #endif /* VISIBLE_STATS */
200 #if defined (COLOR_SUPPORT)
201 extern int _rl_colored_stats
;
202 extern int _rl_colored_completion_prefix
;
206 extern int rl_line_buffer_len
;
207 extern int rl_arg_sign
;
208 extern int rl_visible_prompt_length
;
209 extern int rl_byte_oriented
;
212 extern int rl_display_fixed
;
215 extern int rl_blink_matching_paren
;
217 /*************************************************************************
219 * Global functions and variables unused and undocumented *
221 *************************************************************************/
224 extern int rl_set_retained_kills
PARAMS((int));
227 extern void _rl_set_screen_size
PARAMS((int, int));
230 extern int _rl_fix_last_undo_of_type
PARAMS((int, int, int));
233 extern char *_rl_savestring
PARAMS((const char *));
235 /*************************************************************************
237 * Functions and variables private to the readline library *
239 *************************************************************************/
241 /* NOTE: Functions and variables prefixed with `_rl_' are
242 pseudo-global: they are global so they can be shared
243 between files in the readline library, but are not intended
244 to be visible to readline callers. */
246 /*************************************************************************
247 * Undocumented private functions *
248 *************************************************************************/
250 #if defined(READLINE_CALLBACKS)
253 extern void readline_internal_setup
PARAMS((void));
254 extern char *readline_internal_teardown
PARAMS((int));
255 extern int readline_internal_char
PARAMS((void));
257 extern _rl_keyseq_cxt
*_rl_keyseq_cxt_alloc
PARAMS((void));
258 extern void _rl_keyseq_cxt_dispose
PARAMS((_rl_keyseq_cxt
*));
259 extern void _rl_keyseq_chain_dispose
PARAMS((void));
261 extern int _rl_dispatch_callback
PARAMS((_rl_keyseq_cxt
*));
264 extern _rl_callback_generic_arg
*_rl_callback_data_alloc
PARAMS((int));
265 extern void _rl_callback_data_dispose
PARAMS((_rl_callback_generic_arg
*));
267 #endif /* READLINE_CALLBACKS */
270 extern char *_rl_untranslate_macro_value
PARAMS((char *, int));
273 extern void _rl_reset_completion_state
PARAMS((void));
274 extern char _rl_find_completion_word
PARAMS((int *, int *));
275 extern void _rl_free_match_list
PARAMS((char **));
278 extern char *_rl_strip_prompt
PARAMS((char *));
279 extern void _rl_reset_prompt
PARAMS((void));
280 extern void _rl_move_vert
PARAMS((int));
281 extern void _rl_save_prompt
PARAMS((void));
282 extern void _rl_restore_prompt
PARAMS((void));
283 extern char *_rl_make_prompt_for_search
PARAMS((int));
284 extern void _rl_erase_at_end_of_line
PARAMS((int));
285 extern void _rl_clear_to_eol
PARAMS((int));
286 extern void _rl_clear_screen
PARAMS((int));
287 extern void _rl_update_final
PARAMS((void));
288 extern void _rl_optimize_redisplay
PARAMS((void));
289 extern void _rl_redisplay_after_sigwinch
PARAMS((void));
290 extern void _rl_clean_up_for_exit
PARAMS((void));
291 extern void _rl_erase_entire_line
PARAMS((void));
292 extern int _rl_current_display_line
PARAMS((void));
293 extern void _rl_refresh_line
PARAMS((void));
296 extern int _rl_any_typein
PARAMS((void));
297 extern int _rl_input_available
PARAMS((void));
298 extern int _rl_nchars_available
PARAMS((void));
299 extern int _rl_input_queued
PARAMS((int));
300 extern void _rl_insert_typein
PARAMS((int));
301 extern int _rl_unget_char
PARAMS((int));
302 extern int _rl_pushed_input_available
PARAMS((void));
305 extern _rl_search_cxt
*_rl_scxt_alloc
PARAMS((int, int));
306 extern void _rl_scxt_dispose
PARAMS((_rl_search_cxt
*, int));
308 extern int _rl_isearch_dispatch
PARAMS((_rl_search_cxt
*, int));
309 extern int _rl_isearch_callback
PARAMS((_rl_search_cxt
*));
310 extern int _rl_isearch_cleanup
PARAMS((_rl_search_cxt
*, int));
312 extern int _rl_search_getchar
PARAMS((_rl_search_cxt
*));
315 #ifndef BRACKETED_PASTE_DEFAULT
316 # define BRACKETED_PASTE_DEFAULT 1 /* XXX - for now */
319 #define BRACK_PASTE_PREF "\033[200~"
320 #define BRACK_PASTE_SUFF "\033[201~"
322 #define BRACK_PASTE_LAST '~'
323 #define BRACK_PASTE_SLEN 6
325 #define BRACK_PASTE_INIT "\033[?2004h"
326 #define BRACK_PASTE_FINI "\033[?2004l\r"
328 extern int _rl_read_bracketed_paste_prefix
PARAMS((int));
329 extern char *_rl_bracketed_text
PARAMS((size_t *));
330 extern int _rl_bracketed_read_key
PARAMS((void));
331 extern int _rl_bracketed_read_mbstring
PARAMS((char *, int));
334 extern void _rl_with_macro_input
PARAMS((char *));
335 extern int _rl_peek_macro_key
PARAMS((void));
336 extern int _rl_next_macro_key
PARAMS((void));
337 extern int _rl_prev_macro_key
PARAMS((void));
338 extern void _rl_push_executing_macro
PARAMS((void));
339 extern void _rl_pop_executing_macro
PARAMS((void));
340 extern void _rl_add_macro_char
PARAMS((int));
341 extern void _rl_kill_kbd_macro
PARAMS((void));
344 extern int _rl_arg_overflow
PARAMS((void));
345 extern void _rl_arg_init
PARAMS((void));
346 extern int _rl_arg_getchar
PARAMS((void));
347 extern int _rl_arg_callback
PARAMS((_rl_arg_cxt
));
348 extern void _rl_reset_argument
PARAMS((void));
350 extern void _rl_start_using_history
PARAMS((void));
351 extern int _rl_free_saved_history_line
PARAMS((void));
352 extern void _rl_set_insert_mode
PARAMS((int, int));
354 extern void _rl_revert_previous_lines
PARAMS((void));
355 extern void _rl_revert_all_lines
PARAMS((void));
358 extern char *_rl_init_locale
PARAMS((void));
359 extern int _rl_init_eightbit
PARAMS((void));
362 extern void _rl_enable_paren_matching
PARAMS((int));
365 extern void _rl_init_line_state
PARAMS((void));
366 extern void _rl_set_the_line
PARAMS((void));
367 extern int _rl_dispatch
PARAMS((int, Keymap
));
368 extern int _rl_dispatch_subseq
PARAMS((int, Keymap
, int));
369 extern void _rl_internal_char_cleanup
PARAMS((void));
371 extern void _rl_init_executing_keyseq
PARAMS((void));
372 extern void _rl_term_executing_keyseq
PARAMS((void));
373 extern void _rl_end_executing_keyseq
PARAMS((void));
374 extern void _rl_add_executing_keyseq
PARAMS((int));
377 extern int _rl_disable_tty_signals
PARAMS((void));
378 extern int _rl_restore_tty_signals
PARAMS((void));
381 extern int _rl_nsearch_callback
PARAMS((_rl_search_cxt
*));
382 extern int _rl_nsearch_cleanup
PARAMS((_rl_search_cxt
*, int));
385 extern void _rl_signal_handler
PARAMS((int));
387 extern void _rl_block_sigint
PARAMS((void));
388 extern void _rl_release_sigint
PARAMS((void));
389 extern void _rl_block_sigwinch
PARAMS((void));
390 extern void _rl_release_sigwinch
PARAMS((void));
393 extern void _rl_get_screen_size
PARAMS((int, int));
394 extern void _rl_sigwinch_resize_terminal
PARAMS((void));
395 extern int _rl_init_terminal_io
PARAMS((const char *));
397 extern void _rl_output_character_function
PARAMS((int));
399 extern int _rl_output_character_function
PARAMS((int));
401 extern void _rl_cr
PARAMS((void));
402 extern void _rl_output_some_chars
PARAMS((const char *, int));
403 extern int _rl_backspace
PARAMS((int));
404 extern void _rl_enable_meta_key
PARAMS((void));
405 extern void _rl_disable_meta_key
PARAMS((void));
406 extern void _rl_control_keypad
PARAMS((int));
407 extern void _rl_set_cursor
PARAMS((int, int));
408 extern void _rl_standout_on
PARAMS((void));
409 extern void _rl_standout_off
PARAMS((void));
412 extern void _rl_fix_point
PARAMS((int));
413 extern void _rl_fix_mark
PARAMS((void));
414 extern int _rl_replace_text
PARAMS((const char *, int, int));
415 extern int _rl_forward_char_internal
PARAMS((int));
416 extern int _rl_backward_char_internal
PARAMS((int));
417 extern int _rl_insert_char
PARAMS((int, int));
418 extern int _rl_overwrite_char
PARAMS((int, int));
419 extern int _rl_overwrite_rubout
PARAMS((int, int));
420 extern int _rl_rubout_char
PARAMS((int, int));
421 #if defined (HANDLE_MULTIBYTE)
422 extern int _rl_char_search_internal
PARAMS((int, int, char *, int));
424 extern int _rl_char_search_internal
PARAMS((int, int, int));
426 extern int _rl_set_mark_at_pos
PARAMS((int));
429 extern UNDO_LIST
*_rl_copy_undo_entry
PARAMS((UNDO_LIST
*));
430 extern UNDO_LIST
*_rl_copy_undo_list
PARAMS((UNDO_LIST
*));
431 extern void _rl_free_undo_list
PARAMS((UNDO_LIST
*));
434 #if defined (USE_VARARGS) && defined (PREFER_STDARG)
435 extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf
, 1, 2)));
436 extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf
, 1, 2)));
437 extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf
, 1, 2)));
439 extern void _rl_ttymsg ();
440 extern void _rl_errmsg ();
441 extern void _rl_trace ();
443 extern void _rl_audit_tty
PARAMS((char *));
445 extern int _rl_tropen
PARAMS((void));
447 extern int _rl_abort_internal
PARAMS((void));
448 extern int _rl_null_function
PARAMS((int, int));
449 extern char *_rl_strindex
PARAMS((const char *, const char *));
450 extern int _rl_qsort_string_compare
PARAMS((char **, char **));
451 extern int (_rl_uppercase_p
) PARAMS((int));
452 extern int (_rl_lowercase_p
) PARAMS((int));
453 extern int (_rl_pure_alphabetic
) PARAMS((int));
454 extern int (_rl_digit_p
) PARAMS((int));
455 extern int (_rl_to_lower
) PARAMS((int));
456 extern int (_rl_to_upper
) PARAMS((int));
457 extern int (_rl_digit_value
) PARAMS((int));
460 extern void _rl_vi_initialize_line
PARAMS((void));
461 extern void _rl_vi_reset_last
PARAMS((void));
462 extern void _rl_vi_set_last
PARAMS((int, int, int));
463 extern int _rl_vi_textmod_command
PARAMS((int));
464 extern int _rl_vi_motion_command
PARAMS((int));
465 extern void _rl_vi_done_inserting
PARAMS((void));
466 extern int _rl_vi_domove_callback
PARAMS((_rl_vimotion_cxt
*));
467 extern int _rl_vi_domove_motion_cleanup
PARAMS((int, _rl_vimotion_cxt
*));
469 /*************************************************************************
470 * Undocumented private variables *
471 *************************************************************************/
474 extern const char * const _rl_possible_control_prefixes
[];
475 extern const char * const _rl_possible_meta_prefixes
[];
478 extern _rl_callback_func_t
*_rl_callback_func
;
479 extern _rl_callback_generic_arg
*_rl_callback_data
;
482 extern int _rl_complete_show_all
;
483 extern int _rl_complete_show_unmodified
;
484 extern int _rl_complete_mark_directories
;
485 extern int _rl_complete_mark_symlink_dirs
;
486 extern int _rl_completion_prefix_display_length
;
487 extern int _rl_completion_columns
;
488 extern int _rl_print_completions_horizontally
;
489 extern int _rl_completion_case_fold
;
490 extern int _rl_completion_case_map
;
491 extern int _rl_match_hidden_files
;
492 extern int _rl_page_completions
;
493 extern int _rl_skip_completed_text
;
494 extern int _rl_menu_complete_prefix_first
;
497 extern int _rl_vis_botlin
;
498 extern int _rl_last_c_pos
;
499 extern int _rl_suppress_redisplay
;
500 extern int _rl_want_redisplay
;
502 extern char *_rl_emacs_mode_str
;
503 extern int _rl_emacs_modestr_len
;
504 extern char *_rl_vi_ins_mode_str
;
505 extern int _rl_vi_ins_modestr_len
;
506 extern char *_rl_vi_cmd_mode_str
;
507 extern int _rl_vi_cmd_modestr_len
;
510 extern char *_rl_isearch_terminators
;
512 extern _rl_search_cxt
*_rl_iscxt
;
515 extern char *_rl_executing_macro
;
518 extern int _rl_history_preserve_point
;
519 extern int _rl_history_saved_point
;
521 extern _rl_arg_cxt _rl_argcxt
;
524 extern int _rl_utf8locale
;
527 extern int _rl_echoing_p
;
528 extern int _rl_horizontal_scroll_mode
;
529 extern int _rl_mark_modified_lines
;
530 extern int _rl_bell_preference
;
531 extern int _rl_meta_flag
;
532 extern int _rl_convert_meta_chars_to_ascii
;
533 extern int _rl_output_meta_chars
;
534 extern int _rl_bind_stty_chars
;
535 extern int _rl_revert_all_at_newline
;
536 extern int _rl_echo_control_chars
;
537 extern int _rl_show_mode_in_prompt
;
538 extern int _rl_enable_bracketed_paste
;
539 extern int _rl_enable_active_region
;
540 extern char *_rl_comment_begin
;
541 extern unsigned char _rl_parsing_conditionalized_out
;
542 extern Keymap _rl_keymap
;
543 extern FILE *_rl_in_stream
;
544 extern FILE *_rl_out_stream
;
545 extern int _rl_last_command_was_kill
;
546 extern int _rl_eof_char
;
547 extern int _rl_eof_found
;
548 extern procenv_t _rl_top_level
;
549 extern _rl_keyseq_cxt
*_rl_kscxt
;
550 extern int _rl_keyseq_timeout
;
552 extern int _rl_executing_keyseq_size
;
554 extern rl_hook_func_t
*_rl_internal_startup_hook
;
557 extern _rl_search_cxt
*_rl_nscxt
;
560 extern int volatile _rl_caught_signal
;
562 extern _rl_sigcleanup_func_t
*_rl_sigcleanup
;
563 extern void *_rl_sigcleanarg
;
565 extern int _rl_echoctl
;
567 extern int _rl_intr_char
;
568 extern int _rl_quit_char
;
569 extern int _rl_susp_char
;
572 extern int _rl_enable_keypad
;
573 extern int _rl_enable_meta
;
574 extern char *_rl_term_clreol
;
575 extern char *_rl_term_clrpag
;
576 extern char *_rl_term_clrscroll
;
577 extern char *_rl_term_im
;
578 extern char *_rl_term_ic
;
579 extern char *_rl_term_ei
;
580 extern char *_rl_term_DC
;
581 extern char *_rl_term_up
;
582 extern char *_rl_term_dc
;
583 extern char *_rl_term_cr
;
584 extern char *_rl_term_IC
;
585 extern char *_rl_term_forward_char
;
586 extern int _rl_screenheight
;
587 extern int _rl_screenwidth
;
588 extern int _rl_screenchars
;
589 extern int _rl_terminal_can_insert
;
590 extern int _rl_term_autowrap
;
593 extern int _rl_optimize_typeahead
;
594 extern int _rl_keep_mark_active
;
597 extern int _rl_doing_an_undo
;
598 extern int _rl_undo_group_level
;
601 extern int _rl_vi_last_command
;
602 extern int _rl_vi_redoing
;
603 extern _rl_vimotion_cxt
*_rl_vimvcxt
;
605 #endif /* _RL_PRIVATE_H_ */