URI:
       add set center function (-c) - tty-clock - port of tty-clock to OpenBSD, with pledge/unveil added as goodie.
  HTML git clone https://git.drkhsh.at/tty-clock.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 2ae69059c4f5edca275ed97190d9172244edff0a
   DIR parent 541c860cb1e78138d5e245af6a6a94f1aada8fc7
  HTML Author: martin <xorg62@gmail.com>
       Date:   Fri, 20 Jun 2008 01:08:50 +0200
       
       add set center function (-c)
       
       Diffstat:
         M clock.c                             |      37 ++++++++++++++++++++++++++++---
       
       1 file changed, 34 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/clock.c b/clock.c
       @@ -27,6 +27,7 @@
        #define printh() printf("tty-clock usage : tty-clock -[option] -[option] <arg>\n\n\
          -s, --second                 Show seconds\n\
          -b, --block                 Lock the keyboard\n\
       +  -c, --center                 Set the clock at the center of the terminal\n\
          -t, --tw                 Set the hour in 12h format\n\
          -x  <integer>                 Set the clock to X\n\
          -y  <integer>                 Set the clock to Y\n\
       @@ -41,6 +42,12 @@ push S for enable the second and T for enable the 12H hours format.\n");\
        #define YLENGTH 52
        #define DEPTHB -1
        
       +void start(void);
       +void check_key(bool);
       +void get_time(void);
       +void set_center(void);
       +void run(void);
       +
        /* *************** */
        /* BIG NUMBER INIT */
        /* *************** */
       @@ -69,6 +76,7 @@ static struct option long_options[] ={
                {"second",  0, NULL, 's'},
                {"twelve",        0, NULL, 't'},
                {"block",        0, NULL, 'b'},
       +        {"center",        0, NULL, 'c'},
                {NULL,                0, NULL, 0}
        };
        
       @@ -166,7 +174,7 @@ arrange_clock(int h1, int h2,
                                  int m1, int m2, 
                                  int s1, int s2) {
                int i;
       -
       +        
                temp_dp = (option.second) ? 21 : 12;
        
                print_number(h1, defx, defy);
       @@ -222,7 +230,7 @@ arrange_clock(int h1, int h2,
        /* ********************* */
        
        void
       -check_key(int keylock) {
       +check_key(bool keylock) {
                
                if (keylock) {
                        int c;
       @@ -278,6 +286,12 @@ check_key(int keylock) {
                                                option.twelve = 0;
                                        }
                                        break;
       +                        case 'c':
       +                        case 'C':
       +                                clear();
       +                                set_center();
       +                                
       +                                break;
                                case 'q':
                                case 'Q':
                                        endwin();
       @@ -327,6 +341,20 @@ get_time(void) {
                }
        }
        
       +/* ******************* */
       +/* SET CENTER FUNCTION */
       +/* ******************* */
       +
       +void
       +set_center(void) {
       +        start();
       +        maxcol = getmaxy(stdscr);
       +        maxlin = getmaxx(stdscr);
       +        
       +        defy = maxlin / 2 - SCHANGE + 2;
       +        defx = maxcol / 2 - XLENGTH + 2;
       +}
       +
        /* *********** */
        /* RUN FUCTION */
        /* *********** */
       @@ -352,7 +380,7 @@ main(int argc,char **argv) {
                int c;
                option.keylock = 1;
        
       -        while ((c = getopt_long(argc,argv,"tx:y:vsbih",
       +        while ((c = getopt_long(argc,argv,"tx:y:vsbcih",
                                long_options,NULL)) != -1) {
                        switch(c) {
                                case 'h':
       @@ -392,6 +420,9 @@ main(int argc,char **argv) {
                                case 'b':
                                        option.keylock = 0;
                                        break;
       +                        case 'c':
       +                                set_center();
       +                                break;
                                }
                        }