blob: 6676eea4d32971b4db59af6d547d978f36698a60 (
plain)
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
|
public class CursesUI {
MessageBox messages;
Dialog dialog;
Logo banner;
ClockWindow clkwin;
StatusPanel statuswin;
public CursesUI() {
/* unicode support */
Intl.setlocale(LocaleCategory.CTYPE, "");
/* initialize curses */
Curses.initscr();
/* disable cursor */
Curses.curs_set(0);
/* initialize color mode and define color pairs */
Curses.start_color();
Curses.init_pair(0, Curses.Color.WHITE, Curses.Color.BLACK);
Curses.init_pair(1, Curses.Color.GREEN, Curses.Color.BLACK);
Curses.init_pair(2, Curses.Color.WHITE, Curses.Color.RED);
/* initialize widgets */
banner = new Logo();
statuswin = new StatusPanel();
messages = new MessageBox();
clkwin = new ClockWindow();
clkwin.update();
Timeout.add_seconds(10, update_time);
}
~CursesUI() {
exit();
}
public void exit() {
/* Reset the terminal mode */
Curses.endwin();
}
bool update_time() {
clkwin.update();
return true;
}
public void status(string message) {
statuswin.set(message);
}
public void log(string message) {
messages.add(message);
}
public void dialog_open(string title, string message) {
dialog = new Dialog(message, title);
}
public void dialog_close() {
dialog = null;
messages.redraw();
banner.redraw();
clkwin.redraw();
statuswin.redraw();
}
}
|