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.

преди 21 години
преди 21 години
преди 21 години
преди 21 години
преди 21 години
преди 21 години
преди 21 години
преди 21 години
преди 19 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * libcaca ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Do What The Fuck You Want To
  8. * Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. /** \file caca.h
  12. * \version \$Id$
  13. * \author Sam Hocevar <sam@zoy.org>
  14. * \brief The \e libcaca public header.
  15. *
  16. * This header contains the public types and functions that applications
  17. * using \e libcaca may use.
  18. */
  19. /** \mainpage libcaca developer documentation
  20. *
  21. * \section intro Introduction
  22. *
  23. * \e libcaca is a graphics library that outputs text instead of pixels,
  24. * so that it can work on older video cards or text terminals. It is not
  25. * unlike the famous AAlib library. \e libcaca can use almost any virtual
  26. * terminal to work, thus it should work on all Unix systems (including
  27. * Mac OS X) using either the slang library or the ncurses library, on DOS
  28. * using the conio library, and on Windows systems using either slang or
  29. * ncurses (through Cygwin emulation) or conio. There is also a native X11
  30. * driver, and an OpenGL driver (through freeglut) that does not require a
  31. * text terminal.
  32. *
  33. * \e libcaca is free software, released under the Do What The Fuck You
  34. * Want To Public License. This ensures that no one, not even the \e libcaca
  35. * developers, will ever have anything to say about what you do with the
  36. * software. It used to be licensed under the GNU Lesser General Public
  37. * License, but that was not free enough.
  38. *
  39. * \section api The libcaca API
  40. *
  41. * \e libcaca relies on a low-level, device independent library, called
  42. * \e libcucul. \e libcucul can be used alone as a simple ASCII and/or
  43. * Unicode compositing canvas.
  44. *
  45. * The complete \e libcucul and \e libcaca programming interface is
  46. * available from the cucul.h and caca.h headers.
  47. *
  48. * \section env Environment variables
  49. *
  50. * Some environment variables can be used to change the behaviour of
  51. * \e libcaca or \e libcucul without having to modify the program which
  52. * uses them. These variables are:
  53. *
  54. * \li \b CACA_DRIVER: set the backend video driver. In order of preference:
  55. * - \c conio uses the DOS conio.h interface.
  56. * - \c ncurses uses the ncurses library.
  57. * - \c slang uses the S-Lang library.
  58. * - \c x11 uses the native X11 driver.
  59. * - \c gl uses freeglut and opengl libraries.
  60. * - \c null uses nothing at all, and will display nothing as well.
  61. *
  62. * \li \b CUCUL_BACKGROUND: set the background type.
  63. * - \c solid uses solid coloured backgrounds for all characters. This
  64. * feature does not work with all terminal emulators. This is the
  65. * default choice.
  66. * - \c black uses only black backgrounds to render characters.
  67. *
  68. * \li \b CUCUL_ANTIALIASING: set the antialiasing mode. Antialiasing
  69. * smoothens the rendered image and avoids the commonly seen staircase
  70. * effect.
  71. * - \c none disables antialiasing.
  72. * - \c prefilter uses a simple prefilter antialiasing method. This is
  73. * the default choice.
  74. *
  75. * \li \b CUCUL_DITHERING: set the dithering mode. Dithering is necessary
  76. * when rendering a picture that has more colours than the usually
  77. * available palette.
  78. * - \c none disables dithering.
  79. * - \c ordered2 uses a 2x2 Bayer matrix for dithering.
  80. * - \c ordered4 uses a 4x4 Bayer matrix for dithering. This is the
  81. * default choice.
  82. * - \c ordered8 uses a 8x8 Bayer matrix for dithering.
  83. * - \c random uses random dithering.
  84. *
  85. * \li \b CACA_GEOMETRY: set the video display size. The format of this
  86. * variable must be XxY, with X and Y being integer values. This option
  87. * currently only works with the X11 and the GL driver.
  88. *
  89. * \li \b CACA_FONT: set the rendered font. The format of this variable is
  90. * implementation dependent, but since it currently only works with the
  91. * X11 driver, an X11 font name such as "fixed" or "5x7" is expected.
  92. */
  93. #ifndef __CACA_H__
  94. #define __CACA_H__
  95. #include <cucul.h>
  96. #ifdef __cplusplus
  97. extern "C"
  98. {
  99. #endif
  100. /** \brief User events.
  101. *
  102. * Event types returned by caca_get_event().
  103. */
  104. enum caca_event
  105. {
  106. CACA_EVENT_NONE = 0x00000000, /**< No event. */
  107. CACA_EVENT_KEY_PRESS = 0x01000000, /**< A key was pressed. */
  108. CACA_EVENT_KEY_RELEASE = 0x02000000, /**< A key was released. */
  109. CACA_EVENT_MOUSE_PRESS = 0x04000000, /**< A mouse button was pressed. */
  110. CACA_EVENT_MOUSE_RELEASE = 0x08000000, /**< A mouse button was released. */
  111. CACA_EVENT_MOUSE_MOTION = 0x10000000, /**< The mouse was moved. */
  112. CACA_EVENT_RESIZE = 0x20000000, /**< The window was resized. */
  113. CACA_EVENT_ANY = 0xff000000 /**< Bitmask for any event. */
  114. };
  115. /** \brief Special key values.
  116. *
  117. * Special key values returned by caca_get_event() for which there is no
  118. * ASCII equivalent.
  119. */
  120. enum caca_key
  121. {
  122. CACA_KEY_UNKNOWN = 0, /**< Unknown key. */
  123. /* The following keys have ASCII equivalents */
  124. CACA_KEY_BACKSPACE = 8, /**< The backspace key. */
  125. CACA_KEY_TAB = 9, /**< The tabulation key. */
  126. CACA_KEY_RETURN = 13, /**< The return key. */
  127. CACA_KEY_PAUSE = 19, /**< The pause key. */
  128. CACA_KEY_ESCAPE = 27, /**< The escape key. */
  129. CACA_KEY_DELETE = 127, /**< The delete key. */
  130. /* The following keys do not have ASCII equivalents but have been
  131. * chosen to match the SDL equivalents */
  132. CACA_KEY_UP = 273, /**< The up arrow key. */
  133. CACA_KEY_DOWN = 274, /**< The down arrow key. */
  134. CACA_KEY_LEFT = 275, /**< The left arrow key. */
  135. CACA_KEY_RIGHT = 276, /**< The right arrow key. */
  136. CACA_KEY_INSERT = 277, /**< The insert key. */
  137. CACA_KEY_HOME = 278, /**< The home key. */
  138. CACA_KEY_END = 279, /**< The end key. */
  139. CACA_KEY_PAGEUP = 280, /**< The page up key. */
  140. CACA_KEY_PAGEDOWN = 281, /**< The page down key. */
  141. CACA_KEY_F1 = 282, /**< The F1 key. */
  142. CACA_KEY_F2 = 283, /**< The F2 key. */
  143. CACA_KEY_F3 = 284, /**< The F3 key. */
  144. CACA_KEY_F4 = 285, /**< The F4 key. */
  145. CACA_KEY_F5 = 286, /**< The F5 key. */
  146. CACA_KEY_F6 = 287, /**< The F6 key. */
  147. CACA_KEY_F7 = 288, /**< The F7 key. */
  148. CACA_KEY_F8 = 289, /**< The F8 key. */
  149. CACA_KEY_F9 = 290, /**< The F9 key. */
  150. CACA_KEY_F10 = 291, /**< The F10 key. */
  151. CACA_KEY_F11 = 292, /**< The F11 key. */
  152. CACA_KEY_F12 = 293, /**< The F12 key. */
  153. CACA_KEY_F13 = 294, /**< The F13 key. */
  154. CACA_KEY_F14 = 295, /**< The F14 key. */
  155. CACA_KEY_F15 = 296 /**< The F15 key. */
  156. };
  157. typedef struct caca_context caca_t;
  158. /** \defgroup basic Basic functions
  159. *
  160. * These functions provide the basic \e libcaca routines for library
  161. * initialisation, system information retrieval and configuration.
  162. *
  163. * @{ */
  164. caca_t * caca_attach(cucul_t *qq);
  165. void caca_detach(caca_t *kk);
  166. void caca_set_delay(caca_t *kk, unsigned int);
  167. void caca_display(caca_t *kk);
  168. unsigned int caca_get_rendertime(caca_t *kk);
  169. unsigned int caca_get_window_width(caca_t *kk);
  170. unsigned int caca_get_window_height(caca_t *kk);
  171. int caca_set_window_title(caca_t *kk, char const *);
  172. /* @} */
  173. /** \defgroup event Event handling
  174. *
  175. * These functions handle user events such as keyboard input and mouse
  176. * clicks.
  177. *
  178. * @{ */
  179. unsigned int caca_get_event(caca_t *kk, unsigned int);
  180. unsigned int caca_wait_event(caca_t *kk, unsigned int);
  181. unsigned int caca_get_mouse_x(caca_t *kk);
  182. unsigned int caca_get_mouse_y(caca_t *kk);
  183. /* @} */
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif /* __CACA_H__ */