#define FADE_DELAY 15000 // micro seconds
#define GOTO_SLIDE_DELAY 5 // tenths of seconds
-int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reload, int noreload, int slidenum);
-void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors);
-void inline_display(WINDOW *window, const wchar_t *c, const int colors);
+int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reload, int noreload, int slidenum, int nocodebg);
+void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors, int nocodebg);
+void inline_display(WINDOW *window, const wchar_t *c, const int colors, int nocodebg);
void fade_out(WINDOW *window, int trans, int colors, int invert);
void fade_in(WINDOW *window, int trans, int colors, int invert);
int int_length (int val);
fprintf(stderr, "%s", " -s, --noslidenum do not show slide number at the bottom\n");
fprintf(stderr, "%s", " -v, --version display the version number and license\n");
fprintf(stderr, "%s", " -x, --noslidemax show slide number, but not total number of slides\n");
+ fprintf(stderr, "%s", " -c, --nocodebg don't change the background color of code blocks\n");
fprintf(stderr, "%s", "\nWith no FILE, or when FILE is -, read standard input.\n\n");
exit(EXIT_FAILURE);
}
int reload = 0; // reload page N (0 means no reload)
int noreload = 1; // reload disabled until we know input is a file
int slidenum = 2; // 0:don't show; 1:show #; 2:show #/#
+ int nocodebg = 0; // 0:show code bg as inverted; 1: don't invert code bg
// define command-line options
struct option longopts[] = {
{ "version", no_argument, 0, 'v' },
{ "noslidenum", no_argument, 0, 's' },
{ "noslidemax", no_argument, 0, 'x' },
+ { "nocodebg", no_argument, 0, 'c' },
{ 0, 0, 0, 0 }
};
// parse command-line options
int opt, debug = 0;
- while ((opt = getopt_long(argc, argv, ":defhitvsx", longopts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, ":defhitvsxc", longopts, NULL)) != -1) {
switch(opt) {
case 'd': debug += 1; break;
case 'e': noexpand = 0; break;
case 'v': version(); break;
case 's': slidenum = 0; break;
case 'x': slidenum = 1; break;
+ case 'c': nocodebg = 1; break;
case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break;
case '?':
default : fprintf(stderr, "%s: option '%c' is invalid\n", argv[0], optopt); usage(); break;
markdown_debug(deck, debug);
}
- reload = ncurses_display(deck, notrans, nofade, invert, reload, noreload, slidenum);
+ reload = ncurses_display(deck, notrans, nofade, invert, reload, noreload, slidenum, nocodebg);
free_deck(deck);
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 ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reload, int noreload, int slidenum, int nocodebg) {
int c = 0; // char
int i = 0; // iterate
// print lines
while(line) {
add_line(content, l + ((LINES - slide->lines_consumed - bar_top - bar_bottom) / 2),
- (COLS - max_cols) / 2, line, max_cols, colors);
+ (COLS - max_cols) / 2, line, max_cols, colors, nocodebg);
// raise stop counter if we pass a line having a stop bit
if(CHECK_BIT(line->bits, IS_STOP))
}
}
-void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) {
+void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors, int nocodebg) {
int i; // increment
int offset = 0; // text offset
// fill rest off line with spaces if we are in a code block
if(CHECK_BIT(line->bits, IS_CODE) && colors) {
- if(colors)
+ if(colors && !nocodebg)
wattron(window, COLOR_PAIR(CP_BLACK));
for(i = getcurx(window) - x; i < max_cols; i++)
wprintw(window, "%s", " ");
"%s", prompt);
if(!CHECK_BIT(line->bits, IS_CODE))
- inline_display(window, &line->text->value[offset], colors);
+ inline_display(window, &line->text->value[offset], colors, nocodebg);
// IS_UNORDERED_LIST_2
} else if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_2)) {
"%s", prompt);
if(!CHECK_BIT(line->bits, IS_CODE))
- inline_display(window, &line->text->value[offset], colors);
+ inline_display(window, &line->text->value[offset], colors, nocodebg);
// IS_UNORDERED_LIST_1
} else if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_1)) {
"%s", prompt);
if(!CHECK_BIT(line->bits, IS_CODE))
- inline_display(window, &line->text->value[offset], colors);
+ inline_display(window, &line->text->value[offset], colors, nocodebg);
}
// IS_CODE
}
// reverse color for code blocks
- if(colors)
+ if(colors && !nocodebg)
wattron(window, COLOR_PAIR(CP_BLACK));
// print whole lines
offset = next_word(line->text, offset);
}
- inline_display(window, &line->text->value[offset], colors);
+ inline_display(window, &line->text->value[offset], colors, nocodebg);
} else {
// IS_CENTER
// no line-wide markdown
} else {
- inline_display(window, &line->text->value[offset], colors);
+ inline_display(window, &line->text->value[offset], colors, nocodebg);
}
}
}
wattroff(window, A_UNDERLINE);
}
-void inline_display(WINDOW *window, const wchar_t *c, const int colors) {
+void inline_display(WINDOW *window, const wchar_t *c, const int colors, int nocodebg) {
const static wchar_t *special = L"\\*_`!["; // list of interpreted chars
const wchar_t *i = c; // iterator
const wchar_t *start_link_name, *start_url;
break;
// enable inline code
case L'`':
- if(colors)
+ if(colors && !nocodebg)
wattron(window, COLOR_PAIR(CP_BLACK));
break;
// do nothing for backslashes