Index: console-tools/Config.in =================================================================== --- console-tools/Config.in (revision 16161) +++ console-tools/Config.in (working copy) @@ -58,6 +58,13 @@ config CONFIG_RESET This program is used to reset the terminal screen, if it gets messed up. +config CONFIG_RESIZE + bool "resize" + default n + help + This program is used to (re)set the width and height of your current + terminal. + config CONFIG_SETCONSOLE bool "setconsole" default n Index: console-tools/Makefile.in =================================================================== --- console-tools/Makefile.in (revision 16161) +++ console-tools/Makefile.in (working copy) @@ -20,6 +20,7 @@ CONSOLETOOLS-$(CONFIG_LOADFONT) += loadf CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o CONSOLETOOLS-$(CONFIG_RESET) += reset.o +CONSOLETOOLS-$(CONFIG_RESIZE) += resize.o CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o Index: console-tools/resize.c =================================================================== --- console-tools/resize.c (revision 0) +++ console-tools/resize.c (revision 0) @@ -0,0 +1,40 @@ +/* vi: set sw=4 ts=4: */ +/* + * resize - set terminal width and height. + * + * Copyright 2006 Bernhard Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +/* no options, no getopt */ +#include "busybox.h" + +#define RESIZE_TIOS_TIMEOUT 100 /* in deciseconds */ +int resize_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv) { + /* save_cursor_pos 7 + * scroll_whole_screen [r + * put_cursor_waaaay_off [$x;$yH + * get_cursor_pos [6n + * restore_cursor_pos 8 + */ + const char req[] = "\0337\033[r\033[999;999H\033[6n"; + int f = STDIN_FILENO; + struct winsize w = {0,0,0,0}; + int ret; + struct termios old, new; + tcgetattr(STDIN_FILENO, &old); /* fiddle echo */ + new = old; + new.c_cflag |= (CLOCAL | CREAD); + new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); +#if defined(RESIZE_TIOS_TIMEOUT) && (RESIZE_TIOS_TIMEOUT > 0) + new.c_cc[VMIN] = 0; + new.c_cc[VTIME] = RESIZE_TIOS_TIMEOUT; +#endif + tcsetattr(STDIN_FILENO, TCSANOW, &new); + write(f, req, sizeof req); + scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col); + ret = ioctl(STDIN_FILENO, TIOCSWINSZ, &w); + write(f, "\0338", 2); + tcsetattr(STDIN_FILENO, TCSANOW, &old); + return ret; +} Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16161) +++ include/libbb.h (working copy) @@ -231,8 +231,9 @@ extern void trim(char *s); extern char *skip_whitespace(const char *); #ifndef BUILD_INDIVIDUAL -extern struct BB_applet *find_applet_by_name(const char *name); -void run_applet_by_name(const char *name, int argc, char **argv); +extern struct BB_applet *find_applet_by_name(const char *name) + USE_FEATURE_SH_STANDALONE_SHELL(ATTRIBUTE_EXTERNALLY_VISIBLE); +extern void run_applet_by_name(const char *name, int argc, char **argv); #endif /* dmalloc will redefine these to it's own implementation. It is safe Index: include/usage.h =================================================================== --- include/usage.h (revision 16163) +++ include/usage.h (working copy) @@ -2455,6 +2455,11 @@ USE_FEATURE_MDEV_CONFIG( \ #define reset_full_usage \ "Resets the screen." +#define resize_trivial_usage \ + "" +#define resize_full_usage \ + "Resizes the screen." + #define rm_trivial_usage \ "[OPTION]... FILE..." #define rm_full_usage \ Index: include/applets.h =================================================================== --- include/applets.h (revision 16161) +++ include/applets.h (working copy) @@ -226,6 +226,7 @@ USE_REALPATH(APPLET(realpath, _BB_DIR_US USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot)) USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))