mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] commands: add resize command to reset terminal scroll region
Date: Mon, 13 Apr 2026 11:56:44 +0200	[thread overview]
Message-ID: <20260413095657.1454950-1-a.fatoum@barebox.org> (raw)

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




             reply	other threads:[~2026-04-13  9:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  9:56 Ahmad Fatoum [this message]
2026-04-22  8:16 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413095657.1454950-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox