diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-12-10 16:10:35 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-12-13 23:37:32 +0100 |
commit | c3ba87523ecb19e673f9e69915df8cf62129a73d (patch) | |
tree | d20e67587b7d90051e2b317b775c1183b64be22a /commands | |
parent | 2c451f611781c516152def8fc0d15289f9106af2 (diff) | |
download | barebox-c3ba87523ecb19e673f9e69915df8cf62129a73d.tar.gz barebox-c3ba87523ecb19e673f9e69915df8cf62129a73d.tar.xz |
edit: Improve behaviour on efi-stdio console
Our console driver for the EFI simple text protocol does not support
the "\e[1S" escape sequence to scroll the window which means sedit
doesn't work properly. Disable smartscroll when the efi-stdio console
is active. While at it put the screen height reduction into the same
dynamic test.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/edit.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/commands/edit.c b/commands/edit.c index 30448cbc04..592cf4aa3d 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -522,6 +522,25 @@ static int read_modal_key(bool is_modal) return -EAGAIN; } +static bool is_efi_console_active(void) +{ + struct console_device *cdev; + + if (!IS_ENABLED(CONFIG_DRIVER_SERIAL_EFI_STDIO)) + return false; + + for_each_console(cdev) { + if (!(cdev->f_active & CONSOLE_STDIN)) + continue; + if (!(cdev->f_active & CONSOLE_STDOUT)) + continue; + if (!strcmp(dev_name(cdev->dev), "efi-stdio")) + return true; + } + + return false; +} + static int do_edit(int argc, char *argv[]) { bool is_vi = false; @@ -539,16 +558,7 @@ static int do_edit(int argc, char *argv[]) return 1; screenwidth = 80; - - /* - * The EFI simple text output protocol wraps to the next line and scrolls - * down when we write to the right bottom screen position. Reduce the number - * of rows by one to work around this. - */ - if (IS_ENABLED(CONFIG_EFI_BOOTUP)) - screenheight = 24; - else - screenheight = 25; + screenheight = 25; /* check if we are not called as "edit" */ if (*argv[0] != 'e') { @@ -560,6 +570,22 @@ static int do_edit(int argc, char *argv[]) is_vi = true; } + if (is_efi_console_active()) { + /* + * The EFI simple text output protocol wraps to the next line and + * scrolls down when we write to the right bottom screen position. + * Reduce the number of rows by one to work around this. + */ + screenheight--; + + /* + * Our console driver for the EFI simple text output protocol does + * not implement the "\e[1S" sequence we use for scrolling the + * screen. + */ + smartscroll = 0; + } + cursx = 0; cursy = 0; textx = 0; |