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