reset.c 605 B

1234567891011121314151617181920212223242526272829
  1. /* reset.c - reset the terminal.
  2. *
  3. * Copyright 2015 Rob Landley <rob@landley.net>
  4. *
  5. * No standard.
  6. *
  7. * In 1979 3BSD's tset had a sleep(1) to let mechanical printer-and-ink
  8. * terminals "settle down". We're not doing that.
  9. USE_RESET(NEWTOY(reset, 0, TOYFLAG_USR|TOYFLAG_BIN))
  10. config RESET
  11. bool "reset"
  12. default y
  13. help
  14. usage: reset
  15. Reset the terminal.
  16. */
  17. #include "toys.h"
  18. void reset_main(void)
  19. {
  20. int fd = tty_fd();
  21. // man 4 console_codes: reset terminal is ESC (no left bracket) c
  22. // DEC private mode set enable wraparound sequence.
  23. xwrite(fd<0 ? 1 : fd, "\ec\e[?7h", 2);
  24. }