Sync readline/ to version 7.0 alpha
[deliverable/binutils-gdb.git] / readline / readline.c
1 /* readline.c -- a general facility for reading lines of input
2 with emacs style editing and completion. */
3
4 /* Copyright (C) 1987-2013 Free Software Foundation, Inc.
5
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.
8
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.
13
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.
18
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/>.
21 */
22
23 #define READLINE_LIBRARY
24
25 #if defined (HAVE_CONFIG_H)
26 # include <config.h>
27 #endif
28
29 #include <sys/types.h>
30 #include "posixstat.h"
31 #include <fcntl.h>
32 #if defined (HAVE_SYS_FILE_H)
33 # include <sys/file.h>
34 #endif /* HAVE_SYS_FILE_H */
35
36 #if defined (HAVE_UNISTD_H)
37 # include <unistd.h>
38 #endif /* HAVE_UNISTD_H */
39
40 #if defined (HAVE_STDLIB_H)
41 # include <stdlib.h>
42 #else
43 # include "ansi_stdlib.h"
44 #endif /* HAVE_STDLIB_H */
45
46 #if defined (HAVE_LOCALE_H)
47 # include <locale.h>
48 #endif
49
50 #include <stdio.h>
51 #include "posixjmp.h"
52 #include <errno.h>
53
54 #if !defined (errno)
55 extern int errno;
56 #endif /* !errno */
57
58 /* System-specific feature definitions and include files. */
59 #include "rldefs.h"
60 #include "rlmbutil.h"
61
62 #if defined (__EMX__)
63 # define INCL_DOSPROCESS
64 # include <os2.h>
65 #endif /* __EMX__ */
66
67 /* Some standard library routines. */
68 #include "readline.h"
69 #include "history.h"
70
71 #include "rlprivate.h"
72 #include "rlshell.h"
73 #include "xmalloc.h"
74
75 #ifndef RL_LIBRARY_VERSION
76 # define RL_LIBRARY_VERSION "5.1"
77 #endif
78
79 #ifndef RL_READLINE_VERSION
80 # define RL_READLINE_VERSION 0x0501
81 #endif
82
83 extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
84
85 #if defined (COLOR_SUPPORT)
86 extern void _rl_parse_colors PARAMS((void)); /* XXX */
87 #endif
88
89
90 /* Forward declarations used in this file. */
91 static char *readline_internal PARAMS((void));
92 static void readline_initialize_everything PARAMS((void));
93
94 static void bind_arrow_keys_internal PARAMS((Keymap));
95 static void bind_arrow_keys PARAMS((void));
96
97 static void bind_bracketed_paste_prefix PARAMS((void));
98
99 static void readline_default_bindings PARAMS((void));
100 static void reset_default_bindings PARAMS((void));
101
102 static int _rl_subseq_result PARAMS((int, Keymap, int, int));
103 static int _rl_subseq_getchar PARAMS((int));
104
105 /* **************************************************************** */
106 /* */
107 /* Line editing input utility */
108 /* */
109 /* **************************************************************** */
110
111 const char *rl_library_version = RL_LIBRARY_VERSION;
112
113 int rl_readline_version = RL_READLINE_VERSION;
114
115 /* True if this is `real' readline as opposed to some stub substitute. */
116 int rl_gnu_readline_p = 1;
117
118 /* A pointer to the keymap that is currently in use.
119 By default, it is the standard emacs keymap. */
120 Keymap _rl_keymap = emacs_standard_keymap;
121
122 /* The current style of editing. */
123 int rl_editing_mode = emacs_mode;
124
125 /* The current insert mode: input (the default) or overwrite */
126 int rl_insert_mode = RL_IM_DEFAULT;
127
128 /* Non-zero if we called this function from _rl_dispatch(). It's present
129 so functions can find out whether they were called from a key binding
130 or directly from an application. */
131 int rl_dispatching;
132
133 /* Non-zero if the previous command was a kill command. */
134 int _rl_last_command_was_kill = 0;
135
136 /* The current value of the numeric argument specified by the user. */
137 int rl_numeric_arg = 1;
138
139 /* Non-zero if an argument was typed. */
140 int rl_explicit_arg = 0;
141
142 /* Temporary value used while generating the argument. */
143 int rl_arg_sign = 1;
144
145 /* Non-zero means we have been called at least once before. */
146 static int rl_initialized;
147
148 #if 0
149 /* If non-zero, this program is running in an EMACS buffer. */
150 static int running_in_emacs;
151 #endif
152
153 /* Flags word encapsulating the current readline state. */
154 int rl_readline_state = RL_STATE_NONE;
155
156 /* The current offset in the current input line. */
157 int rl_point;
158
159 /* Mark in the current input line. */
160 int rl_mark;
161
162 /* Length of the current input line. */
163 int rl_end;
164
165 /* Make this non-zero to return the current input_line. */
166 int rl_done;
167
168 /* The last function executed by readline. */
169 rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
170
171 /* Top level environment for readline_internal (). */
172 procenv_t _rl_top_level;
173
174 /* The streams we interact with. */
175 FILE *_rl_in_stream, *_rl_out_stream;
176
177 /* The names of the streams that we do input and output to. */
178 FILE *rl_instream = (FILE *)NULL;
179 FILE *rl_outstream = (FILE *)NULL;
180
181 /* Non-zero means echo characters as they are read. Defaults to no echo;
182 set to 1 if there is a controlling terminal, we can get its attributes,
183 and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
184 for the code that sets it. */
185 int _rl_echoing_p = 0;
186
187 /* Current prompt. */
188 char *rl_prompt = (char *)NULL;
189 int rl_visible_prompt_length = 0;
190
191 /* Set to non-zero by calling application if it has already printed rl_prompt
192 and does not want readline to do it the first time. */
193 int rl_already_prompted = 0;
194
195 /* The number of characters read in order to type this complete command. */
196 int rl_key_sequence_length = 0;
197
198 /* If non-zero, then this is the address of a function to call just
199 before readline_internal_setup () prints the first prompt. */
200 rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
201
202 /* If non-zero, this is the address of a function to call just before
203 readline_internal_setup () returns and readline_internal starts
204 reading input characters. */
205 rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
206
207 /* What we use internally. You should always refer to RL_LINE_BUFFER. */
208 static char *the_line;
209
210 /* The character that can generate an EOF. Really read from
211 the terminal driver... just defaulted here. */
212 int _rl_eof_char = CTRL ('D');
213
214 /* Non-zero makes this the next keystroke to read. */
215 int rl_pending_input = 0;
216
217 /* Pointer to a useful terminal name. */
218 const char *rl_terminal_name = (const char *)NULL;
219
220 /* Non-zero means to always use horizontal scrolling in line display. */
221 int _rl_horizontal_scroll_mode = 0;
222
223 /* Non-zero means to display an asterisk at the starts of history lines
224 which have been modified. */
225 int _rl_mark_modified_lines = 0;
226
227 /* The style of `bell' notification preferred. This can be set to NO_BELL,
228 AUDIBLE_BELL, or VISIBLE_BELL. */
229 int _rl_bell_preference = AUDIBLE_BELL;
230
231 /* String inserted into the line by rl_insert_comment (). */
232 char *_rl_comment_begin;
233
234 /* Keymap holding the function currently being executed. */
235 Keymap rl_executing_keymap;
236
237 /* Keymap we're currently using to dispatch. */
238 Keymap _rl_dispatching_keymap;
239
240 /* Non-zero means to erase entire line, including prompt, on empty input lines. */
241 int rl_erase_empty_line = 0;
242
243 /* Non-zero means to read only this many characters rather than up to a
244 character bound to accept-line. */
245 int rl_num_chars_to_read;
246
247 /* Line buffer and maintenance. */
248 char *rl_line_buffer = (char *)NULL;
249 int rl_line_buffer_len = 0;
250
251 /* Key sequence `contexts' */
252 _rl_keyseq_cxt *_rl_kscxt = 0;
253
254 int rl_executing_key;
255 char *rl_executing_keyseq = 0;
256 int _rl_executing_keyseq_size = 0;
257
258 /* Timeout (specified in milliseconds) when reading characters making up an
259 ambiguous multiple-key sequence */
260 int _rl_keyseq_timeout = 500;
261
262 #define RESIZE_KEYSEQ_BUFFER() \
263 do \
264 { \
265 if (rl_key_sequence_length + 2 >= _rl_executing_keyseq_size) \
266 { \
267 _rl_executing_keyseq_size += 16; \
268 rl_executing_keyseq = xrealloc (rl_executing_keyseq, _rl_executing_keyseq_size); \
269 } \
270 } \
271 while (0);
272
273 /* Forward declarations used by the display, termcap, and history code. */
274
275 /* **************************************************************** */
276 /* */
277 /* `Forward' declarations */
278 /* */
279 /* **************************************************************** */
280
281 /* Non-zero means do not parse any lines other than comments and
282 parser directives. */
283 unsigned char _rl_parsing_conditionalized_out = 0;
284
285 /* Non-zero means to convert characters with the meta bit set to
286 escape-prefixed characters so we can indirect through
287 emacs_meta_keymap or vi_escape_keymap. */
288 int _rl_convert_meta_chars_to_ascii = 1;
289
290 /* Non-zero means to output characters with the meta bit set directly
291 rather than as a meta-prefixed escape sequence. */
292 int _rl_output_meta_chars = 0;
293
294 /* Non-zero means to look at the termios special characters and bind
295 them to equivalent readline functions at startup. */
296 int _rl_bind_stty_chars = 1;
297
298 /* Non-zero means to go through the history list at every newline (or
299 whenever rl_done is set and readline returns) and revert each line to
300 its initial state. */
301 int _rl_revert_all_at_newline = 0;
302
303 /* Non-zero means to honor the termios ECHOCTL bit and echo control
304 characters corresponding to keyboard-generated signals. */
305 int _rl_echo_control_chars = 1;
306
307 /* Non-zero means to prefix the displayed prompt with a character indicating
308 the editing mode: @ for emacs, : for vi-command, + for vi-insert. */
309 int _rl_show_mode_in_prompt = 0;
310
311 /* Non-zero means to attempt to put the terminal in `bracketed paste mode',
312 where it will prefix pasted text with an escape sequence and send
313 another to mark the end of the paste. */
314 int _rl_enable_bracketed_paste = 0;
315
316 /* **************************************************************** */
317 /* */
318 /* Top Level Functions */
319 /* */
320 /* **************************************************************** */
321
322 /* Non-zero means treat 0200 bit in terminal input as Meta bit. */
323 int _rl_meta_flag = 0; /* Forward declaration */
324
325 /* Set up the prompt and expand it. Called from readline() and
326 rl_callback_handler_install (). */
327 int
328 rl_set_prompt (prompt)
329 const char *prompt;
330 {
331 FREE (rl_prompt);
332 rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
333 rl_display_prompt = rl_prompt ? rl_prompt : "";
334
335 rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
336 return 0;
337 }
338
339 /* Read a line of input. Prompt with PROMPT. An empty PROMPT means
340 none. A return value of NULL means that EOF was encountered. */
341 char *
342 readline (prompt)
343 const char *prompt;
344 {
345 char *value;
346 #if 0
347 int in_callback;
348 #endif
349
350 /* If we are at EOF return a NULL string. */
351 if (rl_pending_input == EOF)
352 {
353 rl_clear_pending_input ();
354 return ((char *)NULL);
355 }
356
357 #if 0
358 /* If readline() is called after installing a callback handler, temporarily
359 turn off the callback state to avoid ensuing messiness. Patch supplied
360 by the gdb folks. XXX -- disabled. This can be fooled and readline
361 left in a strange state by a poorly-timed longjmp. */
362 if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK))
363 RL_UNSETSTATE (RL_STATE_CALLBACK);
364 #endif
365
366 rl_set_prompt (prompt);
367
368 rl_initialize ();
369 if (rl_prep_term_function)
370 (*rl_prep_term_function) (_rl_meta_flag);
371
372 #if defined (HANDLE_SIGNALS)
373 rl_set_signals ();
374 #endif
375
376 value = readline_internal ();
377 if (rl_deprep_term_function)
378 (*rl_deprep_term_function) ();
379
380 #if defined (HANDLE_SIGNALS)
381 rl_clear_signals ();
382 #endif
383
384 #if 0
385 if (in_callback)
386 RL_SETSTATE (RL_STATE_CALLBACK);
387 #endif
388
389 #if HAVE_DECL_AUDIT_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
390 if (value)
391 _rl_audit_tty (value);
392 #endif
393
394 return (value);
395 }
396
397 #if defined (READLINE_CALLBACKS)
398 # define STATIC_CALLBACK
399 #else
400 # define STATIC_CALLBACK static
401 #endif
402
403 STATIC_CALLBACK void
404 readline_internal_setup ()
405 {
406 char *nprompt;
407
408 _rl_in_stream = rl_instream;
409 _rl_out_stream = rl_outstream;
410
411 /* Enable the meta key only for the duration of readline(), if this
412 terminal has one and the terminal has been initialized */
413 if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
414 _rl_enable_meta_key ();
415
416 if (rl_startup_hook)
417 (*rl_startup_hook) ();
418
419 #if defined (VI_MODE)
420 if (rl_editing_mode == vi_mode)
421 rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
422 #endif /* VI_MODE */
423
424 /* If we're not echoing, we still want to at least print a prompt, because
425 rl_redisplay will not do it for us. If the calling application has a
426 custom redisplay function, though, let that function handle it. */
427 if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
428 {
429 if (rl_prompt && rl_already_prompted == 0)
430 {
431 nprompt = _rl_strip_prompt (rl_prompt);
432 fprintf (_rl_out_stream, "%s", nprompt);
433 fflush (_rl_out_stream);
434 xfree (nprompt);
435 }
436 }
437 else
438 {
439 if (rl_prompt && rl_already_prompted)
440 rl_on_new_line_with_prompt ();
441 else
442 rl_on_new_line ();
443 (*rl_redisplay_function) ();
444 }
445
446 if (rl_pre_input_hook)
447 (*rl_pre_input_hook) ();
448
449 RL_CHECK_SIGNALS ();
450 }
451
452 STATIC_CALLBACK char *
453 readline_internal_teardown (eof)
454 int eof;
455 {
456 char *temp;
457 HIST_ENTRY *entry;
458
459 RL_CHECK_SIGNALS ();
460
461 /* Restore the original of this history line, iff the line that we
462 are editing was originally in the history, AND the line has changed. */
463 entry = current_history ();
464
465 if (entry && rl_undo_list)
466 {
467 temp = savestring (the_line);
468 rl_revert_line (1, 0);
469 entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
470 _rl_free_history_entry (entry);
471
472 strcpy (the_line, temp);
473 xfree (temp);
474 }
475
476 if (_rl_revert_all_at_newline)
477 _rl_revert_all_lines ();
478
479 /* At any rate, it is highly likely that this line has an undo list. Get
480 rid of it now. */
481 if (rl_undo_list)
482 rl_free_undo_list ();
483
484 /* Disable the meta key, if this terminal has one and we were told to use it.
485 The check whether or not we sent the enable string is in
486 _rl_disable_meta_key(); the flag is set in _rl_enable_meta_key */
487 _rl_disable_meta_key ();
488
489 /* Restore normal cursor, if available. */
490 _rl_set_insert_mode (RL_IM_INSERT, 0);
491
492 return (eof ? (char *)NULL : savestring (the_line));
493 }
494
495 void
496 _rl_internal_char_cleanup ()
497 {
498 #if defined (VI_MODE)
499 /* In vi mode, when you exit insert mode, the cursor moves back
500 over the previous character. We explicitly check for that here. */
501 if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
502 rl_vi_check ();
503 #endif /* VI_MODE */
504
505 if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
506 {
507 (*rl_redisplay_function) ();
508 _rl_want_redisplay = 0;
509 rl_newline (1, '\n');
510 }
511
512 if (rl_done == 0)
513 {
514 (*rl_redisplay_function) ();
515 _rl_want_redisplay = 0;
516 }
517
518 /* If the application writer has told us to erase the entire line if
519 the only character typed was something bound to rl_newline, do so. */
520 if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
521 rl_point == 0 && rl_end == 0)
522 _rl_erase_entire_line ();
523 }
524
525 STATIC_CALLBACK int
526 #if defined (READLINE_CALLBACKS)
527 readline_internal_char ()
528 #else
529 readline_internal_charloop ()
530 #endif
531 {
532 static int lastc, eof_found;
533 int c, code, lk;
534
535 lastc = EOF;
536
537 #if !defined (READLINE_CALLBACKS)
538 eof_found = 0;
539 while (rl_done == 0)
540 {
541 #endif
542 lk = _rl_last_command_was_kill;
543
544 #if defined (HAVE_POSIX_SIGSETJMP)
545 code = sigsetjmp (_rl_top_level, 0);
546 #else
547 code = setjmp (_rl_top_level);
548 #endif
549
550 if (code)
551 {
552 (*rl_redisplay_function) ();
553 _rl_want_redisplay = 0;
554 /* If we get here, we're not being called from something dispatched
555 from _rl_callback_read_char(), which sets up its own value of
556 _rl_top_level (saving and restoring the old, of course), so
557 we can just return here. */
558 if (RL_ISSTATE (RL_STATE_CALLBACK))
559 return (0);
560 }
561
562 if (rl_pending_input == 0)
563 {
564 /* Then initialize the argument and number of keys read. */
565 _rl_reset_argument ();
566 rl_key_sequence_length = 0;
567 rl_executing_keyseq[0] = 0;
568 }
569
570 RL_SETSTATE(RL_STATE_READCMD);
571 c = rl_read_key ();
572 RL_UNSETSTATE(RL_STATE_READCMD);
573
574 /* look at input.c:rl_getc() for the circumstances under which this will
575 be returned; punt immediately on read error without converting it to
576 a newline; assume that rl_read_key has already called the signal
577 handler. */
578 if (c == READERR)
579 {
580 #if defined (READLINE_CALLBACKS)
581 RL_SETSTATE(RL_STATE_DONE);
582 return (rl_done = 1);
583 #else
584 eof_found = 1;
585 break;
586 #endif
587 }
588
589 /* EOF typed to a non-blank line is ^D the first time, EOF the second
590 time in a row. This won't return any partial line read from the tty.
591 If we want to change this, to force any existing line to be returned
592 when read(2) reads EOF, for example, this is the place to change. */
593 if (c == EOF && rl_end)
594 {
595 if (RL_SIG_RECEIVED ())
596 {
597 RL_CHECK_SIGNALS ();
598 if (rl_signal_event_hook)
599 (*rl_signal_event_hook) (); /* XXX */
600 }
601
602 /* XXX - reading two consecutive EOFs returns EOF */
603 if (RL_ISSTATE (RL_STATE_TERMPREPPED))
604 {
605 if (lastc == _rl_eof_char || lastc == EOF)
606 rl_end = 0;
607 else
608 c = _rl_eof_char;
609 }
610 else
611 c = NEWLINE;
612 }
613
614 /* The character _rl_eof_char typed to blank line, and not as the
615 previous character is interpreted as EOF. This doesn't work when
616 READLINE_CALLBACKS is defined, so hitting a series of ^Ds will
617 erase all the chars on the line and then return EOF. */
618 if (((c == _rl_eof_char && lastc != c) || c == EOF) && rl_end == 0)
619 {
620 #if defined (READLINE_CALLBACKS)
621 RL_SETSTATE(RL_STATE_DONE);
622 return (rl_done = 1);
623 #else
624 eof_found = 1;
625 break;
626 #endif
627 }
628
629 lastc = c;
630 _rl_dispatch ((unsigned char)c, _rl_keymap);
631 RL_CHECK_SIGNALS ();
632
633 /* If there was no change in _rl_last_command_was_kill, then no kill
634 has taken place. Note that if input is pending we are reading
635 a prefix command, so nothing has changed yet. */
636 if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
637 _rl_last_command_was_kill = 0;
638
639 _rl_internal_char_cleanup ();
640
641 #if defined (READLINE_CALLBACKS)
642 return 0;
643 #else
644 }
645
646 return (eof_found);
647 #endif
648 }
649
650 #if defined (READLINE_CALLBACKS)
651 static int
652 readline_internal_charloop ()
653 {
654 int eof = 1;
655
656 while (rl_done == 0)
657 eof = readline_internal_char ();
658 return (eof);
659 }
660 #endif /* READLINE_CALLBACKS */
661
662 /* Read a line of input from the global rl_instream, doing output on
663 the global rl_outstream.
664 If rl_prompt is non-null, then that is our prompt. */
665 static char *
666 readline_internal ()
667 {
668 int eof;
669
670 readline_internal_setup ();
671 eof = readline_internal_charloop ();
672 return (readline_internal_teardown (eof));
673 }
674
675 void
676 _rl_init_line_state ()
677 {
678 rl_point = rl_end = rl_mark = 0;
679 the_line = rl_line_buffer;
680 the_line[0] = 0;
681 }
682
683 void
684 _rl_set_the_line ()
685 {
686 the_line = rl_line_buffer;
687 }
688
689 #if defined (READLINE_CALLBACKS)
690 _rl_keyseq_cxt *
691 _rl_keyseq_cxt_alloc ()
692 {
693 _rl_keyseq_cxt *cxt;
694
695 cxt = (_rl_keyseq_cxt *)xmalloc (sizeof (_rl_keyseq_cxt));
696
697 cxt->flags = cxt->subseq_arg = cxt->subseq_retval = 0;
698
699 cxt->okey = 0;
700 cxt->ocxt = _rl_kscxt;
701 cxt->childval = 42; /* sentinel value */
702
703 return cxt;
704 }
705
706 void
707 _rl_keyseq_cxt_dispose (cxt)
708 _rl_keyseq_cxt *cxt;
709 {
710 xfree (cxt);
711 }
712
713 void
714 _rl_keyseq_chain_dispose ()
715 {
716 _rl_keyseq_cxt *cxt;
717
718 while (_rl_kscxt)
719 {
720 cxt = _rl_kscxt;
721 _rl_kscxt = _rl_kscxt->ocxt;
722 _rl_keyseq_cxt_dispose (cxt);
723 }
724 }
725 #endif
726
727 static int
728 _rl_subseq_getchar (key)
729 int key;
730 {
731 int k;
732
733 if (key == ESC)
734 RL_SETSTATE(RL_STATE_METANEXT);
735 RL_SETSTATE(RL_STATE_MOREINPUT);
736 k = rl_read_key ();
737 RL_UNSETSTATE(RL_STATE_MOREINPUT);
738 if (key == ESC)
739 RL_UNSETSTATE(RL_STATE_METANEXT);
740
741 return k;
742 }
743
744 #if defined (READLINE_CALLBACKS)
745 int
746 _rl_dispatch_callback (cxt)
747 _rl_keyseq_cxt *cxt;
748 {
749 int nkey, r;
750
751 /* For now */
752 /* The first time this context is used, we want to read input and dispatch
753 on it. When traversing the chain of contexts back `up', we want to use
754 the value from the next context down. We're simulating recursion using
755 a chain of contexts. */
756 if ((cxt->flags & KSEQ_DISPATCHED) == 0)
757 {
758 nkey = _rl_subseq_getchar (cxt->okey);
759 if (nkey < 0)
760 {
761 _rl_abort_internal ();
762 return -1;
763 }
764 r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
765 cxt->flags |= KSEQ_DISPATCHED;
766 }
767 else
768 r = cxt->childval;
769
770 /* For now */
771 if (r != -3) /* don't do this if we indicate there will be other matches */
772 r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
773
774 RL_CHECK_SIGNALS ();
775 /* We only treat values < 0 specially to simulate recursion. */
776 if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */
777 {
778 _rl_keyseq_chain_dispose ();
779 RL_UNSETSTATE (RL_STATE_MULTIKEY);
780 return r;
781 }
782
783 if (r != -3) /* magic value that says we added to the chain */
784 _rl_kscxt = cxt->ocxt;
785 if (_rl_kscxt)
786 _rl_kscxt->childval = r;
787 if (r != -3)
788 _rl_keyseq_cxt_dispose (cxt);
789
790 return r;
791 }
792 #endif /* READLINE_CALLBACKS */
793
794 /* Do the command associated with KEY in MAP.
795 If the associated command is really a keymap, then read
796 another key, and dispatch into that map. */
797 int
798 _rl_dispatch (key, map)
799 register int key;
800 Keymap map;
801 {
802 _rl_dispatching_keymap = map;
803 return _rl_dispatch_subseq (key, map, 0);
804 }
805
806 int
807 _rl_dispatch_subseq (key, map, got_subseq)
808 register int key;
809 Keymap map;
810 int got_subseq;
811 {
812 int r, newkey;
813 char *macro;
814 rl_command_func_t *func;
815 #if defined (READLINE_CALLBACKS)
816 _rl_keyseq_cxt *cxt;
817 #endif
818
819 if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
820 {
821 if (map[ESC].type == ISKMAP)
822 {
823 if (RL_ISSTATE (RL_STATE_MACRODEF))
824 _rl_add_macro_char (ESC);
825 RESIZE_KEYSEQ_BUFFER ();
826 rl_executing_keyseq[rl_key_sequence_length++] = ESC;
827 map = FUNCTION_TO_KEYMAP (map, ESC);
828 key = UNMETA (key);
829 return (_rl_dispatch (key, map));
830 }
831 else
832 rl_ding ();
833 return 0;
834 }
835
836 if (RL_ISSTATE (RL_STATE_MACRODEF))
837 _rl_add_macro_char (key);
838
839 r = 0;
840 switch (map[key].type)
841 {
842 case ISFUNC:
843 func = map[key].function;
844 if (func)
845 {
846 /* Special case rl_do_lowercase_version (). */
847 if (func == rl_do_lowercase_version)
848 /* Should we do anything special if key == ANYOTHERKEY? */
849 return (_rl_dispatch (_rl_to_lower (key), map));
850
851 rl_executing_keymap = map;
852 rl_executing_key = key;
853
854 RESIZE_KEYSEQ_BUFFER();
855 rl_executing_keyseq[rl_key_sequence_length++] = key;
856 rl_executing_keyseq[rl_key_sequence_length] = '\0';
857
858 rl_dispatching = 1;
859 RL_SETSTATE(RL_STATE_DISPATCHING);
860 r = (*func) (rl_numeric_arg * rl_arg_sign, key);
861 RL_UNSETSTATE(RL_STATE_DISPATCHING);
862 rl_dispatching = 0;
863
864 /* If we have input pending, then the last command was a prefix
865 command. Don't change the state of rl_last_func. Otherwise,
866 remember the last command executed in this variable. */
867 if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
868 rl_last_func = map[key].function;
869
870 RL_CHECK_SIGNALS ();
871 }
872 else if (map[ANYOTHERKEY].function)
873 {
874 /* OK, there's no function bound in this map, but there is a
875 shadow function that was overridden when the current keymap
876 was created. Return -2 to note that. */
877 if (RL_ISSTATE (RL_STATE_MACROINPUT))
878 _rl_prev_macro_key ();
879 else
880 _rl_unget_char (key);
881 return -2;
882 }
883 else if (got_subseq)
884 {
885 /* Return -1 to note that we're in a subsequence, but we don't
886 have a matching key, nor was one overridden. This means
887 we need to back up the recursion chain and find the last
888 subsequence that is bound to a function. */
889 if (RL_ISSTATE (RL_STATE_MACROINPUT))
890 _rl_prev_macro_key ();
891 else
892 _rl_unget_char (key);
893 return -1;
894 }
895 else
896 {
897 #if defined (READLINE_CALLBACKS)
898 RL_UNSETSTATE (RL_STATE_MULTIKEY);
899 _rl_keyseq_chain_dispose ();
900 #endif
901 _rl_abort_internal ();
902 return -1;
903 }
904 break;
905
906 case ISKMAP:
907 if (map[key].function != 0)
908 {
909 #if defined (VI_MODE)
910 /* The only way this test will be true is if a subsequence has been
911 bound starting with ESC, generally the arrow keys. What we do is
912 check whether there's input in the queue, which there generally
913 will be if an arrow key has been pressed, and, if there's not,
914 just dispatch to (what we assume is) rl_vi_movement_mode right
915 away. This is essentially an input test with a zero timeout (by
916 default) or a timeout determined by the value of `keyseq-timeout' */
917 /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
918 takes microseconds, so multiply by 1000 */
919 if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
920 && _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
921 return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
922 #endif
923
924 RESIZE_KEYSEQ_BUFFER ();
925 rl_executing_keyseq[rl_key_sequence_length++] = key;
926 _rl_dispatching_keymap = FUNCTION_TO_KEYMAP (map, key);
927
928 /* Allocate new context here. Use linked contexts (linked through
929 cxt->ocxt) to simulate recursion */
930 #if defined (READLINE_CALLBACKS)
931 if (RL_ISSTATE (RL_STATE_CALLBACK))
932 {
933 /* Return 0 only the first time, to indicate success to
934 _rl_callback_read_char. The rest of the time, we're called
935 from _rl_dispatch_callback, so we return -3 to indicate
936 special handling is necessary. */
937 r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
938 cxt = _rl_keyseq_cxt_alloc ();
939
940 if (got_subseq)
941 cxt->flags |= KSEQ_SUBSEQ;
942 cxt->okey = key;
943 cxt->oldmap = map;
944 cxt->dmap = _rl_dispatching_keymap;
945 cxt->subseq_arg = got_subseq || cxt->dmap[ANYOTHERKEY].function;
946
947 RL_SETSTATE (RL_STATE_MULTIKEY);
948 _rl_kscxt = cxt;
949
950 return r; /* don't indicate immediate success */
951 }
952 #endif
953
954 /* Tentative inter-character timeout for potential multi-key
955 sequences? If no input within timeout, abort sequence and
956 act as if we got non-matching input. */
957 /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
958 takes microseconds, so multiply by 1000 */
959 if (_rl_keyseq_timeout > 0 &&
960 (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
961 _rl_pushed_input_available () == 0 &&
962 _rl_dispatching_keymap[ANYOTHERKEY].function &&
963 _rl_input_queued (_rl_keyseq_timeout*1000) == 0)
964 return (_rl_subseq_result (-2, map, key, got_subseq));
965
966 newkey = _rl_subseq_getchar (key);
967 if (newkey < 0)
968 {
969 _rl_abort_internal ();
970 return -1;
971 }
972
973 r = _rl_dispatch_subseq (newkey, _rl_dispatching_keymap, got_subseq || map[ANYOTHERKEY].function);
974 return _rl_subseq_result (r, map, key, got_subseq);
975 }
976 else
977 {
978 _rl_abort_internal (); /* XXX */
979 return -1;
980 }
981 break;
982
983 case ISMACR:
984 if (map[key].function != 0)
985 {
986 rl_executing_keyseq[rl_key_sequence_length] = '\0';
987 macro = savestring ((char *)map[key].function);
988 _rl_with_macro_input (macro);
989 return 0;
990 }
991 break;
992 }
993 #if defined (VI_MODE)
994 if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
995 key != ANYOTHERKEY &&
996 _rl_dispatching_keymap == vi_movement_keymap &&
997 _rl_vi_textmod_command (key))
998 _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
999 #endif
1000
1001 return (r);
1002 }
1003
1004 static int
1005 _rl_subseq_result (r, map, key, got_subseq)
1006 int r;
1007 Keymap map;
1008 int key, got_subseq;
1009 {
1010 Keymap m;
1011 int type, nt;
1012 rl_command_func_t *func, *nf;
1013
1014 if (r == -2)
1015 /* We didn't match anything, and the keymap we're indexed into
1016 shadowed a function previously bound to that prefix. Call
1017 the function. The recursive call to _rl_dispatch_subseq has
1018 already taken care of pushing any necessary input back onto
1019 the input queue with _rl_unget_char. */
1020 {
1021 m = _rl_dispatching_keymap;
1022 type = m[ANYOTHERKEY].type;
1023 func = m[ANYOTHERKEY].function;
1024 if (type == ISFUNC && func == rl_do_lowercase_version)
1025 r = _rl_dispatch (_rl_to_lower (key), map);
1026 else if (type == ISFUNC)
1027 {
1028 /* If we shadowed a function, whatever it is, we somehow need a
1029 keymap with map[key].func == shadowed-function.
1030 Let's use this one. Then we can dispatch using the original
1031 key, since there are commands (e.g., in vi mode) for which it
1032 matters. */
1033 nt = m[key].type;
1034 nf = m[key].function;
1035
1036 m[key].type = type;
1037 m[key].function = func;
1038 r = _rl_dispatch (key, m);
1039 m[key].type = nt;
1040 m[key].function = nf;
1041 }
1042 else
1043 /* We probably shadowed a keymap, so keep going. */
1044 r = _rl_dispatch (ANYOTHERKEY, m);
1045 }
1046 else if (r && map[ANYOTHERKEY].function)
1047 {
1048 /* We didn't match (r is probably -1), so return something to
1049 tell the caller that it should try ANYOTHERKEY for an
1050 overridden function. */
1051 if (RL_ISSTATE (RL_STATE_MACROINPUT))
1052 _rl_prev_macro_key ();
1053 else
1054 _rl_unget_char (key);
1055 _rl_dispatching_keymap = map;
1056 return -2;
1057 }
1058 else if (r && got_subseq)
1059 {
1060 /* OK, back up the chain. */
1061 if (RL_ISSTATE (RL_STATE_MACROINPUT))
1062 _rl_prev_macro_key ();
1063 else
1064 _rl_unget_char (key);
1065 _rl_dispatching_keymap = map;
1066 return -1;
1067 }
1068
1069 return r;
1070 }
1071
1072 /* **************************************************************** */
1073 /* */
1074 /* Initializations */
1075 /* */
1076 /* **************************************************************** */
1077
1078 /* Initialize readline (and terminal if not already). */
1079 int
1080 rl_initialize ()
1081 {
1082 /* If we have never been called before, initialize the
1083 terminal and data structures. */
1084 if (!rl_initialized)
1085 {
1086 RL_SETSTATE(RL_STATE_INITIALIZING);
1087 readline_initialize_everything ();
1088 RL_UNSETSTATE(RL_STATE_INITIALIZING);
1089 rl_initialized++;
1090 RL_SETSTATE(RL_STATE_INITIALIZED);
1091 }
1092
1093 /* Initialize the current line information. */
1094 _rl_init_line_state ();
1095
1096 /* We aren't done yet. We haven't even gotten started yet! */
1097 rl_done = 0;
1098 RL_UNSETSTATE(RL_STATE_DONE);
1099
1100 /* Tell the history routines what is going on. */
1101 _rl_start_using_history ();
1102
1103 /* Make the display buffer match the state of the line. */
1104 rl_reset_line_state ();
1105
1106 /* No such function typed yet. */
1107 rl_last_func = (rl_command_func_t *)NULL;
1108
1109 /* Parsing of key-bindings begins in an enabled state. */
1110 _rl_parsing_conditionalized_out = 0;
1111
1112 #if defined (VI_MODE)
1113 if (rl_editing_mode == vi_mode)
1114 _rl_vi_initialize_line ();
1115 #endif
1116
1117 /* Each line starts in insert mode (the default). */
1118 _rl_set_insert_mode (RL_IM_DEFAULT, 1);
1119
1120 return 0;
1121 }
1122
1123 #if 0
1124 #if defined (__EMX__)
1125 static void
1126 _emx_build_environ ()
1127 {
1128 TIB *tibp;
1129 PIB *pibp;
1130 char *t, **tp;
1131 int c;
1132
1133 DosGetInfoBlocks (&tibp, &pibp);
1134 t = pibp->pib_pchenv;
1135 for (c = 1; *t; c++)
1136 t += strlen (t) + 1;
1137 tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *));
1138 t = pibp->pib_pchenv;
1139 while (*t)
1140 {
1141 *tp++ = t;
1142 t += strlen (t) + 1;
1143 }
1144 *tp = 0;
1145 }
1146 #endif /* __EMX__ */
1147 #endif
1148
1149 /* Initialize the entire state of the world. */
1150 static void
1151 readline_initialize_everything ()
1152 {
1153 #if 0
1154 #if defined (__EMX__)
1155 if (environ == 0)
1156 _emx_build_environ ();
1157 #endif
1158 #endif
1159
1160 #if 0
1161 /* Find out if we are running in Emacs -- UNUSED. */
1162 running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
1163 #endif
1164
1165 /* Set up input and output if they are not already set up. */
1166 if (!rl_instream)
1167 rl_instream = stdin;
1168
1169 if (!rl_outstream)
1170 rl_outstream = stdout;
1171
1172 /* Bind _rl_in_stream and _rl_out_stream immediately. These values
1173 may change, but they may also be used before readline_internal ()
1174 is called. */
1175 _rl_in_stream = rl_instream;
1176 _rl_out_stream = rl_outstream;
1177
1178 /* Allocate data structures. */
1179 if (rl_line_buffer == 0)
1180 rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
1181
1182 /* Initialize the terminal interface. */
1183 if (rl_terminal_name == 0)
1184 rl_terminal_name = sh_get_env_value ("TERM");
1185 _rl_init_terminal_io (rl_terminal_name);
1186
1187 /* Bind tty characters to readline functions. */
1188 readline_default_bindings ();
1189
1190 /* Initialize the function names. */
1191 rl_initialize_funmap ();
1192
1193 /* Decide whether we should automatically go into eight-bit mode. */
1194 _rl_init_eightbit ();
1195
1196 /* Read in the init file. */
1197 rl_read_init_file ((char *)NULL);
1198
1199 /* XXX */
1200 if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
1201 {
1202 _rl_screenwidth--;
1203 _rl_screenchars -= _rl_screenheight;
1204 }
1205
1206 /* Override the effect of any `set keymap' assignments in the
1207 inputrc file. */
1208 rl_set_keymap_from_edit_mode ();
1209
1210 /* Try to bind a common arrow key prefix, if not already bound. */
1211 bind_arrow_keys ();
1212
1213 /* Bind the bracketed paste prefix assuming that the user will enable
1214 it on terminals that support it. */
1215 bind_bracketed_paste_prefix ();
1216
1217 /* If the completion parser's default word break characters haven't
1218 been set yet, then do so now. */
1219 if (rl_completer_word_break_characters == (char *)NULL)
1220 rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
1221
1222 #if defined (COLOR_SUPPORT)
1223 if (_rl_colored_stats || _rl_colored_completion_prefix)
1224 _rl_parse_colors ();
1225 #endif
1226
1227 rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
1228 if (rl_executing_keyseq)
1229 rl_executing_keyseq[0] = '\0';
1230 }
1231
1232 /* If this system allows us to look at the values of the regular
1233 input editing characters, then bind them to their readline
1234 equivalents, iff the characters are not bound to keymaps. */
1235 static void
1236 readline_default_bindings ()
1237 {
1238 if (_rl_bind_stty_chars)
1239 rl_tty_set_default_bindings (_rl_keymap);
1240 }
1241
1242 /* Reset the default bindings for the terminal special characters we're
1243 interested in back to rl_insert and read the new ones. */
1244 static void
1245 reset_default_bindings ()
1246 {
1247 if (_rl_bind_stty_chars)
1248 {
1249 rl_tty_unset_default_bindings (_rl_keymap);
1250 rl_tty_set_default_bindings (_rl_keymap);
1251 }
1252 }
1253
1254 /* Bind some common arrow key sequences in MAP. */
1255 static void
1256 bind_arrow_keys_internal (map)
1257 Keymap map;
1258 {
1259 Keymap xkeymap;
1260
1261 xkeymap = _rl_keymap;
1262 _rl_keymap = map;
1263
1264 #if defined (__MSDOS__)
1265 rl_bind_keyseq_if_unbound ("\033[0A", rl_get_previous_history);
1266 rl_bind_keyseq_if_unbound ("\033[0B", rl_backward_char);
1267 rl_bind_keyseq_if_unbound ("\033[0C", rl_forward_char);
1268 rl_bind_keyseq_if_unbound ("\033[0D", rl_get_next_history);
1269 #endif
1270
1271 rl_bind_keyseq_if_unbound ("\033[A", rl_get_previous_history);
1272 rl_bind_keyseq_if_unbound ("\033[B", rl_get_next_history);
1273 rl_bind_keyseq_if_unbound ("\033[C", rl_forward_char);
1274 rl_bind_keyseq_if_unbound ("\033[D", rl_backward_char);
1275 rl_bind_keyseq_if_unbound ("\033[H", rl_beg_of_line);
1276 rl_bind_keyseq_if_unbound ("\033[F", rl_end_of_line);
1277
1278 rl_bind_keyseq_if_unbound ("\033OA", rl_get_previous_history);
1279 rl_bind_keyseq_if_unbound ("\033OB", rl_get_next_history);
1280 rl_bind_keyseq_if_unbound ("\033OC", rl_forward_char);
1281 rl_bind_keyseq_if_unbound ("\033OD", rl_backward_char);
1282 rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);
1283 rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);
1284
1285 #if defined (__MINGW32__)
1286 rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
1287 rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
1288 rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
1289 rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
1290 rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line);
1291 rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line);
1292 rl_bind_keyseq_if_unbound ("\340S", rl_delete);
1293 rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode);
1294
1295 /* These may or may not work because of the embedded NUL. */
1296 rl_bind_keyseq_if_unbound ("\\000H", rl_get_previous_history);
1297 rl_bind_keyseq_if_unbound ("\\000P", rl_get_next_history);
1298 rl_bind_keyseq_if_unbound ("\\000M", rl_forward_char);
1299 rl_bind_keyseq_if_unbound ("\\000K", rl_backward_char);
1300 rl_bind_keyseq_if_unbound ("\\000G", rl_beg_of_line);
1301 rl_bind_keyseq_if_unbound ("\\000O", rl_end_of_line);
1302 rl_bind_keyseq_if_unbound ("\\000S", rl_delete);
1303 rl_bind_keyseq_if_unbound ("\\000R", rl_overwrite_mode);
1304 #endif
1305
1306 _rl_keymap = xkeymap;
1307 }
1308
1309 /* Try and bind the common arrow key prefixes after giving termcap and
1310 the inputrc file a chance to bind them and create `real' keymaps
1311 for the arrow key prefix. */
1312 static void
1313 bind_arrow_keys ()
1314 {
1315 bind_arrow_keys_internal (emacs_standard_keymap);
1316
1317 #if defined (VI_MODE)
1318 bind_arrow_keys_internal (vi_movement_keymap);
1319 /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
1320 in vi command mode while still allowing the arrow keys to work. */
1321 if (vi_movement_keymap[ESC].type == ISKMAP)
1322 rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
1323 bind_arrow_keys_internal (vi_insertion_keymap);
1324 #endif
1325 }
1326
1327 static void
1328 bind_bracketed_paste_prefix ()
1329 {
1330 Keymap xkeymap;
1331
1332 xkeymap = _rl_keymap;
1333
1334 _rl_keymap = emacs_standard_keymap;
1335 rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
1336
1337 _rl_keymap = vi_insertion_keymap;
1338 rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
1339
1340 _rl_keymap = xkeymap;
1341 }
1342
1343 /* **************************************************************** */
1344 /* */
1345 /* Saving and Restoring Readline's state */
1346 /* */
1347 /* **************************************************************** */
1348
1349 int
1350 rl_save_state (sp)
1351 struct readline_state *sp;
1352 {
1353 if (sp == 0)
1354 return -1;
1355
1356 sp->point = rl_point;
1357 sp->end = rl_end;
1358 sp->mark = rl_mark;
1359 sp->buffer = rl_line_buffer;
1360 sp->buflen = rl_line_buffer_len;
1361 sp->ul = rl_undo_list;
1362 sp->prompt = rl_prompt;
1363
1364 sp->rlstate = rl_readline_state;
1365 sp->done = rl_done;
1366 sp->kmap = _rl_keymap;
1367
1368 sp->lastfunc = rl_last_func;
1369 sp->insmode = rl_insert_mode;
1370 sp->edmode = rl_editing_mode;
1371 sp->kseq = rl_executing_keyseq;
1372 sp->kseqlen = rl_key_sequence_length;
1373 sp->inf = rl_instream;
1374 sp->outf = rl_outstream;
1375 sp->pendingin = rl_pending_input;
1376 sp->macro = rl_executing_macro;
1377
1378 sp->catchsigs = rl_catch_signals;
1379 sp->catchsigwinch = rl_catch_sigwinch;
1380
1381 sp->entryfunc = rl_completion_entry_function;
1382 sp->menuentryfunc = rl_menu_completion_entry_function;
1383 sp->ignorefunc = rl_ignore_some_completions_function;
1384 sp->attemptfunc = rl_attempted_completion_function;
1385 sp->wordbreakchars = rl_completer_word_break_characters;
1386
1387 return (0);
1388 }
1389
1390 int
1391 rl_restore_state (sp)
1392 struct readline_state *sp;
1393 {
1394 if (sp == 0)
1395 return -1;
1396
1397 rl_point = sp->point;
1398 rl_end = sp->end;
1399 rl_mark = sp->mark;
1400 the_line = rl_line_buffer = sp->buffer;
1401 rl_line_buffer_len = sp->buflen;
1402 rl_undo_list = sp->ul;
1403 rl_prompt = sp->prompt;
1404
1405 rl_readline_state = sp->rlstate;
1406 rl_done = sp->done;
1407 _rl_keymap = sp->kmap;
1408
1409 rl_last_func = sp->lastfunc;
1410 rl_insert_mode = sp->insmode;
1411 rl_editing_mode = sp->edmode;
1412 rl_executing_keyseq = sp->kseq;
1413 rl_key_sequence_length = sp->kseqlen;
1414 rl_instream = sp->inf;
1415 rl_outstream = sp->outf;
1416 rl_pending_input = sp->pendingin;
1417 rl_executing_macro = sp->macro;
1418
1419 rl_catch_signals = sp->catchsigs;
1420 rl_catch_sigwinch = sp->catchsigwinch;
1421
1422 rl_completion_entry_function = sp->entryfunc;
1423 rl_menu_completion_entry_function = sp->menuentryfunc;
1424 rl_ignore_some_completions_function = sp->ignorefunc;
1425 rl_attempted_completion_function = sp->attemptfunc;
1426 rl_completer_word_break_characters = sp->wordbreakchars;
1427
1428 return (0);
1429 }
This page took 0.085982 seconds and 5 git commands to generate.