-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcairoio.h
135 lines (124 loc) · 3.41 KB
/
cairoio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* cairoio.h
*/
/*
* the cairodevice
*
* the cairodevice structure allows the cairoui interface to be run whenever a
* cairo context can be obtained and input is available
*
* void init(struct cairodevice *cairodevice,
* char *device, int doublebuffering,
* int argn, char *argv[], char *opts);
* create the cairo context
*
* void finish(struct cairodevice *cairodevice);
* undo what done by init
*
* cairo_t *context(struct cairodevice *cairodevice);
* double width(struct cairodevice *cairodevice);
* double height(struct cairodevice *cairodevice);
* double screenwidth(struct cairodevice *cairodevice);
* double screenheight(struct cairodevice *cairodevice);
* return the cairo context and its size
*
* int doublebuffering(struct cairodevice *cairodevice);
* return whether double buffering is used
*
* void clear(struct cairodevice *cairodevice);
* void blank(struct cairodevice *cairodevice);
* void flush(struct cairodevice *cairodevice);
* clear and flush
*
* int isactive(struct cairodevice *cairodevice);
* whether the output is active
* do not draw on the framebuffer when the vt is switched out
*
* int input(struct cairodevice *cairodevice,
* int timeout, struct command *command);
* return a key
* on external command: store it in command->command, return KEY_EXTERNAL
* block for at most timeout milliseconds, NO_TIMEOUT=infinite
*/
#ifdef _CAIROOUTPUT_H
#else
#define _CAIROOUTPUT_H
#include <cairo.h>
/*
* include curses to get the key macros
*/
#include <curses.h>
/*
* imaginary keys
*/
#define KEY_NONE ((KEY_MAX) + 1)
#define KEY_INIT ((KEY_MAX) + 2)
#define KEY_FINISH ((KEY_MAX) + 3)
#ifdef KEY_REFRESH
#else
#define KEY_REFRESH ((KEY_MAX) + 4)
#endif
#define KEY_REDRAW ((KEY_MAX) + 5)
#ifdef KEY_RESIZE
#else
#define KEY_RESIZE ((KEY_MAX) + 6)
#endif
#define KEY_TIMEOUT ((KEY_MAX) + 7)
#ifdef KEY_SUSPEND
#else
#define KEY_SUSPEND ((KEY_MAX) + 8)
#endif
#define KEY_SIGNAL ((KEY_MAX) + 9)
#define KEY_EXTERNAL ((KEY_MAX) + 10)
#define KEY_PASTE ((KEY_MAX) + 11)
#define ISIMAGINARYKEY(c) ( \
((c) == KEY_NONE) || \
((c) == KEY_INIT) || \
((c) == KEY_REFRESH) || \
((c) == KEY_REDRAW) || \
((c) == KEY_RESIZE) || \
((c) == KEY_TIMEOUT) || \
((c) == KEY_SUSPEND) || \
((c) == KEY_SIGNAL) || \
((c) == KEY_EXTERNAL) || \
((c) == KEY_PASTE) \
)
#define ISREALKEY(c) (! ISIMAGINARYKEY(c))
/*
* no timeout
*/
#define NO_TIMEOUT (-1)
/*
* external command
*/
struct command {
int fd;
FILE *stream;
char *command;
int max;
};
/*
* a cairo device
*/
struct cairodevice {
char *options;
char *usage;
struct cairoio *cairoio;
int (*init)(struct cairodevice *cairodevice,
char *device, int doublebuffering,
int argn, char *argv[], char *opts);
void (*finish)(struct cairodevice *cairodevice);
cairo_t *(*context)(struct cairodevice *cairodevice);
double (*width)(struct cairodevice *cairodevice);
double (*height)(struct cairodevice *cairodevice);
double (*screenwidth)(struct cairodevice *cairodevice);
double (*screenheight)(struct cairodevice *cairodevice);
int (*doublebuffering)(struct cairodevice *cairodevice);
void (*clear)(struct cairodevice *cairodevice);
void (*blank)(struct cairodevice *cairodevice);
void (*flush)(struct cairodevice *cairodevice);
int (*isactive)(struct cairodevice *cairodevice);
int (*input)(struct cairodevice *cairodevice, int timeout,
struct command *command);
};
#endif