forked from JonasOberhauser/gocurses
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.go
More file actions
executable file
·65 lines (54 loc) · 872 Bytes
/
Copy pathsample.go
File metadata and controls
executable file
·65 lines (54 loc) · 872 Bytes
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
package main
import . "curses"
import "os"
import "fmt"
func main() {
x := 10;
y := 10;
startGoCurses();
defer stopGoCurses();
Init_pair(1, COLOR_RED, COLOR_BLACK);
loop(x, y);
}
func startGoCurses() {
Initscr();
if Stdwin == nil {
stopGoCurses();
os.Exit(1);
}
Noecho();
Curs_set(CURS_HIDE);
Stdwin.Keypad(true);
if err := Start_color(); err != nil {
fmt.Printf("%s\n", err.String());
stopGoCurses();
os.Exit(1);
}
}
func stopGoCurses() {
Endwin();
}
func loop(x, y int) {
for {
Stdwin.Addstr(0, 0, "Hello,\nworld!", 0);
inp := Stdwin.Getch();
if inp == 'q' {
break;
}
if inp == KEY_LEFT {
x = x - 1;
}
if inp == KEY_RIGHT {
x = x + 1;
}
if inp == KEY_UP {
y = y - 1;
}
if inp == KEY_DOWN {
y = y + 1;
}
Stdwin.Clear();
Stdwin.Addch(x, y, '@', Color_pair(1));
Stdwin.Refresh();
}
}