ReactOS 0.4.16-dev-250-g3ecd236
conio_winsrv.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CHAR_CELL
 
struct  _FRONTEND_VTBL
 
struct  _FRONTEND
 
struct  _CONSRV_CONSOLE
 

Macros

#define CSR_DEFAULT_CURSOR_SIZE   25
 
#define PAUSED_FROM_KEYBOARD   0x1
 
#define PAUSED_FROM_SCROLLBAR   0x2
 
#define PAUSED_FROM_SELECTION   0x4
 

Typedefs

typedef struct _CHAR_CELL CHAR_CELL
 
typedef struct _CHAR_CELLPCHAR_CELL
 
typedef struct _FRONTEND FRONTEND
 
typedef struct _FRONTENDPFRONTEND
 
typedef struct _FRONTEND_VTBL FRONTEND_VTBL
 
typedef struct _FRONTEND_VTBLPFRONTEND_VTBL
 
typedef struct _CONSRV_CONSOLE CONSRV_CONSOLE
 
typedef struct _CONSRV_CONSOLEPCONSRV_CONSOLE
 

Functions

 C_ASSERT (sizeof(CHAR_CELL)==2)
 
VOID ConioPause (PCONSRV_CONSOLE Console, UCHAR Flags)
 
VOID ConioUnpause (PCONSRV_CONSOLE Console, UCHAR Flags)
 
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess (IN PCONSRV_CONSOLE Console)
 
