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.4 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 "stubs.h"
  17. typedef struct caca_timer caca_timer_t;
  18. typedef struct caca_privevent caca_privevent_t;
  19. #if !defined(_DOXYGEN_SKIP_ME)
  20. # define EVENTBUF_LEN 10
  21. #endif
  22. /* Graphics driver */
  23. enum caca_driver
  24. {
  25. CACA_DRIVER_NONE = 0,
  26. CACA_DRIVER_RAW = 1,
  27. #if defined(USE_COCOA)
  28. CACA_DRIVER_COCOA = 2,
  29. #endif
  30. #if defined(USE_CONIO)
  31. CACA_DRIVER_CONIO = 3,
  32. #endif
  33. #if defined(USE_GL)
  34. CACA_DRIVER_GL = 4,
  35. #endif
  36. #if defined(USE_NCURSES)
  37. CACA_DRIVER_NCURSES = 5,
  38. #endif
  39. #if defined(USE_SLANG)
  40. CACA_DRIVER_SLANG = 6,
  41. #endif
  42. #if defined(USE_VGA)
  43. CACA_DRIVER_VGA = 7,
  44. #endif
  45. #if defined(USE_WIN32)
  46. CACA_DRIVER_WIN32 = 8,
  47. #endif
  48. #if defined(USE_X11)
  49. CACA_DRIVER_X11 = 9,
  50. #endif
  51. };
  52. /* Available external drivers */
  53. #if defined(USE_COCOA)
  54. int cocoa_install(caca_display_t *);
  55. #endif
  56. #if defined(USE_CONIO)
  57. int conio_install(caca_display_t *);
  58. #endif
  59. #if defined(USE_GL)
  60. int gl_install(caca_display_t *);
  61. #endif
  62. #if defined(USE_NCURSES)
  63. int ncurses_install(caca_display_t *);
  64. #endif
  65. int raw_install(caca_display_t *);
  66. #if defined(USE_SLANG)
  67. int slang_install(caca_display_t *);
  68. #endif
  69. #if defined(USE_VGA)
  70. int vga_install(caca_display_t *);
  71. #endif
  72. #if defined(USE_WIN32)
  73. int win32_install(caca_display_t *);
  74. #endif
  75. #if defined(USE_X11)
  76. int x11_install(caca_display_t *);
  77. #endif
  78. /* Timer structure */
  79. struct caca_timer
  80. {
  81. int last_sec, last_usec;
  82. };
  83. /* Private event structure */
  84. struct caca_privevent
  85. {
  86. enum caca_event_type type;
  87. union
  88. {
  89. struct { int x, y, button; } mouse;
  90. struct { int w, h; } resize;
  91. struct { int ch; uint32_t utf32; char utf8[8]; } key;
  92. } data;
  93. };
  94. /* Internal caca display context */
  95. struct caca_display
  96. {
  97. /* A link to our cucul canvas */
  98. cucul_canvas_t *cv;
  99. int autorelease;
  100. #if defined(USE_PLUGINS)
  101. void *plugin;
  102. #endif
  103. /* Device-specific functions */
  104. struct drv
  105. {
  106. char const * driver;
  107. enum caca_driver id;
  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. int (* get_display_width) (caca_display_t const *);
  113. 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. 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. int w, h; /* Requested width and height */
  131. } resize;
  132. /* Framerate handling */
  133. 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. int last_key_ticks;
  145. int autorepeat_ticks;
  146. caca_privevent_t last_key_event;
  147. #endif
  148. #if defined(USE_WIN32)
  149. uint8_t not_empty_struct;
  150. #endif
  151. } events;
  152. };
  153. /* Internal timer functions */
  154. extern void _caca_sleep(int);
  155. extern 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__ */