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 години
преди 21 години
преди 21 години
преди 18 години
преди 18 години
преди 18 години
преди 21 години
преди 18 години
преди 19 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. /** \file caca.h
  15. * \version \$Id$
  16. * \author Sam Hocevar <sam@zoy.org>
  17. * \brief The \e libcaca public header.
  18. *
  19. * This header contains the public types and functions that applications
  20. * using \e libcaca may use.
  21. */
  22. #ifndef __CACA_H__
  23. #define __CACA_H__
  24. #include <cucul.h>
  25. #undef __extern
  26. #if defined(_WIN32) && defined(__LIBCACA__)
  27. # define __extern extern __declspec(dllexport)
  28. #else
  29. # define __extern extern
  30. #endif
  31. /** libcaca API version */
  32. #define CACA_API_VERSION_1
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. /** \e libcaca display context */
  38. typedef struct caca_display caca_display_t;
  39. /** \e libcaca event structure */
  40. typedef struct caca_event caca_event_t;
  41. /** \brief User event type enumeration.
  42. *
  43. * This enum serves two purposes:
  44. * - Build listening masks for caca_get_event().
  45. * - Define the type of a \e caca_event_t.
  46. */
  47. enum caca_event_type
  48. {
  49. CACA_EVENT_NONE = 0x0000, /**< No event. */
  50. CACA_EVENT_KEY_PRESS = 0x0001, /**< A key was pressed. */
  51. CACA_EVENT_KEY_RELEASE = 0x0002, /**< A key was released. */
  52. CACA_EVENT_MOUSE_PRESS = 0x0004, /**< A mouse button was pressed. */
  53. CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
  54. CACA_EVENT_MOUSE_MOTION = 0x0010, /**< The mouse was moved. */
  55. CACA_EVENT_RESIZE = 0x0020, /**< The window was resized. */
  56. CACA_EVENT_QUIT = 0x0040, /**< The user requested to quit. */
  57. CACA_EVENT_ANY = 0xffff /**< Bitmask for any event. */
  58. };
  59. /** \brief Handling of user events.
  60. *
  61. * This structure is filled by caca_get_event() when an event is received.
  62. * It is an opaque structure that should only be accessed through
  63. * caca_event_get_type() and similar functions. The struct members may no
  64. * longer be directly accessible in future versions.
  65. */
  66. struct caca_event
  67. {
  68. enum caca_event_type type;
  69. union
  70. {
  71. struct { unsigned int x, y, button; } mouse;
  72. struct { unsigned int w, h; } resize;
  73. struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
  74. } data;
  75. unsigned char padding[16];
  76. };
  77. /** \brief Special key values.
  78. *
  79. * Special key values returned by caca_get_event() for which there is no
  80. * printable ASCII equivalent.
  81. */
  82. enum caca_key
  83. {
  84. CACA_KEY_UNKNOWN = 0x00, /**< Unknown key. */
  85. /* The following keys have ASCII equivalents */
  86. CACA_KEY_CTRL_A = 0x01, /**< The Ctrl-A key. */
  87. CACA_KEY_CTRL_B = 0x02, /**< The Ctrl-B key. */
  88. CACA_KEY_CTRL_C = 0x03, /**< The Ctrl-C key. */
  89. CACA_KEY_CTRL_D = 0x04, /**< The Ctrl-D key. */
  90. CACA_KEY_CTRL_E = 0x05, /**< The Ctrl-E key. */
  91. CACA_KEY_CTRL_F = 0x06, /**< The Ctrl-F key. */
  92. CACA_KEY_CTRL_G = 0x07, /**< The Ctrl-G key. */
  93. CACA_KEY_BACKSPACE = 0x08, /**< The backspace key. */
  94. CACA_KEY_TAB = 0x09, /**< The tabulation key. */
  95. CACA_KEY_CTRL_J = 0x0a, /**< The Ctrl-J key. */
  96. CACA_KEY_CTRL_K = 0x0b, /**< The Ctrl-K key. */
  97. CACA_KEY_CTRL_L = 0x0c, /**< The Ctrl-L key. */
  98. CACA_KEY_RETURN = 0x0d, /**< The return key. */
  99. CACA_KEY_CTRL_N = 0x0e, /**< The Ctrl-N key. */
  100. CACA_KEY_CTRL_O = 0x0f, /**< The Ctrl-O key. */
  101. CACA_KEY_CTRL_P = 0x10, /**< The Ctrl-P key. */
  102. CACA_KEY_CTRL_Q = 0x11, /**< The Ctrl-Q key. */
  103. CACA_KEY_CTRL_R = 0x12, /**< The Ctrl-R key. */
  104. CACA_KEY_PAUSE = 0x13, /**< The pause key. */
  105. CACA_KEY_CTRL_T = 0x14, /**< The Ctrl-T key. */
  106. CACA_KEY_CTRL_U = 0x15, /**< The Ctrl-U key. */
  107. CACA_KEY_CTRL_V = 0x16, /**< The Ctrl-V key. */
  108. CACA_KEY_CTRL_W = 0x17, /**< The Ctrl-W key. */
  109. CACA_KEY_CTRL_X = 0x18, /**< The Ctrl-X key. */
  110. CACA_KEY_CTRL_Y = 0x19, /**< The Ctrl-Y key. */
  111. CACA_KEY_CTRL_Z = 0x1a, /**< The Ctrl-Z key. */
  112. CACA_KEY_ESCAPE = 0x1b, /**< The escape key. */
  113. CACA_KEY_DELETE = 0x7f, /**< The delete key. */
  114. /* The following keys do not have ASCII equivalents but have been
  115. * chosen to match the SDL equivalents */
  116. CACA_KEY_UP = 0x111, /**< The up arrow key. */
  117. CACA_KEY_DOWN = 0x112, /**< The down arrow key. */
  118. CACA_KEY_LEFT = 0x113, /**< The left arrow key. */
  119. CACA_KEY_RIGHT = 0x114, /**< The right arrow key. */
  120. CACA_KEY_INSERT = 0x115, /**< The insert key. */
  121. CACA_KEY_HOME = 0x116, /**< The home key. */
  122. CACA_KEY_END = 0x117, /**< The end key. */
  123. CACA_KEY_PAGEUP = 0x118, /**< The page up key. */
  124. CACA_KEY_PAGEDOWN = 0x119, /**< The page down key. */
  125. CACA_KEY_F1 = 0x11a, /**< The F1 key. */
  126. CACA_KEY_F2 = 0x11b, /**< The F2 key. */
  127. CACA_KEY_F3 = 0x11c, /**< The F3 key. */
  128. CACA_KEY_F4 = 0x11d, /**< The F4 key. */
  129. CACA_KEY_F5 = 0x11e, /**< The F5 key. */
  130. CACA_KEY_F6 = 0x11f, /**< The F6 key. */
  131. CACA_KEY_F7 = 0x120, /**< The F7 key. */
  132. CACA_KEY_F8 = 0x121, /**< The F8 key. */
  133. CACA_KEY_F9 = 0x122, /**< The F9 key. */
  134. CACA_KEY_F10 = 0x123, /**< The F10 key. */
  135. CACA_KEY_F11 = 0x124, /**< The F11 key. */
  136. CACA_KEY_F12 = 0x125, /**< The F12 key. */
  137. CACA_KEY_F13 = 0x126, /**< The F13 key. */
  138. CACA_KEY_F14 = 0x127, /**< The F14 key. */
  139. CACA_KEY_F15 = 0x128 /**< The F15 key. */
  140. };
  141. /** \defgroup libcaca libcaca basic functions
  142. *
  143. * These functions provide the basic \e libcaca routines for driver
  144. * initialisation, system information retrieval and configuration.
  145. *
  146. * @{ */
  147. __extern caca_display_t * caca_create_display(cucul_canvas_t *);
  148. __extern caca_display_t * caca_create_display_with_driver(cucul_canvas_t *,
  149. char const *);
  150. __extern char const * const * caca_get_display_driver_list(void);
  151. __extern char const * caca_get_display_driver(caca_display_t *);
  152. __extern int caca_set_display_driver(caca_display_t *, char const *);
  153. __extern int caca_free_display(caca_display_t *);
  154. __extern cucul_canvas_t * caca_get_canvas(caca_display_t *);
  155. __extern int caca_refresh_display(caca_display_t *);
  156. __extern int caca_set_display_time(caca_display_t *, unsigned int);
  157. __extern unsigned int caca_get_display_time(caca_display_t const *);
  158. __extern unsigned int caca_get_display_width(caca_display_t const *);
  159. __extern unsigned int caca_get_display_height(caca_display_t const *);
  160. __extern int caca_set_display_title(caca_display_t *, char const *);
  161. __extern int caca_set_mouse(caca_display_t *, int);
  162. __extern int caca_set_cursor(caca_display_t *, int);
  163. __extern char const * caca_get_version(void);
  164. /* @} */
  165. /** \defgroup caca_event libcaca event handling
  166. *
  167. * These functions handle user events such as keyboard input and mouse
  168. * clicks.
  169. *
  170. * @{ */
  171. __extern int caca_get_event(caca_display_t *, unsigned int,
  172. caca_event_t *, int);
  173. __extern unsigned int caca_get_mouse_x(caca_display_t const *);
  174. __extern unsigned int caca_get_mouse_y(caca_display_t const *);
  175. __extern enum caca_event_type caca_get_event_type(caca_event_t const *);
  176. __extern unsigned int caca_get_event_key_ch(caca_event_t const *);
  177. __extern unsigned long int caca_get_event_key_utf32(caca_event_t const *);
  178. __extern int caca_get_event_key_utf8(caca_event_t const *, char *);
  179. __extern unsigned int caca_get_event_mouse_button(caca_event_t const *);
  180. __extern unsigned int caca_get_event_mouse_x(caca_event_t const *);
  181. __extern unsigned int caca_get_event_mouse_y(caca_event_t const *);
  182. __extern unsigned int caca_get_event_resize_width(caca_event_t const *);
  183. __extern unsigned int caca_get_event_resize_height(caca_event_t const *);
  184. /* @} */
  185. #ifdef __cplusplus
  186. }
  187. #endif
  188. #if !defined(_DOXYGEN_SKIP_ME)
  189. # undef __extern
  190. #endif
  191. #endif /* __CACA_H__ */