1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-27 21:41:16 +02:00

efi_loader: cursor positioning

When backspacing in column 0 do no set the column index to ULONG_MAX.
Ensure that the row number is not set to ULONG_MAX even if the row count is
advertised as 0.
Ignore control characters other the 0x08, 0x0a, 0x0d when updating the
column.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Heinrich Schuchardt
2019-09-04 21:13:45 +02:00
parent d41f99e179
commit 97ea0690f4

View File

@@ -156,13 +156,14 @@ static efi_status_t EFIAPI efi_cout_output_string(
* Update the cursor position. * Update the cursor position.
* *
* The UEFI spec provides advance rules for U+0000, U+0008, U+000A, * The UEFI spec provides advance rules for U+0000, U+0008, U+000A,
* and U000D. All other characters, including control characters * and U000D. All other control characters are ignored. Any non-control
* U+0007 (BEL) and U+0009 (TAB), have to increase the column by one. * character increase the column by one.
*/ */
for (p = string; *p; ++p) { for (p = string; *p; ++p) {
switch (*p) { switch (*p) {
case '\b': /* U+0008, backspace */ case '\b': /* U+0008, backspace */
con->cursor_column = max(0, con->cursor_column - 1); if (con->cursor_column)
con->cursor_column--;
break; break;
case '\n': /* U+000A, newline */ case '\n': /* U+000A, newline */
con->cursor_column = 0; con->cursor_column = 0;
@@ -178,6 +179,8 @@ static efi_status_t EFIAPI efi_cout_output_string(
*/ */
break; break;
default: default:
/* Exclude control codes */
if (*p > 0x1f)
con->cursor_column++; con->cursor_column++;
break; break;
} }
@@ -185,7 +188,12 @@ static efi_status_t EFIAPI efi_cout_output_string(
con->cursor_column = 0; con->cursor_column = 0;
con->cursor_row++; con->cursor_row++;
} }
con->cursor_row = min(con->cursor_row, (s32)mode->rows - 1); /*
* When we exceed the row count the terminal will scroll up one
* line. We have to adjust the cursor position.
*/
if (con->cursor_row >= mode->rows && con->cursor_row)
con->cursor_row--;
} }
out: out: