diff options
author | Ashwini Sharma <ak.ashwini1981@gmail.com> | 2014-04-13 16:07:22 -0500 |
---|---|---|
committer | Ashwini Sharma <ak.ashwini1981@gmail.com> | 2014-04-13 16:07:22 -0500 |
commit | dd61393cba9d4dd7152960274aff1d25dd239c93 (patch) | |
tree | 22e84848e9e5188c98ef64ade149e21f2bd3dff5 /toys | |
parent | 1d12fb66550660f97ef90484dc31304eddfd4bf7 (diff) | |
download | toybox-dd61393cba9d4dd7152960274aff1d25dd239c93.tar.gz |
A tool to reset the terminal.
This implementation depends on the _stty_ 'sane' settings.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/pending/reset.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/toys/pending/reset.c b/toys/pending/reset.c new file mode 100644 index 00000000..a12f0b61 --- /dev/null +++ b/toys/pending/reset.c @@ -0,0 +1,34 @@ +/* reset.c - A program to reset the terminal. + * + * Copyright 2014 Ashwini Kumar <ak.ashwini@gmail.com> + * Copyright 2014 Kyungwan Han <asura321@gmail.com> + * + * No Standard. + +USE_RESET(NEWTOY(reset, NULL, TOYFLAG_USR|TOYFLAG_BIN)) + +config RESET + bool "reset" + default n + help + usage: reset + + A program to reset the terminal. +*/ +#define FOR_reset +#include "toys.h" + +void reset_main(void) +{ + char *args[] = {"stty", "sane", NULL}; + + /* \033c - reset the terminal with default setting + * \033(B - set the G0 character set (B=US) + * \033[2J - clear the whole screen + * \033[0m - Reset all attributes + */ + if (isatty(1)) xprintf("\033c\033(B\033[0m\033[J\033[?25h"); + fflush(stdout); + // set the terminal to sane settings + xexec(args); +} |