1 module gnu.readline; 2 3 import core.stdc.stdio; 4 5 extern (C) 6 { 7 alias Function = int function(); 8 alias VFunction = void function(); 9 alias CPFunction = char* function(); 10 alias CPPFunction = char** function(); 11 alias rl_command_func_t = int function(int, int); 12 alias rl_compentry_func_t = char* function(const(char)*, int, int); 13 alias rl_completion_func_t = char** function(const(char)*, int, int); 14 alias rl_quote_func_t = char* function(char *, int, char *); 15 alias rl_dequote_func_t = char* function(char *, int); 16 alias rl_compignore_func_t = int function(char **); 17 alias rl_compdisp_func_t = void function(char **, int, int); 18 /* Type for input and pre-read hook functions like rl_event_hook */ 19 alias rl_hook_func_t = int function(); 20 21 /* Input function type */ 22 alias rl_getc_func_t = int function(FILE *); 23 24 /* Generic function that takes a character buffer (which could be the readline 25 line buffer) and an index into it (which could be rl_point) and returns 26 an int. */ 27 alias rl_linebuf_func_t = int function(char *, int); 28 29 /* `Generic' function pointer typedefs */ 30 alias rl_intfunc_t = int function(int); 31 alias rl_ivoidfunc_t = rl_hook_func_t; 32 alias rl_icpfunc_t = int function(char *); 33 alias rl_icppfunc_t = int function(char **); 34 35 alias rl_voidfunc_t = void function(); 36 alias rl_vintfunc_t = void function(int); 37 alias rl_vcpfunc_t = void function(char *); 38 alias rl_vcppfunc_t = void function(char **); 39 40 alias rl_cpvfunc_t = char *function(); 41 alias rl_cpifunc_t = char *function(int); 42 alias rl_cpcpfunc_t = char *function(char *); 43 alias rl_cpcppfunc_t = char *function(char **); 44 45 46 struct _keymap_entry 47 { 48 char type; 49 rl_command_func_t function_; 50 } 51 alias KEYMAP_ENTRY = _keymap_entry; 52 53 /* This must be large enough to hold bindings for all of the characters 54 in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, 55 and so on) plus one for subsequence matching. */ 56 enum KEYMAP_SIZE = 257; 57 enum ANYOTHERKEY = KEYMAP_SIZE-1; 58 59 alias KEYMAP_ENTRY_ARRAY = KEYMAP_ENTRY[KEYMAP_SIZE]; 60 alias Keymap = KEYMAP_ENTRY*; 61 62 /* The values that TYPE can have in a keymap entry. */ 63 enum ISFUNC = 0; 64 enum ISKMAP = 1; 65 enum ISMACR = 2; 66 67 extern __gshared KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; 68 extern __gshared KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; 69 70 /* Return a new, empty keymap. 71 Free it with free() when you are done. */ 72 Keymap rl_make_bare_keymap(); 73 74 /* Return a new keymap which is a copy of MAP. */ 75 Keymap rl_copy_keymap(Keymap); 76 77 /* Return a new keymap with the printing characters bound to rl_insert, 78 the lowercase Meta characters bound to run their equivalents, and 79 the Meta digits bound to produce numeric arguments. */ 80 Keymap rl_make_keymap(); 81 82 /* Free the storage associated with a keymap. */ 83 void rl_discard_keymap(Keymap); 84 85 /* These functions actually appear in bind.c */ 86 87 /* Return the keymap corresponding to a given name. Names look like 88 `emacs' or `emacs-meta' or `vi-insert'. */ 89 Keymap rl_get_keymap_by_name(const(char)*); 90 91 /* Return the current keymap. */ 92 Keymap rl_get_keymap(); 93 94 /* Set the current keymap to MAP. */ 95 void rl_set_keymap(Keymap); 96 97 98 99 /* Readline data structures. */ 100 101 /* Maintaining the state of undo. We remember individual deletes and inserts 102 on a chain of things to do. */ 103 104 /* The actions that undo knows how to undo. Notice that UNDO_DELETE means 105 to insert some text, and UNDO_INSERT means to delete some text. I.e., 106 the code tells undo what to undo, not how to undo it. */ 107 enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END }; 108 109 /* What an element of THE_UNDO_LIST looks like. */ 110 struct undo_list 111 { 112 undo_list* next; 113 int start, end; /* Where the change took place. */ 114 char *text; /* The text to insert, if undoing a delete. */ 115 undo_code what; /* Delete, Insert, Begin, End. */ 116 } 117 alias UNDO_LIST = undo_list; 118 119 /* The current undo list for RL_LINE_BUFFER. */ 120 extern __gshared UNDO_LIST* rl_undo_list; 121 122 /* The data structure for mapping textual names to code addresses. */ 123 struct _funmap 124 { 125 const(char)* name; 126 rl_command_func_t function_; 127 } 128 alias FUNMAP = _funmap; 129 130 extern __gshared FUNMAP** funmap; 131 132 133 /* **************************************************************** */ 134 /* */ 135 /* Functions available to bind to key sequences */ 136 /* */ 137 /* **************************************************************** */ 138 139 /* Bindable commands for numeric arguments. */ 140 int rl_digit_argument(int, int); 141 int rl_universal_argument(int, int); 142 143 /* Bindable commands for moving the cursor. */ 144 int rl_forward_byte(int, int); 145 int rl_forward_char(int, int); 146 int rl_forward(int, int); 147 int rl_backward_byte(int, int); 148 int rl_backward_char(int, int); 149 int rl_backward(int, int); 150 int rl_beg_of_line(int, int); 151 int rl_end_of_line(int, int); 152 int rl_forward_word(int, int); 153 int rl_backward_word(int, int); 154 int rl_refresh_line(int, int); 155 int rl_clear_screen(int, int); 156 int rl_skip_csi_sequence(int, int); 157 int rl_arrow_keys(int, int); 158 159 /* Bindable commands for inserting and deleting text. */ 160 int rl_insert(int, int); 161 int rl_quoted_insert(int, int); 162 int rl_tab_insert(int, int); 163 int rl_newline(int, int); 164 int rl_do_lowercase_version(int, int); 165 int rl_rubout(int, int); 166 int rl_delete(int, int); 167 int rl_rubout_or_delete(int, int); 168 int rl_delete_horizontal_space(int, int); 169 int rl_delete_or_show_completions(int, int); 170 int rl_insert_comment(int, int); 171 172 /* Bindable commands for changing case. */ 173 int rl_upcase_word(int, int); 174 int rl_downcase_word(int, int); 175 int rl_capitalize_word(int, int); 176 177 /* Bindable commands for transposing characters and words. */ 178 int rl_transpose_words(int, int); 179 int rl_transpose_chars(int, int); 180 181 /* Bindable commands for searching within a line. */ 182 int rl_char_search(int, int); 183 int rl_backward_char_search(int, int); 184 185 /* Bindable commands for readline's interface to the command history. */ 186 int rl_beginning_of_history(int, int); 187 int rl_end_of_history(int, int); 188 int rl_get_next_history(int, int); 189 int rl_get_previous_history(int, int); 190 191 /* Bindable commands for managing the mark and region. */ 192 int rl_set_mark(int, int); 193 int rl_exchange_point_and_mark(int, int); 194 195 /* Bindable commands to set the editing mode (emacs or vi). */ 196 int rl_vi_editing_mode(int, int); 197 int rl_emacs_editing_mode(int, int); 198 199 /* Bindable commands to change the insert mode (insert or overwrite) */ 200 int rl_overwrite_mode(int, int); 201 202 /* Bindable commands for managing key bindings. */ 203 int rl_re_read_init_file(int, int); 204 int rl_dump_functions(int, int); 205 int rl_dump_macros(int, int); 206 int rl_dump_variables(int, int); 207 208 /* Bindable commands for word completion. */ 209 int rl_complete(int, int); 210 int rl_possible_completions(int, int); 211 int rl_insert_completions(int, int); 212 int rl_old_menu_complete(int, int); 213 int rl_menu_complete(int, int); 214 int rl_backward_menu_complete(int, int); 215 216 /* Bindable commands for killing and yanking text, and managing the kill ring. */ 217 int rl_kill_word(int, int); 218 int rl_backward_kill_word(int, int); 219 int rl_kill_line(int, int); 220 int rl_backward_kill_line(int, int); 221 int rl_kill_full_line(int, int); 222 int rl_unix_word_rubout(int, int); 223 int rl_unix_filename_rubout(int, int); 224 int rl_unix_line_discard(int, int); 225 int rl_copy_region_to_kill(int, int); 226 int rl_kill_region(int, int); 227 int rl_copy_forward_word(int, int); 228 int rl_copy_backward_word(int, int); 229 int rl_yank(int, int); 230 int rl_yank_pop(int, int); 231 int rl_yank_nth_arg(int, int); 232 int rl_yank_last_arg(int, int); 233 234 /* Bindable commands for incremental searching. */ 235 int rl_reverse_search_history(int, int); 236 int rl_forward_search_history(int, int); 237 238 /* Bindable keyboard macro commands. */ 239 int rl_start_kbd_macro(int, int); 240 int rl_end_kbd_macro(int, int); 241 int rl_call_last_kbd_macro(int, int); 242 int rl_print_last_kbd_macro(int, int); 243 244 /* Bindable undo commands. */ 245 int rl_revert_line(int, int); 246 int rl_undo_command(int, int); 247 248 /* Bindable tilde expansion commands. */ 249 int rl_tilde_expand(int, int); 250 251 /* Bindable terminal control commands. */ 252 int rl_restart_output(int, int); 253 int rl_stop_output(int, int); 254 255 /* Miscellaneous bindable commands. */ 256 int rl_abort(int, int); 257 int rl_tty_status(int, int); 258 259 /* Bindable commands for incremental and non-incremental history searching. */ 260 int rl_history_search_forward(int, int); 261 int rl_history_search_backward(int, int); 262 int rl_history_substr_search_forward(int, int); 263 int rl_history_substr_search_backward(int, int); 264 int rl_noninc_forward_search(int, int); 265 int rl_noninc_reverse_search(int, int); 266 int rl_noninc_forward_search_again(int, int); 267 int rl_noninc_reverse_search_again(int, int); 268 269 /* Bindable command used when inserting a matching close character. */ 270 int rl_insert_close(int, int); 271 272 /* Not available unless READLINE_CALLBACKS is defined. */ 273 void rl_callback_handler_install(const(char)*, rl_vcpfunc_t); 274 void rl_callback_read_char(); 275 void rl_callback_handler_remove(); 276 277 /* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */ 278 /* VI-mode bindable commands. */ 279 int rl_vi_redo(int, int); 280 int rl_vi_undo(int, int); 281 int rl_vi_yank_arg(int, int); 282 int rl_vi_fetch_history(int, int); 283 int rl_vi_search_again(int, int); 284 int rl_vi_search(int, int); 285 int rl_vi_complete(int, int); 286 int rl_vi_tilde_expand(int, int); 287 int rl_vi_prev_word(int, int); 288 int rl_vi_next_word(int, int); 289 int rl_vi_end_word(int, int); 290 int rl_vi_insert_beg(int, int); 291 int rl_vi_append_mode(int, int); 292 int rl_vi_append_eol(int, int); 293 int rl_vi_eof_maybe(int, int); 294 int rl_vi_insertion_mode(int, int); 295 int rl_vi_insert_mode(int, int); 296 int rl_vi_movement_mode(int, int); 297 int rl_vi_arg_digit(int, int); 298 int rl_vi_change_case(int, int); 299 int rl_vi_put(int, int); 300 int rl_vi_column(int, int); 301 int rl_vi_delete_to(int, int); 302 int rl_vi_change_to(int, int); 303 int rl_vi_yank_to(int, int); 304 int rl_vi_rubout(int, int); 305 int rl_vi_delete(int, int); 306 int rl_vi_back_to_indent(int, int); 307 int rl_vi_first_print(int, int); 308 int rl_vi_char_search(int, int); 309 int rl_vi_match(int, int); 310 int rl_vi_change_char(int, int); 311 int rl_vi_subst(int, int); 312 int rl_vi_overstrike(int, int); 313 int rl_vi_overstrike_delete(int, int); 314 int rl_vi_replace(int, int); 315 int rl_vi_set_mark(int, int); 316 int rl_vi_goto_mark(int, int); 317 318 /* VI-mode utility functions. */ 319 int rl_vi_check(); 320 int rl_vi_domove(int, int*); 321 int rl_vi_bracktype(int); 322 323 void rl_vi_start_inserting(int, int, int); 324 325 /* VI-mode pseudo-bindable commands, used as utility functions. */ 326 int rl_vi_fWord(int, int); 327 int rl_vi_bWord(int, int); 328 int rl_vi_eWord(int, int); 329 int rl_vi_fword(int, int); 330 int rl_vi_bword(int, int); 331 int rl_vi_eword(int, int); 332 333 334 /* **************************************************************** */ 335 /* */ 336 /* Well Published Functions */ 337 /* */ 338 /* **************************************************************** */ 339 340 /* Readline functions. */ 341 /* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */ 342 char* readline(const(char)*); 343 344 int rl_set_prompt(const(char)*); 345 int rl_expand_prompt(char *); 346 347 int rl_initialize (); 348 349 /* Undocumented; unused by readline */ 350 int rl_discard_argument(); 351 352 /* Utility functions to bind keys to readline commands. */ 353 int rl_add_defun (const(char)*, rl_command_func_t, int); 354 int rl_bind_key (int, rl_command_func_t); 355 int rl_bind_key_in_map (int, rl_command_func_t, Keymap); 356 int rl_unbind_key (int); 357 int rl_unbind_key_in_map (int, Keymap); 358 int rl_bind_key_if_unbound (int, rl_command_func_t); 359 int rl_bind_key_if_unbound_in_map (int, rl_command_func_t, Keymap); 360 int rl_unbind_function_in_map (rl_command_func_t, Keymap); 361 int rl_unbind_command_in_map (const(char)*, Keymap); 362 int rl_bind_keyseq (const(char)**, rl_command_func_t); 363 int rl_bind_keyseq_in_map (const(char)**, rl_command_func_t, Keymap); 364 int rl_bind_keyseq_if_unbound (const(char)**, rl_command_func_t); 365 int rl_bind_keyseq_if_unbound_in_map (const(char)**, rl_command_func_t, Keymap); 366 int rl_generic_bind (int, const(char)**, char *, Keymap); 367 368 char *rl_variable_value (const(char)**); 369 int rl_variable_bind (const(char)**, const(char)**); 370 371 /* Backwards compatibility, use rl_bind_keyseq_in_map instead. */ 372 int rl_set_key (const(char)**, rl_command_func_t, Keymap); 373 374 /* Backwards compatibility, use rl_generic_bind instead. */ 375 int rl_macro_bind (const(char)**, const(char)**, Keymap); 376 377 /* Undocumented in the texinfo manual; not really useful to programs. */ 378 int rl_translate_keyseq (const(char)**, char *, int *); 379 char *rl_untranslate_keyseq (int); 380 381 rl_command_func_t rl_named_function (const(char)**); 382 rl_command_func_t rl_function_of_keyseq (const(char)**, Keymap, int *); 383 384 void rl_list_funmap_names (); 385 char **rl_invoking_keyseqs_in_map (rl_command_func_t, Keymap); 386 char **rl_invoking_keyseqs (rl_command_func_t); 387 388 void rl_function_dumper (int); 389 void rl_macro_dumper (int); 390 void rl_variable_dumper (int); 391 392 int rl_read_init_file (const(char)**); 393 int rl_parse_and_bind (char *); 394 395 /* Functions for manipulating keymaps. */ 396 Keymap rl_make_bare_keymap (); 397 Keymap rl_copy_keymap (Keymap); 398 Keymap rl_make_keymap (); 399 void rl_discard_keymap (Keymap); 400 void rl_free_keymap (Keymap); 401 402 Keymap rl_get_keymap_by_name (const(char)*); 403 char *rl_get_keymap_name (Keymap); 404 void rl_set_keymap (Keymap); 405 Keymap rl_get_keymap (); 406 /* Undocumented; used internally only. */ 407 void rl_set_keymap_from_edit_mode (); 408 char *rl_get_keymap_name_from_edit_mode (); 409 410 /* Functions for manipulating the funmap, which maps command names to functions. */ 411 int rl_add_funmap_entry (const(char)**, rl_command_func_t); 412 const(char)***rl_funmap_names (); 413 /* Undocumented, only used internally -- there is only one funmap, and this 414 function may be called only once. */ 415 void rl_initialize_funmap (); 416 417 /* Utility functions for managing keyboard macros. */ 418 void rl_push_macro_input (char *); 419 420 /* Functions for undoing, from undo.c */ 421 void rl_add_undo (undo_code, int, int, char *); 422 void rl_free_undo_list (); 423 int rl_do_undo (); 424 int rl_begin_undo_group (); 425 int rl_end_undo_group (); 426 int rl_modifying (int, int); 427 428 /* Functions for redisplay. */ 429 void rl_redisplay (); 430 int rl_on_new_line (); 431 int rl_on_new_line_with_prompt (); 432 int rl_forced_update_display (); 433 int rl_clear_message (); 434 int rl_reset_line_state (); 435 int rl_crlf (); 436 437 //int rl_message (const(char)**, ...) __rl_attribute__((__format__ (printf, 1, 2)); 438 439 int rl_show_char (int); 440 441 /* Undocumented in texinfo manual. */ 442 int rl_character_len (int, int); 443 444 /* Save and restore internal prompt redisplay information. */ 445 void rl_save_prompt (); 446 void rl_restore_prompt (); 447 448 /* Modifying text. */ 449 void rl_replace_line (const(char)**, int); 450 int rl_insert_text (const(char)**); 451 int rl_delete_text (int, int); 452 int rl_kill_text (int, int); 453 char *rl_copy_text (int, int); 454 455 /* Terminal and tty mode management. */ 456 void rl_prep_terminal (int); 457 void rl_deprep_terminal (); 458 void rl_tty_set_default_bindings (Keymap); 459 void rl_tty_unset_default_bindings (Keymap); 460 461 int rl_reset_terminal (const(char)**); 462 void rl_resize_terminal (); 463 void rl_set_screen_size (int, int); 464 void rl_get_screen_size (int *, int *); 465 void rl_reset_screen_size (); 466 467 char *rl_get_termcap (const(char)**); 468 469 /* Functions for character input. */ 470 int rl_stuff_char (int); 471 int rl_execute_next (int); 472 int rl_clear_pending_input (); 473 int rl_read_key (); 474 int rl_getc (FILE *); 475 int rl_set_keyboard_input_timeout (int); 476 477 /* `Public' utility functions . */ 478 void rl_extend_line_buffer (int); 479 int rl_ding (); 480 int rl_alphabetic (int); 481 void rl_free (void *); 482 483 /* Readline signal handling, from signals.c */ 484 int rl_set_signals (); 485 int rl_clear_signals (); 486 void rl_cleanup_after_signal (); 487 void rl_reset_after_signal (); 488 void rl_free_line_state (); 489 490 void rl_echo_signal_char (int); 491 492 int rl_set_paren_blink_timeout (int); 493 494 /* History management functions. */ 495 496 void rl_clear_history (); 497 498 /* Undocumented. */ 499 int rl_maybe_save_line (); 500 int rl_maybe_unsave_line (); 501 int rl_maybe_replace_line (); 502 503 /* Completion functions. */ 504 int rl_complete_internal (int); 505 void rl_display_match_list (char **, int, int); 506 507 char **rl_completion_matches (const(char)**, rl_compentry_func_t); 508 char *rl_username_completion_function (const(char)**, int); 509 char *rl_filename_completion_function (const(char)**, int); 510 511 int rl_completion_mode (rl_command_func_t); 512 513 514 /* **************************************************************** */ 515 /* */ 516 /* Well Published Variables */ 517 /* */ 518 /* **************************************************************** */ 519 520 /* The version of this incarnation of the readline library. */ 521 extern __gshared const(char)* rl_library_version; /* e.g., "4.2" */ 522 extern __gshared int rl_readline_version; /* e.g., 0x0402 */ 523 524 /* True if this is real GNU readline. */ 525 extern __gshared int rl_gnu_readline_p; 526 527 /* Flags word encapsulating the current readline state. */ 528 extern __gshared int rl_readline_state; 529 530 /* Says which editing mode readline is currently using. 1 means emacs mode; 531 0 means vi mode. */ 532 extern __gshared int rl_editing_mode; 533 534 /* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means 535 overwrite mode. Reset to insert mode on each input line. */ 536 extern __gshared int rl_insert_mode; 537 538 /* The name of the calling program. You should initialize this to 539 whatever was in argv[0]. It is used when parsing conditionals. */ 540 extern __gshared const(char)* rl_readline_name; 541 542 /* The prompt readline uses. This is set from the argument to 543 readline (), and should not be assigned to directly. */ 544 extern __gshared char *rl_prompt; 545 546 /* The prompt string that is actually displayed by rl_redisplay. Public so 547 applications can more easily supply their own redisplay functions. */ 548 extern __gshared char *rl_display_prompt; 549 550 /* The line buffer that is in use. */ 551 extern __gshared char *rl_line_buffer; 552 553 /* The location of point, and end. */ 554 extern __gshared int rl_point; 555 extern __gshared int rl_end; 556 557 /* The mark, or saved cursor position. */ 558 extern __gshared int rl_mark; 559 560 /* Flag to indicate that readline has finished with the current input 561 line and should return it. */ 562 extern __gshared int rl_done; 563 564 /* If set to a character value, that will be the next keystroke read. */ 565 extern __gshared int rl_pending_input; 566 567 /* Non-zero if we called this function from _rl_dispatch(). It's present 568 so functions can find out whether they were called from a key binding 569 or directly from an application. */ 570 extern __gshared int rl_dispatching; 571 572 /* Non-zero if the user typed a numeric argument before executing the 573 current function. */ 574 extern __gshared int rl_explicit_arg; 575 576 /* The current value of the numeric argument specified by the user. */ 577 extern __gshared int rl_numeric_arg; 578 579 /* The address of the last command function Readline executed. */ 580 extern __gshared rl_command_func_t rl_last_func; 581 582 /* The name of the terminal to use. */ 583 extern __gshared const(char)* rl_terminal_name; 584 585 /* The input and output streams. */ 586 extern __gshared FILE *rl_instream; 587 extern __gshared FILE *rl_outstream; 588 589 /* If non-zero, Readline gives values of LINES and COLUMNS from the environment 590 greater precedence than values fetched from the kernel when computing the 591 screen dimensions. */ 592 extern __gshared int rl_prefer_env_winsize; 593 594 /* If non-zero, then this is the address of a function to call just 595 before readline_internal () prints the first prompt. */ 596 extern __gshared rl_hook_func_t rl_startup_hook; 597 598 /* If non-zero, this is the address of a function to call just before 599 readline_internal_setup () returns and readline_internal starts 600 reading input characters. */ 601 extern __gshared rl_hook_func_t rl_pre_input_hook; 602 603 /* The address of a function to call periodically while Readline is 604 awaiting character input, or NULL, for no event handling. */ 605 extern __gshared rl_hook_func_t rl_event_hook; 606 607 /* The address of a function to call if a read is interrupted by a signal. */ 608 extern __gshared rl_hook_func_t rl_signal_event_hook; 609 610 /* The address of a function to call if Readline needs to know whether or not 611 there is data available from the current input source. */ 612 extern __gshared rl_hook_func_t rl_input_available_hook; 613 614 /* The address of the function to call to fetch a character from the current 615 Readline input stream */ 616 extern __gshared rl_getc_func_t rl_getc_function; 617 618 extern __gshared rl_voidfunc_t rl_redisplay_function; 619 620 extern __gshared rl_vintfunc_t rl_prep_term_function; 621 extern __gshared rl_voidfunc_t rl_deprep_term_function; 622 623 /* Dispatch variables. */ 624 extern __gshared Keymap rl_executing_keymap; 625 extern __gshared Keymap rl_binding_keymap; 626 627 extern __gshared int rl_executing_key; 628 extern __gshared char *rl_executing_keyseq; 629 extern __gshared int rl_key_sequence_length; 630 631 /* Display variables. */ 632 /* If non-zero, readline will erase the entire line, including any prompt, 633 if the only thing typed on an otherwise-blank line is something bound to 634 rl_newline. */ 635 extern __gshared int rl_erase_empty_line; 636 637 /* If non-zero, the application has already printed the prompt (rl_prompt) 638 before calling readline, so readline should not output it the first time 639 redisplay is done. */ 640 extern __gshared int rl_already_prompted; 641 642 /* A non-zero value means to read only this many characters rather than 643 up to a character bound to accept-line. */ 644 extern __gshared int rl_num_chars_to_read; 645 646 /* The text of a currently-executing keyboard macro. */ 647 extern __gshared char *rl_executing_macro; 648 649 /* Variables to control readline signal handling. */ 650 /* If non-zero, readline will install its own signal handlers for 651 SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */ 652 extern __gshared int rl_catch_signals; 653 654 /* If non-zero, readline will install a signal handler for SIGWINCH 655 that also attempts to call any calling application's SIGWINCH signal 656 handler. Note that the terminal is not cleaned up before the 657 application's signal handler is called; use rl_cleanup_after_signal() 658 to do that. */ 659 extern __gshared int rl_catch_sigwinch; 660 661 /* If non-zero, the readline SIGWINCH handler will modify LINES and 662 COLUMNS in the environment. */ 663 extern __gshared int rl_change_environment; 664 665 /* Completion variables. */ 666 /* Pointer to the generator function for completion_matches (). 667 NULL means to use rl_filename_completion_function (), the default 668 filename completer. */ 669 extern __gshared rl_compentry_func_t rl_completion_entry_function; 670 671 /* Optional generator for menu completion. Default is 672 rl_completion_entry_function (rl_filename_completion_function). */ 673 extern __gshared rl_compentry_func_t rl_menu_completion_entry_function; 674 675 /* If rl_ignore_some_completions_function is non-NULL it is the address 676 of a function to call after all of the possible matches have been 677 generated, but before the actual completion is done to the input line. 678 The function is called with one argument; a NULL terminated array 679 of (char *). If your function removes any of the elements, they 680 must be free()'ed. */ 681 extern __gshared rl_compignore_func_t rl_ignore_some_completions_function; 682 683 /* Pointer to alternative function to create matches. 684 Function is called with TEXT, START, and END. 685 START and END are indices in RL_LINE_BUFFER saying what the boundaries 686 of TEXT are. 687 If this function exists and returns NULL then call the value of 688 rl_completion_entry_function to try to match, otherwise use the 689 array of strings returned. */ 690 extern __gshared rl_completion_func_t rl_attempted_completion_function; 691 692 /* The basic list of characters that signal a break between words for the 693 completer routine. The initial contents of this variable is what 694 breaks words in the shell, i.e. "n\"\\'`@$>". */ 695 extern __gshared const(char)* rl_basic_word_break_characters; 696 697 /* The list of characters that signal a break between words for 698 rl_complete_internal. The default list is the contents of 699 rl_basic_word_break_characters. */ 700 extern __gshared /*const*/ char *rl_completer_word_break_characters; 701 702 /* Hook function to allow an application to set the completion word 703 break characters before readline breaks up the line. Allows 704 position-dependent word break characters. */ 705 extern __gshared rl_cpvfunc_t rl_completion_word_break_hook; 706 707 /* List of characters which can be used to quote a substring of the line. 708 Completion occurs on the entire substring, and within the substring 709 rl_completer_word_break_characters are treated as any other character, 710 unless they also appear within this list. */ 711 extern __gshared const(char)* rl_completer_quote_characters; 712 713 /* List of quote characters which cause a word break. */ 714 extern __gshared const(char)* rl_basic_quote_characters; 715 716 /* List of characters that need to be quoted in filenames by the completer. */ 717 extern __gshared const(char)* rl_filename_quote_characters; 718 719 /* List of characters that are word break characters, but should be left 720 in TEXT when it is passed to the completion function. The shell uses 721 this to help determine what kind of completing to do. */ 722 extern __gshared const(char)* rl_special_prefixes; 723 724 /* If non-zero, then this is the address of a function to call when 725 completing on a directory name. The function is called with 726 the address of a string (the current directory name) as an arg. It 727 changes what is displayed when the possible completions are printed 728 or inserted. The directory completion hook should perform 729 any necessary dequoting. This function should return 1 if it modifies 730 the directory name pointer passed as an argument. If the directory 731 completion hook returns 0, it should not modify the directory name 732 pointer passed as an argument. */ 733 extern __gshared rl_icppfunc_t rl_directory_completion_hook; 734 735 /* If non-zero, this is the address of a function to call when completing 736 a directory name. This function takes the address of the directory name 737 to be modified as an argument. Unlike rl_directory_completion_hook, it 738 only modifies the directory name used in opendir(2), not what is displayed 739 when the possible completions are printed or inserted. If set, it takes 740 precedence over rl_directory_completion_hook. The directory rewrite 741 hook should perform any necessary dequoting. This function has the same 742 return value properties as the directory_completion_hook. 743 744 I'm not happy with how this works yet, so it's undocumented. I'm trying 745 it in bash to see how well it goes. */ 746 extern __gshared rl_icppfunc_t rl_directory_rewrite_hook; 747 748 /* If non-zero, this is the address of a function for the completer to call 749 before deciding which character to append to a completed name. It should 750 modify the directory name passed as an argument if appropriate, and return 751 non-zero if it modifies the name. This should not worry about dequoting 752 the filename; that has already happened by the time it gets here. */ 753 extern __gshared rl_icppfunc_t rl_filename_stat_hook; 754 755 /* If non-zero, this is the address of a function to call when reading 756 directory entries from the filesystem for completion and comparing 757 them to the partial word to be completed. The function should 758 either return its first argument (if no conversion takes place) or 759 newly-allocated memory. This can, for instance, convert filenames 760 between character sets for comparison against what's typed at the 761 keyboard. The returned value is what is added to the list of 762 matches. The second argument is the length of the filename to be 763 converted. */ 764 extern __gshared rl_dequote_func_t rl_filename_rewrite_hook; 765 766 /* Backwards compatibility with previous versions of readline. */ 767 alias rl_symbolic_link_hook = rl_directory_completion_hook; 768 769 /* If non-zero, then this is the address of a function to call when 770 completing a word would normally display the list of possible matches. 771 This function is called instead of actually doing the display. 772 It takes three arguments: (char **matches, int num_matches, int max_length) 773 where MATCHES is the array of strings that matched, NUM_MATCHES is the 774 number of strings in that array, and MAX_LENGTH is the length of the 775 longest string in that array. */ 776 extern __gshared rl_compdisp_func_t rl_completion_display_matches_hook; 777 778 /* Non-zero means that the results of the matches are to be treated 779 as filenames. This is ALWAYS zero on entry, and can only be changed 780 within a completion entry finder function. */ 781 extern __gshared int rl_filename_completion_desired; 782 783 /* Non-zero means that the results of the matches are to be quoted using 784 double quotes (or an application-specific quoting mechanism) if the 785 filename contains any characters in rl_word_break_chars. This is 786 ALWAYS non-zero on entry, and can only be changed within a completion 787 entry finder function. */ 788 extern __gshared int rl_filename_quoting_desired; 789 790 /* Set to a function to quote a filename in an application-specific fashion. 791 Called with the text to quote, the type of match found (single or multiple) 792 and a pointer to the quoting character to be used, which the function can 793 reset if desired. */ 794 extern __gshared rl_quote_func_t rl_filename_quoting_function; 795 796 /* Function to call to remove quoting characters from a filename. Called 797 before completion is attempted, so the embedded quotes do not interfere 798 with matching names in the file system. */ 799 extern __gshared rl_dequote_func_t rl_filename_dequoting_function; 800 801 /* Function to call to decide whether or not a word break character is 802 quoted. If a character is quoted, it does not break words for the 803 completer. */ 804 extern __gshared rl_linebuf_func_t rl_char_is_quoted_p; 805 806 /* Non-zero means to suppress normal filename completion after the 807 user-specified completion function has been called. */ 808 extern __gshared int rl_attempted_completion_over; 809 810 /* Set to a character describing the type of completion being attempted by 811 rl_complete_internal; available for use by application completion 812 functions. */ 813 extern __gshared int rl_completion_type; 814 815 /* Set to the last key used to invoke one of the completion functions */ 816 extern __gshared int rl_completion_invoking_key; 817 818 /* Up to this many items will be displayed in response to a 819 possible-completions call. After that, we ask the user if she 820 is sure she wants to see them all. The default value is 100. */ 821 extern __gshared int rl_completion_query_items; 822 823 /* Character appended to completed words when at the end of the line. The 824 default is a space. Nothing is added if this is '\0'. */ 825 extern __gshared int rl_completion_append_character; 826 827 /* If set to non-zero by an application completion function, 828 rl_completion_append_character will not be appended. */ 829 extern __gshared int rl_completion_suppress_append; 830 831 /* Set to any quote character readline thinks it finds before any application 832 completion function is called. */ 833 extern __gshared int rl_completion_quote_character; 834 835 /* Set to a non-zero value if readline found quoting anywhere in the word to 836 be completed; set before any application completion function is called. */ 837 extern __gshared int rl_completion_found_quote; 838 839 /* If non-zero, the completion functions don't append any closing quote. 840 This is set to 0 by rl_complete_internal and may be changed by an 841 application-specific completion function. */ 842 extern __gshared int rl_completion_suppress_quote; 843 844 /* If non-zero, readline will sort the completion matches. On by default. */ 845 extern __gshared int rl_sort_completion_matches; 846 847 /* If non-zero, a slash will be appended to completed filenames that are 848 symbolic links to directory names, subject to the value of the 849 mark-directories variable (which is user-settable). This exists so 850 that application completion functions can override the user's preference 851 (set via the mark-symlinked-directories variable) if appropriate. 852 It's set to the value of _rl_complete_mark_symlink_dirs in 853 rl_complete_internal before any application-specific completion 854 function is called, so without that function doing anything, the user's 855 preferences are honored. */ 856 extern __gshared int rl_completion_mark_symlink_dirs; 857 858 /* If non-zero, then disallow duplicates in the matches. */ 859 extern __gshared int rl_ignore_completion_duplicates; 860 861 /* If this is non-zero, completion is (temporarily) inhibited, and the 862 completion character will be inserted as any other. */ 863 extern __gshared int rl_inhibit_completion; 864 865 /* Input error; can be returned by (*rl_getc_function) if readline is reading 866 a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */ 867 enum READERR = -2; 868 869 /* Definitions available for use by readline clients. */ 870 enum RL_PROMPT_START_IGNORE = '\001'; 871 enum RL_PROMPT_END_IGNORE = '\002'; 872 873 /* Possible values for do_replace argument to rl_filename_quoting_function, 874 called by rl_complete_internal. */ 875 enum NO_MATCH = 0; 876 enum SINGLE_MATCH = 1; 877 enum MULT_MATCH = 2; 878 879 /* Possible state values for rl_readline_state */ 880 enum RL_STATE_NONE = 0x000000; /* no state; before first call */ 881 enum RL_STATE_INITIALIZING = 0x0000001; /* initializing */ 882 enum RL_STATE_INITIALIZED = 0x0000002 ;/* initialization done */ 883 enum RL_STATE_TERMPREPPED = 0x0000004 ;/* terminal is prepped */ 884 enum RL_STATE_READCMD = 0x0000008 ;/* reading a command key */ 885 enum RL_STATE_METANEXT = 0x0000010 ;/* reading input after ESC */ 886 enum RL_STATE_DISPATCHING = 0x0000020 ;/* dispatching to a command */ 887 enum RL_STATE_MOREINPUT = 0x0000040 ;/* reading more input in a command function */ 888 enum RL_STATE_ISEARCH = 0x0000080 ;/* doing incremental search */ 889 enum RL_STATE_NSEARCH = 0x0000100 ;/* doing non-inc search */ 890 enum RL_STATE_SEARCH = 0x0000200 ;/* doing a history search */ 891 enum RL_STATE_NUMERICARG = 0x0000400 ;/* reading numeric argument */ 892 enum RL_STATE_MACROINPUT = 0x0000800 ;/* getting input from a macro */ 893 enum RL_STATE_MACRODEF = 0x0001000 ;/* defining keyboard macro */ 894 enum RL_STATE_OVERWRITE = 0x0002000 ;/* overwrite mode */ 895 enum RL_STATE_COMPLETING = 0x0004000 ;/* doing completion */ 896 enum RL_STATE_SIGHANDLER = 0x0008000 ;/* in readline sighandler */ 897 enum RL_STATE_UNDOING = 0x0010000 ;/* doing an undo */ 898 enum RL_STATE_INPUTPENDING = 0x0020000 ;/* rl_execute_next called */ 899 enum RL_STATE_TTYCSAVED = 0x0040000 ;/* tty special chars saved */ 900 enum RL_STATE_CALLBACK = 0x0080000 ;/* using the callback interface */ 901 enum RL_STATE_VIMOTION = 0x0100000 ;/* reading vi motion arg */ 902 enum RL_STATE_MULTIKEY = 0x0200000 ;/* reading multiple-key command */ 903 enum RL_STATE_VICMDONCE = 0x0400000 ;/* entered vi command mode at least once */ 904 enum RL_STATE_REDISPLAYING = 0x0800000 ;/* updating terminal display */ 905 906 enum RL_STATE_DONE = 0x1000000 ;/* done; accepted line */ 907 908 int RL_SETSTATE(int x) 909 { 910 return rl_readline_state |= x; 911 } 912 913 int RL_UNSETSTATE(int x) 914 { 915 return rl_readline_state &= ~x; 916 } 917 918 auto RL_ISSTATE(int x) 919 { 920 return rl_readline_state & x; 921 } 922 923 struct readline_state 924 { 925 /* line state */ 926 int point; 927 int end; 928 int mark; 929 char *buffer; 930 int buflen; 931 UNDO_LIST *ul; 932 char *prompt; 933 934 /* global state */ 935 int rlstate; 936 int done; 937 Keymap kmap; 938 939 /* input state */ 940 rl_command_func_t lastfunc; 941 int insmode; 942 int edmode; 943 int kseqlen; 944 FILE *inf; 945 FILE *outf; 946 int pendingin; 947 char *macro_; 948 949 /* signal state */ 950 int catchsigs; 951 int catchsigwinch; 952 953 /* search state */ 954 955 /* completion state */ 956 957 /* options state */ 958 959 /* reserved for future expansion, so the struct size doesn't change */ 960 char[64] reserved; 961 } 962 963 int rl_save_state(readline_state *); 964 int rl_restore_state(readline_state *); 965 966 }