Changeset 4800


Ignore:
Timestamp:
01/11/12 16:44:37 (18 months ago)
Author:
alxf
Message:

Drop tabs and trailing spaces.

Location:
libcaca/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/caca/canvas.py

    r4776 r4800  
    15461546 
    15471547    def set_figfont(self, filename): 
    1548         """     Load a figfont and attach it to a canvas. 
     1548        """ Load a figfont and attach it to a canvas. 
    15491549 
    15501550            filename    -- the figfont file to load. 
  • libcaca/trunk/src/cacaclock.c

    r4787 r4800  
    2626static void usage(int argc, char **argv) 
    2727{ 
    28         fprintf(stderr, "Usage: %s [OPTIONS]...\n", argv[0]); 
    29         fprintf(stderr, "Display current time in text mode     (q to quit)\n"); 
    30         fprintf(stderr, "Example : %s -d '%%R'\n\n", argv[0]); 
    31         fprintf(stderr, "Options:\n"); 
    32         fprintf(stderr, "  -h, --help\t\t\tThis help\n"); 
    33         fprintf(stderr, "  -v, --version\t\t\tVersion of the program\n"); 
    34         fprintf(stderr, "  -f, --font=FONT\t\tUse FONT for time display\n"); 
    35         fprintf(stderr, "  -d, --dateformat=FORMAT\tUse FORMAT as strftime argument (default %%R:%%S)\n"); 
     28    fprintf(stderr, "Usage: %s [OPTIONS]...\n", argv[0]); 
     29    fprintf(stderr, "Display current time in text mode     (q to quit)\n"); 
     30    fprintf(stderr, "Example : %s -d '%%R'\n\n", argv[0]); 
     31    fprintf(stderr, "Options:\n"); 
     32    fprintf(stderr, "  -h, --help\t\t\tThis help\n"); 
     33    fprintf(stderr, "  -v, --version\t\t\tVersion of the program\n"); 
     34    fprintf(stderr, "  -f, --font=FONT\t\tUse FONT for time display\n"); 
     35    fprintf(stderr, "  -d, --dateformat=FORMAT\tUse FORMAT as strftime argument (default %%R:%%S)\n"); 
    3636} 
    3737 
     
    3939static void version(void) 
    4040{ 
    41         printf( 
    42                         "cacaclock Copyright 2011 Jean-Yves Lamoureux\n" 
    43                         "Internet: <jylam@lnxscene.org> Version: %s (libcaca %s), date: %s\n" 
    44                         "\n" 
    45                         "cacaclock, along with its documentation, may be freely copied and distributed.\n" 
    46                         "\n" 
    47                         "The latest version of cacaclock is available from the web site,\n" 
    48                         "        http://caca.zoy.org/wiki/libcaca in the libcaca package.\n" 
    49                         "\n", 
    50                         CACACLOCKVERSION, caca_get_version(), __DATE__); 
     41    printf( 
     42            "cacaclock Copyright 2011 Jean-Yves Lamoureux\n" 
     43            "Internet: <jylam@lnxscene.org> Version: %s (libcaca %s), date: %s\n" 
     44            "\n" 
     45            "cacaclock, along with its documentation, may be freely copied and distributed.\n" 
     46            "\n" 
     47            "The latest version of cacaclock is available from the web site,\n" 
     48            "        http://caca.zoy.org/wiki/libcaca in the libcaca package.\n" 
     49            "\n", 
     50            CACACLOCKVERSION, caca_get_version(), __DATE__); 
    5151} 
    5252 
    5353 
    5454static char* get_date(char *format) { 
    55         time_t  currtime; 
    56         char *charTime = malloc(101); 
     55    time_t  currtime; 
     56    char *charTime = malloc(101); 
    5757 
    58         time(&currtime); 
    59         strftime(charTime, 100,format,localtime(&currtime)); 
     58    time(&currtime); 
     59    strftime(charTime, 100,format,localtime(&currtime)); 
    6060 
    61         return charTime; 
     61    return charTime; 
    6262} 
    6363 
    6464int main(int argc, char *argv[]) { 
    6565 
    66         caca_canvas_t *cv; 
    67         caca_canvas_t *figcv; 
    68         caca_display_t *dp; 
    69         uint32_t w, h, fw, fh; 
     66    caca_canvas_t *cv; 
     67    caca_canvas_t *figcv; 
     68    caca_display_t *dp; 
     69    uint32_t w, h, fw, fh; 
    7070 
    71         char *format = "%R:%S"; 
    72         char *font   = "/usr/share/figlet/mono12.tlf"; 
     71    char *format = "%R:%S"; 
     72    char *font   = "/usr/share/figlet/mono12.tlf"; 
    7373 
    7474 
    75         for(;;) 
    76         { 
    77                 int option_index = 0; 
    78                 static struct caca_option long_options[] = 
    79                 { 
    80                         { "font",        1, NULL, 'f' }, 
    81                         { "dateformat",  1, NULL, 'd' }, 
    82                         { "help",        0, NULL, 'h' }, 
    83                         { "version",     0, NULL, 'v' }, 
    84                 }; 
    85                 int c = caca_getopt(argc, argv, "f:d:hv", 
    86                                 long_options, &option_index); 
    87                 if(c == -1) 
    88                         break; 
     75    for(;;) 
     76    { 
     77        int option_index = 0; 
     78        static struct caca_option long_options[] = 
     79        { 
     80            { "font",        1, NULL, 'f' }, 
     81            { "dateformat",  1, NULL, 'd' }, 
     82            { "help",        0, NULL, 'h' }, 
     83            { "version",     0, NULL, 'v' }, 
     84        }; 
     85        int c = caca_getopt(argc, argv, "f:d:hv", 
     86                long_options, &option_index); 
     87        if(c == -1) 
     88            break; 
    8989 
    90                 switch(c) 
    91                 { 
    92                         case 'h': /* --help       */ 
    93                                 usage(argc, argv); 
    94                                 return 0; 
    95                                 break; 
    96                         case 'v': /* --version    */ 
    97                                 version(); 
    98                                 return 0; 
    99                                 break; 
    100                         case 'f': /* --font       */ 
    101                                 font = caca_optarg; 
    102                                 break; 
    103                         case 'd': /* --dateformat */ 
    104                                 format = caca_optarg; 
    105                                 break; 
    106                         default: 
    107                                 return 1; 
    108                                 break; 
    109                 } 
    110         } 
     90        switch(c) 
     91        { 
     92            case 'h': /* --help       */ 
     93                usage(argc, argv); 
     94                return 0; 
     95                break; 
     96            case 'v': /* --version    */ 
     97                version(); 
     98                return 0; 
     99                break; 
     100            case 'f': /* --font       */ 
     101                font = caca_optarg; 
     102                break; 
     103            case 'd': /* --dateformat */ 
     104                format = caca_optarg; 
     105                break; 
     106            default: 
     107                return 1; 
     108                break; 
     109        } 
     110    } 
    111111 
    112112 
    113113 
    114         cv = caca_create_canvas(0, 0); 
    115         figcv = caca_create_canvas(0, 0); 
    116         if(!cv || !figcv) 
    117         { 
    118                 fprintf(stderr, "%s: unable to initialise libcaca\n", argv[0]); 
    119                 return 1; 
    120         } 
     114    cv = caca_create_canvas(0, 0); 
     115    figcv = caca_create_canvas(0, 0); 
     116    if(!cv || !figcv) 
     117    { 
     118        fprintf(stderr, "%s: unable to initialise libcaca\n", argv[0]); 
     119        return 1; 
     120    } 
    121121 
    122         if(caca_canvas_set_figfont(figcv, font)) 
    123         { 
    124                 fprintf(stderr, "Could not open font\n"); 
    125                 return -1; 
    126         } 
     122    if(caca_canvas_set_figfont(figcv, font)) 
     123    { 
     124        fprintf(stderr, "Could not open font\n"); 
     125        return -1; 
     126    } 
    127127 
    128128 
    129         dp = caca_create_display(cv); 
    130         if(!dp) { 
    131                 printf("Can't open window. CACA_DRIVER problem ?\n"); 
    132                 return -1; 
    133         } 
     129    dp = caca_create_display(cv); 
     130    if(!dp) { 
     131        printf("Can't open window. CACA_DRIVER problem ?\n"); 
     132        return -1; 
     133    } 
    134134 
    135         caca_set_color_ansi(figcv, CACA_DEFAULT, CACA_DEFAULT); 
    136         caca_clear_canvas(cv); 
    137         for(;;) { 
    138                 caca_event_t ev; 
     135    caca_set_color_ansi(figcv, CACA_DEFAULT, CACA_DEFAULT); 
     136    caca_clear_canvas(cv); 
     137    for(;;) { 
     138        caca_event_t ev; 
    139139 
    140                 while(caca_get_event(dp, CACA_EVENT_KEY_PRESS 
    141                                         | CACA_EVENT_QUIT, &ev, 1)) 
    142                 { 
    143                         if(caca_get_event_type(&ev)) 
    144                                 goto end; 
    145                 } 
    146                 char *d = get_date(format); 
    147                 uint32_t o = 0; 
     140        while(caca_get_event(dp, CACA_EVENT_KEY_PRESS 
     141                    | CACA_EVENT_QUIT, &ev, 1)) 
     142        { 
     143            if(caca_get_event_type(&ev)) 
     144                goto end; 
     145        } 
     146        char *d = get_date(format); 
     147        uint32_t o = 0; 
    148148 
    149                 // figfont API is not complete, and does not allow us to put a string 
    150                 // at another position than 0,0 
    151                 // So, we have to create a canvas which will hold the figfont string, 
    152                 // then blit this canvas to the main one at the desired position. 
    153                 caca_clear_canvas(cv); 
    154                 caca_clear_canvas(figcv); 
    155                 while(d[o]) 
    156                 { 
    157                         caca_put_figchar(figcv, d[o++]); 
    158                 } 
    159                 caca_flush_figlet (figcv); 
    160                 free(d); 
     149        // figfont API is not complete, and does not allow us to put a string 
     150        // at another position than 0,0 
     151        // So, we have to create a canvas which will hold the figfont string, 
     152        // then blit this canvas to the main one at the desired position. 
     153        caca_clear_canvas(cv); 
     154        caca_clear_canvas(figcv); 
     155        while(d[o]) 
     156        { 
     157            caca_put_figchar(figcv, d[o++]); 
     158        } 
     159        caca_flush_figlet (figcv); 
     160        free(d); 
    161161 
    162                 w = caca_get_canvas_width (cv); 
    163                 h = caca_get_canvas_height(cv); 
     162        w = caca_get_canvas_width (cv); 
     163        h = caca_get_canvas_height(cv); 
    164164        fw = caca_get_canvas_width (figcv); 
    165                 fh = caca_get_canvas_height(figcv);      
     165        fh = caca_get_canvas_height(figcv); 
    166166 
    167                 uint32_t x = (w/2) - (fw/2); 
    168                 uint32_t y = (h/2) - (fh/2); 
     167        uint32_t x = (w/2) - (fw/2); 
     168        uint32_t y = (h/2) - (fh/2); 
    169169 
    170                 caca_blit(cv, x, y, figcv, NULL); 
    171                 caca_refresh_display(dp); 
    172                 usleep(250000); 
    173         } 
     170        caca_blit(cv, x, y, figcv, NULL); 
     171        caca_refresh_display(dp); 
     172        usleep(250000); 
     173    } 
    174174end: 
    175175 
    176         caca_free_canvas(figcv); 
    177         caca_free_canvas(cv); 
    178         caca_free_display(dp); 
     176    caca_free_canvas(figcv); 
     177    caca_free_canvas(cv); 
     178    caca_free_display(dp); 
    179179 
    180         return 0; 
     180    return 0; 
    181181} 
Note: See TracChangeset for help on using the changeset viewer.