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 | |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 13 | #include <stdio.h> |
Eric Andersen | ed3ef50 | 2001-01-27 08:24:39 +0000 | [diff] [blame] | 14 | #include <stdlib.h> |
Eric Andersen | 08573e0 | 2003-12-20 07:07:22 +0000 | [diff] [blame] | 15 | #include <unistd.h> |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame^] | 16 | #include "libbb.h" |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 17 | |
Denis Vlasenko | 06af216 | 2007-02-03 17:28:39 +0000 | [diff] [blame] | 18 | int reset_main(int argc, char **argv); |
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 19 | int reset_main(int argc, char **argv) |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 20 | { |
"Vladimir N. Oleynik" | ffe17b5 | 2005-10-12 08:38:28 +0000 | [diff] [blame] | 21 | if (isatty(1)) { |
Eric Andersen | 08573e0 | 2003-12-20 07:07:22 +0000 | [diff] [blame] | 22 | /* See 'man 4 console_codes' for details: |
| 23 | * "ESC c" -- Reset |
| 24 | * "ESC ( K" -- Select user mapping |
| 25 | * "ESC [ J" -- Erase display |
"Vladimir N. Oleynik" | ffe17b5 | 2005-10-12 08:38:28 +0000 | [diff] [blame] | 26 | * "ESC [ 0 m" -- Reset all display attributes |
Eric Andersen | 08573e0 | 2003-12-20 07:07:22 +0000 | [diff] [blame] | 27 | * "ESC [ ? 25 h" -- Make cursor visible. |
| 28 | */ |
| 29 | printf("\033c\033(K\033[J\033[0m\033[?25h"); |
| 30 | } |
Eric Andersen | 7f6295f | 2003-10-22 10:34:15 +0000 | [diff] [blame] | 31 | return EXIT_SUCCESS; |
Eric Andersen | dc74616 | 2000-08-21 21:26:33 +0000 | [diff] [blame] | 32 | } |
| 33 | |