From: Michael Göhler Date: Fri, 29 Aug 2014 11:55:39 +0000 (+0200) Subject: display header / footer from deck header + some compiler warnings X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=ea429fb3f31aaee9f8b931b56b4488c70b2b7549;p=smdp.git display header / footer from deck header + some compiler warnings --- diff --git a/parser.c b/parser.c index 29dbf83..3b56b5b 100644 --- a/parser.c +++ b/parser.c @@ -360,12 +360,12 @@ int next_nonblank(cstring_t *text, int i) { ++i; return i; -}; +} int next_blank(cstring_t *text, int i) { while ((i < text->size) && !isspace((text->text)[i])) ++i; return i; -}; +} diff --git a/test/fade.c b/test/fade.c index c358d58..6ba3757 100644 --- a/test/fade.c +++ b/test/fade.c @@ -30,10 +30,6 @@ int main() 19, 20, 20, 21, 27, 32, 33, 38, 39, 44, 45, 45, 81, 81, 51, 51, 123, 123}; - short white_ramp[] = {232, 233, 234, 235, 236, 237, - 238, 239, 240, 241, 242, 243, - 244, 245, 246, 247, 248, 249, - 250, 251, 252, 253, 254, 255}; short red_ramp[] = { 16, 52, 52, 53, 53, 89, 89, 90, 90, 126, 127, 127, 163, 163, 164, 164, 200, 200, diff --git a/viewer.c b/viewer.c index d6b5c85..57b88df 100644 --- a/viewer.c +++ b/viewer.c @@ -28,6 +28,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { int trans = -1; // enable transparency if term supports it int max_lines = 0; // max lines per slide int max_cols = 0; // max columns per line + int offset; // text offset // header line 1 is displayed at the top int bar_top = (deck->headers > 0) ? 1 : 0; @@ -113,18 +114,31 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { // setup header if(bar_top) { - //TODO move cursor to calculated indentation - wmove(stdscr, 0, 1); - //TODO add text to header - wprintw(stdscr, "header"); + line = deck->header; + offset = next_blank(line->text, 0) + 1; + // add text to header + mvwprintw(stdscr, + 0, (COLS - line->length + offset) / 2, + "%s", &line->text->text[offset]); } // setup footer if(bar_bottom) { - //TODO move cursor to calculated indentation - wmove(stdscr, LINES - 1, 1); - //TODO add text to footer - wprintw(stdscr, "footer"); + line = deck->header->next; + offset = next_blank(line->text, 0) + 1; + // add text to left footer + mvwprintw(stdscr, + LINES - 1, 0, + "%s", &line->text->text[offset]); + + if(deck->headers > 2) { + line = deck->header->next->next; + offset = next_blank(line->text, 0) + 1; + // add text to right footer + mvwprintw(stdscr, + LINES - 1, COLS - line->length + offset, + "%s", &line->text->text[offset]); + } } // make header + fooder visible @@ -141,7 +155,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { werase(content); //TODO print lines - wprintw(content, "content"); + wprintw(content, "%s", "content"); // make content visible wrefresh(content);