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

Last change on this file since 2138 was 2138, checked in by Sam Hocevar, 12 years ago
  • Implement caca_create_display_with_driver() to specify an output driver without using environment variables..
  • Implement caca_get_display_driver() to return the current display's output driver.
  • Add a simple example program to test caca_create_display_with_driver().
  • Property svn:keywords set to Id
File size: 7.6 KB
RevLine 
[79]1/*
[672]2 *  libcaca       Colour ASCII-Art library
[524]3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
[268]4 *                All Rights Reserved
[79]5 *
[769]6 *  $Id: caca.h 2138 2007-12-16 01:50:41Z sam $
7 *
[1462]8 *  This library is free software. It comes without any warranty, to
[1452]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
[522]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
[79]13 */
14
[268]15/** \file caca.h
16 *  \version \$Id: caca.h 2138 2007-12-16 01:50:41Z sam $
17 *  \author Sam Hocevar <sam@zoy.org>
18 *  \brief The \e libcaca public header.
[205]19 *
[268]20 *  This header contains the public types and functions that applications
21 *  using \e libcaca may use.
[205]22 */
23
[193]24#ifndef __CACA_H__
25#define __CACA_H__
[153]26
[2039]27#include <cucul.h>
28
[2071]29#undef __extern
30#if defined(_WIN32) && defined(__LIBCACA__)
31#   define __extern extern __declspec(dllexport)
32#else
33#   define __extern extern
[2039]34#endif
35
[773]36/** libcaca API version */
[645]37#define CACA_API_VERSION_1
38
[153]39#ifdef __cplusplus
40extern "C"
41{
42#endif
43
[1358]44/** \e libcaca display context */
[811]45typedef struct caca_display caca_display_t;
[1358]46/** \e libcaca event structure */
[777]47typedef struct caca_event caca_event_t;
[681]48
[1358]49/** \brief Handling of user events.
[685]50 *
51 *  This structure is filled by caca_get_event() when an event is received.
[2073]52 *  It is an opaque structure that should only be accessed through
53 *  caca_event_get_type() and similar functions.
54 */
[681]55struct caca_event
56{
[2049]57    unsigned char opaque_structure[32];
58};
[777]59
[2049]60/** \brief User event type enumeration.
61 *
62 *  This enum serves two purposes:
63 *  - Build listening masks for caca_get_event().
64 *  - Define the type of a \e caca_event_t.
65 */
66enum caca_event_type
67{
68    CACA_EVENT_NONE =          0x0000, /**< No event. */
[777]69
[2049]70    CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
71    CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
72    CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
73    CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
74    CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
75    CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
76    CACA_EVENT_QUIT =          0x0040, /**< The user requested to quit. */
[777]77
[2049]78    CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
[681]79};
80
[267]81/** \brief Special key values.
82 *
[298]83 *  Special key values returned by caca_get_event() for which there is no
[941]84 *  printable ASCII equivalent.
[198]85 */
86enum caca_key
87{
[685]88    CACA_KEY_UNKNOWN = 0x00, /**< Unknown key. */
[332]89
90    /* The following keys have ASCII equivalents */
[1386]91    CACA_KEY_CTRL_A =    0x01, /**< The Ctrl-A key. */
92    CACA_KEY_CTRL_B =    0x02, /**< The Ctrl-B key. */
93    CACA_KEY_CTRL_C =    0x03, /**< The Ctrl-C key. */
94    CACA_KEY_CTRL_D =    0x04, /**< The Ctrl-D key. */
95    CACA_KEY_CTRL_E =    0x05, /**< The Ctrl-E key. */
96    CACA_KEY_CTRL_F =    0x06, /**< The Ctrl-F key. */
97    CACA_KEY_CTRL_G =    0x07, /**< The Ctrl-G key. */
[685]98    CACA_KEY_BACKSPACE = 0x08, /**< The backspace key. */
99    CACA_KEY_TAB =       0x09, /**< The tabulation key. */
[1386]100    CACA_KEY_CTRL_J =    0x0a, /**< The Ctrl-J key. */
101    CACA_KEY_CTRL_K =    0x0b, /**< The Ctrl-K key. */
102    CACA_KEY_CTRL_L =    0x0c, /**< The Ctrl-L key. */
[685]103    CACA_KEY_RETURN =    0x0d, /**< The return key. */
[1386]104    CACA_KEY_CTRL_N =    0x0e, /**< The Ctrl-N key. */
105    CACA_KEY_CTRL_O =    0x0f, /**< The Ctrl-O key. */
106    CACA_KEY_CTRL_P =    0x10, /**< The Ctrl-P key. */
107    CACA_KEY_CTRL_Q =    0x11, /**< The Ctrl-Q key. */
108    CACA_KEY_CTRL_R =    0x12, /**< The Ctrl-R key. */
[685]109    CACA_KEY_PAUSE =     0x13, /**< The pause key. */
[1386]110    CACA_KEY_CTRL_T =    0x14, /**< The Ctrl-T key. */
111    CACA_KEY_CTRL_U =    0x15, /**< The Ctrl-U key. */
112    CACA_KEY_CTRL_V =    0x16, /**< The Ctrl-V key. */
113    CACA_KEY_CTRL_W =    0x17, /**< The Ctrl-W key. */
114    CACA_KEY_CTRL_X =    0x18, /**< The Ctrl-X key. */
115    CACA_KEY_CTRL_Y =    0x19, /**< The Ctrl-Y key. */
116    CACA_KEY_CTRL_Z =    0x1a, /**< The Ctrl-Z key. */
[685]117    CACA_KEY_ESCAPE =    0x1b, /**< The escape key. */
118    CACA_KEY_DELETE =    0x7f, /**< The delete key. */
[332]119
120    /* The following keys do not have ASCII equivalents but have been
121     * chosen to match the SDL equivalents */
[685]122    CACA_KEY_UP =    0x111, /**< The up arrow key. */
123    CACA_KEY_DOWN =  0x112, /**< The down arrow key. */
124    CACA_KEY_LEFT =  0x113, /**< The left arrow key. */
125    CACA_KEY_RIGHT = 0x114, /**< The right arrow key. */
[198]126
[685]127    CACA_KEY_INSERT =   0x115, /**< The insert key. */
128    CACA_KEY_HOME =     0x116, /**< The home key. */
129    CACA_KEY_END =      0x117, /**< The end key. */
130    CACA_KEY_PAGEUP =   0x118, /**< The page up key. */
131    CACA_KEY_PAGEDOWN = 0x119, /**< The page down key. */
[332]132
[685]133    CACA_KEY_F1 =  0x11a, /**< The F1 key. */
134    CACA_KEY_F2 =  0x11b, /**< The F2 key. */
135    CACA_KEY_F3 =  0x11c, /**< The F3 key. */
136    CACA_KEY_F4 =  0x11d, /**< The F4 key. */
137    CACA_KEY_F5 =  0x11e, /**< The F5 key. */
138    CACA_KEY_F6 =  0x11f, /**< The F6 key. */
139    CACA_KEY_F7 =  0x120, /**< The F7 key. */
140    CACA_KEY_F8 =  0x121, /**< The F8 key. */
141    CACA_KEY_F9 =  0x122, /**< The F9 key. */
142    CACA_KEY_F10 = 0x123, /**< The F10 key. */
143    CACA_KEY_F11 = 0x124, /**< The F11 key. */
144    CACA_KEY_F12 = 0x125, /**< The F12 key. */
145    CACA_KEY_F13 = 0x126, /**< The F13 key. */
146    CACA_KEY_F14 = 0x127, /**< The F14 key. */
147    CACA_KEY_F15 = 0x128  /**< The F15 key. */
[198]148};
149
[1879]150/** \defgroup libcaca libcaca basic functions
[268]151 *
[685]152 *  These functions provide the basic \e libcaca routines for driver
[268]153 *  initialisation, system information retrieval and configuration.
154 *
155 *  @{ */
[2039]156__extern caca_display_t * caca_create_display(cucul_canvas_t *);
[2138]157__extern caca_display_t * caca_create_display_with_driver(cucul_canvas_t *,
158                                                          char const *);
159__extern char const * caca_get_display_driver(caca_display_t *);
[2039]160__extern int caca_free_display(caca_display_t *);
[2061]161__extern cucul_canvas_t * caca_get_canvas(caca_display_t *);
[2039]162__extern int caca_refresh_display(caca_display_t *);
[2138]163__extern char const * const * caca_get_display_driver_list(void);
[2039]164__extern int caca_set_display_time(caca_display_t *, unsigned int);
[2043]165__extern unsigned int caca_get_display_time(caca_display_t const *);
166__extern unsigned int caca_get_display_width(caca_display_t const *);
167__extern unsigned int caca_get_display_height(caca_display_t const *);
[2039]168__extern int caca_set_display_title(caca_display_t *, char const *);
[2049]169__extern int caca_set_mouse(caca_display_t *, int);
170__extern int caca_set_cursor(caca_display_t *, int);
[2074]171__extern char const * caca_get_version(void);
[268]172/*  @} */
[79]173
[1879]174/** \defgroup caca_event libcaca event handling
[268]175 *
176 *  These functions handle user events such as keyboard input and mouse
177 *  clicks.
178 *
179 *  @{ */
[2039]180__extern int caca_get_event(caca_display_t *, unsigned int,
181                            caca_event_t *, int);
[2043]182__extern unsigned int caca_get_mouse_x(caca_display_t const *);
183__extern unsigned int caca_get_mouse_y(caca_display_t const *);
[2049]184__extern enum caca_event_type caca_get_event_type(caca_event_t const *);
185__extern unsigned int caca_get_event_key_ch(caca_event_t const *);
186__extern unsigned long int caca_get_event_key_utf32(caca_event_t const *);
187__extern int caca_get_event_key_utf8(caca_event_t const *, char *);
188__extern unsigned int caca_get_event_mouse_button(caca_event_t const *);
189__extern unsigned int caca_get_event_mouse_x(caca_event_t const *);
190__extern unsigned int caca_get_event_mouse_y(caca_event_t const *);
191__extern unsigned int caca_get_event_resize_width(caca_event_t const *);
192__extern unsigned int caca_get_event_resize_height(caca_event_t const *);
[268]193/*  @} */
[79]194
[153]195#ifdef __cplusplus
196}
197#endif
198
[2039]199#if !defined(_DOXYGEN_SKIP_ME)
200#   undef __extern
201#endif
202
[193]203#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.