X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fviewer.c;h=d23ed73cd099162965a021502e230f4627c700a4;hb=354cf2e07ccd0d7900f96bffc279093997cbe203;hp=89365bf4b76911c4c30bc51cc331e7d8535a05cb;hpb=7a83ae3f48dc8ef279fb9168bd809048def70406;p=smdp.git diff --git a/src/viewer.c b/src/viewer.c index 89365bf..d23ed73 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -2,7 +2,7 @@ * Functions necessary to display a deck of slides in different color modes * using ncurses. Only white, red, and blue are supported, as they can be * faded in 256 color mode. - * Copyright (C) 2016 Michael Goehler + * Copyright (C) 2018 Michael Goehler * * This file is part of mdp. * @@ -75,18 +75,19 @@ static const char *list_head3 = " +- "; int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reload, int noreload, int slidenum) { - int c = 0; // char - int i = 0; // iterate - int l = 0; // line number - int lc = 0; // line count - int sc = 1; // slide count - int colors = 0; // amount of colors supported - int fade = 0; // disable color fading by default - 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 - int stop = 0; // passed stop bits per slide + int c = 0; // char + int i = 0; // iterate + int l = 0; // line number + int lc = 0; // line count + int sc = 1; // slide count + int colors = 0; // amount of colors supported + int fade = 0; // disable color fading by default + int trans = -1; // enable transparency if term supports it + int max_lines = 0; // max lines per slide + int max_lines_slide = -1; // the slide that has the most lines + int max_cols = 0; // max columns per line + int offset; // text offset + int stop = 0; // passed stop bits per slide // header line 1 is displayed at the top int bar_top = (deck->headers > 0) ? 1 : 0; @@ -153,8 +154,12 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa } max_lines = MAX(lc, max_lines); + if (lc == max_lines) { + max_lines_slide = sc; + } slide = slide->next; + ++sc; } // not enough lines @@ -164,7 +169,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa endwin(); // print error - fwprintf(stderr, L"Error: Terminal height (%i lines) too small. Need at least %i lines.\n", LINES, max_lines + bar_top + bar_bottom); + fwprintf(stderr, L"Error: Terminal height (%i lines) too small. Need at least %i lines for slide #%i.\n", LINES, max_lines + bar_top + bar_bottom, max_lines_slide); fwprintf(stderr, L"You may need to add additional horizontal rules (---) to split your file in shorter slides.\n"); // no reload @@ -256,6 +261,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa slide = deck->slide; // find slide to reload + sc = 1; while(reload > 1 && reload <= deck->slides) { slide = slide->next; sc++; @@ -346,8 +352,9 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa } // print pandoc URL references - // only if we already printed all lines of the current slide - if(!line) { + // only if we already printed all lines of the current slide (or output is stopped) + if(!line || + stop > slide->stop) { int i, ymax; getmaxyx( content, ymax, i ); for (i = 0; i < url_get_amount(); i++) { @@ -649,7 +656,8 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo // IS_CODE if(CHECK_BIT(line->bits, IS_CODE)) { - if (!CHECK_BIT(line->bits, IS_TILDE_CODE)) { + if (!CHECK_BIT(line->bits, IS_TILDE_CODE) && + !CHECK_BIT(line->bits, IS_GFM_CODE)) { // set static offset for code offset = CODE_INDENT; } @@ -974,7 +982,7 @@ int int_length (int val) { int get_slide_number(char init) { int retval = init - '0'; - char c; + int c; // block for tenths of a second when using getch, ERR if no input halfdelay(GOTO_SLIDE_DELAY); while((c = getch()) != ERR) {