Deleted Added
full compact
terminal.c (58314) terminal.c (75409)
1/* $FreeBSD: head/contrib/libreadline/terminal.c 58314 2000-03-19 22:00:57Z ache $ */
1/* $FreeBSD: head/contrib/libreadline/terminal.c 75409 2001-04-11 03:15:56Z ache $ */
2/* terminal.c -- controlling the terminal with termcap. */
3
4/* Copyright (C) 1996 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it

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

72/* */
73/* **************************************************************** */
74
75static char *term_buffer = (char *)NULL;
76static char *term_string_buffer = (char *)NULL;
77
78static int tcap_initialized;
79
2/* terminal.c -- controlling the terminal with termcap. */
3
4/* Copyright (C) 1996 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it

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

72/* */
73/* **************************************************************** */
74
75static char *term_buffer = (char *)NULL;
76static char *term_string_buffer = (char *)NULL;
77
78static int tcap_initialized;
79
80/* Non-zero means this terminal can't really do anything. */
81static int dumb_term;
82
83#if !defined (__linux__)
84# if defined (__EMX__) || defined (NEED_EXTERN_PC)
85extern
86# endif /* __EMX__ || NEED_EXTERN_PC */
87char PC, *BC, *UP;
88#endif /* __linux__ */
89
90/* Some strings to control terminal actions. These are output by tputs (). */
80#if !defined (__linux__)
81# if defined (__EMX__) || defined (NEED_EXTERN_PC)
82extern
83# endif /* __EMX__ || NEED_EXTERN_PC */
84char PC, *BC, *UP;
85#endif /* __linux__ */
86
87/* Some strings to control terminal actions. These are output by tputs (). */
91char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace;
92char *term_pc;
88char *_rl_term_clreol;
89char *_rl_term_clrpag;
90char *_rl_term_cr;
91char *_rl_term_backspace;
92char *_rl_term_goto;
93char *_rl_term_pc;
93
94/* Non-zero if we determine that the terminal can do character insertion. */
94
95/* Non-zero if we determine that the terminal can do character insertion. */
95int terminal_can_insert = 0;
96int _rl_terminal_can_insert = 0;
96
97/* How to insert characters. */
97
98/* How to insert characters. */
98char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
99char *_rl_term_im;
100char *_rl_term_ei;
101char *_rl_term_ic;
102char *_rl_term_ip;
103char *_rl_term_IC;
99
100/* How to delete characters. */
104
105/* How to delete characters. */
101char *term_dc, *term_DC;
106char *_rl_term_dc;
107char *_rl_term_DC;
102
103#if defined (HACK_TERMCAP_MOTION)
108
109#if defined (HACK_TERMCAP_MOTION)
104char *term_forward_char;
110char *_rl_term_forward_char;
105#endif /* HACK_TERMCAP_MOTION */
106
107/* How to go up a line. */
111#endif /* HACK_TERMCAP_MOTION */
112
113/* How to go up a line. */
108char *term_up;
114char *_rl_term_up;
109
115
110/* A visible bell, if the terminal can be made to flash the screen. */
111static char *visible_bell;
116/* A visible bell; char if the terminal can be made to flash the screen. */
117static char *_rl_visible_bell;
112
113/* Non-zero means the terminal can auto-wrap lines. */
114int _rl_term_autowrap;
115
116/* Non-zero means that this terminal has a meta key. */
117static int term_has_meta;
118
119/* The sequences to write to turn on and off the meta key, if this
118
119/* Non-zero means the terminal can auto-wrap lines. */
120int _rl_term_autowrap;
121
122/* Non-zero means that this terminal has a meta key. */
123static int term_has_meta;
124
125/* The sequences to write to turn on and off the meta key, if this
120 terminal has one. */
121static char *term_mm, *term_mo;
126 terminal has one. */
127static char *_rl_term_mm;
128static char *_rl_term_mo;
122
123/* The key sequences output by the arrow keys, if this terminal has any. */
129
130/* The key sequences output by the arrow keys, if this terminal has any. */
124static char *term_ku, *term_kd, *term_kr, *term_kl;
131static char *_rl_term_ku;
132static char *_rl_term_kd;
133static char *_rl_term_kr;
134static char *_rl_term_kl;
125
126/* How to initialize and reset the arrow keys, if this terminal has any. */
135
136/* How to initialize and reset the arrow keys, if this terminal has any. */
127static char *term_ks, *term_ke;
137static char *_rl_term_ks;
138static char *_rl_term_ke;
128
129/* The key sequences sent by the Home and End keys, if any. */
139
140/* The key sequences sent by the Home and End keys, if any. */
130static char *term_kh, *term_kH;
141static char *_rl_term_kh;
142static char *_rl_term_kH;
131
132/* Variables that hold the screen dimensions, used by the display code. */
143
144/* Variables that hold the screen dimensions, used by the display code. */
133int screenwidth, screenheight, screenchars;
145int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
134
135/* Non-zero means the user wants to enable the keypad. */
136int _rl_enable_keypad;
137
138/* Non-zero means the user wants to enable a meta key. */
139int _rl_enable_meta = 1;
140
141#if defined (__EMX__)

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

