blob: c844e1511b1e13ebdea1b318e697e43ef90a86f8 [file] [log] [blame]
Eric Andersendc746162000-08-21 21:26:33 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Mini reset implementation for busybox
4 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersenbdfd0d72001-10-24 05:00:29 +00006 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
Eric Andersendc746162000-08-21 21:26:33 +00007 *
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00008 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersendc746162000-08-21 21:26:33 +00009 */
10
Eric Andersen7f6295f2003-10-22 10:34:15 +000011/* no options, no getopt */
12
Eric Andersendc746162000-08-21 21:26:33 +000013#include <stdio.h>
Eric Andersened3ef502001-01-27 08:24:39 +000014#include <stdlib.h>
Eric Andersen08573e02003-12-20 07:07:22 +000015#include <unistd.h>
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000016#include "libbb.h"
Eric Andersendc746162000-08-21 21:26:33 +000017
Denis Vlasenko06af2162007-02-03 17:28:39 +000018int reset_main(int argc, char **argv);
Rob Landleydfba7412006-03-06 20:47:33 +000019int reset_main(int argc, char **argv)
Eric Andersendc746162000-08-21 21:26:33 +000020{
"Vladimir N. Oleynik"ffe17b52005-10-12 08:38:28 +000021 if (isatty(1)) {
Eric Andersen08573e02003-12-20 07:07:22 +000022 /* 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"ffe17b52005-10-12 08:38:28 +000026 * "ESC [ 0 m" -- Reset all display attributes
Eric Andersen08573e02003-12-20 07:07:22 +000027 * "ESC [ ? 25 h" -- Make cursor visible.
28 */
29 printf("\033c\033(K\033[J\033[0m\033[?25h");
30 }
Eric Andersen7f6295f2003-10-22 10:34:15 +000031 return EXIT_SUCCESS;
Eric Andersendc746162000-08-21 21:26:33 +000032}
33