|
|
|
|
@ -86,14 +86,18 @@ init(void) |
|
|
|
|
ttyclock->geo.w, |
|
|
|
|
ttyclock->geo.x, |
|
|
|
|
ttyclock->geo.y); |
|
|
|
|
box(ttyclock->framewin, 0, 0); |
|
|
|
|
if(ttyclock->option.box) { |
|
|
|
|
box(ttyclock->framewin, 0, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Create the date win */ |
|
|
|
|
ttyclock->datewin = newwin(DATEWINH, strlen(ttyclock->date.datestr) + 2, |
|
|
|
|
ttyclock->geo.x + ttyclock->geo.h - 1, |
|
|
|
|
ttyclock->geo.y + (ttyclock->geo.w / 2) - |
|
|
|
|
(strlen(ttyclock->date.datestr) / 2) - 1); |
|
|
|
|
box(ttyclock->datewin, 0, 0); |
|
|
|
|
if(ttyclock->option.box) { |
|
|
|
|
box(ttyclock->datewin, 0, 0); |
|
|
|
|
} |
|
|
|
|
clearok(ttyclock->datewin, True); |
|
|
|
|
|
|
|
|
|
set_center(ttyclock->option.center); |
|
|
|
|
@ -263,8 +267,10 @@ clock_move(int x, int y, int w, int h) |
|
|
|
|
ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1); |
|
|
|
|
wresize(ttyclock->datewin, DATEWINH, strlen(ttyclock->date.datestr) + 2); |
|
|
|
|
|
|
|
|
|
box(ttyclock->framewin, 0, 0); |
|
|
|
|
box(ttyclock->datewin, 0, 0); |
|
|
|
|
if(ttyclock->option.box) { |
|
|
|
|
box(ttyclock->framewin, 0, 0); |
|
|
|
|
box(ttyclock->datewin, 0, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wrefresh(ttyclock->datewin); |
|
|
|
|
wrefresh(ttyclock->framewin); |
|
|
|
|
@ -327,6 +333,29 @@ set_center(Bool b) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
set_box(Bool b) |
|
|
|
|
{ |
|
|
|
|
ttyclock->option.box = b; |
|
|
|
|
|
|
|
|
|
wbkgdset(ttyclock->framewin, COLOR_PAIR(0)); |
|
|
|
|
wbkgdset(ttyclock->datewin, COLOR_PAIR(0)); |
|
|
|
|
|
|
|
|
|
if(ttyclock->option.box) { |
|
|
|
|
wbkgdset(ttyclock->framewin, COLOR_PAIR(0)); |
|
|
|
|
wbkgdset(ttyclock->datewin, COLOR_PAIR(0)); |
|
|
|
|
box(ttyclock->framewin, 0, 0); |
|
|
|
|
box(ttyclock->datewin, 0, 0); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
wborder(ttyclock->framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); |
|
|
|
|
wborder(ttyclock->datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wrefresh(ttyclock->datewin); |
|
|
|
|
wrefresh(ttyclock->framewin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
key_event(void) |
|
|
|
|
{ |
|
|
|
|
@ -419,6 +448,12 @@ key_event(void) |
|
|
|
|
if(ttyclock->option.rebound && ttyclock->option.center) |
|
|
|
|
ttyclock->option.center = False; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'b': |
|
|
|
|
case 'B': |
|
|
|
|
set_box(!ttyclock->option.box); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
nanosleep(&length, NULL); |
|
|
|
|
for(i = 0; i < 8; ++i) |
|
|
|
|
@ -453,15 +488,16 @@ main(int argc, char **argv) |
|
|
|
|
|
|
|
|
|
atexit(cleanup); |
|
|
|
|
|
|
|
|
|
while ((c = getopt(argc, argv, "tvsSrcihf:d:C:")) != -1) |
|
|
|
|
while ((c = getopt(argc, argv, "tvsSrcihbf:d:C:")) != -1) |
|
|
|
|
{ |
|
|
|
|
switch(c) |
|
|
|
|
{ |
|
|
|
|
case 'h': |
|
|
|
|
default: |
|
|
|
|
printf("usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format] \n" |
|
|
|
|
printf("usage : tty-clock [-sSbctrvih] [-C [0-7]] [-f format] [-d delay] \n" |
|
|
|
|
" -s Show seconds \n" |
|
|
|
|
" -S Screensaver mode \n" |
|
|
|
|
" -b Show box \n" |
|
|
|
|
" -c Set the clock at the center of the terminal \n" |
|
|
|
|
" -C [0-7] Set the clock color \n" |
|
|
|
|
" -t Set the hour in 12h format \n" |
|
|
|
|
@ -507,6 +543,9 @@ main(int argc, char **argv) |
|
|
|
|
if(atol(optarg) >= 0 && atol(optarg) < 1000000000) |
|
|
|
|
ttyclock->option.delay = atol(optarg); |
|
|
|
|
break; |
|
|
|
|
case 'b': |
|
|
|
|
ttyclock->option.box = True; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|