Merge pull request #14 from briancain/master

Adding Blinking Colon
reverse-branch
Martin Duquesnoy 13 years ago
commit 7a789dc0f8
  1. 2
      .gitignore
  2. 23
      README
  3. 39
      ttyclock.c
  4. 1
      ttyclock.h

2
.gitignore vendored

@ -0,0 +1,2 @@
tty-clock
tty-clock.dSYM/

@ -1,10 +1,13 @@
usage : tty-clock [-sctrvih] [-C [0-7]] [-f format]
-s Show seconds
-c Set the clock at the center of the terminal
-C [0-7] Set the clock color
-t Set the hour in 12h format
-r Do rebound the clock
-f format Set the date format
-v Show tty-clock version
-i Show some info about tty-clock
-h Show this page
usage : tty-clock [-sctrvihDB] [-C [0-7]] [-f format]
-s Show seconds
-c Set the clock at the center of the terminal
-C [0-7] Set the clock color
-t Set the hour in 12h format
-r Do rebound the clock
-f format Set the date format
-v Show tty-clock version
-i Show some info about tty-clock
-h Show this page
-d delay Set the delay between two redraws of the clock
-D Hide date
-B Enable blinking colon

@ -207,10 +207,29 @@ draw_clock(void)
draw_number(ttyclock->date.hour[0], 1, 1);
draw_number(ttyclock->date.hour[1], 1, 8);
/* 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{
/* 2 dot for number separation */
wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
mvwaddstr(ttyclock->framewin, 2, 16, " ");
mvwaddstr(ttyclock->framewin, 4, 16, " ");
}
/* Draw minute numbers */
draw_number(ttyclock->date.minute[0], 1, 20);
@ -437,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"
@ -455,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;
@ -497,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