2006-11-10 18:20:00 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 2002 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-11-10 18:20:00 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS text-mode setup
|
2018-05-15 17:47:52 +00:00
|
|
|
* FILE: base/setup/usetup/consup.c
|
2006-11-10 18:20:00 +00:00
|
|
|
* PURPOSE: Console support functions
|
2018-05-27 19:33:07 +00:00
|
|
|
* PROGRAMMER:
|
2006-11-10 18:20:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <usetup.h>
|
2006-11-10 18:20:00 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2006-11-10 21:00:24 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
|
|
|
HANDLE StdInput = INVALID_HANDLE_VALUE;
|
|
|
|
HANDLE StdOutput = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
SHORT xScreen = 0;
|
|
|
|
SHORT yScreen = 0;
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2006-11-10 21:00:24 +00:00
|
|
|
BOOLEAN
|
|
|
|
CONSOLE_Init(
|
2014-05-15 16:32:30 +00:00
|
|
|
VOID)
|
2006-11-10 21:00:24 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
2018-05-15 21:35:17 +00:00
|
|
|
if (!AllocConsole())
|
2014-05-15 16:32:30 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
StdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
StdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
if (!GetConsoleScreenBufferInfo(StdOutput, &csbi))
|
|
|
|
return FALSE;
|
|
|
|
xScreen = csbi.dwSize.X;
|
2018-09-29 19:48:27 +00:00
|
|
|
yScreen = csbi.dwSize.Y;
|
2014-05-15 16:32:30 +00:00
|
|
|
return TRUE;
|
2006-11-10 21:00:24 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_ConInKey(
|
2014-05-15 16:32:30 +00:00
|
|
|
OUT PINPUT_RECORD Buffer)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
DWORD Read;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
2018-08-26 22:22:07 +00:00
|
|
|
/* Wait for a key press */
|
2014-05-15 16:32:30 +00:00
|
|
|
ReadConsoleInput(StdInput, Buffer, 1, &Read);
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2018-08-26 22:22:07 +00:00
|
|
|
if ((Buffer->EventType == KEY_EVENT) &&
|
|
|
|
(Buffer->Event.KeyEvent.bKeyDown != FALSE))
|
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
break;
|
2018-08-26 22:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
CONSOLE_ConInKeyPeek(
|
|
|
|
OUT PINPUT_RECORD Buffer)
|
|
|
|
{
|
|
|
|
DWORD Read = 0;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
/* Try to get a key press without blocking */
|
|
|
|
if (!PeekConsoleInput(StdInput, Buffer, 1, &Read))
|
|
|
|
return FALSE;
|
|
|
|
if (Read == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Consume it */
|
|
|
|
ReadConsoleInput(StdInput, Buffer, 1, &Read);
|
|
|
|
|
|
|
|
if ((Buffer->EventType == KEY_EVENT) &&
|
|
|
|
(Buffer->Event.KeyEvent.bKeyDown != FALSE))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_ConOutChar(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN CHAR c)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
WriteConsole(
|
|
|
|
StdOutput,
|
|
|
|
&c,
|
|
|
|
1,
|
|
|
|
&Written,
|
|
|
|
NULL);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_ConOutPuts(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN LPCSTR szText)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
WriteConsole(
|
|
|
|
StdOutput,
|
|
|
|
szText,
|
|
|
|
(ULONG)strlen(szText),
|
|
|
|
&Written,
|
|
|
|
NULL);
|
|
|
|
WriteConsole(
|
|
|
|
StdOutput,
|
|
|
|
"\n",
|
|
|
|
1,
|
|
|
|
&Written,
|
|
|
|
NULL);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_ConOutPrintf(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN LPCSTR szFormat, ...)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR szOut[256];
|
|
|
|
DWORD dwWritten;
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
|
|
|
va_start(arg_ptr, szFormat);
|
|
|
|
vsprintf(szOut, szFormat, arg_ptr);
|
|
|
|
va_end(arg_ptr);
|
|
|
|
|
|
|
|
WriteConsole(
|
|
|
|
StdOutput,
|
|
|
|
szOut,
|
|
|
|
(ULONG)strlen(szOut),
|
|
|
|
&dwWritten,
|
|
|
|
NULL);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 13:13:55 +00:00
|
|
|
BOOL
|
|
|
|
CONSOLE_Flush(VOID)
|
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
return FlushConsoleInputBuffer(StdInput);
|
2007-11-02 13:13:55 +00:00
|
|
|
}
|
|
|
|
|
2014-12-20 21:58:22 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_GetCursorXY(
|
|
|
|
PSHORT x,
|
|
|
|
PSHORT y)
|
|
|
|
{
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
|
|
|
|
|
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
|
|
|
|
|
|
|
*x = csbi.dwCursorPosition.X;
|
|
|
|
*y = csbi.dwCursorPosition.Y;
|
|
|
|
}
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
SHORT
|
|
|
|
CONSOLE_GetCursorX(VOID)
|
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
GetConsoleScreenBufferInfo(StdOutput, &csbi);
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
return csbi.dwCursorPosition.X;
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SHORT
|
|
|
|
CONSOLE_GetCursorY(VOID)
|
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
GetConsoleScreenBufferInfo(StdOutput, &csbi);
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
return csbi.dwCursorPosition.Y;
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetCursorType(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN BOOL bInsert,
|
|
|
|
IN BOOL bVisible)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CONSOLE_CURSOR_INFO cci;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
cci.dwSize = bInsert ? 10 : 99;
|
|
|
|
cci.bVisible = bVisible;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
SetConsoleCursorInfo(StdOutput, &cci);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetCursorXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
2006-11-10 18:20:00 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
SetConsoleCursorPosition(StdOutput, coPos);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_ClearScreen(VOID)
|
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = 0;
|
|
|
|
coPos.Y = 0;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
FOREGROUND_WHITE | BACKGROUND_BLUE,
|
|
|
|
xScreen * yScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
' ',
|
|
|
|
xScreen * yScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_InvertTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN SHORT col,
|
|
|
|
IN SHORT row)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
for (coPos.Y = y; coPos.Y < y + row; coPos.Y++)
|
|
|
|
{
|
|
|
|
coPos.X = x;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
FOREGROUND_BLUE | BACKGROUND_WHITE,
|
|
|
|
col,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_NormalTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN SHORT col,
|
|
|
|
IN SHORT row)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
for (coPos.Y = y; coPos.Y < y + row; coPos.Y++)
|
|
|
|
{
|
|
|
|
coPos.X = x;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
FOREGROUND_WHITE | BACKGROUND_BLUE,
|
|
|
|
col,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN LPCSTR Text)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Text,
|
|
|
|
(ULONG)strlen(Text),
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 18:27:42 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
CONSOLE_ClearTextXY(IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN SHORT Length)
|
|
|
|
{
|
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
|
|
|
' ',
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_SetInputTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN SHORT len,
|
|
|
|
IN LPCWSTR Text)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
SHORT Length;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
Length = (SHORT)wcslen(Text);
|
|
|
|
if (Length > len - 1)
|
|
|
|
Length = len - 1;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
BACKGROUND_WHITE,
|
|
|
|
len,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterW(
|
|
|
|
StdOutput,
|
|
|
|
Text,
|
|
|
|
(ULONG)Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
coPos.X += Length;
|
2018-05-15 09:28:33 +00:00
|
|
|
if (len > Length)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
' ',
|
2018-05-15 09:28:33 +00:00
|
|
|
len - Length,
|
2014-05-15 16:32:30 +00:00
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetUnderlinedTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN LPCSTR Text)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Length;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
Length = (ULONG)strlen(Text);
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Text,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
coPos.Y++;
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
0xCD,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
2008-03-20 18:28:37 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_SetStatusText(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN LPCSTR fmt, ...)
|
2008-03-20 18:28:37 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR Buffer[128];
|
|
|
|
va_list ap;
|
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(Buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
coPos.X = 0;
|
|
|
|
coPos.Y = yScreen - 1;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
BACKGROUND_WHITE,
|
|
|
|
xScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
' ',
|
|
|
|
xScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Buffer,
|
|
|
|
(ULONG)strlen(Buffer),
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2008-03-20 18:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetStatusTextX(
|
|
|
|
IN SHORT x,
|
2014-05-15 16:32:30 +00:00
|
|
|
IN LPCSTR fmt, ...)
|
2008-03-20 18:28:37 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR Buffer[128];
|
|
|
|
va_list ap;
|
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(Buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
coPos.X = 0;
|
|
|
|
coPos.Y = yScreen - 1;
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
BACKGROUND_WHITE,
|
|
|
|
xScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
' ',
|
|
|
|
xScreen,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2008-03-20 18:28:37 +00:00
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Buffer,
|
|
|
|
(ULONG)strlen(Buffer),
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2008-03-20 18:28:37 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 18:27:42 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
CONSOLE_ClearStatusTextX(IN SHORT x,
|
|
|
|
IN SHORT Length)
|
|
|
|
{
|
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = yScreen - 1;
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
|
|
|
' ',
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-20 18:28:37 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_SetStatusTextAutoFitX(
|
|
|
|
IN SHORT x,
|
2014-05-15 16:32:30 +00:00
|
|
|
IN LPCSTR fmt, ...)
|
2008-03-20 18:28:37 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR Buffer[128];
|
2008-03-20 18:28:37 +00:00
|
|
|
DWORD Length;
|
2014-05-15 16:32:30 +00:00
|
|
|
va_list ap;
|
2008-03-20 18:28:37 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(Buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
2008-03-20 18:28:37 +00:00
|
|
|
|
|
|
|
Length = (ULONG)strlen(Buffer);
|
|
|
|
|
|
|
|
if (Length + x <= 79)
|
|
|
|
{
|
|
|
|
CONSOLE_SetStatusTextX (x , Buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CONSOLE_SetStatusTextX (79 - Length , Buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_SetInvertedTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN LPCSTR Text)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Length;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
Length = (ULONG)strlen(Text);
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
FOREGROUND_BLUE | BACKGROUND_WHITE,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Text,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_SetHighlightedTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN LPCSTR Text)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Length;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
Length = (ULONG)strlen(Text);
|
|
|
|
|
|
|
|
FillConsoleOutputAttribute(
|
|
|
|
StdOutput,
|
|
|
|
FOREGROUND_WHITE | FOREGROUND_INTENSITY | BACKGROUND_BLUE,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
Text,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_PrintTextXY(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN LPCSTR fmt, ...)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR buffer[512];
|
|
|
|
va_list ap;
|
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
buffer,
|
|
|
|
(ULONG)strlen(buffer),
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_PrintTextXYN(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN SHORT len,
|
|
|
|
IN LPCSTR fmt, ...)
|
2006-11-10 18:20:00 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
CHAR buffer[512];
|
|
|
|
va_list ap;
|
|
|
|
COORD coPos;
|
|
|
|
SHORT Length;
|
|
|
|
DWORD Written;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
Length = (SHORT)strlen(buffer);
|
|
|
|
if (Length > len - 1)
|
|
|
|
Length = len - 1;
|
|
|
|
|
|
|
|
WriteConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
buffer,
|
|
|
|
Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
coPos.X += Length;
|
|
|
|
|
|
|
|
if (len > Length)
|
|
|
|
{
|
|
|
|
FillConsoleOutputCharacterA(
|
|
|
|
StdOutput,
|
|
|
|
' ',
|
|
|
|
len - Length,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2006-11-10 18:20:00 +00:00
|
|
|
}
|
|
|
|
|
2008-03-19 04:43:40 +00:00
|
|
|
VOID
|
|
|
|
CONSOLE_SetStyledText(
|
2014-05-15 16:32:30 +00:00
|
|
|
IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN INT Flags,
|
|
|
|
IN LPCSTR Text)
|
2008-03-19 04:43:40 +00:00
|
|
|
{
|
2014-05-15 16:32:30 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Length;
|
2008-03-19 04:43:40 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
2008-03-19 04:43:40 +00:00
|
|
|
|
2014-05-15 16:32:30 +00:00
|
|
|
Length = (ULONG)strlen(Text);
|
2008-03-19 04:43:40 +00:00
|
|
|
|
|
|
|
if (Flags & TEXT_TYPE_STATUS)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = yScreen - 1;
|
|
|
|
}
|
2008-03-19 04:43:40 +00:00
|
|
|
else /* TEXT_TYPE_REGULAR (Default) */
|
|
|
|
{
|
2008-03-20 18:28:37 +00:00
|
|
|
coPos.X = x;
|
2014-05-15 16:32:30 +00:00
|
|
|
coPos.Y = y;
|
2008-03-19 04:43:40 +00:00
|
|
|
}
|
|
|
|
|
2008-03-20 18:28:37 +00:00
|
|
|
if (Flags & TEXT_ALIGN_CENTER)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
2017-05-23 21:01:10 +00:00
|
|
|
coPos.X = (xScreen - Length) /2;
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
2008-03-20 18:28:37 +00:00
|
|
|
else if(Flags & TEXT_ALIGN_RIGHT)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
2017-05-23 21:01:10 +00:00
|
|
|
coPos.X = coPos.X - Length;
|
2014-05-15 16:32:30 +00:00
|
|
|
|
|
|
|
if (Flags & TEXT_PADDING_SMALL)
|
|
|
|
{
|
|
|
|
coPos.X -= 1;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_MEDIUM)
|
|
|
|
{
|
2017-05-23 21:01:10 +00:00
|
|
|
coPos.X -= 2;
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_BIG)
|
|
|
|
{
|
|
|
|
coPos.X -= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* TEXT_ALIGN_LEFT (Default) */
|
|
|
|
{
|
|
|
|
if (Flags & TEXT_PADDING_SMALL)
|
|
|
|
{
|
|
|
|
coPos.X += 1;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_MEDIUM)
|
|
|
|
{
|
2017-05-23 21:01:10 +00:00
|
|
|
coPos.X += 2;
|
|
|
|
}
|
2014-05-15 16:32:30 +00:00
|
|
|
else if (Flags & TEXT_PADDING_BIG)
|
|
|
|
{
|
|
|
|
coPos.X += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & TEXT_TYPE_STATUS)
|
|
|
|
{
|
2008-03-20 18:28:37 +00:00
|
|
|
CONSOLE_SetStatusTextX(coPos.X, Text);
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
2008-03-19 04:43:40 +00:00
|
|
|
else /* TEXT_TYPE_REGULAR (Default) */
|
|
|
|
{
|
|
|
|
if (Flags & TEXT_STYLE_HIGHLIGHT)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
2008-03-19 04:43:40 +00:00
|
|
|
CONSOLE_SetHighlightedTextXY(coPos.X, coPos.Y, Text);
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
2008-03-19 04:43:40 +00:00
|
|
|
else if (Flags & TEXT_STYLE_UNDERLINE)
|
2014-05-15 16:32:30 +00:00
|
|
|
{
|
2008-03-19 04:43:40 +00:00
|
|
|
CONSOLE_SetUnderlinedTextXY(coPos.X, coPos.Y, Text);
|
2014-05-15 16:32:30 +00:00
|
|
|
}
|
2008-03-19 04:43:40 +00:00
|
|
|
else /* TEXT_STYLE_NORMAL (Default) */
|
|
|
|
{
|
|
|
|
CONSOLE_SetTextXY(coPos.X, coPos.Y, Text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-26 18:27:42 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
CONSOLE_ClearStyledText(IN SHORT x,
|
|
|
|
IN SHORT y,
|
|
|
|
IN INT Flags,
|
|
|
|
IN SHORT Length)
|
|
|
|
{
|
|
|
|
COORD coPos;
|
|
|
|
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
|
|
|
|
if (Flags & TEXT_TYPE_STATUS)
|
|
|
|
{
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = yScreen - 1;
|
|
|
|
}
|
|
|
|
else /* TEXT_TYPE_REGULAR (Default) */
|
|
|
|
{
|
|
|
|
coPos.X = x;
|
|
|
|
coPos.Y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & TEXT_ALIGN_CENTER)
|
|
|
|
{
|
|
|
|
coPos.X = (xScreen - Length) /2;
|
|
|
|
}
|
|
|
|
else if(Flags & TEXT_ALIGN_RIGHT)
|
|
|
|
{
|
|
|
|
coPos.X = coPos.X - Length;
|
|
|
|
|
|
|
|
if (Flags & TEXT_PADDING_SMALL)
|
|
|
|
{
|
|
|
|
coPos.X -= 1;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_MEDIUM)
|
|
|
|
{
|
|
|
|
coPos.X -= 2;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_BIG)
|
|
|
|
{
|
|
|
|
coPos.X -= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* TEXT_ALIGN_LEFT (Default) */
|
|
|
|
{
|
|
|
|
if (Flags & TEXT_PADDING_SMALL)
|
|
|
|
{
|
|
|
|
coPos.X += 1;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_MEDIUM)
|
|
|
|
{
|
|
|
|
coPos.X += 2;
|
|
|
|
}
|
|
|
|
else if (Flags & TEXT_PADDING_BIG)
|
|
|
|
{
|
|
|
|
coPos.X += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & TEXT_TYPE_STATUS)
|
|
|
|
{
|
|
|
|
CONSOLE_ClearStatusTextX(coPos.X, Length);
|
|
|
|
}
|
|
|
|
else /* TEXT_TYPE_REGULAR (Default) */
|
|
|
|
{
|
|
|
|
CONSOLE_ClearTextXY(coPos.X, coPos.Y, Length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-10 18:20:00 +00:00
|
|
|
/* EOF */
|