1 /* $Id: conio.h 55617 2012-02-15 20:29:08Z ion $
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 LIST_ENTRY ListEntry
; /* entry in console's list of buffers */
50 } CSRSS_SCREEN_BUFFER
, *PCSRSS_SCREEN_BUFFER
;
52 typedef struct tagCSRSS_CONSOLE
*PCSRSS_CONSOLE
;
54 typedef struct tagCSRSS_CONSOLE_VTBL
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
;
70 typedef struct tagCSRSS_CONSOLE
72 Object_t Header
; /* Object header */
74 CRITICAL_SECTION Lock
;
75 PCSRSS_CONSOLE Prev
, Next
; /* Next and Prev consoles in console wheel */
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 */
100 PCSRSS_CONSOLE_VTBL Vtbl
;
101 LIST_ENTRY ProcessList
;
102 struct tagALIAS_HEADER
*Aliases
;
103 CONSOLE_SELECTION_INFO Selection
;
108 typedef struct ConsoleInput_t
110 LIST_ENTRY ListEntry
;
111 INPUT_RECORD InputEvent
;
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
123 /* PauseFlags values (internal only) */
124 #define PAUSED_FROM_KEYBOARD 0x1
125 #define PAUSED_FROM_SCROLLBAR 0x2
126 #define PAUSED_FROM_SELECTION 0x4
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)
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
,
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
);