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];
|
WCHAR InputField[XTBL_TUI_MAX_DIALOG_WIDTH];
|
||||||
ULONG InputColor, TextColor;
|
ULONG InputColor, TextColor;
|
||||||
UINT_PTR Index, Position;
|
UINT_PTR Index, Position;
|
||||||
|
SIZE_T Length;
|
||||||
|
|
||||||
/* Set dialog button colors */
|
/* Set dialog button colors */
|
||||||
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
|
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
|
||||||
@ -922,9 +923,27 @@ BlpDrawDialogInputField(IN PXTBL_DIALOG_HANDLE Handle,
|
|||||||
BlDisableConsoleCursor();
|
BlDisableConsoleCursor();
|
||||||
BlConsoleWrite(InputField);
|
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 */
|
/* Write input field text */
|
||||||
BlSetCursorPosition(Handle->PosX + 4, Handle->PosY + Handle->Height - Position);
|
BlSetCursorPosition(Handle->PosX + 4, Handle->PosY + Handle->Height - Position);
|
||||||
BlConsoleWrite(InputFieldText);
|
BlConsoleWrite(InputField);
|
||||||
|
|
||||||
/* Check if this is an active input field */
|
/* Check if this is an active input field */
|
||||||
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
|
if(Handle->Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT)
|
||||||
@ -1178,21 +1197,18 @@ BlDisplayInputDialog(IN PWCHAR Caption,
|
|||||||
/* Other key pressed, add character to the buffer */
|
/* Other key pressed, add character to the buffer */
|
||||||
if(Handle.Attributes & XTBL_TUI_DIALOG_ACTIVE_INPUT && Key.UnicodeChar != 0)
|
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;
|
||||||
RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition, (InputFieldLength - TextPosition) * sizeof(WCHAR));
|
TextPosition++;
|
||||||
InputFieldBuffer[TextPosition] = Key.UnicodeChar;
|
InputFieldLength++;
|
||||||
TextPosition++;
|
InputFieldBuffer[InputFieldLength] = 0;
|
||||||
InputFieldLength++;
|
|
||||||
InputFieldBuffer[InputFieldLength] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TextPosition > (Handle.Width - 8))
|
if(TextPosition > (Handle.Width - 9))
|
||||||
{
|
{
|
||||||
TextIndex = TextPosition - (Handle.Width - 8);
|
TextIndex = TextPosition - (Handle.Width - 9);
|
||||||
TextCursorPosition = Handle.Width - 8;
|
TextCursorPosition = Handle.Width - 9;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user