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.

97 lines
3.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* Win32 screen routines header.
  2. Copyright (c) 2002 by Salvador E. Tropea (SET)
  3. Covered by the GPL license. */
  4. // This headers needs windows header
  5. #if defined(TVOS_Win32) && !defined(WIN32SCR_HEADER_INCLUDED)
  6. #define WIN32SCR_HEADER_INCLUDED
  7. // virtual to avoid problems with multiple inheritance
  8. class TDisplayWin32 : virtual public TDisplay
  9. {
  10. protected:
  11. TDisplayWin32() {};
  12. // We will use casts to base classes, destructors must be pointers
  13. virtual ~TDisplayWin32();
  14. // This sets the pointers of TDisplay to point to this class
  15. static void Init();
  16. // Behaviors to replace TDisplay
  17. static void SetCursorPos(unsigned x, unsigned y);
  18. static void GetCursorPos(unsigned &x, unsigned &y);
  19. static void GetCursorShape(unsigned &start, unsigned &end);
  20. static void SetCursorShape(unsigned start, unsigned end);
  21. static ushort GetRows();
  22. static ushort GetCols();
  23. // Not available static void setCrtMode(ushort mode);
  24. // Not available static ushort getCrtMode();
  25. // Not available static void SetCrtModeExt(char *mode);
  26. static int CheckForWindowSize(void);
  27. static const char *GetWindowTitle(void);
  28. static int SetWindowTitle(const char *name);
  29. static void SetCrtMode(ushort);
  30. static void SetCrtModeExt(char *);
  31. static void Beep();
  32. // Variables for this driver
  33. // Input/output handles
  34. static HANDLE hOut,hIn;
  35. static HANDLE hStdOut;
  36. // Console information
  37. static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
  38. // Cursor information
  39. static CONSOLE_CURSOR_INFO ConsoleCursorInfo;
  40. // Lock for the WindowSizeChanged variable
  41. static CRITICAL_SECTION lockWindowSizeChanged;
  42. // Used to indicate a window size change
  43. static int WindowSizeChanged;
  44. };
  45. // With this order the destructor will be called first for TScreenWin32,
  46. // TScreen, TDisplayWin32 and finally TDisplay.
  47. class TScreenWin32 : public TDisplayWin32, public TScreen
  48. {
  49. public:
  50. TScreenWin32();
  51. // We will use casts to base classes, destructors must be pointers
  52. virtual ~TScreenWin32();
  53. friend class TGKeyWin32;
  54. friend class THWMouseWin32;
  55. friend class TDisplayWin32;
  56. protected:
  57. static void Resume();
  58. static void Suspend();
  59. // Default: ushort fixCrtMode( ushort mode )
  60. // Default: static void setCrtData();
  61. static void clearScreen();
  62. // Default: static void setVideoMode(ushort mode);
  63. // Default: static void setVideoModeExt(char *mode);
  64. // Default: static void getCharacters(unsigned offset,ushort *buf,unsigned count);
  65. // Default: static ushort getCharacter(unsigned dst);
  66. static void setCharacter(unsigned offset, ushort value);
  67. static void setCharacters(unsigned dst, ushort *src, unsigned len);
  68. static int System(const char *command, pid_t *pidChild, int in, int out,
  69. int err);
  70. static int SetCrtModeRes(unsigned w, unsigned h, int fW=-1, int fH=-1);
  71. static int SetVideoModeRes(unsigned w, unsigned h, int fW=-1, int fH=-1);
  72. // Support functions
  73. static int InitConsole();
  74. static void DoneConsole();
  75. static DWORD WINAPI HandleEvents(void* p);
  76. static BOOL WINAPI ConsoleEventHandler(DWORD dwCtrlType);
  77. // Support variables
  78. static CONSOLE_SCREEN_BUFFER_INFO info;
  79. // Flag to stop the events thread
  80. static int ExitEventThread;
  81. // Handler for the events thread
  82. static HANDLE EventThreadHandle;
  83. static DWORD oldConsoleMode, newConsoleMode;
  84. static unsigned xCurStart, yCurStart;
  85. static unsigned saveScreenWidth, saveScreenHeight;
  86. };
  87. #endif // WIN32SCR_HEADER_INCLUDED