diff options
author | Louie S <louie@example.com> | 2023-07-05 16:39:37 -0700 |
---|---|---|
committer | Louie S <louie@example.com> | 2023-07-05 16:39:37 -0700 |
commit | 2d4457781f7262bef67d6681767db9393ce35b6d (patch) | |
tree | 41abffa1a45ac556d2df47d0580705a972e50042 /src | |
parent | 0bf5e72a2ee87af0e7ac3e2b769359084829a20f (diff) |
Draw due date if it exists
Diffstat (limited to 'src')
-rw-r--r-- | src/draw.c | 22 | ||||
-rw-r--r-- | src/main.c | 2 |
2 files changed, 17 insertions, 7 deletions
@@ -1,12 +1,14 @@ #include <curses.h> #include <signal.h> #include <stdlib.h> +#include <string.h> +#include <time.h> #include "draw.h" #include "entry.h" #include "group.h" -void draw_data(Group **groups, int g_count, Entry **entries, int e_count, int start_x, int start_y); +void draw_data(Group **groups, int g_count, Entry **entries, int e_count, WINDOW *w, int start_x, int start_y); void tui_init(Group **groups, int g_count, Entry **entries, int e_count) { int input; // capture user input @@ -25,10 +27,10 @@ void tui_init(Group **groups, int g_count, Entry **entries, int e_count) { w_main = newwin(0, 0, 0, 0); box(w_main, 0, 0); refresh(); - wrefresh(w_main); // draw groups and entries - draw_data(groups, g_count, entries, e_count, 1, 1); + draw_data(groups, g_count, entries, e_count, w_main, 1, 1); + wrefresh(w_main); input = getch(); tui_end(); @@ -42,16 +44,24 @@ void tui_end() { -void draw_data(Group **groups, int g_count, Entry **entries, int e_count, int start_x, int start_y) { +void draw_data(Group **groups, int g_count, Entry **entries, int e_count, WINDOW *w, int start_x, int start_y) { int i; int j; + char buf[BUF_LEN]; for(i = 0; i < g_count; ++i) { - mvprintw(start_y, start_x, "%s", group_get_name(&((*groups)[i]))); + mvwprintw(w, start_y, start_x, "%s", group_get_name(&((*groups)[i]))); ++start_y; for(j = 0; j < e_count; ++j) { if(entry_get_group_id(&((*entries)[j])) == group_get_id(&((*groups)[i]))) { - mvprintw(start_y, start_x, "\t%s", entry_get_title(&((*entries)[i]))); + mvwprintw(w, start_y, start_x, "\t"); + if(entry_get_due_date(&((*entries)[j])) != NULL) { + memset(buf, 0, BUF_LEN); + strftime(buf, BUF_LEN, "%a, %m/%d", entry_get_due_date(&((*entries)[j]))); + wprintw(w, "%s: ", buf); + } + //mvprintw(start_y, start_x, "\t%s", entry_get_title(&((*entries)[i]))); + wprintw(w, "%s", entry_get_title(&((*entries)[i]))); ++start_y; } } @@ -45,7 +45,7 @@ int main() { if(groups == NULL) perror("could not get groups"); if(entries == NULL) perror("could not get entries"); - //tui_init(&groups, group_count, &entries, entry_count); + tui_init(&groups, group_count, &entries, entry_count); return 0; } |