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

Last change on this file since 1392 was 1392, checked in by Sam Hocevar, 14 years ago
  • Factored terminal title setting code.
  • Do not try to set the terminal title if TERM=linux.
  • Property svn:keywords set to Id
File size: 3.8 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 1392 2006-11-13 23:42:43Z 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_CONIO)
33    CACA_DRIVER_CONIO = 2,
34#endif
35#if defined(USE_GL)
36    CACA_DRIVER_GL = 3,
37#endif
38#if defined(USE_NCURSES)
39    CACA_DRIVER_NCURSES = 4,
40#endif
41#if defined(USE_SLANG)
42    CACA_DRIVER_SLANG = 5,
43#endif
44#if defined(USE_VGA)
45    CACA_DRIVER_VGA = 6,
46#endif
47#if defined(USE_WIN32)
48    CACA_DRIVER_WIN32 = 7,
49#endif
50#if defined(USE_X11)
51    CACA_DRIVER_X11 = 8,
52#endif
53};
54
55/* Available external drivers */
56#if defined(USE_CONIO)
57int conio_install(caca_display_t *);
58#endif
59#if defined(USE_GL)
60int gl_install(caca_display_t *);
61#endif
62#if defined(USE_NCURSES)
63int ncurses_install(caca_display_t *);
64#endif
65int raw_install(caca_display_t *);
66#if defined(USE_SLANG)
67int slang_install(caca_display_t *);
68#endif
69#if defined(USE_VGA)
70int vga_install(caca_display_t *);
71#endif
72#if defined(USE_WIN32)
73int win32_install(caca_display_t *);
74#endif
75#if defined(USE_X11)
76int x11_install(caca_display_t *);
77#endif
78
79/* Timer structure */
80struct caca_timer
81{
82    int last_sec, last_usec;
83};
84
85/* Internal caca display context */
86struct caca_display
87{
88    /* A link to our cucul canvas */
89    cucul_canvas_t *cv;
90
91#if defined(USE_PLUGINS)
92    void *plugin;
93#endif
94
95    /* Device-specific functions */
96    struct drv
97    {
98        enum caca_driver driver;
99        struct driver_private *p;
100
101        int (* init_graphics) (caca_display_t *);
102        int (* end_graphics) (caca_display_t *);
103        int (* set_display_title) (caca_display_t *, char const *);
104        unsigned int (* get_display_width) (caca_display_t *);
105        unsigned int (* get_display_height) (caca_display_t *);
106        void (* display) (caca_display_t *);
107        void (* handle_resize) (caca_display_t *);
108        int (* get_event) (caca_display_t *, caca_event_t *);
109        void (* set_mouse) (caca_display_t *, int);
110    } drv;
111
112    /* Mouse position */
113    struct mouse
114    {
115        unsigned int x, y;
116    } mouse;
117
118    /* Window resize handling */
119    struct resize
120    {
121        int resized;   /* A resize event was requested */
122        unsigned w, h; /* Requested width and height */
123    } resize;
124
125    /* Framerate handling */
126    unsigned int delay, rendertime;
127    caca_timer_t timer;
128    int lastticks;
129
130    struct events
131    {
132#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
133        caca_event_t buf[EVENTBUF_LEN];
134        int queue;
135#endif
136#if defined(USE_SLANG) || defined(USE_NCURSES)
137        caca_timer_t key_timer;
138        unsigned int last_key_ticks;
139        unsigned int autorepeat_ticks;
140        caca_event_t last_key_event;
141#endif
142#if defined(USE_WIN32)
143        unsigned char not_empty_struct;
144#endif
145    } events;
146};
147
148/* Internal timer functions */
149extern void _caca_sleep(unsigned int);
150extern unsigned int _caca_getticks(caca_timer_t *);
151
152/* Internal event functions */
153extern void _caca_handle_resize(caca_display_t *);
154#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
155extern void _push_event(caca_display_t *, caca_event_t *);
156extern int _pop_event(caca_display_t *, caca_event_t *);
157#endif
158
159/* Internal window functions */
160extern void _caca_set_term_title(char const *);
161
162#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.