Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

861 řádky
36 KiB

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