Changeset 1341 for libcaca/trunk


Ignore:
Timestamp:
Nov 11, 2006, 2:29:03 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • Cosmetic code and documentation changes here and there.
  • Updated TODO.
Location:
libcaca/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/TODO

    r1284 r1341  
    66
    77  - allow to change the canvas size in a per-frame basis.
    8   - allow to import data in feed mode
    9   - cucul_getchar -> cucul_get_char?
    10   - maybe switch back to utf32 arguments for box, ellipse etc.
    118  - export attribute parsing functions such as attr_to_ansi4fg etc.
     9  - add cursor support in the canvas, so that we can load ANSI files
     10    in stream mode.
    1211
    1312  \subsection indep API-independent stuff
  • libcaca/trunk/cucul/canvas.c

    r1338 r1341  
    349349 *
    350350 *  Set new boundaries for a canvas. This function can be used to crop a
    351  *  canvas, to expand it or for combinations of both actions.
     351 *  canvas, to expand it or for combinations of both actions. All frames
     352 *  are affected by this function.
    352353 *
    353354 *  If an error occurs, -1 is returned and \b errno is set accordingly:
  • libcaca/trunk/cucul/frame.c

    r1339 r1341  
    8282/** \brief Add a frame to a canvas.
    8383 *
    84  *  Create a new frame within the given canvas. Its contents are copied
    85  *  from the currently active frame.
     84 *  Create a new frame within the given canvas. Its contents and attributes
     85 *  are copied from the currently active frame.
    8686 *
    8787 *  The frame index indicates where the frame should be inserted. Valid
     
    100100 *  \return 0 in case of success, -1 if an error occurred.
    101101 */
    102 int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int frame)
    103 {
    104     unsigned int size = cv->width * cv->height * sizeof(uint32_t);
     102int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int id)
     103{
     104    unsigned int size = cv->width * cv->height;
    105105    unsigned int f;
    106106
    107     if(frame > cv->framecount)
    108         frame = cv->framecount;
     107    if(id > cv->framecount)
     108        id = cv->framecount;
    109109
    110110    cv->framecount++;
     
    112112                         sizeof(struct cucul_frame) * cv->framecount);
    113113
    114     for(f = cv->framecount - 1; f > frame; f--)
     114    for(f = cv->framecount - 1; f > id; f--)
    115115        cv->frames[f] = cv->frames[f - 1];
    116116
    117     cv->frames[frame].width = cv->width;
    118     cv->frames[frame].height = cv->height;
    119     cv->frames[frame].chars = malloc(size);
    120     memcpy(cv->frames[frame].chars, cv->chars, size);
    121     cv->frames[frame].attrs = malloc(size);
    122     memcpy(cv->frames[frame].attrs, cv->attrs, size);
    123     cv->frames[frame].curattr = cv->curattr;
    124 
    125     if(cv->frame >= frame)
     117    cv->frames[id].width = cv->width;
     118    cv->frames[id].height = cv->height;
     119    cv->frames[id].chars = malloc(size * sizeof(uint32_t));
     120    memcpy(cv->frames[id].chars, cv->chars, size * sizeof(uint32_t));
     121    cv->frames[id].attrs = malloc(size * sizeof(uint32_t));
     122    memcpy(cv->frames[id].attrs, cv->attrs, size * sizeof(uint32_t));
     123    cv->frames[id].curattr = cv->curattr;
     124
     125    if(cv->frame >= id)
    126126        cv->frame++;
    127127
     
    150150 *  \return 0 in case of success, -1 if an error occurred.
    151151 */
    152 int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int frame)
     152int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id)
    153153{
    154154    unsigned int f;
    155155
    156     if(frame >= cv->framecount)
     156    if(id >= cv->framecount)
    157157    {
    158158#if defined(HAVE_ERRNO_H)
     
    170170    }
    171171
    172     free(cv->frames[frame].chars);
    173     free(cv->frames[frame].attrs);
    174 
    175     for(f = frame + 1; f < cv->framecount; f++)
     172    free(cv->frames[id].chars);
     173    free(cv->frames[id].attrs);
     174
     175    for(f = id + 1; f < cv->framecount; f++)
    176176        cv->frames[f - 1] = cv->frames[f];
    177177
     
    180180                         sizeof(struct cucul_frame) * cv->framecount);
    181181
    182     if(cv->frame > frame)
     182    if(cv->frame > id)
    183183        cv->frame--;
    184     else if(cv->frame == frame)
     184    else if(cv->frame == id)
    185185    {
    186186        cv->frame = 0;
Note: See TracChangeset for help on using the changeset viewer.