reformatting c
[taskasaur.git] / main.c
1 #include <stdio.h>
2 #include <ncurses.h>
3 #include <signal.h>
4 #include <unistd.h>
5
6 void winch_handler(int sig); 
7
8 WINDOW* create_list_win(int height, int width, int y, int x);
9
10 int 
11 main(int argc, char** argv) 
12 {
13     int height, width;
14     int x, y;
15     int ch;
16     WINDOW* todo_win;
17
18     signal(SIGWINCH, winch_handler);
19
20     // start ncurses 
21     initscr();
22     cbreak();
23     /* raw(); */
24     noecho();
25     start_color();
26     
27     init_pair(1, COLOR_CYAN, COLOR_BLACK); 
28     init_pair(2, COLOR_BLACK, COLOR_CYAN); 
29
30     getmaxyx(stdscr, height, width);
31     x = y = 0;
32     refresh();
33
34     todo_win = create_list_win(20, 20, 5, 5);
35     
36     move(y,x);
37     while ((ch = getch()) != 113) {
38         
39         //ofc the first thing we need is vim keys 
40         switch (ch) {
41             case 104: // h
42                 x -= 1;
43                 break;
44             case 106: // j
45                 y += 1;
46                 break;
47             case 107: // k
48                 y -= 1;
49                 break;
50             case 108: // l
51                 x += 1;
52                 break;
53         } 
54
55         move(y,x);
56         refresh();
57         /* clear(); */
58     }
59
60     endwin();
61     return 0;
62 }
63
64 void 
65 winch_handler(int sig) 
66 {
67     endwin();
68     refresh();
69 }
70
71 WINDOW* 
72 create_list_win(int height, int width, int y, int x)
73 {
74     WINDOW* new_win = newwin(height, width, y, x);
75     box(new_win, 0, 0);
76     wrefresh(new_win);
77     return new_win;
78 }