diff options
author | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2000-07-09 17:20:00 +0000 |
---|---|---|
committer | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2000-07-09 17:20:00 +0000 |
commit | 1b17e766659d93d1e7bd6633bf78132e1abb3568 (patch) | |
tree | 6fa61b8b0140bca0772cdf39390405ca20fec949 /readline/terminal.c | |
parent | d0352a18a504a4e7b761f6b3264cf11347d8d056 (diff) | |
download | gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.zip gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.tar.gz gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.tar.bz2 |
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
Diffstat (limited to 'readline/terminal.c')
-rw-r--r-- | readline/terminal.c | 235 |
1 files changed, 112 insertions, 123 deletions
diff --git a/readline/terminal.c b/readline/terminal.c index 627a385..20ad126 100644 --- a/readline/terminal.c +++ b/readline/terminal.c @@ -7,7 +7,7 @@ The GNU Readline Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 1, or + as published by the Free Software Foundation; either version 2, or (at your option) any later version. The GNU Readline Library is distributed in the hope that it will be @@ -18,7 +18,7 @@ The GNU General Public License is often shipped with GNU software, and is generally kept in a file called COPYING or LICENSE. If you do not have a copy of the license, write to the Free Software Foundation, - 675 Mass Ave, Cambridge, MA 02139, USA. */ + 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -46,9 +46,7 @@ # include <locale.h> #endif -#include <signal.h> #include <stdio.h> -#include <setjmp.h> /* System-specific feature definitions and include files. */ #include "rldefs.h" @@ -57,10 +55,6 @@ # include <sys/ioctl.h> #endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ -#if defined (__GO32__) -# include <pc.h> -#endif - #include "rltty.h" #include "tcap.h" @@ -68,21 +62,8 @@ #include "readline.h" #include "history.h" -/* Variables and functions imported from readline.c */ -extern FILE *_rl_in_stream, *_rl_out_stream; -extern int readline_echoing_p; -extern int _rl_bell_preference; -extern Keymap _rl_keymap; - -/* Functions imported from bind.c */ -extern void _rl_bind_if_unbound (); - -/* Functions imported from shell.c */ -extern void set_lines_and_columns (); -extern char *get_env_value (); - -/* Functions imported from display.c */ -extern void _rl_redisplay_after_sigwinch (); +#include "rlprivate.h" +#include "rlshell.h" /* **************************************************************** */ /* */ @@ -90,15 +71,13 @@ extern void _rl_redisplay_after_sigwinch (); /* */ /* **************************************************************** */ -#ifndef __DJGPP__ static char *term_buffer = (char *)NULL; static char *term_string_buffer = (char *)NULL; +static int tcap_initialized; + /* Non-zero means this terminal can't really do anything. */ static int dumb_term; -#endif - -static int tcap_initialized; #if !defined (__linux__) # if defined (__EMX__) || defined (NEED_EXTERN_PC) @@ -158,6 +137,22 @@ int _rl_enable_keypad; /* Non-zero means the user wants to enable a meta key. */ int _rl_enable_meta = 1; +#if defined (__EMX__) +static void +_emx_get_screensize (swp, shp) + int *swp, *shp; +{ + int sz[2]; + + _scrsize (sz); + + if (swp) + *swp = sz[0]; + if (shp) + *shp = sz[1]; +} +#endif + /* Get readline's idea of the screen size. TTY is a file descriptor open to the terminal. If IGNORE_ENV is true, we do not pay attention to the values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being @@ -170,9 +165,6 @@ _rl_get_screen_size (tty, ignore_env) #if defined (TIOCGWINSZ) struct winsize window_size; #endif /* TIOCGWINSZ */ -#if defined (__EMX__) - int sz[2]; -#endif #if defined (TIOCGWINSZ) if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) @@ -183,9 +175,7 @@ _rl_get_screen_size (tty, ignore_env) #endif /* TIOCGWINSZ */ #if defined (__EMX__) - _scrsize (sz); - screenwidth = sz[0]; - screenheight = sz[1]; + _emx_get_screensize (&screenwidth, &screenheight); #endif /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV @@ -195,11 +185,7 @@ _rl_get_screen_size (tty, ignore_env) if (ignore_env == 0 && (ss = get_env_value ("COLUMNS"))) screenwidth = atoi (ss); -#if defined(__DJGPP__) - tty = tty; - if (screenwidth <= 0) - screenwidth = ScreenCols (); -#else +#if !defined (__DJGPP__) if (screenwidth <= 0 && term_string_buffer) screenwidth = tgetnum ("co"); #endif @@ -212,10 +198,7 @@ _rl_get_screen_size (tty, ignore_env) if (ignore_env == 0 && (ss = get_env_value ("LINES"))) screenheight = atoi (ss); -#if defined(__DJGPP__) - if (screenheight <= 0) - screenheight = ScreenRows (); -#else +#if !defined (__DJGPP__) if (screenheight <= 0 && term_string_buffer) screenheight = tgetnum ("li"); #endif @@ -233,7 +216,7 @@ _rl_get_screen_size (tty, ignore_env) do a pair of putenv () or setenv () calls. */ set_lines_and_columns (screenheight, screenwidth); - if (!_rl_term_autowrap) + if (_rl_term_autowrap == 0) screenwidth--; screenchars = screenwidth * screenheight; @@ -271,32 +254,32 @@ struct _tc_string { search algorithm to something smarter. */ static struct _tc_string tc_strings[] = { - "DC", &term_DC, - "IC", &term_IC, - "ce", &term_clreol, - "cl", &term_clrpag, - "cr", &term_cr, - "dc", &term_dc, - "ei", &term_ei, - "ic", &term_ic, - "im", &term_im, - "kd", &term_kd, - "kh", &term_kh, /* home */ - "kH", &term_kH, /* end */ - "kl", &term_kl, - "kr", &term_kr, - "ku", &term_ku, - "ks", &term_ks, - "ke", &term_ke, - "le", &term_backspace, - "mm", &term_mm, - "mo", &term_mo, + { "DC", &term_DC }, + { "IC", &term_IC }, + { "ce", &term_clreol }, + { "cl", &term_clrpag }, + { "cr", &term_cr }, + { "dc", &term_dc }, + { "ei", &term_ei }, + { "ic", &term_ic }, + { "im", &term_im }, + { "kd", &term_kd }, + { "kh", &term_kh }, /* home */ + { "kH", &term_kH }, /* end */ + { "kl", &term_kl }, + { "kr", &term_kr }, + { "ku", &term_ku }, + { "ks", &term_ks }, + { "ke", &term_ke }, + { "le", &term_backspace }, + { "mm", &term_mm }, + { "mo", &term_mo }, #if defined (HACK_TERMCAP_MOTION) - "nd", &term_forward_char, + { "nd", &term_forward_char }, #endif - "pc", &term_pc, - "up", &term_up, - "vb", &visible_bell, + { "pc", &term_pc }, + { "up", &term_up }, + { "vb", &visible_bell }, }; #define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string)) @@ -307,9 +290,7 @@ static void get_term_capabilities (bp) char **bp; { -#if defined(__DJGPP__) - bp = bp; -#else +#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */ register int i; for (i = 0; i < NUM_TC_STRINGS; i++) @@ -318,66 +299,87 @@ get_term_capabilities (bp) tcap_initialized = 1; } +#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) +#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) + int _rl_init_terminal_io (terminal_name) char *terminal_name; { -#if defined (__GO32__) - terminal_name = terminal_name; - screenwidth = screenheight = 0; - _rl_get_screen_size (rl_instream ? fileno (rl_instream) : 0, 0); - - term_cr = "\r"; - term_im = term_ei = term_ic = term_IC = (char *)NULL; - term_up = term_dc = term_DC = visible_bell = (char *)NULL; - - /* Does the __GO32__ have a meta key? I don't know. */ - term_has_meta = 0; - term_mm = term_mo = (char *)NULL; - - /* It probably has arrow keys, but I don't know what they are. */ - term_ku = term_kd = term_kr = term_kl = (char *)NULL; - -#if defined (HACK_TERMCAP_MOTION) - term_forward_char = (char *)NULL; -#endif /* HACK_TERMCAP_MOTION */ - terminal_can_insert = _rl_term_autowrap = 0; - return 0; -#else /* !__GO32__ */ - char *term, *buffer; - int tty; + int tty, tgetent_ret; Keymap xkeymap; term = terminal_name ? terminal_name : get_env_value ("TERM"); + term_clrpag = term_cr = term_clreol = (char *)NULL; + tty = rl_instream ? fileno (rl_instream) : 0; + screenwidth = screenheight = 0; - if (term_string_buffer == 0) - term_string_buffer = xmalloc (2032); + if (term == 0) + term = "dumb"; - if (term_buffer == 0) - term_buffer = xmalloc (4080); + /* I've separated this out for later work on not calling tgetent at all + if the calling application has supplied a custom redisplay function, + (and possibly if the application has supplied a custom input function). */ + if (CUSTOM_REDISPLAY_FUNC()) + { + tgetent_ret = -1; + } + else + { + if (term_string_buffer == 0) + term_string_buffer = xmalloc(2032); - buffer = term_string_buffer; + if (term_buffer == 0) + term_buffer = xmalloc(4080); - term_clrpag = term_cr = term_clreol = (char *)NULL; + buffer = term_string_buffer; - if (term == 0) - term = "dumb"; + tgetent_ret = tgetent (term_buffer, term); + } - if (tgetent (term_buffer, term) <= 0) + if (tgetent_ret <= 0) { + FREE (term_string_buffer); + FREE (term_buffer); + buffer = term_buffer = term_string_buffer = (char *)NULL; + dumb_term = 1; - screenwidth = 79; - screenheight = 24; - screenchars = 79 * 24; + _rl_term_autowrap = 0; /* used by _rl_get_screen_size */ + +#if defined (__EMX__) + _emx_get_screensize (&screenwidth, &screenheight); + screenwidth--; +#else /* !__EMX__ */ + _rl_get_screen_size (tty, 0); +#endif /* !__EMX__ */ + + /* Defaults. */ + if (screenwidth <= 0 || screenheight <= 0) + { + screenwidth = 79; + screenheight = 24; + } + + /* Everything below here is used by the redisplay code (tputs). */ + screenchars = screenwidth * screenheight; term_cr = "\r"; term_im = term_ei = term_ic = term_IC = (char *)NULL; term_up = term_dc = term_DC = visible_bell = (char *)NULL; term_ku = term_kd = term_kl = term_kr = (char *)NULL; + term_mm = term_mo = (char *)NULL; #if defined (HACK_TERMCAP_MOTION) term_forward_char = (char *)NULL; #endif - terminal_can_insert = 0; + terminal_can_insert = term_has_meta = 0; + + /* Reasonable defaults for tgoto(). Readline currently only uses + tgoto if term_IC or term_DC is defined, but just in case we + change that later... */ + PC = '\0'; + BC = term_backspace = "\b"; + UP = term_up; + return 0; } @@ -392,10 +394,6 @@ _rl_init_terminal_io (terminal_name) if (!term_cr) term_cr = "\r"; - tty = rl_instream ? fileno (rl_instream) : 0; - - screenwidth = screenheight = 0; - _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn"); _rl_get_screen_size (tty, 0); @@ -438,7 +436,6 @@ _rl_init_terminal_io (terminal_name) _rl_keymap = xkeymap; -#endif /* !__GO32__ */ return 0; } @@ -484,6 +481,7 @@ _rl_output_character_function (c) return putc (c, _rl_out_stream); } #endif /* !_MINIX */ + /* Write COUNT characters from STRING to the output stream. */ void _rl_output_some_chars (string, count) @@ -500,12 +498,10 @@ _rl_backspace (count) { register int i; -#if !defined (__GO32__) if (term_backspace) for (i = 0; i < count; i++) tputs (term_backspace, 1, _rl_output_character_function); else -#endif /* !__GO32__ */ for (i = 0; i < count; i++) putc ('\b', _rl_out_stream); return 0; @@ -535,16 +531,11 @@ ding () default: break; case VISIBLE_BELL: -#if defined (__GO32__) - ScreenVisualBell (); - break; -#else if (visible_bell) { tputs (visible_bell, 1, _rl_output_character_function); break; } -#endif /* FALLTHROUGH */ case AUDIBLE_BELL: fprintf (stderr, "\007"); @@ -565,7 +556,7 @@ ding () void _rl_enable_meta_key () { -#if !defined(__DJGPP__) +#if !defined (__DJGPP__) if (term_has_meta && term_mm) tputs (term_mm, 1, _rl_output_character_function); #endif @@ -575,9 +566,7 @@ void _rl_control_keypad (on) int on; { -#if defined(__DJGPP__) - on = on; -#else +#if !defined (__DJGPP__) if (on && term_ks) tputs (term_ks, 1, _rl_output_character_function); else if (!on && term_ke) |