Browse Source

* Fix a bug in cucul_set_canvas_size() that caused the default attribute

to be ignored.
tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
46b84c8c02
3 changed files with 16 additions and 18 deletions
  1. +7
    -10
      cucul/cucul.c
  2. +4
    -0
      cucul/cucul_internals.h
  3. +5
    -8
      cucul/frame.c

+ 7
- 10
cucul/cucul.c View File

@@ -59,13 +59,6 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)


cv->refcount = 0; cv->refcount = 0;


cv->curattr = 0x00000000;
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);

cv->width = cv->height = 0;
cv->chars = NULL;
cv->attrs = NULL;

cv->frame = 0; cv->frame = 0;
cv->framecount = 1; cv->framecount = 1;
cv->frames = malloc(sizeof(struct cucul_frame)); cv->frames = malloc(sizeof(struct cucul_frame));
@@ -80,7 +73,10 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
cv->frames[0].attrs = NULL; cv->frames[0].attrs = NULL;
cv->frames[0].x = cv->frames[0].y = 0; cv->frames[0].x = cv->frames[0].y = 0;
cv->frames[0].handlex = cv->frames[0].handley = 0; cv->frames[0].handlex = cv->frames[0].handley = 0;
cv->frames[0].curattr = cv->curattr;
cv->frames[0].curattr = 0;

_cucul_load_frame_info(cv);
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);


if(_cucul_set_canvas_size(cv, width, height) < 0) if(_cucul_set_canvas_size(cv, width, height) < 0)
{ {
@@ -234,6 +230,8 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
old_height = cv->height; old_height = cv->height;
old_size = old_width * old_height; old_size = old_width * old_height;


_cucul_save_frame_info(cv);

cv->width = width; cv->width = width;
cv->height = height; cv->height = height;
new_size = width * height; new_size = width * height;
@@ -355,8 +353,7 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
} }


/* Reset the current frame shortcuts */ /* Reset the current frame shortcuts */
cv->chars = cv->frames[cv->frame].chars;
cv->attrs = cv->frames[cv->frame].attrs;
_cucul_load_frame_info(cv);


return 0; return 0;
} }


+ 4
- 0
cucul/cucul_internals.h View File

@@ -65,4 +65,8 @@ extern uint32_t _cucul_attr_to_rgb24fg(uint32_t);
extern uint32_t _cucul_attr_to_rgb24bg(uint32_t); extern uint32_t _cucul_attr_to_rgb24bg(uint32_t);
extern void _cucul_attr_to_argb4(uint32_t, uint8_t[8]); extern void _cucul_attr_to_argb4(uint32_t, uint8_t[8]);


/* Frames functions */
extern void _cucul_save_frame_info(cucul_canvas_t *);
extern void _cucul_load_frame_info(cucul_canvas_t *);

#endif /* __CUCUL_INTERNALS_H__ */ #endif /* __CUCUL_INTERNALS_H__ */

+ 5
- 8
cucul/frame.c View File

@@ -27,9 +27,6 @@
#include "cucul.h" #include "cucul.h"
#include "cucul_internals.h" #include "cucul_internals.h"


static void save_frame_info(cucul_canvas_t *);
static void load_frame_info(cucul_canvas_t *);

/** \brief Get the number of frames in a canvas. /** \brief Get the number of frames in a canvas.
* *
* Return the current canvas' frame count. * Return the current canvas' frame count.
@@ -67,9 +64,9 @@ int cucul_set_canvas_frame(cucul_canvas_t *cv, unsigned int frame)
return -1; return -1;
} }


save_frame_info(cv);
_cucul_save_frame_info(cv);
cv->frame = frame; cv->frame = frame;
load_frame_info(cv);
_cucul_load_frame_info(cv);


return 0; return 0;
} }
@@ -180,7 +177,7 @@ int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id)
else if(cv->frame == id) else if(cv->frame == id)
{ {
cv->frame = 0; cv->frame = 0;
load_frame_info(cv);
_cucul_load_frame_info(cv);
} }


return 0; return 0;
@@ -190,7 +187,7 @@ int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id)
* XXX: the following functions are local. * XXX: the following functions are local.
*/ */


static void save_frame_info(cucul_canvas_t *cv)
void _cucul_save_frame_info(cucul_canvas_t *cv)
{ {
cv->frames[cv->frame].width = cv->width; cv->frames[cv->frame].width = cv->width;
cv->frames[cv->frame].height = cv->height; cv->frames[cv->frame].height = cv->height;
@@ -198,7 +195,7 @@ static void save_frame_info(cucul_canvas_t *cv)
cv->frames[cv->frame].curattr = cv->curattr; cv->frames[cv->frame].curattr = cv->curattr;
} }


static void load_frame_info(cucul_canvas_t *cv)
void _cucul_load_frame_info(cucul_canvas_t *cv)
{ {
cv->width = cv->frames[cv->frame].width; cv->width = cv->frames[cv->frame].width;
cv->height = cv->frames[cv->frame].height; cv->height = cv->frames[cv->frame].height;


Loading…
Cancel
Save