165 char *ss;
166#if defined (TIOCGWINSZ)
167 struct winsize window_size;
168#endif /* TIOCGWINSZ */
169
170#if defined (TIOCGWINSZ)
171 if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
172 {
146
147/* Non-zero means the user wants to enable the keypad. */
148int _rl_enable_keypad;
149
150/* Non-zero means the user wants to enable a meta key. */
151int _rl_enable_meta = 1;
152
153#if defined (__EMX__)

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

177 char *ss;
178#if defined (TIOCGWINSZ)
179 struct winsize window_size;
180#endif /* TIOCGWINSZ */
181
182#if defined (TIOCGWINSZ)
183 if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
184 {
173 screenwidth = (int) window_size.ws_col;
174 screenheight = (int) window_size.ws_row;
185 _rl_screenwidth = (int) window_size.ws_col;
186 _rl_screenheight = (int) window_size.ws_row;
175 }
176#endif /* TIOCGWINSZ */
177
178#if defined (__EMX__)
187 }
188#endif /* TIOCGWINSZ */
189
190#if defined (__EMX__)
179 _emx_get_screensize (&screenwidth, &screenheight);
191 _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
180#endif
181
182 /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
183 is unset. */
192#endif
193
194 /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
195 is unset. */
184 if (screenwidth <= 0)
196 if (_rl_screenwidth <= 0)
185 {
197 {
186 if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
187 screenwidth = atoi (ss);
198 if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
199 _rl_screenwidth = atoi (ss);
188
189#if !defined (__DJGPP__)
200
201#if !defined (__DJGPP__)
190 if (screenwidth <= 0 && term_string_buffer)
191 screenwidth = tgetnum ("co");
202 if (_rl_screenwidth <= 0 && term_string_buffer)
203 _rl_screenwidth = tgetnum ("co");
192#endif
193 }
194
195 /* Environment variable LINES overrides setting of "li" if IGNORE_ENV
196 is unset. */
204#endif
205 }
206
207 /* Environment variable LINES overrides setting of "li" if IGNORE_ENV
208 is unset. */
197 if (screenheight <= 0)
209 if (_rl_screenheight <= 0)
198 {
210 {
199 if (ignore_env == 0 && (ss = get_env_value ("LINES")))
200 screenheight = atoi (ss);
211 if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
212 _rl_screenheight = atoi (ss);
201
202#if !defined (__DJGPP__)
213
214#if !defined (__DJGPP__)
203 if (screenheight <= 0 && term_string_buffer)
204 screenheight = tgetnum ("li");
215 if (_rl_screenheight <= 0 && term_string_buffer)
216 _rl_screenheight = tgetnum ("li");
205#endif
206 }
207
208 /* If all else fails, default to 80x24 terminal. */
217#endif
218 }
219
220 /* If all else fails, default to 80x24 terminal. */
209 if (screenwidth <= 1)
210 screenwidth = 80;
221 if (_rl_screenwidth <= 1)
222 _rl_screenwidth = 80;
211
223
212 if (screenheight <= 0)
213 screenheight = 24;
224 if (_rl_screenheight <= 0)
225 _rl_screenheight = 24;
214
215 /* If we're being compiled as part of bash, set the environment
216 variables $LINES and $COLUMNS to new values. Otherwise, just
217 do a pair of putenv () or setenv () calls. */
226
227 /* If we're being compiled as part of bash, set the environment
228 variables $LINES and $COLUMNS to new values. Otherwise, just
229 do a pair of putenv () or setenv () calls. */
218 set_lines_and_columns (screenheight, screenwidth);
230 sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
219
220 if (_rl_term_autowrap == 0)
231
232 if (_rl_term_autowrap == 0)
221 screenwidth--;
233 _rl_screenwidth--;
222
234
223 screenchars = screenwidth * screenheight;
235 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
224}
225
226void
227_rl_set_screen_size (rows, cols)
228 int rows, cols;
229{
236}
237
238void
239_rl_set_screen_size (rows, cols)
240 int rows, cols;
241{
230 screenheight = rows;
231 screenwidth = cols;
242 if (rows == 0 || cols == 0)
243 return;
232
244
245 _rl_screenheight = rows;
246 _rl_screenwidth = cols;
247
233 if (_rl_term_autowrap == 0)
248 if (_rl_term_autowrap == 0)
234 screenwidth--;
249 _rl_screenwidth--;
235
250
236 screenchars = screenwidth * screenheight;
251 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
237}
238
239void
252}
253
254void
255rl_set_screen_size (rows, cols)
256 int rows, cols;
257{
258 _rl_set_screen_size (rows, cols);
259}
260
261void
262rl_get_screen_size (rows, cols)
263 int *rows, *cols;
264{
265 if (rows)
266 *rows = _rl_screenheight;
267 if (cols)
268 *cols = _rl_screenwidth;
269}
270
271void
240rl_resize_terminal ()
241{
242 if (readline_echoing_p)
243 {
244 _rl_get_screen_size (fileno (rl_instream), 1);
245 _rl_redisplay_after_sigwinch ();
246 }
247}
248
249struct _tc_string {
272rl_resize_terminal ()
273{
274 if (readline_echoing_p)
275 {
276 _rl_get_screen_size (fileno (rl_instream), 1);
277 _rl_redisplay_after_sigwinch ();
278 }
279}
280
281struct _tc_string {
250 char *tc_var;
282 const char *tc_var;
251 char **tc_value;
252};
253
254/* This should be kept sorted, just in case we decide to change the
255 search algorithm to something smarter. */
256static struct _tc_string tc_strings[] =
257{
283 char **tc_value;
284};
285
286/* This should be kept sorted, just in case we decide to change the
287 search algorithm to something smarter. */
288static struct _tc_string tc_strings[] =
289{
258 { "DC", &term_DC },
259 { "IC", &term_IC },
260 { "ce", &term_clreol },
261 { "cl", &term_clrpag },
262 { "cr", &term_cr },
263 { "dc", &term_dc },
264 { "ei", &term_ei },
265 { "ic", &term_ic },
266 { "im", &term_im },
267 { "kd", &term_kd },
268 { "kh", &term_kh }, /* home */
269 { "@7", &term_kH }, /* end */
270 { "kl", &term_kl },
271 { "kr", &term_kr },
272 { "ku", &term_ku },
273 { "ks", &term_ks },
274 { "ke", &term_ke },
275 { "le", &term_backspace },
276 { "mm", &term_mm },
277 { "mo", &term_mo },
290 { "DC", &_rl_term_DC },
291 { "IC", &_rl_term_IC },
292 { "ce", &_rl_term_clreol },
293 { "cl", &_rl_term_clrpag },
294 { "cr", &_rl_term_cr },
295 { "dc", &_rl_term_dc },
296 { "ei", &_rl_term_ei },
297 { "ic", &_rl_term_ic },
298 { "im", &_rl_term_im },
299 { "kd", &_rl_term_kd },
300 { "kh", &_rl_term_kh }, /* home */
301 { "@7", &_rl_term_kH }, /* end */
302 { "kl", &_rl_term_kl },
303 { "kr", &_rl_term_kr },
304 { "ku", &_rl_term_ku },
305 { "ks", &_rl_term_ks },
306 { "ke", &_rl_term_ke },
307 { "le", &_rl_term_backspace },
308 { "mm", &_rl_term_mm },
309 { "mo", &_rl_term_mo },
278#if defined (HACK_TERMCAP_MOTION)
310#if defined (HACK_TERMCAP_MOTION)
279 { "nd", &term_forward_char },
311 { "nd", &_rl_term_forward_char },
280#endif
312#endif
281 { "pc", &term_pc },
282 { "up", &term_up },
283 { "vb", &visible_bell },
313 { "pc", &_rl_term_pc },
314 { "up", &_rl_term_up },
315 { "vb", &_rl_visible_bell },
284};
285
286#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
287
288/* Read the desired terminal capability strings into BP. The capabilities
289 are described in the TC_STRINGS table. */
290static void
291get_term_capabilities (bp)

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

300 tcap_initialized = 1;
301}
302
303#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
304#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
305
306int
307_rl_init_terminal_io (terminal_name)
316};
317
318#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
319
320/* Read the desired terminal capability strings into BP. The capabilities
321 are described in the TC_STRINGS table. */
322static void
323get_term_capabilities (bp)

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