NTSTATUS ConSrvConsoleCtrlEvent (IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
 
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent (IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
 
VOID ConSrvSetProcessFocus (IN PCSR_PROCESS CsrProcess, IN BOOLEAN SetForeground)
 
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus (IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
 
VOID NTAPI ConioProcessKey (PCONSRV_CONSOLE Console, MSG *msg)
 
DWORD ConioEffectiveCursorSize (PCONSRV_CONSOLE Console, DWORD Scale)
 
NTSTATUS ConioProcessInputEvent (PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
 
PCHAR_INFO ConioCoordToPointer (PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
 
VOID ConioDrawConsole (PCONSRV_CONSOLE Console)
 

Macro Definition Documentation

◆ CSR_DEFAULT_CURSOR_SIZE

#define CSR_DEFAULT_CURSOR_SIZE   25

Definition at line 16 of file conio_winsrv.h.

◆ PAUSED_FROM_KEYBOARD

#define PAUSED_FROM_KEYBOARD   0x1

Definition at line 109 of file conio_winsrv.h.

◆ PAUSED_FROM_SCROLLBAR

#define PAUSED_FROM_SCROLLBAR   0x2

Definition at line 110 of file conio_winsrv.h.

◆ PAUSED_FROM_SELECTION

#define PAUSED_FROM_SELECTION   0x4

Definition at line 111 of file conio_winsrv.h.

Typedef Documentation

◆ CHAR_CELL

◆ CONSRV_CONSOLE

◆ FRONTEND

Definition at line 28 of file conio_winsrv.h.

◆ FRONTEND_VTBL

◆ PCHAR_CELL

◆ PCONSRV_CONSOLE

◆ PFRONTEND

Definition at line 28 of file conio_winsrv.h.

◆ PFRONTEND_VTBL

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(CHAR_CELL = =2)

◆ ConioCoordToPointer()

PCHAR_INFO ConioCoordToPointer ( PTEXTMODE_SCREEN_BUFFER  Buff,
ULONG  X,
ULONG  Y 
)

◆ ConioDrawConsole()

VOID ConioDrawConsole ( PCONSRV_CONSOLE  Console)

Definition at line 860 of file terminal.c.

861{
863 PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
864
865 if (!ActiveBuffer) return;
866
867 ConioInitRect(&Region, 0, 0,
868 ActiveBuffer->ViewSize.Y - 1,
869 ActiveBuffer->ViewSize.X - 1);
871 // Console->FrontEndIFace.Vtbl->DrawRegion(&Console->FrontEndIFace, &Region);
872}
CConsole Console
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20

Referenced by ConioProcessKey().

◆ ConioEffectiveCursorSize()

DWORD ConioEffectiveCursorSize ( PCONSRV_CONSOLE  Console,
DWORD  Scale 
)

Definition at line 182 of file input.c.

183{
184 DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100;
185 /* If line input in progress, perhaps adjust for insert toggle */
186 if (Console->LineBuffer && !Console->LineComplete && (Console->InsertMode ? !Console->LineInsertToggle : Console->LineInsertToggle))
187 return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2);
188 return Size;
189}
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by GuiPaintCaret().

◆ ConioPause()

VOID ConioPause ( PCONSRV_CONSOLE  Console,
UCHAR  Flags 
)

Definition at line 859 of file console.c.

860{
861 Console->PauseFlags |= Flags;
863}
VOID NTAPI ConDrvPause(PCONSOLE Console)
Definition: console.c:304
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by OnScroll(), PreprocessInput(), and UpdateSelection().

◆ ConioProcessInputEvent()

NTSTATUS ConioProcessInputEvent ( PCONSRV_CONSOLE  Console,
PINPUT_RECORD  InputEvent 
)

Definition at line 201 of file coninput.c.

203{
204 ULONG NumEventsWritten;
205
206 if (InputEvent->EventType == KEY_EVENT)
207 {
208 BOOL Down = InputEvent->Event.KeyEvent.bKeyDown;
209 UINT VirtualKeyCode = InputEvent->Event.KeyEvent.wVirtualKeyCode;
210 DWORD ShiftState = InputEvent->Event.KeyEvent.dwControlKeyState;
211
212 /* Process Ctrl-C and Ctrl-Break */
214 Down && (VirtualKeyCode == VK_PAUSE || VirtualKeyCode == 'C') &&
215 (ShiftState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) )
216 {
217 DPRINT1("Console_Api Ctrl-C\n");
219
220 if (Console->LineBuffer && !Console->LineComplete)
221 {
222 /* Line input is in progress; end it */
223 Console->LinePos = Console->LineSize = 0;
224 Console->LineComplete = TRUE;
225 }
226 return STATUS_SUCCESS; // STATUS_CONTROL_C_EXIT;
227 }
228 }
229
231 InputEvent,
232 1,
233 &NumEventsWritten,
234 TRUE);
235}
#define DPRINT1
Definition: precomp.h:8
static NTSTATUS ConioAddInputEvents(PCONSRV_CONSOLE Console, PINPUT_RECORD InputRecords, ULONG NumEventsToWrite, PULONG NumEventsWritten, BOOLEAN AppendToEnd)
Definition: coninput.c:167
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int UINT
Definition: ndis.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
union _INPUT_RECORD::@3285 Event
WORD EventType
Definition: wincon.h:273
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:275
DWORD dwControlKeyState
Definition: wincon.h:248
WORD wVirtualKeyCode
Definition: wincon.h:242
uint32_t ULONG
Definition: typedefs.h:59
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:1402
#define GetConsoleInputBufferMode(Console)
Definition: conio.h:320
#define CTRL_C_EVENT
Definition: wincon.h:68
#define LEFT_CTRL_PRESSED
Definition: wincon.h:140
#define KEY_EVENT
Definition: wincon.h:128
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:139
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:78
#define VK_PAUSE
Definition: winuser.h:2208

Referenced by ConioProcessKey(), OnFocus(), OnMouse(), PasteText(), and SendMenuEvent().

◆ ConioProcessKey()

VOID NTAPI ConioProcessKey ( PCONSRV_CONSOLE  Console,
MSG msg 
)

Definition at line 60 of file input.c.

61{
62 static BYTE KeyState[256] = { 0 };
63 /* MSDN mentions that you should use the last virtual key code received
64 * when putting a virtual key identity to a WM_CHAR message since multiple
65 * or translated keys may be involved. */
66 static UINT LastVirtualKey = 0;
67 DWORD ShiftState;
68 WCHAR UnicodeChar;
69 UINT VirtualKeyCode;
70 UINT VirtualScanCode;
71 BOOL Down;
72 BOOLEAN Fake; // Synthesized, not a real event
73 BOOLEAN NotChar; // Message should not be used to return a character
74
75 INPUT_RECORD er;
76
77 if (Console == NULL)
78 {
79 DPRINT1("No Active Console!\n");
80 return;
81 }
82
83 VirtualScanCode = HIWORD(msg->lParam) & 0xFF;
84 Down = msg->message == WM_KEYDOWN || msg->message == WM_CHAR ||
85 msg->message == WM_SYSKEYDOWN || msg->message == WM_SYSCHAR;
86
87 GetKeyboardState(KeyState);
88 ShiftState = ConioGetShiftState(KeyState, msg->lParam);
89
90 if (msg->message == WM_CHAR || msg->message == WM_SYSCHAR)
91 {
92 VirtualKeyCode = LastVirtualKey;
93 UnicodeChar = msg->wParam;
94 }
95 else
96 {
97 WCHAR Chars[2];
98 INT RetChars = 0;
99
100 VirtualKeyCode = msg->wParam;
101 RetChars = ToUnicodeEx(VirtualKeyCode,
102 VirtualScanCode,
103 KeyState,
104 Chars,
105 2,
106 0,
107 NULL);
108 UnicodeChar = (RetChars == 1 ? Chars[0] : 0);
109 }
110
111 Fake = UnicodeChar &&
112 (msg->message != WM_CHAR && msg->message != WM_SYSCHAR &&
113 msg->message != WM_KEYUP && msg->message != WM_SYSKEYUP);
114 NotChar = (msg->message != WM_CHAR && msg->message != WM_SYSCHAR);
115 if (NotChar) LastVirtualKey = msg->wParam;
116
117 DPRINT("CONSRV: %s %s %s %s %02x %02x '%lc' %04x\n",
118 Down ? "down" : "up ",
119 (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) ?
120 "char" : "key ",
121 Fake ? "fake" : "real",
122 NotChar ? "notc" : "char",
123 VirtualScanCode,
124 VirtualKeyCode,
125 (UnicodeChar >= L' ') ? UnicodeChar : L'.',
126 ShiftState);
127
128 if (Fake) return;
129
130//
131// FIXME: Scrolling via keyboard shortcuts must be done differently,
132// without touching the internal VirtualY variable.
133//
134#if 0
135 if ( (ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) != 0 &&
136 (VirtualKeyCode == VK_UP || VirtualKeyCode == VK_DOWN) )
137 {
138 if (!Down) return;
139
140 /* Scroll up or down */
141 if (VirtualKeyCode == VK_UP)
142 {
143 /* Only scroll up if there is room to scroll up into */
144 if (Console->ActiveBuffer->CursorPosition.Y != Console->ActiveBuffer->ScreenBufferSize.Y - 1)
145 {
146 Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY +
147 Console->ActiveBuffer->ScreenBufferSize.Y - 1) %
148 Console->ActiveBuffer->ScreenBufferSize.Y;
149 Console->ActiveBuffer->CursorPosition.Y++;
150 }
151 }
152 else
153 {
154 /* Only scroll down if there is room to scroll down into */
155 if (Console->ActiveBuffer->CursorPosition.Y != 0)
156 {
157 Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY + 1) %
158 Console->ActiveBuffer->ScreenBufferSize.Y;
159 Console->ActiveBuffer->CursorPosition.Y--;
160 }
161 }
162
164 return;
165 }
166#endif
167
168 /* Send the key press to the console driver */
169
170 er.EventType = KEY_EVENT;
171 er.Event.KeyEvent.bKeyDown = Down;
173 er.Event.KeyEvent.wVirtualKeyCode = VirtualKeyCode;
174 er.Event.KeyEvent.wVirtualScanCode = VirtualScanCode;
175 er.Event.KeyEvent.uChar.UnicodeChar = UnicodeChar;
176 er.Event.KeyEvent.dwControlKeyState = ShiftState;
177
179}
unsigned char BOOLEAN
#define msg(x)
Definition: auth_time.c:54
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:201
#define NULL
Definition: types.h:112
#define L(x)
Definition: ntvdm.h:50
#define DPRINT
Definition: sndvol32.h:73
union _KEY_EVENT_RECORD::@3284 uChar
WORD wVirtualScanCode
Definition: wincon.h:243
WORD wRepeatCount
Definition: wincon.h:241
WCHAR UnicodeChar
Definition: wincon.h:245
VOID ConioDrawConsole(PCONSRV_CONSOLE Console)
Definition: terminal.c:860
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
static DWORD ConioGetShiftState(PBYTE KeyState, LPARAM lParam)
Definition: input.c:23
#define RIGHT_ALT_PRESSED
Definition: wincon.h:137
#define LEFT_ALT_PRESSED
Definition: wincon.h:138
#define WM_KEYUP
Definition: winuser.h:1719
#define VK_UP
Definition: winuser.h:2228
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define WM_SYSCHAR
Definition: winuser.h:1724
#define WM_SYSKEYUP
Definition: winuser.h:1723
#define WM_CHAR
Definition: winuser.h:1720
#define VK_DOWN
Definition: winuser.h:2230
int WINAPI ToUnicodeEx(_In_ UINT wVirtKey, _In_ UINT wScanCode, _In_reads_bytes_(256) CONST BYTE *lpKeyState, _Out_writes_(cchBuff) LPWSTR pwszBuff, _In_ int cchBuff, _In_ UINT wFlags, _In_opt_ HKL dwhkl)
#define WM_KEYDOWN
Definition: winuser.h:1718
#define WM_SYSKEYDOWN
Definition: winuser.h:1722
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by OnKey().

