libt3window
Main Page
Modules
All
Data Structures
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
src
terminal.h
1
/* Copyright (C) 2011-2012 G.P. Halkes
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License version 3, as
4
published by the Free Software Foundation.
5
6
This program is distributed in the hope that it will be useful,
7
but WITHOUT ANY WARRANTY; without even the implied warranty of
8
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
GNU General Public License for more details.
10
11
You should have received a copy of the GNU General Public License
12
along with this program. If not, see <http://www.gnu.org/licenses/>.
13
*/
14
#ifndef T3_TERMINAL_H
15
#define T3_TERMINAL_H
16
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
#include <limits.h>
27
#include <t3window/window_api.h>
28
46
#define T3_WINDOW_VERSION 0
47
48
/* Although it doesn't make a lot of sense to put this function in either this
49
file or in window.h, there is a good reason to put it in here: because
50
window.h includes terminal.h, this function (and the macro) will always
51
be available, regardless of which files the user includes. */
52
T3_WINDOW_API
long
t3_window_get_version
(
void
);
62
#if INT_MAX < 2147483647L
63
typedef
long
t3_attr_t
;
64
#else
65
typedef
int
t3_attr_t
;
66
#endif
67
72
typedef
struct
{
73
t3_attr_t
highlights
;
74
int
colors
;
75
int
pairs
;
76
int
cap_flags
;
77
}
t3_term_caps_t
;
78
80
#define T3_TERM_CAP_FG (1 << 0)
81
82
#define T3_TERM_CAP_BG (1 << 1)
83
84
#define T3_TERM_CAP_CP (1 << 2)
85
91
typedef
void (*
t3_attr_user_callback_t
)(
const
char
*str,
int
length,
int
width, t3_attr_t attr);
92
101
#define T3_ATTR_USER ((t3_attr_t) (1L << 0))
102
103
#define T3_ATTR_UNDERLINE ((t3_attr_t) (1L << 1))
104
105
#define T3_ATTR_BOLD ((t3_attr_t) (1L << 2))
106
107
#define T3_ATTR_REVERSE ((t3_attr_t) (1L << 3))
108
109
#define T3_ATTR_BLINK ((t3_attr_t) (1L << 4))
110
111
#define T3_ATTR_DIM ((t3_attr_t) (1L << 5))
112
113
#define T3_ATTR_ACS ((t3_attr_t) (1L << 6))
114
119
#define T3_ATTR_FALLBACK_ACS ((t3_attr_t) (1L << 7))
120
122
#define T3_ATTR_COLOR_SHIFT 8
123
124
#define T3_ATTR_FG(x) (((((t3_attr_t) (x)) & 0xff) + 1) << T3_ATTR_COLOR_SHIFT)
125
126
#define T3_ATTR_BG(x) (((((t3_attr_t) (x)) & 0xff) + 1) << (T3_ATTR_COLOR_SHIFT + 9))
127
128
#define T3_ATTR_FG_MASK (0x1ff << T3_ATTR_COLOR_SHIFT)
129
130
#define T3_ATTR_BG_MASK (0x1ff << (T3_ATTR_COLOR_SHIFT + 9))
131
133
#define T3_ATTR_FG_UNSPEC ((t3_attr_t) 0L)
134
135
#define T3_ATTR_FG_DEFAULT (((t3_attr_t) 257) << (T3_ATTR_COLOR_SHIFT))
136
137
#define T3_ATTR_FG_BLACK T3_ATTR_FG(0)
138
139
#define T3_ATTR_FG_RED T3_ATTR_FG(1)
140
141
#define T3_ATTR_FG_GREEN T3_ATTR_FG(2)
142
143
#define T3_ATTR_FG_YELLOW T3_ATTR_FG(3)
144
145
#define T3_ATTR_FG_BLUE T3_ATTR_FG(4)
146
147
#define T3_ATTR_FG_MAGENTA T3_ATTR_FG(5)
148
149
#define T3_ATTR_FG_CYAN T3_ATTR_FG(6)
150
151
#define T3_ATTR_FG_WHITE T3_ATTR_FG(7)
152
154
#define T3_ATTR_BG_UNSPEC ((t3_attr_t) 0L)
155
156
#define T3_ATTR_BG_DEFAULT (((t3_attr_t) 257) << (T3_ATTR_COLOR_SHIFT + 9))
157
158
#define T3_ATTR_BG_BLACK T3_ATTR_BG(0)
159
160
#define T3_ATTR_BG_RED T3_ATTR_BG(1)
161
162
#define T3_ATTR_BG_GREEN T3_ATTR_BG(2)
163
164
#define T3_ATTR_BG_YELLOW T3_ATTR_BG(3)
165
166
#define T3_ATTR_BG_BLUE T3_ATTR_BG(4)
167
168
#define T3_ATTR_BG_MAGENTA T3_ATTR_BG(5)
169
170
#define T3_ATTR_BG_CYAN T3_ATTR_BG(6)
171
172
#define T3_ATTR_BG_WHITE T3_ATTR_BG(7)
173
176
enum
{
177
T3_ACS_TTEE
=
'w'
,
178
T3_ACS_RTEE
=
'u'
,
179
T3_ACS_LTEE
=
't'
,
180
T3_ACS_BTEE
=
'v'
,
181
T3_ACS_ULCORNER
=
'l'
,
182
T3_ACS_URCORNER
=
'k'
,
183
T3_ACS_LLCORNER
=
'm'
,
184
T3_ACS_LRCORNER
=
'j'
,
185
T3_ACS_HLINE
=
'q'
,
186
T3_ACS_VLINE
=
'x'
,
187
T3_ACS_UARROW
=
'-'
,
188
T3_ACS_DARROW
=
'.'
,
189
T3_ACS_LARROW
=
','
,
190
T3_ACS_RARROW
=
'+'
,
191
T3_ACS_BOARD
=
'h'
,
192
T3_ACS_CKBOARD
=
'a'
,
193
T3_ACS_BULLET
=
'~'
,
194
T3_ACS_DIAMOND
=
'`'
,
195
T3_ACS_BLOCK
=
'0'
196
/* FIXME: add all the different known ACS chars */
197
};
198
199
#define T3_TERM_KEY_CTRL (1<<0)
200
#define T3_TERM_KEY_META (1<<1)
201
#define T3_TERM_KEY_SHIFT (1<<2)
202
203
#include "window_errors.h"
204
208
#define T3_ERR_NOT_A_TTY (-64)
209
210
#define T3_ERR_TIMEOUT (-63)
211
212
#define T3_ERR_NO_SIZE_INFO (-62)
213
214
#define T3_ERR_NONPRINT (-61)
215
216
#define T3_ERR_CHARSET_ERROR (-60)
217
218
#define T3_WARN_UPDATE_TERMINAL (-1)
219
221
T3_WINDOW_API
const
char
*
t3_window_strerror
(
int
error);
222
225
T3_WINDOW_API
int
t3_term_init(
int
fd,
const
char
*term);
226
T3_WINDOW_API
void
t3_term_deinit(
void
);
227
T3_WINDOW_API
void
t3_term_restore(
void
);
228
T3_WINDOW_API
const
char
*
t3_term_get_codeset
(
void
);
229
T3_WINDOW_API
int
t3_term_get_keychar
(
int
msec);
230
T3_WINDOW_API
void
t3_term_set_cursor
(
int
y,
int
x);
231
T3_WINDOW_API
void
t3_term_hide_cursor
(
void
);
232
T3_WINDOW_API
void
t3_term_show_cursor
(
void
);
233
T3_WINDOW_API
void
t3_term_get_size
(
int
*height,
int
*width);
234
T3_WINDOW_API
t3_bool
t3_term_resize
(
void
);
235
T3_WINDOW_API
void
t3_term_update_cursor
(
void
);
236
T3_WINDOW_API
void
t3_term_update
(
void
);
237
T3_WINDOW_API
void
t3_term_redraw
(
void
);
238
T3_WINDOW_API
void
t3_term_set_attrs
(t3_attr_t new_attrs);
239
T3_WINDOW_API
void
t3_term_set_user_callback
(
t3_attr_user_callback_t
callback);
240
T3_WINDOW_API
int
t3_term_get_keychar
(
int
msec);
241
T3_WINDOW_API
int
t3_term_unget_keychar
(
int
c);
242
T3_WINDOW_API
void
t3_term_putp
(
const
char
*str);
243
T3_WINDOW_API
t3_bool
t3_term_acs_available
(
int
idx);
244
245
T3_WINDOW_API
int
t3_term_strwidth
(
const
char
*str);
246
247
T3_WINDOW_API t3_attr_t
t3_term_combine_attrs
(t3_attr_t a, t3_attr_t b);
248
T3_WINDOW_API t3_attr_t
t3_term_get_ncv
(
void
);
249
250
T3_WINDOW_API
void
t3_term_disable_ansi_optimization(
void
);
251
253
T3_WINDOW_API
t3_bool
t3_term_can_draw
(
const
char
*str,
size_t
str_len);
254
T3_WINDOW_API
void
t3_term_set_replacement_char
(
int
c);
255
T3_WINDOW_API
t3_bool
t3_term_putc
(
char
c);
256
T3_WINDOW_API
t3_bool
t3_term_puts
(
const
char
*s);
257
T3_WINDOW_API
t3_bool
t3_term_putn
(
const
char
*s,
size_t
n);
258
267
#define t3_term_get_caps(caps) t3_term_get_caps_internal((caps), T3_WINDOW_VERSION)
268
269
T3_WINDOW_API
void
t3_term_get_caps_internal
(
t3_term_caps_t
*caps,
int
version);
270
T3_WINDOW_API
int
t3_term_get_modifiers_hack
(
void
);
271
272
#ifdef __cplusplus
273
}
/* extern "C" */
274
#endif
275
276
#endif
Generated on Sat May 3 2014 14:51:22 for libt3window by
1.8.3.1