summaryrefslogtreecommitdiffstats
path: root/src/screen.c
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-10-13 20:54:32 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-10-13 20:54:32 (EDT)
commit351ba155fdf7db739f45f9d4381f0b979d9037ab (patch)
treef8e7685dec21526de0e859547e0c10f167d9504d /src/screen.c
parentbb65b69a5b97f9f5508f4fa5adbdc19b480ee638 (diff)
downloadtimeteller-351ba155fdf7db739f45f9d4381f0b979d9037ab.zip
timeteller-351ba155fdf7db739f45f9d4381f0b979d9037ab.tar.gz
timeteller-351ba155fdf7db739f45f9d4381f0b979d9037ab.tar.bz2
clock_*(): New functions
And create and draw the clock on the screen.
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/screen.c b/src/screen.c
index a8b8b26..f705701 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -25,8 +25,11 @@
#include <curses.h>
#include <stdlib.h>
+#include "clock.h"
+
struct screen {
- WINDOW *win;
+ WINDOW *win;
+ struct clock *clock;
};
struct screen *
@@ -46,12 +49,23 @@ screen_new(void)
}
curs_set(0); /* Ignore errors. */
+ screen->clock = clock_new(screen->win);
+ if (screen->clock == NULL) {
+ free(screen);
+ return NULL;
+ }
+
return screen;
}
void
screen_draw(struct screen *screen)
{
+ assert(screen);
+
+ clock_draw(screen->clock);
+
+ refresh();
}
struct screen *
@@ -66,6 +80,8 @@ screen_destroy(struct screen **screen_p)
delwin(screen->win);
endwin();
+ clock_destroy(&screen->clock);
+
free(screen);
return screen = NULL;
}