source: libcaca/trunk/caca/caca.h @ 4146

Last change on this file since 4146 was 4146, checked in by Sam Hocevar, 10 years ago

Fix an alignment issue in caca_get_canvas_chars() and caca_get_canvas_attrs().
Fixes #41.

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