From 21bfa6210dac5c32050407eb2fe9cd13bec5cec1 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 11 Nov 2006 13:29:03 +0000 Subject: [PATCH] * Cosmetic code and documentation changes here and there. * Updated TODO. --- TODO | 5 ++--- cucul/canvas.c | 3 ++- cucul/frame.c | 44 ++++++++++++++++++++++---------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index e950961..c7ed7cf 100644 --- a/TODO +++ b/TODO @@ -5,10 +5,9 @@ \subsection dep API-dependent stuff - allow to change the canvas size in a per-frame basis. - - allow to import data in feed mode - - cucul_getchar -> cucul_get_char? - - maybe switch back to utf32 arguments for box, ellipse etc. - export attribute parsing functions such as attr_to_ansi4fg etc. + - add cursor support in the canvas, so that we can load ANSI files + in stream mode. \subsection indep API-independent stuff diff --git a/cucul/canvas.c b/cucul/canvas.c index bc8b4c8..7a5ad3c 100644 --- a/cucul/canvas.c +++ b/cucul/canvas.c @@ -348,7 +348,8 @@ int cucul_blit(cucul_canvas_t *dst, int x, int y, /** \brief Set a canvas' new boundaries. * * Set new boundaries for a canvas. This function can be used to crop a - * canvas, to expand it or for combinations of both actions. + * canvas, to expand it or for combinations of both actions. All frames + * are affected by this function. * * If an error occurs, -1 is returned and \b errno is set accordingly: * - \c EBUSY The canvas is in use by a display driver and cannot be resized. diff --git a/cucul/frame.c b/cucul/frame.c index f9a0c64..2148fb7 100644 --- a/cucul/frame.c +++ b/cucul/frame.c @@ -81,8 +81,8 @@ int cucul_set_canvas_frame(cucul_canvas_t *cv, unsigned int frame) /** \brief Add a frame to a canvas. * - * Create a new frame within the given canvas. Its contents are copied - * from the currently active frame. + * Create a new frame within the given canvas. Its contents and attributes + * are copied from the currently active frame. * * The frame index indicates where the frame should be inserted. Valid * values range from 0 to the current canvas frame count. If the frame @@ -99,30 +99,30 @@ int cucul_set_canvas_frame(cucul_canvas_t *cv, unsigned int frame) * \param frame The index where to insert the new frame * \return 0 in case of success, -1 if an error occurred. */ -int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int frame) +int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int id) { - unsigned int size = cv->width * cv->height * sizeof(uint32_t); + unsigned int size = cv->width * cv->height; unsigned int f; - if(frame > cv->framecount) - frame = cv->framecount; + if(id > cv->framecount) + id = cv->framecount; cv->framecount++; cv->frames = realloc(cv->frames, sizeof(struct cucul_frame) * cv->framecount); - for(f = cv->framecount - 1; f > frame; f--) + for(f = cv->framecount - 1; f > id; f--) cv->frames[f] = cv->frames[f - 1]; - cv->frames[frame].width = cv->width; - cv->frames[frame].height = cv->height; - cv->frames[frame].chars = malloc(size); - memcpy(cv->frames[frame].chars, cv->chars, size); - cv->frames[frame].attrs = malloc(size); - memcpy(cv->frames[frame].attrs, cv->attrs, size); - cv->frames[frame].curattr = cv->curattr; + cv->frames[id].width = cv->width; + cv->frames[id].height = cv->height; + cv->frames[id].chars = malloc(size * sizeof(uint32_t)); + memcpy(cv->frames[id].chars, cv->chars, size * sizeof(uint32_t)); + cv->frames[id].attrs = malloc(size * sizeof(uint32_t)); + memcpy(cv->frames[id].attrs, cv->attrs, size * sizeof(uint32_t)); + cv->frames[id].curattr = cv->curattr; - if(cv->frame >= frame) + if(cv->frame >= id) cv->frame++; return 0; @@ -149,11 +149,11 @@ int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int frame) * \param frame The index of the frame to delete * \return 0 in case of success, -1 if an error occurred. */ -int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int frame) +int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id) { unsigned int f; - if(frame >= cv->framecount) + if(id >= cv->framecount) { #if defined(HAVE_ERRNO_H) errno = EINVAL; @@ -169,19 +169,19 @@ int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int frame) return -1; } - free(cv->frames[frame].chars); - free(cv->frames[frame].attrs); + free(cv->frames[id].chars); + free(cv->frames[id].attrs); - for(f = frame + 1; f < cv->framecount; f++) + for(f = id + 1; f < cv->framecount; f++) cv->frames[f - 1] = cv->frames[f]; cv->framecount--; cv->frames = realloc(cv->frames, sizeof(struct cucul_frame) * cv->framecount); - if(cv->frame > frame) + if(cv->frame > id) cv->frame--; - else if(cv->frame == frame) + else if(cv->frame == id) { cv->frame = 0; load_frame_info(cv);