2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/consrv/conio.h
5 * PURPOSE: Internal console I/O interface
11 #define CSR_DEFAULT_CURSOR_SIZE 25
13 /* Object type magic numbers */
15 #define CONIO_CONSOLE_MAGIC 0x00000001
16 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002
18 /************************************************************************
19 * Screen buffer structure represents the win32 screen buffer object. *
20 * Internally, the portion of the buffer being shown CAN loop past the *
21 * bottom of the virtual buffer and wrap around to the top. Win32 does *
22 * not do this. I decided to do this because it eliminates the need to *
23 * do a massive memcpy() to scroll the contents of the buffer up to *
24 * scroll the screen on output, instead I just shift down the position *
25 * to be displayed, and let it wrap around to the top again. *
26 * The VirtualY member keeps track of the top Y coord that win32 *
27 * clients THINK is currently being displayed, because they think that *
28 * when the display reaches the bottom of the buffer and another line *
29 * being printed causes another line to scroll down, that the buffer IS *
30 * memcpy()'s up, and the bottom of the buffer is still displayed, but *
31 * internally, I just wrap back to the top of the buffer. *
32 ***********************************************************************/
34 typedef struct tagCSRSS_SCREEN_BUFFER
36 Object_t Header
; /* Object header */
37 BYTE
*Buffer
; /* pointer to screen buffer */
38 USHORT MaxX
, MaxY
; /* size of the entire scrollback buffer */
39 USHORT ShowX
, ShowY
; /* beginning offset for the actual display area */
40 ULONG CurrentX
; /* Current X cursor position */
41 ULONG CurrentY
; /* Current Y cursor position */
42 WORD DefaultAttrib
; /* default char attribute */
43 USHORT VirtualY
; /* top row of buffer being displayed, reported to callers */
44 CONSOLE_CURSOR_INFO CursorInfo
;
46 LIST_ENTRY ListEntry
; /* entry in console's list of buffers */
47 } CSRSS_SCREEN_BUFFER
, *PCSRSS_SCREEN_BUFFER
;
49 typedef struct tagCSRSS_CONSOLE
51 Object_t Header
; /* Object header */
53 CRITICAL_SECTION Lock
;
54 struct tagCSRSS_CONSOLE
*Prev
, *Next
; /* Next and Prev consoles in console wheel */
57 LIST_ENTRY ReadWaitQueue
; /* List head for the queue of read wait blocks */
59 LIST_ENTRY InputEvents
; /* List head for input event queue */
60 PWCHAR LineBuffer
; /* current line being input, in line buffered mode */
61 WORD LineMaxSize
; /* maximum size of line in characters (including CR+LF) */
62 WORD LineSize
; /* current size of line */
63 WORD LinePos
; /* current position within line */
64 BOOLEAN LineComplete
; /* user pressed enter, ready to send back to client */
65 BOOLEAN LineUpPressed
;
66 BOOLEAN LineInsertToggle
; /* replace character over cursor instead of inserting */
67 ULONG LineWakeupMask
; /* bitmap of which control characters will end line input */
68 LIST_ENTRY HistoryBuffers
;
69 UINT HistoryBufferSize
; /* size for newly created history buffers */
70 UINT NumberOfHistoryBuffers
; /* maximum number of history buffers allowed */
71 BOOLEAN HistoryNoDup
; /* remove old duplicate history entries */
72 LIST_ENTRY BufferList
; /* List of all screen buffers for this console */
73 PCSRSS_SCREEN_BUFFER ActiveBuffer
; /* Pointer to currently active screen buffer */
74 WORD Mode
; /* Console mode flags */
75 UNICODE_STRING Title
; /* Title of console */
76 DWORD HardwareState
; /* _GDI_MANAGED, _DIRECT */
82 struct tagCSRSS_CONSOLE_VTBL
*Vtbl
;
83 LIST_ENTRY ProcessList
;
84 struct tagALIAS_HEADER
*Aliases
;
85 CONSOLE_SELECTION_INFO Selection
;
88 } CSRSS_CONSOLE
, *PCSRSS_CONSOLE
;
90 typedef struct tagCSRSS_CONSOLE_VTBL
92 VOID (WINAPI
*InitScreenBuffer
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
93 VOID (WINAPI
*WriteStream
)(PCSRSS_CONSOLE Console
, SMALL_RECT
*Block
, LONG CursorStartX
, LONG CursorStartY
,
94 UINT ScrolledLines
, CHAR
*Buffer
, UINT Length
);
95 VOID (WINAPI
*DrawRegion
)(PCSRSS_CONSOLE Console
, SMALL_RECT
*Region
);
96 BOOL (WINAPI
*SetCursorInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
97 BOOL (WINAPI
*SetScreenInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
,
98 UINT OldCursorX
, UINT OldCursorY
);
99 BOOL (WINAPI
*UpdateScreenInfo
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
);
100 BOOL (WINAPI
*ChangeTitle
)(PCSRSS_CONSOLE Console
);
101 VOID (WINAPI
*CleanupConsole
)(PCSRSS_CONSOLE Console
);
102 BOOL (WINAPI
*ChangeIcon
)(PCSRSS_CONSOLE Console
, HICON hWindowIcon
);
103 NTSTATUS (WINAPI
*ResizeBuffer
)(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER ScreenBuffer
, COORD Size
);
104 } CSRSS_CONSOLE_VTBL
, *PCSRSS_CONSOLE_VTBL
;
106 typedef struct ConsoleInput_t
108 LIST_ENTRY ListEntry
;
109 INPUT_RECORD InputEvent
;
112 /* CONSOLE_SELECTION_INFO dwFlags values */
113 #define CONSOLE_NO_SELECTION 0x0
114 #define CONSOLE_SELECTION_IN_PROGRESS 0x1
115 #define CONSOLE_SELECTION_NOT_EMPTY 0x2
116 #define CONSOLE_MOUSE_SELECTION 0x4
117 #define CONSOLE_MOUSE_DOWN 0x8
118 /* HistoryFlags values */
119 #define HISTORY_NO_DUP_FLAG 0x1
121 /* PauseFlags values (internal only) */
122 #define PAUSED_FROM_KEYBOARD 0x1
123 #define PAUSED_FROM_SCROLLBAR 0x2
124 #define PAUSED_FROM_SELECTION 0x4
126 #define ConioInitScreenBuffer(Console, Buff) (Console)->Vtbl->InitScreenBuffer((Console), (Buff))
127 #define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console), (Region))
128 #define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
129 (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \
130 (ScrolledLines), (Buffer), (Length))
131 #define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console), (Buff))
132 #define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
133 (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY))
134 #define ConioUpdateScreenInfo(Console, Buff) \
135 (Console)->Vtbl->UpdateScreenInfo(Console, Buff)
136 #define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
137 #define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
138 #define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon(Console, hWindowIcon)
139 #define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
142 NTSTATUS FASTCALL
ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData
,
143 PCSRSS_CONSOLE
*Console
);
144 VOID WINAPI
ConioDeleteConsole(Object_t
*Object
);
145 VOID WINAPI
CsrInitConsoleSupport(VOID
);
146 VOID FASTCALL
ConioPause(PCSRSS_CONSOLE Console
, UINT Flags
);
147 VOID FASTCALL
ConioUnpause(PCSRSS_CONSOLE Console
, UINT Flags
);
148 VOID FASTCALL
ConioConsoleCtrlEvent(DWORD Event
, PCONSOLE_PROCESS_DATA ProcessData
);
149 VOID FASTCALL
ConioConsoleCtrlEventTimeout(DWORD Event
,
150 PCONSOLE_PROCESS_DATA ProcessData
,
154 #define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
155 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_CONSOLE_MAGIC)
156 #define ConioUnlockConsole(Console) \
157 Win32CsrUnlockObject((Object_t *) Console)
158 void WINAPI
ConioProcessKey(MSG
*msg
, PCSRSS_CONSOLE Console
, BOOL TextMode
);
161 #define ConioRectHeight(Rect) \
162 (((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
163 #define ConioRectWidth(Rect) \
164 (((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
165 #define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
166 Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_SCREEN_BUFFER_MAGIC)
167 #define ConioUnlockScreenBuffer(Buff) \
168 Win32CsrUnlockObject((Object_t *) Buff)
169 PBYTE FASTCALL
ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buf
, ULONG X
, ULONG Y
);
170 VOID FASTCALL
ConioDrawConsole(PCSRSS_CONSOLE Console
);
171 NTSTATUS FASTCALL
ConioWriteConsole(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER Buff
,
172 CHAR
*Buffer
, DWORD Length
, BOOL Attrib
);
173 NTSTATUS FASTCALL
CsrInitConsoleScreenBuffer(PCSRSS_CONSOLE Console
, PCSRSS_SCREEN_BUFFER Buffer
);
174 VOID WINAPI
ConioDeleteScreenBuffer(PCSRSS_SCREEN_BUFFER Buffer
);
175 DWORD FASTCALL
ConioEffectiveCursorSize(PCSRSS_CONSOLE Console
, DWORD Scale
);
178 VOID
IntDeleteAllAliases(struct tagALIAS_HEADER
*RootHeader
);
181 struct tagHISTORY_BUFFER
;
182 VOID FASTCALL
HistoryDeleteBuffer(struct tagHISTORY_BUFFER
*Hist
);
183 VOID FASTCALL
LineInputKeyDown(PCSRSS_CONSOLE Console
, KEY_EVENT_RECORD
*KeyEvent
);