aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-08-02 15:17:44 +0000
committerdam <dam@gudinoff>2022-08-02 15:17:44 +0000
commit64cd0650c3b99aeba12c4eb9cb3da3555105b8e1 (patch)
treec338e561f64ea0eaa5135fb3ee9c224e1089772c
parentdc6db567d464bb710398c39dba67d396187f1b0c (diff)
downloadtask-time-tracker-64cd0650c3b99aeba12c4eb9cb3da3555105b8e1.tar.zst
task-time-tracker-64cd0650c3b99aeba12c4eb9cb3da3555105b8e1.zip
Moved table header to top row and fixed initial UI draw.
-rw-r--r--task_tracker.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/task_tracker.c b/task_tracker.c
index 6bef5d4..9984618 100644
--- a/task_tracker.c
+++ b/task_tracker.c
@@ -6,32 +6,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;
}