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
10 USE_RESET(NEWTOY(reset, 0, TOYFLAG_USR|TOYFLAG_BIN))
11
12 config RESET
13 bool "reset"
14 default y
15 help
16 usage: reset
17
18 Reset the terminal.
19 */
20 #include "toys.h"
21
reset_main(void)22 void reset_main(void)
23 {
24 int fd = tty_fd();
25
26 // man 4 console_codes: reset terminal is ESC (no left bracket) c
27 // DEC private mode set enable wraparound sequence.
28 xwrite(fd<0 ? 1 : fd, "\ec\e[?7h", 2);
29 }
30