X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fviewer.c;h=cbb1498f73746f889506272642bbbd17a7586ff1;hb=4ebae8ba8f3700f740d2705f7a3c2dc92f4995dc;hp=2c4c8fa68aa26322d4dcb82375636b6eecbc29f2;hpb=072515bbb5e9ab6125d4cf237cd253a33eab1bad;p=smdp.git diff --git a/src/viewer.c b/src/viewer.c index 2c4c8fa..cbb1498 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -61,20 +61,33 @@ static short red_ramp_invert[24] = { 15, 231, 231, 224, 224, 225, 206, 207, 201, 200, 199, 199, 198, 198, 197, 197, 196, 196}; +// unordered list characters +// +// override via env vars: +// export MDP_LIST_OPEN1=" " MDP_LIST_OPEN2=" " MDP_LIST_OPEN3=" " +// export MDP_LIST_HEAD1=" ■ " MDP_LIST_HEAD2=" ● " MDP_LIST_HEAD3=" ▫ " +static const char *list_open1 = " | "; +static const char *list_open2 = " | "; +static const char *list_open3 = " | "; +static const char *list_head1 = " +- "; +static const char *list_head2 = " +- "; +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; @@ -141,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 @@ -152,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 @@ -244,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 = 0; while(reload > 1 && reload <= deck->slides) { slide = slide->next; sc++; @@ -334,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++) { @@ -517,27 +536,6 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa return reload; } -static const char *list_open1 = " | "; -static const char *list_open2 = " | "; -static const char *list_open3 = " | "; -static const char *list_head1 = " +- "; -static const char *list_head2 = " +- "; -static const char *list_head3 = " +- "; -/* -export MDP_LIST_OPEN1=" " -export MDP_LIST_OPEN2=" " -export MDP_LIST_OPEN3=" " -export MDP_LIST_HEAD1=" ■ " -export MDP_LIST_HEAD2=" ▫ " -export MDP_LIST_HEAD3=" ● " - -export MDP_LIST_OPEN1=" │ " -export MDP_LIST_OPEN2=" │ " -export MDP_LIST_OPEN3=" │ " -export MDP_LIST_HEAD1=" ▇─ " -export MDP_LIST_HEAD2=" ▓─ " -export MDP_LIST_HEAD3=" ▒─ " -*/ void setup_list_strings(void) { const char *str;