summaryrefslogtreecommitdiff
path: root/src/draw.c
blob: 04e02e2a73694f639c898c43e83a21ab87c057d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <curses.h>
#include <signal.h>
#include <stdlib.h>

#include "draw.h"

void tui_init(Group **groups, Entry **entries) {
	int input; // capture user input
	WINDOW *w_main;
	
	// set an interrupt to end cleanly
	signal(SIGINT, tui_end);

	// init and set options
	initscr();
	keypad(stdscr, TRUE); // enable arrow keys and other function keys
	cbreak();             // set for interactive curses applications
	curs_set(0);             // hide cursor

	// set main window
	w_main = newwin(0, 0, 0, 0);
	box(w_main, 0, 0);
	refresh();
	wrefresh(w_main);

	// draw groups and entries
	fprintf(stderr, "groups: %d\n", sizeof(*groups) / sizeof(Group));
	fprintf(stderr, "entries: %d\n", sizeof(*entries) / sizeof(Entry));

	input = getch();
	tui_end();
	free(*groups);
	free(*entries);
}

void tui_end() {
	endwin();
}