You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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