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

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • 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 2299 2008-04-19 12:42:50Z 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#include "stubs.h"
19
20typedef struct caca_timer caca_timer_t;
21typedef struct caca_privevent caca_privevent_t;
22
23#if !defined(_DOXYGEN_SKIP_ME)
24#   define EVENTBUF_LEN 10
25#endif
26
27/* Graphics driver */
28enum caca_driver
29{
30    CACA_DRIVER_NONE = 0,
31    CACA_DRIVER_RAW = 1,
32#if defined(USE_COCOA)
33    CACA_DRIVER_COCOA = 2,
34#endif
35#if defined(USE_CONIO)
36    CACA_DRIVER_CONIO = 3,
37#endif
38#if defined(USE_GL)
39    CACA_DRIVER_GL = 4,
40#endif
41#if defined(USE_NCURSES)
42    CACA_DRIVER_NCURSES = 5,
43#endif
44#if defined(USE_SLANG)
45    CACA_DRIVER_SLANG = 6,
46#endif
47#if defined(USE_VGA)
48    CACA_DRIVER_VGA = 7,
49#endif
50#if defined(USE_WIN32)
51    CACA_DRIVER_WIN32 = 8,
52#endif
53#if defined(USE_X11)
54    CACA_DRIVER_X11 = 9,
55#endif
56};
57
58/* Available external drivers */
59#if defined(USE_COCOA)
60int cocoa_install(caca_display_t *);
61#endif
62#if defined(USE_CONIO)
63int conio_install(caca_display_t *);
64#endif
65#if defined(USE_GL)
66int gl_install(caca_display_t *);
67#endif
68#if defined(USE_NCURSES)
69int ncurses_install(caca_display_t *);
70#endif
71int raw_install(caca_display_t *);
72#if defined(USE_SLANG)
73int slang_install(caca_display_t *);
74#endif
75#if defined(USE_VGA)
76int vga_install(caca_display_t *);
77#endif
78#if defined(USE_WIN32)
79int win32_install(caca_display_t *);
80#endif
81#if defined(USE_X11)
82int x11_install(caca_display_t *);
83#endif
84
85/* Timer structure */
86struct caca_timer
87{
88    int last_sec, last_usec;
89};
90
91/* Private event structure */
92struct caca_privevent
93{
94    enum caca_event_type type;
95
96    union
97    {
98        struct { unsigned int x, y, button; } mouse;
99        struct { unsigned int w, h; } resize;
100        struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
101    } data;
102};
103
104/* Internal caca display context */
105struct caca_display
106{
107    /* A link to our cucul canvas */
108    cucul_canvas_t *cv;
109    int autorelease;
110
111#if defined(USE_PLUGINS)
112    void *plugin;
113#endif
114
115    /* Device-specific functions */
116    struct drv
117    {
118        char const * driver;
119        enum caca_driver id;
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.