summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2006-02-23 18:14:43 +0000
committerDaniel Jacobowitz <dan@debian.org>2006-02-23 18:14:43 +0000
commit172026c897a27a558d3dcf69b12cf37993fc4c2f (patch)
tree8d8fbaa07ea327b7b31f048061bc0bed3d4bf970
parent729522ed12640e5a7c6bd8b1c6543b198057c36e (diff)
downloadgdb-172026c897a27a558d3dcf69b12cf37993fc4c2f.tar.gz
* readline/terminal.c (_rl_get_screen_size): Get console size from
the Windows API when compiling with MinGW.
-rw-r--r--readline/ChangeLog.gdb5
-rw-r--r--readline/terminal.c19
2 files changed, 24 insertions, 0 deletions
diff --git a/readline/ChangeLog.gdb b/readline/ChangeLog.gdb
index 7105ea387d9..28cb1f2ff35 100644
--- a/readline/ChangeLog.gdb
+++ b/readline/ChangeLog.gdb
@@ -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
diff --git a/readline/terminal.c b/readline/terminal.c
index 06bc8e94d6b..ce45d28d024 100644
--- a/readline/terminal.c
+++ b/readline/terminal.c
@@ -70,6 +70,11 @@
#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