diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /dedicated/console/TextConsoleWin32.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'dedicated/console/TextConsoleWin32.h')
| -rw-r--r-- | dedicated/console/TextConsoleWin32.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/dedicated/console/TextConsoleWin32.h b/dedicated/console/TextConsoleWin32.h new file mode 100644 index 0000000..4c762ec --- /dev/null +++ b/dedicated/console/TextConsoleWin32.h @@ -0,0 +1,82 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// TextConsoleWin32.h: Win32 interface for the TextConsole class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined TEXTCONSOLE_WIN32_H +#define TEXTCONSOLE_WIN32_H +#pragma once + +#ifdef _WIN32 + +#include <windows.h> +#include "TextConsole.h" + +#define MAX_CONSOLE_TEXTLEN 256 +#define MAX_BUFFER_LINES 30 + +class CTextConsoleWin32 : public CTextConsole +{ +public: + CTextConsoleWin32(); + virtual ~CTextConsoleWin32() { }; + + // CTextConsole + bool Init(); + void ShutDown( void ); + void Print( char *pszMsg ); + + void SetTitle( char * pszTitle ); + void SetStatusLine( char * pszStatus ); + void UpdateStatus( void ); + + char * GetLine( int index, char *buf, int buflen ); + int GetWidth( void ); + + void SetVisible( bool visible ); + +protected: + // CTextConsoleWin32 + void SetColor( WORD ); + void PrintRaw( const char * pszMsg, int nChars = -1 ); + +private: + char m_szConsoleText[ MAX_CONSOLE_TEXTLEN ]; // console text buffer + int m_nConsoleTextLen; // console textbuffer length + int m_nCursorPosition; // position in the current input line + + // Saved input data when scrolling back through command history + char m_szSavedConsoleText[ MAX_CONSOLE_TEXTLEN ]; // console text buffer + int m_nSavedConsoleTextLen; // console textbuffer length + + char m_aszLineBuffer[ MAX_BUFFER_LINES ][ MAX_CONSOLE_TEXTLEN ]; // command buffer last MAX_BUFFER_LINES commands + int m_nInputLine; // Current line being entered + int m_nBrowseLine; // current buffer line for up/down arrow + int m_nTotalLines; // # of nonempty lines in the buffer + + int ReceiveNewline( void ); + void ReceiveBackspace( void ); + void ReceiveTab( void ); + void ReceiveStandardChar( const char ch ); + void ReceiveUpArrow( void ); + void ReceiveDownArrow( void ); + void ReceiveLeftArrow( void ); + void ReceiveRightArrow( void ); + +private: + HANDLE hinput; // standard input handle + HANDLE houtput; // standard output handle + WORD Attrib; // attrib colours for status bar + + char statusline[81]; // first line in console is status line +}; + +#endif // _WIN32 + +#endif // !defined TEXTCONSOLE_WIN32_H |