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
14 #define CSR_DEFAULT_CURSOR_SIZE 25
16 /* Object type magic numbers */
18 #define CONIO_CONSOLE_MAGIC 0x00000001
19 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002
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 ***********************************************************************/
37 typedef struct tagCSRSS_SCREEN_BUFFER
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
;
49 } CSRSS_SCREEN_BUFFER
, *PCSRSS_SCREEN_BUFFER
;
51 typedef struct tagCSRSS_CONSOLE
*PCSRSS_CONSOLE
;
53 typedef struct tagCSRSS_CONSOLE_VTBL
55 VOID (WINAPI
*InitScreenBuffer
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
56 VOID (WINAPI
*WriteStream
)(PCSRSS_CONSOLE Console
, RECT
*Block
, LONG CursorStartX
, LONG CursorStartY
,
57 UINT ScrolledLines
, CHAR
*Buffer
, UINT Length
);
58 VOID (WINAPI
*DrawRegion
)(PCSRSS_CONSOLE Console
, RECT
*Region
);
59 BOOL (WINAPI
*SetCursorInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
60 BOOL (WINAPI
*SetScreenInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
,
61 UINT OldCursorX
, UINT OldCursorY
);
62 BOOL (WINAPI
*UpdateScreenInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
63 BOOL (WINAPI
*ChangeTitle
)(PCSRSS_CONSOLE Console
);
64 VOID (WINAPI
*CleanupConsole
)(PCSRSS_CONSOLE Console
);
65 BOOL (WINAPI
*ChangeIcon
)(PCSRSS_CONSOLE Console
, HICON hWindowIcon
);
66 NTSTATUS (WINAPI
*ResizeBuffer
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
, COORD Size
);
67 } CSRSS_CONSOLE_VTBL
, *PCSRSS_CONSOLE_VTBL
;
69 typedef struct tagCSRSS_CONSOLE
71 Object_t Header
; /* Object header */
73 CRITICAL_SECTION Lock
;
74 PCSRSS_CONSOLE Prev
, Next
; /* Next and Prev consoles in console wheel */
76 LIST_ENTRY InputEvents
; /* List head for input event queue */
78 WORD WaitingLines
; /* number of chars and lines in input queue */
79 PCSRSS_SCREEN_BUFFER ActiveBuffer
; /* Pointer to currently active screen buffer */
80 WORD Mode
; /* Console mode flags */
81 WORD EchoCount
; /* count of chars to echo, in line buffered mode */
82 UNICODE_STRING Title
; /* Title of console */
83 BOOL EarlyReturn
; /* wake client and return data, even if we are in line buffered mode, and we don't have a complete line */
84 DWORD HardwareState
; /* _GDI_MANAGED, _DIRECT */
90 PCSRSS_CONSOLE_VTBL Vtbl
;
91 LIST_ENTRY ProcessList
;
92 struct tagALIAS_HEADER
*Aliases
;
95 typedef struct ConsoleInput_t
98 INPUT_RECORD InputEvent
;
99 BOOLEAN Echoed
; // already been echoed or not
100 BOOLEAN Fake
; // synthesized, not a real event
101 BOOLEAN NotChar
; // message should not be used to return a character
104 NTSTATUS FASTCALL
ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData
, PCSRSS_CONSOLE
*Console
);
105 VOID WINAPI
ConioDeleteConsole(Object_t
*Object
);
106 VOID WINAPI
ConioDeleteScreenBuffer(Object_t
*Buffer
);
107 VOID WINAPI
CsrInitConsoleSupport(VOID
);
108 void WINAPI
ConioProcessKey(MSG
*msg
, PCSRSS_CONSOLE Console
, BOOL TextMode
);
109 PBYTE FASTCALL
ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buf
, ULONG X
, ULONG Y
);
110 VOID FASTCALL
ConioDrawConsole(PCSRSS_CONSOLE Console
);
111 VOID FASTCALL
ConioConsoleCtrlEvent(DWORD Event
, PCSRSS_PROCESS_DATA ProcessData
);
112 VOID FASTCALL
ConioConsoleCtrlEventTimeout(DWORD Event
, PCSRSS_PROCESS_DATA ProcessData
,
116 CSR_API(CsrWriteConsole
);
117 CSR_API(CsrAllocConsole
);
118 CSR_API(CsrFreeConsole
);
119 CSR_API(CsrReadConsole
);
120 CSR_API(CsrConnectProcess
);
121 CSR_API(CsrGetScreenBufferInfo
);
122 CSR_API(CsrSetCursor
);
123 CSR_API(CsrFillOutputChar
);
124 CSR_API(CsrReadInputEvent
);
125 CSR_API(CsrWriteConsoleOutputChar
);
126 CSR_API(CsrWriteConsoleOutputAttrib
);
127 CSR_API(CsrFillOutputAttrib
);
128 CSR_API(CsrGetCursorInfo
);
129 CSR_API(CsrSetCursorInfo
);
130 CSR_API(CsrSetTextAttrib
);
131 CSR_API(CsrSetConsoleMode
);
132 CSR_API(CsrGetConsoleMode
);
133 CSR_API(CsrCreateScreenBuffer
);
134 CSR_API(CsrSetScreenBuffer
);
135 CSR_API(CsrSetTitle
);
136 CSR_API(CsrGetTitle
);
137 CSR_API(CsrWriteConsoleOutput
);
138 CSR_API(CsrFlushInputBuffer
);
139 CSR_API(CsrScrollConsoleScreenBuffer
);
140 CSR_API(CsrReadConsoleOutputChar
);
141 CSR_API(CsrReadConsoleOutputAttrib
);
142 CSR_API(CsrGetNumberOfConsoleInputEvents
);
143 CSR_API(CsrPeekConsoleInput
);
144 CSR_API(CsrReadConsoleOutput
);
145 CSR_API(CsrWriteConsoleInput
);
146 CSR_API(CsrHardwareStateProperty
);
147 CSR_API(CsrGetConsoleWindow
);
148 CSR_API(CsrSetConsoleIcon
);
149 CSR_API(CsrGetConsoleCodePage
);
150 CSR_API(CsrSetConsoleCodePage
);
151 CSR_API(CsrGetConsoleOutputCodePage
);
152 CSR_API(CsrSetConsoleOutputCodePage
);
153 CSR_API(CsrGetProcessList
);
154 CSR_API(CsrGenerateCtrlEvent
);
155 CSR_API(CsrSetScreenBufferSize
);
157 #define ConioInitScreenBuffer(Console, Buff) (Console)->Vtbl->InitScreenBuffer((Console), (Buff))
158 #define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console), (Region))
159 #define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
160 (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \
161 (ScrolledLines), (Buffer), (Length))
162 #define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console), (Buff))
163 #define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
164 (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY))
165 #define ConioUpdateScreenInfo(Console, Buff) \
166 (Console)->Vtbl->UpdateScreenInfo(Console, Buff)
167 #define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
168 #define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
169 #define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon(Console, hWindowIcon)
170 #define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
172 #define ConioRectHeight(Rect) \
173 (((Rect)->top) > ((Rect)->bottom) ? 0 : ((Rect)->bottom) - ((Rect)->top) + 1)
174 #define ConioRectWidth(Rect) \
175 (((Rect)->left) > ((Rect)->right) ? 0 : ((Rect)->right) - ((Rect)->left) + 1)
177 #define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
178 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_CONSOLE_MAGIC)
179 #define ConioUnlockConsole(Console) \
180 Win32CsrUnlockObject((Object_t *) Console)
181 #define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
182 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_SCREEN_BUFFER_MAGIC)
183 #define ConioUnlockScreenBuffer(Buff) \
184 Win32CsrUnlockObject((Object_t *) Buff)
187 VOID
IntDeleteAllAliases(struct tagALIAS_HEADER
*RootHeader
);
188 CSR_API(CsrAddConsoleAlias
);
189 CSR_API(CsrGetConsoleAlias
);
190 CSR_API(CsrGetAllConsoleAliases
);
191 CSR_API(CsrGetAllConsoleAliasesLength
);
192 CSR_API(CsrGetConsoleAliasesExes
);
193 CSR_API(CsrGetConsoleAliasesExesLength
);