Files forgotten in r19815
[reactos.git] / reactos / subsys / csrss / include / conio.h
1 /* $Id$
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 #ifndef CONIO_H_INCLUDED
10 #define CONIO_H_INCLUDED
11
12 #include "api.h"
13 #include "win32csr.h"
14
15 /* Object type magic numbers */
16
17 #define CONIO_CONSOLE_MAGIC 0x00000001
18 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002
19
20 /************************************************************************
21 * Screen buffer structure represents the win32 screen buffer object. *
22 * Internally, the portion of the buffer being shown CAN loop past the *
23 * bottom of the virtual buffer and wrap around to the top. Win32 does *
24 * not do this. I decided to do this because it eliminates the need to *
25 * do a massive memcpy() to scroll the contents of the buffer up to *
26 * scroll the screen on output, instead I just shift down the position *
27 * to be displayed, and let it wrap around to the top again. *
28 * The VirtualX member keeps track of the top X coord that win32 *
29 * clients THINK is currently being displayed, because they think that *
30 * when the display reaches the bottom of the buffer and another line *
31 * being printed causes another line to scroll down, that the buffer IS *
32 * memcpy()'s up, and the bottom of the buffer is still displayed, but *
33 * internally, I just wrap back to the top of the buffer. *
34 ***********************************************************************/
35
36 typedef struct tagCSRSS_SCREEN_BUFFER
37 {
38 Object_t Header; /* Object header */
39 BYTE *Buffer; /* pointer to screen buffer */
40 USHORT MaxX, MaxY; /* size of the entire scrollback buffer */
41 USHORT ShowX, ShowY; /* beginning offset for the actual display area */
42 ULONG CurrentX; /* Current X cursor position */
43 ULONG CurrentY; /* Current Y cursor position */
44 BYTE DefaultAttrib; /* default char attribute */
45 USHORT VirtualX; /* top row of buffer being displayed, reported to callers */
46 CONSOLE_CURSOR_INFO CursorInfo;
47 USHORT Mode;
48 } CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
49
50 typedef struct tagCSRSS_CONSOLE_VTBL
51 {
52 VOID (STDCALL *InitScreenBuffer)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer);
53 VOID (STDCALL *WriteStream)(PCSRSS_CONSOLE Console, RECT *Block, LONG CursorStartX, LONG CursorStartY,
54 UINT ScrolledLines, CHAR *Buffer, UINT Length);
55 VOID (STDCALL *DrawRegion)(PCSRSS_CONSOLE Console, RECT *Region);
56 BOOL (STDCALL *SetCursorInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer);
57 BOOL (STDCALL *SetScreenInfo)(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer,
58 UINT OldCursorX, UINT OldCursorY);
59 BOOL (STDCALL *ChangeTitle)(PCSRSS_CONSOLE Console);
60 VOID (STDCALL *CleanupConsole)(PCSRSS_CONSOLE Console);
61 BOOL (STDCALL *ChangeIcon)(PCSRSS_CONSOLE Console);
62 } CSRSS_CONSOLE_VTBL, *PCSRSS_CONSOLE_VTBL;
63
64 typedef struct tagCSRSS_CONSOLE
65 {
66 Object_t Header; /* Object header */
67 PCSRSS_CONSOLE Prev, Next; /* Next and Prev consoles in console wheel */
68 HANDLE ActiveEvent;
69 LIST_ENTRY InputEvents; /* List head for input event queue */
70 WORD WaitingChars;
71 WORD WaitingLines; /* number of chars and lines in input queue */
72 PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
73 WORD Mode; /* Console mode flags */
74 WORD EchoCount; /* count of chars to echo, in line buffered mode */
75 UNICODE_STRING Title; /* Title of console */
76 struct /* active code pages */
77 {
78 UINT Input;
79 UINT Output;
80 } CodePageId;
81 BOOL EarlyReturn; /* wake client and return data, even if we are in line buffered mode, and we don't have a complete line */
82 DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
83 HWND hWindow;
84 HICON hWindowIcon;
85 COORD Size;
86 PVOID PrivateData;
87 UINT CodePage;
88 UINT OutputCodePage;
89 PCSRSS_CONSOLE_VTBL Vtbl;
90 LIST_ENTRY ProcessList;
91 } CSRSS_CONSOLE;
92
93 VOID STDCALL ConioDeleteConsole(Object_t *Object);
94 VOID STDCALL ConioDeleteScreenBuffer(Object_t *Buffer);
95 void STDCALL ConioProcessKey(MSG *msg, PCSRSS_CONSOLE Console, BOOL TextMode);
96 void FASTCALL ConioPhysicalToLogical(PCSRSS_SCREEN_BUFFER Buff,
97 ULONG PhysicalX,
98 ULONG PhysicalY,
99 LONG *LogicalX,
100 LONG *LogicalY);
101 VOID FASTCALL ConioDrawConsole(PCSRSS_CONSOLE Console);
102 VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCSRSS_PROCESS_DATA ProcessData);
103 VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSRSS_PROCESS_DATA ProcessData,
104 DWORD Timeout);
105
106 /* api/conio.c */
107 CSR_API(CsrWriteConsole);
108 CSR_API(CsrAllocConsole);
109 CSR_API(CsrFreeConsole);
110 CSR_API(CsrReadConsole);
111 CSR_API(CsrConnectProcess);
112 CSR_API(CsrGetScreenBufferInfo);
113 CSR_API(CsrSetCursor);
114 CSR_API(CsrFillOutputChar);
115 CSR_API(CsrReadInputEvent);
116 CSR_API(CsrWriteConsoleOutputChar);
117 CSR_API(CsrWriteConsoleOutputAttrib);
118 CSR_API(CsrFillOutputAttrib);
119 CSR_API(CsrGetCursorInfo);
120 CSR_API(CsrSetCursorInfo);
121 CSR_API(CsrSetTextAttrib);
122 CSR_API(CsrSetConsoleMode);
123 CSR_API(CsrGetConsoleMode);
124 CSR_API(CsrCreateScreenBuffer);
125 CSR_API(CsrSetScreenBuffer);
126 CSR_API(CsrSetTitle);
127 CSR_API(CsrGetTitle);
128 CSR_API(CsrWriteConsoleOutput);
129 CSR_API(CsrFlushInputBuffer);
130 CSR_API(CsrScrollConsoleScreenBuffer);
131 CSR_API(CsrReadConsoleOutputChar);
132 CSR_API(CsrReadConsoleOutputAttrib);
133 CSR_API(CsrGetNumberOfConsoleInputEvents);
134 CSR_API(CsrPeekConsoleInput);
135 CSR_API(CsrReadConsoleOutput);
136 CSR_API(CsrWriteConsoleInput);
137 CSR_API(CsrHardwareStateProperty);
138 CSR_API(CsrGetConsoleWindow);
139 CSR_API(CsrSetConsoleIcon);
140 CSR_API(CsrGetConsoleCodePage);
141 CSR_API(CsrSetConsoleCodePage);
142 CSR_API(CsrGetConsoleOutputCodePage);
143 CSR_API(CsrSetConsoleOutputCodePage);
144 CSR_API(CsrGetProcessList);
145
146 #define ConioInitScreenBuffer(Console, Buff) (Console)->Vtbl->InitScreenBuffer((Console), (Buff))
147 #define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console), (Region))
148 #define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
149 (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \
150 (ScrolledLines), (Buffer), (Length))
151 #define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console), (Buff))
152 #define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
153 (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY))
154 #define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
155 #define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
156
157 #define ConioRectHeight(Rect) \
158 (((Rect)->top) > ((Rect)->bottom) ? 0 : ((Rect)->bottom) - ((Rect)->top) + 1)
159 #define ConioRectWidth(Rect) \
160 (((Rect)->left) > ((Rect)->right) ? 0 : ((Rect)->right) - ((Rect)->left) + 1)
161
162 #define ConioLockConsole(ProcessData, Handle, Ptr) \
163 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), CONIO_CONSOLE_MAGIC)
164 #define ConioUnlockConsole(Console) \
165 Win32CsrUnlockObject((Object_t *) Console)
166 #define ConioLockScreenBuffer(ProcessData, Handle, Ptr) \
167 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), CONIO_SCREEN_BUFFER_MAGIC)
168 #define ConioUnlockScreenBuffer(Buff) \
169 Win32CsrUnlockObject((Object_t *) Buff)
170 #define ConioChangeIcon(Console) (Console)->Vtbl->ChangeIcon(Console)
171
172 #endif /* CONIO_H_INCLUDED */
173
174 /* EOF */
175