Deleted Added
full compact
callback.c (157184) callback.c (165670)
1/* callback.c -- functions to use readline as an X `callback' mechanism. */
2
3/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it

--- 29 unchanged lines hidden (view full) ---

38#endif
39
40#include <stdio.h>
41
42/* System-specific feature definitions and include files. */
43#include "rldefs.h"
44#include "readline.h"
45#include "rlprivate.h"
1/* callback.c -- functions to use readline as an X `callback' mechanism. */
2
3/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it

--- 29 unchanged lines hidden (view full) ---

38#endif
39
40#include <stdio.h>
41
42/* System-specific feature definitions and include files. */
43#include "rldefs.h"
44#include "readline.h"
45#include "rlprivate.h"
46#include "xmalloc.h"
46
47/* Private data for callback registration functions. See comments in
48 rl_callback_read_char for more details. */
49_rl_callback_func_t *_rl_callback_func = 0;
50_rl_callback_generic_arg *_rl_callback_data = 0;
51
52/* **************************************************************** */
53/* */

--- 65 unchanged lines hidden (view full) ---

119 if (jcode)
120 {
121 (*rl_redisplay_function) ();
122 _rl_want_redisplay = 0;
123 memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
124 return;
125 }
126
47
48/* Private data for callback registration functions. See comments in
49 rl_callback_read_char for more details. */
50_rl_callback_func_t *_rl_callback_func = 0;
51_rl_callback_generic_arg *_rl_callback_data = 0;
52
53/* **************************************************************** */
54/* */

--- 65 unchanged lines hidden (view full) ---

120 if (jcode)
121 {
122 (*rl_redisplay_function) ();
123 _rl_want_redisplay = 0;
124 memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
125 return;
126 }
127
127 if (RL_ISSTATE (RL_STATE_ISEARCH))
128 do
128 {
129 {
129 eof = _rl_isearch_callback (_rl_iscxt);
130 if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
131 rl_callback_read_char ();
130 if (RL_ISSTATE (RL_STATE_ISEARCH))
131 {
132 eof = _rl_isearch_callback (_rl_iscxt);
133 if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
134 rl_callback_read_char ();
132
135
133 return;
134 }
135 else if (RL_ISSTATE (RL_STATE_NSEARCH))
136 {
137 eof = _rl_nsearch_callback (_rl_nscxt);
138 return;
139 }
140 else if (RL_ISSTATE (RL_STATE_NUMERICARG))
141 {
142 eof = _rl_arg_callback (_rl_argcxt);
143 if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
144 rl_callback_read_char ();
145 /* XXX - this should handle _rl_last_command_was_kill better */
146 else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
147 _rl_internal_char_cleanup ();
136 return;
137 }
138 else if (RL_ISSTATE (RL_STATE_NSEARCH))
139 {
140 eof = _rl_nsearch_callback (_rl_nscxt);
141 return;
142 }
143 else if (RL_ISSTATE (RL_STATE_NUMERICARG))
144 {
145 eof = _rl_arg_callback (_rl_argcxt);
146 if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
147 rl_callback_read_char ();
148 /* XXX - this should handle _rl_last_command_was_kill better */
149 else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
150 _rl_internal_char_cleanup ();
148
151
149 return;
150 }
151 else if (RL_ISSTATE (RL_STATE_MULTIKEY))
152 {
153 eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
154 while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
155 eof = _rl_dispatch_callback (_rl_kscxt);
156 if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
152 return;
153 }
154 else if (RL_ISSTATE (RL_STATE_MULTIKEY))
157 {
155 {
158 _rl_internal_char_cleanup ();
159 _rl_want_redisplay = 1;
156 eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
157 while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
158 eof = _rl_dispatch_callback (_rl_kscxt);
159 if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
160 {
161 _rl_internal_char_cleanup ();
162 _rl_want_redisplay = 1;
163 }
160 }
164 }
161 }
162 else if (_rl_callback_func)
163 {
164 /* This allows functions that simply need to read an additional character
165 (like quoted-insert) to register a function to be called when input is
166 available. _rl_callback_data is simply a pointer to a struct that has
167 the argument count originally passed to the registering function and
168 space for any additional parameters. */
169 eof = (*_rl_callback_func) (_rl_callback_data);
170 /* If the function `deregisters' itself, make sure the data is cleaned
171 up. */
172 if (_rl_callback_func == 0)
165 else if (_rl_callback_func)
173 {
166 {
174 if (_rl_callback_data)
167 /* This allows functions that simply need to read an additional
168 character (like quoted-insert) to register a function to be
169 called when input is available. _rl_callback_data is simply a
170 pointer to a struct that has the argument count originally
171 passed to the registering function and space for any additional
172 parameters. */
173 eof = (*_rl_callback_func) (_rl_callback_data);
174 /* If the function `deregisters' itself, make sure the data is
175 cleaned up. */
176 if (_rl_callback_func == 0)
175 {
177 {
176 _rl_callback_data_dispose (_rl_callback_data);
177 _rl_callback_data = 0;
178 if (_rl_callback_data)
179 {
180 _rl_callback_data_dispose (_rl_callback_data);
181 _rl_callback_data = 0;
182 }
183 _rl_internal_char_cleanup ();
178 }
184 }
179 _rl_internal_char_cleanup ();
180 }
185 }
181 }
182 else
183 eof = readline_internal_char ();
186 else
187 eof = readline_internal_char ();
184
188
185 if (rl_done == 0 && _rl_want_redisplay)
186 {
187 (*rl_redisplay_function) ();
188 _rl_want_redisplay = 0;
189 }
189 if (rl_done == 0 && _rl_want_redisplay)
190 {
191 (*rl_redisplay_function) ();
192 _rl_want_redisplay = 0;
193 }
190
194
191 /* We loop in case some function has pushed input back with rl_execute_next. */
192 for (;;)
193 {
194 if (rl_done)
195 {
196 line = readline_internal_teardown (eof);
197
198 if (rl_deprep_term_function)
199 (*rl_deprep_term_function) ();
200#if defined (HANDLE_SIGNALS)
201 rl_clear_signals ();

--- 5 unchanged lines hidden (view full) ---

207 if (rl_line_buffer[0])
208 _rl_init_line_state ();
209
210 /* Redisplay the prompt if readline_handler_{install,remove}
211 not called. */
212 if (in_handler == 0 && rl_linefunc)
213 _rl_callback_newline ();
214 }
195 if (rl_done)
196 {
197 line = readline_internal_teardown (eof);
198
199 if (rl_deprep_term_function)
200 (*rl_deprep_term_function) ();
201#if defined (HANDLE_SIGNALS)
202 rl_clear_signals ();

--- 5 unchanged lines hidden (view full) ---

208 if (rl_line_buffer[0])
209 _rl_init_line_state ();
210
211 /* Redisplay the prompt if readline_handler_{install,remove}
212 not called. */
213 if (in_handler == 0 && rl_linefunc)
214 _rl_callback_newline ();
215 }
215 if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
216 eof = readline_internal_char ();
217 else
218 break;
219 }
216 }
217 while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
220}
221
222/* Remove the handler, and make sure the terminal is in its normal state. */
223void
224rl_callback_handler_remove ()
225{
226 rl_linefunc = NULL;
227 RL_UNSETSTATE (RL_STATE_CALLBACK);

--- 33 unchanged lines hidden ---
218}
219
220/* Remove the handler, and make sure the terminal is in its normal state. */
221void
222rl_callback_handler_remove ()
223{
224 rl_linefunc = NULL;
225 RL_UNSETSTATE (RL_STATE_CALLBACK);

--- 33 unchanged lines hidden ---