◆ ConioUnpause()

VOID ConioUnpause ( PCONSRV_CONSOLE  Console,
UCHAR  Flags 
)

Definition at line 866 of file console.c.

867{
868 Console->PauseFlags &= ~Flags;
869
870 // if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
871 if (Console->PauseFlags == 0)
872 {
874
875 CsrNotifyWait(&Console->WriteWaitQueue,
876 TRUE,
877 NULL,
878 NULL);
879 if (!IsListEmpty(&Console->WriteWaitQueue))
880 {
881 CsrDereferenceWait(&Console->WriteWaitQueue);
882 }
883 }
884}
VOID NTAPI CsrDereferenceWait(IN PLIST_ENTRY WaitList)
Definition: wait.c:266
BOOLEAN NTAPI CsrNotifyWait(IN PLIST_ENTRY WaitList, IN BOOLEAN NotifyAll, IN PVOID WaitArgument1, IN PVOID WaitArgument2)
Definition: wait.c:388
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
VOID NTAPI ConDrvUnpause(PCONSOLE Console)
Definition: console.c:314

Referenced by OnScroll(), PreprocessInput(), and UpdateSelection().

◆ ConSrvConsoleCtrlEvent()

NTSTATUS ConSrvConsoleCtrlEvent ( IN ULONG  CtrlEvent,
IN PCONSOLE_PROCESS_DATA  ProcessData 
)

