Merge remote branch 'Karnash/master' - tty-clock - port of tty-clock to OpenBSD, with pledge/unveil added as goodie.
 (HTM) git clone https://git.drkhsh.at/tty-clock.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2a3e01597e689ec7fe40fb0a83a09beea9d35f58
 (DIR) parent df64a7fbb2fe270c98426f8f4556e5a14bd6fa30
 (HTM) Author: anarcat <anarcat@koumbit.org>
       Date:   Tue, 11 Jan 2011 00:23:16 -0500
       
       Merge remote branch 'Karnash/master'
       
       Conflicts:
               README
               ttyclock.c
       
       Diffstat:
         M README                              |      23 ++++++++++++-----------
         M ttyclock.c                          |      51 +++++++++++++++++++++++++++----
         M ttyclock.h                          |       2 ++
       
       3 files changed, 59 insertions(+), 17 deletions(-)
       ---
 (DIR) diff --git 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 
 (DIR) diff --git 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);
       @@ -319,6 +325,29 @@ set_center(Bool b)
        }
        
        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)
        {
             int i, c;
       @@ -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;
                  }
             }
        
 (DIR) diff --git 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 */