瀏覽代碼

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

to be ignored.
tags/v0.99.beta14
Sam Hocevar sam 18 年之前
父節點
當前提交
46b84c8c02
共有 3 個文件被更改,包括 16 次插入18 次删除
  1. +7
    -10
      cucul/cucul.c
  2. +4
    -0
      cucul/cucul_internals.h
  3. +5
    -8
      cucul/frame.c

+ 7
- 10
cucul/cucul.c 查看文件

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

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->framecount = 1;
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].x = cv->frames[0].y = 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)
{
@@ -234,6 +230,8 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
old_height = cv->height;
old_size = old_width * old_height;

_cucul_save_frame_info(cv);

cv->width = width;
cv->height = 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 */
cv->chars = cv->frames[cv->frame].chars;
cv->attrs = cv->frames[cv->frame].attrs;
_cucul_load_frame_info(cv);

return 0;
}


+ 4
- 0
cucul/cucul_internals.h 查看文件

@@ -65,4 +65,8 @@ extern uint32_t _cucul_attr_to_rgb24fg(uint32_t);
extern uint32_t _cucul_attr_to_rgb24bg(uint32_t);
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__ */

+ 5
- 8
cucul/frame.c 查看文件

@@ -27,9 +27,6 @@
#include "cucul.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.
*
* Return the current canvas' frame count.
@@ -67,9 +64,9 @@ int cucul_set_canvas_frame(cucul_canvas_t *cv, unsigned int frame)
return -1;
}

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

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

return 0;
@@ -190,7 +187,7 @@ int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id)
* 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].height = cv->height;
@@ -198,7 +195,7 @@ static void save_frame_info(cucul_canvas_t *cv)
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->height = cv->frames[cv->frame].height;


Loading…
取消
儲存