Definition at line 1356 of file console.c.

1358{
1359 return ConSrvConsoleCtrlEventTimeout(CtrlEvent, ProcessData, 0);
1360}
NTSTATUS ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:1305

Referenced by ConSrvConsoleProcessCtrlEvent(), and ConSrvRemoveConsole().

◆ ConSrvConsoleProcessCtrlEvent()

NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent ( IN PCONSRV_CONSOLE  Console,
IN ULONG  ProcessGroupId,
IN ULONG  CtrlEvent 
)

Definition at line 1402 of file console.c.

1405{
1407 PLIST_ENTRY current_entry;
1409
1410 /* If the console is already being destroyed, just return */
1412 return STATUS_UNSUCCESSFUL;
1413
1414 /*
1415 * Loop through the process list, from the most recent process
1416 * (the active one) to the oldest one (the first created, i.e.
1417 * the console leader process), and for each, send an event
1418 * (new processes are inserted at the head of the console process list).
1419 */
1420 current_entry = Console->ProcessList.Flink;
1421 while (current_entry != &Console->ProcessList)
1422 {
1423 current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
1424 current_entry = current_entry->Flink;
1425
1426 /*
1427 * Only processes belonging to the same process group are signaled.
1428 * If the process group ID is zero, then all the processes are signaled.
1429 */
1430 if (ProcessGroupId == 0 || current->Process->ProcessGroupId == ProcessGroupId)
1431 {
1433 }
1434 }
1435
1436 return Status;
1437}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
struct task_struct * current
Definition: linux.c:32
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
BOOLEAN NTAPI ConDrvValidateConsoleState(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
Definition: console.c:24
NTSTATUS ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
Definition: console.c:1356
@ CONSOLE_RUNNING
Definition: conio.h:283

Referenced by CON_API(), ConioProcessInputEvent(), and OnClose().

◆ ConSrvGetConsoleLeaderProcess()

PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess ( IN PCONSRV_CONSOLE  Console)

Definition at line 1363 of file console.c.

1364{
1365 if (Console == NULL) return NULL;
1366
1367 return CONTAINING_RECORD(Console->ProcessList.Blink,
1369 ConsoleLink);
1370}

Referenced by ConSrvRemoveConsole(), GuiApplyUserSettings(), GuiConsoleShowConsoleProperties(), and SetConWndConsoleLeaderCID().

◆ ConSrvSetConsoleProcessFocus()

NTSTATUS NTAPI ConSrvSetConsoleProcessFocus ( IN PCONSRV_CONSOLE  Console,
IN BOOLEAN  SetForeground 
)

Definition at line 1453 of file console.c.

1455{
1456 PLIST_ENTRY current_entry;
1458
1459 /* If the console is already being destroyed, just return */
1461 return STATUS_UNSUCCESSFUL;
1462
1463 /*
1464 * Loop through the process list, from the most recent process
1465 * to the oldest one, and for each, set its foreground priority.
1466 */
1467 current_entry = Console->ProcessList.Flink;
1468 while (current_entry != &Console->ProcessList)
1469 {
1470 current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
1471 current_entry = current_entry->Flink;
1472
1473 ConSrvSetProcessFocus(current->Process, SetForeground);
1474 }
1475
1476 return STATUS_SUCCESS;
1477}
VOID ConSrvSetProcessFocus(IN PCSR_PROCESS CsrProcess, IN BOOLEAN SetForeground)
Definition: console.c:1440

Referenced by OnFocus().

◆ ConSrvSetProcessFocus()

VOID ConSrvSetProcessFocus ( IN PCSR_PROCESS  CsrProcess,
IN BOOLEAN  SetForeground 
)

Definition at line 1440 of file console.c.

1442{
1443 // FIXME: Call NtUserSetInformationProcess (currently unimplemented!)
1444 // for setting Win32 foreground/background flags.
1445
1446 if (SetForeground)
1448 else
1450}
VOID NTAPI CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1138
VOID NTAPI CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1107
PKPROCESS CsrProcess
Definition: videoprt.c:39

Referenced by ConSrvAllocateConsole(), ConSrvInheritConsole(), and ConSrvSetConsoleProcessFocus().