annotate toys/pending/reset.c @ 1276:d48bdc1cb017 draft

Switch human_readable() to just outputing decimal kilo/mega/gigabytes, make du use it, move it from lib/pending.c to lib.c.
author Rob Landley <rob@landley.net>
date Tue, 06 May 2014 06:31:28 -0500
parents fd0a595f5486
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1258
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
1 /* reset.c - A program to reset the terminal.
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
2 *
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
3 * Copyright 2014 Ashwini Kumar <ak.ashwini@gmail.com>
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Kyungwan Han <asura321@gmail.com>
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
5 *
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
6 * No Standard.
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
7
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
8 USE_RESET(NEWTOY(reset, NULL, TOYFLAG_USR|TOYFLAG_BIN))
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
9
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
10 config RESET
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
11 bool "reset"
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
12 default n
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
13 help
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
14 usage: reset
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
15
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
16 A program to reset the terminal.
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
17 */
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
18 #define FOR_reset
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
19 #include "toys.h"
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
20
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
21 void reset_main(void)
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
22 {
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
23 char *args[] = {"stty", "sane", NULL};
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
24
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
25 /* \033c - reset the terminal with default setting
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
26 * \033(B - set the G0 character set (B=US)
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
27 * \033[2J - clear the whole screen
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
28 * \033[0m - Reset all attributes
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
29 */
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
30 if (isatty(1)) xprintf("\033c\033(B\033[0m\033[J\033[?25h");
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
31 fflush(stdout);
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
32 // set the terminal to sane settings
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
33 xexec(args);
fd0a595f5486 A tool to reset the terminal.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
34 }