forked from nitlang/nitutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caca.nit
26 lines (20 loc) · 780 Bytes
/
caca.nit
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
module caca is pkgconfig
`{
#include <caca.h>
`}
extern class CacaCanvas `{ caca_canvas_t* `}
fun put(text: String, x,y: Int) do native_put(text.to_cstring, x, y)
fun native_put(text: NativeString, x,y: Int) `{ caca_put_str(self, x, y, text); `}
fun draw_line(x1, y1, x2, y2: Int) `{ caca_draw_thin_line (self, x1, y1, x2, y2); `}
fun width: Int `{ return caca_get_canvas_width(self); `}
fun height: Int `{ return caca_get_canvas_height(self); `}
end
extern class CacaDisplay `{ caca_display_t* `}
new `{ return caca_create_display(NULL); `}
fun quit `{
caca_event_t ev;
caca_get_event(self, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_free_display(self); `}
fun canvas: CacaCanvas `{ return caca_get_canvas(self); `}
fun refresh `{ caca_refresh_display(self); `}
end