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
|
|
|
*
|
2006-07-12 07:56:04 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2000-08-21 21:26:33 +00:00
|
|
|
*/
|
|
|
|
|
2007-05-26 19:00:18 +00:00
|
|
|
#include "libbb.h"
|
2000-08-21 21:26:33 +00:00
|
|
|
|
2008-02-26 15:33:10 +00:00
|
|
|
/* BTW, which "standard" package has this utility? It doesn't seem
|
|
|
|
* to be ncurses, coreutils, console-tools... then what? */
|
|
|
|
|
|
|
|
#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 */
|
|
|
|
|
2008-05-19 08:18:50 +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
|
|
|
|
* "ESC ( K" -- Select user mapping
|
|
|
|
* "ESC [ J" -- Erase to the end of screen
|
|
|
|
* "ESC [ 0 m" -- Reset all display attributes
|
|
|
|
* "ESC [ ? 25 h" -- Make cursor visible
|
2003-12-20 07:07:22 +00:00
|
|
|
*/
|
|
|
|
printf("\033c\033(K\033[J\033[0m\033[?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
|
|
|
}
|