progress
[oftp] / src / main.c
1 #include "tgfx.h"
2 #include "input.h"
3 #include "tui.h"
4 #include "ftp.h"
5
6 struct ftp *ftp;
7 struct tui_widget *uilist;
8
9 int main(void)
10 {
11         union event ev;
12
13         if(!(ftp = ftp_alloc())) {
14                 return 1;
15         }
16         if(ftp_connect(ftp, "192.168.0.4", 21) == -1) {
17                 ftp_free(ftp);
18                 return 1;
19         }
20
21         init_input();
22
23         tg_bgchar(' ');
24         tg_clear();
25
26         uilist = tui_list("Remote", 0, 0, 40, 23, 0, 0);
27         tui_add_list_item(uilist, "first item");
28         tui_add_list_item(uilist, "second item");
29         tui_add_list_item(uilist, "another item");
30         tui_add_list_item(uilist, "foo");
31
32         /*
33         tg_bgcolor(1);
34         tg_rect("Remote", 0, 0, 40, 23, TGFX_FRAME);
35         tg_rect("Local", 40, 0, 40, 23, TGFX_FRAME);
36
37         tg_bgcolor(0);
38         tg_fgcolor(7);
39         tg_text(0, 23, ">");
40         tg_setcursor(2, 23);
41         */
42
43         tui_draw(uilist);
44
45         while(wait_input(&ev)) {
46                 switch(ev.type) {
47                 case EV_KEY:
48                         if(ev.key.key == 27) goto done;
49                         break;
50
51                 default:
52                         break;
53                 }
54         }
55
56 done:
57         tg_bgchar(' ');
58         tg_bgcolor(0);
59         tg_fgcolor(7);
60         tg_clear();
61
62         cleanup_input();
63
64         ftp_free(ftp);
65         return 0;
66 }