comparison toys/pending/reset.c @ 1258:fd0a595f5486 draft

A tool to reset the terminal. This implementation depends on the _stty_ 'sane' settings.
author Ashwini Sharma <ak.ashwini1981@gmail.com>
date Sun, 13 Apr 2014 16:07:22 -0500
parents
children
comparison
equal deleted inserted replaced
1257:eb19245b94b6 1258:fd0a595f5486
1 /* reset.c - A program to reset the terminal.
2 *
3 * Copyright 2014 Ashwini Kumar <ak.ashwini@gmail.com>
4 * Copyright 2014 Kyungwan Han <asura321@gmail.com>
5 *
6 * No Standard.
7
8 USE_RESET(NEWTOY(reset, NULL, TOYFLAG_USR|TOYFLAG_BIN))
9
10 config RESET
11 bool "reset"
12 default n
13 help
14 usage: reset
15
16 A program to reset the terminal.
17 */
18 #define FOR_reset
19 #include "toys.h"
20
21 void reset_main(void)
22 {
23 char *args[] = {"stty", "sane", NULL};
24
25 /* \033c - reset the terminal with default setting
26 * \033(B - set the G0 character set (B=US)
27 * \033[2J - clear the whole screen
28 * \033[0m - Reset all attributes
29 */
30 if (isatty(1)) xprintf("\033c\033(B\033[0m\033[J\033[?25h");
31 fflush(stdout);
32 // set the terminal to sane settings
33 xexec(args);
34 }