Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // TextConsoleWin32.h: Win32 interface for the TextConsole class.
  9. //
  10. //////////////////////////////////////////////////////////////////////
  11. #if !defined TEXTCONSOLE_WIN32_H
  12. #define TEXTCONSOLE_WIN32_H
  13. #pragma once
  14. #ifdef _WIN32
  15. #include <windows.h>
  16. #include "TextConsole.h"
  17. #define MAX_CONSOLE_TEXTLEN 256
  18. #define MAX_BUFFER_LINES 30
  19. class CTextConsoleWin32 : public CTextConsole
  20. {
  21. public:
  22. CTextConsoleWin32();
  23. virtual ~CTextConsoleWin32() { };
  24. // CTextConsole
  25. bool Init();
  26. void ShutDown( void );
  27. void Print( char *pszMsg );
  28. void SetTitle( char * pszTitle );
  29. void SetStatusLine( char * pszStatus );
  30. void UpdateStatus( void );
  31. char * GetLine( int index, char *buf, int buflen );
  32. int GetWidth( void );
  33. void SetVisible( bool visible );
  34. protected:
  35. // CTextConsoleWin32
  36. void SetColor( WORD );
  37. void PrintRaw( const char * pszMsg, int nChars = -1 );
  38. private:
  39. char m_szConsoleText[ MAX_CONSOLE_TEXTLEN ]; // console text buffer
  40. int m_nConsoleTextLen; // console textbuffer length
  41. int m_nCursorPosition; // position in the current input line
  42. // Saved input data when scrolling back through command history
  43. char m_szSavedConsoleText[ MAX_CONSOLE_TEXTLEN ]; // console text buffer
  44. int m_nSavedConsoleTextLen; // console textbuffer length
  45. char m_aszLineBuffer[ MAX_BUFFER_LINES ][ MAX_CONSOLE_TEXTLEN ]; // command buffer last MAX_BUFFER_LINES commands
  46. int m_nInputLine; // Current line being entered
  47. int m_nBrowseLine; // current buffer line for up/down arrow
  48. int m_nTotalLines; // # of nonempty lines in the buffer
  49. int ReceiveNewline( void );
  50. void ReceiveBackspace( void );
  51. void ReceiveTab( void );
  52. void ReceiveStandardChar( const char ch );
  53. void ReceiveUpArrow( void );
  54. void ReceiveDownArrow( void );
  55. void ReceiveLeftArrow( void );
  56. void ReceiveRightArrow( void );
  57. private:
  58. HANDLE hinput; // standard input handle
  59. HANDLE houtput; // standard output handle
  60. WORD Attrib; // attrib colours for status bar
  61. char statusline[81]; // first line in console is status line
  62. };
  63. #endif // _WIN32
  64. #endif // !defined TEXTCONSOLE_WIN32_H