* [PATCH] commands: add resize command to reset terminal scroll region
@ 2026-04-13 9:56 Ahmad Fatoum
2026-04-22 8:16 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-04-13 9:56 UTC (permalink / raw)
To: barebox; +Cc: 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.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
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
diff --git a/commands/Kconfig b/commands/Kconfig
index 8c9f61b5ac3e..71f086968971 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -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
diff --git a/commands/Makefile b/commands/Makefile
index 2563efb12f4e..7f0c68a5e58e 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -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
diff --git a/commands/resize.c b/commands/resize.c
new file mode 100644
index 000000000000..1213679d1069
--- /dev/null
+++ b/commands/resize.c
@@ -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
diff --git a/common/boards/configs/efi-loader.config b/common/boards/configs/efi-loader.config
index 7fadc60e41a8..f8c022de5e5a 100644
--- a/common/boards/configs/efi-loader.config
+++ b/common/boards/configs/efi-loader.config
@@ -1,2 +1,3 @@
CONFIG_EFI_LOADER=y
CONFIG_FS_EFIVARFS=y
+CONFIG_CMD_RESIZE=y
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] commands: add resize command to reset terminal scroll region
2026-04-13 9:56 [PATCH] commands: add resize command to reset terminal scroll region Ahmad Fatoum
@ 2026-04-22 8:16 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-04-22 8:16 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 13 Apr 2026 11:56:44 +0200, Ahmad Fatoum wrote:
> 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,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-22 8:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-13 9:56 [PATCH] commands: add resize command to reset terminal scroll region Ahmad Fatoum
2026-04-22 8:16 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox