-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvt.h
More file actions
83 lines (72 loc) · 2.6 KB
/
vt.h
File metadata and controls
83 lines (72 loc) · 2.6 KB
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
/*
* Copyright © 2004 Bruno T. C. de Oliveira
* Copyright © 2006 Pierre Habouzit
* Copyright © 2008-2011 Marc Andre Tanner
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef VT_VT_H
#define VT_VT_H
#include <curses.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#ifndef NCURSES_MOUSE_VERSION
#define mmask_t unsigned long
#endif
enum {
/* means escape sequence was handled */
VT_HANDLER_OK,
/* means the escape sequence was not recognized yet, but
* there is hope that it still will once more characters
* arrive (i.e. it is not yet complete).
*
* The library will thus continue collecting characters
* and calling the handler as each character arrives until
* either OK or NOWAY is returned.
*/
VT_HANDLER_NOTYET,
/* means the escape sequence was not recognized, and there
* is no chance that it will even if more characters are
* added to it.
*/
VT_HANDLER_NOWAY
};
typedef struct Vt Vt;
typedef int (*vt_handler_t)(Vt *, char *es);
void vt_init(void);
void vt_set_handler(Vt *, vt_handler_t);
void vt_set_data(Vt *, void *);
void *vt_get_data(Vt *);
void vt_set_default_colors(Vt *, unsigned attrs, short fg, short bg);
Vt *vt_create(int rows, int cols, int scroll_buf_sz);
void vt_resize(Vt *, int rows, int cols);
void vt_destroy(Vt *);
pid_t vt_forkpty(Vt *, const char *, const char *argv[], const char *envp[], int *pty);
int vt_getpty(Vt *);
unsigned vt_cursor(Vt *t);
int vt_process(Vt *);
void vt_keypress(Vt *, int keycode);
int vt_write(Vt *t, const char *buf, int len);
void vt_mouse(Vt *t, int x, int y, mmask_t mask);
void vt_dirty(Vt *t);
void vt_draw(Vt *, WINDOW *win, int startrow, int startcol);
short vt_color_get(short fg, short bg);
void vt_scroll(Vt *, int rows);
void vt_noscroll(Vt *);
void vt_bell(Vt *, bool bell);
void vt_togglebell(Vt *);
#endif /* VT_VT_H */