[CONSRV]
[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 #define CSR_DEFAULT_CURSOR_SIZE 25
14
15 typedef struct _FRONTEND FRONTEND, *PFRONTEND;
16 /* HACK: */ typedef struct _CONSOLE_INFO *PCONSOLE_INFO;
17 typedef struct _FRONTEND_VTBL
18 {
19 // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
20
21 /*
22 * Internal interface (functions called by the console server only)
23 */
24 NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This,
25 IN struct _CONSOLE* Console);
26 VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This);
27
28 /* Interface used for both text-mode and graphics screen buffers */
29 VOID (NTAPI *DrawRegion)(IN OUT PFRONTEND This,
30 SMALL_RECT* Region);
31 /* Interface used only for text-mode screen buffers */
32 VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This,
33 SMALL_RECT* Block,
34 SHORT CursorStartX,
35 SHORT CursorStartY,
36 UINT ScrolledLines,
37 PWCHAR Buffer,
38 UINT Length);
39 BOOL (NTAPI *SetCursorInfo)(IN OUT PFRONTEND This,
40 PCONSOLE_SCREEN_BUFFER ScreenBuffer);
41 BOOL (NTAPI *SetScreenInfo)(IN OUT PFRONTEND This,
42 PCONSOLE_SCREEN_BUFFER ScreenBuffer,
43 SHORT OldCursorX,
44 SHORT OldCursorY);
45 VOID (NTAPI *ResizeTerminal)(IN OUT PFRONTEND This);
46 VOID (NTAPI *SetActiveScreenBuffer)(IN OUT PFRONTEND This);
47 VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PFRONTEND This,
48 IN PCONSOLE_SCREEN_BUFFER ScreenBuffer);
49 BOOL (NTAPI *ProcessKeyCallback)(IN OUT PFRONTEND This,
50 MSG* msg,
51 BYTE KeyStateMenu,
52 DWORD ShiftState,
53 UINT VirtualKeyCode,
54 BOOL Down);
55 VOID (NTAPI *RefreshInternalInfo)(IN OUT PFRONTEND This);
56
57 /*
58 * External interface (functions corresponding to the Console API)
59 */
60 VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
61 BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
62 HICON IconHandle);
63 HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
64 VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
65 PCOORD pSize);
66 BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
67 PCONSOLE_SELECTION_INFO pSelectionInfo);
68 BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
69 HPALETTE PaletteHandle,
70 UINT PaletteUsage);
71 ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This);
72 BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This,
73 ULONG NewMode);
74 INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This,
75 BOOL Show);
76 BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This,
77 HCURSOR CursorHandle);
78 HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This,
79 UINT CmdIdLow,
80 UINT CmdIdHigh);
81 BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This,
82 BOOL Enable);
83 } FRONTEND_VTBL, *PFRONTEND_VTBL;
84
85 struct _FRONTEND
86 {
87 PFRONTEND_VTBL Vtbl; /* Virtual table */
88 struct _CONSOLE* Console; /* Console to which the frontend is attached to */
89 PVOID Data; /* Private data */
90 PVOID OldData; /* Reserved */
91 };
92
93 /* PauseFlags values (internal only) */
94 #define PAUSED_FROM_KEYBOARD 0x1
95 #define PAUSED_FROM_SCROLLBAR 0x2
96 #define PAUSED_FROM_SELECTION 0x4
97
98 typedef struct _WINSRV_CONSOLE
99 {
100 /******************************* Console Set-up *******************************/
101 /* This **MUST** be FIRST!! */
102 // CONSOLE;
103
104 // 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 */
105 // CRITICAL_SECTION Lock;
106 // CONSOLE_STATE State; /* State of the console */
107
108 FRONTEND FrontEndIFace; /* Frontend-specific interface */
109
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 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 } WINSRV_CONSOLE, *PWINSRV_CONSOLE;
121
122 /* console.c */
123 VOID ConioPause(PCONSOLE Console, UINT Flags);
124 VOID ConioUnpause(PCONSOLE Console, UINT Flags);
125
126 PCONSOLE_PROCESS_DATA NTAPI
127 ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
128 NTSTATUS
129 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
130 IN PCONSOLE_PROCESS_DATA ProcessData);
131 NTSTATUS NTAPI
132 ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
133 IN ULONG ProcessGroupId,
134 IN ULONG CtrlEvent);
135
136 /* coninput.c */
137 VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
138 NTSTATUS ConioAddInputEvent(PCONSOLE Console,
139 PINPUT_RECORD InputEvent,
140 BOOLEAN AppendToEnd);
141 NTSTATUS ConioProcessInputEvent(PCONSOLE Console,
142 PINPUT_RECORD InputEvent);
143
144 /* conoutput.c */
145 #define ConioInitRect(Rect, top, left, bottom, right) \
146 do { \
147 ((Rect)->Top) = top; \
148 ((Rect)->Left) = left; \
149 ((Rect)->Bottom) = bottom; \
150 ((Rect)->Right) = right; \
151 } while (0)
152 #define ConioIsRectEmpty(Rect) \
153 (((Rect)->Left > (Rect)->Right) || ((Rect)->Top > (Rect)->Bottom))
154 #define ConioRectHeight(Rect) \
155 (((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
156 #define ConioRectWidth(Rect) \
157 (((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
158
159 #define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
160 WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
161
162 #define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
163 MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
164
165 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
166 VOID ConioDrawConsole(PCONSOLE Console);
167 NTSTATUS ConioResizeBuffer(PCONSOLE Console,
168 PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
169 COORD Size);
170 NTSTATUS ConioWriteConsole(PCONSOLE Console,
171 PTEXTMODE_SCREEN_BUFFER Buff,
172 PWCHAR Buffer,
173 DWORD Length,
174 BOOL Attrib);
175 DWORD ConioEffectiveCursorSize(PCONSOLE Console,
176 DWORD Scale);
177
178 /* EOF */