332 tcap_initialized = 1;
333}
334
335#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
336#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
337
338int
339_rl_init_terminal_io (terminal_name)
308 char *terminal_name;
340 const char *terminal_name;
309{
341{
310 char *term, *buffer;
342 const char *term;
343 char *buffer;
311 int tty, tgetent_ret;
312 Keymap xkeymap;
313
344 int tty, tgetent_ret;
345 Keymap xkeymap;
346
314 term = terminal_name ? terminal_name : get_env_value ("TERM");
315 term_clrpag = term_cr = term_clreol = (char *)NULL;
347 term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
348 _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
316 tty = rl_instream ? fileno (rl_instream) : 0;
349 tty = rl_instream ? fileno (rl_instream) : 0;
317 screenwidth = screenheight = 0;
350 _rl_screenwidth = _rl_screenheight = 0;
318
319 if (term == 0)
320 term = "dumb";
321
322 /* I've separated this out for later work on not calling tgetent at all
323 if the calling application has supplied a custom redisplay function,
324 (and possibly if the application has supplied a custom input function). */
325 if (CUSTOM_REDISPLAY_FUNC())

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

340 }
341
342 if (tgetent_ret <= 0)
343 {
344 FREE (term_string_buffer);
345 FREE (term_buffer);
346 buffer = term_buffer = term_string_buffer = (char *)NULL;
347
351
352 if (term == 0)
353 term = "dumb";
354
355 /* I've separated this out for later work on not calling tgetent at all
356 if the calling application has supplied a custom redisplay function,
357 (and possibly if the application has supplied a custom input function). */
358 if (CUSTOM_REDISPLAY_FUNC())

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

373 }
374
375 if (tgetent_ret <= 0)
376 {
377 FREE (term_string_buffer);
378 FREE (term_buffer);
379 buffer = term_buffer = term_string_buffer = (char *)NULL;
380
348 dumb_term = 1;
349 _rl_term_autowrap = 0; /* used by _rl_get_screen_size */
350
351#if defined (__EMX__)
381 _rl_term_autowrap = 0; /* used by _rl_get_screen_size */
382
383#if defined (__EMX__)
352 _emx_get_screensize (&screenwidth, &screenheight);
353 screenwidth--;
384 _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
385 _rl_screenwidth--;
354#else /* !__EMX__ */
355 _rl_get_screen_size (tty, 0);
356#endif /* !__EMX__ */
357
358 /* Defaults. */
386#else /* !__EMX__ */
387 _rl_get_screen_size (tty, 0);
388#endif /* !__EMX__ */
389
390 /* Defaults. */
359 if (screenwidth <= 0 || screenheight <= 0)
391 if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
360 {
392 {
361 screenwidth = 79;
362 screenheight = 24;
393 _rl_screenwidth = 79;
394 _rl_screenheight = 24;
363 }
364
365 /* Everything below here is used by the redisplay code (tputs). */
395 }
396
397 /* Everything below here is used by the redisplay code (tputs). */
366 screenchars = screenwidth * screenheight;
367 term_cr = "\r";
368 term_im = term_ei = term_ic = term_IC = (char *)NULL;
369 term_up = term_dc = term_DC = visible_bell = (char *)NULL;
370 term_ku = term_kd = term_kl = term_kr = (char *)NULL;
371 term_mm = term_mo = (char *)NULL;
398 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
399 _rl_term_cr = "\r";
400 _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
401 _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
402 _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
403 _rl_term_mm = _rl_term_mo = (char *)NULL;
372#if defined (HACK_TERMCAP_MOTION)
373 term_forward_char = (char *)NULL;
374#endif
404#if defined (HACK_TERMCAP_MOTION)
405 term_forward_char = (char *)NULL;
406#endif
375 terminal_can_insert = term_has_meta = 0;
407 _rl_terminal_can_insert = term_has_meta = 0;
376
377 /* Reasonable defaults for tgoto(). Readline currently only uses
408
409 /* Reasonable defaults for tgoto(). Readline currently only uses
378 tgoto if term_IC or term_DC is defined, but just in case we
410 tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
379 change that later... */
380 PC = '\0';
411 change that later... */
412 PC = '\0';
381 BC = term_backspace = "\b";
382 UP = term_up;
413 BC = _rl_term_backspace = "\b";
414 UP = _rl_term_up;
383
384 return 0;
385 }
386
387 get_term_capabilities (&buffer);
388
389 /* Set up the variables that the termcap library expects the application
390 to provide. */
415
416 return 0;
417 }
418
419 get_term_capabilities (&buffer);
420
421 /* Set up the variables that the termcap library expects the application
422 to provide. */
391 PC = term_pc ? *term_pc : 0;
392 BC = term_backspace;
393 UP = term_up;
423 PC = _rl_term_pc ? *_rl_term_pc : 0;
424 BC = _rl_term_backspace;
425 UP = _rl_term_up;
394
426
395 if (!term_cr)
396 term_cr = "\r";
427 if (!_rl_term_cr)
428 _rl_term_cr = "\r";
397
398 _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
399
400 _rl_get_screen_size (tty, 0);
401
402 /* "An application program can assume that the terminal can do
403 character insertion if *any one of* the capabilities `IC',
404 `im', `ic' or `ip' is provided." But we can't do anything if
405 only `ip' is provided, so... */
429
430 _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
431
432 _rl_get_screen_size (tty, 0);
433
434 /* "An application program can assume that the terminal can do
435 character insertion if *any one of* the capabilities `IC',
436 `im', `ic' or `ip' is provided." But we can't do anything if
437 only `ip' is provided, so... */
406 terminal_can_insert = (term_IC || term_im || term_ic);
438 _rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
407
408 /* Check to see if this terminal has a meta key and clear the capability
409 variables if there is none. */
410 term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
411 if (!term_has_meta)
439
440 /* Check to see if this terminal has a meta key and clear the capability
441 variables if there is none. */
442 term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
443 if (!term_has_meta)
412 term_mm = term_mo = (char *)NULL;
444 _rl_term_mm = _rl_term_mo = (char *)NULL;
413
414 /* Attempt to find and bind the arrow keys. Do not override already
415 bound keys in an overzealous attempt, however. */
416 xkeymap = _rl_keymap;
417
418 _rl_keymap = emacs_standard_keymap;
445
446 /* Attempt to find and bind the arrow keys. Do not override already
447 bound keys in an overzealous attempt, however. */
448 xkeymap = _rl_keymap;
449
450 _rl_keymap = emacs_standard_keymap;
419 _rl_bind_if_unbound (term_ku, rl_get_previous_history);
420 _rl_bind_if_unbound (term_kd, rl_get_next_history);
421 _rl_bind_if_unbound (term_kr, rl_forward);
422 _rl_bind_if_unbound (term_kl, rl_backward);
451 _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
452 _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
453 _rl_bind_if_unbound (_rl_term_kr, rl_forward);
454 _rl_bind_if_unbound (_rl_term_kl, rl_backward);
423
455
424 _rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
425 _rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
456 _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
457 _rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */
426
427#if defined (VI_MODE)
428 _rl_keymap = vi_movement_keymap;
458
459#if defined (VI_MODE)
460 _rl_keymap = vi_movement_keymap;
429 _rl_bind_if_unbound (term_ku, rl_get_previous_history);
430 _rl_bind_if_unbound (term_kd, rl_get_next_history);
431 _rl_bind_if_unbound (term_kr, rl_forward);
432 _rl_bind_if_unbound (term_kl, rl_backward);
461 _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
462 _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
463 _rl_bind_if_unbound (_rl_term_kr, rl_forward);
464 _rl_bind_if_unbound (_rl_term_kl, rl_backward);
433
465
434 _rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
435 _rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
466 _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
467 _rl_bind_if_unbound (_rl_term_kH, rl_end_of_line); /* End */
436#endif /* VI_MODE */
437
438 _rl_keymap = xkeymap;
439
440 return 0;
441}
442
443char *
444rl_get_termcap (cap)
468#endif /* VI_MODE */
469
470 _rl_keymap = xkeymap;
471
472 return 0;
473}
474
475char *
476rl_get_termcap (cap)
445 char *cap;
477 const char *cap;
446{
447 register int i;
448
449 if (tcap_initialized == 0)
450 return ((char *)NULL);
451 for (i = 0; i < NUM_TC_STRINGS; i++)
452 {
453 if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
454 return *(tc_strings[i].tc_value);
455 }
456 return ((char *)NULL);
457}
458
459/* Re-initialize the terminal considering that the TERM/TERMCAP variable
460 has changed. */
461int
462rl_reset_terminal (terminal_name)
478{
479 register int i;
480
481 if (tcap_initialized == 0)
482 return ((char *)NULL);
483 for (i = 0; i < NUM_TC_STRINGS; i++)
484 {
485 if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
486 return *(tc_strings[i].tc_value);
487 }
488 return ((char *)NULL);
489}
490
491/* Re-initialize the terminal considering that the TERM/TERMCAP variable
492 has changed. */
493int
494rl_reset_terminal (terminal_name)
463 char *terminal_name;
495 const char *terminal_name;
464{
465 _rl_init_terminal_io (terminal_name);
466 return 0;
467}
468
469/* A function for the use of tputs () */
470#ifdef _MINIX
471void

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

