1 /* readline.c -- a general facility for reading lines of input
2 with emacs style editing and completion. */
4 /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
9 The GNU Readline Library is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2, or
12 (at your option) any later version.
14 The GNU Readline Library is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 The GNU General Public License is often shipped with GNU software, and
20 is generally kept in a file called COPYING or LICENSE. If you do not
21 have a copy of the license, write to the Free Software Foundation,
22 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23 #define READLINE_LIBRARY
25 #if defined (HAVE_CONFIG_H)
29 #include <sys/types.h>
30 #include "posixstat.h"
32 #if defined (HAVE_SYS_FILE_H)
33 # include <sys/file.h>
34 #endif /* HAVE_SYS_FILE_H */
36 #if defined (HAVE_UNISTD_H)
38 #endif /* HAVE_UNISTD_H */
40 #if defined (HAVE_STDLIB_H)
43 # include "ansi_stdlib.h"
44 #endif /* HAVE_STDLIB_H */
46 #if defined (HAVE_LOCALE_H)
53 /* System-specific feature definitions and include files. */
58 # define INCL_DOSPROCESS
62 /* Some standard library routines. */
66 #include "rlprivate.h"
70 #ifndef RL_LIBRARY_VERSION
71 # define RL_LIBRARY_VERSION "4.3"
74 #ifndef RL_READLINE_VERSION
75 # define RL_READLINE_VERSION 0x0403
78 extern void _rl_free_history_entry
PARAMS((HIST_ENTRY
*));
80 /* Forward declarations used in this file. */
81 static char *readline_internal
PARAMS((void));
82 static void readline_initialize_everything
PARAMS((void));
84 static void bind_arrow_keys_internal
PARAMS((Keymap
));
85 static void bind_arrow_keys
PARAMS((void));
87 static void readline_default_bindings
PARAMS((void));
89 /* **************************************************************** */
91 /* Line editing input utility */
93 /* **************************************************************** */
95 const char *rl_library_version
= RL_LIBRARY_VERSION
;
97 int rl_readline_version
= RL_READLINE_VERSION
;
99 /* True if this is `real' readline as opposed to some stub substitute. */
100 int rl_gnu_readline_p
= 1;
102 /* A pointer to the keymap that is currently in use.
103 By default, it is the standard emacs keymap. */
104 Keymap _rl_keymap
= emacs_standard_keymap
;
106 /* The current style of editing. */
107 int rl_editing_mode
= emacs_mode
;
109 /* The current insert mode: input (the default) or overwrite */
110 int rl_insert_mode
= RL_IM_DEFAULT
;
112 /* Non-zero if we called this function from _rl_dispatch(). It's present
113 so functions can find out whether they were called from a key binding
114 or directly from an application. */
117 /* Non-zero if the previous command was a kill command. */
118 int _rl_last_command_was_kill
= 0;
120 /* The current value of the numeric argument specified by the user. */
121 int rl_numeric_arg
= 1;
123 /* Non-zero if an argument was typed. */
124 int rl_explicit_arg
= 0;
126 /* Temporary value used while generating the argument. */
129 /* Non-zero means we have been called at least once before. */
130 static int rl_initialized
;
133 /* If non-zero, this program is running in an EMACS buffer. */
134 static int running_in_emacs
;
137 /* Flags word encapsulating the current readline state. */
138 int rl_readline_state
= RL_STATE_NONE
;
140 /* The current offset in the current input line. */
143 /* Mark in the current input line. */
146 /* Length of the current input line. */
149 /* Make this non-zero to return the current input_line. */
152 /* The last function executed by readline. */
153 rl_command_func_t
*rl_last_func
= (rl_command_func_t
*)NULL
;
155 /* Top level environment for readline_internal (). */
156 procenv_t readline_top_level
;
158 /* The streams we interact with. */
159 FILE *_rl_in_stream
, *_rl_out_stream
;
161 /* The names of the streams that we do input and output to. */
162 FILE *rl_instream
= (FILE *)NULL
;
163 FILE *rl_outstream
= (FILE *)NULL
;
165 /* Non-zero means echo characters as they are read. Defaults to no echo;
166 set to 1 if there is a controlling terminal, we can get its attributes,
167 and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
168 for the code that sets it. */
169 int readline_echoing_p
= 0;
171 /* Current prompt. */
172 char *rl_prompt
= (char *)NULL
;
173 int rl_visible_prompt_length
= 0;
175 /* Set to non-zero by calling application if it has already printed rl_prompt
176 and does not want readline to do it the first time. */
177 int rl_already_prompted
= 0;
179 /* The number of characters read in order to type this complete command. */
180 int rl_key_sequence_length
= 0;
182 /* If non-zero, then this is the address of a function to call just
183 before readline_internal_setup () prints the first prompt. */
184 rl_hook_func_t
*rl_startup_hook
= (rl_hook_func_t
*)NULL
;
186 /* If non-zero, this is the address of a function to call just before
187 readline_internal_setup () returns and readline_internal starts
188 reading input characters. */
189 rl_hook_func_t
*rl_pre_input_hook
= (rl_hook_func_t
*)NULL
;
191 /* What we use internally. You should always refer to RL_LINE_BUFFER. */
192 static char *the_line
;
194 /* The character that can generate an EOF. Really read from
195 the terminal driver... just defaulted here. */
196 int _rl_eof_char
= CTRL ('D');
198 /* Non-zero makes this the next keystroke to read. */
199 int rl_pending_input
= 0;
201 /* Pointer to a useful terminal name. */
202 const char *rl_terminal_name
= (const char *)NULL
;
204 /* Non-zero means to always use horizontal scrolling in line display. */
205 int _rl_horizontal_scroll_mode
= 0;
207 /* Non-zero means to display an asterisk at the starts of history lines
208 which have been modified. */
209 int _rl_mark_modified_lines
= 0;
211 /* The style of `bell' notification preferred. This can be set to NO_BELL,
212 AUDIBLE_BELL, or VISIBLE_BELL. */
213 int _rl_bell_preference
= AUDIBLE_BELL
;
215 /* String inserted into the line by rl_insert_comment (). */
216 char *_rl_comment_begin
;
218 /* Keymap holding the function currently being executed. */
219 Keymap rl_executing_keymap
;
221 /* Non-zero means to erase entire line, including prompt, on empty input lines. */
222 int rl_erase_empty_line
= 0;
224 /* Non-zero means to read only this many characters rather than up to a
225 character bound to accept-line. */
226 int rl_num_chars_to_read
;
228 /* Line buffer and maintenence. */
229 char *rl_line_buffer
= (char *)NULL
;
230 int rl_line_buffer_len
= 0;
232 /* Forward declarations used by the display, termcap, and history code. */
234 /* **************************************************************** */
236 /* `Forward' declarations */
238 /* **************************************************************** */
240 /* Non-zero means do not parse any lines other than comments and
241 parser directives. */
242 unsigned char _rl_parsing_conditionalized_out
= 0;
244 /* Non-zero means to convert characters with the meta bit set to
245 escape-prefixed characters so we can indirect through
246 emacs_meta_keymap or vi_escape_keymap. */
247 int _rl_convert_meta_chars_to_ascii
= 1;
249 /* Non-zero means to output characters with the meta bit set directly
250 rather than as a meta-prefixed escape sequence. */
251 int _rl_output_meta_chars
= 0;
253 /* **************************************************************** */
255 /* Top Level Functions */
257 /* **************************************************************** */
259 /* Non-zero means treat 0200 bit in terminal input as Meta bit. */
260 int _rl_meta_flag
= 0; /* Forward declaration */
262 /* Set up the prompt and expand it. Called from readline() and
263 rl_callback_handler_install (). */
265 rl_set_prompt (prompt
)
269 rl_prompt
= prompt
? savestring (prompt
) : (char *)NULL
;
271 rl_visible_prompt_length
= rl_expand_prompt (rl_prompt
);
275 /* Read a line of input. Prompt with PROMPT. An empty PROMPT means
276 none. A return value of NULL means that EOF was encountered. */
283 /* If we are at EOF return a NULL string. */
284 if (rl_pending_input
== EOF
)
286 rl_clear_pending_input ();
287 return ((char *)NULL
);
290 rl_set_prompt (prompt
);
293 (*rl_prep_term_function
) (_rl_meta_flag
);
295 #if defined (HANDLE_SIGNALS)
299 value
= readline_internal ();
300 (*rl_deprep_term_function
) ();
302 #if defined (HANDLE_SIGNALS)
309 #if defined (READLINE_CALLBACKS)
310 # define STATIC_CALLBACK
312 # define STATIC_CALLBACK static
316 readline_internal_setup ()
320 _rl_in_stream
= rl_instream
;
321 _rl_out_stream
= rl_outstream
;
324 (*rl_startup_hook
) ();
326 /* If we're not echoing, we still want to at least print a prompt, because
327 rl_redisplay will not do it for us. If the calling application has a
328 custom redisplay function, though, let that function handle it. */
329 if (readline_echoing_p
== 0 && rl_redisplay_function
== rl_redisplay
)
331 if (rl_prompt
&& rl_already_prompted
== 0)
333 nprompt
= _rl_strip_prompt (rl_prompt
);
334 fprintf (_rl_out_stream
, "%s", nprompt
);
335 fflush (_rl_out_stream
);
341 if (rl_prompt
&& rl_already_prompted
)
342 rl_on_new_line_with_prompt ();
345 (*rl_redisplay_function
) ();
348 #if defined (VI_MODE)
349 if (rl_editing_mode
== vi_mode
)
350 rl_vi_insertion_mode (1, 0);
353 if (rl_pre_input_hook
)
354 (*rl_pre_input_hook
) ();
357 STATIC_CALLBACK
char *
358 readline_internal_teardown (eof
)
364 /* Restore the original of this history line, iff the line that we
365 are editing was originally in the history, AND the line has changed. */
366 entry
= current_history ();
368 if (entry
&& rl_undo_list
)
370 temp
= savestring (the_line
);
371 rl_revert_line (1, 0);
372 entry
= replace_history_entry (where_history (), the_line
, (histdata_t
)NULL
);
373 _rl_free_history_entry (entry
);
375 strcpy (the_line
, temp
);
379 /* At any rate, it is highly likely that this line has an undo list. Get
382 rl_free_undo_list ();
384 /* Restore normal cursor, if available. */
385 _rl_set_insert_mode (RL_IM_INSERT
, 0);
387 return (eof
? (char *)NULL
: savestring (the_line
));
391 #if defined (READLINE_CALLBACKS)
392 readline_internal_char ()
394 readline_internal_charloop ()
397 static int lastc
, eof_found
;
403 #if !defined (READLINE_CALLBACKS)
407 lk
= _rl_last_command_was_kill
;
409 code
= setjmp (readline_top_level
);
412 (*rl_redisplay_function
) ();
414 if (rl_pending_input
== 0)
416 /* Then initialize the argument and number of keys read. */
417 _rl_init_argument ();
418 rl_key_sequence_length
= 0;
421 RL_SETSTATE(RL_STATE_READCMD
);
423 RL_UNSETSTATE(RL_STATE_READCMD
);
425 /* EOF typed to a non-blank line is a <NL>. */
426 if (c
== EOF
&& rl_end
)
429 /* The character _rl_eof_char typed to blank line, and not as the
430 previous character is interpreted as EOF. */
431 if (((c
== _rl_eof_char
&& lastc
!= c
) || c
== EOF
) && !rl_end
)
433 #if defined (READLINE_CALLBACKS)
434 RL_SETSTATE(RL_STATE_DONE
);
435 return (rl_done
= 1);
443 _rl_dispatch ((unsigned char)c
, _rl_keymap
);
445 /* If there was no change in _rl_last_command_was_kill, then no kill
446 has taken place. Note that if input is pending we are reading
447 a prefix command, so nothing has changed yet. */
448 if (rl_pending_input
== 0 && lk
== _rl_last_command_was_kill
)
449 _rl_last_command_was_kill
= 0;
451 #if defined (VI_MODE)
452 /* In vi mode, when you exit insert mode, the cursor moves back
453 over the previous character. We explicitly check for that here. */
454 if (rl_editing_mode
== vi_mode
&& _rl_keymap
== vi_movement_keymap
)
458 if (rl_num_chars_to_read
&& rl_end
>= rl_num_chars_to_read
)
460 (*rl_redisplay_function
) ();
461 rl_newline (1, '\n');
465 (*rl_redisplay_function
) ();
467 /* If the application writer has told us to erase the entire line if
468 the only character typed was something bound to rl_newline, do so. */
469 if (rl_erase_empty_line
&& rl_done
&& rl_last_func
== rl_newline
&&
470 rl_point
== 0 && rl_end
== 0)
471 _rl_erase_entire_line ();
473 #if defined (READLINE_CALLBACKS)
482 #if defined (READLINE_CALLBACKS)
484 readline_internal_charloop ()
489 eof
= readline_internal_char ();
492 #endif /* READLINE_CALLBACKS */
494 /* Read a line of input from the global rl_instream, doing output on
495 the global rl_outstream.
496 If rl_prompt is non-null, then that is our prompt. */
502 readline_internal_setup ();
503 eof
= readline_internal_charloop ();
504 return (readline_internal_teardown (eof
));
508 _rl_init_line_state ()
510 rl_point
= rl_end
= rl_mark
= 0;
511 the_line
= rl_line_buffer
;
518 the_line
= rl_line_buffer
;
521 /* Do the command associated with KEY in MAP.
522 If the associated command is really a keymap, then read
523 another key, and dispatch into that map. */
525 _rl_dispatch (key
, map
)
529 return _rl_dispatch_subseq (key
, map
, 0);
533 _rl_dispatch_subseq (key
, map
, got_subseq
)
540 rl_command_func_t
*func
;
542 if (META_CHAR (key
) && _rl_convert_meta_chars_to_ascii
)
544 if (map
[ESC
].type
== ISKMAP
)
546 if (RL_ISSTATE (RL_STATE_MACRODEF
))
547 _rl_add_macro_char (ESC
);
548 map
= FUNCTION_TO_KEYMAP (map
, ESC
);
550 rl_key_sequence_length
+= 2;
551 return (_rl_dispatch (key
, map
));
558 if (RL_ISSTATE (RL_STATE_MACRODEF
))
559 _rl_add_macro_char (key
);
562 switch (map
[key
].type
)
565 func
= map
[key
].function
;
568 /* Special case rl_do_lowercase_version (). */
569 if (func
== rl_do_lowercase_version
)
570 return (_rl_dispatch (_rl_to_lower (key
), map
));
572 rl_executing_keymap
= map
;
575 _rl_suppress_redisplay
= (map
[key
].function
== rl_insert
) && _rl_input_available ();
579 RL_SETSTATE(RL_STATE_DISPATCHING
);
580 r
= (*map
[key
].function
)(rl_numeric_arg
* rl_arg_sign
, key
);
581 RL_UNSETSTATE(RL_STATE_DISPATCHING
);
584 /* If we have input pending, then the last command was a prefix
585 command. Don't change the state of rl_last_func. Otherwise,
586 remember the last command executed in this variable. */
587 if (rl_pending_input
== 0 && map
[key
].function
!= rl_digit_argument
)
588 rl_last_func
= map
[key
].function
;
590 else if (map
[ANYOTHERKEY
].function
)
592 /* OK, there's no function bound in this map, but there is a
593 shadow function that was overridden when the current keymap
594 was created. Return -2 to note that. */
595 _rl_unget_char (key
);
600 /* Return -1 to note that we're in a subsequence, but we don't
601 have a matching key, nor was one overridden. This means
602 we need to back up the recursion chain and find the last
603 subsequence that is bound to a function. */
604 _rl_unget_char (key
);
609 _rl_abort_internal ();
615 if (map
[key
].function
!= 0)
617 #if defined (VI_MODE)
618 /* The only way this test will be true is if a subsequence has been
619 bound starting with ESC, generally the arrow keys. What we do is
620 check whether there's input in the queue, which there generally
621 will be if an arrow key has been pressed, and, if there's not,
622 just dispatch to (what we assume is) rl_vi_movement_mode right
623 away. This is essentially an input test with a zero timeout. */
624 if (rl_editing_mode
== vi_mode
&& key
== ESC
&& map
== vi_insertion_keymap
625 && _rl_input_queued (0) == 0)
626 return (_rl_dispatch (ANYOTHERKEY
, FUNCTION_TO_KEYMAP (map
, key
)));
629 rl_key_sequence_length
++;
632 RL_SETSTATE(RL_STATE_METANEXT
);
633 RL_SETSTATE(RL_STATE_MOREINPUT
);
634 newkey
= rl_read_key ();
635 RL_UNSETSTATE(RL_STATE_MOREINPUT
);
637 RL_UNSETSTATE(RL_STATE_METANEXT
);
641 _rl_abort_internal ();
645 r
= _rl_dispatch_subseq (newkey
, FUNCTION_TO_KEYMAP (map
, key
), got_subseq
|| map
[ANYOTHERKEY
].function
);
648 /* We didn't match anything, and the keymap we're indexed into
649 shadowed a function previously bound to that prefix. Call
650 the function. The recursive call to _rl_dispatch_subseq has
651 already taken care of pushing any necessary input back onto
652 the input queue with _rl_unget_char. */
653 r
= _rl_dispatch (ANYOTHERKEY
, FUNCTION_TO_KEYMAP (map
, key
));
654 else if (r
&& map
[ANYOTHERKEY
].function
)
656 /* We didn't match (r is probably -1), so return something to
657 tell the caller that it should try ANYOTHERKEY for an
658 overridden function. */
659 _rl_unget_char (key
);
662 else if (r
&& got_subseq
)
664 /* OK, back up the chain. */
665 _rl_unget_char (key
);
671 _rl_abort_internal ();
677 if (map
[key
].function
!= 0)
679 macro
= savestring ((char *)map
[key
].function
);
680 _rl_with_macro_input (macro
);
685 #if defined (VI_MODE)
686 if (rl_editing_mode
== vi_mode
&& _rl_keymap
== vi_movement_keymap
&&
687 key
!= ANYOTHERKEY
&&
688 _rl_vi_textmod_command (key
))
689 _rl_vi_set_last (key
, rl_numeric_arg
, rl_arg_sign
);
694 /* **************************************************************** */
696 /* Initializations */
698 /* **************************************************************** */
700 /* Initialize readline (and terminal if not already). */
704 /* If we have never been called before, initialize the
705 terminal and data structures. */
708 RL_SETSTATE(RL_STATE_INITIALIZING
);
709 readline_initialize_everything ();
710 RL_UNSETSTATE(RL_STATE_INITIALIZING
);
712 RL_SETSTATE(RL_STATE_INITIALIZED
);
715 /* Initalize the current line information. */
716 _rl_init_line_state ();
718 /* We aren't done yet. We haven't even gotten started yet! */
720 RL_UNSETSTATE(RL_STATE_DONE
);
722 /* Tell the history routines what is going on. */
723 _rl_start_using_history ();
725 /* Make the display buffer match the state of the line. */
726 rl_reset_line_state ();
728 /* No such function typed yet. */
729 rl_last_func
= (rl_command_func_t
*)NULL
;
731 /* Parsing of key-bindings begins in an enabled state. */
732 _rl_parsing_conditionalized_out
= 0;
734 #if defined (VI_MODE)
735 if (rl_editing_mode
== vi_mode
)
736 _rl_vi_initialize_line ();
739 /* Each line starts in insert mode (the default). */
740 _rl_set_insert_mode (RL_IM_DEFAULT
, 1);
746 #if defined (__EMX__)
748 _emx_build_environ ()
755 DosGetInfoBlocks (&tibp
, &pibp
);
756 t
= pibp
->pib_pchenv
;
759 tp
= environ
= (char **)xmalloc ((c
+ 1) * sizeof (char *));
760 t
= pibp
->pib_pchenv
;
771 /* Initialize the entire state of the world. */
773 readline_initialize_everything ()
776 #if defined (__EMX__)
778 _emx_build_environ ();
783 /* Find out if we are running in Emacs -- UNUSED. */
784 running_in_emacs
= sh_get_env_value ("EMACS") != (char *)0;
787 /* Set up input and output if they are not already set up. */
792 rl_outstream
= stdout
;
794 /* Bind _rl_in_stream and _rl_out_stream immediately. These values
795 may change, but they may also be used before readline_internal ()
797 _rl_in_stream
= rl_instream
;
798 _rl_out_stream
= rl_outstream
;
800 /* Allocate data structures. */
801 if (rl_line_buffer
== 0)
802 rl_line_buffer
= (char *)xmalloc (rl_line_buffer_len
= DEFAULT_BUFFER_SIZE
);
804 /* Initialize the terminal interface. */
805 if (rl_terminal_name
== 0)
806 rl_terminal_name
= sh_get_env_value ("TERM");
807 _rl_init_terminal_io (rl_terminal_name
);
809 /* Bind tty characters to readline functions. */
810 readline_default_bindings ();
812 /* Initialize the function names. */
813 rl_initialize_funmap ();
815 /* Decide whether we should automatically go into eight-bit mode. */
816 _rl_init_eightbit ();
818 /* Read in the init file. */
819 rl_read_init_file ((char *)NULL
);
822 if (_rl_horizontal_scroll_mode
&& _rl_term_autowrap
)
825 _rl_screenchars
-= _rl_screenheight
;
828 /* Override the effect of any `set keymap' assignments in the
830 rl_set_keymap_from_edit_mode ();
832 /* Try to bind a common arrow key prefix, if not already bound. */
835 /* Enable the meta key, if this terminal has one. */
837 _rl_enable_meta_key ();
839 /* If the completion parser's default word break characters haven't
840 been set yet, then do so now. */
841 if (rl_completer_word_break_characters
== (char *)NULL
)
842 rl_completer_word_break_characters
= rl_basic_word_break_characters
;
845 /* If this system allows us to look at the values of the regular
846 input editing characters, then bind them to their readline
847 equivalents, iff the characters are not bound to keymaps. */
849 readline_default_bindings ()
851 rl_tty_set_default_bindings (_rl_keymap
);
854 /* Bind some common arrow key sequences in MAP. */
856 bind_arrow_keys_internal (map
)
861 xkeymap
= _rl_keymap
;
864 #if defined (__MSDOS__)
865 _rl_bind_if_unbound ("\033[0A", rl_get_previous_history
);
866 _rl_bind_if_unbound ("\033[0B", rl_backward_char
);
867 _rl_bind_if_unbound ("\033[0C", rl_forward_char
);
868 _rl_bind_if_unbound ("\033[0D", rl_get_next_history
);
871 _rl_bind_if_unbound ("\033[A", rl_get_previous_history
);
872 _rl_bind_if_unbound ("\033[B", rl_get_next_history
);
873 _rl_bind_if_unbound ("\033[C", rl_forward_char
);
874 _rl_bind_if_unbound ("\033[D", rl_backward_char
);
875 _rl_bind_if_unbound ("\033[H", rl_beg_of_line
);
876 _rl_bind_if_unbound ("\033[F", rl_end_of_line
);
878 _rl_bind_if_unbound ("\033OA", rl_get_previous_history
);
879 _rl_bind_if_unbound ("\033OB", rl_get_next_history
);
880 _rl_bind_if_unbound ("\033OC", rl_forward_char
);
881 _rl_bind_if_unbound ("\033OD", rl_backward_char
);
882 _rl_bind_if_unbound ("\033OH", rl_beg_of_line
);
883 _rl_bind_if_unbound ("\033OF", rl_end_of_line
);
885 _rl_keymap
= xkeymap
;
888 /* Try and bind the common arrow key prefixes after giving termcap and
889 the inputrc file a chance to bind them and create `real' keymaps
890 for the arrow key prefix. */
894 bind_arrow_keys_internal (emacs_standard_keymap
);
896 #if defined (VI_MODE)
897 bind_arrow_keys_internal (vi_movement_keymap
);
898 bind_arrow_keys_internal (vi_insertion_keymap
);
902 /* **************************************************************** */
904 /* Saving and Restoring Readline's state */
906 /* **************************************************************** */
910 struct readline_state
*sp
;
915 sp
->point
= rl_point
;
918 sp
->buffer
= rl_line_buffer
;
919 sp
->buflen
= rl_line_buffer_len
;
920 sp
->ul
= rl_undo_list
;
921 sp
->prompt
= rl_prompt
;
923 sp
->rlstate
= rl_readline_state
;
925 sp
->kmap
= _rl_keymap
;
927 sp
->lastfunc
= rl_last_func
;
928 sp
->insmode
= rl_insert_mode
;
929 sp
->edmode
= rl_editing_mode
;
930 sp
->kseqlen
= rl_key_sequence_length
;
931 sp
->inf
= rl_instream
;
932 sp
->outf
= rl_outstream
;
933 sp
->pendingin
= rl_pending_input
;
934 sp
->macro
= rl_executing_macro
;
936 sp
->catchsigs
= rl_catch_signals
;
937 #if defined (SIGWINCH)
938 sp
->catchsigwinch
= rl_catch_sigwinch
;
945 rl_restore_state (sp
)
946 struct readline_state
*sp
;
951 rl_point
= sp
->point
;
954 the_line
= rl_line_buffer
= sp
->buffer
;
955 rl_line_buffer_len
= sp
->buflen
;
956 rl_undo_list
= sp
->ul
;
957 rl_prompt
= sp
->prompt
;
959 rl_readline_state
= sp
->rlstate
;
961 _rl_keymap
= sp
->kmap
;
963 rl_last_func
= sp
->lastfunc
;
964 rl_insert_mode
= sp
->insmode
;
965 rl_editing_mode
= sp
->edmode
;
966 rl_key_sequence_length
= sp
->kseqlen
;
967 rl_instream
= sp
->inf
;
968 rl_outstream
= sp
->outf
;
969 rl_pending_input
= sp
->pendingin
;
970 rl_executing_macro
= sp
->macro
;
972 rl_catch_signals
= sp
->catchsigs
;
973 #if defined (SIGWINCH)
974 rl_catch_sigwinch
= sp
->catchsigwinch
;