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.
 
 
 
 
 
 

723 line
28 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright © 2002—2018 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * This library is free software. It comes without any warranty, to
  7. * the extent permitted by applicable law. You can redistribute it
  8. * and/or modify it under the terms of the Do What the Fuck You Want
  9. * to Public License, Version 2, as published by Sam Hocevar. See
  10. * http://www.wtfpl.net/ for more details.
  11. */
  12. /** \file caca.h
  13. * \author Sam Hocevar <sam@hocevar.net>
  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. #ifndef __CACA_H__
  20. #define __CACA_H__
  21. #include <caca_types.h>
  22. #if !defined(__KERNEL__)
  23. # include <stdarg.h>
  24. #endif
  25. #undef __extern
  26. #if defined _DOXYGEN_SKIP_ME
  27. #elif defined _WIN32 && defined __LIBCACA__ && defined DLL_EXPORT
  28. # define __extern extern __declspec(dllexport)
  29. #elif defined _WIN32 && !defined __LIBCACA__ && !defined CACA_STATIC
  30. # define __extern extern __declspec(dllimport)
  31. #elif defined CACA_ENABLE_VISIBILITY
  32. # define __extern extern __attribute__((visibility("default")))
  33. #else
  34. # define __extern extern
  35. #endif
  36. /** libcaca API version */
  37. #define CACA_API_VERSION_1
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. /** \e libcaca canvas */
  43. typedef struct caca_canvas caca_canvas_t;
  44. /** dither structure */
  45. typedef struct caca_dither caca_dither_t;
  46. /** character font structure */
  47. typedef struct caca_charfont caca_charfont_t;
  48. /** bitmap font structure */
  49. typedef struct caca_font caca_font_t;
  50. /** file handle structure */
  51. typedef struct caca_file caca_file_t;
  52. /** \e libcaca display context */
  53. typedef struct caca_display caca_display_t;
  54. /** \e libcaca event structure */
  55. typedef struct caca_event caca_event_t;
  56. /** \defgroup caca_attr libcaca attribute definitions
  57. *
  58. * Colours and styles that can be used with caca_set_attr().
  59. *
  60. * @{ */
  61. /** \e libcaca colour keyword */
  62. enum caca_color
  63. {
  64. CACA_BLACK = 0x00, /**< The colour index for black. */
  65. CACA_BLUE = 0x01, /**< The colour index for blue. */
  66. CACA_GREEN = 0x02, /**< The colour index for green. */
  67. CACA_CYAN = 0x03, /**< The colour index for cyan. */
  68. CACA_RED = 0x04, /**< The colour index for red. */
  69. CACA_MAGENTA = 0x05, /**< The colour index for magenta. */
  70. CACA_BROWN = 0x06, /**< The colour index for brown. */
  71. CACA_LIGHTGRAY = 0x07, /**< The colour index for light gray. */
  72. CACA_DARKGRAY = 0x08, /**< The colour index for dark gray. */
  73. CACA_LIGHTBLUE = 0x09, /**< The colour index for blue. */
  74. CACA_LIGHTGREEN = 0x0a, /**< The colour index for light green. */
  75. CACA_LIGHTCYAN = 0x0b, /**< The colour index for light cyan. */
  76. CACA_LIGHTRED = 0x0c, /**< The colour index for light red. */
  77. CACA_LIGHTMAGENTA = 0x0d, /**< The colour index for light magenta. */
  78. CACA_YELLOW = 0x0e, /**< The colour index for yellow. */
  79. CACA_WHITE = 0x0f, /**< The colour index for white. */
  80. CACA_DEFAULT = 0x10, /**< The output driver's default colour. */
  81. CACA_TRANSPARENT = 0x20, /**< The transparent colour. */
  82. };
  83. /** \e libcaca style keyword */
  84. enum caca_style
  85. {
  86. CACA_BOLD = 0x01, /**< The style mask for bold. */
  87. CACA_ITALICS = 0x02, /**< The style mask for italics. */
  88. CACA_UNDERLINE = 0x04, /**< The style mask for underline. */
  89. CACA_BLINK = 0x08, /**< The style mask for blink. */
  90. };
  91. /* @} */
  92. /** \brief User event type enumeration.
  93. *
  94. * This enum serves two purposes:
  95. * - Build listening masks for caca_get_event().
  96. * - Define the type of a \e caca_event_t.
  97. */
  98. enum caca_event_type
  99. {
  100. CACA_EVENT_NONE = 0x0000, /**< No event. */
  101. CACA_EVENT_KEY_PRESS = 0x0001, /**< A key was pressed. */
  102. CACA_EVENT_KEY_RELEASE = 0x0002, /**< A key was released. */
  103. CACA_EVENT_MOUSE_PRESS = 0x0004, /**< A mouse button was pressed. */
  104. CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
  105. CACA_EVENT_MOUSE_MOTION = 0x0010, /**< The mouse was moved. */
  106. CACA_EVENT_RESIZE = 0x0020, /**< The window was resized. */
  107. CACA_EVENT_QUIT = 0x0040, /**< The user requested to quit. */
  108. CACA_EVENT_ANY = 0xffff /**< Bitmask for any event. */
  109. };
  110. /** \brief Handling of user events.
  111. *
  112. * This structure is filled by caca_get_event() when an event is received.
  113. * It is an opaque structure that should only be accessed through
  114. * caca_event_get_type() and similar functions. The struct members may no
  115. * longer be directly accessible in future versions.
  116. */
  117. struct caca_event
  118. {
  119. enum caca_event_type type; /**< The event type. */
  120. union
  121. {
  122. struct { int x, y, button; } mouse;
  123. struct { int w, h; } resize;
  124. struct { int ch; uint32_t utf32; char utf8[8]; } key;
  125. } data; /**< The event information data */
  126. #if !defined(_DOXYGEN_SKIP_ME)
  127. uint8_t padding[16];
  128. #endif
  129. };
  130. /** \brief Option parsing.
  131. *
  132. * This structure contains commandline parsing information for systems
  133. * where getopt_long() is unavailable.
  134. */
  135. struct caca_option
  136. {
  137. char const *name;
  138. int has_arg;
  139. int *flag;
  140. int val;
  141. };
  142. /** \brief Special key values.
  143. *
  144. * Special key values returned by caca_get_event() for which there is no
  145. * printable ASCII equivalent.
  146. */
  147. enum caca_key
  148. {
  149. CACA_KEY_UNKNOWN = 0x00, /**< Unknown key. */
  150. /* The following keys have ASCII equivalents */
  151. CACA_KEY_CTRL_A = 0x01, /**< The Ctrl-A key. */
  152. CACA_KEY_CTRL_B = 0x02, /**< The Ctrl-B key. */
  153. CACA_KEY_CTRL_C = 0x03, /**< The Ctrl-C key. */
  154. CACA_KEY_CTRL_D = 0x04, /**< The Ctrl-D key. */
  155. CACA_KEY_CTRL_E = 0x05, /**< The Ctrl-E key. */
  156. CACA_KEY_CTRL_F = 0x06, /**< The Ctrl-F key. */
  157. CACA_KEY_CTRL_G = 0x07, /**< The Ctrl-G key. */
  158. CACA_KEY_BACKSPACE = 0x08, /**< The backspace key. */
  159. CACA_KEY_TAB = 0x09, /**< The tabulation key. */
  160. CACA_KEY_CTRL_J = 0x0a, /**< The Ctrl-J key. */
  161. CACA_KEY_CTRL_K = 0x0b, /**< The Ctrl-K key. */
  162. CACA_KEY_CTRL_L = 0x0c, /**< The Ctrl-L key. */
  163. CACA_KEY_RETURN = 0x0d, /**< The return key. */
  164. CACA_KEY_CTRL_N = 0x0e, /**< The Ctrl-N key. */
  165. CACA_KEY_CTRL_O = 0x0f, /**< The Ctrl-O key. */
  166. CACA_KEY_CTRL_P = 0x10, /**< The Ctrl-P key. */
  167. CACA_KEY_CTRL_Q = 0x11, /**< The Ctrl-Q key. */
  168. CACA_KEY_CTRL_R = 0x12, /**< The Ctrl-R key. */
  169. CACA_KEY_PAUSE = 0x13, /**< The pause key. */
  170. CACA_KEY_CTRL_T = 0x14, /**< The Ctrl-T key. */
  171. CACA_KEY_CTRL_U = 0x15, /**< The Ctrl-U key. */
  172. CACA_KEY_CTRL_V = 0x16, /**< The Ctrl-V key. */
  173. CACA_KEY_CTRL_W = 0x17, /**< The Ctrl-W key. */
  174. CACA_KEY_CTRL_X = 0x18, /**< The Ctrl-X key. */
  175. CACA_KEY_CTRL_Y = 0x19, /**< The Ctrl-Y key. */
  176. CACA_KEY_CTRL_Z = 0x1a, /**< The Ctrl-Z key. */
  177. CACA_KEY_ESCAPE = 0x1b, /**< The escape key. */
  178. CACA_KEY_DELETE = 0x7f, /**< The delete key. */
  179. /* The following keys do not have ASCII equivalents but have been
  180. * chosen to match the SDL equivalents */
  181. CACA_KEY_UP = 0x111, /**< The up arrow key. */
  182. CACA_KEY_DOWN = 0x112, /**< The down arrow key. */
  183. CACA_KEY_LEFT = 0x113, /**< The left arrow key. */
  184. CACA_KEY_RIGHT = 0x114, /**< The right arrow key. */
  185. CACA_KEY_INSERT = 0x115, /**< The insert key. */
  186. CACA_KEY_HOME = 0x116, /**< The home key. */
  187. CACA_KEY_END = 0x117, /**< The end key. */
  188. CACA_KEY_PAGEUP = 0x118, /**< The page up key. */
  189. CACA_KEY_PAGEDOWN = 0x119, /**< The page down key. */
  190. CACA_KEY_F1 = 0x11a, /**< The F1 key. */
  191. CACA_KEY_F2 = 0x11b, /**< The F2 key. */
  192. CACA_KEY_F3 = 0x11c, /**< The F3 key. */
  193. CACA_KEY_F4 = 0x11d, /**< The F4 key. */
  194. CACA_KEY_F5 = 0x11e, /**< The F5 key. */
  195. CACA_KEY_F6 = 0x11f, /**< The F6 key. */
  196. CACA_KEY_F7 = 0x120, /**< The F7 key. */
  197. CACA_KEY_F8 = 0x121, /**< The F8 key. */
  198. CACA_KEY_F9 = 0x122, /**< The F9 key. */
  199. CACA_KEY_F10 = 0x123, /**< The F10 key. */
  200. CACA_KEY_F11 = 0x124, /**< The F11 key. */
  201. CACA_KEY_F12 = 0x125, /**< The F12 key. */
  202. CACA_KEY_F13 = 0x126, /**< The F13 key. */
  203. CACA_KEY_F14 = 0x127, /**< The F14 key. */
  204. CACA_KEY_F15 = 0x128 /**< The F15 key. */
  205. };
  206. /** \defgroup libcaca libcaca basic functions
  207. *
  208. * These functions provide the basic \e libcaca routines for library
  209. * initialisation, system information retrieval and configuration.
  210. *
  211. * @{ */
  212. __extern caca_canvas_t * caca_create_canvas(int, int);
  213. __extern int caca_manage_canvas(caca_canvas_t *, int (*)(void *), void *);
  214. __extern int caca_unmanage_canvas(caca_canvas_t *, int (*)(void *), void *);
  215. __extern int caca_set_canvas_size(caca_canvas_t *, int, int);
  216. __extern int caca_get_canvas_width(caca_canvas_t const *);
  217. __extern int caca_get_canvas_height(caca_canvas_t const *);
  218. __extern uint32_t const * caca_get_canvas_chars(caca_canvas_t const *);
  219. __extern uint32_t const * caca_get_canvas_attrs(caca_canvas_t const *);
  220. __extern int caca_free_canvas(caca_canvas_t *);
  221. __extern int caca_rand(int, int);
  222. __extern char const * caca_get_version(void);
  223. /* @} */
  224. /** \defgroup caca_canvas libcaca canvas drawing
  225. *
  226. * These functions provide low-level character printing routines and
  227. * higher level graphics functions.
  228. *
  229. * @{ */
  230. #define CACA_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */
  231. __extern int caca_gotoxy(caca_canvas_t *, int, int);
  232. __extern int caca_wherex(caca_canvas_t const *);
  233. __extern int caca_wherey(caca_canvas_t const *);
  234. __extern int caca_put_char(caca_canvas_t *, int, int, uint32_t);
  235. __extern uint32_t caca_get_char(caca_canvas_t const *, int, int);
  236. __extern int caca_put_str(caca_canvas_t *, int, int, char const *);
  237. __extern int caca_printf(caca_canvas_t *, int, int, char const *, ...);
  238. __extern int caca_vprintf(caca_canvas_t *, int, int, char const *, va_list);
  239. __extern int caca_clear_canvas(caca_canvas_t *);
  240. __extern int caca_set_canvas_handle(caca_canvas_t *, int, int);
  241. __extern int caca_get_canvas_handle_x(caca_canvas_t const *);
  242. __extern int caca_get_canvas_handle_y(caca_canvas_t const *);
  243. __extern int caca_blit(caca_canvas_t *, int, int, caca_canvas_t const *,
  244. caca_canvas_t const *);
  245. __extern int caca_set_canvas_boundaries(caca_canvas_t *, int, int, int, int);
  246. /* @} */
  247. /** \defgroup caca_dirty libcaca dirty rectangle manipulation
  248. *
  249. * These functions manipulate dirty rectangles for optimised blitting.
  250. * @{ */
  251. __extern int caca_disable_dirty_rect(caca_canvas_t *);
  252. __extern int caca_enable_dirty_rect(caca_canvas_t *);
  253. __extern int caca_get_dirty_rect_count(caca_canvas_t *);
  254. __extern int caca_get_dirty_rect(caca_canvas_t *, int, int *, int *,
  255. int *, int *);
  256. __extern int caca_add_dirty_rect(caca_canvas_t *, int, int, int, int);
  257. __extern int caca_remove_dirty_rect(caca_canvas_t *, int, int, int, int);
  258. __extern int caca_clear_dirty_rect_list(caca_canvas_t *);
  259. /* @} */
  260. /** \defgroup caca_transform libcaca canvas transformation
  261. *
  262. * These functions perform horizontal and vertical canvas flipping.
  263. *
  264. * @{ */
  265. __extern int caca_invert(caca_canvas_t *);
  266. __extern int caca_flip(caca_canvas_t *);
  267. __extern int caca_flop(caca_canvas_t *);
  268. __extern int caca_rotate_180(caca_canvas_t *);
  269. __extern int caca_rotate_left(caca_canvas_t *);
  270. __extern int caca_rotate_right(caca_canvas_t *);
  271. __extern int caca_stretch_left(caca_canvas_t *);
  272. __extern int caca_stretch_right(caca_canvas_t *);
  273. /* @} */
  274. /** \defgroup caca_attributes libcaca attribute conversions
  275. *
  276. * These functions perform conversions between attribute values.
  277. *
  278. * @{ */
  279. __extern uint32_t caca_get_attr(caca_canvas_t const *, int, int);
  280. __extern int caca_set_attr(caca_canvas_t *, uint32_t);
  281. __extern int caca_unset_attr(caca_canvas_t *, uint32_t);
  282. __extern int caca_toggle_attr(caca_canvas_t *, uint32_t);
  283. __extern int caca_put_attr(caca_canvas_t *, int, int, uint32_t);
  284. __extern int caca_set_color_ansi(caca_canvas_t *, uint8_t, uint8_t);
  285. __extern int caca_set_color_argb(caca_canvas_t *, uint16_t, uint16_t);
  286. __extern uint8_t caca_attr_to_ansi(uint32_t);
  287. __extern uint8_t caca_attr_to_ansi_fg(uint32_t);
  288. __extern uint8_t caca_attr_to_ansi_bg(uint32_t);
  289. __extern uint16_t caca_attr_to_rgb12_fg(uint32_t);
  290. __extern uint16_t caca_attr_to_rgb12_bg(uint32_t);
  291. __extern void caca_attr_to_argb64(uint32_t, uint8_t[8]);
  292. /* @} */
  293. /** \defgroup caca_charset libcaca character set conversions
  294. *
  295. * These functions perform conversions between usual character sets.
  296. *
  297. * @{ */
  298. __extern uint32_t caca_utf8_to_utf32(char const *, size_t *);
  299. __extern size_t caca_utf32_to_utf8(char *, uint32_t);
  300. __extern uint8_t caca_utf32_to_cp437(uint32_t);
  301. __extern uint32_t caca_cp437_to_utf32(uint8_t);
  302. __extern char caca_utf32_to_ascii(uint32_t);
  303. __extern int caca_utf32_is_fullwidth(uint32_t);
  304. /* @} */
  305. /** \defgroup caca_primitives libcaca primitives drawing
  306. *
  307. * These functions provide routines for primitive drawing, such as lines,
  308. * boxes, triangles and ellipses.
  309. *
  310. * @{ */
  311. __extern int caca_draw_line(caca_canvas_t *, int, int, int, int, uint32_t);
  312. __extern int caca_draw_polyline(caca_canvas_t *, int const x[],
  313. int const y[], int, uint32_t);
  314. __extern int caca_draw_thin_line(caca_canvas_t *, int, int, int, int);
  315. __extern int caca_draw_thin_polyline(caca_canvas_t *, int const x[],
  316. int const y[], int);
  317. __extern int caca_draw_circle(caca_canvas_t *, int, int, int, uint32_t);
  318. __extern int caca_draw_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
  319. __extern int caca_draw_thin_ellipse(caca_canvas_t *, int, int, int, int);
  320. __extern int caca_fill_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
  321. __extern int caca_draw_box(caca_canvas_t *, int, int, int, int, uint32_t);
  322. __extern int caca_draw_thin_box(caca_canvas_t *, int, int, int, int);
  323. __extern int caca_draw_cp437_box(caca_canvas_t *, int, int, int, int);
  324. __extern int caca_fill_box(caca_canvas_t *, int, int, int, int, uint32_t);
  325. __extern int caca_draw_triangle(caca_canvas_t *, int, int, int, int, int,
  326. int, uint32_t);
  327. __extern int caca_draw_thin_triangle(caca_canvas_t *, int, int, int, int,
  328. int, int);
  329. __extern int caca_fill_triangle(caca_canvas_t *, int, int, int, int, int,
  330. int, uint32_t);
  331. __extern int caca_fill_triangle_textured(caca_canvas_t *cv,
  332. int coords[6],
  333. caca_canvas_t *tex,
  334. float uv[6]);
  335. /* @} */
  336. /** \defgroup caca_frame libcaca canvas frame handling
  337. *
  338. * These functions provide high level routines for canvas frame insertion,
  339. * removal, copying etc.
  340. *
  341. * @{ */
  342. __extern int caca_get_frame_count(caca_canvas_t const *);
  343. __extern int caca_set_frame(caca_canvas_t *, int);
  344. __extern char const *caca_get_frame_name(caca_canvas_t const *);
  345. __extern int caca_set_frame_name(caca_canvas_t *, char const *);
  346. __extern int caca_create_frame(caca_canvas_t *, int);
  347. __extern int caca_free_frame(caca_canvas_t *, int);
  348. /* @} */
  349. /** \defgroup caca_dither libcaca bitmap dithering
  350. *
  351. * These functions provide high level routines for dither allocation and
  352. * rendering.
  353. *
  354. * @{ */
  355. __extern caca_dither_t *caca_create_dither(int, int, int, int,
  356. uint32_t, uint32_t,
  357. uint32_t, uint32_t);
  358. __extern int caca_set_dither_palette(caca_dither_t *,
  359. uint32_t r[], uint32_t g[],
  360. uint32_t b[], uint32_t a[]);
  361. __extern int caca_set_dither_brightness(caca_dither_t *, float);
  362. __extern float caca_get_dither_brightness(caca_dither_t const *);
  363. __extern int caca_set_dither_gamma(caca_dither_t *, float);
  364. __extern float caca_get_dither_gamma(caca_dither_t const *);
  365. __extern int caca_set_dither_contrast(caca_dither_t *, float);
  366. __extern float caca_get_dither_contrast(caca_dither_t const *);
  367. __extern int caca_set_dither_antialias(caca_dither_t *, char const *);
  368. __extern char const * const * caca_get_dither_antialias_list(caca_dither_t
  369. const *);
  370. __extern char const * caca_get_dither_antialias(caca_dither_t const *);
  371. __extern int caca_set_dither_color(caca_dither_t *, char const *);
  372. __extern char const * const * caca_get_dither_color_list(caca_dither_t
  373. const *);
  374. __extern char const * caca_get_dither_color(caca_dither_t const *);
  375. __extern int caca_set_dither_charset(caca_dither_t *, char const *);
  376. __extern char const * const * caca_get_dither_charset_list(caca_dither_t
  377. const *);
  378. __extern char const * caca_get_dither_charset(caca_dither_t const *);
  379. __extern int caca_set_dither_algorithm(caca_dither_t *, char const *);
  380. __extern char const * const * caca_get_dither_algorithm_list(caca_dither_t
  381. const *);
  382. __extern char const * caca_get_dither_algorithm(caca_dither_t const *);
  383. __extern int caca_dither_bitmap(caca_canvas_t *, int, int, int, int,
  384. caca_dither_t const *, void const *);
  385. __extern int caca_free_dither(caca_dither_t *);
  386. /* @} */
  387. /** \defgroup caca_charfont libcaca character font handling
  388. *
  389. * These functions provide character font handling routines.
  390. *
  391. * @{ */
  392. __extern caca_charfont_t *caca_load_charfont(void const *, size_t);
  393. __extern int caca_free_charfont(caca_charfont_t *);
  394. /* @} */
  395. /** \defgroup caca_font libcaca bitmap font handling
  396. *
  397. * These functions provide bitmap font handling routines and high quality
  398. * canvas to bitmap rendering.
  399. *
  400. * @{ */
  401. __extern caca_font_t *caca_load_font(void const *, size_t);
  402. __extern char const * const * caca_get_font_list(void);
  403. __extern int caca_get_font_width(caca_font_t const *);
  404. __extern int caca_get_font_height(caca_font_t const *);
  405. __extern uint32_t const *caca_get_font_blocks(caca_font_t const *);
  406. __extern int caca_render_canvas(caca_canvas_t const *, caca_font_t const *,
  407. void *, int, int, int);
  408. __extern int caca_free_font(caca_font_t *);
  409. /* @} */
  410. /** \defgroup caca_figfont libcaca FIGfont handling
  411. *
  412. * These functions provide FIGlet and TOIlet font handling routines.
  413. *
  414. * @{ */
  415. __extern int caca_canvas_set_figfont(caca_canvas_t *, char const *);
  416. __extern int caca_set_figfont_smush(caca_canvas_t *, char const *);
  417. __extern int caca_set_figfont_width(caca_canvas_t *, int);
  418. __extern int caca_put_figchar(caca_canvas_t *, uint32_t);
  419. __extern int caca_flush_figlet(caca_canvas_t *);
  420. /* @} */
  421. /** \defgroup caca_file libcaca file IO
  422. *
  423. * These functions allow to read and write files in a platform-independent
  424. * way.
  425. * @{ */
  426. __extern caca_file_t *caca_file_open(char const *, const char *);
  427. __extern int caca_file_close(caca_file_t *);
  428. __extern uint64_t caca_file_tell(caca_file_t *);
  429. __extern size_t caca_file_read(caca_file_t *, void *, size_t);
  430. __extern size_t caca_file_write(caca_file_t *, const void *, size_t);
  431. __extern char * caca_file_gets(caca_file_t *, char *, int);
  432. __extern int caca_file_eof(caca_file_t *);
  433. /* @} */
  434. /** \defgroup caca_importexport libcaca importers/exporters from/to various
  435. * formats
  436. *
  437. * These functions import various file formats into a new canvas, or export
  438. * the current canvas to various text formats.
  439. *
  440. * @{ */
  441. __extern ssize_t caca_import_canvas_from_memory(caca_canvas_t *, void const *,
  442. size_t, char const *);
  443. __extern ssize_t caca_import_canvas_from_file(caca_canvas_t *, char const *,
  444. char const *);
  445. __extern ssize_t caca_import_area_from_memory(caca_canvas_t *, int, int,
  446. void const *, size_t,
  447. char const *);
  448. __extern ssize_t caca_import_area_from_file(caca_canvas_t *, int, int,
  449. char const *, char const *);
  450. __extern char const * const * caca_get_import_list(void);
  451. __extern void *caca_export_canvas_to_memory(caca_canvas_t const *,
  452. char const *, size_t *);
  453. __extern void *caca_export_area_to_memory(caca_canvas_t const *, int, int,
  454. int, int, char const *, size_t *);
  455. __extern char const * const * caca_get_export_list(void);
  456. /* @} */
  457. /** \defgroup caca_display libcaca display functions
  458. *
  459. * These functions provide the basic \e libcaca routines for display
  460. * initialisation, system information retrieval and configuration.
  461. *
  462. * @{ */
  463. __extern caca_display_t * caca_create_display(caca_canvas_t *);
  464. __extern caca_display_t * caca_create_display_with_driver(caca_canvas_t *,
  465. char const *);
  466. __extern char const * const * caca_get_display_driver_list(void);
  467. __extern char const * caca_get_display_driver(caca_display_t *);
  468. __extern int caca_set_display_driver(caca_display_t *, char const *);
  469. __extern int caca_free_display(caca_display_t *);
  470. __extern caca_canvas_t * caca_get_canvas(caca_display_t *);
  471. __extern int caca_refresh_display(caca_display_t *);
  472. __extern int caca_set_display_time(caca_display_t *, int);
  473. __extern int caca_get_display_time(caca_display_t const *);
  474. __extern int caca_get_display_width(caca_display_t const *);
  475. __extern int caca_get_display_height(caca_display_t const *);
  476. __extern int caca_set_display_title(caca_display_t *, char const *);
  477. __extern int caca_set_mouse(caca_display_t *, int);
  478. __extern int caca_set_cursor(caca_display_t *, int);
  479. /* @} */
  480. /** \defgroup caca_event libcaca event handling
  481. *
  482. * These functions handle user events such as keyboard input and mouse
  483. * clicks.
  484. *
  485. * @{ */
  486. __extern int caca_get_event(caca_display_t *, int, caca_event_t *, int);
  487. __extern int caca_get_mouse_x(caca_display_t const *);
  488. __extern int caca_get_mouse_y(caca_display_t const *);
  489. __extern enum caca_event_type caca_get_event_type(caca_event_t const *);
  490. __extern int caca_get_event_key_ch(caca_event_t const *);
  491. __extern uint32_t caca_get_event_key_utf32(caca_event_t const *);
  492. __extern int caca_get_event_key_utf8(caca_event_t const *, char *);
  493. __extern int caca_get_event_mouse_button(caca_event_t const *);
  494. __extern int caca_get_event_mouse_x(caca_event_t const *);
  495. __extern int caca_get_event_mouse_y(caca_event_t const *);
  496. __extern int caca_get_event_resize_width(caca_event_t const *);
  497. __extern int caca_get_event_resize_height(caca_event_t const *);
  498. /* @} */
  499. /** \defgroup caca_process libcaca process management
  500. *
  501. * These functions help with various process handling tasks such as
  502. * option parsing, DLL injection.
  503. *
  504. * @{ */
  505. __extern int caca_optind;
  506. __extern char *caca_optarg;
  507. __extern int caca_getopt(int, char * const[], char const *,
  508. struct caca_option const *, int *);
  509. /* @} */
  510. /** \brief DOS colours
  511. *
  512. * This enum lists the colour values for the DOS conio.h compatibility
  513. * layer.
  514. */
  515. enum CACA_CONIO_COLORS
  516. {
  517. CACA_CONIO_BLINK = 128,
  518. CACA_CONIO_BLACK = 0,
  519. CACA_CONIO_BLUE = 1,
  520. CACA_CONIO_GREEN = 2,
  521. CACA_CONIO_CYAN = 3,
  522. CACA_CONIO_RED = 4,
  523. CACA_CONIO_MAGENTA = 5,
  524. CACA_CONIO_BROWN = 6,
  525. CACA_CONIO_LIGHTGRAY = 7,
  526. CACA_CONIO_DARKGRAY = 8,
  527. CACA_CONIO_LIGHTBLUE = 9,
  528. CACA_CONIO_LIGHTGREEN = 10,
  529. CACA_CONIO_LIGHTCYAN = 11,
  530. CACA_CONIO_LIGHTRED = 12,
  531. CACA_CONIO_LIGHTMAGENTA = 13,
  532. CACA_CONIO_YELLOW = 14,
  533. CACA_CONIO_WHITE = 15,
  534. };
  535. /** \brief DOS cursor modes
  536. *
  537. * This enum lists the cursor mode values for the DOS conio.h compatibility
  538. * layer.
  539. */
  540. enum CACA_CONIO_CURSOR
  541. {
  542. CACA_CONIO__NOCURSOR = 0,
  543. CACA_CONIO__SOLIDCURSOR = 1,
  544. CACA_CONIO__NORMALCURSOR = 2,
  545. };
  546. /** \brief DOS video modes
  547. *
  548. * This enum lists the video mode values for the DOS conio.h compatibility
  549. * layer.
  550. */
  551. enum CACA_CONIO_MODE
  552. {
  553. CACA_CONIO_LASTMODE = -1,
  554. CACA_CONIO_BW40 = 0,
  555. CACA_CONIO_C40 = 1,
  556. CACA_CONIO_BW80 = 2,
  557. CACA_CONIO_C80 = 3,
  558. CACA_CONIO_MONO = 7,
  559. CACA_CONIO_C4350 = 64,
  560. };
  561. /** \brief DOS text area information
  562. *
  563. * This structure stores text area information for the DOS conio.h
  564. * compatibility layer.
  565. */
  566. struct caca_conio_text_info
  567. {
  568. unsigned char winleft; /**< left window coordinate */
  569. unsigned char wintop; /**< top window coordinate */
  570. unsigned char winright; /**< right window coordinate */
  571. unsigned char winbottom; /**< bottom window coordinate */
  572. unsigned char attribute; /**< text attribute */
  573. unsigned char normattr; /**< normal attribute */
  574. unsigned char currmode; /**< current video mode:
  575. BW40, BW80, C40, C80, or C4350 */
  576. unsigned char screenheight; /**< text screen's height */
  577. unsigned char screenwidth; /**< text screen's width */
  578. unsigned char curx; /**< x-coordinate in current window */
  579. unsigned char cury; /**< y-coordinate in current window */
  580. };
  581. /** \brief DOS direct video control */
  582. __extern int caca_conio_directvideo;
  583. /** \brief DOS scrolling control */
  584. __extern int caca_conio__wscroll;
  585. /** \defgroup conio libcaca DOS conio.h compatibility layer
  586. *
  587. * These functions implement DOS-like functions for high-level text
  588. * operations.
  589. *
  590. * @{ */
  591. __extern char * caca_conio_cgets(char *str);
  592. __extern void caca_conio_clreol(void);
  593. __extern void caca_conio_clrscr(void);
  594. __extern int caca_conio_cprintf(const char *format, ...);
  595. __extern int caca_conio_cputs(const char *str);
  596. __extern int caca_conio_cscanf(char *format, ...);
  597. __extern void caca_conio_delay(unsigned int);
  598. __extern void caca_conio_delline(void);
  599. __extern int caca_conio_getch(void);
  600. __extern int caca_conio_getche(void);
  601. __extern char * caca_conio_getpass(const char *prompt);
  602. __extern int caca_conio_gettext(int left, int top, int right, int bottom,
  603. void *destin);
  604. __extern void caca_conio_gettextinfo(struct caca_conio_text_info *r);
  605. __extern void caca_conio_gotoxy(int x, int y);
  606. __extern void caca_conio_highvideo(void);
  607. __extern void caca_conio_insline(void);
  608. __extern int caca_conio_kbhit(void);
  609. __extern void caca_conio_lowvideo(void);
  610. __extern int caca_conio_movetext(int left, int top, int right, int bottom,
  611. int destleft, int desttop);
  612. __extern void caca_conio_normvideo(void);
  613. __extern void caca_conio_nosound(void);
  614. __extern int caca_conio_printf(const char *format, ...);
  615. __extern int caca_conio_putch(int ch);
  616. __extern int caca_conio_puttext(int left, int top, int right, int bottom,
  617. void *destin);
  618. __extern void caca_conio__setcursortype(int cur_t);
  619. __extern void caca_conio_sleep(unsigned int);
  620. __extern void caca_conio_sound(unsigned int);
  621. __extern void caca_conio_textattr(int newattr);
  622. __extern void caca_conio_textbackground(int newcolor);
  623. __extern void caca_conio_textcolor(int newcolor);
  624. __extern void caca_conio_textmode(int newmode);
  625. __extern int caca_conio_ungetch(int ch);
  626. __extern int caca_conio_wherex(void);
  627. __extern int caca_conio_wherey(void);
  628. __extern void caca_conio_window(int left, int top, int right, int bottom);
  629. /* @} */
  630. #if !defined(_DOXYGEN_SKIP_ME)
  631. /* Legacy stuff from beta versions, will probably disappear in 1.0 */
  632. # if defined __GNUC__ && __GNUC__ >= 3
  633. # define CACA_DEPRECATED __attribute__ ((__deprecated__))
  634. # else
  635. # define CACA_DEPRECATED
  636. # endif
  637. # if defined __GNUC__ && __GNUC__ > 3 && !defined __APPLE__
  638. # define CACA_ALIAS(x) __attribute__ ((weak, alias(#x)))
  639. # else
  640. # define CACA_ALIAS(x)
  641. # endif
  642. # if defined __GNUC__ && __GNUC__ > 3
  643. # define CACA_WEAK __attribute__ ((weak))
  644. # else
  645. # define CACA_WEAK
  646. # endif
  647. /* Aliases from old libcaca functions */
  648. #if !defined _WIN32 || !defined __GNUC__
  649. __extern ssize_t caca_import_memory(caca_canvas_t *, void const *, size_t,
  650. char const *) CACA_DEPRECATED;
  651. __extern ssize_t caca_import_file(caca_canvas_t *, char const *,
  652. char const *) CACA_DEPRECATED;
  653. __extern void *caca_export_memory(caca_canvas_t const *, char const *,
  654. size_t *) CACA_DEPRECATED;
  655. #endif
  656. # if !defined __LIBCACA__
  657. # define caca_get_cursor_x caca_wherex
  658. # define caca_get_cursor_y caca_wherey
  659. # endif
  660. #endif
  661. #ifdef __cplusplus
  662. }
  663. #endif
  664. #undef __extern
  665. #endif /* __CACA_H__ */