* Sync to trunk r63845.
[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 #define CSR_DEFAULT_CURSOR_SIZE 25
16
17 typedef struct _FRONTEND FRONTEND, *PFRONTEND;
18 /* HACK: */ typedef struct _CONSOLE_INFO *PCONSOLE_INFO;
19 typedef struct _FRONTEND_VTBL
20 {
21 // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
22
23 /*
24 * Internal interface (functions called by the console server only)
25 */
26 NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This,
27 IN struct _CONSOLE* Console);
28 VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This);
29
30 /* Interface used for both text-mode and graphics screen buffers */
31 VOID (NTAPI *DrawRegion)(IN OUT PFRONTEND This,
32 SMALL_RECT* Region);
33 /* Interface used only for text-mode screen buffers */
34 VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This,
35 SMALL_RECT* Region,
36 SHORT CursorStartX,
37 SHORT CursorStartY,
38 UINT ScrolledLines,
39 PWCHAR Buffer,
40 UINT Length);
41 BOOL (NTAPI *SetCursorInfo)(IN OUT PFRONTEND This,
42 PCONSOLE_SCREEN_BUFFER ScreenBuffer);
43 BOOL (NTAPI *SetScreenInfo)(IN OUT PFRONTEND This,
44 PCONSOLE_SCREEN_BUFFER ScreenBuffer,
45 SHORT OldCursorX,
46 SHORT OldCursorY);
47 VOID (NTAPI *ResizeTerminal)(IN OUT PFRONTEND This);
48 VOID (NTAPI *SetActiveScreenBuffer)(IN OUT PFRONTEND This);
49 VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PFRONTEND This,
50 IN PCONSOLE_SCREEN_BUFFER ScreenBuffer);
51 VOID (NTAPI *RefreshInternalInfo)(IN OUT PFRONTEND This);
52
53 /*
54 * External interface (functions corresponding to the Console API)
55 */
56 VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
57 BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
58 HICON IconHandle);
59 HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
60 VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
61 PCOORD pSize);
62 BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
63 PCONSOLE_SELECTION_INFO pSelectionInfo);
64 BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
65 HPALETTE PaletteHandle,
66 UINT PaletteUsage);
67 ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This);
68 BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This,
69 ULONG NewMode);
70 INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This,
71 BOOL Show);
72 BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This,
73 HCURSOR CursorHandle);
74 HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This,
75 UINT CmdIdLow,
76 UINT CmdIdHigh);
77 BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This,
78 BOOL Enable);
79 } FRONTEND_VTBL, *PFRONTEND_VTBL;
80
81 struct _FRONTEND
82 {
83 PFRONTEND_VTBL Vtbl; /* Virtual table */
84 NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
85
86 struct _CONSOLE* Console; /* Console to which the frontend is attached to */
87 PVOID Data; /* Private data */
88 PVOID OldData; /* Reserved */
89 };
90
91 /* PauseFlags values (internal only) */
92 #define PAUSED_FROM_KEYBOARD 0x1
93 #define PAUSED_FROM_SCROLLBAR 0x2
94 #define PAUSED_FROM_SELECTION 0x4
95
96 typedef struct _WINSRV_CONSOLE
97 {
98 /******************************* Console Set-up *******************************/
99 /* This **MUST** be FIRST!! */
100 // CONSOLE;
101
102 // 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 */
103 // CRITICAL_SECTION Lock;
104 // CONSOLE_STATE State; /* State of the console */
105
106 FRONTEND FrontEndIFace; /* Frontend-specific interface */
107
108 /******************************* Process support ******************************/
109 LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
110 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
111 BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */
112
113 BOOLEAN QuickEdit;
114
115 /******************************* Pausing support ******************************/
116 BYTE PauseFlags;
117 LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */
118 LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */
119
120 /**************************** Aliases and Histories ***************************/
121 struct _ALIAS_HEADER *Aliases;
122 LIST_ENTRY HistoryBuffers;
123 ULONG HistoryBufferSize; /* Size for newly created history buffers */
124 ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
125 BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
126
127 } WINSRV_CONSOLE, *PWINSRV_CONSOLE;
128
129 /* console.c */
130 VOID ConioPause(PCONSOLE Console, UINT Flags);
131 VOID ConioUnpause(PCONSOLE Console, UINT Flags);
132
133 PCONSOLE_PROCESS_DATA NTAPI
134 ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
135 NTSTATUS
136 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
137 IN PCONSOLE_PROCESS_DATA ProcessData);
138 NTSTATUS NTAPI
139 ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
140 IN ULONG ProcessGroupId,
141 IN ULONG CtrlEvent);
142
143 /* coninput.c */
144 VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
145 DWORD ConioEffectiveCursorSize(PCONSOLE Console,
146 DWORD Scale);
147
148 NTSTATUS
149 ConioAddInputEvents(PCONSOLE Console,
150 PINPUT_RECORD InputRecords,
151 ULONG NumEventsToWrite,
152 PULONG NumEventsWritten,
153 BOOLEAN AppendToEnd);
154 NTSTATUS
155 ConioProcessInputEvent(PCONSOLE Console,
156 PINPUT_RECORD InputEvent);
157
158 /* conoutput.c */
159
160 /*
161 * From MSDN:
162 * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
163 * If they are the same, the function fails, and GetLastError returns
164 * ERROR_INVALID_PARAMETER."
165 */
166 #define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
167 ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
168 WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
169
170 #define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
171 ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
172 MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
173
174 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
175 VOID ConioDrawConsole(PCONSOLE Console);
176 NTSTATUS ConioResizeBuffer(PCONSOLE Console,
177 PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
178 COORD Size);
179 NTSTATUS ConioWriteConsole(PCONSOLE Console,
180 PTEXTMODE_SCREEN_BUFFER Buff,
181 PWCHAR Buffer,
182 DWORD Length,
183 BOOL Attrib);
184
185 /* EOF */