Fix uneven indentation

master
Jakub Wilk 6 years ago
parent e20a6efebd
commit aab718ad40
  1. 70
      ttyclock.c

@ -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();
@ -95,18 +95,18 @@ init(void)
ttyclock.geo.h = 7; ttyclock.geo.h = 7;
ttyclock.tm = localtime(&(ttyclock.lt)); ttyclock.tm = localtime(&(ttyclock.lt));
if(ttyclock.option.utc) { if(ttyclock.option.utc) {
ttyclock.tm = gmtime(&(ttyclock.lt)); ttyclock.tm = gmtime(&(ttyclock.lt));
} }
ttyclock.lt = time(NULL); ttyclock.lt = time(NULL);
update_hour(); update_hour();
/* Create clock win */ /* Create clock win */
ttyclock.framewin = newwin(ttyclock.geo.h, ttyclock.framewin = newwin(ttyclock.geo.h,
ttyclock.geo.w, ttyclock.geo.w,
ttyclock.geo.x, ttyclock.geo.x,
ttyclock.geo.y); ttyclock.geo.y);
if(ttyclock.option.box) { if(ttyclock.option.box) {
box(ttyclock.framewin, 0, 0); box(ttyclock.framewin, 0, 0);
} }
if (ttyclock.option.bold) if (ttyclock.option.bold)
@ -116,9 +116,9 @@ init(void)
/* Create the date win */ /* Create the date win */
ttyclock.datewin = newwin(DATEWINH, strlen(ttyclock.date.datestr) + 2, ttyclock.datewin = newwin(DATEWINH, strlen(ttyclock.date.datestr) + 2,
ttyclock.geo.x + ttyclock.geo.h - 1, ttyclock.geo.x + ttyclock.geo.h - 1,
ttyclock.geo.y + (ttyclock.geo.w / 2) - ttyclock.geo.y + (ttyclock.geo.w / 2) -
(strlen(ttyclock.date.datestr) / 2) - 1); (strlen(ttyclock.date.datestr) / 2) - 1);
if(ttyclock.option.box && ttyclock.option.date) { if(ttyclock.option.box && ttyclock.option.date) {
box(ttyclock.datewin, 0, 0); box(ttyclock.datewin, 0, 0);
} }
@ -166,10 +166,10 @@ signal_handler(int signal)
void void
cleanup(void) cleanup(void)
{ {
if (ttyclock.ttyscr) if (ttyclock.ttyscr)
delscreen(ttyclock.ttyscr); delscreen(ttyclock.ttyscr);
free(ttyclock.tty); free(ttyclock.tty);
} }
void void
@ -181,7 +181,7 @@ update_hour(void)
ttyclock.lt = time(NULL); ttyclock.lt = time(NULL);
ttyclock.tm = localtime(&(ttyclock.lt)); ttyclock.tm = localtime(&(ttyclock.lt));
if(ttyclock.option.utc) { if(ttyclock.option.utc) {
ttyclock.tm = gmtime(&(ttyclock.lt)); ttyclock.tm = gmtime(&(ttyclock.lt));
} }
ihour = ttyclock.tm->tm_hour; ihour = ttyclock.tm->tm_hour;
@ -322,13 +322,13 @@ clock_move(int x, int y, int w, int h)
wresize(ttyclock.datewin, DATEWINH, strlen(ttyclock.date.datestr) + 2); wresize(ttyclock.datewin, DATEWINH, strlen(ttyclock.date.datestr) + 2);
if (ttyclock.option.box) { if (ttyclock.option.box) {
box(ttyclock.datewin, 0, 0); box(ttyclock.datewin, 0, 0);
} }
} }
if (ttyclock.option.box) if (ttyclock.option.box)
{ {
box(ttyclock.framewin, 0, 0); box(ttyclock.framewin, 0, 0);
} }
wrefresh(ttyclock.framewin); wrefresh(ttyclock.framewin);
@ -400,14 +400,14 @@ set_box(Bool b)
wbkgdset(ttyclock.datewin, COLOR_PAIR(0)); wbkgdset(ttyclock.datewin, COLOR_PAIR(0));
if(ttyclock.option.box) { if(ttyclock.option.box) {
wbkgdset(ttyclock.framewin, COLOR_PAIR(0)); wbkgdset(ttyclock.framewin, COLOR_PAIR(0));
wbkgdset(ttyclock.datewin, COLOR_PAIR(0)); wbkgdset(ttyclock.datewin, COLOR_PAIR(0));
box(ttyclock.framewin, 0, 0); box(ttyclock.framewin, 0, 0);
box(ttyclock.datewin, 0, 0); box(ttyclock.datewin, 0, 0);
} }
else { else {
wborder(ttyclock.framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wborder(ttyclock.framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wborder(ttyclock.datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wborder(ttyclock.datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
} }
wrefresh(ttyclock.datewin); wrefresh(ttyclock.datewin);
@ -569,10 +569,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"
@ -631,7 +631,7 @@ main(int argc, char **argv)
case 'a': case 'a':
if(atol(optarg) >= 0 && atol(optarg) < 1000000000) if(atol(optarg) >= 0 && atol(optarg) < 1000000000)
ttyclock.option.nsdelay = atol(optarg); ttyclock.option.nsdelay = atol(optarg);
break; break;
case 'x': case 'x':
ttyclock.option.box = True; ttyclock.option.box = True;
break; break;
@ -646,8 +646,8 @@ main(int argc, char **argv)
optarg); optarg);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else { } else {
free(ttyclock.tty); free(ttyclock.tty);
ttyclock.tty = strdup(optarg); ttyclock.tty = strdup(optarg);
}} }}
break; break;
case 'n': case 'n':

Loading…
Cancel
Save