* readline/terminal.c (_rl_get_screen_size): Get console size from
authorDaniel Jacobowitz <drow@false.org>
Thu, 23 Feb 2006 18:14:43 +0000 (18:14 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 23 Feb 2006 18:14:43 +0000 (18:14 +0000)
the Windows API when compiling with MinGW.

readline/ChangeLog.gdb
readline/terminal.c

index 7105ea387d936aad3506a1d44f1d7891882a8b79..28cb1f2ff359652e58b435ac07a77f5b2a7040ea 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-10  Denis Pilat  <denis.pilat@st.com>
+
+       * readline/terminal.c (_rl_get_screen_size): Get console size from
+       the Windows API when compiling with MinGW.
+
 2005-07-25  Mark Mitchell <mark@codesourcery.com>
 
        * input.c (rl_getc): Use getch to read console input on
index 06bc8e94d6b6da01523dc34f3970770c9496b547..ce45d28d02420dde7a52f42901295a40318a6156 100644 (file)
 #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)
 
@@ -209,6 +214,20 @@ _rl_get_screen_size (tty, ignore_env)
     }
 #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
This page took 0.02699 seconds and 4 git commands to generate.