Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

186 Zeilen
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. #if defined(USE_PLUGINS)
  102. void *plugin;
  103. #endif
  104. /* Device-specific functions */
  105. struct drv
  106. {
  107. enum caca_driver driver;
  108. struct driver_private *p;
  109. int (* init_graphics) (caca_display_t *);
  110. int (* end_graphics) (caca_display_t *);
  111. int (* set_display_title) (caca_display_t *, char const *);
  112. unsigned int (* get_display_width) (caca_display_t const *);
  113. unsigned int (* get_display_height) (caca_display_t const *);
  114. void (* display) (caca_display_t *);
  115. void (* handle_resize) (caca_display_t *);
  116. int (* get_event) (caca_display_t *, caca_privevent_t *);
  117. void (* set_mouse) (caca_display_t *, int);
  118. void (* set_cursor) (caca_display_t *, int);
  119. } drv;
  120. /* Mouse position */
  121. struct mouse
  122. {
  123. unsigned int x, y;
  124. } mouse;
  125. /* Window resize handling */
  126. struct resize
  127. {
  128. int resized; /* A resize event was requested */
  129. int allow; /* The display driver allows resizing */
  130. unsigned w, h; /* Requested width and height */
  131. } resize;
  132. /* Framerate handling */
  133. unsigned int delay, rendertime;
  134. caca_timer_t timer;
  135. int lastticks;
  136. struct events
  137. {
  138. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  139. caca_privevent_t buf[EVENTBUF_LEN];
  140. int queue;
  141. #endif
  142. #if defined(USE_SLANG) || defined(USE_NCURSES)
  143. caca_timer_t key_timer;
  144. unsigned int last_key_ticks;
  145. unsigned int autorepeat_ticks;
  146. caca_privevent_t last_key_event;
  147. #endif
  148. #if defined(USE_WIN32)
  149. unsigned char not_empty_struct;
  150. #endif
  151. } events;
  152. };
  153. /* Internal timer functions */
  154. extern void _caca_sleep(unsigned int);
  155. extern unsigned int _caca_getticks(caca_timer_t *);
  156. /* Internal event functions */
  157. extern void _caca_handle_resize(caca_display_t *);
  158. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  159. extern void _push_event(caca_display_t *, caca_privevent_t *);
  160. extern int _pop_event(caca_display_t *, caca_privevent_t *);
  161. #endif
  162. /* Internal window functions */
  163. extern void _caca_set_term_title(char const *);
  164. #endif /* __CACA_INTERNALS_H__ */