Browse Source

* Cosmetic code and documentation changes here and there.

* Updated TODO.
tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
21bfa6210d
3 changed files with 26 additions and 26 deletions
  1. +2
    -3
      TODO
  2. +2
    -1
      cucul/canvas.c
  3. +22
    -22
      cucul/frame.c

+ 2
- 3
TODO View File

@@ -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



+ 2
- 1
cucul/canvas.c View File

@@ -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.


+ 22
- 22
cucul/frame.c View File

@@ -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);


Loading…
Cancel
Save