source: MondoRescue/branches/3.2/mindi-busybox/console-tools/reset.c@ 3232

Last change on this file since 3232 was 3232, checked in by Bruno Cornec, 10 years ago
  • Update mindi-busybox to 1.21.1
File size: 1.5 KB
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * Mini reset implementation for busybox
4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
7 *
[2725]8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
[821]9 */
10
[2725]11/* BTW, which "standard" package has this utility? It doesn't seem
12 * to be ncurses, coreutils, console-tools... then what? */
[821]13
[3232]14//usage:#define reset_trivial_usage
15//usage: ""
16//usage:#define reset_full_usage "\n\n"
17//usage: "Reset the screen"
18
[1765]19#include "libbb.h"
[821]20
[2725]21#define ESC "\033"
22
23#if ENABLE_STTY
24int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
25#endif
26
27int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
[821]29{
[2725]30 static const char *const args[] = {
31 "stty", "sane", NULL
32 };
33
34 /* no options, no getopt */
35
36 if (/*isatty(STDIN_FILENO) &&*/ isatty(STDOUT_FILENO)) {
[821]37 /* See 'man 4 console_codes' for details:
[2725]38 * "ESC c" -- Reset
[3232]39 * "ESC ( B" -- Select G0 Character Set (B = US)
[2725]40 * "ESC [ 0 m" -- Reset all display attributes
41 * "ESC [ J" -- Erase to the end of screen
42 * "ESC [ ? 25 h" -- Make cursor visible
[821]43 */
[3232]44 printf(ESC"c" ESC"(B" ESC"[0m" ESC"[J" ESC"[?25h");
[2725]45 /* http://bugs.busybox.net/view.php?id=1414:
46 * people want it to reset echo etc: */
47#if ENABLE_STTY
48 return stty_main(2, (char**)args);
49#else
50 execvp("stty", (char**)args);
51#endif
[821]52 }
53 return EXIT_SUCCESS;
54}
Note: See TracBrowser for help on using the repository browser.