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
RevLine 
[159]1/*
[672]2 *  libcaca       Colour ASCII-Art library
[527]3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
[268]4 *                All Rights Reserved
[159]5 *
[769]6 *  $Id: caca_internals.h 2299 2008-04-19 12:42:50Z sam $
7 *
[1462]8 *  This library is free software. It comes without any warranty, to
[1452]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
[522]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
[159]13 */
14
[193]15#ifndef __CACA_INTERNALS_H__
16#define __CACA_INTERNALS_H__
[159]17
[2299]18#include "stubs.h"
[540]19
[777]20typedef struct caca_timer caca_timer_t;
[2049]21typedef struct caca_privevent caca_privevent_t;
[777]22
[541]23#if !defined(_DOXYGEN_SKIP_ME)
24#   define EVENTBUF_LEN 10
25#endif
26
[265]27/* Graphics driver */
28enum caca_driver
29{
[684]30    CACA_DRIVER_NONE = 0,
[699]31    CACA_DRIVER_RAW = 1,
[1396]32#if defined(USE_COCOA)
33    CACA_DRIVER_COCOA = 2,
34#endif
[265]35#if defined(USE_CONIO)
[1396]36    CACA_DRIVER_CONIO = 3,
[265]37#endif
[699]38#if defined(USE_GL)
[1396]39    CACA_DRIVER_GL = 4,
[699]40#endif
[265]41#if defined(USE_NCURSES)
[1396]42    CACA_DRIVER_NCURSES = 5,
[265]43#endif
44#if defined(USE_SLANG)
[1396]45    CACA_DRIVER_SLANG = 6,
[265]46#endif
[699]47#if defined(USE_VGA)
[1396]48    CACA_DRIVER_VGA = 7,
[265]49#endif
[335]50#if defined(USE_WIN32)
[1396]51    CACA_DRIVER_WIN32 = 8,
[335]52#endif
[699]53#if defined(USE_X11)
[1396]54    CACA_DRIVER_X11 = 9,
[483]55#endif
[265]56};
57
[699]58/* Available external drivers */
[1396]59#if defined(USE_COCOA)
60int cocoa_install(caca_display_t *);
61#endif
[539]62#if defined(USE_CONIO)
[811]63int conio_install(caca_display_t *);
[539]64#endif
65#if defined(USE_GL)
[811]66int gl_install(caca_display_t *);
[539]67#endif
68#if defined(USE_NCURSES)
[811]69int ncurses_install(caca_display_t *);
[539]70#endif
[811]71int raw_install(caca_display_t *);
[539]72#if defined(USE_SLANG)
[811]73int slang_install(caca_display_t *);
[539]74#endif
[699]75#if defined(USE_VGA)
[811]76int vga_install(caca_display_t *);
[699]77#endif
[539]78#if defined(USE_WIN32)
[811]79int win32_install(caca_display_t *);
[539]80#endif
81#if defined(USE_X11)
[811]82int x11_install(caca_display_t *);
[539]83#endif
[684]84
[331]85/* Timer structure */
86struct caca_timer
87{
88    int last_sec, last_usec;
89};
90
[2049]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
[811]104/* Internal caca display context */
105struct caca_display
[524]106{
[551]107    /* A link to our cucul canvas */
[811]108    cucul_canvas_t *cv;
[2061]109    int autorelease;
[265]110
[1208]111#if defined(USE_PLUGINS)
112    void *plugin;
113#endif
114
[551]115    /* Device-specific functions */
[550]116    struct drv
[539]117    {
[2138]118        char const * driver;
119        enum caca_driver id;
[550]120        struct driver_private *p;
[539]121
[811]122        int (* init_graphics) (caca_display_t *);
123        int (* end_graphics) (caca_display_t *);
[819]124        int (* set_display_title) (caca_display_t *, char const *);
[2043]125        unsigned int (* get_display_width) (caca_display_t const *);
126        unsigned int (* get_display_height) (caca_display_t const *);
[811]127        void (* display) (caca_display_t *);
128        void (* handle_resize) (caca_display_t *);
[2049]129        int (* get_event) (caca_display_t *, caca_privevent_t *);
[811]130        void (* set_mouse) (caca_display_t *, int);
[1430]131        void (* set_cursor) (caca_display_t *, int);
[550]132    } drv;
[539]133
[551]134    /* Mouse position */
135    struct mouse
136    {
137        unsigned int x, y;
138    } mouse;
[524]139
[551]140    /* Window resize handling */
[553]141    struct resize
142    {
143        int resized;   /* A resize event was requested */
[2055]144        int allow;     /* The display driver allows resizing */
[553]145        unsigned w, h; /* Requested width and height */
146    } resize;
[524]147
[551]148    /* Framerate handling */
[524]149    unsigned int delay, rendertime;
[777]150    caca_timer_t timer;
[527]151    int lastticks;
[524]152
[527]153    struct events
154    {
[681]155#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
[2049]156        caca_privevent_t buf[EVENTBUF_LEN];
[541]157        int queue;
158#endif
[527]159#if defined(USE_SLANG) || defined(USE_NCURSES)
[777]160        caca_timer_t key_timer;
[527]161        unsigned int last_key_ticks;
162        unsigned int autorepeat_ticks;
[2049]163        caca_privevent_t last_key_event;
[527]164#endif
[775]165#if defined(USE_WIN32)
[978]166        unsigned char not_empty_struct;
[775]167#endif
[527]168    } events;
[524]169};
170
[645]171/* Internal timer functions */
[335]172extern void _caca_sleep(unsigned int);
[777]173extern unsigned int _caca_getticks(caca_timer_t *);
[331]174
[645]175/* Internal event functions */
[811]176extern void _caca_handle_resize(caca_display_t *);
[681]177#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
[2049]178extern void _push_event(caca_display_t *, caca_privevent_t *);
179extern int _pop_event(caca_display_t *, caca_privevent_t *);
[645]180#endif
181
[1392]182/* Internal window functions */
183extern void _caca_set_term_title(char const *);
184
[193]185#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.