Browse Source

* Changed the cucul_init parameter so that it now directly accepts a

canvas size (use cucul_init(0, 0) for the old behaviour).
tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
c979bc6eae
16 changed files with 36 additions and 25 deletions
  1. +21
    -10
      cucul/cucul.c
  2. +1
    -1
      cucul/cucul.h
  3. +1
    -1
      src/aafire.c
  4. +1
    -1
      src/cacaball.c
  5. +1
    -1
      src/cacamoir.c
  6. +1
    -1
      src/cacaplas.c
  7. +1
    -1
      src/cacaview.c
  8. +1
    -1
      test/colors.c
  9. +1
    -1
      test/demo.c
  10. +1
    -1
      test/dithering.c
  11. +1
    -1
      test/event.c
  12. +1
    -1
      test/export.c
  13. +1
    -1
      test/gamma.c
  14. +1
    -1
      test/hsv.c
  15. +1
    -1
      test/spritedit.c
  16. +1
    -1
      test/unicode.c

+ 21
- 10
cucul/cucul.c View File

@@ -37,9 +37,14 @@ static void cucul_read_environment(cucul_t *);
* first \e libcucul function to be called in a function. cucul_end() should
* be called at the end of the program to free all allocated resources.
*
* If one of the desired canvas coordinates is zero, a default canvas size
* of 80x32 is used instead.
*
* \param width The desired canvas width
* \param height The desired canvas height
* \return 0 upon success, a non-zero value if an error occurs.
*/
cucul_t * cucul_init(void)
cucul_t * cucul_init(unsigned int width, unsigned int height)
{
cucul_t *qq = malloc(sizeof(cucul_t));

@@ -48,14 +53,18 @@ cucul_t * cucul_init(void)
qq->fgcolor = CUCUL_COLOR_LIGHTGRAY;
qq->bgcolor = CUCUL_COLOR_BLACK;

/* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
* default X11 window. When a graphic driver attaches to us, it can set
* a different size. */
qq->width = qq->width = 0;
qq->chars = NULL;
qq->attr = NULL;
qq->empty_line = qq->scratch_line = NULL;
_cucul_set_size(qq, 80, 32);

/* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
* default X11 window. When a graphic driver attaches to us, it can set
* a different size. */
if(width && height)
_cucul_set_size(qq, width, height);
else
_cucul_set_size(qq, 80, 32);

if(_cucul_init_bitmap())
{
@@ -70,14 +79,16 @@ cucul_t * cucul_init(void)
*
* This function sets the canvas width and height, in character cells.
*
* The contents of the canvas are preserved to the extent of the new
* canvas size. Newly allocated character cells at the right and/or at
* the bottom of the canvas are filled with spaces.
*
* It is an error to try to resize the canvas if an output driver has
* been attached to the canvas using caca_attach(). You need to remove
* the output driver using caca_detach() before you can change the
* canvas size again.
*
* However, the caca output driver can cause a canvas resize through
* user interaction. See the caca_event() documentation for more about
* this.
* canvas size again. However, the caca output driver can cause a canvas
* resize through user interaction. See the caca_event() documentation
* for more about this.
*
* \param width The desired canvas width
* \param height The desired canvas height


+ 1
- 1
cucul/cucul.h View File

@@ -118,7 +118,7 @@ typedef struct cucul_context cucul_t;
* initialisation, system information retrieval and configuration.
*
* @{ */
cucul_t * cucul_init(void);
cucul_t * cucul_init(unsigned int, unsigned int);
void cucul_set_size(cucul_t *, unsigned int, unsigned int);
unsigned int cucul_get_width(cucul_t *);
unsigned int cucul_get_height(cucul_t *);


+ 1
- 1
src/aafire.c View File

@@ -100,7 +100,7 @@ initialize (void)
#endif

#ifdef LIBCACA
qq = cucul_init();
qq = cucul_init(80, 32);
if (!qq)
{
printf ("Failed to initialize libcucul\n");


+ 1
- 1
src/cacaball.c View File

@@ -53,7 +53,7 @@ int main(int argc, char **argv)
double frameOffset40[360];
double frameOffset80[360];

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
src/cacamoir.c View File

@@ -42,7 +42,7 @@ int main (int argc, char **argv)
struct cucul_bitmap *bitmap;
int i, x, y, frame = 0, pause = 0;

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
src/cacaplas.c View File

@@ -45,7 +45,7 @@ int main (int argc, char **argv)
struct cucul_bitmap *bitmap;
int i, x, y, frame = 0, pause = 0;

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
src/cacaview.c View File

@@ -88,7 +88,7 @@ int main(int argc, char **argv)
int i;

/* Initialise libcucul */
qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
{
fprintf(stderr, "%s: unable to initialise libcucul\n", argv[0]);


+ 1
- 1
test/colors.c View File

@@ -26,7 +26,7 @@ int main(int argc, char **argv)
caca_t *kk;
int i, j;

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;



+ 1
- 1
test/demo.c View File

@@ -45,7 +45,7 @@ int main(int argc, char **argv)
void (*demo)(void) = NULL;
int quit = 0;

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
test/dithering.c View File

@@ -39,7 +39,7 @@ int main(void)
int neara, dista, nearb, distb, dist;
int x, y;

qq = cucul_init();
qq = cucul_init(0, 0);
kk = caca_attach(qq);

for(x = 0; x < 100; x++)


+ 1
- 1
test/event.c View File

@@ -30,7 +30,7 @@ int main(int argc, char **argv)
int *events;
int i, h, quit;

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
test/export.c View File

@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
exit(-1);
}

qq = cucul_init();
qq = cucul_init(0, 0);
cucul_set_size(qq, WIDTH, HEIGHT);

for(y = 0; y < 256; y++)


+ 1
- 1
test/gamma.c View File

@@ -34,7 +34,7 @@ int main(void)
struct cucul_bitmap *left, *right;
int x;

qq = cucul_init();
qq = cucul_init(0, 0);
kk = caca_attach(qq);

for(x = 0; x < 256; x++)


+ 1
- 1
test/hsv.c View File

@@ -34,7 +34,7 @@ int main(void)
struct cucul_bitmap *bitmap;
int x, y;

qq = cucul_init();
qq = cucul_init(0, 0);
kk = caca_attach(qq);

for(y = 0; y < 256; y++)


+ 1
- 1
test/spritedit.c View File

@@ -33,7 +33,7 @@ int main(int argc, char **argv)
return 1;
}

qq = cucul_init();
qq = cucul_init(0, 0);
if(!qq)
return 1;
kk = caca_attach(qq);


+ 1
- 1
test/unicode.c View File

@@ -29,7 +29,7 @@ int main(void)
cucul_t *qq;
caca_t *kk;

qq = cucul_init();
qq = cucul_init(0, 0);
kk = caca_attach(qq);

cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);


Loading…
Cancel
Save