Changeset 665


Ignore:
Timestamp:
Mar 22, 2006, 6:46:11 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Changed the cucul_init parameter so that it now directly accepts a canvas size (use cucul_init(0, 0) for the old behaviour).
Location:
libcaca/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/cucul.c

    r663 r665  
    3838 *  be called at the end of the program to free all allocated resources.
    3939 *
     40 *  If one of the desired canvas coordinates is zero, a default canvas size
     41 *  of 80x32 is used instead.
     42 *
     43 *  \param width The desired canvas width
     44 *  \param height The desired canvas height
    4045 *  \return 0 upon success, a non-zero value if an error occurs.
    4146 */
    42 cucul_t * cucul_init(void)
     47cucul_t * cucul_init(unsigned int width, unsigned int height)
    4348{
    4449    cucul_t *qq = malloc(sizeof(cucul_t));
     
    4954    qq->bgcolor = CUCUL_COLOR_BLACK;
    5055
    51     /* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
    52      * default X11 window. When a graphic driver attaches to us, it can set
    53      * a different size. */
    5456    qq->width = qq->width = 0;
    5557    qq->chars = NULL;
    5658    qq->attr = NULL;
    5759    qq->empty_line = qq->scratch_line = NULL;
    58     _cucul_set_size(qq, 80, 32);
     60
     61    /* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
     62     * default X11 window. When a graphic driver attaches to us, it can set
     63     * a different size. */
     64    if(width && height)
     65        _cucul_set_size(qq, width, height);
     66    else
     67        _cucul_set_size(qq, 80, 32);
    5968
    6069    if(_cucul_init_bitmap())
     
    7079 *
    7180 *  This function sets the canvas width and height, in character cells.
     81 *
     82 *  The contents of the canvas are preserved to the extent of the new
     83 *  canvas size. Newly allocated character cells at the right and/or at
     84 *  the bottom of the canvas are filled with spaces.
    7285 *
    7386 *  It is an error to try to resize the canvas if an output driver has
    7487 *  been attached to the canvas using caca_attach(). You need to remove
    7588 *  the output driver using caca_detach() before you can change the
    76  *  canvas size again.
    77  *
    78  *  However, the caca output driver can cause a canvas resize through
    79  *  user interaction. See the caca_event() documentation for more about
    80  *  this.
     89 *  canvas size again. However, the caca output driver can cause a canvas
     90 *  resize through user interaction. See the caca_event() documentation
     91 *  for more about this.
    8192 *
    8293 *  \param width The desired canvas width
  • libcaca/trunk/cucul/cucul.h

    r658 r665  
    119119 *
    120120 *  @{ */
    121 cucul_t * cucul_init(void);
     121cucul_t * cucul_init(unsigned int, unsigned int);
    122122void cucul_set_size(cucul_t *, unsigned int, unsigned int);
    123123unsigned int cucul_get_width(cucul_t *);
  • libcaca/trunk/src/aafire.c

    r653 r665  
    101101
    102102#ifdef LIBCACA
    103   qq = cucul_init();
     103  qq = cucul_init(80, 32);
    104104  if (!qq)
    105105    {
  • libcaca/trunk/src/cacaball.c

    r653 r665  
    5454    double frameOffset80[360];
    5555
    56     qq = cucul_init();
     56    qq = cucul_init(0, 0);
    5757    if(!qq)
    5858        return 1;
  • libcaca/trunk/src/cacamoir.c

    r653 r665  
    4343    int i, x, y, frame = 0, pause = 0;
    4444
    45     qq = cucul_init();
     45    qq = cucul_init(0, 0);
    4646    if(!qq)
    4747        return 1;
  • libcaca/trunk/src/cacaplas.c

    r655 r665  
    4646    int i, x, y, frame = 0, pause = 0;
    4747
    48     qq = cucul_init();
     48    qq = cucul_init(0, 0);
    4949    if(!qq)
    5050        return 1;
  • libcaca/trunk/src/cacaview.c

    r662 r665  
    8989
    9090    /* Initialise libcucul */
    91     qq = cucul_init();
     91    qq = cucul_init(0, 0);
    9292    if(!qq)
    9393    {
  • libcaca/trunk/test/colors.c

    r592 r665  
    2727    int i, j;
    2828
    29     qq = cucul_init();
     29    qq = cucul_init(0, 0);
    3030    if(!qq)
    3131        return 1;
  • libcaca/trunk/test/demo.c

    r653 r665  
    4646    int quit = 0;
    4747
    48     qq = cucul_init();
     48    qq = cucul_init(0, 0);
    4949    if(!qq)
    5050        return 1;
  • libcaca/trunk/test/dithering.c

    r527 r665  
    4040    int x, y;
    4141
    42     qq = cucul_init();
     42    qq = cucul_init(0, 0);
    4343    kk = caca_attach(qq);
    4444
  • libcaca/trunk/test/event.c

    r527 r665  
    3131    int i, h, quit;
    3232
    33     qq = cucul_init();
     33    qq = cucul_init(0, 0);
    3434    if(!qq)
    3535        return 1;
  • libcaca/trunk/test/export.c

    r653 r665  
    6767    }
    6868
    69     qq = cucul_init();
     69    qq = cucul_init(0, 0);
    7070    cucul_set_size(qq, WIDTH, HEIGHT);
    7171
  • libcaca/trunk/test/gamma.c

    r661 r665  
    3535    int x;
    3636
    37     qq = cucul_init();
     37    qq = cucul_init(0, 0);
    3838    kk = caca_attach(qq);
    3939
  • libcaca/trunk/test/hsv.c

    r653 r665  
    3535    int x, y;
    3636
    37     qq = cucul_init();
     37    qq = cucul_init(0, 0);
    3838    kk = caca_attach(qq);
    3939
  • libcaca/trunk/test/spritedit.c

    r527 r665  
    3434    }
    3535
    36     qq = cucul_init();
     36    qq = cucul_init(0, 0);
    3737    if(!qq)
    3838        return 1;
  • libcaca/trunk/test/unicode.c

    r646 r665  
    3030    caca_t *kk;
    3131
    32     qq = cucul_init();
     32    qq = cucul_init(0, 0);
    3333    kk = caca_attach(qq);
    3434
Note: See TracChangeset for help on using the changeset viewer.