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

Last change on this file since 1430 was 1430, checked in by Sam Hocevar, 13 years ago
  • Added caca_set_cursor(). Not yet functional.
  • Property svn:keywords set to Id
File size: 4.0 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 1430 2006-11-24 05:51:10Z sam $
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#ifndef __CACA_INTERNALS_H__
15#define __CACA_INTERNALS_H__
16
17#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
18#   include <inttypes.h>
19#endif
20
21typedef struct caca_timer caca_timer_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/* Internal caca display context */
92struct caca_display
93{
94    /* A link to our cucul canvas */
95    cucul_canvas_t *cv;
96
97#if defined(USE_PLUGINS)
98    void *plugin;
99#endif
100
101    /* Device-specific functions */
102    struct drv
103    {
104        enum caca_driver driver;
105        struct driver_private *p;
106
107        int (* init_graphics) (caca_display_t *);
108        int (* end_graphics) (caca_display_t *);
109        int (* set_display_title) (caca_display_t *, char const *);
110        unsigned int (* get_display_width) (caca_display_t *);
111        unsigned int (* get_display_height) (caca_display_t *);
112        void (* display) (caca_display_t *);
113        void (* handle_resize) (caca_display_t *);
114        int (* get_event) (caca_display_t *, caca_event_t *);
115        void (* set_mouse) (caca_display_t *, int);
116        void (* set_cursor) (caca_display_t *, int);
117    } drv;
118
119    /* Mouse position */
120    struct mouse
121    {
122        unsigned int x, y;
123    } mouse;
124
125    /* Window resize handling */
126    struct resize
127    {
128        int resized;   /* A resize event was requested */
129        unsigned w, h; /* Requested width and height */
130    } resize;
131
132    /* Framerate handling */
133    unsigned int delay, rendertime;
134    caca_timer_t timer;
135    int lastticks;
136
137    struct events
138    {
139#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
140        caca_event_t buf[EVENTBUF_LEN];
141        int queue;
142#endif
143#if defined(USE_SLANG) || defined(USE_NCURSES)
144        caca_timer_t key_timer;
145        unsigned int last_key_ticks;
146        unsigned int autorepeat_ticks;
147        caca_event_t last_key_event;
148#endif
149#if defined(USE_WIN32)
150        unsigned char not_empty_struct;
151#endif
152    } events;
153};
154
155/* Internal timer functions */
156extern void _caca_sleep(unsigned int);
157extern unsigned int _caca_getticks(caca_timer_t *);
158
159/* Internal event functions */
160extern void _caca_handle_resize(caca_display_t *);
161#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
162extern void _push_event(caca_display_t *, caca_event_t *);
163extern int _pop_event(caca_display_t *, caca_event_t *);
164#endif
165
166/* Internal window functions */
167extern void _caca_set_term_title(char const *);
168
169#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.