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-03-17 09:00:54 +00:00
|
|
|
int reset_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
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:
|
|
|
|
* "ESC c" -- Reset
|
|
|
|
* "ESC ( K" -- Select user mapping
|
|
|
|
* "ESC [ J" -- Erase display
|
2005-10-12 08:38:28 +00:00
|
|
|
* "ESC [ 0 m" -- Reset all display attributes
|
2003-12-20 07:07:22 +00:00
|
|
|
* "ESC [ ? 25 h" -- Make cursor visible.
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|