4 #include "include/parser.h"
5 #include "include/viewer.h"
7 int ncurses_display(deck_t *deck, int notrans, int nofade) {
10 int colors = 0; // amount of colors supported
11 int fade = 0; // disable color fading by default
12 int trans = -1; // enable transparency if term supports it
13 int max_lines = 0; // max lines per slide
14 int max_cols = 0; // max columns per line
16 // header line 1 is displayed at the top
17 int bar_top = (deck->headers > 0) ? 1 : 0;
18 // header line 2 and 3 are displayed at the bottom
19 int bar_bottom = (deck->headers > 1) ? 1 : 0;
21 slide_t *slide = deck->slide;
25 // set max_lines if line count exceeded
26 max_lines = (slide->lines > max_lines) ? slide->lines : max_lines;
29 // set max_cols if length exceeded
30 max_cols = (line->length > max_cols) ? line->length : max_cols;
36 if((max_cols > COLS) ||
37 (max_lines + bar_top + bar_bottom + 2 > LINES)) {
39 fprintf(stderr, "Error: Terminal size %ix%i to small. Need at least %ix%i.\n",
40 COLS, LINES, max_cols, max_lines + bar_top + bar_bottom + 2);
44 // replace stdin with current tty if markdown input was piped
45 freopen("/dev/tty", "rw", stdin);
53 // disable output of keyboard typing
56 // make getch() process one char at a time
63 if(has_colors() == TRUE) {
67 if(!notrans) trans = 0; // 0 is black
71 init_pair(CP_WHITE, 255, trans);
72 init_pair(CP_BLUE, 123, trans);
73 init_pair(CP_RED, 213, trans);
74 init_pair(CP_YELLOW, 208, trans);
76 // enable color fading
81 init_pair(CP_WHITE, 7, trans);
82 init_pair(CP_BLUE, 4, trans);
83 init_pair(CP_RED, 1, trans);
84 init_pair(CP_YELLOW, 3, trans);
90 // set background color of main window
92 wbkgd(stdscr, COLOR_PAIR(CP_YELLOW));
96 //TODO move cursor to calculated indentation
98 //TODO add text to header
99 wprintw(stdscr, "header");
104 //TODO move cursor to calculated indentation
105 wmove(stdscr, LINES - 1, 1);
106 //TODO add text to footer
107 wprintw(stdscr, "footer");
111 WINDOW *content = newwin(LINES - bar_top - bar_bottom, COLS, 0, 0 + bar_top);
113 wbkgd(content, COLOR_PAIR(CP_WHITE));
118 // print header / footer
122 // wait for user input
125 // evaluate user input
128 // show previous slide