From 64cd0650c3b99aeba12c4eb9cb3da3555105b8e1 Mon Sep 17 00:00:00 2001 From: dam Date: Tue, 2 Aug 2022 15:17:44 +0000 Subject: Moved table header to top row and fixed initial UI draw. --- task_tracker.c | 59 ++++++++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) (limited to 'task_tracker.c') diff --git a/task_tracker.c b/task_tracker.c index 6bef5d4..9984618 100644 --- a/task_tracker.c +++ b/task_tracker.c @@ -5,32 +5,6 @@ void draw_header() -{ - const char *app_name = "Task Tracker"; - const char *app_version = "v1.0"; - - int row,col; /* to store the number of rows and the number of colums of the screen */ - initscr(); /* start the curses mode */ - getmaxyx(stdscr,row,col); /* get the number of rows and columns */ - - mvaddch(0, 0, ACS_ULCORNER); - addch(ACS_HLINE); - addch(' '); - printw(app_name); - addch(' '); - for (int idx = strlen(app_name) + 4; idx < col - strlen(app_version) - 4; idx ++) { - addch(ACS_HLINE); - } - addch(' '); - printw(app_version); - addch(' '); - addch(ACS_HLINE); - addch(ACS_URCORNER); -// addch('@'); -// mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg); -} - -void draw_table() { const char *table_headers[] = { "Task", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Total" }; const int table_headers_size = sizeof(table_headers)/sizeof(char*); @@ -39,7 +13,7 @@ void draw_table() initscr(); /* start the curses mode */ getmaxyx(stdscr,row,col); /* get the number of rows and columns */ - mvaddch(1, 0, ACS_LTEE); + mvaddch(0, 0, ACS_ULCORNER); for (int idx = 0; idx < table_headers_size; idx++) { if (idx > 0) { addch(ACS_TTEE); @@ -56,7 +30,12 @@ void draw_table() for (int idx = cursor_x; idx < col-1; idx++) { addch(ACS_HLINE); } - addch(ACS_RTEE); + addch(ACS_URCORNER); +} + +void draw_table() +{ + } void draw_footer() @@ -109,40 +88,42 @@ int main(int argc, char *argv[]) int rows; int colums; - halfdelay(10); - while((ch = getch()) != KEY_F(1)) - { - draw_header(); - draw_table(); - draw_footer(); + ch = KEY_RESIZE; + do { switch(ch) { case KEY_RESIZE: -// getmaxyx(stdscr, rows, colums); -// resizeterm(rows, colums); erase(); break; - + case KEY_LEFT: destroy_win(my_win); my_win = create_newwin(height, width, starty,--startx); break; + case KEY_RIGHT: destroy_win(my_win); my_win = create_newwin(height, width, starty,++startx); break; + case KEY_UP: destroy_win(my_win); my_win = create_newwin(height, width, --starty,startx); break; + case KEY_DOWN: destroy_win(my_win); my_win = create_newwin(height, width, ++starty,startx); break; } - } + + draw_header(); + draw_table(); + draw_footer(); + + } while((ch = getch()) != KEY_F(1)); - endwin(); /* End curses mode */ + endwin(); return 0; } -- cgit v1.2.3