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.

117 lines
3.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* WinNT 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(WINNTSCR_HEADER_INCLUDED)
  6. #define WINNTSCR_HEADER_INCLUDED
  7. #define USE_NEW_BUFFER
  8. #define hCurrentOut hOut
  9. // virtual to avoid problems with multiple inheritance
  10. class TDisplayWinNT : virtual public TDisplay
  11. {
  12. protected:
  13. TDisplayWinNT() {};
  14. // We will use casts to base classes, destructors must be pointers
  15. virtual ~TDisplayWinNT();
  16. // This sets the pointers of TDisplay to point to this class
  17. static void Init();
  18. // Behaviors to replace TDisplay
  19. static void SetCursorPos(unsigned x, unsigned y);
  20. static void GetCursorPos(unsigned &x, unsigned &y);
  21. static void GetCursorShape(unsigned &start, unsigned &end);
  22. static void SetCursorShape(unsigned start, unsigned end);
  23. static ushort GetRows();
  24. static ushort GetCols();
  25. // Default static void SetCrtMode(ushort mode);
  26. // Default static void SetCrtModeExt(char *mode);
  27. // Not available static ushort getCrtMode();
  28. // Not implemented static int CheckForWindowSize(void);
  29. static const char
  30. *GetWindowTitle(void);
  31. static int SetWindowTitle(const char *name);
  32. static void ClearScreen(uchar w, uchar h);
  33. static void Beep();
  34. // Low level routines, doesn't use cached values
  35. static void GetCursorPosLow(unsigned &x, unsigned &y);
  36. static void GetCursorShapeLow(unsigned &start, unsigned &end);
  37. static void SetCursorShapeLow(unsigned start, unsigned end);
  38. static void SetCursorPosLow(unsigned x, unsigned y);
  39. // Variables for this driver
  40. // Input/output handles
  41. static HANDLE hOut,hIn;
  42. #ifdef USE_NEW_BUFFER
  43. static HANDLE hStdOut;
  44. #endif
  45. // Cursor position
  46. static unsigned currentCursorX,currentCursorY;
  47. // Cursor shape
  48. static unsigned curStart, curEnd;
  49. };
  50. // With this order the destructor will be called first for TScreenWin32,
  51. // TScreen, TDisplayWinNT and finally TDisplay.
  52. class TScreenWinNT : public TDisplayWinNT, public TScreen
  53. {
  54. public:
  55. TScreenWinNT();
  56. // We will use casts to base classes, destructors must be pointers
  57. virtual ~TScreenWinNT();
  58. static void YieldProcessor(int micros);
  59. friend class TGKeyWinNT;
  60. friend class THWMouseWinNT;
  61. friend class TDisplayWinNT;
  62. protected:
  63. static void Resume();
  64. static void Suspend();
  65. // Default: ushort fixCrtMode( ushort mode )
  66. // Default: static void setCrtData();
  67. // Default: static void clearScreen();
  68. // Default: static void setVideoMode(ushort mode);
  69. // Default: static void setVideoModeExt(char *mode);
  70. static void GetCharacters(unsigned offset,ushort *buf,unsigned count);
  71. static ushort GetCharacter(unsigned dst);
  72. static void SetCharacter(unsigned offset, ushort value);
  73. static void SetCharacters(unsigned dst, ushort *src, unsigned len);
  74. static int System(const char *command, pid_t *pidChild, int in, int out,
  75. int err);
  76. static int SetCrtModeRes(unsigned w, unsigned h, int fW=-1, int fH=-1);
  77. // Support functions
  78. #ifndef USE_NEW_BUFFER
  79. static void SaveScreen();
  80. static void SaveScreenReleaseMemory();
  81. static void RestoreScreen();
  82. #endif
  83. //static void ScreenUpdate();
  84. static BOOL WINAPI ConsoleEventHandler(DWORD dwCtrlType);
  85. static void ensureOutBufCapacity(unsigned count);
  86. // Initialization done at start
  87. static int InitOnce();
  88. // Support variables
  89. // Old console state
  90. #ifndef USE_NEW_BUFFER
  91. static ushort* saveScreenBuf;
  92. static unsigned saveScreenSize;
  93. static unsigned saveScreenCursorStart, saveScreenCursorEnd;
  94. static unsigned saveScreenCursorX, saveScreenCursorY;
  95. #endif
  96. static DWORD saveScreenConsoleMode;
  97. static unsigned saveScreenWidth, saveScreenHeight;
  98. // Buffer used to arrange the data as needed by Win32 API
  99. static CHAR* outBuf;
  100. static WORD* outBufAttr;
  101. static CHAR_INFO* outBufCI;
  102. static unsigned outBufCapacity;
  103. };
  104. #endif // WINNTSCR_HEADER_INCLUDED