mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:03:14 +00:00
[USETUP]: Instead of defining a special function "DrawInputField" just to draw an input field for entering the partition size number, just use the already existing CONSOLE_SetInputTextXY function (and adapt the calling code because the string buffer for the SetInputTextXY function wants a unicode string). We now have a consistent input UI for usetup.
CORE-9453 #resolve #comment I committed a more elegant solution to this problem. svn path=/trunk/; revision=67546
This commit is contained in:
parent
ac4f5ac401
commit
048d0522f4
2 changed files with 33 additions and 62 deletions
|
@ -145,13 +145,6 @@ CONSOLE_SetInputTextXY(
|
||||||
IN SHORT len,
|
IN SHORT len,
|
||||||
IN LPCWSTR Text);
|
IN LPCWSTR Text);
|
||||||
|
|
||||||
VOID
|
|
||||||
CONSOLE_SetInputTextXY(
|
|
||||||
IN SHORT x,
|
|
||||||
IN SHORT y,
|
|
||||||
IN SHORT len,
|
|
||||||
IN LPCWSTR Text);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
CONSOLE_SetInvertedTextXY(
|
CONSOLE_SetInvertedTextXY(
|
||||||
IN SHORT x,
|
IN SHORT x,
|
||||||
|
|
|
@ -392,7 +392,7 @@ ConfirmQuit(PINPUT_RECORD Ir)
|
||||||
Result = TRUE;
|
Result = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
||||||
{
|
{
|
||||||
Result = FALSE;
|
Result = FALSE;
|
||||||
break;
|
break;
|
||||||
|
@ -701,7 +701,7 @@ LanguagePage(PINPUT_RECORD Ir)
|
||||||
else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
|
else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
|
||||||
{
|
{
|
||||||
/* a-z */
|
/* a-z */
|
||||||
GenericListKeyPress (LanguageList, Ir->Event.KeyEvent.uChar.AsciiChar);
|
GenericListKeyPress(LanguageList, Ir->Event.KeyEvent.uChar.AsciiChar);
|
||||||
RefreshPage = TRUE;
|
RefreshPage = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1678,30 +1678,6 @@ SelectPartitionPage(PINPUT_RECORD Ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
|
||||||
DrawInputField(ULONG FieldLength,
|
|
||||||
SHORT Left,
|
|
||||||
SHORT Top,
|
|
||||||
PCHAR FieldContent)
|
|
||||||
{
|
|
||||||
CHAR buf[100];
|
|
||||||
COORD coPos;
|
|
||||||
DWORD Written;
|
|
||||||
|
|
||||||
coPos.X = Left;
|
|
||||||
coPos.Y = Top;
|
|
||||||
memset(buf, '_', sizeof(buf));
|
|
||||||
buf[FieldLength - strlen(FieldContent)] = 0;
|
|
||||||
strcat(buf, FieldContent);
|
|
||||||
|
|
||||||
WriteConsoleOutputCharacterA(StdOutput,
|
|
||||||
buf,
|
|
||||||
strlen(buf),
|
|
||||||
coPos,
|
|
||||||
&Written);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
|
#define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
|
||||||
/* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
|
/* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
|
||||||
#define PARTITION_MAXSIZE 999999
|
#define PARTITION_MAXSIZE 999999
|
||||||
|
@ -1720,8 +1696,9 @@ ShowPartitionSizeInputBox(SHORT Left,
|
||||||
COORD coPos;
|
COORD coPos;
|
||||||
DWORD Written;
|
DWORD Written;
|
||||||
CHAR Buffer[100];
|
CHAR Buffer[100];
|
||||||
|
WCHAR PartitionSizeBuffer[100];
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
CHAR ch;
|
WCHAR ch;
|
||||||
SHORT iLeft;
|
SHORT iLeft;
|
||||||
SHORT iTop;
|
SHORT iTop;
|
||||||
|
|
||||||
|
@ -1742,7 +1719,7 @@ ShowPartitionSizeInputBox(SHORT Left,
|
||||||
|
|
||||||
WriteConsoleOutputCharacterA(StdOutput,
|
WriteConsoleOutputCharacterA(StdOutput,
|
||||||
Buffer,
|
Buffer,
|
||||||
strlen (Buffer),
|
strlen(Buffer),
|
||||||
coPos,
|
coPos,
|
||||||
&Written);
|
&Written);
|
||||||
|
|
||||||
|
@ -1751,16 +1728,16 @@ ShowPartitionSizeInputBox(SHORT Left,
|
||||||
coPos.Y = iTop;
|
coPos.Y = iTop;
|
||||||
WriteConsoleOutputCharacterA(StdOutput,
|
WriteConsoleOutputCharacterA(StdOutput,
|
||||||
Buffer,
|
Buffer,
|
||||||
strlen (Buffer),
|
strlen(Buffer),
|
||||||
coPos,
|
coPos,
|
||||||
&Written);
|
&Written);
|
||||||
|
|
||||||
sprintf(Buffer, "%lu", MaxSize);
|
swprintf(PartitionSizeBuffer, L"%lu", MaxSize);
|
||||||
Index = strlen(Buffer);
|
Index = wcslen(PartitionSizeBuffer);
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
CONSOLE_SetInputTextXY(iLeft,
|
||||||
iLeft,
|
iTop,
|
||||||
iTop,
|
PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
Buffer);
|
PartitionSizeBuffer);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
|
@ -1772,52 +1749,53 @@ ShowPartitionSizeInputBox(SHORT Left,
|
||||||
if (Quit != NULL)
|
if (Quit != NULL)
|
||||||
*Quit = TRUE;
|
*Quit = TRUE;
|
||||||
|
|
||||||
Buffer[0] = 0;
|
PartitionSizeBuffer[0] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
|
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESCAPE */
|
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESCAPE */
|
||||||
{
|
{
|
||||||
if (Cancel != NULL)
|
if (Cancel != NULL)
|
||||||
*Cancel = TRUE;
|
*Cancel = TRUE;
|
||||||
|
|
||||||
Buffer[0] = 0;
|
PartitionSizeBuffer[0] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) && /* BACKSPACE */
|
else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) && /* BACKSPACE */
|
||||||
(Index > 0))
|
(Index > 0))
|
||||||
{
|
{
|
||||||
Index--;
|
Index--;
|
||||||
Buffer[Index] = 0;
|
PartitionSizeBuffer[Index] = 0;
|
||||||
|
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
CONSOLE_SetInputTextXY(iLeft,
|
||||||
iLeft,
|
iTop,
|
||||||
iTop,
|
PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
Buffer);
|
PartitionSizeBuffer);
|
||||||
}
|
}
|
||||||
else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00) &&
|
else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00) &&
|
||||||
(Index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
|
(Index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
|
||||||
{
|
{
|
||||||
ch = Ir.Event.KeyEvent.uChar.AsciiChar;
|
ch = (WCHAR)Ir.Event.KeyEvent.uChar.AsciiChar;
|
||||||
|
|
||||||
if ((ch >= '0') && (ch <= '9'))
|
if ((ch >= L'0') && (ch <= L'9'))
|
||||||
{
|
{
|
||||||
Buffer[Index] = ch;
|
PartitionSizeBuffer[Index] = ch;
|
||||||
Index++;
|
Index++;
|
||||||
Buffer[Index] = 0;
|
PartitionSizeBuffer[Index] = 0;
|
||||||
|
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
CONSOLE_SetInputTextXY(iLeft,
|
||||||
iLeft,
|
iTop,
|
||||||
iTop,
|
PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
Buffer);
|
PartitionSizeBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(InputBuffer, Buffer);
|
/* Convert UNICODE --> ANSI the poor man's way */
|
||||||
|
sprintf(InputBuffer, "%S", PartitionSizeBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3910,7 +3888,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
||||||
{
|
{
|
||||||
if (Line == 12)
|
if (Line == 12)
|
||||||
{
|
{
|
||||||
|
@ -3958,7 +3936,7 @@ BootLoaderFloppyPage(PINPUT_RECORD Ir)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
|
||||||
{
|
{
|
||||||
if (DoesFileExist(L"\\Device\\Floppy0", L"\\") == FALSE)
|
if (DoesFileExist(L"\\Device\\Floppy0", L"\\") == FALSE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue