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