Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Mini reset implementation for busybox |
| 4 | * |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 6 | * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com> |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 7 | * |
"Robert P. J. Day" | 801ab14 | 2006-07-12 07:56:04 +0000 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 11 | /* no options, no getopt */ |
| 12 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 13 | #include "libbb.h" |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 14 | |
Denis Vlasenko | 06af216 | 2007-02-03 17:28:39 +0000 | [diff] [blame] | 15 | int reset_main(int argc, char **argv); |
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 16 | int reset_main(int argc, char **argv) |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 17 | { |
"Vladimir N. Oleynik" | ffe17b5 | 2005-10-12 08:38:28 +0000 | [diff] [blame] | 18 | if (isatty(1)) { |
Eric Andersen | 08573e0 | 2003-12-20 07:07:22 +0000 | [diff] [blame] | 19 | /* See 'man 4 console_codes' for details: |
| 20 | * "ESC c" -- Reset |
| 21 | * "ESC ( K" -- Select user mapping |
| 22 | * "ESC [ J" -- Erase display |
"Vladimir N. Oleynik" | ffe17b5 | 2005-10-12 08:38:28 +0000 | [diff] [blame] | 23 | * "ESC [ 0 m" -- Reset all display attributes |
Eric Andersen | 08573e0 | 2003-12-20 07:07:22 +0000 | [diff] [blame] | 24 | * "ESC [ ? 25 h" -- Make cursor visible. |
| 25 | */ |
| 26 | printf("\033c\033(K\033[J\033[0m\033[?25h"); |
| 27 | } |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 28 | return EXIT_SUCCESS; |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 29 | } |
| 30 | |