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
|
ldat :: struct {
text :*void; /* text of the line */
firstchar :s16; /* first changed character in the line */
lastchar :s16; /* last changed character in the line */
oldindex :s16; /* index of the line at last update */
};
// TODO This also works...
WINDOW :: struct {
data : [88] u8;
}
WINDOWx :: struct {
_cury, _curx : s16; /* current cursor position */
/* window location and size */
_maxy, _maxx : s16; /* maximums of x and y, NOT window size */
_begy, _begx : s16; /* screen coords of upper-left-hand corner */
_flags :s16; /* window state flags */
/* attribute tracking */
_attrs :u8; /* current attribute for non-space character */
_bkgd :u8; /* current background char/attribute pair */
/* option values set by user */
_notimeout :bool; /* no time out on function-key entry? */
_clear :bool; /* consider all data in the window invalid? */
_leaveok :bool; /* OK to not reset cursor on exit? */
_scroll :bool; /* OK to scroll this window? */
_idlok :bool; /* OK to use insert/delete line? */
_idcok :bool; /* OK to use insert/delete char? */
_immed :bool; /* window in immed mode? (not yet used) */
_sync :bool; /* window in sync mode? */
_use_keypad :bool; /* process function keys into KEY_ symbols? */
_delay :s32; /* 0 = nodelay, <0 = blocking, >0 = delay */
_line :*ldat; /* the actual line data */
/* global screen state */
_regtop :s16; /* top line of scrolling region */
_regbottom :s16; /* bottom line of scrolling region */
/* these are used only if this is a sub-window */
_parx :s32; /* x coordinate of this window in parent */
_pary :s32; /* y coordinate of this window in parent */
_parent :*WINDOW; /* pointer to parent if a sub-window */
/* these are used only if this is a pad */
pdat :: struct
{
_pad_y, _pad_x :s16 ;
_pad_top, _pad_left :s16;
_pad_bottom, _pad_right :s16;
};
_pad :pdat;
_yoffset :s16; /* real begy is _begy + _yoffset */
/*
#if NCURSES_WIDECHAR
cchar_t _bkgrnd;
#if 1
int _color;
#endif
#endif
*/
};
tinfo :: #system_library "libtinfo"; // Required by some of ncurses functions.
// NOTE
// Must use local lib while having package libncurses-dev installed because it introduces
// an override file:
// > cat /lib/x86_64-linux-gnu/libncurses.so
// INPUT(libncursesw.so.6 -ltinfo)
// I suspect this is an attempt to help the compilers to include libtinfo automatically.
// ncurses :: #system_library "libncurses";
ncurses :: #library "libncurses";
COLOR_BLACK :: 0;
COLOR_RED :: 1;
COLOR_GREEN :: 2;
COLOR_YELLOW :: 3;
COLOR_BLUE :: 4;
COLOR_MAGENTA :: 5;
COLOR_CYAN :: 6;
COLOR_WHITE :: 7;
stdscr : *WINDOW;
initscr :: () -> *WINDOW #foreign ncurses;
getch :: () -> s8 #foreign ncurses;
endwin :: () -> void #foreign ncurses;
cbreak :: () -> void #foreign ncurses;
start_color :: () -> void #foreign ncurses;
use_default_colors :: () -> void #foreign ncurses;
keypad :: (win: *WINDOW, bf: bool) -> s32 #foreign ncurses;
curs_set :: (visibility: s32) -> s32 #foreign ncurses;
mvaddstr :: (y: s32, x: s32, str: *u8) -> s32 #foreign ncurses;
noecho :: () -> s32 #foreign ncurses;
box :: (win: *WINDOW, verch: u8, horch: u8) -> s32 #foreign ncurses;
init_pair :: (pair: s16, f: s16, b: s16) -> s32 #foreign ncurses;
|