No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

242 líneas
5.6 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #ifndef __CACA_INTERNALS_H__
  15. #define __CACA_INTERNALS_H__
  16. #include "caca_stubs.h"
  17. typedef struct caca_timer caca_timer_t;
  18. typedef struct caca_privevent caca_privevent_t;
  19. typedef struct caca_figfont caca_figfont_t;
  20. #if !defined(_DOXYGEN_SKIP_ME)
  21. # define EVENTBUF_LEN 10
  22. #endif
  23. struct caca_frame
  24. {
  25. /* Frame size */
  26. int width, height;
  27. /* Cell information */
  28. uint32_t *chars;
  29. uint32_t *attrs;
  30. /* Painting context */
  31. int x, y;
  32. int handlex, handley;
  33. uint32_t curattr;
  34. /* Frame name */
  35. char *name;
  36. };
  37. struct caca_canvas
  38. {
  39. /* XXX: look at caca_set_canvas_boundaries() before adding anything
  40. * to this structure. The function is quite hacky. */
  41. /* Frame information */
  42. int frame, framecount;
  43. struct caca_frame *frames;
  44. /* Canvas management */
  45. int refcount;
  46. int autoinc;
  47. int (*resize_callback)(void *);
  48. void *resize_data;
  49. /* Dirty rectangles */
  50. int ndirty;
  51. int dirty_xmin, dirty_xmax, dirty_ymin, dirty_ymax;
  52. /* Shortcut to the active frame information */
  53. int width, height;
  54. uint32_t *chars;
  55. uint32_t *attrs;
  56. uint32_t curattr;
  57. /* FIGfont management */
  58. caca_figfont_t *ff;
  59. };
  60. /* Graphics driver */
  61. enum caca_driver
  62. {
  63. CACA_DRIVER_NONE = 0,
  64. CACA_DRIVER_RAW = 1,
  65. #if defined(USE_COCOA)
  66. CACA_DRIVER_COCOA = 2,
  67. #endif
  68. #if defined(USE_CONIO)
  69. CACA_DRIVER_CONIO = 3,
  70. #endif
  71. #if defined(USE_GL)
  72. CACA_DRIVER_GL = 4,
  73. #endif
  74. #if defined(USE_NCURSES)
  75. CACA_DRIVER_NCURSES = 5,
  76. #endif
  77. #if defined(USE_SLANG)
  78. CACA_DRIVER_SLANG = 6,
  79. #endif
  80. #if defined(USE_VGA)
  81. CACA_DRIVER_VGA = 7,
  82. #endif
  83. #if defined(USE_WIN32)
  84. CACA_DRIVER_WIN32 = 8,
  85. #endif
  86. #if defined(USE_X11)
  87. CACA_DRIVER_X11 = 9,
  88. #endif
  89. };
  90. /* Available external drivers */
  91. #if defined(USE_COCOA)
  92. int cocoa_install(caca_display_t *);
  93. #endif
  94. #if defined(USE_CONIO)
  95. int conio_install(caca_display_t *);
  96. #endif
  97. #if defined(USE_GL)
  98. int gl_install(caca_display_t *);
  99. #endif
  100. #if defined(USE_NCURSES)
  101. int ncurses_install(caca_display_t *);
  102. #endif
  103. int raw_install(caca_display_t *);
  104. #if defined(USE_SLANG)
  105. int slang_install(caca_display_t *);
  106. #endif
  107. #if defined(USE_VGA)
  108. int vga_install(caca_display_t *);
  109. #endif
  110. #if defined(USE_WIN32)
  111. int win32_install(caca_display_t *);
  112. #endif
  113. #if defined(USE_X11)
  114. int x11_install(caca_display_t *);
  115. #endif
  116. /* Timer structure */
  117. struct caca_timer
  118. {
  119. int last_sec, last_usec;
  120. };
  121. /* Private event structure */
  122. struct caca_privevent
  123. {
  124. enum caca_event_type type;
  125. union
  126. {
  127. struct { int x, y, button; } mouse;
  128. struct { int w, h; } resize;
  129. struct { int ch; uint32_t utf32; char utf8[8]; } key;
  130. } data;
  131. };
  132. /* Internal caca display context */
  133. struct caca_display
  134. {
  135. /* A link to our caca canvas */
  136. caca_canvas_t *cv;
  137. int autorelease;
  138. #if defined(USE_PLUGINS)
  139. void *plugin;
  140. #endif
  141. /* Device-specific functions */
  142. struct drv
  143. {
  144. char const * driver;
  145. enum caca_driver id;
  146. struct driver_private *p;
  147. int (* init_graphics) (caca_display_t *);
  148. int (* end_graphics) (caca_display_t *);
  149. int (* set_display_title) (caca_display_t *, char const *);
  150. int (* get_display_width) (caca_display_t const *);
  151. int (* get_display_height) (caca_display_t const *);
  152. void (* display) (caca_display_t *);
  153. void (* handle_resize) (caca_display_t *);
  154. int (* get_event) (caca_display_t *, caca_privevent_t *);
  155. void (* set_mouse) (caca_display_t *, int);
  156. void (* set_cursor) (caca_display_t *, int);
  157. } drv;
  158. /* Mouse position */
  159. struct mouse
  160. {
  161. int x, y;
  162. } mouse;
  163. /* Window resize handling */
  164. struct resize
  165. {
  166. int resized; /* A resize event was requested */
  167. int allow; /* The display driver allows resizing */
  168. int w, h; /* Requested width and height */
  169. } resize;
  170. /* Framerate handling */
  171. int delay, rendertime;
  172. caca_timer_t timer;
  173. int lastticks;
  174. struct events
  175. {
  176. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  177. caca_privevent_t buf[EVENTBUF_LEN];
  178. int queue;
  179. #endif
  180. #if defined(USE_SLANG) || defined(USE_NCURSES)
  181. caca_timer_t key_timer;
  182. int last_key_ticks;
  183. int autorepeat_ticks;
  184. caca_privevent_t last_key_event;
  185. #endif
  186. #if defined(USE_WIN32)
  187. uint8_t not_empty_struct;
  188. #endif
  189. } events;
  190. };
  191. /* Colour functions */
  192. extern uint32_t _caca_attr_to_rgb24fg(uint32_t);
  193. extern uint32_t _caca_attr_to_rgb24bg(uint32_t);
  194. /* Frames functions */
  195. extern void _caca_save_frame_info(caca_canvas_t *);
  196. extern void _caca_load_frame_info(caca_canvas_t *);
  197. /* Internal timer functions */
  198. extern void _caca_sleep(int);
  199. extern int _caca_getticks(caca_timer_t *);
  200. /* Internal event functions */
  201. extern void _caca_handle_resize(caca_display_t *);
  202. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  203. extern void _push_event(caca_display_t *, caca_privevent_t *);
  204. extern int _pop_event(caca_display_t *, caca_privevent_t *);
  205. #endif
  206. /* Internal window functions */
  207. extern void _caca_set_term_title(char const *);
  208. #endif /* __CACA_INTERNALS_H__ */