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