"Fossies" - the Fresh Open Source Software Archive

Member "libcaca-0.99.beta20/caca/caca.h" (22 May 2018, 28975 Bytes) of package /linux/privat/libcaca-0.99.beta20.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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