X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=viewer.c;h=f5e43d49b1df09d0dc269b4c29a82d8472436497;hb=6edf0543111ac7f119c0255ae254159d9508f770;hp=6db88b95319a7e2edf0b93b3056bfb1effa74a64;hpb=2c77b5e6e665dcce85cc22d7673573c46137593d;p=smdp.git diff --git a/viewer.c b/viewer.c index 6db88b9..f5e43d4 100644 --- a/viewer.c +++ b/viewer.c @@ -104,9 +104,19 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { if((max_cols > COLS) || (max_lines + bar_top + bar_bottom + 2 > LINES)) { + // disable ncurses + endwin(); + + // print error fprintf(stderr, "Error: Terminal size %ix%i too small. Need at least %ix%i.\n", COLS, LINES, max_cols, max_lines + bar_top + bar_bottom + 2); - endwin(); + + // print hint to solve it + if(max_lines + bar_top + bar_bottom + 2 > LINES) + fprintf(stderr, "You may need to add additional horizontal rules ('***') to split your file in shorter slides.\n"); + if(max_cols > COLS) + fprintf(stderr, "Automatic line wrapping is not supported jet. You may need to shorten some lines by inserting line breaks.\n"); + return(1); } @@ -353,7 +363,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) { int i = 0; // increment char *c; // char pointer for iteration - char *special = "\\*_"; // list of interpreted chars + char *special = "\\*_`"; // list of interpreted chars cstack_t *stack = cstack_init(); if(line->text->text) { @@ -440,6 +450,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo case '_': wattroff(window, A_UNDERLINE); break; + // disable inline code + case '`': + wattroff(window, A_REVERSE); + break; } // remove top special char from stack @@ -464,6 +478,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo case '_': wattron(window, A_UNDERLINE); break; + // enable inline code + case '`': + wattron(window, A_REVERSE); + break; // do nothing for backslashes } @@ -495,6 +513,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo case '_': wattroff(window, A_UNDERLINE); break; + // disable inline code + case '`': + wattroff(window, A_REVERSE); + break; // do nothing for backslashes } }