ReactOS 0.4.15-dev-7961-gdcf9eb0
conio.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/include/conio.h
5 * PURPOSE: Public Console I/O Interface
6 * PROGRAMMERS: Gé van Geldorp
7 * Jeffrey Morlan
8 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 */
10
11#pragma once
12
13#include "rect.h"
14
15/* Default attributes */
16#define DEFAULT_SCREEN_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
17#define DEFAULT_POPUP_ATTRIB (FOREGROUND_BLUE | FOREGROUND_RED | \
18 BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
19
20
21/* Object type magic numbers */
23{
24 UNKNOWN = 0x00, // --> Unknown object
25 TEXTMODE_BUFFER = 0x01, // --> Output-type object for text SBs
26 GRAPHICS_BUFFER = 0x02, // --> Output-type object for graphics SBs
27 SCREEN_BUFFER = 0x03, // --> Any SB type
28 INPUT_BUFFER = 0x04, // --> Input-type object
29 ANY_TYPE_BUFFER = 0x07, // --> Any IO object
31
32typedef struct _CONSOLE_IO_OBJECT
33{
35
36 struct _CONSOLE* /* PCONSOLE */ Console;
37 LONG ReferenceCount; /* Is incremented each time a console object gets referenced */
38
42
43
44/******************************************************************************\
45|* *|
46|* Abstract "class" for screen-buffers, be they text-mode or graphics *|
47|* *|
48\******************************************************************************/
49
50/*
51 * See conoutput.c for the implementation
52 */
53
54#define GetType(This) (((PCONSOLE_SCREEN_BUFFER)(This))->Header.Type)
55
57{
58 CONSOLE_IO_OBJECT Header; /* Object header - MUST BE IN FIRST PLACE */
59
60 LIST_ENTRY ListEntry; /* Entry in console's list of buffers */
61
62 COORD ScreenBufferSize; /* Size of this screen buffer. (Rows, Columns) for text-mode and (Width, Height) for graphics-mode */
63 COORD ViewSize; /* Associated "view" (i.e. console) size */
64
65 COORD OldScreenBufferSize; /* Old size of this screen buffer */
66 COORD OldViewSize; /* Old associated view size */
67
68 COORD ViewOrigin; /* Beginning offset for the actual display area */
69
70/***** Put that VV in TEXTMODE_SCREEN_BUFFER ?? *****/
71 COORD CursorPosition; /* Current cursor position */
74// ULONG CursorSize;
75 CONSOLE_CURSOR_INFO CursorInfo; // FIXME: Keep this member or not ??
76/*********************************************/
77
78 HPALETTE PaletteHandle; /* Handle to the color palette associated to this buffer */
79 UINT PaletteUsage; /* The new use of the system palette. See SetSystemPaletteUse 'uUsage' parameter */
80
81// USHORT ScreenDefaultAttrib; /* Default screen char attribute */
82// USHORT PopupDefaultAttrib; /* Default popup char attribute */
83 USHORT Mode; /* Output buffer modes */
85
86
87
88/******************************************************************************\
89|* *|
90|* Text-mode and graphics-mode screen-buffer "classes" *|
91|* *|
92\******************************************************************************/
93
94/*
95 * See text.c for the implementation
96 */
97
98/************************************************************************
99 * Screen buffer structure represents the win32 screen buffer object. *
100 * Internally, the portion of the buffer being shown CAN loop past the *
101 * bottom of the virtual buffer and wrap around to the top. Win32 does *
102 * not do this. I decided to do this because it eliminates the need to *
103 * do a massive memcpy() to scroll the contents of the buffer up to *
104 * scroll the screen on output, instead I just shift down the position *
105 * to be displayed, and let it wrap around to the top again. *
106 * The VirtualY member keeps track of the top Y coord that win32 *
107 * clients THINK is currently being displayed, because they think that *
108 * when the display reaches the bottom of the buffer and another line *
109 * being printed causes another line to scroll down, that the buffer IS *
110 * memcpy()'s up, and the bottom of the buffer is still displayed, but *
111 * internally, I just wrap back to the top of the buffer. *
112 ************************************************************************/
113
115{
123
125{
126 CONSOLE_SCREEN_BUFFER; /* Screen buffer base class - MUST BE IN FIRST PLACE */
127
128 USHORT VirtualY; /* Top row of buffer being displayed, reported to callers */
129 PCHAR_INFO Buffer; /* Pointer to UNICODE screen buffer (Buffer->Char.UnicodeChar only is valid, not Char.AsciiChar) */
130
131 USHORT ScreenDefaultAttrib; /* Default screen char attribute */
132 USHORT PopupDefaultAttrib; /* Default popup char attribute */
134
135
136/*
137 * See graphics.c for the implementation
138 */
139
141{
144
146{
147 CONSOLE_SCREEN_BUFFER; /* Screen buffer base class - MUST BE IN FIRST PLACE */
148
149 ULONG BitMapInfoLength; /* Real size of the structure pointed by BitMapInfo */
150 LPBITMAPINFO BitMapInfo; /* Information on the bitmap buffer */
151 ULONG BitMapUsage; /* See the uUsage parameter of GetDIBits */
152 HANDLE hSection; /* Handle to the memory shared section for the bitmap buffer */
153 PVOID BitMap; /* Our bitmap buffer */
154
155 PVOID ClientBitMap; /* A copy of the client view of our bitmap buffer */
156 HANDLE Mutex; /* Our mutex, used to synchronize read / writes to the bitmap buffer */
157 HANDLE ClientMutex; /* A copy of the client handle to our mutex */
158 HANDLE ClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */
160
161
162
164{
165 CONSOLE_IO_OBJECT Header; /* Object header - MUST BE IN FIRST PLACE */
166
167 ULONG InputBufferSize; /* Size of this input buffer (maximum number of events) -- UNUSED!! */
168 ULONG NumberOfEvents; /* Current number of events in the queue */
169 LIST_ENTRY InputEvents; /* Input events queue list head */
170 HANDLE ActiveEvent; /* Event set when an input event is added to the queue */
171
172 USHORT Mode; /* Input buffer modes */
174
175
176/*
177 * Structure used to hold console information
178 */
179typedef struct _CONSOLE_INFO
180{
183 COORD ConsoleSize; /* The size of the console */
184
188
189 USHORT ScreenAttrib; // CHAR_INFO ScreenFillAttrib
191
193
195
196typedef struct _TERMINAL TERMINAL, *PTERMINAL;
197
198typedef struct _TERMINAL_VTBL
199{
200 /*
201 * Internal interface (functions called by the console server only)
202 */
205 VOID (NTAPI *DeinitTerminal)(IN OUT PTERMINAL This);
206
207
208
209/************ Line discipline ***************/
210
211 /* Interface used only for text-mode screen buffers */
212
220 OUT PULONG NumCharsRead OPTIONAL);
226
227/************ Line discipline ***************/
228
229
230
231 /* Interface used for both text-mode and graphics screen buffers */
234 BOOL (NTAPI *SetCursorInfo)(IN OUT PTERMINAL This,
236 BOOL (NTAPI *SetScreenInfo)(IN OUT PTERMINAL This,
240 VOID (NTAPI *ResizeTerminal)(IN OUT PTERMINAL This);
242 VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PTERMINAL This,
244
245 /*
246 * External interface (functions corresponding to the Console API)
247 */
250 BOOL (NTAPI *SetPalette)(IN OUT PTERMINAL This,
253 BOOL (NTAPI *SetCodePage)(IN OUT PTERMINAL This,
255 INT (NTAPI *ShowMouseCursor)(IN OUT PTERMINAL This,
257
258#if 0 // Possible future terminal interface
259 BOOL (NTAPI *GetTerminalProperty)(IN OUT PTERMINAL This,
260 ULONG Flag,
261 PVOID Info,
262 ULONG Size);
263 BOOL (NTAPI *SetTerminalProperty)(IN OUT PTERMINAL This,
264 ULONG Flag,
265 PVOID Info /*,
266 ULONG Size */);
267#endif
269
271{
272 PTERMINAL_VTBL Vtbl; /* Virtual table */
273 struct _CONSOLE* Console; /* Console to which the terminal is attached to */
274 PVOID Context; /* Private context */
275};
276
277/*
278 * WARNING: Change the state of the console ONLY when the console is locked !
279 */
280typedef enum _CONSOLE_STATE
281{
282 CONSOLE_INITIALIZING, /* Console is initializing */
283 CONSOLE_RUNNING , /* Console running */
284 CONSOLE_TERMINATING , /* Console about to be destroyed (but still not) */
285 CONSOLE_IN_DESTRUCTION /* Console in destruction */
287
288typedef struct _CONSOLE
289{
290/******************************* Console Set-up *******************************/
291 LONG ReferenceCount; /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
293
294 CONSOLE_STATE State; /* State of the console */
295 TERMINAL TermIFace; /* Terminal-specific interface */
296
297 BOOLEAN ConsolePaused; /* If TRUE, the console is paused */
298
299/******************************** Input buffer ********************************/
300 CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
302
303/******************************* Screen buffers *******************************/
304 LIST_ENTRY BufferList; /* List of all screen buffers for this console */
305 PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
307
308/****************************** Other properties ******************************/
309 COORD ConsoleSize; /* The current size of the console, for text-mode only */
310 BOOLEAN FixedSize; /* TRUE if the console is of fixed size */
311 BOOLEAN IsCJK; /* TRUE if Chinese, Japanese or Korean (CJK) */
313
314/* console.c */
319
320#define GetConsoleInputBufferMode(Console) \
321 (Console)->InputBuffer.Mode
322
323#define CON_SET_OUTPUT_CP(Console, CodePage)\
324do { \
325 (Console)->OutputCodePage = (CodePage); \
326 (Console)->IsCJK = IsCJKCodePage((Console)->OutputCodePage); \
327} while (0)
328
329
330/* conoutput.c */
334 COORD Size);
335
336/* wcwidth.c */
337int mk_wcwidth_cjk(wchar_t ucs);
338
339// NOTE: The check against 0x80 is to avoid calling the helper function
340// for characters that we already know are not full-width.
341#define IS_FULL_WIDTH(wch) \
342 (((USHORT)(wch) >= 0x0080) && (mk_wcwidth_cjk(wch) == 2))
343
344/* EOF */
unsigned char BOOLEAN
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
#define Y(I)
COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
Definition: console.c:1673
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID DrawRegion(PGUI_CONSOLE_DATA GuiData, SMALL_RECT *Region)
Definition: guiterm.c:76
unsigned int UINT
Definition: ndis.h:50
HANDLE ScreenBuffer
Definition: notevil.c:37
#define BOOL
Definition: nt_native.h:43
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
Definition: xml2sdb.h:80
BOOLEAN CursorBlinkOn
Definition: conio.h:186
USHORT ScreenAttrib
Definition: conio.h:189
ULONG CodePage
Definition: conio.h:192
ULONG InputBufferSize
Definition: conio.h:181
COORD ScreenBufferSize
Definition: conio.h:182
USHORT PopupAttrib
Definition: conio.h:190
ULONG CursorSize
Definition: conio.h:185
COORD ConsoleSize
Definition: conio.h:183
BOOLEAN ForceCursorOff
Definition: conio.h:187
CONSOLE_IO_OBJECT Header
Definition: conio.h:165
ULONG NumberOfEvents
Definition: conio.h:168
ULONG InputBufferSize
Definition: conio.h:167
LIST_ENTRY InputEvents
Definition: conio.h:169
HANDLE ActiveEvent
Definition: conio.h:170
LONG ExclusiveRead
Definition: conio.h:40
LONG ExclusiveWrite
Definition: conio.h:40
struct _CONSOLE * Console
Definition: conio.h:36
CONSOLE_IO_OBJECT_TYPE Type
Definition: conio.h:34
LONG AccessWrite
Definition: conio.h:39
LONG AccessRead
Definition: conio.h:39
LONG ReferenceCount
Definition: conio.h:37
BOOLEAN ForceCursorOff
Definition: conio.h:73
COORD CursorPosition
Definition: conio.h:71
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:75
CONSOLE_IO_OBJECT Header
Definition: conio.h:58
COORD OldScreenBufferSize
Definition: conio.h:65
COORD ScreenBufferSize
Definition: conio.h:62
BOOLEAN CursorBlinkOn
Definition: conio.h:72
HPALETTE PaletteHandle
Definition: conio.h:78
LIST_ENTRY ListEntry
Definition: conio.h:60
TERMINAL TermIFace
Definition: conio.h:295
BOOLEAN FixedSize
Definition: conio.h:310
LIST_ENTRY BufferList
Definition: conio.h:304
UINT OutputCodePage
Definition: conio.h:306
CONSOLE_STATE State
Definition: conio.h:294
COORD ConsoleSize
Definition: conio.h:309
BOOLEAN ConsolePaused
Definition: conio.h:297
UINT InputCodePage
Definition: conio.h:301
CONSOLE_INPUT_BUFFER InputBuffer
Definition: conio.h:300
CRITICAL_SECTION Lock
Definition: conio.h:292
LONG ReferenceCount
Definition: conio.h:291
BOOLEAN IsCJK
Definition: conio.h:311
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conio.h:305
Definition: bl.h:1338
CONSOLE_GRAPHICS_BUFFER_INFO Info
Definition: conio.h:142
LPBITMAPINFO BitMapInfo
Definition: conio.h:150
Definition: typedefs.h:120
BOOL(NTAPI *SetScreenInfo)(IN OUT PTERMINAL This
IN BOOLEAN OUT PVOID IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl
Definition: conio.h:217
IN BOOLEAN OUT PVOID IN OUT PCONSOLE_READCONSOLE_CONTROL IN PVOID Parameter OPTIONAL
Definition: conio.h:218
VOID(NTAPI *ResizeTerminal)(IN OUT PTERMINAL This)
PCONSOLE_SCREEN_BUFFER SHORT SHORT OldCursorY
Definition: conio.h:239
PTEXTMODE_SCREEN_BUFFER Buff
Definition: conio.h:222
PCONSOLE_SCREEN_BUFFER SHORT OldCursorX
Definition: conio.h:238
BOOL Show
Definition: conio.h:256
IN BOOLEAN OUT PVOID IN OUT PCONSOLE_READCONSOLE_CONTROL IN PVOID Parameter IN ULONG OUT PULONG NumCharsRead OPTIONAL
Definition: conio.h:220
UINT CodePage
Definition: conio.h:254
IN struct _CONSOLE * Console
Definition: conio.h:204
VOID(NTAPI *GetLargestConsoleWindowSize)(IN OUT PTERMINAL This
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer
Definition: conio.h:243
BOOL(NTAPI *SetCodePage)(IN OUT PTERMINAL This
VOID(NTAPI *ReleaseScreenBuffer)(IN OUT PTERMINAL This
HPALETTE UINT PaletteUsage
Definition: conio.h:252
NTSTATUS(NTAPI *WriteStream)(IN OUT PTERMINAL This
NTSTATUS(NTAPI *ReadStream)(IN OUT PTERMINAL This
PCONSOLE_SCREEN_BUFFER ScreenBuffer
Definition: conio.h:235
VOID(NTAPI *DeinitTerminal)(IN OUT PTERMINAL This)
PTEXTMODE_SCREEN_BUFFER PWCHAR DWORD BOOL Attrib
Definition: conio.h:225
PTEXTMODE_SCREEN_BUFFER PWCHAR Buffer
Definition: conio.h:223
NTSTATUS(NTAPI *InitTerminal)(IN OUT PTERMINAL This
IN BOOLEAN OUT PVOID Buffer
Definition: conio.h:216
VOID(NTAPI *SetActiveScreenBuffer)(IN OUT PTERMINAL This)
HPALETTE PaletteHandle
Definition: conio.h:251
IN BOOLEAN Unicode
Definition: conio.h:214
BOOL(NTAPI *SetPalette)(IN OUT PTERMINAL This
PCOORD pSize
Definition: conio.h:249
INT(NTAPI *ShowMouseCursor)(IN OUT PTERMINAL This
IN BOOLEAN OUT PVOID IN OUT PCONSOLE_READCONSOLE_CONTROL IN PVOID Parameter IN ULONG NumCharsToRead
Definition: conio.h:219
SMALL_RECT * Region
Definition: conio.h:233
BOOL(NTAPI *SetCursorInfo)(IN OUT PTERMINAL This
VOID(NTAPI *DrawRegion)(IN OUT PTERMINAL This
PTEXTMODE_SCREEN_BUFFER PWCHAR DWORD Length
Definition: conio.h:224
PVOID Context
Definition: conio.h:274
PTERMINAL_VTBL Vtbl
Definition: conio.h:272
struct _CONSOLE * Console
Definition: conio.h:273
BOOLEAN IsCursorVisible
Definition: conio.h:121
USHORT PopupAttrib
Definition: conio.h:119
COORD ScreenBufferSize
Definition: conio.h:116
USHORT ScreenAttrib
Definition: conio.h:118
PCHAR_INFO Buffer
Definition: conio.h:129
USHORT PopupDefaultAttrib
Definition: conio.h:132
USHORT ScreenDefaultAttrib
Definition: conio.h:131
static VOID SetActiveScreenBuffer(HANDLE ScreenBuffer)
Definition: video.c:439
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
struct _TERMINAL * PTERMINAL
Definition: conio.h:196
struct _CONSOLE_INPUT_BUFFER * PCONSOLE_INPUT_BUFFER
enum _CONSOLE_IO_OBJECT_TYPE CONSOLE_IO_OBJECT_TYPE
VOID NTAPI ConDrvUnpause(PCONSOLE Console)
Definition: console.c:314
struct _CONSOLE_IO_OBJECT * PCONSOLE_IO_OBJECT
enum _CONSOLE_STATE CONSOLE_STATE
struct _CONSOLE * PCONSOLE
_CONSOLE_IO_OBJECT_TYPE
Definition: conio.h:23
@ SCREEN_BUFFER
Definition: conio.h:27
@ INPUT_BUFFER
Definition: conio.h:28
@ GRAPHICS_BUFFER
Definition: conio.h:26
@ TEXTMODE_BUFFER
Definition: conio.h:25
@ ANY_TYPE_BUFFER
Definition: conio.h:29
enum _CONSOLE_STATE * PCONSOLE_STATE
int mk_wcwidth_cjk(wchar_t ucs)
Definition: wcwidth.c:234
struct _TERMINAL_VTBL TERMINAL_VTBL
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
struct _GRAPHICS_BUFFER_INFO GRAPHICS_BUFFER_INFO
struct _CONSOLE_SCREEN_BUFFER CONSOLE_SCREEN_BUFFER
struct _GRAPHICS_BUFFER_INFO * PGRAPHICS_BUFFER_INFO
struct _GRAPHICS_SCREEN_BUFFER GRAPHICS_SCREEN_BUFFER
struct _TEXTMODE_BUFFER_INFO TEXTMODE_BUFFER_INFO
struct _CONSOLE_IO_OBJECT CONSOLE_IO_OBJECT
struct _CONSOLE_INPUT_BUFFER CONSOLE_INPUT_BUFFER
struct _CONSOLE CONSOLE
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
struct _CONSOLE_INFO CONSOLE_INFO
struct _TEXTMODE_SCREEN_BUFFER TEXTMODE_SCREEN_BUFFER
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:359
struct _CONSOLE_INFO * PCONSOLE_INFO
struct _TERMINAL_VTBL * PTERMINAL_VTBL
@ CONSOLE_IN_DESTRUCTION
Definition: conio.h:285
@ CONSOLE_TERMINATING
Definition: conio.h:284
@ CONSOLE_RUNNING
Definition: conio.h:283
@ CONSOLE_INITIALIZING
Definition: conio.h:282
struct _TEXTMODE_BUFFER_INFO * PTEXTMODE_BUFFER_INFO
VOID NTAPI ConDrvPause(PCONSOLE Console)
Definition: console.c:304
struct _GRAPHICS_SCREEN_BUFFER * PGRAPHICS_SCREEN_BUFFER
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323