XTLDR Rewrite #7

Merged
belliash merged 184 commits from xtldr_rewrite into master 2024-01-09 18:51:04 +01:00
Showing only changes of commit acacc3f2e8 - Show all commits

View File

@ -881,6 +881,7 @@ BlpDrawDialogInputField(IN PXTBL_DIALOG_HANDLE Handle,
WCHAR InputField[XTBL_TUI_MAX_DIALOG_WIDTH];
ULONG InputColor, TextColor;
UINT_PTR Index, Position;
SIZE_T Length;
/* Set dialog button colors */
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
@ -922,9 +923,27 @@ BlpDrawDialogInputField(IN PXTBL_DIALOG_HANDLE Handle,
BlDisableConsoleCursor();
BlConsoleWrite(InputField);
/* Check input field text length */
Length = RtlWideStringLength(InputFieldText, 0);
if(Length > (Handle->Width - 9))
{
/* Text longer than input field width, display only part of it */
Length = Handle->Width - 9;
}
/* Copy a part of input field text to input field */
for(Index = 0; Index < Length; Index++)
{
/* Write input field text */
InputField[Index] = InputFieldText[Index];
}
/* Add null terminator to the end of the line */
InputField[Handle->Width] = 0;
/* Write input field text */
BlSetCursorPosition(Handle->PosX + 4, Handle->PosY + Handle->Height - Position);
BlConsoleWrite(InputFieldText);
BlConsoleWrite(InputField);
/* Check if this is an active input field */
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
@ -1178,21 +1197,18 @@ BlDisplayInputDialog(IN PWCHAR Caption,
/* Other key pressed, add character to the buffer */
if(Handle.Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT && Key.UnicodeChar != 0)
{
if(InputFieldLength < Handle.Width - 8 - 1 && TextPosition < Handle.Width - 8 - 1)
{
RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition, (InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldBuffer[TextPosition] = Key.UnicodeChar;
TextPosition++;
InputFieldLength++;
InputFieldBuffer[InputFieldLength] = 0;
}
RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition, (InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldBuffer[TextPosition] = Key.UnicodeChar;
TextPosition++;
InputFieldLength++;
InputFieldBuffer[InputFieldLength] = 0;
}
}
if(TextPosition > (Handle.Width - 8))
if(TextPosition > (Handle.Width - 9))
{
TextIndex = TextPosition - (Handle.Width - 8);
TextCursorPosition = Handle.Width - 8;
TextIndex = TextPosition - (Handle.Width - 9);
TextCursorPosition = Handle.Width - 9;
}
else
{