[CONSRV]: Rename context members with a more explicit name (code "style" only).
[reactos.git] / win32ss / user / winsrv / consrv / include / conio_winsrv.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: consrv/include/conio_winsrv.h
5 * PURPOSE: Public Console I/O Interface - Offers wrap-up structures
6 * over the console objects exposed by the console driver.
7 * PROGRAMMERS: Gé van Geldorp
8 * Jeffrey Morlan
9 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10 */
11
12 #pragma once
13
14 #include "rect.h"
15
16 // This is ALMOST a HACK!!!!!!!
17 // Helpers for code refactoring
18 #ifdef USE_NEW_CONSOLE_WAY
19
20 #define _CONSRV_CONSOLE _WINSRV_CONSOLE
21 #define CONSRV_CONSOLE WINSRV_CONSOLE
22 #define PCONSRV_CONSOLE PWINSRV_CONSOLE
23
24 #else
25
26 #define _CONSRV_CONSOLE _CONSOLE
27 #define CONSRV_CONSOLE CONSOLE
28 #define PCONSRV_CONSOLE PCONSOLE
29
30 #endif
31
32 #define CSR_DEFAULT_CURSOR_SIZE 25
33
34 /* VGA character cell */
35 typedef struct _CHAR_CELL
36 {
37 CHAR Char;
38 BYTE Attributes;
39 } CHAR_CELL, *PCHAR_CELL;
40 C_ASSERT(sizeof(CHAR_CELL) == 2);
41
42 // HACK!!
43 struct _WINSRV_CONSOLE;
44 /* HACK: */ typedef struct _WINSRV_CONSOLE *PWINSRV_CONSOLE;
45 #ifdef USE_NEW_CONSOLE_WAY
46 #include "conio.h"
47 #endif
48
49 typedef struct _FRONTEND FRONTEND, *PFRONTEND;
50 /* HACK: */ typedef struct _CONSOLE_INFO *PCONSOLE_INFO;
51 typedef struct _FRONTEND_VTBL
52 {
53 // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
54
55 /*
56 * Internal interface (functions called by the console server only)
57 */
58 NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This,
59 IN struct _CONSRV_CONSOLE* Console);
60 VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This);
61
62 /* Interface used for both text-mode and graphics screen buffers */
63 VOID (NTAPI *DrawRegion)(IN OUT PFRONTEND This,
64 SMALL_RECT* Region);
65 /* Interface used only for text-mode screen buffers */
66 VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This,
67 SMALL_RECT* Region,
68 SHORT CursorStartX,
69 SHORT CursorStartY,
70 UINT ScrolledLines,
71 PWCHAR Buffer,
72 UINT Length);
73 VOID (NTAPI *RingBell)(IN OUT PFRONTEND This);
74 BOOL (NTAPI *SetCursorInfo)(IN OUT PFRONTEND This,
75 PCONSOLE_SCREEN_BUFFER ScreenBuffer);
76 BOOL (NTAPI *SetScreenInfo)(IN OUT PFRONTEND This,
77 PCONSOLE_SCREEN_BUFFER ScreenBuffer,
78 SHORT OldCursorX,
79 SHORT OldCursorY);
80 VOID (NTAPI *ResizeTerminal)(IN OUT PFRONTEND This);
81 VOID (NTAPI *SetActiveScreenBuffer)(IN OUT PFRONTEND This);
82 VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PFRONTEND This,
83 IN PCONSOLE_SCREEN_BUFFER ScreenBuffer);
84 VOID (NTAPI *RefreshInternalInfo)(IN OUT PFRONTEND This);
85
86 /*
87 * External interface (functions corresponding to the Console API)
88 */
89 VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
90 BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
91 HICON IconHandle);
92 HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
93 VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
94 PCOORD pSize);
95 BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
96 PCONSOLE_SELECTION_INFO pSelectionInfo);
97 BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
98 HPALETTE PaletteHandle,
99 UINT PaletteUsage);
100 ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This);
101 BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This,
102 ULONG NewMode);
103 INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This,
104 BOOL Show);
105 BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This,
106 HCURSOR CursorHandle);
107 HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This,
108 UINT CmdIdLow,
109 UINT CmdIdHigh);
110 BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This,
111 BOOL Enable);
112 } FRONTEND_VTBL, *PFRONTEND_VTBL;
113
114 struct _FRONTEND
115 {
116 PFRONTEND_VTBL Vtbl; /* Virtual table */
117 NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
118
119 struct _CONSRV_CONSOLE* Console; /* Console to which the frontend is attached to */
120 PVOID Context; /* Private context */
121 PVOID Context2; /* Private context */
122 };
123
124 /* PauseFlags values (internal only) */
125 #define PAUSED_FROM_KEYBOARD 0x1
126 #define PAUSED_FROM_SCROLLBAR 0x2
127 #define PAUSED_FROM_SELECTION 0x4
128
129 typedef struct _WINSRV_CONSOLE
130 {
131 /******************************* Console Set-up *******************************/
132 /* This **MUST** be FIRST!! */
133 #ifdef USE_NEW_CONSOLE_WAY
134 CONSOLE;
135 // CONSOLE Console;
136 // // PCONSOLE Console;
137 #endif
138
139 // 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 */
140 // CRITICAL_SECTION Lock;
141 // CONSOLE_STATE State; /* State of the console */
142
143 HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */
144
145 FRONTEND FrontEndIFace; /* Frontend-specific interface */
146
147 /******************************* Process support ******************************/
148 LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
149 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
150 BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */
151
152 /******************************* Pausing support ******************************/
153 BYTE PauseFlags;
154 LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */
155 LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */
156
157 /**************************** Aliases and Histories ***************************/
158 struct _ALIAS_HEADER *Aliases;
159 LIST_ENTRY HistoryBuffers;
160 ULONG HistoryBufferSize; /* Size for newly created history buffers */
161 ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
162 BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
163
164 /**************************** Input Line Discipline ***************************/
165 PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
166 ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
167 ULONG LineSize; /* Current size of line */
168 ULONG LinePos; /* Current position within line */
169 BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */
170 BOOLEAN LineUpPressed;
171 BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */
172 ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */
173
174 BOOLEAN InsertMode;
175 BOOLEAN QuickEdit;
176
177 /************************ Virtual DOS Machine support *************************/
178 COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */
179 HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */
180 PVOID VDMBuffer; /* Our VDM buffer */
181 PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */
182 HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */
183
184 HANDLE StartHardwareEvent;
185 HANDLE EndHardwareEvent;
186 HANDLE ErrorHardwareEvent;
187
188 /****************************** Other properties ******************************/
189 LIST_ENTRY PopupWindows; /* List of popup windows */
190 UNICODE_STRING OriginalTitle; /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */
191 UNICODE_STRING Title; /* Title of console. Always NULL-terminated */
192 COLORREF Colors[16]; /* Colour palette */
193
194 } WINSRV_CONSOLE; // , *PWINSRV_CONSOLE;
195
196 /* console.c */
197 VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags);
198 VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags);
199
200 PCONSOLE_PROCESS_DATA NTAPI
201 ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console);
202 NTSTATUS
203 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
204 IN PCONSOLE_PROCESS_DATA ProcessData);
205 NTSTATUS NTAPI
206 ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console,
207 IN ULONG ProcessGroupId,
208 IN ULONG CtrlEvent);
209
210 /* coninput.c */
211 VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg);
212 DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console,
213 DWORD Scale);
214
215 NTSTATUS
216 ConioProcessInputEvent(PCONSRV_CONSOLE Console,
217 PINPUT_RECORD InputEvent);
218
219 /* conoutput.c */
220 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
221 NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
222 PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
223 COORD Size);
224
225 /* terminal.c */
226 VOID ConioDrawConsole(PCONSRV_CONSOLE Console);
227
228 /* EOF */