X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fviewer.c;h=3e4284b472a439cda2ed6cc33962fdc11bacb319;hb=698e2f33adf0ca6ada826a61b1db0c2dfce3bc3a;hp=747329cb288599cab7245c7d079ccaec65700737;hpb=43aa3385fb0e78b302a9191789d59115402035f8;p=smdp.git diff --git a/src/viewer.c b/src/viewer.c index 747329c..3e4284b 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -113,11 +113,11 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { fprintf(stderr, "Error: Terminal width (%i columns) too small. Need at least %i columns.\n", COLS, i); fprintf(stderr, "You may need to shorten some lines by inserting line breaks.\n"); - return(1); + return 1; } // set max_cols - max_cols = (i > max_cols) ? i : max_cols; + max_cols = MAX(i, max_cols); // iterate to next line offset = prev_blank(line->text, offset + COLS); @@ -125,16 +125,16 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { lc++; } // set max_cols one last time - max_cols = (i > max_cols) ? i : max_cols; + max_cols = MAX(i, max_cols); } else { // set max_cols - max_cols = (line->length > max_cols) ? line->length : max_cols; + max_cols = MAX(line->length, max_cols); } lc++; line = line->next; } - max_lines = (lc > max_lines) ? lc : max_lines; + max_lines = MAX(lc, max_lines); slide = slide->next; } @@ -149,7 +149,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { fprintf(stderr, "Error: Terminal heigth (%i lines) too small. Need at least %i lines.\n", LINES, max_lines + bar_top + bar_bottom); fprintf(stderr, "You may need to add additional horizontal rules ('***') to split your file in shorter slides.\n"); - return(1); + return 1; } // disable cursor @@ -194,7 +194,8 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { init_pair(CP_YELLOW, 208, trans); // enable color fading - if(!nofade) fade = 1; + if(!nofade) + fade = true; // 8 color mode } else { @@ -273,8 +274,8 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { // print lines while(line) { add_line(content, l, (COLS - max_cols) / 2, line, max_cols, colors); + l += (line->length / COLS) + 1; line = line->next; - l++; } // make content visible @@ -285,7 +286,8 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { fade_in(content, trans, colors, invert); // re-enable fading after any undefined key press - if(COLORS == 256 && !nofade) fade = 1; + if(COLORS == 256 && !nofade) + fade = true; // wait for user input c = getch(); @@ -307,7 +309,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { slide = slide->prev; sc--; } else { - fade = 0; + fade = false; } break; @@ -323,7 +325,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { slide = slide->next; sc++; } else { - fade = 0; + fade = false; } break; @@ -355,7 +357,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { } } else { // disable fading if slide n doesn't exist - fade = 0; + fade = false; } break; @@ -378,13 +380,13 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { // quit case 'q': // do not fade out on exit - fade = 0; - slide = (void*)0; + fade = false; + slide = NULL; break; default: // disable fading on undefined key press - fade = 0; + fade = false; break; } @@ -395,7 +397,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { endwin(); - return(0); + return 0; } void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) {