0a1
> /* $FreeBSD: head/contrib/libreadline/terminal.c 58314 2000-03-19 22:00:57Z ache $ */
10c11
< as published by the Free Software Foundation; either version 1, or
---
> as published by the Free Software Foundation; either version 2, or
21c22
< 675 Mass Ave, Cambridge, MA 02139, USA. */
---
> 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
49d49
< #include <signal.h>
51d50
< #include <setjmp.h>
67,71c66,67
< /* 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;
---
> #include "rlprivate.h"
> #include "rlshell.h"
73,79d68
< /* 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 ();
<
151a141,156
> #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
>
164,166d168
< #if defined (__EMX__)
< int sz[2];
< #endif
177,179c179
< _scrsize (sz);
< screenwidth = sz[0];
< screenheight = sz[1];
---
> _emx_get_screensize (&screenwidth, &screenheight);
188a189
> #if !defined (__DJGPP__)
190a192
> #endif
199a202
> #if !defined (__DJGPP__)
201a205
> #endif
216c220
< if (!_rl_term_autowrap)
---
> if (_rl_term_autowrap == 0)
254,273c258,277
< "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 */
< "@7", &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 */
> { "@7", &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 },
275c279
< "nd", &term_forward_char,
---
> { "nd", &term_forward_char },
277,279c281,283
< "pc", &term_pc,
< "up", &term_up,
< "vb", &visible_bell,
---
> { "pc", &term_pc },
> { "up", &term_up },
> { "vb", &visible_bell },
289a294
> #if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
293a299
> #endif
296a303,305
> #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
> #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
>
301,322d309
< #if defined (__GO32__)
< screenwidth = ScreenCols ();
< screenheight = ScreenRows ();
< 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;
<
< /* 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;
< #else /* !__GO32__ */
<
324c311
< int tty;
---
> int tty, tgetent_ret;
327a315,317
> term_clrpag = term_cr = term_clreol = (char *)NULL;
> tty = rl_instream ? fileno (rl_instream) : 0;
> screenwidth = screenheight = 0;
329,330c319,320
< if (term_string_buffer == 0)
< term_string_buffer = xmalloc (2032);
---
> if (term == 0)
> term = "dumb";
332,333c322,332
< 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);
335c334,335
< buffer = term_string_buffer;
---
> if (term_buffer == 0)
> term_buffer = xmalloc(4080);
337c337
< term_clrpag = term_cr = term_clreol = (char *)NULL;
---
> buffer = term_string_buffer;
339,340c339,340
< if (term == 0)
< term = "dumb";
---
> tgetent_ret = tgetent (term_buffer, term);
> }
342c342
< if (tgetent (term_buffer, term) <= 0)
---
> if (tgetent_ret <= 0)
343a344,347
> FREE (term_string_buffer);
> FREE (term_buffer);
> buffer = term_buffer = term_string_buffer = (char *)NULL;
>
345,347c349,366
< 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;
351a371
> term_mm = term_mo = (char *)NULL;
355c375,383
< 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;
>
370,373d397
< tty = rl_instream ? fileno (rl_instream) : 0;
<
< screenwidth = screenheight = 0;
<
416d439
< #endif /* !__GO32__ */
461a485
>
478d501
< #if !defined (__GO32__)
483d505
< #endif /* !__GO32__ */
507d528
< #if !defined (__GO32__)
525,528d545
< #else /* __GO32__ */
< fprintf (stderr, "\007");
< fflush (stderr);
< #endif /* __GO32__ */
542a560
> #if !defined (__DJGPP__)
544a563
> #endif
550a570
> #if !defined (__DJGPP__)
554a575
> #endif
> /* $FreeBSD: head/contrib/libreadline/terminal.c 58314 2000-03-19 22:00:57Z ache $ */
10c11
< as published by the Free Software Foundation; either version 1, or
---
> as published by the Free Software Foundation; either version 2, or
21c22
< 675 Mass Ave, Cambridge, MA 02139, USA. */
---
> 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
49d49
< #include <signal.h>
51d50
< #include <setjmp.h>
67,71c66,67
< /* 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;
---
> #include "rlprivate.h"
> #include "rlshell.h"
73,79d68
< /* 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 ();
<
151a141,156
> #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
>
164,166d168
< #if defined (__EMX__)
< int sz[2];
< #endif
177,179c179
< _scrsize (sz);
< screenwidth = sz[0];
< screenheight = sz[1];
---
> _emx_get_screensize (&screenwidth, &screenheight);
188a189
> #if !defined (__DJGPP__)
190a192
> #endif
199a202
> #if !defined (__DJGPP__)
201a205
> #endif
216c220
< if (!_rl_term_autowrap)
---
> if (_rl_term_autowrap == 0)
254,273c258,277
< "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 */
< "@7", &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 */
> { "@7", &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 },
275c279
< "nd", &term_forward_char,
---
> { "nd", &term_forward_char },
277,279c281,283
< "pc", &term_pc,
< "up", &term_up,
< "vb", &visible_bell,
---
> { "pc", &term_pc },
> { "up", &term_up },
> { "vb", &visible_bell },
289a294
> #if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
293a299
> #endif
296a303,305
> #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
> #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
>
301,322d309
< #if defined (__GO32__)
< screenwidth = ScreenCols ();
< screenheight = ScreenRows ();
< 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;
<
< /* 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;
< #else /* !__GO32__ */
<
324c311
< int tty;
---
> int tty, tgetent_ret;
327a315,317
> term_clrpag = term_cr = term_clreol = (char *)NULL;
> tty = rl_instream ? fileno (rl_instream) : 0;
> screenwidth = screenheight = 0;
329,330c319,320
< if (term_string_buffer == 0)
< term_string_buffer = xmalloc (2032);
---
> if (term == 0)
> term = "dumb";
332,333c322,332
< 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);
335c334,335
< buffer = term_string_buffer;
---
> if (term_buffer == 0)
> term_buffer = xmalloc(4080);
337c337
< term_clrpag = term_cr = term_clreol = (char *)NULL;
---
> buffer = term_string_buffer;
339,340c339,340
< if (term == 0)
< term = "dumb";
---
> tgetent_ret = tgetent (term_buffer, term);
> }
342c342
< if (tgetent (term_buffer, term) <= 0)
---
> if (tgetent_ret <= 0)
343a344,347
> FREE (term_string_buffer);
> FREE (term_buffer);
> buffer = term_buffer = term_string_buffer = (char *)NULL;
>
345,347c349,366
< 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;
351a371
> term_mm = term_mo = (char *)NULL;
355c375,383
< 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;
>
370,373d397
< tty = rl_instream ? fileno (rl_instream) : 0;
<
< screenwidth = screenheight = 0;
<
416d439
< #endif /* !__GO32__ */
461a485
>
478d501
< #if !defined (__GO32__)
483d505
< #endif /* !__GO32__ */
507d528
< #if !defined (__GO32__)
525,528d545
< #else /* __GO32__ */
< fprintf (stderr, "\007");
< fflush (stderr);
< #endif /* __GO32__ */
542a560
> #if !defined (__DJGPP__)
544a563
> #endif
550a570
> #if !defined (__DJGPP__)
554a575
> #endif