From e92805126abbe811958f6cbd24f7a5ee8680ace6 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Wed, 27 Mar 2013 22:25:13 +1100 Subject: Improve kernel32 console.c --- dlls/kernel32/console.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index d6d1414..9814895 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -1362,6 +1362,26 @@ DWORD WINAPI GetConsoleTitleW(LPWSTR title, DWORD size) return ret; } +/*********************************************************************** + * GetLargestConsoleWindowSize_helper + */ + +COORD GetLargestConsoleWindowSize_helper(HANDLE hConsoleOutput) +{ + int screen_width; + int screen_height; + COORD console_fontsize; + COORD max_console; + + GetDesktopScreenSize(&screen_width, &screen_height); + + console_fontsize = GetConsoleFontSize(hConsoleOutput, 0); + + max_console.X = (screen_width / console_fontsize.X) - 6; + max_console.Y = (screen_height / console_fontsize.Y) - 5; + + return max_console; +} /*********************************************************************** * GetLargestConsoleWindowSize (KERNEL32.@) @@ -1380,8 +1400,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD c; DWORD w; } x; - x.c.X = 80; - x.c.Y = 24; + x.c = GetLargestConsoleWindowSize_helper(hConsoleOutput); TRACE("(%p), returning %dx%d (%x)\n", hConsoleOutput, x.c.X, x.c.Y, x.w); return x.w; } @@ -1401,8 +1420,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) { COORD c; - c.X = 80; - c.Y = 24; + c = GetLargestConsoleWindowSize_helper(hConsoleOutput); TRACE("(%p), returning %dx%d\n", hConsoleOutput, c.X, c.Y); return c; } @@ -3244,20 +3262,21 @@ DWORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font) FIXME(": (%p, %d) stub!\n", hConsole, font); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - x.c.X = 0; - x.c.Y = 0; + /* Use defaults: each cell is 8 pixels wide and 16 pixels tall */ + x.c.X = 8; + x.c.Y = 16; + return x.w; } #endif /* defined(__i386__) */ - #ifndef __i386__ COORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font) { COORD c; c.X = 80; c.Y = 24; - FIXME(": (%p, %d) stub!\n", hConsole, font); + FIXME(": (%p, %d) stub!\n", hConsole, font); return c; } #endif /* defined(__i386__) */ -- 1.7.10.4