Debian Codegraph @

src/debug/debug_win32.cpp

raw
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #ifdef WIN32
20
21 #include <windows.h>
22 #include <stdio.h>
23 #include <stdarg.h>
24
25 #ifndef min
26 #define min(a,b) ((a)<(b)?(a):(b))
27 #endif
28
29 /*
30 Have to remember where i ripped this code sometime ago.
31
32 */
33 static void ResizeConsole( HANDLE hConsole, SHORT xSize, SHORT ySize ) {
34 CONSOLE_SCREEN_BUFFER_INFO csbi; // Hold Current Console Buffer Info
35 BOOL bSuccess;
36 SMALL_RECT srWindowRect; // Hold the New Console Size
37 COORD coordScreen;
38
39 bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
40
41 // Get the Largest Size we can size the Console Window to
42 coordScreen = GetLargestConsoleWindowSize( hConsole );
43
44 // Define the New Console Window Size and Scroll Position
45 srWindowRect.Right = (SHORT)(min(xSize, coordScreen.X) - 1);
46 srWindowRect.Bottom = (SHORT)(min(ySize, coordScreen.Y) - 1);
47 srWindowRect.Left = srWindowRect.Top = (SHORT)0;
48
49 // Define the New Console Buffer Size
50 coordScreen.X = xSize;
51 coordScreen.Y = ySize;
52
53 // If the Current Buffer is Larger than what we want, Resize the
54 // Console Window First, then the Buffer
55 if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y > (DWORD) xSize * ySize)
56 {
57 bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect );
58 bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen );
59 }
60
61 // If the Current Buffer is Smaller than what we want, Resize the
62 // Buffer First, then the Console Window
63 if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y < (DWORD) xSize * ySize )
64 {
65 bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen );
66 bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect );
67 }
68
69 // If the Current Buffer *is* the Size we want, Don't do anything!
70 return;
71 }
72
73
74 void WIN32_Console() {
75 AllocConsole();
76 SetConsoleTitle("DOSBox Debugger");
77 ResizeConsole(GetStdHandle(STD_OUTPUT_HANDLE),80,50);
78 }
79 #endif