Changeset 1390 for libcaca/trunk/cucul/frame.c
- Timestamp:
- Nov 14, 2006, 12:16:35 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/frame.c
r1381 r1390 37 37 * \return The frame count 38 38 */ 39 unsigned int cucul_get_ canvas_frame_count(cucul_canvas_t *cv)39 unsigned int cucul_get_frame_count(cucul_canvas_t *cv) 40 40 { 41 41 return cv->framecount; … … 54 54 * 55 55 * \param cv A libcucul canvas 56 * \param frameThe canvas frame to activate57 * \return 0 in case of success, -1 if an error occurred. 58 */ 59 int cucul_set_ canvas_frame(cucul_canvas_t *cv, unsigned int frame)60 { 61 if( frame>= cv->framecount)56 * \param id The canvas frame to activate 57 * \return 0 in case of success, -1 if an error occurred. 58 */ 59 int cucul_set_frame(cucul_canvas_t *cv, unsigned int id) 60 { 61 if(id >= cv->framecount) 62 62 { 63 63 seterrno(EINVAL); … … 66 66 67 67 _cucul_save_frame_info(cv); 68 cv->frame = frame;68 cv->frame = id; 69 69 _cucul_load_frame_info(cv); 70 71 return 0; 72 } 73 74 /** \brief Get the current frame's name. 75 * 76 * Return the current frame's name. The returned string is valid until 77 * the frame is deleted or cucul_set_frame_name() is called to change 78 * the frame name again. 79 * 80 * This function never fails. 81 * 82 * \param cv A libcucul canvas. 83 * \return The current frame's name. 84 */ 85 char const *cucul_get_frame_name(cucul_canvas_t *cv) 86 { 87 return cv->frames[cv->frame].name; 88 } 89 90 /** \brief Set the current frame's name. 91 * 92 * Set the current frame's name. Upon creation, a frame has a default name 93 * of \rc "frame#xxxxxxxx" where \c xxxxxxxx is a self-incrementing 94 * hexadecimal number. 95 * 96 * If an error occurs, -1 is returned and \b errno is set accordingly: 97 * - \c ENOMEM Not enough memory to allocate new frame. 98 * 99 * \param cv A libcucul canvas. 100 * \return 0 in case of success, -1 if an error occurred. 101 */ 102 int cucul_set_frame_name(cucul_canvas_t *cv, char const *name) 103 { 104 char *newname = strdup(name); 105 106 if(!newname) 107 { 108 seterrno(ENOMEM); 109 return -1; 110 } 111 112 free(cv->frames[cv->frame].name); 113 cv->frames[cv->frame].name = newname; 70 114 71 115 return 0; … … 92 136 * \return 0 in case of success, -1 if an error occurred. 93 137 */ 94 int cucul_create_ canvas_frame(cucul_canvas_t *cv, unsigned int id)138 int cucul_create_frame(cucul_canvas_t *cv, unsigned int id) 95 139 { 96 140 unsigned int size = cv->width * cv->height; … … 123 167 cv->frames[id].handley = cv->frames[cv->frame].handley; 124 168 169 cv->frames[id].name = strdup("frame#--------"); 170 sprintf(cv->frames[id].name + 6, "%.08x", cv->autoinc++); 171 125 172 return 0; 126 173 } … … 147 194 * \return 0 in case of success, -1 if an error occurred. 148 195 */ 149 int cucul_free_ canvas_frame(cucul_canvas_t *cv, unsigned int id)196 int cucul_free_frame(cucul_canvas_t *cv, unsigned int id) 150 197 { 151 198 unsigned int f; … … 165 212 free(cv->frames[id].chars); 166 213 free(cv->frames[id].attrs); 214 free(cv->frames[id].name); 167 215 168 216 for(f = id + 1; f < cv->framecount; f++)
Note: See TracChangeset
for help on using the changeset viewer.