aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorache <ache@ache.one>2017-11-11 03:57:47 +0000
committerache <ache@ache.one>2017-11-11 03:57:47 +0000
commit65087f82753a12e330fa0e6fc0c0e4b70c6a6c63 (patch)
tree00c4f4a5a022ab5a631ff738315eb830a039922b /main.c
parentInit commit (diff)
PoC menu Contact
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/main.c b/main.c
index 3c5a6f5..a75a553 100644
--- a/main.c
+++ b/main.c
@@ -41,6 +41,7 @@ WINDOW *sep_win;
char status[10];
+
void fail_exit(const char *msg) {
if (visual_mode)
endwin();
@@ -99,10 +100,10 @@ int main(int argc, char* argv[]){
CHECK(start_color);
}
- CHECK(cbreak);
CHECK(noecho);
CHECK(nonl);
- CHECK(intrflush, NULL, FALSE);
+ CHECK(intrflush, stdscr, FALSE);
+ CHECK(keypad, stdscr, TRUE);
visual_mode = true;
curs_set(0);
@@ -115,23 +116,45 @@ int main(int argc, char* argv[]){
CHECK(wrefresh, sep_win);
init_readline();
+ int r = 0;
+ if( r = fillContactList("contact.csv") ) {
+ return r;
+ }
+
for(int i = 0 ; i < 9 ; i++) {
init_pair( i+1, i, COLOR_BLACK);
}
/* Premier affichage */
+ resize();
/* Event loop */
while( c = getch() ) {
if (c == KEY_RESIZE) {
+ resize();
+ refresh();
continue;
}
+ if ( c == 'q' ) {
+ break;
+ }
+ switch( c ) {
+ case KEY_DOWN:
+ case KEY_RIGHT:
+ case 'j':
+ selectNextContact();
+ break;
+ case KEY_UP:
+ case KEY_LEFT:
+ case 'k':
+ selectPreviousContact();
+ break;
+ }
- refresh();
+ resize();
}
refresh();
- getch();
end:
endwin();