Leaked source code of windows server 2003
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.

270 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. output.h
  5. Abstract:
  6. This module contains the internal structures and definitions used
  7. by the output (screen) component of the NT console subsystem.
  8. Author:
  9. Therese Stowell (thereses) 12-Nov-1990
  10. Revision History:
  11. --*/
  12. // the characters of one row of screen buffer
  13. // we keep the following values so that we don't write
  14. // more pixels to the screen than we have to:
  15. // left is initialized to screenbuffer width. right is
  16. // initialized to zero.
  17. //
  18. // [ foo.bar 12-12-61 ]
  19. // ^ ^ ^ ^
  20. // | | | |
  21. // Chars Left Right end of Chars buffer
  22. typedef struct _CHAR_ROW {
  23. SHORT Right; // one past rightmost bound of chars in Chars array (array will be full width)
  24. SHORT OldRight; // old one past rightmost bound of chars in Chars array (array will be full width)
  25. SHORT Left; // leftmost bound of chars in Chars array (array will be full width)
  26. SHORT OldLeft; // old leftmost bound of chars in Chars array (array will be full width)
  27. PWCHAR Chars; // all chars in row up to last non-space char
  28. #if defined(FE_SB)
  29. PBYTE KAttrs; // all DBCS lead & trail bit in row
  30. #define ATTR_LEADING_BYTE 0x01
  31. #define ATTR_TRAILING_BYTE 0x02
  32. #define ATTR_DBCSSBCS_BYTE 0x03
  33. #define ATTR_SEPARATE_BYTE 0x10
  34. #define ATTR_EUDCFLAG_BYTE 0x20
  35. #endif
  36. } CHAR_ROW, *PCHAR_ROW;
  37. // run-length encoded data structure for attributes
  38. typedef struct _ATTR_PAIR {
  39. SHORT Length; // number of times attribute appears
  40. WORD Attr; // attribute
  41. } ATTR_PAIR, *PATTR_PAIR;
  42. // the attributes of one row of screen buffer
  43. typedef struct _ATTR_ROW {
  44. SHORT Length; // length of attr pair array
  45. ATTR_PAIR AttrPair; // use this if only one pair
  46. PATTR_PAIR Attrs; // attr pair array
  47. } ATTR_ROW, *PATTR_ROW;
  48. // information associated with one row of screen buffer
  49. typedef struct _ROW {
  50. CHAR_ROW CharRow;
  51. ATTR_ROW AttrRow;
  52. } ROW, *PROW;
  53. #if defined(FE_SB)
  54. typedef struct _DBCS_SCREEN_BUFFER {
  55. /*
  56. * all DBCS lead & trail bit buffer
  57. */
  58. PBYTE KAttrRows;
  59. /*
  60. * Temporary buffer for translate Unicode<--ASCII.
  61. *
  62. * Used as follows routine:
  63. * WriteOutputString
  64. * WriteRegionToScreen
  65. * DoWriteConsole
  66. */
  67. PWCHAR TransBufferCharacter;
  68. PBYTE TransBufferAttribute;
  69. /*
  70. * Used as follows routine:
  71. * SrvWriteConsole
  72. */
  73. PWCHAR TransWriteConsole;
  74. } DBCS_SCREEN_BUFFER, *PDBCS_SCREEN_BUFFER;
  75. #endif
  76. typedef struct _TEXT_BUFFER_FONT_INFO {
  77. struct _TEXT_BUFFER_FONT_INFO *NextTextBufferFont;
  78. COORD FontSize; // Desired size. Pixels (x,y) or Points (0, -p)
  79. DWORD FontNumber; // index into fontinfo[] - sometimes out of date
  80. WCHAR FaceName[LF_FACESIZE];
  81. LONG Weight;
  82. BYTE Family;
  83. UINT FontCodePage; // Code page for this font
  84. } TEXT_BUFFER_FONT_INFO, *PTEXT_BUFFER_FONT_INFO;
  85. typedef struct _TEXT_BUFFER_INFO {
  86. PROW Rows;
  87. PWCHAR TextRows;
  88. SHORT FirstRow; // indexes top row (not necessarily 0)
  89. BOOLEAN CursorMoved;
  90. BOOLEAN CursorVisible; // whether cursor is visible (set by user)
  91. BOOLEAN CursorOn; // whether blinking cursor is on or not
  92. BOOLEAN DoubleCursor; // whether the cursor size should be doubled
  93. BOOLEAN DelayCursor; // don't toggle cursor on next timer message
  94. COORD CursorPosition; // current position on screen (in screen buffer coords).
  95. ULONG CursorSize;
  96. WORD CursorYSize;
  97. WORD UpdatingScreen; // whether cursor is visible (set by console)
  98. ULONG ModeIndex; // fullscreen font and mode
  99. #ifdef i386
  100. // the following fields are used only by fullscreen textmode
  101. COORD WindowedWindowSize; // window size in windowed mode
  102. COORD WindowedScreenSize; // screen buffer size in windowed mode
  103. COORD MousePosition;
  104. #endif
  105. ULONG Flags; // indicate screen update hint state
  106. PTEXT_BUFFER_FONT_INFO ListOfTextBufferFont;
  107. TEXT_BUFFER_FONT_INFO CurrentTextBufferFont;
  108. #if defined(FE_SB)
  109. BOOLEAN CursorBlink;
  110. BOOLEAN CursorDBEnable;
  111. DBCS_SCREEN_BUFFER DbcsScreenBuffer;
  112. #endif
  113. } TEXT_BUFFER_INFO, *PTEXT_BUFFER_INFO;
  114. typedef struct _GRAPHICS_BUFFER_INFO {
  115. ULONG BitMapInfoLength;
  116. LPBITMAPINFO lpBitMapInfo;
  117. PVOID BitMap;
  118. PVOID ClientBitMap;
  119. HANDLE ClientProcess;
  120. HANDLE hMutex;
  121. HANDLE hSection;
  122. DWORD dwUsage;
  123. } GRAPHICS_BUFFER_INFO, *PGRAPHICS_BUFFER_INFO;
  124. #define CONSOLE_TEXTMODE_BUFFER 1
  125. #define CONSOLE_GRAPHICS_BUFFER 2
  126. #define CONSOLE_OEMFONT_DISPLAY 4
  127. typedef struct _SCREEN_INFORMATION {
  128. struct _CONSOLE_INFORMATION *Console;
  129. ULONG Flags;
  130. DWORD OutputMode;
  131. ULONG RefCount;
  132. CONSOLE_SHARE_ACCESS ShareAccess; // share mode
  133. COORD ScreenBufferSize; // dimensions of buffer
  134. SMALL_RECT Window; // window location in screen buffer coordinates
  135. WORD ResizingWindow; // > 0 if we should ignore WM_SIZE messages
  136. WORD Attributes; // attributes of written text
  137. WORD PopupAttributes; // attributes of popup text
  138. BOOLEAN WindowMaximizedX;
  139. BOOLEAN WindowMaximizedY;
  140. BOOLEAN WindowMaximized;
  141. UINT CommandIdLow;
  142. UINT CommandIdHigh;
  143. HCURSOR CursorHandle;
  144. HPALETTE hPalette;
  145. UINT dwUsage;
  146. int CursorDisplayCount;
  147. int WheelDelta;
  148. union {
  149. TEXT_BUFFER_INFO TextInfo;
  150. GRAPHICS_BUFFER_INFO GraphicsInfo;
  151. } BufferInfo;
  152. struct _SCREEN_INFORMATION *Next;
  153. #if defined(FE_SB)
  154. BYTE WriteConsoleDbcsLeadByte[2];
  155. BYTE FillOutDbcsLeadChar;
  156. WCHAR LineChar[6];
  157. #define UPPER_LEFT_CORNER 0
  158. #define UPPER_RIGHT_CORNER 1
  159. #define HORIZONTAL_LINE 2
  160. #define VERTICAL_LINE 3
  161. #define BOTTOM_LEFT_CORNER 4
  162. #define BOTTOM_RIGHT_CORNER 5
  163. BYTE BisectFlag;
  164. #define BISECT_LEFT 0x01
  165. #define BISECT_TOP 0x02
  166. #define BISECT_RIGHT 0x04
  167. #define BISECT_BOTTOM 0x08
  168. #if defined(FE_IME)
  169. struct _CONVERSIONAREA_INFORMATION *ConvScreenInfo;
  170. #else
  171. PVOID ConvScreenInfo;
  172. #endif // FE_IME
  173. #endif
  174. } SCREEN_INFORMATION, *PSCREEN_INFORMATION;
  175. typedef struct _WINDOW_LIMITS {
  176. COORD MinimumWindowSize; // minimum dimensions of window
  177. COORD MaximumWindowSize; // maximum dimensions of window
  178. COORD MaxWindow; // in pixels
  179. COORD FullScreenSize;
  180. } WINDOW_LIMITS, *PWINDOW_LIMITS;
  181. //
  182. // the following values are used for TextInfo.Flags
  183. //
  184. #define TEXT_VALID_HINT 1
  185. #define SINGLE_ATTRIBUTES_PER_LINE 2 // only one attribute per line
  186. #if defined(FE_IME)
  187. #define CONSOLE_CONVERSION_AREA_REDRAW 4
  188. #endif
  189. //
  190. // the following value is put in CharInfo.OldLength if the value shouldn't
  191. // be used.
  192. //
  193. #define INVALID_OLD_LENGTH -1
  194. //
  195. // the following mask is used to test for valid text attributes.
  196. //
  197. #if defined(FE_SB)
  198. #define VALID_TEXT_ATTRIBUTES (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | \
  199. COMMON_LVB_LEADING_BYTE | COMMON_LVB_TRAILING_BYTE | COMMON_LVB_GRID_HORIZONTAL | COMMON_LVB_GRID_LVERTICAL | COMMON_LVB_GRID_RVERTICAL | COMMON_LVB_REVERSE_VIDEO | COMMON_LVB_UNDERSCORE )
  200. #else
  201. #define VALID_TEXT_ATTRIBUTES (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
  202. #endif
  203. //
  204. // the following macros are used to calculate 1) the cursor size in pixels
  205. // and 2) the upper left pixel in the cursor, given the font size and
  206. // the cursor size.
  207. //
  208. #define CURSOR_SIZE_IN_PIXELS(FONT_SIZE_Y,SIZE) ((((FONT_SIZE_Y)*(SIZE))+99)/100)
  209. #define CURSOR_Y_OFFSET_IN_PIXELS(FONT_SIZE_Y,YSIZE) ((FONT_SIZE_Y) - (YSIZE))
  210. //
  211. // the following values are used to create the textmode cursor.
  212. //
  213. #define CURSOR_TIMER 1
  214. #define CURSOR_SMALL_SIZE 25 // large enough to be one pixel on a six pixel font
  215. #define CURSOR_BIG_SIZE 50
  216. //
  217. // the following macro returns TRUE if the given screen buffer is the
  218. // active screen buffer.
  219. //
  220. #define ACTIVE_SCREEN_BUFFER(SCREEN_INFO) ((SCREEN_INFO)->Console->CurrentScreenBuffer == SCREEN_INFO)
  221. //
  222. // the following mask is used to create console windows.
  223. //
  224. #define CONSOLE_WINDOW_FLAGS (WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL)
  225. #define CONSOLE_WINDOW_EX_FLAGS (WS_EX_OVERLAPPEDWINDOW | WS_EX_ACCEPTFILES | WS_EX_APPWINDOW )
  226. #define WINDOW_SIZE_X(WINDOW) ((SHORT)(((WINDOW)->Right - (WINDOW)->Left + 1)))
  227. #define WINDOW_SIZE_Y(WINDOW) ((SHORT)(((WINDOW)->Bottom - (WINDOW)->Top + 1)))
  228. #define CONSOLE_WINDOW_SIZE_X(SCREEN) (WINDOW_SIZE_X(&(SCREEN)->Window))
  229. #define CONSOLE_WINDOW_SIZE_Y(SCREEN) (WINDOW_SIZE_Y(&(SCREEN)->Window))