# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
+#ifdef __MSDOS__
+# include <pc.h>
+#endif
+
#include "rltty.h"
#include "tcap.h"
#include "rlshell.h"
#include "xmalloc.h"
+#if defined (__MINGW32__)
+# include <windows.h>
+# include <wincon.h>
+#endif
+
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
/* */
/* **************************************************************** */
+#ifndef __MSDOS__
static char *term_buffer = (char *)NULL;
static char *term_string_buffer = (char *)NULL;
+#endif /* !__MSDOS__ */
static int tcap_initialized;
static char *_rl_visible_bell;
/* Non-zero means the terminal can auto-wrap lines. */
-int _rl_term_autowrap;
+int _rl_term_autowrap = -1;
/* Non-zero means that this terminal has a meta key. */
static int term_has_meta;
}
#endif /* TIOCGWINSZ */
+ /* For MinGW, we get the console size from the Windows API. */
+#if defined (__MINGW32__)
+ HANDLE hConOut = GetStdHandle (STD_OUTPUT_HANDLE);
+ if (hConOut != INVALID_HANDLE_VALUE)
+ {
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+ if (GetConsoleScreenBufferInfo (hConOut, &scr))
+ {
+ _rl_screenwidth = scr.dwSize.X;
+ _rl_screenheight = scr.srWindow.Bottom - scr.srWindow.Top + 1;
+ }
+ }
+#endif
+
#if defined (__EMX__)
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
#endif
if (_rl_screenwidth <= 0)
_rl_screenwidth = wc;
-#if !defined (__DJGPP__)
+#if defined (__DJGPP__)
+ if (_rl_screenwidth <= 0)
+ _rl_screenwidth = ScreenCols ();
+#else
if (_rl_screenwidth <= 0 && term_string_buffer)
_rl_screenwidth = tgetnum ("co");
#endif
if (_rl_screenheight <= 0)
_rl_screenheight = wr;
-#if !defined (__DJGPP__)
+#if defined (__DJGPP__)
+ if (_rl_screenheight <= 0)
+ _rl_screenheight = ScreenRows ();
+#else
if (_rl_screenheight <= 0 && term_string_buffer)
_rl_screenheight = tgetnum ("li");
#endif
_rl_set_screen_size (rows, cols)
int rows, cols;
{
+ if (_rl_term_autowrap == -1)
+ _rl_init_terminal_io (rl_terminal_name);
+
if (rows > 0)
_rl_screenheight = rows;
if (cols > 0)
if (term == 0)
term = "dumb";
+#ifdef __MSDOS__
+ _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
+ _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
+ _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
+ _rl_term_mm = _rl_term_mo = (char *)NULL;
+ _rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
+ _rl_term_cr = "\r";
+ _rl_term_clreol = _rl_term_clrpag = _rl_term_backspace = (char *)NULL;
+ _rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
+ _rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
+ _rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
+#if defined(HACK_TERMCAP_MOTION)
+ _rl_term_forward_char = (char *)NULL;
+#endif
+
+ _rl_get_screen_size (tty, 0);
+#else /* !__MSDOS__ */
/* 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 (!term_has_meta)
_rl_term_mm = _rl_term_mo = (char *)NULL;
+#endif /* !__MSDOS__ */
+
/* Attempt to find and bind the arrow keys. Do not override already
bound keys in an overzealous attempt, however. */
{
register int i;
+#ifndef __MSDOS__
if (_rl_term_backspace)
for (i = 0; i < count; i++)
tputs (_rl_term_backspace, 1, _rl_output_character_function);
else
+#endif
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
default:
break;
case VISIBLE_BELL:
+#ifdef __MSDOS__
+ ScreenVisualBell ();
+ break;
+#else
if (_rl_visible_bell)
{
tputs (_rl_visible_bell, 1, _rl_output_character_function);
break;
}
/* FALLTHROUGH */
+#endif
case AUDIBLE_BELL:
fprintf (stderr, "\007");
fflush (stderr);
_rl_set_cursor (im, force)
int im, force;
{
+#ifndef __MSDOS__
if (_rl_term_ve && _rl_term_vs)
{
if (force || im != rl_insert_mode)
tputs (_rl_term_ve, 1, _rl_output_character_function);
}
}
+#endif
}