commands: add resize command to reset terminal scroll region
PATCH 1/1 commands: add resize command to reset terminal scroll region
Add a small command that resets the DECSTBM scroll region to the full window. This is useful for rebooting after a curses installer has restricted the scroll region for example.
Running "resize" then will give the shell the full terminal back.
Signed-off-by Ahmad Fatoum <[email protected]>
--- commands/Kconfig | 7 +++++++ commands/Makefile | 1 + commands/resize.c | 26 +++++++++++++++++++++++++ common/boards/configs/efi-loader.config | 1 + 4 files changed, 35 insertions(+) create mode 100644 commands/resize.c
commands/Kconfig +7 -0
@@ -1559,6 +1559,13 @@ config CMD_CLEAR Send ANSI ESC sequence to clear the screen. +config CMD_RESIZE + tristate + prompt "resize" + help + Reset the terminal scroll region to the full window and clear + the screen. + config CMD_ECHO tristate default y
commands/Makefile +1 -0
@@ -43,6 +43,7 @@ obj-$(CONFIG_CMD_UMOUNT) += umount.o obj-$(CONFIG_CMD_FINDMNT) += findmnt.o obj-$(CONFIG_CMD_CRC) += crc.o obj-$(CONFIG_CMD_CLEAR) += clear.o +obj-$(CONFIG_CMD_RESIZE) += resize.o obj-$(CONFIG_CMD_TEST) += test.o obj-$(CONFIG_CMD_TRUNCATE) += truncate.o obj-$(CONFIG_CMD_SYNC) += sync.o
commands/resize.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <stdio.h> +#include <command.h> +#include <complete.h> + +static int do_resize (int argc,char *argv[]) +{ +/* save cursor, reset DECSTBM scroll region, restore cursor */ +printf ("\e7" "\e[r" "\e8" ); + +return 0 ; +} + +BAREBOX_CMD_HELP_START(resize) +BAREBOX_CMD_HELP_TEXT("Reset the terminal scroll region to the full window") +BAREBOX_CMD_HELP_TEXT("and clear the screen.") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START (resize) + .cmd = do_resize, + BAREBOX_CMD_DESC("reset scroll region and clear screen") + BAREBOX_CMD_GROUP(CMD_GRP_CONSOLE) + BAREBOX_CMD_COMPLETE(empty_complete) + BAREBOX_CMD_HELP(cmd_resize_help) +BAREBOX_CMD_END
common/boards/configs/efi-loader.config +1 -0
@@ -1,2 +1,3 @@ CONFIG_EFI_LOADER=y CONFIG_FS_EFIVARFS=y +CONFIG_CMD_RESIZE=y
Signature · 1 line
2.47.3
Sascha Hauer
AppliedQuoted 6 lines · Ahmad Fatoum
Add a small command that resets the DECSTBM scroll region to the full window. This is useful for rebooting after a curses installer has restricted the scroll region for example.
Running "resize" then will give the shell the full terminal back.
Applied, thanks!
[1/1] commands: add resize command to reset terminal scroll region
https://git.pengutronix.de/cgit/barebox/commit/?id=5b820d185c20 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>