xref: /third_party/toybox/toys/other/reset.c (revision 0f66f451)
1/* reset.c - reset the terminal.
2 *
3 * Copyright 2015 Rob Landley <rob@landley.net>
4 *
5 * No standard.
6
7USE_RESET(NEWTOY(reset, 0, TOYFLAG_USR|TOYFLAG_BIN))
8
9config RESET
10  bool "reset"
11  default y
12  help
13    usage: reset
14
15    Reset the terminal.
16*/
17#include "toys.h"
18
19void reset_main(void)
20{
21  int fd = tty_fd();
22
23  // man 4 console_codes: reset terminal is ESC (no left bracket) c
24  // DEC private mode set enable wraparound sequence.
25  xwrite(fd<0 ? 1 : fd, "\033c\033[?7h", 2);
26}
27