3519
|
1 /* |
|
2 |
|
3 Copyright (C) 2000 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #if defined (USE_READLINE) |
|
28 |
|
29 #include <stdio.h> |
|
30 #include <stdlib.h> |
|
31 |
|
32 #include <readline/readline.h> |
|
33 |
|
34 #include "oct-rl-edit.h" |
|
35 |
3520
|
36 /* It would be nice if readline.h declared these, I think. */ |
3519
|
37 |
|
38 extern int rl_blink_matching_paren; |
|
39 |
|
40 extern int screenheight; |
|
41 |
|
42 extern int screenwidth; |
|
43 |
|
44 int |
|
45 octave_rl_screen_height (void) |
|
46 { |
|
47 return screenheight; |
|
48 } |
|
49 |
|
50 int |
|
51 octave_rl_screen_width (void) |
|
52 { |
|
53 return screenwidth; |
|
54 } |
|
55 |
|
56 void |
|
57 octave_set_rl_blink_matching_paren_flag (int val) |
|
58 { |
|
59 rl_blink_matching_paren = val; |
|
60 } |
|
61 |
|
62 int |
|
63 octave_get_rl_blink_matching_paren_flag (void) |
|
64 { |
|
65 return rl_blink_matching_paren; |
|
66 } |
|
67 |
|
68 void |
|
69 octave_rl_clear_screen (void) |
|
70 { |
|
71 rl_clear_screen (); |
|
72 } |
|
73 |
|
74 void |
|
75 octave_rl_resize_terminal (void) |
|
76 { |
|
77 rl_resize_terminal (); |
|
78 } |
|
79 |
|
80 void |
|
81 octave_rl_restore_terminal_state () |
|
82 { |
|
83 if (rl_deprep_term_function) |
|
84 rl_deprep_term_function (); |
|
85 } |
|
86 |
|
87 void |
|
88 octave_rl_insert_text (const char *s) |
|
89 { |
|
90 rl_insert_text (s); |
|
91 } |
|
92 |
|
93 void |
|
94 octave_rl_newline (void) |
|
95 { |
|
96 rl_newline (); |
|
97 } |
|
98 |
|
99 void |
|
100 octave_rl_clear_undo_list (void) |
|
101 { |
|
102 if (rl_undo_list) |
|
103 { |
|
104 free_undo_list (); |
|
105 |
|
106 rl_undo_list = 0; |
|
107 } |
|
108 } |
|
109 |
|
110 void |
|
111 octave_rl_set_name (const char *n) |
|
112 { |
|
113 static char *nm = 0; |
|
114 |
|
115 if (nm) |
|
116 { |
|
117 free (nm); |
|
118 nm = 0; |
|
119 } |
|
120 |
|
121 nm = malloc (strlen (n + 1)); |
|
122 |
|
123 strcpy (nm, n); |
|
124 |
|
125 rl_readline_name = nm; |
|
126 |
|
127 /* Since we've already called rl_initialize, we need to re-read the |
|
128 init file to take advantage of the conditional parsing feature |
|
129 based on rl_readline_name; */ |
|
130 |
|
131 rl_re_read_init_file (); |
|
132 } |
|
133 |
|
134 char * |
|
135 octave_rl_readline (const char *prompt) |
|
136 { |
|
137 return readline (prompt); |
|
138 } |
|
139 |
|
140 void |
|
141 octave_rl_set_input_stream (FILE *f) |
|
142 { |
|
143 rl_instream = f; |
|
144 } |
|
145 |
|
146 FILE * |
|
147 octave_rl_get_input_stream (void) |
|
148 { |
|
149 return rl_instream; |
|
150 } |
|
151 |
|
152 void |
|
153 octave_rl_set_output_stream (FILE *f) |
|
154 { |
|
155 rl_outstream = f; |
|
156 } |
|
157 |
|
158 FILE * |
|
159 octave_rl_get_output_stream (void) |
|
160 { |
|
161 return rl_outstream; |
|
162 } |
|
163 |
|
164 void |
|
165 octave_rl_read_init_file (const char *f) |
|
166 { |
|
167 if (f && *f) |
|
168 rl_read_init_file (f); |
|
169 else |
|
170 rl_re_read_init_file (); |
|
171 } |
|
172 |
|
173 void |
|
174 octave_rl_set_basic_quote_characters (const char *s) |
|
175 { |
|
176 static char *ss = 0; |
|
177 |
|
178 if (ss) |
|
179 { |
|
180 free (ss); |
|
181 ss = 0; |
|
182 } |
|
183 |
|
184 ss = malloc (strlen (s) + 1); |
|
185 |
|
186 strcpy (ss, s); |
|
187 |
|
188 rl_basic_quote_characters = ss; |
|
189 } |
|
190 |
|
191 void |
|
192 octave_rl_set_completion_append_character (char c) |
|
193 { |
|
194 rl_completion_append_character = c; |
|
195 } |
|
196 |
|
197 void |
|
198 octave_rl_set_completion_function (rl_attempted_completion_fcn_ptr f) |
|
199 { |
|
200 rl_attempted_completion_function = f; |
|
201 } |
|
202 |
|
203 void |
|
204 octave_rl_set_startup_hook (rl_startup_hook_fcn_ptr f) |
|
205 { |
3520
|
206 rl_startup_hook_fcn_ptr fp = (rl_startup_hook_fcn_ptr) rl_startup_hook; |
|
207 fp = (rl_startup_hook_fcn_ptr) f; |
3519
|
208 } |
|
209 |
|
210 rl_startup_hook_fcn_ptr |
|
211 octave_rl_get_startup_hook (void) |
|
212 { |
3520
|
213 return (rl_startup_hook_fcn_ptr) rl_startup_hook; |
3519
|
214 } |
|
215 |
|
216 void |
|
217 octave_rl_set_event_hook (rl_event_hook_fcn_ptr f) |
|
218 { |
3520
|
219 rl_event_hook_fcn_ptr fp = (rl_event_hook_fcn_ptr) rl_event_hook; |
|
220 fp = (rl_event_hook_fcn_ptr) f; |
3519
|
221 } |
|
222 |
|
223 rl_event_hook_fcn_ptr |
|
224 octave_rl_get_event_hook (void) |
|
225 { |
3520
|
226 return (rl_event_hook_fcn_ptr) rl_event_hook; |
3519
|
227 } |
|
228 |
|
229 char ** |
|
230 octave_rl_completion_matches (const char *text, rl_completer_fcn_ptr f) |
|
231 { |
|
232 return completion_matches (text, f); |
|
233 } |
|
234 |
|
235 char |
|
236 octave_rl_prompt_start_ignore (void) |
|
237 { |
|
238 return RL_PROMPT_START_IGNORE; |
|
239 } |
|
240 |
|
241 char |
|
242 octave_rl_prompt_end_ignore (void) |
|
243 { |
|
244 return RL_PROMPT_END_IGNORE; |
|
245 } |
|
246 |
|
247 void |
|
248 octave_rl_add_defun (const char *name, rl_fcn_ptr f, char key) |
|
249 { |
|
250 rl_add_defun (name, f, key); |
|
251 } |
|
252 |
|
253 void |
|
254 octave_rl_set_terminal_name (const char *term) |
|
255 { |
|
256 rl_terminal_name = (char *) term; |
|
257 } |
|
258 |
|
259 void |
|
260 octave_rl_initialize (void) |
|
261 { |
|
262 rl_initialize (); |
|
263 } |
|
264 |
|
265 int |
|
266 octave_rl_history_search_forward (int count, int ignore) |
|
267 { |
|
268 return rl_history_search_forward (count, ignore); |
|
269 } |
|
270 |
|
271 int |
|
272 octave_rl_history_search_backward (int count, int ignore) |
|
273 { |
|
274 return rl_history_search_backward (count, ignore); |
|
275 } |
|
276 |
|
277 char |
|
278 octave_rl_ctrl (char c) |
|
279 { |
|
280 return CTRL (c); |
|
281 } |
|
282 |
|
283 char |
|
284 octave_rl_meta (char c) |
|
285 { |
|
286 return META (c); |
|
287 } |
|
288 |
|
289 #endif |
|
290 |
|
291 /* |
|
292 ;;; Local Variables: *** |
|
293 ;;; mode: C++ *** |
|
294 ;;; End: *** |
|
295 */ |