1 /* reset.c - reset the terminal.
2 *
3 * Copyright 2015 Rob Landley <[email protected]>
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 if (fd<0) fd = 1;
29 xwrite(fd, "\ec\e[?7h", 2);
30 set_terminal(fd, 0, 0, 0);
31 }
32