(maint) Add blink colon option

Prior to this commit, my blinking colon pull req made blinking default.
This commit makes it so that you have to pass in a flag -B to make the
colons blink. This fits with the style of this program.
reverse-branch
Brian Cain 13 years ago
parent aefad0a773
commit ad835677bc
  1. 1
      README
  2. 46
      ttyclock.c
  3. 1
      ttyclock.h

@ -8,3 +8,4 @@ usage : tty-clock [-sctrvih] [-C [0-7]] [-f format]
-v Show tty-clock version
-i Show some info about tty-clock
-h Show this page
-B Enable blinking colon

@ -207,20 +207,28 @@ draw_clock(void)
draw_number(ttyclock->date.hour[0], 1, 1);
draw_number(ttyclock->date.hour[1], 1, 8);
time_t seconds;
seconds = time(NULL);
if (seconds % 2 != 0){
/* 2 dot for number separation */
wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
if (ttyclock->option.blink){
time_t seconds;
seconds = time(NULL);
if (seconds % 2 != 0){
/* 2 dot for number separation */
wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
}
else if (seconds % 2 == 0){
/*2 dot black for blinking */
wbkgdset(ttyclock->framewin, COLOR_PAIR(2));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
}
}
else if (seconds % 2 == 0){
/*2 dot black for blinking */
wbkgdset(ttyclock->framewin, COLOR_PAIR(2));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
else{
/* 2 dot for number separation */
wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
}
/* Draw minute numbers */
@ -448,14 +456,16 @@ main(int argc, char **argv)
ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */
/* Default delay */
ttyclock->option.delay = 40000000; /* 25FPS */
/* Default blink */
ttyclock->option.blink = False;
while ((c = getopt(argc, argv, "tvsrcihfDd:C:")) != -1)
while ((c = getopt(argc, argv, "tvsrcihfDBd:C:")) != -1)
{
switch(c)
{
case 'h':
default:
printf("usage : tty-clock [-sctrvihD] [-C [0-7]] [-f format] \n"
printf("usage : tty-clock [-sctrvihDB] [-C [0-7]] [-f format] \n"
" -s Show seconds \n"
" -c Set the clock at the center of the terminal \n"
" -C [0-7] Set the clock color \n"
@ -466,7 +476,8 @@ main(int argc, char **argv)
" -i Show some info about tty-clock \n"
" -h Show this page \n"
" -d delay Set the delay between two redraws of the clock \n"
" -D Hide date \n");
" -D Hide date \n"
" -B Enable blinking colon \n");
free(ttyclock);
exit(EXIT_SUCCESS);
break;
@ -508,6 +519,9 @@ main(int argc, char **argv)
case 'D':
ttyclock->option.date = False;
break;
case 'B':
ttyclock->option.blink = True;
break;
}
}

@ -68,6 +68,7 @@ typedef struct
char *format;
int color;
long delay;
Bool blink;
} option;
/* Clock geometry */

Loading…
Cancel
Save