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 години
преди 15 години
преди 19 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
  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@hocevar.net>
  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 <caca_types.h>
  25. #if !defined(__KERNEL__)
  26. # include <stdarg.h>
  27. #endif
  28. #undef __extern
  29. #if defined(_DOXYGEN_SKIP_ME)
  30. #elif defined(_WIN32) && defined(__LIBCACA__)
  31. # define __extern extern __declspec(dllexport)
  32. #elif defined(_WIN32)
  33. # define __extern extern __declspec(dllimport)
  34. #else
  35. # define __extern extern
  36. #endif
  37. /** libcaca API version */
  38. #define CACA_API_VERSION_1
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43. /** \e libcaca canvas */
  44. typedef struct caca_canvas caca_canvas_t;
  45. /** dither structure */
  46. typedef struct caca_dither caca_dither_t;
  47. /** font structure */
  48. typedef struct caca_font caca_font_t;
  49. /** file handle structure */
  50. typedef struct caca_file caca_file_t;
  51. /** \e libcaca display context */
  52. typedef struct caca_display caca_display_t;
  53. /** \e libcaca event structure */
  54. typedef struct caca_event caca_event_t;
  55. /** \defgroup caca_attr libcaca attribute definitions
  56. *
  57. * Colours and styles that can be used with caca_set_attr().
  58. *
  59. * @{ */
  60. enum caca_color
  61. {
  62. CACA_BLACK = 0x00, /**< The colour index for black. */
  63. CACA_BLUE = 0x01, /**< The colour index for blue. */
  64. CACA_GREEN = 0x02, /**< The colour index for green. */
  65. CACA_CYAN = 0x03, /**< The colour index for cyan. */
  66. CACA_RED = 0x04, /**< The colour index for red. */
  67. CACA_MAGENTA = 0x05, /**< The colour index for magenta. */
  68. CACA_BROWN = 0x06, /**< The colour index for brown. */
  69. CACA_LIGHTGRAY = 0x07, /**< The colour index for light gray. */
  70. CACA_DARKGRAY = 0x08, /**< The colour index for dark gray. */
  71. CACA_LIGHTBLUE = 0x09, /**< The colour index for blue. */
  72. CACA_LIGHTGREEN = 0x0a, /**< The colour index for light green. */
  73. CACA_LIGHTCYAN = 0x0b, /**< The colour index for light cyan. */
  74. CACA_LIGHTRED = 0x0c, /**< The colour index for light red. */
  75. CACA_LIGHTMAGENTA = 0x0d, /**< The colour index for light magenta. */
  76. CACA_YELLOW = 0x0e, /**< The colour index for yellow. */
  77. CACA_WHITE = 0x0f, /**< The colour index for white. */
  78. CACA_DEFAULT = 0x10, /**< The output driver's default colour. */
  79. CACA_TRANSPARENT = 0x20, /**< The transparent colour. */
  80. };
  81. enum caca_style
  82. {
  83. CACA_BOLD = 0x01, /**< The style mask for bold. */
  84. CACA_ITALICS = 0x02, /**< The style mask for italics. */
  85. CACA_UNDERLINE = 0x04, /**< The style mask for underline. */
  86. CACA_BLINK = 0x08, /**< The style mask for blink. */
  87. };
  88. /* @} */
  89. /** \brief User event type enumeration.
  90. *
  91. * This enum serves two purposes:
  92. * - Build listening masks for caca_get_event().
  93. * - Define the type of a \e caca_event_t.
  94. */
  95. enum caca_event_type
  96. {
  97. CACA_EVENT_NONE = 0x0000, /**< No event. */
  98. CACA_EVENT_KEY_PRESS = 0x0001, /**< A key was pressed. */
  99. CACA_EVENT_KEY_RELEASE = 0x0002, /**< A key was released. */
  100. CACA_EVENT_MOUSE_PRESS = 0x0004, /**< A mouse button was pressed. */
  101. CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
  102. CACA_EVENT_MOUSE_MOTION = 0x0010, /**< The mouse was moved. */
  103. CACA_EVENT_RESIZE = 0x0020, /**< The window was resized. */
  104. CACA_EVENT_QUIT = 0x0040, /**< The user requested to quit. */
  105. CACA_EVENT_ANY = 0xffff /**< Bitmask for any event. */
  106. };
  107. /** \brief Handling of user events.
  108. *
  109. * This structure is filled by caca_get_event() when an event is received.
  110. * It is an opaque structure that should only be accessed through
  111. * caca_event_get_type() and similar functions. The struct members may no
  112. * longer be directly accessible in future versions.
  113. */
  114. struct caca_event
  115. {
  116. enum caca_event_type type;
  117. union
  118. {
  119. struct { int x, y, button; } mouse;
  120. struct { int w, h; } resize;
  121. struct { int ch; uint32_t utf32; char utf8[8]; } key;
  122. } data;
  123. uint8_t padding[16];
  124. };
  125. /** \brief Special key values.
  126. *
  127. * Special key values returned by caca_get_event() for which there is no
  128. * printable ASCII equivalent.
  129. */
  130. enum caca_key
  131. {
  132. CACA_KEY_UNKNOWN = 0x00, /**< Unknown key. */
  133. /* The following keys have ASCII equivalents */
  134. CACA_KEY_CTRL_A = 0x01, /**< The Ctrl-A key. */
  135. CACA_KEY_CTRL_B = 0x02, /**< The Ctrl-B key. */
  136. CACA_KEY_CTRL_C = 0x03, /**< The Ctrl-C key. */
  137. CACA_KEY_CTRL_D = 0x04, /**< The Ctrl-D key. */
  138. CACA_KEY_CTRL_E = 0x05, /**< The Ctrl-E key. */
  139. CACA_KEY_CTRL_F = 0x06, /**< The Ctrl-F key. */
  140. CACA_KEY_CTRL_G = 0x07, /**< The Ctrl-G key. */
  141. CACA_KEY_BACKSPACE = 0x08, /**< The backspace key. */
  142. CACA_KEY_TAB = 0x09, /**< The tabulation key. */
  143. CACA_KEY_CTRL_J = 0x0a, /**< The Ctrl-J key. */
  144. CACA_KEY_CTRL_K = 0x0b, /**< The Ctrl-K key. */
  145. CACA_KEY_CTRL_L = 0x0c, /**< The Ctrl-L key. */
  146. CACA_KEY_RETURN = 0x0d, /**< The return key. */
  147. CACA_KEY_CTRL_N = 0x0e, /**< The Ctrl-N key. */
  148. CACA_KEY_CTRL_O = 0x0f, /**< The Ctrl-O key. */
  149. CACA_KEY_CTRL_P = 0x10, /**< The Ctrl-P key. */
  150. CACA_KEY_CTRL_Q = 0x11, /**< The Ctrl-Q key. */
  151. CACA_KEY_CTRL_R = 0x12, /**< The Ctrl-R key. */
  152. CACA_KEY_PAUSE = 0x13, /**< The pause key. */
  153. CACA_KEY_CTRL_T = 0x14, /**< The Ctrl-T key. */
  154. CACA_KEY_CTRL_U = 0x15, /**< The Ctrl-U key. */
  155. CACA_KEY_CTRL_V = 0x16, /**< The Ctrl-V key. */
  156. CACA_KEY_CTRL_W = 0x17, /**< The Ctrl-W key. */
  157. CACA_KEY_CTRL_X = 0x18, /**< The Ctrl-X key. */
  158. CACA_KEY_CTRL_Y = 0x19, /**< The Ctrl-Y key. */
  159. CACA_KEY_CTRL_Z = 0x1a, /**< The Ctrl-Z key. */
  160. CACA_KEY_ESCAPE = 0x1b, /**< The escape key. */
  161. CACA_KEY_DELETE = 0x7f, /**< The delete key. */
  162. /* The following keys do not have ASCII equivalents but have been
  163. * chosen to match the SDL equivalents */
  164. CACA_KEY_UP = 0x111, /**< The up arrow key. */
  165. CACA_KEY_DOWN = 0x112, /**< The down arrow key. */
  166. CACA_KEY_LEFT = 0x113, /**< The left arrow key. */
  167. CACA_KEY_RIGHT = 0x114, /**< The right arrow key. */
  168. CACA_KEY_INSERT = 0x115, /**< The insert key. */
  169. CACA_KEY_HOME = 0x116, /**< The home key. */
  170. CACA_KEY_END = 0x117, /**< The end key. */
  171. CACA_KEY_PAGEUP = 0x118, /**< The page up key. */
  172. CACA_KEY_PAGEDOWN = 0x119, /**< The page down key. */
  173. CACA_KEY_F1 = 0x11a, /**< The F1 key. */
  174. CACA_KEY_F2 = 0x11b, /**< The F2 key. */
  175. CACA_KEY_F3 = 0x11c, /**< The F3 key. */
  176. CACA_KEY_F4 = 0x11d, /**< The F4 key. */
  177. CACA_KEY_F5 = 0x11e, /**< The F5 key. */
  178. CACA_KEY_F6 = 0x11f, /**< The F6 key. */
  179. CACA_KEY_F7 = 0x120, /**< The F7 key. */
  180. CACA_KEY_F8 = 0x121, /**< The F8 key. */
  181. CACA_KEY_F9 = 0x122, /**< The F9 key. */
  182. CACA_KEY_F10 = 0x123, /**< The F10 key. */
  183. CACA_KEY_F11 = 0x124, /**< The F11 key. */
  184. CACA_KEY_F12 = 0x125, /**< The F12 key. */
  185. CACA_KEY_F13 = 0x126, /**< The F13 key. */
  186. CACA_KEY_F14 = 0x127, /**< The F14 key. */
  187. CACA_KEY_F15 = 0x128 /**< The F15 key. */
  188. };
  189. /** \defgroup libcaca libcaca basic functions
  190. *
  191. * These functions provide the basic \e libcaca routines for library
  192. * initialisation, system information retrieval and configuration.
  193. *
  194. * @{ */
  195. __extern caca_canvas_t * caca_create_canvas(int, int);
  196. __extern int caca_manage_canvas(caca_canvas_t *, int (*)(void *), void *);
  197. __extern int caca_unmanage_canvas(caca_canvas_t *, int (*)(void *), void *);
  198. __extern int caca_set_canvas_size(caca_canvas_t *, int, int);
  199. __extern int caca_get_canvas_width(caca_canvas_t const *);
  200. __extern int caca_get_canvas_height(caca_canvas_t const *);
  201. __extern uint8_t const * caca_get_canvas_chars(caca_canvas_t const *);
  202. __extern uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *);
  203. __extern int caca_free_canvas(caca_canvas_t *);
  204. __extern int caca_rand(int, int);
  205. __extern char const * caca_get_version(void);
  206. /* @} */
  207. /** \defgroup caca_canvas libcaca canvas drawing
  208. *
  209. * These functions provide low-level character printing routines and
  210. * higher level graphics functions.
  211. *
  212. * @{ */
  213. #define CACA_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */
  214. __extern int caca_gotoxy(caca_canvas_t *, int, int);
  215. __extern int caca_wherex(caca_canvas_t const *);
  216. __extern int caca_wherey(caca_canvas_t const *);
  217. __extern int caca_put_char(caca_canvas_t *, int, int, uint32_t);
  218. __extern uint32_t caca_get_char(caca_canvas_t const *, int, int);
  219. __extern int caca_put_str(caca_canvas_t *, int, int, char const *);
  220. __extern int caca_printf(caca_canvas_t *, int, int, char const *, ...);
  221. __extern int caca_vprintf(caca_canvas_t *, int, int, char const *, va_list);
  222. __extern int caca_clear_canvas(caca_canvas_t *);
  223. __extern int caca_set_canvas_handle(caca_canvas_t *, int, int);
  224. __extern int caca_get_canvas_handle_x(caca_canvas_t const *);
  225. __extern int caca_get_canvas_handle_y(caca_canvas_t const *);
  226. __extern int caca_blit(caca_canvas_t *, int, int, caca_canvas_t const *,
  227. caca_canvas_t const *);
  228. __extern int caca_set_canvas_boundaries(caca_canvas_t *, int, int, int, int);
  229. /* @} */
  230. /** \defgroup caca_dirty libcaca dirty rectangle manipulation
  231. *
  232. * These functions manipulate dirty rectangles for optimised blitting.
  233. * @{ */
  234. __extern int caca_disable_dirty_rect(caca_canvas_t *);
  235. __extern int caca_enable_dirty_rect(caca_canvas_t *);
  236. __extern int caca_get_dirty_rect_count(caca_canvas_t *);
  237. __extern int caca_get_dirty_rect(caca_canvas_t *, int, int *, int *,
  238. int *, int *);
  239. __extern int caca_add_dirty_rect(caca_canvas_t *, int, int, int, int);
  240. __extern int caca_remove_dirty_rect(caca_canvas_t *, int, int, int, int);
  241. __extern int caca_clear_dirty_rect_list(caca_canvas_t *);
  242. /* @} */
  243. /** \defgroup caca_transform libcaca canvas transformation
  244. *
  245. * These functions perform horizontal and vertical canvas flipping.
  246. *
  247. * @{ */
  248. __extern int caca_invert(caca_canvas_t *);
  249. __extern int caca_flip(caca_canvas_t *);
  250. __extern int caca_flop(caca_canvas_t *);
  251. __extern int caca_rotate_180(caca_canvas_t *);
  252. __extern int caca_rotate_left(caca_canvas_t *);
  253. __extern int caca_rotate_right(caca_canvas_t *);
  254. __extern int caca_stretch_left(caca_canvas_t *);
  255. __extern int caca_stretch_right(caca_canvas_t *);
  256. /* @} */
  257. /** \defgroup caca_attributes libcaca attribute conversions
  258. *
  259. * These functions perform conversions between attribute values.
  260. *
  261. * @{ */
  262. __extern uint32_t caca_get_attr(caca_canvas_t const *, int, int);
  263. __extern int caca_set_attr(caca_canvas_t *, uint32_t);
  264. __extern int caca_put_attr(caca_canvas_t *, int, int, uint32_t);
  265. __extern int caca_set_color_ansi(caca_canvas_t *, uint8_t, uint8_t);
  266. __extern int caca_set_color_argb(caca_canvas_t *, uint16_t, uint16_t);
  267. __extern uint8_t caca_attr_to_ansi(uint32_t);
  268. __extern uint8_t caca_attr_to_ansi_fg(uint32_t);
  269. __extern uint8_t caca_attr_to_ansi_bg(uint32_t);
  270. __extern uint16_t caca_attr_to_rgb12_fg(uint32_t);
  271. __extern uint16_t caca_attr_to_rgb12_bg(uint32_t);
  272. __extern void caca_attr_to_argb64(uint32_t, uint8_t[8]);
  273. /* @} */
  274. /** \defgroup caca_charset libcaca character set conversions
  275. *
  276. * These functions perform conversions between usual character sets.
  277. *
  278. * @{ */
  279. __extern uint32_t caca_utf8_to_utf32(char const *, size_t *);
  280. __extern size_t caca_utf32_to_utf8(char *, uint32_t);
  281. __extern uint8_t caca_utf32_to_cp437(uint32_t);
  282. __extern uint32_t caca_cp437_to_utf32(uint8_t);
  283. __extern char caca_utf32_to_ascii(uint32_t);
  284. __extern int caca_utf32_is_fullwidth(uint32_t);
  285. /* @} */
  286. /** \defgroup caca_primitives libcaca primitives drawing
  287. *
  288. * These functions provide routines for primitive drawing, such as lines,
  289. * boxes, triangles and ellipses.
  290. *
  291. * @{ */
  292. __extern int caca_draw_line(caca_canvas_t *, int, int, int, int, uint32_t);
  293. __extern int caca_draw_polyline(caca_canvas_t *, int const x[],
  294. int const y[], int, uint32_t);
  295. __extern int caca_draw_thin_line(caca_canvas_t *, int, int, int, int);
  296. __extern int caca_draw_thin_polyline(caca_canvas_t *, int const x[],
  297. int const y[], int);
  298. __extern int caca_draw_circle(caca_canvas_t *, int, int, int, uint32_t);
  299. __extern int caca_draw_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
  300. __extern int caca_draw_thin_ellipse(caca_canvas_t *, int, int, int, int);
  301. __extern int caca_fill_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
  302. __extern int caca_draw_box(caca_canvas_t *, int, int, int, int, uint32_t);
  303. __extern int caca_draw_thin_box(caca_canvas_t *, int, int, int, int);
  304. __extern int caca_draw_cp437_box(caca_canvas_t *, int, int, int, int);
  305. __extern int caca_fill_box(caca_canvas_t *, int, int, int, int, uint32_t);
  306. __extern int caca_draw_triangle(caca_canvas_t *, int, int, int, int, int,
  307. int, uint32_t);
  308. __extern int caca_draw_thin_triangle(caca_canvas_t *, int, int, int, int,
  309. int, int);
  310. __extern int caca_fill_triangle(caca_canvas_t *, int, int, int, int, int,
  311. int, uint32_t);
  312. /* @} */
  313. /** \defgroup caca_frame libcaca canvas frame handling
  314. *
  315. * These functions provide high level routines for canvas frame insertion,
  316. * removal, copying etc.
  317. *
  318. * @{ */
  319. __extern int caca_get_frame_count(caca_canvas_t const *);
  320. __extern int caca_set_frame(caca_canvas_t *, int);
  321. __extern char const *caca_get_frame_name(caca_canvas_t const *);
  322. __extern int caca_set_frame_name(caca_canvas_t *, char const *);
  323. __extern int caca_create_frame(caca_canvas_t *, int);
  324. __extern int caca_free_frame(caca_canvas_t *, int);
  325. /* @} */
  326. /** \defgroup caca_dither libcaca bitmap dithering
  327. *
  328. * These functions provide high level routines for dither allocation and
  329. * rendering.
  330. *
  331. * @{ */
  332. __extern caca_dither_t *caca_create_dither(int, int, int, int,
  333. uint32_t, uint32_t,
  334. uint32_t, uint32_t);
  335. __extern int caca_set_dither_palette(caca_dither_t *,
  336. uint32_t r[], uint32_t g[],
  337. uint32_t b[], uint32_t a[]);
  338. __extern int caca_set_dither_brightness(caca_dither_t *, float);
  339. __extern float caca_get_dither_brightness(caca_dither_t const *);
  340. __extern int caca_set_dither_gamma(caca_dither_t *, float);
  341. __extern float caca_get_dither_gamma(caca_dither_t const *);
  342. __extern int caca_set_dither_contrast(caca_dither_t *, float);
  343. __extern float caca_get_dither_contrast(caca_dither_t const *);
  344. __extern int caca_set_dither_antialias(caca_dither_t *, char const *);
  345. __extern char const * const * caca_get_dither_antialias_list(caca_dither_t
  346. const *);
  347. __extern char const * caca_get_dither_antialias(caca_dither_t const *);
  348. __extern int caca_set_dither_color(caca_dither_t *, char const *);
  349. __extern char const * const * caca_get_dither_color_list(caca_dither_t
  350. const *);
  351. __extern char const * caca_get_dither_color(caca_dither_t const *);
  352. __extern int caca_set_dither_charset(caca_dither_t *, char const *);
  353. __extern char const * const * caca_get_dither_charset_list(caca_dither_t
  354. const *);
  355. __extern char const * caca_get_dither_charset(caca_dither_t const *);
  356. __extern int caca_set_dither_algorithm(caca_dither_t *, char const *);
  357. __extern char const * const * caca_get_dither_algorithm_list(caca_dither_t
  358. const *);
  359. __extern char const * caca_get_dither_algorithm(caca_dither_t const *);
  360. __extern int caca_dither_bitmap(caca_canvas_t *, int, int, int, int,
  361. caca_dither_t const *, void const *);
  362. __extern int caca_free_dither(caca_dither_t *);
  363. /* @} */
  364. /** \defgroup caca_font libcaca font handling
  365. *
  366. * These functions provide font handling routines and high quality
  367. * canvas to bitmap rendering.
  368. *
  369. * @{ */
  370. __extern caca_font_t *caca_load_font(void const *, size_t);
  371. __extern char const * const * caca_get_font_list(void);
  372. __extern int caca_get_font_width(caca_font_t const *);
  373. __extern int caca_get_font_height(caca_font_t const *);
  374. __extern uint32_t const *caca_get_font_blocks(caca_font_t const *);
  375. __extern int caca_render_canvas(caca_canvas_t const *, caca_font_t const *,
  376. void *, int, int, int);
  377. __extern int caca_free_font(caca_font_t *);
  378. /* @} */
  379. /** \defgroup caca_figfont libcaca FIGfont handling
  380. *
  381. * These functions provide FIGlet and TOIlet font handling routines.
  382. *
  383. * @{ */
  384. __extern int caca_canvas_set_figfont(caca_canvas_t *, char const *);
  385. __extern int caca_put_figchar(caca_canvas_t *, uint32_t);
  386. __extern int caca_flush_figlet(caca_canvas_t *);
  387. /* @} */
  388. /** \defgroup caca_file libcaca file IO
  389. *
  390. * These functions allow to read and write files in a platform-independent
  391. * way.
  392. * @{ */
  393. __extern caca_file_t *caca_file_open(char const *, const char *);
  394. __extern int caca_file_close(caca_file_t *);
  395. __extern uint64_t caca_file_tell(caca_file_t *);
  396. __extern size_t caca_file_read(caca_file_t *, void *, size_t);
  397. __extern size_t caca_file_write(caca_file_t *, const void *, size_t);
  398. __extern char * caca_file_gets(caca_file_t *, char *, int);
  399. __extern int caca_file_eof(caca_file_t *);
  400. /* @} */
  401. /** \defgroup caca_importexport libcaca importers/exporters from/to various
  402. * formats
  403. *
  404. * These functions import various file formats into a new canvas, or export
  405. * the current canvas to various text formats.
  406. *
  407. * @{ */
  408. __extern ssize_t caca_import_canvas_from_memory(caca_canvas_t *, void const *,
  409. size_t, char const *);
  410. __extern ssize_t caca_import_canvas_from_file(caca_canvas_t *, char const *,
  411. char const *);
  412. __extern ssize_t caca_import_area_from_memory(caca_canvas_t *, int, int,
  413. void const *, size_t,
  414. char const *);
  415. __extern ssize_t caca_import_area_from_file(caca_canvas_t *, int, int,
  416. char const *, char const *);
  417. __extern char const * const * caca_get_import_list(void);
  418. __extern void *caca_export_canvas_to_memory(caca_canvas_t const *,
  419. char const *, size_t *);
  420. __extern void *caca_export_area_to_memory(caca_canvas_t const *, int, int,
  421. int, int, char const *, size_t *);
  422. __extern char const * const * caca_get_export_list(void);
  423. /* @} */
  424. /** \defgroup caca_display libcaca display functions
  425. *
  426. * These functions provide the basic \e libcaca routines for display
  427. * initialisation, system information retrieval and configuration.
  428. *
  429. * @{ */
  430. __extern caca_display_t * caca_create_display(caca_canvas_t *);
  431. __extern caca_display_t * caca_create_display_with_driver(caca_canvas_t *,
  432. char const *);
  433. __extern char const * const * caca_get_display_driver_list(void);
  434. __extern char const * caca_get_display_driver(caca_display_t *);
  435. __extern int caca_set_display_driver(caca_display_t *, char const *);
  436. __extern int caca_free_display(caca_display_t *);
  437. __extern caca_canvas_t * caca_get_canvas(caca_display_t *);
  438. __extern int caca_refresh_display(caca_display_t *);
  439. __extern int caca_set_display_time(caca_display_t *, int);
  440. __extern int caca_get_display_time(caca_display_t const *);
  441. __extern int caca_get_display_width(caca_display_t const *);
  442. __extern int caca_get_display_height(caca_display_t const *);
  443. __extern int caca_set_display_title(caca_display_t *, char const *);
  444. __extern int caca_set_mouse(caca_display_t *, int);
  445. __extern int caca_set_cursor(caca_display_t *, int);
  446. /* @} */
  447. /** \defgroup caca_event libcaca event handling
  448. *
  449. * These functions handle user events such as keyboard input and mouse
  450. * clicks.
  451. *
  452. * @{ */
  453. __extern int caca_get_event(caca_display_t *, int, caca_event_t *, int);
  454. __extern int caca_get_mouse_x(caca_display_t const *);
  455. __extern int caca_get_mouse_y(caca_display_t const *);
  456. __extern enum caca_event_type caca_get_event_type(caca_event_t const *);
  457. __extern int caca_get_event_key_ch(caca_event_t const *);
  458. __extern uint32_t caca_get_event_key_utf32(caca_event_t const *);
  459. __extern int caca_get_event_key_utf8(caca_event_t const *, char *);
  460. __extern int caca_get_event_mouse_button(caca_event_t const *);
  461. __extern int caca_get_event_mouse_x(caca_event_t const *);
  462. __extern int caca_get_event_mouse_y(caca_event_t const *);
  463. __extern int caca_get_event_resize_width(caca_event_t const *);
  464. __extern int caca_get_event_resize_height(caca_event_t const *);
  465. /* @} */
  466. /** \brief DOS colours
  467. *
  468. * This enum lists the colour values for the DOS conio.h compatibility
  469. * layer.
  470. */
  471. enum CACA_CONIO_COLORS
  472. {
  473. CACA_CONIO_BLINK = 128,
  474. CACA_CONIO_BLACK = 0,
  475. CACA_CONIO_BLUE = 1,
  476. CACA_CONIO_GREEN = 2,
  477. CACA_CONIO_CYAN = 3,
  478. CACA_CONIO_RED = 4,
  479. CACA_CONIO_MAGENTA = 5,
  480. CACA_CONIO_BROWN = 6,
  481. CACA_CONIO_LIGHTGRAY = 7,
  482. CACA_CONIO_DARKGRAY = 8,
  483. CACA_CONIO_LIGHTBLUE = 9,
  484. CACA_CONIO_LIGHTGREEN = 10,
  485. CACA_CONIO_LIGHTCYAN = 11,
  486. CACA_CONIO_LIGHTRED = 12,
  487. CACA_CONIO_LIGHTMAGENTA = 13,
  488. CACA_CONIO_YELLOW = 14,
  489. CACA_CONIO_WHITE = 15,
  490. };
  491. /** \brief DOS cursor modes
  492. *
  493. * This enum lists the cursor mode values for the DOS conio.h compatibility
  494. * layer.
  495. */
  496. enum CACA_CONIO_CURSOR
  497. {
  498. CACA_CONIO__NOCURSOR = 0,
  499. CACA_CONIO__SOLIDCURSOR = 1,
  500. CACA_CONIO__NORMALCURSOR = 2,
  501. };
  502. /** \brief DOS video modes
  503. *
  504. * This enum lists the video mode values for the DOS conio.h compatibility
  505. * layer.
  506. */
  507. enum CACA_CONIO_MODE
  508. {
  509. CACA_CONIO_LASTMODE = -1,
  510. CACA_CONIO_BW40 = 0,
  511. CACA_CONIO_C40 = 1,
  512. CACA_CONIO_BW80 = 2,
  513. CACA_CONIO_C80 = 3,
  514. CACA_CONIO_MONO = 7,
  515. CACA_CONIO_C4350 = 64,
  516. };
  517. /** \brief DOS text area information
  518. *
  519. * This structure stores text area information for the DOS conio.h
  520. * compatibility layer.
  521. */
  522. struct caca_conio_text_info
  523. {
  524. unsigned char winleft; /* left window coordinate */
  525. unsigned char wintop; /* top window coordinate */
  526. unsigned char winright; /* right window coordinate */
  527. unsigned char winbottom; /* bottom window coordinate */
  528. unsigned char attribute; /* text attribute */
  529. unsigned char normattr; /* normal attribute */
  530. unsigned char currmode; /* current video mode:
  531. BW40, BW80, C40, C80, or C4350 */
  532. unsigned char screenheight; /* text screen's height */
  533. unsigned char screenwidth; /* text screen's width */
  534. unsigned char curx; /* x-coordinate in current window */
  535. unsigned char cury; /* y-coordinate in current window */
  536. };
  537. /** \brief DOS direct video control */
  538. __extern int caca_conio_directvideo;
  539. /** \brief DOS scrolling control */
  540. __extern int caca_conio__wscroll;
  541. /** \defgroup conio libcaca DOS conio.h compatibility layer
  542. *
  543. * These functions implement DOS-like functions for high-level text
  544. * operations.
  545. *
  546. * @{ */
  547. __extern char * caca_conio_cgets(char *str);
  548. __extern void caca_conio_clreol(void);
  549. __extern void caca_conio_clrscr(void);
  550. __extern int caca_conio_cprintf(const char *format, ...);
  551. __extern int caca_conio_cputs(const char *str);
  552. __extern int caca_conio_cscanf(char *format, ...);
  553. __extern void caca_conio_delay(unsigned int);
  554. __extern void caca_conio_delline(void);
  555. __extern int caca_conio_getch(void);
  556. __extern int caca_conio_getche(void);
  557. __extern char * caca_conio_getpass(const char *prompt);
  558. __extern int caca_conio_gettext(int left, int top, int right, int bottom,
  559. void *destin);
  560. __extern void caca_conio_gettextinfo(struct caca_conio_text_info *r);
  561. __extern void caca_conio_gotoxy(int x, int y);
  562. __extern void caca_conio_highvideo(void);
  563. __extern void caca_conio_insline(void);
  564. __extern int caca_conio_kbhit(void);
  565. __extern void caca_conio_lowvideo(void);
  566. __extern int caca_conio_movetext(int left, int top, int right, int bottom,
  567. int destleft, int desttop);
  568. __extern void caca_conio_normvideo(void);
  569. __extern void caca_conio_nosound(void);
  570. __extern int caca_conio_printf(const char *format, ...);
  571. __extern int caca_conio_putch(int ch);
  572. __extern int caca_conio_puttext(int left, int top, int right, int bottom,
  573. void *destin);
  574. __extern void caca_conio__setcursortype(int cur_t);
  575. __extern void caca_conio_sleep(unsigned int);
  576. __extern void caca_conio_sound(unsigned int);
  577. __extern void caca_conio_textattr(int newattr);
  578. __extern void caca_conio_textbackground(int newcolor);
  579. __extern void caca_conio_textcolor(int newcolor);
  580. __extern void caca_conio_textmode(int newmode);
  581. __extern int caca_conio_ungetch(int ch);
  582. __extern int caca_conio_wherex(void);
  583. __extern int caca_conio_wherey(void);
  584. __extern void caca_conio_window(int left, int top, int right, int bottom);
  585. /* @} */
  586. #if !defined(_DOXYGEN_SKIP_ME)
  587. /* Legacy stuff from beta versions, will probably disappear in 1.0 */
  588. typedef struct cucul_buffer cucul_buffer_t;
  589. # if defined __GNUC__ && __GNUC__ >= 3
  590. # define CACA_DEPRECATED __attribute__ ((__deprecated__))
  591. # define CACA_ALIAS(x) __attribute__ ((weak, alias(#x)))
  592. # else
  593. # define CACA_DEPRECATED
  594. # define CACA_ALIAS(x)
  595. # endif
  596. /* Aliases from old libcaca and libcucul functions */
  597. __extern int cucul_putchar(caca_canvas_t *, int, int,
  598. unsigned long int) CACA_DEPRECATED;
  599. __extern unsigned long int cucul_getchar(caca_canvas_t *,
  600. int, int) CACA_DEPRECATED;
  601. __extern int cucul_putstr(caca_canvas_t *, int, int,
  602. char const *) CACA_DEPRECATED;
  603. __extern int cucul_set_color(caca_canvas_t *, unsigned char,
  604. unsigned char) CACA_DEPRECATED;
  605. __extern int cucul_set_truecolor(caca_canvas_t *, unsigned int,
  606. unsigned int) CACA_DEPRECATED;
  607. __extern unsigned int cucul_get_canvas_frame_count(caca_canvas_t *)
  608. CACA_DEPRECATED;
  609. __extern int cucul_set_canvas_frame(caca_canvas_t *,
  610. unsigned int) CACA_DEPRECATED;
  611. __extern int cucul_create_canvas_frame(caca_canvas_t *,
  612. unsigned int) CACA_DEPRECATED;
  613. __extern int cucul_free_canvas_frame(caca_canvas_t *,
  614. unsigned int) CACA_DEPRECATED;
  615. __extern cucul_buffer_t *cucul_load_memory(void *,
  616. unsigned long int) CACA_DEPRECATED;
  617. __extern cucul_buffer_t *cucul_load_file(char const *) CACA_DEPRECATED;
  618. __extern unsigned long int cucul_get_buffer_size(cucul_buffer_t *)
  619. CACA_DEPRECATED;
  620. __extern void * cucul_get_buffer_data(cucul_buffer_t *) CACA_DEPRECATED;
  621. __extern int cucul_free_buffer(cucul_buffer_t *) CACA_DEPRECATED;
  622. __extern cucul_buffer_t * cucul_export_canvas(caca_canvas_t *,
  623. char const *) CACA_DEPRECATED;
  624. __extern caca_canvas_t * cucul_import_canvas(cucul_buffer_t *,
  625. char const *) CACA_DEPRECATED;
  626. __extern ssize_t caca_import_memory(caca_canvas_t *, void const *, size_t,
  627. char const *) CACA_DEPRECATED;
  628. __extern ssize_t caca_import_file(caca_canvas_t *, char const *,
  629. char const *) CACA_DEPRECATED;
  630. __extern void *caca_export_memory(caca_canvas_t const *, char const *,
  631. size_t *) CACA_DEPRECATED;
  632. __extern int cucul_rotate(caca_canvas_t *) CACA_DEPRECATED;
  633. __extern int cucul_set_dither_invert(caca_dither_t *, int) CACA_DEPRECATED;
  634. __extern int cucul_set_dither_mode(caca_dither_t *,
  635. char const *) CACA_DEPRECATED;
  636. __extern char const * const * cucul_get_dither_mode_list(caca_dither_t const *)
  637. CACA_DEPRECATED;
  638. # define CUCUL_COLOR_BLACK CACA_BLACK
  639. # define CUCUL_COLOR_BLUE CACA_BLUE
  640. # define CUCUL_COLOR_GREEN CACA_GREEN
  641. # define CUCUL_COLOR_CYAN CACA_CYAN
  642. # define CUCUL_COLOR_RED CACA_RED
  643. # define CUCUL_COLOR_MAGENTA CACA_MAGENTA
  644. # define CUCUL_COLOR_BROWN CACA_BROWN
  645. # define CUCUL_COLOR_LIGHTGRAY CACA_LIGHTGRAY
  646. # define CUCUL_COLOR_DARKGRAY CACA_DARKGRAY
  647. # define CUCUL_COLOR_LIGHTBLUE CACA_LIGHTBLUE
  648. # define CUCUL_COLOR_LIGHTGREEN CACA_LIGHTGREEN
  649. # define CUCUL_COLOR_LIGHTCYAN CACA_LIGHTCYAN
  650. # define CUCUL_COLOR_LIGHTRED CACA_LIGHTRED
  651. # define CUCUL_COLOR_LIGHTMAGENTA CACA_LIGHTMAGENTA
  652. # define CUCUL_COLOR_YELLOW CACA_YELLOW
  653. # define CUCUL_COLOR_WHITE CACA_YELLOW
  654. # define CUCUL_COLOR_DEFAULT CACA_DEFAULT
  655. # define CUCUL_COLOR_TRANSPARENT CACA_TRANSPARENT
  656. /* Aliases from the libcucul/libcaca merge */
  657. # define cucul_canvas_t caca_canvas_t
  658. # define cucul_dither_t caca_dither_t
  659. # define cucul_font_t caca_font_t
  660. # define cucul_file_t caca_file_t
  661. # define cucul_display_t caca_display_t
  662. # define cucul_event_t caca_event_t
  663. # define CUCUL_BLACK CACA_BLACK
  664. # define CUCUL_BLUE CACA_BLUE
  665. # define CUCUL_GREEN CACA_GREEN
  666. # define CUCUL_CYAN CACA_CYAN
  667. # define CUCUL_RED CACA_RED
  668. # define CUCUL_MAGENTA CACA_MAGENTA
  669. # define CUCUL_BROWN CACA_BROWN
  670. # define CUCUL_LIGHTGRAY CACA_LIGHTGRAY
  671. # define CUCUL_DARKGRAY CACA_DARKGRAY
  672. # define CUCUL_LIGHTBLUE CACA_LIGHTBLUE
  673. # define CUCUL_LIGHTGREEN CACA_LIGHTGREEN
  674. # define CUCUL_LIGHTCYAN CACA_LIGHTCYAN
  675. # define CUCUL_LIGHTRED CACA_LIGHTRED
  676. # define CUCUL_LIGHTMAGENTA CACA_LIGHTMAGENTA
  677. # define CUCUL_YELLOW CACA_YELLOW
  678. # define CUCUL_WHITE CACA_YELLOW
  679. # define CUCUL_DEFAULT CACA_DEFAULT
  680. # define CUCUL_TRANSPARENT CACA_TRANSPARENT
  681. # define CUCUL_BOLD CACA_BOLD
  682. # define CUCUL_ITALICS CACA_ITALICS
  683. # define CUCUL_UNDERLINE CACA_UNDERLINE
  684. # define CUCUL_BLINK CACA_BLINK
  685. # if !defined __LIBCACA__
  686. # define caca_get_cursor_x caca_wherex
  687. # define caca_get_cursor_y caca_wherey
  688. # define cucul_draw_triangle caca_draw_triangle
  689. # define cucul_draw_thin_triangle caca_draw_thin_triangle
  690. # define cucul_fill_triangle caca_fill_triangle
  691. # define cucul_load_font caca_load_font
  692. # define cucul_get_font_list caca_get_font_list
  693. # define cucul_get_font_width caca_get_font_width
  694. # define cucul_get_font_height caca_get_font_height
  695. # define cucul_get_font_blocks caca_get_font_blocks
  696. # define cucul_render_canvas caca_render_canvas
  697. # define cucul_free_font caca_free_font
  698. # define cucul_gotoxy caca_gotoxy
  699. # define cucul_get_cursor_x caca_wherex
  700. # define cucul_get_cursor_y caca_wherey
  701. # define cucul_put_char caca_put_char
  702. # define cucul_get_char caca_get_char
  703. # define cucul_put_str caca_put_str
  704. # define cucul_printf caca_printf
  705. # define cucul_clear_canvas caca_clear_canvas
  706. # define cucul_set_canvas_handle caca_set_canvas_handle
  707. # define cucul_get_canvas_handle_x caca_get_canvas_handle_x
  708. # define cucul_get_canvas_handle_y caca_get_canvas_handle_y
  709. # define cucul_blit caca_blit
  710. # define cucul_set_canvas_boundaries caca_set_canvas_boundaries
  711. # define cucul_import_memory caca_import_memory
  712. # define cucul_import_file caca_import_file
  713. # define cucul_get_import_list caca_get_import_list
  714. # define cucul_create_canvas caca_create_canvas
  715. # define cucul_manage_canvas caca_manage_canvas
  716. # define cucul_unmanage_canvas caca_unmanage_canvas
  717. # define cucul_set_canvas_size caca_set_canvas_size
  718. # define cucul_get_canvas_width caca_get_canvas_width
  719. # define cucul_get_canvas_height caca_get_canvas_height
  720. # define cucul_get_canvas_chars caca_get_canvas_chars
  721. # define cucul_get_canvas_attrs caca_get_canvas_attrs
  722. # define cucul_free_canvas caca_free_canvas
  723. # define cucul_rand caca_rand
  724. # define cucul_export_memory caca_export_memory
  725. # define cucul_get_export_list caca_get_export_list
  726. # define cucul_get_version caca_get_version
  727. # define cucul_utf8_to_utf32 caca_utf8_to_utf32
  728. # define cucul_utf32_to_utf8 caca_utf32_to_utf8
  729. # define cucul_utf32_to_cp437 caca_utf32_to_cp437
  730. # define cucul_cp437_to_utf32 caca_cp437_to_utf32
  731. # define cucul_utf32_to_ascii caca_utf32_to_ascii
  732. # define cucul_utf32_is_fullwidth caca_utf32_is_fullwidth
  733. # define cucul_draw_circle caca_draw_circle
  734. # define cucul_draw_ellipse caca_draw_ellipse
  735. # define cucul_draw_thin_ellipse caca_draw_thin_ellipse
  736. # define cucul_fill_ellipse caca_fill_ellipse
  737. # define cucul_canvas_set_figfont caca_canvas_set_figfont
  738. # define cucul_put_figchar caca_put_figchar
  739. # define cucul_flush_figlet caca_flush_figlet
  740. # define cucul_putchar caca_putchar
  741. # define cucul_getchar caca_getchar
  742. # define cucul_get_attr caca_get_attr
  743. # define cucul_set_attr caca_set_attr
  744. # define cucul_put_attr caca_put_attr
  745. # define cucul_set_color_ansi caca_set_color_ansi
  746. # define cucul_set_color_argb caca_set_color_argb
  747. # define cucul_attr_to_ansi caca_attr_to_ansi
  748. # define cucul_attr_to_ansi_fg caca_attr_to_ansi_fg
  749. # define cucul_attr_to_ansi_bg caca_attr_to_ansi_bg
  750. # define cucul_attr_to_rgb12_fg caca_attr_to_rgb12_fg
  751. # define cucul_attr_to_rgb12_bg caca_attr_to_rgb12_bg
  752. # define cucul_attr_to_argb64 caca_attr_to_argb64
  753. # define cucul_invert caca_invert
  754. # define cucul_flip caca_flip
  755. # define cucul_flop caca_flop
  756. # define cucul_rotate_180 caca_rotate_180
  757. # define cucul_rotate_left caca_rotate_left
  758. # define cucul_rotate_right caca_rotate_right
  759. # define cucul_stretch_left caca_stretch_left
  760. # define cucul_stretch_right caca_stretch_right
  761. # define cucul_file_open caca_file_open
  762. # define cucul_file_close caca_file_close
  763. # define cucul_file_tell caca_file_tell
  764. # define cucul_file_read caca_file_read
  765. # define cucul_file_write caca_file_write
  766. # define cucul_file_gets caca_file_gets
  767. # define cucul_file_eof caca_file_eof
  768. # define cucul_create_dither caca_create_dither
  769. # define cucul_set_dither_palette caca_set_dither_palette
  770. # define cucul_set_dither_brightness caca_set_dither_brightness
  771. # define cucul_get_dither_brightness caca_get_dither_brightness
  772. # define cucul_set_dither_gamma caca_set_dither_gamma
  773. # define cucul_get_dither_gamma caca_get_dither_gamma
  774. # define cucul_set_dither_contrast caca_set_dither_contrast
  775. # define cucul_get_dither_contrast caca_get_dither_contrast
  776. # define cucul_set_dither_antialias caca_set_dither_antialias
  777. # define cucul_get_dither_antialias_list caca_get_dither_antialias_list
  778. # define cucul_get_dither_antialias caca_get_dither_antialias
  779. # define cucul_set_dither_color caca_set_dither_color
  780. # define cucul_get_dither_color_list caca_get_dither_color_list
  781. # define cucul_get_dither_color caca_get_dither_color
  782. # define cucul_set_dither_charset caca_set_dither_charset
  783. # define cucul_get_dither_charset_list caca_get_dither_charset_list
  784. # define cucul_get_dither_charset caca_get_dither_charset
  785. # define cucul_set_dither_algorithm caca_set_dither_algorithm
  786. # define cucul_get_dither_algorithm_list caca_get_dither_algorithm_list
  787. # define cucul_get_dither_algorithm caca_get_dither_algorithm
  788. # define cucul_dither_bitmap caca_dither_bitmap
  789. # define cucul_free_dither caca_free_dither
  790. # define cucul_draw_line caca_draw_line
  791. # define cucul_draw_polyline caca_draw_polyline
  792. # define cucul_draw_thin_line caca_draw_thin_line
  793. # define cucul_draw_thin_polyline caca_draw_thin_polyline
  794. # define cucul_draw_box caca_draw_box
  795. # define cucul_draw_thin_box caca_draw_thin_box
  796. # define cucul_draw_cp437_box caca_draw_cp437_box
  797. # define cucul_fill_box caca_fill_box
  798. # define cucul_get_frame_count caca_get_frame_count
  799. # define cucul_set_frame caca_set_frame
  800. # define cucul_get_frame_name caca_get_frame_name
  801. # define cucul_set_frame_name caca_set_frame_name
  802. # define cucul_create_frame caca_create_frame
  803. # define cucul_free_frame caca_free_frame
  804. # endif
  805. #endif
  806. #ifdef __cplusplus
  807. }
  808. #endif
  809. #undef __extern
  810. #endif /* __CACA_H__ */