source: libcaca/trunk/caca/caca_internals.h @ 2061

Last change on this file since 2061 was 2061, checked in by Sam Hocevar, 13 years ago
  • Allow caca_create_display()'s argument to be NULL. It will automatically create a canvas when so.
  • Add caca_get_canvas() to retrieve the cucul canvas.
  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: caca_internals.h 2061 2007-11-25 17:13:08Z 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#ifndef __CACA_INTERNALS_H__
16#define __CACA_INTERNALS_H__
17
18#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
19#   include <inttypes.h>
20#endif
21
22typedef struct caca_timer caca_timer_t;
23typedef struct caca_privevent caca_privevent_t;
24
25#if !defined(_DOXYGEN_SKIP_ME)
26#   define EVENTBUF_LEN 10
27#endif
28
29/* Graphics driver */
30enum caca_driver
31{
32    CACA_DRIVER_NONE = 0,
33    CACA_DRIVER_RAW = 1,
34#if defined(USE_COCOA)
35    CACA_DRIVER_COCOA = 2,
36#endif
37#if defined(USE_CONIO)
38    CACA_DRIVER_CONIO = 3,
39#endif
40#if defined(USE_GL)
41    CACA_DRIVER_GL = 4,
42#endif
43#if defined(USE_NCURSES)
44    CACA_DRIVER_NCURSES = 5,
45#endif
46#if defined(USE_SLANG)
47    CACA_DRIVER_SLANG = 6,
48#endif
49#if defined(USE_VGA)
50    CACA_DRIVER_VGA = 7,
51#endif
52#if defined(USE_WIN32)
53    CACA_DRIVER_WIN32 = 8,
54#endif
55#if defined(USE_X11)
56    CACA_DRIVER_X11 = 9,
57#endif
58};
59
60/* Available external drivers */
61#if defined(USE_COCOA)
62int cocoa_install(caca_display_t *);
63#endif
64#if defined(USE_CONIO)
65int conio_install(caca_display_t *);
66#endif
67#if defined(USE_GL)
68int gl_install(caca_display_t *);
69#endif
70#if defined(USE_NCURSES)
71int ncurses_install(caca_display_t *);
72#endif
73int raw_install(caca_display_t *);
74#if defined(USE_SLANG)
75int slang_install(caca_display_t *);
76#endif
77#if defined(USE_VGA)
78int vga_install(caca_display_t *);
79#endif
80#if defined(USE_WIN32)
81int win32_install(caca_display_t *);
82#endif
83#if defined(USE_X11)
84int x11_install(caca_display_t *);
85#endif
86
87/* Timer structure */
88struct caca_timer
89{
90    int last_sec, last_usec;
91};
92
93/* Private event structure */
94struct caca_privevent
95{
96    enum caca_event_type type;
97
98    union
99    {
100        struct { unsigned int x, y, button; } mouse;
101        struct { unsigned int w, h; } resize;
102        struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
103    } data;
104};
105
106/* Internal caca display context */
107struct caca_display
108{
109    /* A link to our cucul canvas */
110    cucul_canvas_t *cv;
111    int autorelease;
112
113#if defined(USE_PLUGINS)
114    void *plugin;
115#endif
116
117    /* Device-specific functions */
118    struct drv
119    {
120        enum caca_driver driver;
121        struct driver_private *p;
122
123        int (* init_graphics) (caca_display_t *);
124        int (* end_graphics) (caca_display_t *);
125        int (* set_display_title) (caca_display_t *, char const *);
126        unsigned int (* get_display_width) (caca_display_t const *);
127        unsigned int (* get_display_height) (caca_display_t const *);
128        void (* display) (caca_display_t *);
129        void (* handle_resize) (caca_display_t *);
130        int (* get_event) (caca_display_t *, caca_privevent_t *);
131        void (* set_mouse) (caca_display_t *, int);
132        void (* set_cursor) (caca_display_t *, int);
133    } drv;
134
135    /* Mouse position */
136    struct mouse
137    {
138        unsigned int x, y;
139    } mouse;
140
141    /* Window resize handling */
142    struct resize
143    {
144        int resized;   /* A resize event was requested */
145        int allow;     /* The display driver allows resizing */
146        unsigned w, h; /* Requested width and height */
147    } resize;
148
149    /* Framerate handling */
150    unsigned int delay, rendertime;
151    caca_timer_t timer;
152    int lastticks;
153
154    struct events
155    {
156#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
157        caca_privevent_t buf[EVENTBUF_LEN];
158        int queue;
159#endif
160#if defined(USE_SLANG) || defined(USE_NCURSES)
161        caca_timer_t key_timer;
162        unsigned int last_key_ticks;
163        unsigned int autorepeat_ticks;
164        caca_privevent_t last_key_event;
165#endif
166#if defined(USE_WIN32)
167        unsigned char not_empty_struct;
168#endif
169    } events;
170};
171
172/* Internal timer functions */
173extern void _caca_sleep(unsigned int);
174extern unsigned int _caca_getticks(caca_timer_t *);
175
176/* Internal event functions */
177extern void _caca_handle_resize(caca_display_t *);
178#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
179extern void _push_event(caca_display_t *, caca_privevent_t *);
180extern int _pop_event(caca_display_t *, caca_privevent_t *);
181#endif
182
183/* Internal window functions */
184extern void _caca_set_term_title(char const *);
185
186#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.