Fix input field text positioning
This commit is contained in:
parent
46253c0503
commit
acacc3f2e8
@ -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)
|
||||
@ -1177,8 +1196,6 @@ 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;
|
||||
@ -1187,12 +1204,11 @@ BlDisplayInputDialog(IN PWCHAR Caption,
|
||||
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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user