diff --git a/README b/README index 62d1726..2942123 100755 --- a/README +++ b/README @@ -1,11 +1,12 @@ -usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] [-d delay] - -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 +usage : tty-clock [-sbctrvih] [-C [0-7]] [-f format] [-d delay] + -s Show seconds + -b Show box + -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 diff --git a/ttyclock.c b/ttyclock.c index 1a8daee..6df69e6 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -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); @@ -254,8 +258,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); @@ -318,6 +324,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) { @@ -388,6 +417,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) @@ -420,14 +455,15 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihf:d:C:")) != -1) + while ((c = getopt(argc, argv, "tvsrcihbf:d:C:")) != -1) { switch(c) { case 'h': default: - printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] [-d delay] \n" + printf("usage : tty-clock [-sbctrvih] [-C [0-7]] [-f format] [-d delay] \n" " -s Show seconds \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" @@ -475,6 +511,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; } } diff --git a/ttyclock.h b/ttyclock.h index 911aa20..08c8a32 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -64,6 +64,7 @@ typedef struct Bool twelve; Bool center; Bool rebound; + Bool box; char *format; int color; long delay; @@ -106,6 +107,7 @@ void draw_clock(void); void clock_move(int x, int y, int w, int h); void set_second(void); void set_center(Bool b); +void set_box(Bool b); void key_event(void); /* Global variable */