Fix: Console command scrolling did not take account of padding and cursor width. (#12642)

This commit is contained in:
Peter Nelson 2024-05-08 01:52:30 +01:00 committed by GitHub
parent 731d46beb5
commit b74a7e749b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -151,6 +151,7 @@ struct IConsoleWindow : Window
static size_t scroll;
int line_height; ///< Height of one line of text in the console.
int line_offset;
int cursor_width;
IConsoleWindow() : Window(&_console_window_desc)
{
@ -164,6 +165,7 @@ struct IConsoleWindow : Window
{
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.hsep_normal;
this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left;
this->cursor_width = GetCharacterWidth(FS_NORMAL, '_');
}
void Close([[maybe_unused]] int data = 0) override
@ -204,7 +206,7 @@ struct IConsoleWindow : Window
if (ypos < 0) break;
}
/* If the text is longer than the window, don't show the starting ']' */
int delta = this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH;
int delta = this->width - WidgetDimensions::scaled.frametext.right - cursor_width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH;
if (delta > 0) {
DrawString(WidgetDimensions::scaled.frametext.left, right, this->height - this->line_height, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
delta = 0;