2000-08-21 21:26:33 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* Mini reset implementation for busybox
|
|
|
|
*
|
2004-03-15 08:29:22 +00:00
|
|
|
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
2001-10-24 05:00:29 +00:00
|
|
|
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
|
2000-08-21 21:26:33 +00:00
|
|
|
*
|
2010-08-16 18:14:46 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2000-08-21 21:26:33 +00:00
|
|
|
*/
|
2016-11-23 09:39:27 +00:00
|
|
|
/* "Standard" version of this tool is in ncurses package */
|
2000-08-21 21:26:33 +00:00
|
|
|
|
2016-11-23 09:39:27 +00:00
|
|
|
//config:config RESET
|
|
|
|
//config: bool "reset"
|
|
|
|
//config: default y
|
|
|
|
//config: help
|
|
|
|
//config: This program is used to reset the terminal screen, if it
|
|
|
|
//config: gets messed up.
|
|
|
|
|
|
|
|
//applet:IF_RESET(APPLET(reset, BB_DIR_USR_BIN, BB_SUID_DROP))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_RESET) += reset.o
|
2008-02-26 15:33:10 +00:00
|
|
|
|
2011-03-27 21:42:28 +00:00
|
|
|
//usage:#define reset_trivial_usage
|
|
|
|
//usage: ""
|
|
|
|
//usage:#define reset_full_usage "\n\n"
|
|
|
|
//usage: "Reset the screen"
|
|
|
|
|
2010-10-28 19:34:56 +00:00
|
|
|
#include "libbb.h"
|
|
|
|
|
|
|
|
#define ESC "\033"
|
|
|
|
|
2008-02-26 15:33:10 +00:00
|
|
|
#if ENABLE_STTY
|
|
|
|
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
|
|
#endif
|
|
|
|
|
2007-10-11 10:05:36 +00:00
|
|
|
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 09:18:54 +00:00
|
|
|
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
2000-08-21 21:26:33 +00:00
|
|
|
{
|
2008-02-26 15:33:10 +00:00
|
|
|
static const char *const args[] = {
|
|
|
|
"stty", "sane", NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* no options, no getopt */
|
|
|
|
|
2010-10-28 19:34:56 +00:00
|
|
|
if (/*isatty(STDIN_FILENO) &&*/ isatty(STDOUT_FILENO)) {
|
2003-12-20 07:07:22 +00:00
|
|
|
/* See 'man 4 console_codes' for details:
|
2010-05-16 21:42:13 +00:00
|
|
|
* "ESC c" -- Reset
|
2011-02-10 09:18:22 +00:00
|
|
|
* "ESC ( B" -- Select G0 Character Set (B = US)
|
2010-05-16 21:42:13 +00:00
|
|
|
* "ESC [ 0 m" -- Reset all display attributes
|
2010-10-28 19:34:56 +00:00
|
|
|
* "ESC [ J" -- Erase to the end of screen
|
2010-05-16 21:42:13 +00:00
|
|
|
* "ESC [ ? 25 h" -- Make cursor visible
|
2003-12-20 07:07:22 +00:00
|
|
|
*/
|
2011-02-10 09:18:22 +00:00
|
|
|
printf(ESC"c" ESC"(B" ESC"[0m" ESC"[J" ESC"[?25h");
|
2008-02-26 15:33:10 +00:00
|
|
|
/* http://bugs.busybox.net/view.php?id=1414:
|
|
|
|
* people want it to reset echo etc: */
|
|
|
|
#if ENABLE_STTY
|
|
|
|
return stty_main(2, (char**)args);
|
|
|
|
#else
|
2008-03-17 09:04:04 +00:00
|
|
|
execvp("stty", (char**)args);
|
2008-02-26 15:33:10 +00:00
|
|
|
#endif
|
2003-12-20 07:07:22 +00:00
|
|
|
}
|
2003-10-22 10:34:15 +00:00
|
|
|
return EXIT_SUCCESS;
|
2000-08-21 21:26:33 +00:00
|
|
|
}
|