Mercurial > hg > toybox
changeset 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 | eb19245b94b6 |
children | 565980862743 |
files | toys/pending/reset.c |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/pending/reset.c Sun Apr 13 16:07:22 2014 -0500 @@ -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); +}