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

Last change on this file since 2055 was 2055, checked in by Sam Hocevar, 12 years ago
  • Add cucul_manage_canvas() and cucul_unmanage_canvas(). Display drivers no longer need to access the cv->refcount private member and cucul_set_canvas_size() is no longer needed.
  • 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 2055 2007-11-25 14:11:58Z 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
112#if defined(USE_PLUGINS)
113    void *plugin;
114#endif
115
116    /* Device-specific functions */
117    struct drv
118    {
119        enum caca_driver driver;
120        struct driver_private *p;
121
122        int (* init_graphics) (caca_display_t *);
123        int (* end_graphics) (caca_display_t *);
124        int (* set_display_title) (caca_display_t *, char const *);
125        unsigned int (* get_display_width) (caca_display_t const *);
126        unsigned int (* get_display_height) (caca_display_t const *);
127        void (* display) (caca_display_t *);
128        void (* handle_resize) (caca_display_t *);
129        int (* get_event) (caca_display_t *, caca_privevent_t *);
130        void (* set_mouse) (caca_display_t *, int);
131        void (* set_cursor) (caca_display_t *, int);
132    } drv;
133
134    /* Mouse position */
135    struct mouse
136    {
137        unsigned int x, y;
138    } mouse;
139
140    /* Window resize handling */
141    struct resize
142    {
143        int resized;   /* A resize event was requested */
144        int allow;     /* The display driver allows resizing */
145        unsigned w, h; /* Requested width and height */
146    } resize;
147
148    /* Framerate handling */
149    unsigned int delay, rendertime;
150    caca_timer_t timer;
151    int lastticks;
152
153    struct events
154    {
155#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
156        caca_privevent_t buf[EVENTBUF_LEN];
157        int queue;
158#endif
159#if defined(USE_SLANG) || defined(USE_NCURSES)
160        caca_timer_t key_timer;
161        unsigned int last_key_ticks;
162        unsigned int autorepeat_ticks;
163        caca_privevent_t last_key_event;
164#endif
165#if defined(USE_WIN32)
166        unsigned char not_empty_struct;
167#endif
168    } events;
169};
170
171/* Internal timer functions */
172extern void _caca_sleep(unsigned int);
173extern unsigned int _caca_getticks(caca_timer_t *);
174
175/* Internal event functions */
176extern void _caca_handle_resize(caca_display_t *);
177#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
178extern void _push_event(caca_display_t *, caca_privevent_t *);
179extern int _pop_event(caca_display_t *, caca_privevent_t *);
180#endif
181
182/* Internal window functions */
183extern void _caca_set_term_title(char const *);
184
185#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.