3
0

reset.c 781 B

1234567891011121314151617181920212223242526272829303132
  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. *
  8. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  9. */
  10. /* no options, no getopt */
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <unistd.h>
  14. #include "busybox.h"
  15. int reset_main(int argc, char **argv)
  16. {
  17. if (isatty(1)) {
  18. /* See 'man 4 console_codes' for details:
  19. * "ESC c" -- Reset
  20. * "ESC ( K" -- Select user mapping
  21. * "ESC [ J" -- Erase display
  22. * "ESC [ 0 m" -- Reset all display attributes
  23. * "ESC [ ? 25 h" -- Make cursor visible.
  24. */
  25. printf("\033c\033(K\033[J\033[0m\033[?25h");
  26. }
  27. return EXIT_SUCCESS;
  28. }