DOSBox-X
|
00001 /* 00002 * Copyright (C) 2002-2020 The DOSBox Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifdef WIN32 00020 00021 #include <windows.h> 00022 #include <stdio.h> 00023 #include <stdarg.h> 00024 00025 #ifndef min 00026 #define min(a,b) ((a)<(b)?(a):(b)) 00027 #endif 00028 00029 /* 00030 Have to remember where i ripped this code sometime ago. 00031 00032 */ 00033 static void ResizeConsole( HANDLE hConsole, SHORT xSize, SHORT ySize ) { 00034 CONSOLE_SCREEN_BUFFER_INFO csbi; // Hold Current Console Buffer Info 00035 SMALL_RECT srWindowRect; // Hold the New Console Size 00036 COORD coordScreen; 00037 00038 GetConsoleScreenBufferInfo( hConsole, &csbi ); 00039 00040 // Get the Largest Size we can size the Console Window to 00041 coordScreen = GetLargestConsoleWindowSize( hConsole ); 00042 00043 // Define the New Console Window Size and Scroll Position 00044 srWindowRect.Right = (SHORT)(min(xSize, coordScreen.X) - 1); 00045 srWindowRect.Bottom = (SHORT)(min(ySize, coordScreen.Y) - 1); 00046 srWindowRect.Left = srWindowRect.Top = (SHORT)0; 00047 00048 // Define the New Console Buffer Size 00049 coordScreen.X = xSize; 00050 coordScreen.Y = ySize; 00051 00052 // If the Current Buffer is Larger than what we want, Resize the 00053 // Console Window First, then the Buffer 00054 if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y > (DWORD) xSize * ySize) 00055 { 00056 SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect ); 00057 SetConsoleScreenBufferSize( hConsole, coordScreen ); 00058 } 00059 00060 // If the Current Buffer is Smaller than what we want, Resize the 00061 // Buffer First, then the Console Window 00062 if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y < (DWORD) xSize * ySize ) 00063 { 00064 SetConsoleScreenBufferSize( hConsole, coordScreen ); 00065 SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect ); 00066 } 00067 00068 // If the Current Buffer *is* the Size we want, Don't do anything! 00069 return; 00070 } 00071 00072 00073 void WIN32_Console() { 00074 AllocConsole(); 00075 SetConsoleTitle("DOSBox-X Debugger"); 00076 ResizeConsole(GetStdHandle(STD_OUTPUT_HANDLE),80,50); 00077 } 00078 #endif