Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

187 linhas
4.5 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. #if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
  17. # include <inttypes.h>
  18. #endif
  19. typedef struct caca_timer caca_timer_t;
  20. typedef struct caca_privevent caca_privevent_t;
  21. #if !defined(_DOXYGEN_SKIP_ME)
  22. # define EVENTBUF_LEN 10
  23. #endif
  24. /* Graphics driver */
  25. enum caca_driver
  26. {
  27. CACA_DRIVER_NONE = 0,
  28. CACA_DRIVER_RAW = 1,
  29. #if defined(USE_COCOA)
  30. CACA_DRIVER_COCOA = 2,
  31. #endif
  32. #if defined(USE_CONIO)
  33. CACA_DRIVER_CONIO = 3,
  34. #endif
  35. #if defined(USE_GL)
  36. CACA_DRIVER_GL = 4,
  37. #endif
  38. #if defined(USE_NCURSES)
  39. CACA_DRIVER_NCURSES = 5,
  40. #endif
  41. #if defined(USE_SLANG)
  42. CACA_DRIVER_SLANG = 6,
  43. #endif
  44. #if defined(USE_VGA)
  45. CACA_DRIVER_VGA = 7,
  46. #endif
  47. #if defined(USE_WIN32)
  48. CACA_DRIVER_WIN32 = 8,
  49. #endif
  50. #if defined(USE_X11)
  51. CACA_DRIVER_X11 = 9,
  52. #endif
  53. };
  54. /* Available external drivers */
  55. #if defined(USE_COCOA)
  56. int cocoa_install(caca_display_t *);
  57. #endif
  58. #if defined(USE_CONIO)
  59. int conio_install(caca_display_t *);
  60. #endif
  61. #if defined(USE_GL)
  62. int gl_install(caca_display_t *);
  63. #endif
  64. #if defined(USE_NCURSES)
  65. int ncurses_install(caca_display_t *);
  66. #endif
  67. int raw_install(caca_display_t *);
  68. #if defined(USE_SLANG)
  69. int slang_install(caca_display_t *);
  70. #endif
  71. #if defined(USE_VGA)
  72. int vga_install(caca_display_t *);
  73. #endif
  74. #if defined(USE_WIN32)
  75. int win32_install(caca_display_t *);
  76. #endif
  77. #if defined(USE_X11)
  78. int x11_install(caca_display_t *);
  79. #endif
  80. /* Timer structure */
  81. struct caca_timer
  82. {
  83. int last_sec, last_usec;
  84. };
  85. /* Private event structure */
  86. struct caca_privevent
  87. {
  88. enum caca_event_type type;
  89. union
  90. {
  91. struct { unsigned int x, y, button; } mouse;
  92. struct { unsigned int w, h; } resize;
  93. struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
  94. } data;
  95. };
  96. /* Internal caca display context */
  97. struct caca_display
  98. {
  99. /* A link to our cucul canvas */
  100. cucul_canvas_t *cv;
  101. int autorelease;
  102. #if defined(USE_PLUGINS)
  103. void *plugin;
  104. #endif
  105. /* Device-specific functions */
  106. struct drv
  107. {
  108. enum caca_driver driver;
  109. struct driver_private *p;
  110. int (* init_graphics) (caca_display_t *);
  111. int (* end_graphics) (caca_display_t *);
  112. int (* set_display_title) (caca_display_t *, char const *);
  113. unsigned int (* get_display_width) (caca_display_t const *);
  114. unsigned int (* get_display_height) (caca_display_t const *);
  115. void (* display) (caca_display_t *);
  116. void (* handle_resize) (caca_display_t *);
  117. int (* get_event) (caca_display_t *, caca_privevent_t *);
  118. void (* set_mouse) (caca_display_t *, int);
  119. void (* set_cursor) (caca_display_t *, int);
  120. } drv;
  121. /* Mouse position */
  122. struct mouse
  123. {
  124. unsigned int x, y;
  125. } mouse;
  126. /* Window resize handling */
  127. struct resize
  128. {
  129. int resized; /* A resize event was requested */
  130. int allow; /* The display driver allows resizing */
  131. unsigned w, h; /* Requested width and height */
  132. } resize;
  133. /* Framerate handling */
  134. unsigned int delay, rendertime;
  135. caca_timer_t timer;
  136. int lastticks;
  137. struct events
  138. {
  139. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  140. caca_privevent_t buf[EVENTBUF_LEN];
  141. int queue;
  142. #endif
  143. #if defined(USE_SLANG) || defined(USE_NCURSES)
  144. caca_timer_t key_timer;
  145. unsigned int last_key_ticks;
  146. unsigned int autorepeat_ticks;
  147. caca_privevent_t last_key_event;
  148. #endif
  149. #if defined(USE_WIN32)
  150. unsigned char not_empty_struct;
  151. #endif
  152. } events;
  153. };
  154. /* Internal timer functions */
  155. extern void _caca_sleep(unsigned int);
  156. extern unsigned int _caca_getticks(caca_timer_t *);
  157. /* Internal event functions */
  158. extern void _caca_handle_resize(caca_display_t *);
  159. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  160. extern void _push_event(caca_display_t *, caca_privevent_t *);
  161. extern int _pop_event(caca_display_t *, caca_privevent_t *);
  162. #endif
  163. /* Internal window functions */
  164. extern void _caca_set_term_title(char const *);
  165. #endif /* __CACA_INTERNALS_H__ */