29 #include "../../idlib/precompiled.h"
48 #define ERRORBOX_ID 10
49 #define ERRORTEXT_ID 11
54 #define COMMAND_HISTORY 64
80 char consoleText[512], returnedText[512];
100 static bool s_timePolarity;
104 if ( LOWORD( wParam ) != WA_INACTIVE ) {
113 PostQuitMessage( 0 );
119 case WM_CTLCOLORSTATIC:
121 SetBkColor( (
HDC ) wParam, RGB( 0x00, 0x00, 0x80 ) );
122 SetTextColor( (
HDC ) wParam, RGB( 0xff, 0xff, 0x00 ) );
125 if ( s_timePolarity & 1 ) {
126 SetBkColor( (
HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
127 SetTextColor( (
HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) );
129 SetBkColor( (
HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
130 SetTextColor( (
HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) );
136 if ( wParam == SC_CLOSE ) {
137 PostQuitMessage( 0 );
142 SendMessage( s_wcd.
hwndBuffer, EM_SETSEL, 0, -1 );
143 SendMessage( s_wcd.
hwndBuffer, WM_COPY, 0, 0 );
144 }
else if ( wParam ==
QUIT_ID ) {
146 PostQuitMessage( 0 );
152 SendMessage( s_wcd.
hwndBuffer, EM_SETSEL, 0, -1 );
160 SetTimer( hWnd, 1, 1000,
NULL );
184 s_timePolarity = (
bool)!s_timePolarity;
192 return DefWindowProc( hWnd, uMsg, wParam, lParam );
199 if ( ( HWND ) wParam == s_wcd.
hWnd || ( HWND ) wParam == s_wcd.
hwndErrorBox ) {
259 if ( key ==
K_TAB ) {
290 int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;
293 memset( &wc, 0,
sizeof( wc ) );
296 wc.lpfnWndProc = (WNDPROC) ConWndProc;
301 wc.hCursor = LoadCursor (
NULL,IDC_ARROW);
302 wc.hbrBackground = (
struct HBRUSH__ *)COLOR_WINDOW;
304 wc.lpszClassName = DEDCLASS;
306 if ( !RegisterClass (&wc) ) {
314 AdjustWindowRect( &rect, DEDSTYLE,
FALSE );
316 hDC = GetDC( GetDesktopWindow() );
317 swidth = GetDeviceCaps( hDC, HORZRES );
318 sheight = GetDeviceCaps( hDC, VERTRES );
319 ReleaseDC( GetDesktopWindow(), hDC );
326 s_wcd.
hWnd = CreateWindowEx( 0,
330 ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
343 hDC = GetDC( s_wcd.
hWnd );
344 nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY ), 72 );
346 s_wcd.
hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH,
"Courier New" );
348 ReleaseDC( s_wcd.
hWnd, hDC );
353 s_wcd.
hwndInputLine = CreateWindow(
"edit",
NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
354 ES_LEFT | ES_AUTOHSCROLL,
363 s_wcd.
hwndButtonCopy = CreateWindow(
"button",
NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
370 s_wcd.
hwndButtonClear = CreateWindow(
"button",
NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
377 s_wcd.
hwndButtonQuit = CreateWindow(
"button",
NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
388 s_wcd.
hwndBuffer = CreateWindow(
"edit",
NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER |
389 ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
401 ShowWindow( s_wcd.
hWnd, SW_SHOWDEFAULT);
402 UpdateWindow( s_wcd.
hWnd );
403 SetForegroundWindow( s_wcd.
hWnd );
421 ShowWindow( s_wcd.
hWnd, SW_HIDE );
422 CloseWindow( s_wcd.
hWnd );
423 DestroyWindow( s_wcd.
hWnd );
439 switch ( visLevel ) {
441 ShowWindow( s_wcd.
hWnd, SW_HIDE );
444 ShowWindow( s_wcd.
hWnd, SW_SHOWNORMAL );
445 SendMessage( s_wcd.
hwndBuffer, EM_LINESCROLL, 0, 0xffff );
448 ShowWindow( s_wcd.
hWnd, SW_MINIMIZE );
451 Sys_Error(
"Invalid visLevel %d sent to Sys_ShowConsole\n", visLevel );
476 #define CONSOLE_BUFFER_SIZE 16384
483 static unsigned long s_totalChars;
497 while ( msg[i] && ( ( b - buffer ) <
sizeof( buffer ) - 1 ) ) {
498 if ( msg[i] ==
'\n' && msg[i+1] ==
'\r' ) {
503 }
else if ( msg[i] ==
'\r' ) {
507 }
else if ( msg[i] ==
'\n' ) {
522 s_totalChars += bufLen;
527 if ( s_totalChars > 0x7000 ) {
528 SendMessage( s_wcd.
hwndBuffer, EM_SETSEL, 0, -1 );
529 s_totalChars = bufLen;
535 SendMessage( s_wcd.
hwndBuffer, EM_LINESCROLL, 0, 0xffff );
536 SendMessage( s_wcd.
hwndBuffer, EM_SCROLLCARET, 0, 0 );
546 s_wcd.
hwndErrorBox = CreateWindow(
"static",
NULL, WS_CHILD | WS_VISIBLE | SS_SUNKEN,
#define CONSOLE_BUFFER_SIZE
idCVar com_skipRenderer("com_skipRenderer","0", CVAR_BOOL|CVAR_SYSTEM,"skip the renderer completely")
idCVarSystem * cvarSystem
int GetCursor(void) const
virtual bool IsInitialized(void) const =0
void Win_SetErrorText(const char *buf)
CONST PIXELFORMATDESCRIPTOR UINT
void Sys_Printf(const char *msg,...)
void Sys_ShowConsole(int visLevel, bool quitOnClose)
void ClearAutoComplete(void)
void Sys_DestroyConsole(void)
WNDPROC SysInputLineWndProc
static idCVar win_viewlog
char * Sys_ConsoleInput(void)
static void Copynz(char *dest, const char *src, int destsize)
void Sys_QueEvent(int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr)
#define WIN32_CONSOLE_CLASS
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
void Conbuf_AppendText(const char *pMsg)
idEditField historyEditLines[COMMAND_HISTORY]
void SetBool(const bool value)
void Sys_Error(const char *error,...)
void Sys_CreateConsole(void)
char * Mem_CopyString(const char *in)
HBRUSH hbrErrorBackground
LONG WINAPI InputLineWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)