Make roken build on windows

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
This commit is contained in:
Asanka Herath
2009-11-24 21:42:02 -08:00
committed by Love Hornquist Astrand
parent c4b95f7330
commit d00f9984a5
168 changed files with 3688 additions and 607 deletions

View File

@@ -57,7 +57,7 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
get_window_size(int fd, struct winsize *wp)
{
int ret = -1;
@@ -85,6 +85,20 @@ get_window_size(int fd, struct winsize *wp)
wp->ws_col = dst[0];
ret = 0;
}
#elif defined(_WIN32)
{
intptr_t fh = 0;
CONSOLE_SCREEN_BUFFER_INFO sb_info;
fh = _get_osfhandle(fd);
if (fh != (intptr_t) INVALID_HANDLE_VALUE &&
GetConsoleScreenBufferInfo((HANDLE) fh, &sb_info)) {
wp->ws_row = 1 + sb_info.srWindow.Bottom - sb_info.srWindow.Top;
wp->ws_col = 1 + sb_info.srWindow.Right - sb_info.srWindow.Left;
ret = 0;
}
}
#endif
if (ret != 0) {
char *s;