X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=viewer.c;h=c4e6b90f93849cb2284b5b29d45da6ca9ced5a6e;hb=b0159e9e6cdf21c13cb94387146301aa000726c7;hp=ffe1c970bc3f7c1da6059dee503470f329fa09d5;hpb=ebef3b3f1031622ad04c4ba10c3aff8cf4f2ef08;p=smdp.git diff --git a/viewer.c b/viewer.c index ffe1c97..c4e6b90 100644 --- a/viewer.c +++ b/viewer.c @@ -4,7 +4,7 @@ * faded in 256 color mode. * Copyright (C) 2014 Michael Goehler * - * This file is part of mpd. + * This file is part of mdp. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,9 +116,11 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { start_color(); use_default_colors(); - if(notrans) trans = 0; // 0 is black + if(notrans) trans = 0; // black in 8 color mode if(COLORS == 256) { + if(notrans) trans = 16; // black in 256 color mode + // 256 color mode init_pair(CP_WHITE, 255, trans); init_pair(CP_BLUE, 123, trans); @@ -154,6 +156,9 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { werase(content); werase(stdscr); + // always resize window in case terminal geometry has changed + wresize(content, LINES - bar_top - bar_bottom, COLS); + // setup header if(bar_top) { line = deck->header; @@ -165,12 +170,14 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { } // setup footer - line = deck->header->next; - offset = next_blank(line->text, 0) + 1; - // add text to left footer - mvwprintw(stdscr, - LINES - 1, 3, - "%s", &line->text->text[offset]); + if(deck->headers > 1) { + line = deck->header->next; + offset = next_blank(line->text, 0) + 1; + // add text to left footer + mvwprintw(stdscr, + LINES - 1, 3, + "%s", &line->text->text[offset]); + } // add slide number to right footer mvwprintw(stdscr, LINES - 1, COLS - int_length(deck->slides) - int_length(sc) - 6, @@ -312,7 +319,6 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) { if(line->text->text) { int offset = 0; // text offset - offset = next_nonblank(line->text, 0); // IS_CODE if(CHECK_BIT(line->bits, IS_CODE)) { @@ -434,9 +440,6 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) { // pop stack until empty to prevent formated trailing spaces while(!(stack->empty)(stack)) { switch((stack->pop)(stack)) { - case '\\': - wprintw(window, "%c", '\\'); - break; // disable highlight case '*': wattron(window, COLOR_PAIR(CP_WHITE)); @@ -445,6 +448,7 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) { case '_': wattroff(window, A_UNDERLINE); break; + // do nothing for backslashes } } }