forked from mono/mono-curses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmono-curses.c
77 lines (61 loc) · 1.05 KB
/
mono-curses.c
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
#include <ncurses.h>
#include <sys/types.h>
#include <signal.h>
#include <stdint.h>
void *console_sharp_get_stdscr ()
{
return stdscr;
}
void *console_sharp_get_curscr ()
{
return curscr;
}
void *console_sharp_get_newscr ()
{
return newscr;
}
void console_sharp_get_dims (int *lines, int *cols)
{
*lines = LINES;
*cols = COLS;
}
void console_sharp_sendsigtstp ()
{
killpg (0, SIGTSTP);
}
int64_t console_sharp_mouse_mask (int64_t newmask, int64_t *oldmask)
{
mmask_t old;
mmask_t ret;
ret = mousemask (newmask, &old);
*oldmask = old;
return ret;
}
typedef struct {
int ID;
int X, Y, Z;
int64_t ButtonState;
} MouseEvent;
int console_sharp_getmouse (MouseEvent *event)
{
MEVENT m;
int c = getmouse (&m);
if (c == -1)
return -1;
event->ID = m.id;
event->X = m.x;
event->Y = m.y;
event->Z = m.z;
event->ButtonState = m.bstate;
return c;
}
int console_sharp_ungetmouse (MouseEvent *event)
{
MEVENT m;
m.x = event->X;
m.y = event->Y;
m.z = event->Z;
m.id = event->ID;
m.bstate = event->ButtonState;
return ungetmouse (&m);
}