4669dae025530ff02bbb6b83166316b67ef81f99
[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 _WINSRV_CONSOLE*
87 struct _CONSOLE* Console; /* Console to which the frontend is attached to */
88 PVOID Data; /* Private data */
89 PVOID OldData; /* Reserved */
90 };
91
92 /* PauseFlags values (internal only) */
93 #define PAUSED_FROM_KEYBOARD 0x1
94 #define PAUSED_FROM_SCROLLBAR 0x2
95 #define PAUSED_FROM_SELECTION 0x4
96
97 typedef struct _WINSRV_CONSOLE
98 {
99 /******************************* Console Set-up *******************************/
100 /* This **MUST** be FIRST!! */
101 // CONSOLE;
102
103 // 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 */
104 // CRITICAL_SECTION Lock;
105 // CONSOLE_STATE State; /* State of the console */
106
107 FRONTEND FrontEndIFace; /* Frontend-specific interface */
108
109 /******************************* Process support ******************************/
110 LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
111 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
112 BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */
113
114 BOOLEAN QuickEdit;
115
116 /******************************* Pausing support ******************************/
117 BYTE PauseFlags;
118 LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */
119 LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */
120
121 /**************************** Aliases and Histories ***************************/
122 struct _ALIAS_HEADER *Aliases;
123 LIST_ENTRY HistoryBuffers;
124 ULONG HistoryBufferSize; /* Size for newly created history buffers */
125 ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
126 BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
127
128 } WINSRV_CONSOLE, *PWINSRV_CONSOLE;
129
130 /* console.c */
131 VOID ConioPause(PCONSOLE Console, UINT Flags);
132 VOID ConioUnpause(PCONSOLE Console, UINT Flags);
133
134 PCONSOLE_PROCESS_DATA NTAPI
135 ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
136 NTSTATUS
137 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
138 IN PCONSOLE_PROCESS_DATA ProcessData);
139 NTSTATUS NTAPI
140 ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
141 IN ULONG ProcessGroupId,
142 IN ULONG CtrlEvent);
143
144 /* coninput.c */
145 VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
146 DWORD ConioEffectiveCursorSize(PCONSOLE Console,
147 DWORD Scale);
148
149 NTSTATUS
150 ConioAddInputEvents(PCONSOLE Console,
151 PINPUT_RECORD InputRecords,
152 ULONG NumEventsToWrite,
153 PULONG NumEventsWritten,
154 BOOLEAN AppendToEnd);
155 NTSTATUS
156 ConioProcessInputEvent(PCONSOLE Console,
157 PINPUT_RECORD InputEvent);
158
159 /* conoutput.c */
160
161 /*
162 * From MSDN:
163 * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
164 * If they are the same, the function fails, and GetLastError returns
165 * ERROR_INVALID_PARAMETER."
166 */
167 #define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
168 ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
169 WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
170
171 #define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
172 ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
173 MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
174
175 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
176 VOID ConioDrawConsole(PCONSOLE Console);
177 NTSTATUS ConioResizeBuffer(PCONSOLE Console,
178 PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
179 COORD Size);
180 NTSTATUS ConioWriteConsole(PCONSOLE Console,
181 PTEXTMODE_SCREEN_BUFFER Buff,
182 PWCHAR Buffer,
183 DWORD Length,
184 BOOL Attrib);
185
186 /* EOF */