- Remove ALL the unneeded "author date id revision" svn properties.
[reactos.git] / reactos / win32ss / user / win32csr / conio.h
1 /* $Id: conio.h 55617 2012-02-15 20:29:08Z ion $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: subsys/csrss/include/conio.h
6 * PURPOSE: CSRSS internal console I/O interface
7 */
8
9 #pragma once
10
11 #include "api.h"
12 #include "win32csr.h"
13
14 #define CSR_DEFAULT_CURSOR_SIZE 25
15
16 /* Object type magic numbers */
17
18 #define CONIO_CONSOLE_MAGIC 0x00000001
19 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002
20
21 /************************************************************************
22 * Screen buffer structure represents the win32 screen buffer object. *
23 * Internally, the portion of the buffer being shown CAN loop past the *
24 * bottom of the virtual buffer and wrap around to the top. Win32 does *
25 * not do this. I decided to do this because it eliminates the need to *
26 * do a massive memcpy() to scroll the contents of the buffer up to *
27 * scroll the screen on output, instead I just shift down the position *
28 * to be displayed, and let it wrap around to the top again. *
29 * The VirtualY member keeps track of the top Y coord that win32 *
30 * clients THINK is currently being displayed, because they think that *
31 * when the display reaches the bottom of the buffer and another line *
32 * being printed causes another line to scroll down, that the buffer IS *
33 * memcpy()'s up, and the bottom of the buffer is still displayed, but *
34 * internally, I just wrap back to the top of the buffer. *
35 ***********************************************************************/
36
37 typedef struct tagCSRSS_SCREEN_BUFFER
38 {
39 Object_t Header; /* Object header */
40 BYTE *Buffer; /* pointer to screen buffer */
41 USHORT MaxX, MaxY; /* size of the entire scrollback buffer */
42 USHORT ShowX, ShowY; /* beginning offset for the actual display area */
43 ULONG CurrentX; /* Current X cursor position */
44 ULONG CurrentY; /* Current Y cursor position */
45 WORD DefaultAttrib; /* default char attribute */
46 USHORT VirtualY; /* top row of buffer being displayed, reported to callers */
47 CONSOLE_CURSOR_INFO CursorInfo;
48 USHORT Mode;
49 LIST_ENTRY ListEntry; /* entry in console's list of buffers */
50 } CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
51
52 typedef struct tagCSRSS_CONSOLE *PCSRSS_CONSOLE;
53
54 typedef struct tagCSRSS_CONSOLE_VTBL
55 {
56 VOID (WINAPI *InitScreenBuffer)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer);
57 VOID (WINAPI *WriteStream)(PCSRSS_CONSOLE Console, SMALL_RECT *Block, LONG CursorStartX, LONG CursorStartY,
58 UINT ScrolledLines, CHAR *Buffer, UINT Length);
59 VOID (WINAPI *DrawRegion)(PCSRSS_CONSOLE Console, SMALL_RECT *Region);
60 BOOL (WINAPI *SetCursorInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer);
61 BOOL (WINAPI *SetScreenInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer,
62 UINT OldCursorX, UINT OldCursorY);
63 BOOL (WINAPI *UpdateScreenInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer);
64 BOOL (WINAPI *ChangeTitle)(PCSRSS_CONSOLE Console);
65 VOID (WINAPI *CleanupConsole)(PCSRSS_CONSOLE Console);
66 BOOL (WINAPI *ChangeIcon)(PCSRSS_CONSOLE Console, HICON hWindowIcon);
67 NTSTATUS (WINAPI *ResizeBuffer)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer, COORD Size);
68 } CSRSS_CONSOLE_VTBL, *PCSRSS_CONSOLE_VTBL;
69
70 typedef struct tagCSRSS_CONSOLE
71 {
72 Object_t Header; /* Object header */
73 LONG ReferenceCount;
74 CRITICAL_SECTION Lock;
75 PCSRSS_CONSOLE Prev, Next; /* Next and Prev consoles in console wheel */
76 HANDLE ActiveEvent;
77 LIST_ENTRY InputEvents; /* List head for input event queue */
78 PWCHAR LineBuffer; /* current line being input, in line buffered mode */
79 WORD LineMaxSize; /* maximum size of line in characters (including CR+LF) */
80 WORD LineSize; /* current size of line */
81 WORD LinePos; /* current position within line */
82 BOOLEAN LineComplete; /* user pressed enter, ready to send back to client */
83 BOOLEAN LineUpPressed;
84 BOOLEAN LineInsertToggle; /* replace character over cursor instead of inserting */
85 ULONG LineWakeupMask; /* bitmap of which control characters will end line input */
86 LIST_ENTRY HistoryBuffers;
87 WORD HistoryBufferSize; /* size for newly created history buffers */
88 WORD NumberOfHistoryBuffers; /* maximum number of history buffers allowed */
89 BOOLEAN HistoryNoDup; /* remove old duplicate history entries */
90 LIST_ENTRY BufferList; /* List of all screen buffers for this console */
91 PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
92 WORD Mode; /* Console mode flags */
93 UNICODE_STRING Title; /* Title of console */
94 DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
95 HWND hWindow;
96 COORD Size;
97 PVOID PrivateData;
98 UINT CodePage;
99 UINT OutputCodePage;
100 PCSRSS_CONSOLE_VTBL Vtbl;
101 LIST_ENTRY ProcessList;
102 struct tagALIAS_HEADER *Aliases;
103 CONSOLE_SELECTION_INFO Selection;
104 BYTE PauseFlags;
105 HANDLE UnpauseEvent;
106 } CSRSS_CONSOLE;
107
108 typedef struct ConsoleInput_t
109 {
110 LIST_ENTRY ListEntry;
111 INPUT_RECORD InputEvent;
112 } ConsoleInput;
113
114 /* CONSOLE_SELECTION_INFO dwFlags values */
115 #define CONSOLE_NO_SELECTION 0x0
116 #define CONSOLE_SELECTION_IN_PROGRESS 0x1
117 #define CONSOLE_SELECTION_NOT_EMPTY 0x2
118 #define CONSOLE_MOUSE_SELECTION 0x4
119 #define CONSOLE_MOUSE_DOWN 0x8
120 /* HistoryFlags values */
121 #define HISTORY_NO_DUP_FLAG 0x1
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 #define ConioInitScreenBuffer(Console, Buff) (Console)->Vtbl->InitScreenBuffer((Console), (Buff))
129 #define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console), (Region))
130 #define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
131 (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \
132 (ScrolledLines), (Buffer), (Length))
133 #define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console), (Buff))
134 #define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
135 (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY))
136 #define ConioUpdateScreenInfo(Console, Buff) \
137 (Console)->Vtbl->UpdateScreenInfo(Console, Buff)
138 #define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
139 #define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
140 #define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon(Console, hWindowIcon)
141 #define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
142
143 /* console.c */
144 NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSR_PROCESS ProcessData, PCSRSS_CONSOLE *Console);
145 VOID WINAPI ConioDeleteConsole(Object_t *Object);
146 VOID WINAPI CsrInitConsoleSupport(VOID);
147 VOID FASTCALL ConioPause(PCSRSS_CONSOLE Console, UINT Flags);
148 VOID FASTCALL ConioUnpause(PCSRSS_CONSOLE Console, UINT Flags);
149 VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCSR_PROCESS ProcessData);
150 VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData,
151 DWORD Timeout);
152 CSR_API(CsrAllocConsole);
153 CSR_API(CsrFreeConsole);
154 CSR_API(CsrSetConsoleMode);
155 CSR_API(CsrGetConsoleMode);
156 CSR_API(CsrSetTitle);
157 CSR_API(CsrGetTitle);
158 CSR_API(CsrHardwareStateProperty);
159 CSR_API(CsrGetConsoleWindow);
160 CSR_API(CsrSetConsoleIcon);
161 CSR_API(CsrGetConsoleCodePage);
162 CSR_API(CsrSetConsoleCodePage);
163 CSR_API(CsrGetConsoleOutputCodePage);
164 CSR_API(CsrSetConsoleOutputCodePage);
165 CSR_API(CsrGetProcessList);
166 CSR_API(CsrGenerateCtrlEvent);
167 CSR_API(CsrGetConsoleSelectionInfo);
168
169 /* coninput.c */
170 #define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
171 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_CONSOLE_MAGIC)
172 #define ConioUnlockConsole(Console) \
173 Win32CsrUnlockObject((Object_t *) Console)
174 void WINAPI ConioProcessKey(MSG *msg, PCSRSS_CONSOLE Console, BOOL TextMode);
175 CSR_API(CsrReadConsole);
176 CSR_API(CsrReadInputEvent);
177 CSR_API(CsrFlushInputBuffer);
178 CSR_API(CsrGetNumberOfConsoleInputEvents);
179 CSR_API(CsrPeekConsoleInput);
180 CSR_API(CsrWriteConsoleInput);
181
182 /* conoutput.c */
183 #define ConioRectHeight(Rect) \
184 (((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
185 #define ConioRectWidth(Rect) \
186 (((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
187 #define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
188 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_SCREEN_BUFFER_MAGIC)
189 #define ConioUnlockScreenBuffer(Buff) \
190 Win32CsrUnlockObject((Object_t *) Buff)
191 PBYTE FASTCALL ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buf, ULONG X, ULONG Y);
192 VOID FASTCALL ConioDrawConsole(PCSRSS_CONSOLE Console);
193 NTSTATUS FASTCALL ConioWriteConsole(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buff,
194 CHAR *Buffer, DWORD Length, BOOL Attrib);
195 NTSTATUS FASTCALL CsrInitConsoleScreenBuffer(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buffer);
196 VOID WINAPI ConioDeleteScreenBuffer(PCSRSS_SCREEN_BUFFER Buffer);
197 DWORD FASTCALL ConioEffectiveCursorSize(PCSRSS_CONSOLE Console, DWORD Scale);
198
199 CSR_API(CsrWriteConsole);
200 CSR_API(CsrGetScreenBufferInfo);
201 CSR_API(CsrSetCursor);
202 CSR_API(CsrWriteConsoleOutputChar);
203 CSR_API(CsrFillOutputChar);
204 CSR_API(CsrWriteConsoleOutputAttrib);
205 CSR_API(CsrFillOutputAttrib);
206 CSR_API(CsrGetCursorInfo);
207 CSR_API(CsrSetCursorInfo);
208 CSR_API(CsrSetTextAttrib);
209 CSR_API(CsrCreateScreenBuffer);
210 CSR_API(CsrSetScreenBuffer);
211 CSR_API(CsrWriteConsoleOutput);
212 CSR_API(CsrScrollConsoleScreenBuffer);
213 CSR_API(CsrReadConsoleOutputChar);
214 CSR_API(CsrReadConsoleOutputAttrib);
215 CSR_API(CsrReadConsoleOutput);
216 CSR_API(CsrSetScreenBufferSize);
217
218 /* alias.c */
219 VOID IntDeleteAllAliases(struct tagALIAS_HEADER *RootHeader);
220 CSR_API(CsrAddConsoleAlias);
221 CSR_API(CsrGetConsoleAlias);
222 CSR_API(CsrGetAllConsoleAliases);
223 CSR_API(CsrGetAllConsoleAliasesLength);
224 CSR_API(CsrGetConsoleAliasesExes);
225 CSR_API(CsrGetConsoleAliasesExesLength);
226
227 /* lineinput.c */
228 struct tagHISTORY_BUFFER;
229 VOID FASTCALL HistoryDeleteBuffer(struct tagHISTORY_BUFFER *Hist);
230 CSR_API(CsrGetCommandHistoryLength);
231 CSR_API(CsrGetCommandHistory);
232 CSR_API(CsrExpungeCommandHistory);
233 CSR_API(CsrSetHistoryNumberCommands);
234 CSR_API(CsrGetHistoryInfo);
235 CSR_API(CsrSetHistoryInfo);
236 VOID FASTCALL LineInputKeyDown(PCSRSS_CONSOLE Console, KEY_EVENT_RECORD *KeyEvent);
237
238 /* EOF */