481{
482 return putc (c, _rl_out_stream);
483}
484#endif /* !_MINIX */
485
486/* Write COUNT characters from STRING to the output stream. */
487void
488_rl_output_some_chars (string, count)
496{
497 _rl_init_terminal_io (terminal_name);
498 return 0;
499}
500
501/* A function for the use of tputs () */
502#ifdef _MINIX
503void

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

513{
514 return putc (c, _rl_out_stream);
515}
516#endif /* !_MINIX */
517
518/* Write COUNT characters from STRING to the output stream. */
519void
520_rl_output_some_chars (string, count)
489 char *string;
521 const char *string;
490 int count;
491{
492 fwrite (string, 1, count, _rl_out_stream);
493}
494
495/* Move the cursor back. */
496int
497_rl_backspace (count)
498 int count;
499{
500 register int i;
501
522 int count;
523{
524 fwrite (string, 1, count, _rl_out_stream);
525}
526
527/* Move the cursor back. */
528int
529_rl_backspace (count)
530 int count;
531{
532 register int i;
533
502 if (term_backspace)
534 if (_rl_term_backspace)
503 for (i = 0; i < count; i++)
535 for (i = 0; i < count; i++)
504 tputs (term_backspace, 1, _rl_output_character_function);
536 tputs (_rl_term_backspace, 1, _rl_output_character_function);
505 else
506 for (i = 0; i < count; i++)
507 putc ('\b', _rl_out_stream);
508 return 0;
509}
510
511/* Move to the start of the next line. */
512int
537 else
538 for (i = 0; i < count; i++)
539 putc ('\b', _rl_out_stream);
540 return 0;
541}
542
543/* Move to the start of the next line. */
544int
513crlf ()
545rl_crlf ()
514{
515#if defined (NEW_TTY_DRIVER)
546{
547#if defined (NEW_TTY_DRIVER)
516 if (term_cr)
517 tputs (term_cr, 1, _rl_output_character_function);
548 if (_rl_term_cr)
549 tputs (_rl_term_cr, 1, _rl_output_character_function);
518#endif /* NEW_TTY_DRIVER */
519 putc ('\n', _rl_out_stream);
520 return 0;
521}
522
523/* Ring the terminal bell. */
524int
550#endif /* NEW_TTY_DRIVER */
551 putc ('\n', _rl_out_stream);
552 return 0;
553}
554
555/* Ring the terminal bell. */
556int
525ding ()
557rl_ding ()
526{
527 if (readline_echoing_p)
528 {
529 switch (_rl_bell_preference)
530 {
531 case NO_BELL:
532 default:
533 break;
534 case VISIBLE_BELL:
558{
559 if (readline_echoing_p)
560 {
561 switch (_rl_bell_preference)
562 {
563 case NO_BELL:
564 default:
565 break;
566 case VISIBLE_BELL:
535 if (visible_bell)
567 if (_rl_visible_bell)
536 {
568 {
537 tputs (visible_bell, 1, _rl_output_character_function);
569 tputs (_rl_visible_bell, 1, _rl_output_character_function);
538 break;
539 }
540 /* FALLTHROUGH */
541 case AUDIBLE_BELL:
542 fprintf (stderr, "\007");
543 fflush (stderr);
544 break;
545 }

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

553/* Controlling the Meta Key and Keypad */
554/* */
555/* **************************************************************** */
556
557void
558_rl_enable_meta_key ()
559{
560#if !defined (__DJGPP__)
570 break;
571 }
572 /* FALLTHROUGH */
573 case AUDIBLE_BELL:
574 fprintf (stderr, "\007");
575 fflush (stderr);
576 break;
577 }

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

585/* Controlling the Meta Key and Keypad */
586/* */
587/* **************************************************************** */
588
589void
590_rl_enable_meta_key ()
591{
592#if !defined (__DJGPP__)
561 if (term_has_meta && term_mm)
562 tputs (term_mm, 1, _rl_output_character_function);
593 if (term_has_meta && _rl_term_mm)
594 tputs (_rl_term_mm, 1, _rl_output_character_function);
563#endif
564}
565
566void
567_rl_control_keypad (on)
568 int on;
569{
570#if !defined (__DJGPP__)
595#endif
596}
597
598void
599_rl_control_keypad (on)
600 int on;
601{
602#if !defined (__DJGPP__)
571 if (on && term_ks)
572 tputs (term_ks, 1, _rl_output_character_function);
573 else if (!on && term_ke)
574 tputs (term_ke, 1, _rl_output_character_function);
603 if (on && _rl_term_ks)
604 tputs (_rl_term_ks, 1, _rl_output_character_function);
605 else if (!on && _rl_term_ke)
606 tputs (_rl_term_ke, 1, _rl_output_character_function);
575#endif
576}
607#endif
608}