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.

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