3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/console.c
23 * PURPOSE: Console support functions
24 * PROGRAMMER: Eric Kohl
27 /* INCLUDES ******************************************************************/
34 /* GLOBALS ******************************************************************/
36 HANDLE StdInput
= INVALID_HANDLE_VALUE
;
37 HANDLE StdOutput
= INVALID_HANDLE_VALUE
;
42 /* FUNCTIONS *****************************************************************/
48 CONSOLE_SCREEN_BUFFER_INFO csbi
;
49 if (!HOST_InitConsole())
52 StdInput
= GetStdHandle(STD_INPUT_HANDLE
);
53 StdOutput
= GetStdHandle(STD_OUTPUT_HANDLE
);
54 if (!GetConsoleScreenBufferInfo(StdOutput
, &csbi
))
56 xScreen
= csbi
.dwSize
.X
;
57 yScreen
= 50;//csbi.dwSize.Y;
63 OUT PINPUT_RECORD Buffer
)
69 ReadConsoleInput(StdInput
, Buffer
, 1, &Read
);
71 if ((Buffer
->EventType
== KEY_EVENT
)
72 && (Buffer
->Event
.KeyEvent
.bKeyDown
== TRUE
))
100 (ULONG
)strlen(szText
),
112 CONSOLE_ConOutPrintf(
113 IN LPCSTR szFormat
, ...)
119 va_start(arg_ptr
, szFormat
);
120 vsprintf(szOut
, szFormat
, arg_ptr
);
126 (ULONG
)strlen(szOut
),
134 return FlushConsoleInputBuffer(StdInput
);
138 CONSOLE_GetCursorX(VOID
)
140 CONSOLE_SCREEN_BUFFER_INFO csbi
;
142 GetConsoleScreenBufferInfo(StdOutput
, &csbi
);
144 return csbi
.dwCursorPosition
.X
;
148 CONSOLE_GetCursorY(VOID
)
150 CONSOLE_SCREEN_BUFFER_INFO csbi
;
152 GetConsoleScreenBufferInfo(StdOutput
, &csbi
);
154 return csbi
.dwCursorPosition
.Y
;
158 CONSOLE_SetCursorType(
162 CONSOLE_CURSOR_INFO cci
;
164 cci
.dwSize
= bInsert
? 10 : 99;
165 cci
.bVisible
= bVisible
;
167 SetConsoleCursorInfo(StdOutput
, &cci
);
179 SetConsoleCursorPosition(StdOutput
, coPos
);
183 CONSOLE_ClearScreen(VOID
)
191 FillConsoleOutputAttribute(
193 FOREGROUND_WHITE
| BACKGROUND_BLUE
,
198 FillConsoleOutputCharacterA(
207 CONSOLE_SetStatusText(
216 vsprintf(Buffer
, fmt
, ap
);
220 coPos
.Y
= yScreen
- 1;
222 FillConsoleOutputAttribute(
229 FillConsoleOutputCharacterA(
236 WriteConsoleOutputCharacterA(
239 (ULONG
)strlen(Buffer
),
245 CONSOLE_InvertTextXY(
254 for (coPos
.Y
= y
; coPos
.Y
< y
+ row
; coPos
.Y
++)
258 FillConsoleOutputAttribute(
260 FOREGROUND_BLUE
| BACKGROUND_WHITE
,
268 CONSOLE_NormalTextXY(
277 for (coPos
.Y
= y
; coPos
.Y
< y
+ row
; coPos
.Y
++)
281 FillConsoleOutputAttribute(
283 FOREGROUND_WHITE
| BACKGROUND_BLUE
,
302 WriteConsoleOutputCharacterA(
311 CONSOLE_SetInputTextXY(
324 Length
= (SHORT
)wcslen(Text
);
325 if (Length
> len
- 1)
328 FillConsoleOutputAttribute(
335 WriteConsoleOutputCharacterW(
343 FillConsoleOutputCharacterA(
350 if (len
> Length
+ 1)
353 FillConsoleOutputCharacterA(
363 CONSOLE_SetUnderlinedTextXY(
375 Length
= (ULONG
)strlen(Text
);
377 WriteConsoleOutputCharacterA(
385 FillConsoleOutputCharacterA(
394 CONSOLE_SetInvertedTextXY(
406 Length
= (ULONG
)strlen(Text
);
408 FillConsoleOutputAttribute(
410 FOREGROUND_BLUE
| BACKGROUND_WHITE
,
415 WriteConsoleOutputCharacterA(
424 CONSOLE_SetHighlightedTextXY(
436 Length
= (ULONG
)strlen(Text
);
438 FillConsoleOutputAttribute(
440 FOREGROUND_WHITE
| FOREGROUND_INTENSITY
| BACKGROUND_BLUE
,
445 WriteConsoleOutputCharacterA(
465 vsprintf(buffer
, fmt
, ap
);
471 WriteConsoleOutputCharacterA(
474 (ULONG
)strlen(buffer
),
480 CONSOLE_PrintTextXYN(
493 vsprintf(buffer
, fmt
, ap
);
499 Length
= (SHORT
)strlen(buffer
);
500 if (Length
> len
- 1)
503 WriteConsoleOutputCharacterA(
514 FillConsoleOutputCharacterA(