* configure.in: Remove --enable-shared option. It shouldn't be used for gdb.
[deliverable/binutils-gdb.git] / readline / terminal.c
CommitLineData
d60d9f65
SS
1/* terminal.c -- controlling the terminal with termcap. */
2
3/* Copyright (C) 1996 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
9 and/or modify it under the terms of the GNU General Public License
1b17e766 10 as published by the Free Software Foundation; either version 2, or
d60d9f65
SS
11 (at your option) any later version.
12
13 The GNU Readline Library is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
1b17e766 21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
d60d9f65
SS
22#define READLINE_LIBRARY
23
24#if defined (HAVE_CONFIG_H)
25# include <config.h>
26#endif
27
28#include <sys/types.h>
29#include "posixstat.h"
30#include <fcntl.h>
31#if defined (HAVE_SYS_FILE_H)
32# include <sys/file.h>
33#endif /* HAVE_SYS_FILE_H */
34
35#if defined (HAVE_UNISTD_H)
36# include <unistd.h>
37#endif /* HAVE_UNISTD_H */
38
39#if defined (HAVE_STDLIB_H)
40# include <stdlib.h>
41#else
42# include "ansi_stdlib.h"
43#endif /* HAVE_STDLIB_H */
44
45#if defined (HAVE_LOCALE_H)
46# include <locale.h>
47#endif
48
d60d9f65 49#include <stdio.h>
d60d9f65
SS
50
51/* System-specific feature definitions and include files. */
52#include "rldefs.h"
53
54#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
55# include <sys/ioctl.h>
56#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
57
30083a32
EZ
58#ifdef __MSDOS__
59# include <pc.h>
60#endif
61
d60d9f65
SS
62#include "rltty.h"
63#include "tcap.h"
64
65/* Some standard library routines. */
66#include "readline.h"
67#include "history.h"
68
1b17e766
EZ
69#include "rlprivate.h"
70#include "rlshell.h"
9255ee31
EZ
71#include "xmalloc.h"
72
73#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
74#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
8f2eba6e 75
d60d9f65
SS
76/* **************************************************************** */
77/* */
78/* Terminal and Termcap */
79/* */
80/* **************************************************************** */
81
30083a32 82#ifndef __MSDOS__
d60d9f65
SS
83static char *term_buffer = (char *)NULL;
84static char *term_string_buffer = (char *)NULL;
85
d60d9f65
SS
86/* Non-zero means this terminal can't really do anything. */
87static int dumb_term;
30083a32
EZ
88#endif /* !__MSDOS__ */
89
90static int tcap_initialized;
d60d9f65
SS
91
92#if !defined (__linux__)
93# if defined (__EMX__) || defined (NEED_EXTERN_PC)
94extern
95# endif /* __EMX__ || NEED_EXTERN_PC */
96char PC, *BC, *UP;
97#endif /* __linux__ */
98
99/* Some strings to control terminal actions. These are output by tputs (). */
9255ee31
EZ
100char *_rl_term_clreol;
101char *_rl_term_clrpag;
102char *_rl_term_cr;
103char *_rl_term_backspace;
104char *_rl_term_goto;
105char *_rl_term_pc;
d60d9f65
SS
106
107/* Non-zero if we determine that the terminal can do character insertion. */
9255ee31 108int _rl_terminal_can_insert = 0;
d60d9f65
SS
109
110/* How to insert characters. */
9255ee31
EZ
111char *_rl_term_im;
112char *_rl_term_ei;
113char *_rl_term_ic;
114char *_rl_term_ip;
115char *_rl_term_IC;
d60d9f65
SS
116
117/* How to delete characters. */
9255ee31
EZ
118char *_rl_term_dc;
119char *_rl_term_DC;
d60d9f65
SS
120
121#if defined (HACK_TERMCAP_MOTION)
9255ee31 122char *_rl_term_forward_char;
d60d9f65
SS
123#endif /* HACK_TERMCAP_MOTION */
124
125/* How to go up a line. */
9255ee31 126char *_rl_term_up;
d60d9f65 127
9255ee31
EZ
128/* A visible bell; char if the terminal can be made to flash the screen. */
129static char *_rl_visible_bell;
d60d9f65
SS
130
131/* Non-zero means the terminal can auto-wrap lines. */
132int _rl_term_autowrap;
133
134/* Non-zero means that this terminal has a meta key. */
135static int term_has_meta;
136
137/* The sequences to write to turn on and off the meta key, if this
9255ee31
EZ
138 terminal has one. */
139static char *_rl_term_mm;
140static char *_rl_term_mo;
d60d9f65
SS
141
142/* The key sequences output by the arrow keys, if this terminal has any. */
9255ee31
EZ
143static char *_rl_term_ku;
144static char *_rl_term_kd;
145static char *_rl_term_kr;
146static char *_rl_term_kl;
d60d9f65
SS
147
148/* How to initialize and reset the arrow keys, if this terminal has any. */
9255ee31
EZ
149static char *_rl_term_ks;
150static char *_rl_term_ke;
d60d9f65
SS
151
152/* The key sequences sent by the Home and End keys, if any. */
9255ee31
EZ
153static char *_rl_term_kh;
154static char *_rl_term_kH;
155static char *_rl_term_at7; /* @7 */
156
157/* Insert key */
158static char *_rl_term_kI;
159
160/* Cursor control */
161static char *_rl_term_vs; /* very visible */
162static char *_rl_term_ve; /* normal */
163
164static void bind_termcap_arrow_keys PARAMS((Keymap));
d60d9f65
SS
165
166/* Variables that hold the screen dimensions, used by the display code. */
9255ee31 167int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
d60d9f65
SS
168
169/* Non-zero means the user wants to enable the keypad. */
170int _rl_enable_keypad;
171
172/* Non-zero means the user wants to enable a meta key. */
173int _rl_enable_meta = 1;
174
1b17e766
EZ
175#if defined (__EMX__)
176static void
177_emx_get_screensize (swp, shp)
178 int *swp, *shp;
179{
180 int sz[2];
181
182 _scrsize (sz);
183
184 if (swp)
185 *swp = sz[0];
186 if (shp)
187 *shp = sz[1];
188}
189#endif
190
d60d9f65
SS
191/* Get readline's idea of the screen size. TTY is a file descriptor open
192 to the terminal. If IGNORE_ENV is true, we do not pay attention to the
193 values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
194 non-null serve to check whether or not we have initialized termcap. */
195void
196_rl_get_screen_size (tty, ignore_env)
197 int tty, ignore_env;
198{
199 char *ss;
200#if defined (TIOCGWINSZ)
201 struct winsize window_size;
202#endif /* TIOCGWINSZ */
d60d9f65
SS
203
204#if defined (TIOCGWINSZ)
205 if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
206 {
9255ee31
EZ
207 _rl_screenwidth = (int) window_size.ws_col;
208 _rl_screenheight = (int) window_size.ws_row;
d60d9f65
SS
209 }
210#endif /* TIOCGWINSZ */
211
212#if defined (__EMX__)
9255ee31 213 _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
d60d9f65
SS
214#endif
215
216 /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
217 is unset. */
9255ee31 218 if (_rl_screenwidth <= 0)
d60d9f65 219 {
9255ee31
EZ
220 if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
221 _rl_screenwidth = atoi (ss);
d60d9f65 222
9255ee31
EZ
223#if !defined (__DJGPP__)
224 if (_rl_screenwidth <= 0 && term_string_buffer)
225 _rl_screenwidth = tgetnum ("co");
771578d1 226#endif
d60d9f65
SS
227 }
228
229 /* Environment variable LINES overrides setting of "li" if IGNORE_ENV
230 is unset. */
9255ee31 231 if (_rl_screenheight <= 0)
d60d9f65 232 {
9255ee31
EZ
233 if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
234 _rl_screenheight = atoi (ss);
d60d9f65 235
9255ee31
EZ
236#if !defined (__DJGPP__)
237 if (_rl_screenheight <= 0 && term_string_buffer)
238 _rl_screenheight = tgetnum ("li");
771578d1 239#endif
d60d9f65
SS
240 }
241
242 /* If all else fails, default to 80x24 terminal. */
9255ee31
EZ
243 if (_rl_screenwidth <= 1)
244 _rl_screenwidth = 80;
d60d9f65 245
9255ee31
EZ
246 if (_rl_screenheight <= 0)
247 _rl_screenheight = 24;
d60d9f65
SS
248
249 /* If we're being compiled as part of bash, set the environment
250 variables $LINES and $COLUMNS to new values. Otherwise, just
251 do a pair of putenv () or setenv () calls. */
9255ee31 252 sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
d60d9f65 253
1b17e766 254 if (_rl_term_autowrap == 0)
9255ee31 255 _rl_screenwidth--;
d60d9f65 256
9255ee31 257 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
d60d9f65
SS
258}
259
260void
261_rl_set_screen_size (rows, cols)
262 int rows, cols;
263{
9255ee31
EZ
264 if (rows == 0 || cols == 0)
265 return;
266
267 _rl_screenheight = rows;
268 _rl_screenwidth = cols;
d60d9f65
SS
269
270 if (_rl_term_autowrap == 0)
9255ee31 271 _rl_screenwidth--;
d60d9f65 272
9255ee31 273 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
d60d9f65
SS
274}
275
9255ee31
EZ
276void
277rl_set_screen_size (rows, cols)
278 int rows, cols;
279{
280 _rl_set_screen_size (rows, cols);
281}
282
283void
284rl_get_screen_size (rows, cols)
285 int *rows, *cols;
286{
287 if (rows)
288 *rows = _rl_screenheight;
289 if (cols)
290 *cols = _rl_screenwidth;
291}
292
c862e87b
JM
293void
294rl_resize_terminal ()
295{
296 if (readline_echoing_p)
297 {
298 _rl_get_screen_size (fileno (rl_instream), 1);
9255ee31
EZ
299 if (CUSTOM_REDISPLAY_FUNC ())
300 rl_forced_update_display ();
301 else
302 _rl_redisplay_after_sigwinch ();
c862e87b
JM
303 }
304}
305
d60d9f65 306struct _tc_string {
9255ee31 307 const char *tc_var;
d60d9f65
SS
308 char **tc_value;
309};
310
311/* This should be kept sorted, just in case we decide to change the
312 search algorithm to something smarter. */
313static struct _tc_string tc_strings[] =
314{
9255ee31
EZ
315 { "@7", &_rl_term_at7 },
316 { "DC", &_rl_term_DC },
317 { "IC", &_rl_term_IC },
318 { "ce", &_rl_term_clreol },
319 { "cl", &_rl_term_clrpag },
320 { "cr", &_rl_term_cr },
321 { "dc", &_rl_term_dc },
322 { "ei", &_rl_term_ei },
323 { "ic", &_rl_term_ic },
324 { "im", &_rl_term_im },
325 { "kH", &_rl_term_kH }, /* home down ?? */
326 { "kI", &_rl_term_kI }, /* insert */
327 { "kd", &_rl_term_kd },
328 { "ke", &_rl_term_ke }, /* end keypad mode */
329 { "kh", &_rl_term_kh }, /* home */
330 { "kl", &_rl_term_kl },
331 { "kr", &_rl_term_kr },
332 { "ks", &_rl_term_ks }, /* start keypad mode */
333 { "ku", &_rl_term_ku },
334 { "le", &_rl_term_backspace },
335 { "mm", &_rl_term_mm },
336 { "mo", &_rl_term_mo },
d60d9f65 337#if defined (HACK_TERMCAP_MOTION)
9255ee31 338 { "nd", &_rl_term_forward_char },
d60d9f65 339#endif
9255ee31
EZ
340 { "pc", &_rl_term_pc },
341 { "up", &_rl_term_up },
342 { "vb", &_rl_visible_bell },
343 { "vs", &_rl_term_vs },
344 { "ve", &_rl_term_ve },
d60d9f65
SS
345};
346
347#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
348
349/* Read the desired terminal capability strings into BP. The capabilities
350 are described in the TC_STRINGS table. */
351static void
352get_term_capabilities (bp)
353 char **bp;
354{
1b17e766 355#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
d60d9f65
SS
356 register int i;
357
358 for (i = 0; i < NUM_TC_STRINGS; i++)
9255ee31
EZ
359# ifdef __LCC__
360 *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
361# else
d60d9f65 362 *(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
9255ee31 363# endif
771578d1 364#endif
d60d9f65
SS
365 tcap_initialized = 1;
366}
367
368int
369_rl_init_terminal_io (terminal_name)
9255ee31 370 const char *terminal_name;
d60d9f65 371{
9255ee31
EZ
372 const char *term;
373 char *buffer;
1b17e766 374 int tty, tgetent_ret;
d60d9f65 375
9255ee31
EZ
376 term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
377 _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
1b17e766 378 tty = rl_instream ? fileno (rl_instream) : 0;
9255ee31 379 _rl_screenwidth = _rl_screenheight = 0;
d60d9f65 380
1b17e766
EZ
381 if (term == 0)
382 term = "dumb";
d60d9f65 383
30083a32
EZ
384#ifdef __MSDOS__
385 term_im = term_ei = term_ic = term_IC = (char *)NULL;
386 term_up = term_dc = term_DC = visible_bell = (char *)NULL;
387 term_ku = term_kd = term_kl = term_kr = (char *)NULL;
388 term_mm = term_mo = (char *)NULL;
389 terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
390 term_cr = "\r";
391
392 _rl_get_screen_size (tty, 0);
393#else /* !__MSDOS__ */
1b17e766
EZ
394 /* I've separated this out for later work on not calling tgetent at all
395 if the calling application has supplied a custom redisplay function,
396 (and possibly if the application has supplied a custom input function). */
397 if (CUSTOM_REDISPLAY_FUNC())
398 {
399 tgetent_ret = -1;
400 }
401 else
402 {
403 if (term_string_buffer == 0)
9255ee31 404 term_string_buffer = (char *)xmalloc(2032);
d60d9f65 405
1b17e766 406 if (term_buffer == 0)
9255ee31 407 term_buffer = (char *)xmalloc(4080);
d60d9f65 408
1b17e766 409 buffer = term_string_buffer;
d60d9f65 410
1b17e766
EZ
411 tgetent_ret = tgetent (term_buffer, term);
412 }
d60d9f65 413
1b17e766 414 if (tgetent_ret <= 0)
d60d9f65 415 {
1b17e766
EZ
416 FREE (term_string_buffer);
417 FREE (term_buffer);
418 buffer = term_buffer = term_string_buffer = (char *)NULL;
419
1b17e766
EZ
420 _rl_term_autowrap = 0; /* used by _rl_get_screen_size */
421
422#if defined (__EMX__)
9255ee31
EZ
423 _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
424 _rl_screenwidth--;
1b17e766
EZ
425#else /* !__EMX__ */
426 _rl_get_screen_size (tty, 0);
427#endif /* !__EMX__ */
428
429 /* Defaults. */
9255ee31 430 if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
1b17e766 431 {
9255ee31
EZ
432 _rl_screenwidth = 79;
433 _rl_screenheight = 24;
1b17e766
EZ
434 }
435
436 /* Everything below here is used by the redisplay code (tputs). */
9255ee31
EZ
437 _rl_screenchars = _rl_screenwidth * _rl_screenheight;
438 _rl_term_cr = "\r";
439 _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
440 _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
441 _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
442 _rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL;
443 _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
444 _rl_term_mm = _rl_term_mo = (char *)NULL;
445 _rl_term_ve = _rl_term_vs = (char *)NULL;
d60d9f65
SS
446#if defined (HACK_TERMCAP_MOTION)
447 term_forward_char = (char *)NULL;
448#endif
9255ee31 449 _rl_terminal_can_insert = term_has_meta = 0;
1b17e766
EZ
450
451 /* Reasonable defaults for tgoto(). Readline currently only uses
9255ee31 452 tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
1b17e766
EZ
453 change that later... */
454 PC = '\0';
9255ee31
EZ
455 BC = _rl_term_backspace = "\b";
456 UP = _rl_term_up;
1b17e766 457
d60d9f65
SS
458 return 0;
459 }
460
461 get_term_capabilities (&buffer);
462
463 /* Set up the variables that the termcap library expects the application
464 to provide. */
9255ee31
EZ
465 PC = _rl_term_pc ? *_rl_term_pc : 0;
466 BC = _rl_term_backspace;
467 UP = _rl_term_up;
d60d9f65 468
9255ee31
EZ
469 if (!_rl_term_cr)
470 _rl_term_cr = "\r";
d60d9f65 471
d60d9f65
SS
472 _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
473
474 _rl_get_screen_size (tty, 0);
475
476 /* "An application program can assume that the terminal can do
477 character insertion if *any one of* the capabilities `IC',
478 `im', `ic' or `ip' is provided." But we can't do anything if
479 only `ip' is provided, so... */
9255ee31 480 _rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
d60d9f65
SS
481
482 /* Check to see if this terminal has a meta key and clear the capability
483 variables if there is none. */
484 term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
485 if (!term_has_meta)
9255ee31 486 _rl_term_mm = _rl_term_mo = (char *)NULL;
d60d9f65 487
30083a32
EZ
488#endif /* !__MSDOS__ */
489
d60d9f65
SS
490 /* Attempt to find and bind the arrow keys. Do not override already
491 bound keys in an overzealous attempt, however. */
d60d9f65 492
9255ee31 493 bind_termcap_arrow_keys (emacs_standard_keymap);
d60d9f65
SS
494
495#if defined (VI_MODE)
9255ee31
EZ
496 bind_termcap_arrow_keys (vi_movement_keymap);
497 bind_termcap_arrow_keys (vi_insertion_keymap);
d60d9f65
SS
498#endif /* VI_MODE */
499
d60d9f65
SS
500 return 0;
501}
502
9255ee31
EZ
503/* Bind the arrow key sequences from the termcap description in MAP. */
504static void
505bind_termcap_arrow_keys (map)
506 Keymap map;
507{
508 Keymap xkeymap;
509
510 xkeymap = _rl_keymap;
511 _rl_keymap = map;
512
513 _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
514 _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
515 _rl_bind_if_unbound (_rl_term_kr, rl_forward);
516 _rl_bind_if_unbound (_rl_term_kl, rl_backward);
517
518 _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
519 _rl_bind_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
520
521 _rl_keymap = xkeymap;
522}
523
d60d9f65
SS
524char *
525rl_get_termcap (cap)
9255ee31 526 const char *cap;
d60d9f65
SS
527{
528 register int i;
529
530 if (tcap_initialized == 0)
531 return ((char *)NULL);
532 for (i = 0; i < NUM_TC_STRINGS; i++)
533 {
534 if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
535 return *(tc_strings[i].tc_value);
536 }
537 return ((char *)NULL);
538}
539
540/* Re-initialize the terminal considering that the TERM/TERMCAP variable
541 has changed. */
542int
543rl_reset_terminal (terminal_name)
9255ee31 544 const char *terminal_name;
d60d9f65
SS
545{
546 _rl_init_terminal_io (terminal_name);
547 return 0;
548}
549
550/* A function for the use of tputs () */
551#ifdef _MINIX
552void
553_rl_output_character_function (c)
554 int c;
555{
556 putc (c, _rl_out_stream);
557}
558#else /* !_MINIX */
559int
560_rl_output_character_function (c)
561 int c;
562{
563 return putc (c, _rl_out_stream);
564}
565#endif /* !_MINIX */
1b17e766 566
d60d9f65
SS
567/* Write COUNT characters from STRING to the output stream. */
568void
569_rl_output_some_chars (string, count)
9255ee31 570 const char *string;
d60d9f65
SS
571 int count;
572{
573 fwrite (string, 1, count, _rl_out_stream);
574}
575
576/* Move the cursor back. */
577int
578_rl_backspace (count)
579 int count;
580{
581 register int i;
582
30083a32 583#ifndef __MSDOS__
9255ee31 584 if (_rl_term_backspace)
d60d9f65 585 for (i = 0; i < count; i++)
9255ee31 586 tputs (_rl_term_backspace, 1, _rl_output_character_function);
d60d9f65 587 else
30083a32 588#endif
d60d9f65
SS
589 for (i = 0; i < count; i++)
590 putc ('\b', _rl_out_stream);
591 return 0;
592}
593
594/* Move to the start of the next line. */
595int
9255ee31 596rl_crlf ()
d60d9f65
SS
597{
598#if defined (NEW_TTY_DRIVER)
9255ee31
EZ
599 if (_rl_term_cr)
600 tputs (_rl_term_cr, 1, _rl_output_character_function);
d60d9f65
SS
601#endif /* NEW_TTY_DRIVER */
602 putc ('\n', _rl_out_stream);
603 return 0;
604}
605
606/* Ring the terminal bell. */
607int
9255ee31 608rl_ding ()
d60d9f65
SS
609{
610 if (readline_echoing_p)
611 {
d60d9f65
SS
612 switch (_rl_bell_preference)
613 {
614 case NO_BELL:
615 default:
616 break;
617 case VISIBLE_BELL:
30083a32
EZ
618#ifdef __MSDOS__
619 ScreenVisualBell ();
620 break;
621#else
9255ee31 622 if (_rl_visible_bell)
d60d9f65 623 {
9255ee31 624 tputs (_rl_visible_bell, 1, _rl_output_character_function);
d60d9f65
SS
625 break;
626 }
30083a32 627#endif
d60d9f65
SS
628 /* FALLTHROUGH */
629 case AUDIBLE_BELL:
630 fprintf (stderr, "\007");
631 fflush (stderr);
632 break;
633 }
d60d9f65
SS
634 return (0);
635 }
636 return (-1);
637}
638
639/* **************************************************************** */
640/* */
641/* Controlling the Meta Key and Keypad */
642/* */
643/* **************************************************************** */
644
645void
646_rl_enable_meta_key ()
647{
1b17e766 648#if !defined (__DJGPP__)
9255ee31
EZ
649 if (term_has_meta && _rl_term_mm)
650 tputs (_rl_term_mm, 1, _rl_output_character_function);
771578d1 651#endif
d60d9f65
SS
652}
653
654void
655_rl_control_keypad (on)
656 int on;
657{
1b17e766 658#if !defined (__DJGPP__)
9255ee31
EZ
659 if (on && _rl_term_ks)
660 tputs (_rl_term_ks, 1, _rl_output_character_function);
661 else if (!on && _rl_term_ke)
662 tputs (_rl_term_ke, 1, _rl_output_character_function);
771578d1 663#endif
d60d9f65 664}
9255ee31
EZ
665
666/* **************************************************************** */
667/* */
668/* Controlling the Cursor */
669/* */
670/* **************************************************************** */
671
672/* Set the cursor appropriately depending on IM, which is one of the
673 insert modes (insert or overwrite). Insert mode gets the normal
674 cursor. Overwrite mode gets a very visible cursor. Only does
675 anything if we have both capabilities. */
676void
677_rl_set_cursor (im, force)
678 int im, force;
679{
680 if (_rl_term_ve && _rl_term_vs)
681 {
682 if (force || im != rl_insert_mode)
683 {
684 if (im == RL_IM_OVERWRITE)
685 tputs (_rl_term_vs, 1, _rl_output_character_function);
686 else
687 tputs (_rl_term_ve, 1, _rl_output_character_function);
688 }
689 }
690}
This page took 0.17519 seconds and 4 git commands to generate.