Merge git://github.com/Karnash/tty-clock

This adds the -b command line option (already present in the debian
version) which disables displaying a box by default.
reverse-branch
Carla Valenti 15 years ago
commit 4296d5c151
  1. 3
      README
  2. 51
      ttyclock.c
  3. 2
      ttyclock.h

@ -1,5 +1,6 @@
usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format]
-s Show seconds
-b Show box
-S Screensaver mode
-c Set the clock at the center of the terminal
-C [0-7] Set the clock color
@ -9,3 +10,5 @@ usage : tty-clock [-sSctrvih] [-C [0-7]] [-f 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

@ -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;
}
}

@ -65,6 +65,7 @@ typedef struct
Bool twelve;
Bool center;
Bool rebound;
Bool box;
char *format;
int color;
long delay;
@ -107,6 +108,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 */

Loading…
Cancel
Save