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

Last change on this file since 599 was 599, checked in by Sam Hocevar, 14 years ago
  • Changed port environment variable to "CACA_PORT". No need to mention it's a network port, we could have guessed.
  • Property svn:keywords set to Id
File size: 7.8 KB
Line 
1/*
2 *  libcaca       ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the Do What The Fuck You Want To
8 *  Public License, Version 2, as published by Sam Hocevar. See
9 *  http://sam.zoy.org/wtfpl/COPYING for more details.
10 */
11
12/** \file caca.h
13 *  \version \$Id: caca.h 599 2006-03-14 12:49:01Z sam $
14 *  \author Sam Hocevar <sam@zoy.org>
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/** \mainpage libcaca developer documentation
22 *
23 *  \section intro Introduction
24 *
25 *  \e libcaca is a graphics library that outputs text instead of pixels,
26 *  so that it can work on older video cards or text terminals. It is not
27 *  unlike the famous AAlib library. \e libcaca can use almost any virtual
28 *  terminal to work, thus it should work on all Unix systems (including
29 *  Mac OS X) using either the slang library or the ncurses library, on DOS
30 *  using the conio library, and on Windows systems using either slang or
31 *  ncurses (through Cygwin emulation) or conio. There is also a native X11
32 *  driver, and an OpenGL driver (through freeglut) that does not require a
33 *  text terminal. For machines without a screen, and with a valid tcp stack,
34 *  the network driver (BSD sockets) should perfectly fit your needs.
35 *
36 *  \e libcaca is free software, released under the Do What The Fuck You
37 *  Want To Public License. This ensures that no one, not even the \e libcaca
38 *  developers, will ever have anything to say about what you do with the
39 *  software. It used to be licensed under the GNU Lesser General Public
40 *  License, but that was not free enough.
41 *
42 *  \section api The libcaca API
43 *
44 *  \e libcaca relies on a low-level, device independent library, called
45 *  \e libcucul. \e libcucul can be used alone as a simple ASCII and/or
46 *  Unicode compositing canvas.
47 *
48 *  The complete \e libcucul and \e libcaca programming interface is
49 *  available from the cucul.h and caca.h headers.
50 *
51 *  \section env Environment variables
52 *
53 *  Some environment variables can be used to change the behaviour of
54 *  \e libcaca or \e libcucul without having to modify the program which
55 *  uses them. These variables are:
56 *
57 *  \li \b CACA_DRIVER: set the backend video driver. In order of preference:
58 *      - \c conio uses the DOS conio.h interface.
59 *      - \c ncurses uses the ncurses library.
60 *      - \c slang uses the S-Lang library.
61 *      - \c x11 uses the native X11 driver.
62 *      - \c gl uses freeglut and opengl libraries.
63 *      - \c network uses BSD sockets calls.
64 *
65 *  \li \b CUCUL_BACKGROUND: set the background type.
66 *      - \c solid uses solid coloured backgrounds for all characters. This
67 *        feature does not work with all terminal emulators. This is the
68 *        default choice.
69 *      - \c black uses only black backgrounds to render characters.
70 *
71 *  \li \b CUCUL_ANTIALIASING: set the antialiasing mode. Antialiasing
72 *      smoothens the rendered image and avoids the commonly seen staircase
73 *      effect.
74 *      - \c none disables antialiasing.
75 *      - \c prefilter uses a simple prefilter antialiasing method. This is
76 *        the default choice.
77 *
78 *  \li \b CUCUL_DITHERING: set the dithering mode. Dithering is necessary
79 *      when rendering a picture that has more colours than the usually
80 *      available palette.
81 *      - \c none disables dithering.
82 *      - \c ordered2 uses a 2x2 Bayer matrix for dithering.
83 *      - \c ordered4 uses a 4x4 Bayer matrix for dithering. This is the
84 *        default choice.
85 *      - \c ordered8 uses a 8x8 Bayer matrix for dithering.
86 *      - \c random uses random dithering.
87 *
88 *  \li \b CACA_GEOMETRY: set the video display size. The format of this
89 *      variable must be XxY, with X and Y being integer values. This option
90 *      currently only works with the X11 and the GL driver.
91 *
92 *  \li \b CACA_FONT: set the rendered font. The format of this variable is
93 *      implementation dependent, but since it currently only works with the
94 *      X11 driver, an X11 font name such as "fixed" or "5x7" is expected.
95 *
96 *  \li \b CACA_PORT: set the port the network driver will listen on, when
97 *      the output driver is "network". Default port is 51914 (0xCACA).
98 */
99
100#ifndef __CACA_H__
101#define __CACA_H__
102
103#include <cucul.h>
104
105#ifdef __cplusplus
106extern "C"
107{
108#endif
109
110/** \brief User events.
111 *
112 *  Event types returned by caca_get_event().
113 */
114enum caca_event
115{
116    CACA_EVENT_NONE =          0x00000000, /**< No event. */
117    CACA_EVENT_KEY_PRESS =     0x01000000, /**< A key was pressed. */
118    CACA_EVENT_KEY_RELEASE =   0x02000000, /**< A key was released. */
119    CACA_EVENT_MOUSE_PRESS =   0x04000000, /**< A mouse button was pressed. */
120    CACA_EVENT_MOUSE_RELEASE = 0x08000000, /**< A mouse button was released. */
121    CACA_EVENT_MOUSE_MOTION =  0x10000000, /**< The mouse was moved. */
122    CACA_EVENT_RESIZE =        0x20000000, /**< The window was resized. */
123    CACA_EVENT_ANY =           0xff000000  /**< Bitmask for any event. */
124};
125
126/** \brief Special key values.
127 *
128 *  Special key values returned by caca_get_event() for which there is no
129 *  ASCII equivalent.
130 */
131enum caca_key
132{
133    CACA_KEY_UNKNOWN = 0, /**< Unknown key. */
134
135    /* The following keys have ASCII equivalents */
136    CACA_KEY_BACKSPACE = 8, /**< The backspace key. */
137    CACA_KEY_TAB = 9, /**< The tabulation key. */
138    CACA_KEY_RETURN = 13, /**< The return key. */
139    CACA_KEY_PAUSE = 19, /**< The pause key. */
140    CACA_KEY_ESCAPE = 27, /**< The escape key. */
141    CACA_KEY_DELETE = 127, /**< The delete key. */
142
143    /* The following keys do not have ASCII equivalents but have been
144     * chosen to match the SDL equivalents */
145    CACA_KEY_UP = 273, /**< The up arrow key. */
146    CACA_KEY_DOWN = 274, /**< The down arrow key. */
147    CACA_KEY_LEFT = 275, /**< The left arrow key. */
148    CACA_KEY_RIGHT = 276, /**< The right arrow key. */
149
150    CACA_KEY_INSERT = 277, /**< The insert key. */
151    CACA_KEY_HOME = 278, /**< The home key. */
152    CACA_KEY_END = 279, /**< The end key. */
153    CACA_KEY_PAGEUP = 280, /**< The page up key. */
154    CACA_KEY_PAGEDOWN = 281, /**< The page down key. */
155
156    CACA_KEY_F1 = 282, /**< The F1 key. */
157    CACA_KEY_F2 = 283, /**< The F2 key. */
158    CACA_KEY_F3 = 284, /**< The F3 key. */
159    CACA_KEY_F4 = 285, /**< The F4 key. */
160    CACA_KEY_F5 = 286, /**< The F5 key. */
161    CACA_KEY_F6 = 287, /**< The F6 key. */
162    CACA_KEY_F7 = 288, /**< The F7 key. */
163    CACA_KEY_F8 = 289, /**< The F8 key. */
164    CACA_KEY_F9 = 290, /**< The F9 key. */
165    CACA_KEY_F10 = 291, /**< The F10 key. */
166    CACA_KEY_F11 = 292, /**< The F11 key. */
167    CACA_KEY_F12 = 293, /**< The F12 key. */
168    CACA_KEY_F13 = 294, /**< The F13 key. */
169    CACA_KEY_F14 = 295, /**< The F14 key. */
170    CACA_KEY_F15 = 296 /**< The F15 key. */
171};
172
173typedef struct caca_context caca_t;
174
175/** \defgroup basic Basic functions
176 *
177 *  These functions provide the basic \e libcaca routines for library
178 *  initialisation, system information retrieval and configuration.
179 *
180 *  @{ */
181caca_t * caca_attach(cucul_t *qq);
182void caca_detach(caca_t *kk);
183void caca_set_delay(caca_t *kk, unsigned int);
184void caca_display(caca_t *kk);
185unsigned int caca_get_rendertime(caca_t *kk);
186unsigned int caca_get_window_width(caca_t *kk);
187unsigned int caca_get_window_height(caca_t *kk);
188int caca_set_window_title(caca_t *kk, char const *);
189/*  @} */
190
191/** \defgroup event Event handling
192 *
193 *  These functions handle user events such as keyboard input and mouse
194 *  clicks.
195 *
196 *  @{ */
197unsigned int caca_get_event(caca_t *kk, unsigned int);
198unsigned int caca_wait_event(caca_t *kk, unsigned int);
199unsigned int caca_get_mouse_x(caca_t *kk);
200unsigned int caca_get_mouse_y(caca_t *kk);
201/*  @} */
202
203#ifdef __cplusplus
204}
205#endif
206
207#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.