Fix mixed indents and trailing whitespace (#56)

This fixes the tabs and trailing whitespace.

I've set a vim modeline to expand tabs and set tab width to 4 spaces.
reverse-branch
Slackhead 8 years ago committed by anarcat
parent ab121b53e1
commit 75ca275408
  1. 38
      README
  2. 78
      tty-clock.1
  3. 90
      ttyclock.c
  4. 8
      ttyclock.h

@ -1,20 +1,20 @@
usage : tty-clock [-iuvsScbtrahDBxn] [-C [0-7]] [-f format] [-d delay] [-a nsdelay] [-T tty] usage : tty-clock [-iuvsScbtrahDBxn] [-C [0-7]] [-f format] [-d delay] [-a nsdelay] [-T tty]
-s Show seconds -s Show seconds
-S Screensaver mode -S Screensaver mode
-x Show box -x Show box
-c Set the clock at the center of the terminal -c Set the clock at the center of the terminal
-C [0-7] Set the clock color -C [0-7] Set the clock color
-b Use bold colors -b Use bold colors
-t Set the hour in 12h format -t Set the hour in 12h format
-u Use UTC time -u Use UTC time
-T tty Display the clock on the specified terminal -T tty Display the clock on the specified terminal
-r Do rebound the clock -r Do rebound the clock
-f format Set the date format -f format Set the date format
-n Don't quit on keypress -n Don't quit on keypress
-v Show tty-clock version -v Show tty-clock version
-i Show some info about tty-clock -i Show some info about tty-clock
-h Show this page -h Show this page
-D Hide date -D Hide date
-B Enable blinking colon -B Enable blinking colon
-d delay Set the delay between two redraws of the clock. Default 1s. -d delay Set the delay between two redraws of the clock. Default 1s.
-a nsdelay Additional delay between two redraws in nanoseconds. Default 0ns. -a nsdelay Additional delay between two redraws in nanoseconds. Default 0ns.

@ -1,131 +1,131 @@
.\" This manpage was written by Carla Valenti <valenti.karla@gmail.com> .\" This manpage was written by Carla Valenti <valenti.karla@gmail.com>
.\" and Christian Giessen <cgie@informatik.uni-kiel.de> for tty-clock. .\" and Christian Giessen <cgie@informatik.uni-kiel.de> for tty-clock.
.\" In details the command line options displayed by tty-clock -h as .\" In details the command line options displayed by tty-clock -h as
.\" well as the keyboard commands. .\" well as the keyboard commands.
.TH "TTY-CLOCK" "1" "October 2013" "" "User Commands" .TH "TTY-CLOCK" "1" "October 2013" "" "User Commands"
.SH "NAME" .SH "NAME"
.LP .LP
tty\-clock \- a terminal digital clock tty\-clock \- a terminal digital clock
.SH "SYNOPSIS" .SH "SYNOPSIS"
.LP .LP
\fBtty\-clock [\-iuvsScbtrahDBxn] [\-C [\fI0\-7\fB]] [\-f \fIformat\fB] [\-d \fIdelay\fB] [\-a \fInsdelay\fB] \fB[\-T \fItty\fB]\fR \fBtty\-clock [\-iuvsScbtrahDBxn] [\-C [\fI0\-7\fB]] [\-f \fIformat\fB] [\-d \fIdelay\fB] [\-a \fInsdelay\fB] \fB[\-T \fItty\fB]\fR
.SH "DESCRIPTION" .SH "DESCRIPTION"
.LP .LP
\fItty\-clock\fR displays a simple digital clock on the terminal. Invoked without options \fItty\-clock\fR displays a simple digital clock on the terminal. Invoked without options
it will display the clock on the upper left corner of the screen on the terminal it was it will display the clock on the upper left corner of the screen on the terminal it was
executed from. executed from.
.SH "COMMANDS" .SH "COMMANDS"
.LP .LP
\fItty\-clock\fR accepts a number of runtime keyboard commands, upper and lower case characters are \fItty\-clock\fR accepts a number of runtime keyboard commands, upper and lower case characters are
treated identically. treated identically.
.TP .TP
K,J,H,L K,J,H,L
vi\-style movement commands to set the position of the displayed clock. vi\-style movement commands to set the position of the displayed clock.
These commands have no effect when the \fBcentered\fR option is set. These commands have no effect when the \fBcentered\fR option is set.
.TP .TP
[0\-7] [0\-7]
Select a different color for displaying the clock. Select a different color for displaying the clock.
.TP .TP
B B
Toggles between bold and normal colors. Toggles between bold and normal colors.
.TP .TP
X X
Toggles displaying a box around the clock. This option is disabled by default. Toggles displaying a box around the clock. This option is disabled by default.
.TP .TP
C C
Toggle the clock's position to \fBcentered\fR. Toggle the clock's position to \fBcentered\fR.
When set the movement commands are disabled. When set the movement commands are disabled.
.TP .TP
R R
Set the clock to \fBrebound\fR along the edges of the terminal. Set the clock to \fBrebound\fR along the edges of the terminal.
.TP .TP
S S
Display seconds. Display seconds.
.TP .TP
T T
Switch time output to the 12\-hour format. Switch time output to the 12\-hour format.
.TP .TP
Q Q
Quit. Quit.
.SH "OPTIONS" .SH "OPTIONS"
.LP .LP
.TP .TP
\fB\-s\fR \fB\-s\fR
Show seconds. Show seconds.
.TP .TP
\fB\-S\fR \fB\-S\fR
Screensaver mode. tty\-clock terminates when any key is pressed. Screensaver mode. tty\-clock terminates when any key is pressed.
.TP .TP
\fB\-x\fR \fB\-x\fR
Show box. Show box.
.TP .TP
\fB\-c\fR \fB\-c\fR
Set the clock at the center of the terminal. Set the clock at the center of the terminal.
.TP .TP
\fB\-C\fR \fI[0\-7]\fR \fB\-C\fR \fI[0\-7]\fR
Set the clock color. Set the clock color.
.TP .TP
\fB\-b\fR \fB\-b\fR
Use bold colors. Use bold colors.
.TP .TP
\fB\-t\fR \fB\-t\fR
Set the hour in 12h format. Set the hour in 12h format.
.TP .TP
\fB\-u\fR \fB\-u\fR
Use UTC time. Use UTC time.
.TP .TP
\fB\-T\fR \fItty\fR \fB\-T\fR \fItty\fR
Display the clock on the given \fItty\fR. \fItty\fR must be Display the clock on the given \fItty\fR. \fItty\fR must be
a valid character device to which the user has rw access permissions. a valid character device to which the user has rw access permissions.
(See \fBEXAMPLES\fR) (See \fBEXAMPLES\fR)
.TP .TP
\fB\-r\fR \fB\-r\fR
Do rebound the clock. Do rebound the clock.
.TP .TP
\fB\-f\fR \fIformat\fR \fB\-f\fR \fIformat\fR
Set the date format as described in \fBstrftime(3)\fR. Set the date format as described in \fBstrftime(3)\fR.
.TP .TP
\fB\-n\fR \fB\-n\fR
Do not quit the program when the Q key is pressed (or when any Do not quit the program when the Q key is pressed (or when any
key is pressed while in \fBScreensaver\fR mode). A signal must key is pressed while in \fBScreensaver\fR mode). A signal must
be sent to \fItty\-clock\fR in order to terminate its execution. (See \fBEXAMPLES\fR) be sent to \fItty\-clock\fR in order to terminate its execution. (See \fBEXAMPLES\fR)
.TP .TP
\fB\-v\fR \fB\-v\fR
Show tty\-clock version. Show tty\-clock version.
.TP .TP
\fB\-i\fR \fB\-i\fR
Show some info about tty\-clock. Show some info about tty\-clock.
.TP .TP
\fB\-h\fR \fB\-h\fR
Show usage information. Show usage information.
.TP .TP
\fB\-D\fR \fB\-D\fR
Hide the date. Hide the date.
.TP .TP
\fB\-B\fR \fB\-B\fR
Enable blinking colon. Enable blinking colon.
.TP .TP
\fB\-d\fR \fIdelay\fR \fB\-d\fR \fIdelay\fR
Set the delay (in seconds) between two redraws of the clock. Default 1s. Set the delay (in seconds) between two redraws of the clock. Default 1s.
.TP .TP
\fB\-a\fR \fInsdelay\fR \fB\-a\fR \fInsdelay\fR
Additional delay (in nanoseconds) between two redraws of the clock. Default 0ns. Additional delay (in nanoseconds) between two redraws of the clock. Default 0ns.
.SH "EXAMPLES" .SH "EXAMPLES"
.LP .LP
To invoke To invoke
.I tty\-clock .I tty\-clock
in screensaver mode with the clock display set to rebound and the update in screensaver mode with the clock display set to rebound and the update
delay set to 1/10th of a second (10 FPS): delay set to 1/10th of a second (10 FPS):
.IP .IP
$ tty\-clock \-Sra 100000000 \-d 0 $ tty\-clock \-Sra 100000000 \-d 0
.LP .LP
The following example arranges for \fItty\-clock\fR to be displayed The following example arranges for \fItty\-clock\fR to be displayed
indefinitely on one of the Virtual Terminals on a Linux system indefinitely on one of the Virtual Terminals on a Linux system
at boot time using an at boot time using an
.B inittab(5) .B inittab(5)
entry: entry:
.IP .IP
# /etc/inittab: # /etc/inittab:
.br .br
9:2345:respawn:/usr/bin/tty\-clock \-c \-n \-T /dev/tty9 9:2345:respawn:/usr/bin/tty\-clock \-c \-n \-T /dev/tty9
.LP .LP

@ -41,17 +41,17 @@ init(void)
/* Init ncurses */ /* Init ncurses */
if (ttyclock->tty) { if (ttyclock->tty) {
FILE *ftty = fopen(ttyclock->tty, "r+"); FILE *ftty = fopen(ttyclock->tty, "r+");
if (!ftty) { if (!ftty) {
fprintf(stderr, "tty-clock: error: '%s' couldn't be opened: %s.\n", fprintf(stderr, "tty-clock: error: '%s' couldn't be opened: %s.\n",
ttyclock->tty, strerror(errno)); ttyclock->tty, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ttyclock->ttyscr = newterm(NULL, ftty, ftty); ttyclock->ttyscr = newterm(NULL, ftty, ftty);
assert(ttyclock->ttyscr != NULL); assert(ttyclock->ttyscr != NULL);
set_term(ttyclock->ttyscr); set_term(ttyclock->ttyscr);
} else } else
initscr(); initscr();
cbreak(); cbreak();
noecho(); noecho();
@ -166,15 +166,15 @@ signal_handler(int signal)
void void
cleanup(void) cleanup(void)
{ {
if (ttyclock->ttyscr) if (ttyclock->ttyscr)
delscreen(ttyclock->ttyscr); delscreen(ttyclock->ttyscr);
if (ttyclock && ttyclock->tty) if (ttyclock && ttyclock->tty)
free(ttyclock->tty); free(ttyclock->tty);
if (ttyclock && ttyclock->option.format) if (ttyclock && ttyclock->option.format)
free(ttyclock->option.format); free(ttyclock->option.format);
if (ttyclock) if (ttyclock)
free(ttyclock); free(ttyclock);
} }
void void
@ -337,7 +337,7 @@ clock_move(int x, int y, int w, int h)
} }
wrefresh(ttyclock->framewin); wrefresh(ttyclock->framewin);
wrefresh(ttyclock->datewin); wrefresh(ttyclock->datewin);
return; return;
} }
@ -425,7 +425,7 @@ key_event(void)
int i, c; int i, c;
struct timespec length = { ttyclock->option.delay, ttyclock->option.nsdelay }; struct timespec length = { ttyclock->option.delay, ttyclock->option.nsdelay };
if (ttyclock->option.screensaver) if (ttyclock->option.screensaver)
{ {
c = wgetch(stdscr); c = wgetch(stdscr);
@ -446,7 +446,7 @@ key_event(void)
} }
return; return;
} }
switch(c = wgetch(stdscr)) switch(c = wgetch(stdscr))
{ {
@ -485,7 +485,7 @@ key_event(void)
case 'q': case 'q':
case 'Q': case 'Q':
if (ttyclock->option.noquit == False) if (ttyclock->option.noquit == False)
ttyclock->running = False; ttyclock->running = False;
break; break;
case 's': case 's':
@ -578,10 +578,10 @@ main(int argc, char **argv)
" -b Use bold colors \n" " -b Use bold colors \n"
" -t Set the hour in 12h format \n" " -t Set the hour in 12h format \n"
" -u Use UTC time \n" " -u Use UTC time \n"
" -T tty Display the clock on the specified terminal \n" " -T tty Display the clock on the specified terminal \n"
" -r Do rebound the clock \n" " -r Do rebound the clock \n"
" -f format Set the date format \n" " -f format Set the date format \n"
" -n Don't quit on keypress \n" " -n Don't quit on keypress \n"
" -v Show tty-clock version \n" " -v Show tty-clock version \n"
" -i Show some info about tty-clock \n" " -i Show some info about tty-clock \n"
" -h Show this page \n" " -h Show this page \n"
@ -644,25 +644,25 @@ main(int argc, char **argv)
case 'x': case 'x':
ttyclock->option.box = True; ttyclock->option.box = True;
break; break;
case 'T': { case 'T': {
struct stat sbuf; struct stat sbuf;
if (stat(optarg, &sbuf) == -1) { if (stat(optarg, &sbuf) == -1) {
fprintf(stderr, "tty-clock: error: couldn't stat '%s': %s.\n", fprintf(stderr, "tty-clock: error: couldn't stat '%s': %s.\n",
optarg, strerror(errno)); optarg, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (!S_ISCHR(sbuf.st_mode)) { } else if (!S_ISCHR(sbuf.st_mode)) {
fprintf(stderr, "tty-clock: error: '%s' doesn't appear to be a character device.\n", fprintf(stderr, "tty-clock: error: '%s' doesn't appear to be a character device.\n",
optarg); optarg);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else { } else {
if (ttyclock->tty) if (ttyclock->tty)
free(ttyclock->tty); free(ttyclock->tty);
ttyclock->tty = strdup(optarg); ttyclock->tty = strdup(optarg);
}} }}
break; break;
case 'n': case 'n':
ttyclock->option.noquit = True; ttyclock->option.noquit = True;
break; break;
} }
} }
@ -680,3 +680,5 @@ main(int argc, char **argv)
return 0; return 0;
} }
// vim: expandtab tabstop=4 softtabstop=4 shiftwidth=4

@ -60,8 +60,8 @@ typedef struct
{ {
/* while() boolean */ /* while() boolean */
Bool running; Bool running;
/* terminal variables */ /* terminal variables */
SCREEN *ttyscr; SCREEN *ttyscr;
char *tty; char *tty;
int bg; int bg;
@ -77,7 +77,7 @@ typedef struct
Bool date; Bool date;
Bool utc; Bool utc;
Bool box; Bool box;
Bool noquit; Bool noquit;
char *format; char *format;
int color; int color;
Bool bold; Bool bold;
@ -145,3 +145,5 @@ const Bool number[][15] =
}; };
#endif /* TTYCLOCK_H_INCLUDED */ #endif /* TTYCLOCK_H_INCLUDED */
// vim: expandtab tabstop=4 softtabstop=4 shiftwidth=4

Loading…
Cancel
Save