- Timestamp:
- Nov 11, 2006, 3:24:35 PM (16 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/TODO
r1341 r1342 7 7 - allow to change the canvas size in a per-frame basis. 8 8 - export attribute parsing functions such as attr_to_ansi4fg etc. 9 - add cursor support in the canvas, so that we can load ANSI files10 in stream mode.11 9 12 10 \subsection indep API-independent stuff -
libcaca/trunk/cucul/canvas.c
r1341 r1342 42 42 #include "cucul_internals.h" 43 43 44 /** \brief Set cursor position. 45 * 46 * Put the cursor at the given coordinates. Functions making use of the 47 * cursor will use the new values. Setting the cursor position outside the 48 * canvas is legal but the cursor will not be shown. 49 * 50 * This function never fails. 51 * 52 * \param cv A handle to the libcucul canvas. 53 * \param x X cursor coordinate. 54 * \param y Y cursor coordinate. 55 * \return This function always returns 0. 56 */ 57 int cucul_gotoxy(cucul_canvas_t *cv, int x, int y) 58 { 59 cv->frames[cv->frame].x = x; 60 cv->frames[cv->frame].y = y; 61 62 return 0; 63 } 64 65 /** \brief Get X cursor position. 66 * 67 * Retrieve the X coordinate of the cursor's position. 68 * 69 * This function never fails. 70 * 71 * \param cv A handle to the libcucul canvas. 72 * \return The cursor's X coordinate. 73 */ 74 int cucul_get_cursor_x(cucul_canvas_t *cv) 75 { 76 return cv->frames[cv->frame].x; 77 } 78 79 /** \brief Get Y cursor position. 80 * 81 * Retrieve the Y coordinate of the cursor's position. 82 * 83 * This function never fails. 84 * 85 * \param cv A handle to the libcucul canvas. 86 * \return The cursor's Y coordinate. 87 */ 88 int cucul_get_cursor_y(cucul_canvas_t *cv) 89 { 90 return cv->frames[cv->frame].y; 91 } 92 44 93 /** \brief Print an ASCII or Unicode character. 45 94 * … … 263 312 264 313 return 0; 314 } 315 316 /** \brief Set cursor handle. 317 * 318 * Set the canvas' handle. Blitting functions will use the handle value 319 * to put the canvas at the proper coordinates. 320 * 321 * This function never fails. 322 * 323 * \param cv A handle to the libcucul canvas. 324 * \param x X handle coordinate. 325 * \param y Y handle coordinate. 326 * \return This function always returns 0. 327 */ 328 int cucul_set_canvas_handle(cucul_canvas_t *cv, int x, int y) 329 { 330 cv->frames[cv->frame].handlex = x; 331 cv->frames[cv->frame].handley = y; 332 333 return 0; 334 } 335 336 /** \brief Get X handle position. 337 * 338 * Retrieve the X coordinate of the canvas' handle. 339 * 340 * This function never fails. 341 * 342 * \param cv A handle to the libcucul canvas. 343 * \return The canvas' handle's X coordinate. 344 */ 345 int cucul_get_canvas_handle_x(cucul_canvas_t *cv) 346 { 347 return cv->frames[cv->frame].handlex; 348 } 349 350 /** \brief Get Y handle position. 351 * 352 * Retrieve the Y coordinate of the canvas' handle. 353 * 354 * This function never fails. 355 * 356 * \param cv A handle to the libcucul canvas. 357 * \return The canvas' handle's Y coordinate. 358 */ 359 int cucul_get_canvas_handle_y(cucul_canvas_t *cv) 360 { 361 return cv->frames[cv->frame].handley; 265 362 } 266 363 -
libcaca/trunk/cucul/cucul.c
r1338 r1342 44 44 * should be called at the end of the program to free all allocated resources. 45 45 * 46 * Both the cursor and the canvas' handle are initialised at the top-left 47 * corner. 48 * 46 49 * If an error occurs, NULL is returned and \b errno is set accordingly: 47 50 * - \c ENOMEM Not enough memory for the requested canvas size. … … 79 82 cv->frames[0].chars = NULL; 80 83 cv->frames[0].attrs = NULL; 84 cv->frames[0].x = cv->frames[0].y = 0; 85 cv->frames[0].handlex = cv->frames[0].handley = 0; 81 86 cv->frames[0].curattr = cv->curattr; 82 87 -
libcaca/trunk/cucul/cucul.h
r1333 r1342 90 90 * @{ */ 91 91 #define CUCUL_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */ 92 int cucul_gotoxy(cucul_canvas_t *, int, int); 93 int cucul_get_cursor_x(cucul_canvas_t *); 94 int cucul_get_cursor_y(cucul_canvas_t *); 92 95 unsigned long int cucul_get_attr(cucul_canvas_t *, int, int); 93 96 int cucul_set_attr(cucul_canvas_t *, unsigned long int); … … 100 103 int cucul_printf(cucul_canvas_t *, int, int, char const *, ...); 101 104 int cucul_clear_canvas(cucul_canvas_t *); 105 int cucul_set_canvas_handle(cucul_canvas_t *, int, int); 106 int cucul_get_canvas_handle_x(cucul_canvas_t *); 107 int cucul_get_canvas_handle_y(cucul_canvas_t *); 102 108 int cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, 103 109 cucul_canvas_t const *); -
libcaca/trunk/cucul/cucul_internals.h
r1338 r1342 29 29 30 30 /* Painting context */ 31 int x, y; 32 int handlex, handley; 31 33 uint32_t curattr; 32 34 }; -
libcaca/trunk/cucul/export.c
r1332 r1342 172 172 * - 24 bytes for the frame info 173 173 * 8 bytes for each character cell */ 174 *bytes = 44+ 8 * cv->width * cv->height;174 *bytes = 52 + 8 * cv->width * cv->height; 175 175 cur = data = malloc(*bytes); 176 176 … … 179 179 180 180 /* canvas_header */ 181 cur += sprintu32(cur, 16 + 24);181 cur += sprintu32(cur, 16 + 32 * 1); 182 182 cur += sprintu32(cur, cv->width * cv->height * 8); 183 183 cur += sprintu16(cur, 0x0001); … … 190 190 cur += sprintu32(cur, 0); 191 191 cur += sprintu32(cur, cv->curattr); 192 cur += sprintu32(cur, 0); 193 cur += sprintu32(cur, 0); 192 cur += sprintu32(cur, cv->frames[0].x); 193 cur += sprintu32(cur, cv->frames[0].y); 194 cur += sprintu32(cur, cv->frames[0].handlex); 195 cur += sprintu32(cur, cv->frames[0].handley); 194 196 195 197 /* canvas_data */ … … 237 239 * // not specify a duration 238 240 * uint32_t attr; // Graphics context attribute 241 * int32_t cursor_x; // Cursor X coordinate 242 * int32_t cursor_y; // Cursor Y coordinate 239 243 * int32_t handle_x; // Handle X coordinate 240 244 * int32_t handle_y; // Handle Y coordinate -
libcaca/trunk/cucul/frame.c
r1341 r1342 115 115 cv->frames[f] = cv->frames[f - 1]; 116 116 117 if(cv->frame >= id) 118 cv->frame++; 119 117 120 cv->frames[id].width = cv->width; 118 121 cv->frames[id].height = cv->height; … … 123 126 cv->frames[id].curattr = cv->curattr; 124 127 125 if(cv->frame >= id) 126 cv->frame++; 128 cv->frames[id].x = cv->frames[cv->frame].x; 129 cv->frames[id].y = cv->frames[cv->frame].y; 130 cv->frames[id].handlex = cv->frames[cv->frame].handlex; 131 cv->frames[id].handley = cv->frames[cv->frame].handley; 127 132 128 133 return 0; -
libcaca/trunk/cucul/import.c
r1314 r1342 248 248 return 0; 249 249 250 if(control_size < 16 + frames * 24)250 if(control_size < 16 + frames * 32) 251 251 goto invalid_caca; 252 252 … … 255 255 unsigned int width, height, duration; 256 256 uint32_t attr; 257 int x, y ;257 int x, y, handlex, handley; 258 258 259 259 width = sscanu32(buf + 4 + 16 + f * 24); … … 263 263 x = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 16); 264 264 y = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 20); 265 handlex = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 24); 266 handley = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 28); 265 267 266 268 expected_size += width * height * 8; … … 284 286 285 287 cv->curattr = sscanu32(buf + 4 + 16 + 12); 288 cv->frames[0].x = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 16); 289 cv->frames[0].y = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 20); 290 cv->frames[0].handlex = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 24); 291 cv->frames[0].handley = (int32_t)sscanu32(buf + 4 + 16 + f * 24 + 28); 286 292 287 293 return 4 + control_size + data_size;
Note: See TracChangeset
for help on using the changeset viewer.