pinosaur
/
smdp.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moved file handling to mdp.c completely
[smdp.git]
/
viewer.c
diff --git
a/viewer.c
b/viewer.c
index
7f1fb85
..
a97e44d
100644
(file)
--- a/
viewer.c
+++ b/
viewer.c
@@
-4,7
+4,7
@@
* faded in 256 color mode.
* Copyright (C) 2014 Michael Goehler
*
* faded in 256 color mode.
* Copyright (C) 2014 Michael Goehler
*
- * This file is part of m
pd
.
+ * This file is part of m
dp
.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-81,16
+81,13
@@
int ncurses_display(deck_t *deck, int notrans, int nofade) {
// set locale to display UTF-8 correctly in ncurses
setlocale(LC_CTYPE, "");
// set locale to display UTF-8 correctly in ncurses
setlocale(LC_CTYPE, "");
- // replace stdin with current tty if markdown input was piped
- freopen("/dev/tty", "rw", stdin);
-
// init ncurses
initscr();
if((max_cols > COLS) ||
(max_lines + bar_top + bar_bottom + 2 > LINES)) {
// init ncurses
initscr();
if((max_cols > COLS) ||
(max_lines + bar_top + bar_bottom + 2 > LINES)) {
- fprintf(stderr, "Error: Terminal size %ix%i to small. Need at least %ix%i.\n",
+ fprintf(stderr, "Error: Terminal size %ix%i to
o
small. Need at least %ix%i.\n",
COLS, LINES, max_cols, max_lines + bar_top + bar_bottom + 2);
endwin();
return(1);
COLS, LINES, max_cols, max_lines + bar_top + bar_bottom + 2);
endwin();
return(1);
@@
-116,9
+113,11
@@
int ncurses_display(deck_t *deck, int notrans, int nofade) {
start_color();
use_default_colors();
start_color();
use_default_colors();
- if(notrans) trans = 0; //
0 is black
+ if(notrans) trans = 0; //
black in 8 color mode
if(COLORS == 256) {
if(COLORS == 256) {
+ if(notrans) trans = 16; // black in 256 color mode
+
// 256 color mode
init_pair(CP_WHITE, 255, trans);
init_pair(CP_BLUE, 123, trans);
// 256 color mode
init_pair(CP_WHITE, 255, trans);
init_pair(CP_BLUE, 123, trans);
@@
-189,7
+188,7
@@
int ncurses_display(deck_t *deck, int notrans, int nofade) {
// print lines
while(line) {
// print lines
while(line) {
- add_line(content, l, (COLS - max_cols) / 2, line, max_cols);
+ add_line(content, l, (COLS - max_cols) / 2, line, max_cols
, colors
);
line = line->next;
l++;
}
line = line->next;
l++;
}
@@
-309,7
+308,7
@@
int ncurses_display(deck_t *deck, int notrans, int nofade) {
return(0);
}
return(0);
}
-void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
+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
int i = 0; // increment
char *c; // char pointer for iteration
char *special = "\\*_"; // list of interpreted chars
@@
-317,7
+316,6
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
if(line->text->text) {
int offset = 0; // text offset
if(line->text->text) {
int offset = 0; // text offset
- offset = next_nonblank(line->text, 0);
// IS_CODE
if(CHECK_BIT(line->bits, IS_CODE)) {
// IS_CODE
if(CHECK_BIT(line->bits, IS_CODE)) {
@@
-339,7
+337,8
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
if(CHECK_BIT(line->bits, IS_H1) || CHECK_BIT(line->bits, IS_H2)) {
// set headline color
if(CHECK_BIT(line->bits, IS_H1) || CHECK_BIT(line->bits, IS_H2)) {
// set headline color
- wattron(window, COLOR_PAIR(CP_BLUE));
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_BLUE));
// enable underline for H1
if(CHECK_BIT(line->bits, IS_H1))
// enable underline for H1
if(CHECK_BIT(line->bits, IS_H1))
@@
-392,7
+391,8
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
break;
// disable highlight
case '*':
break;
// disable highlight
case '*':
- wattron(window, COLOR_PAIR(CP_WHITE));
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_WHITE));
break;
// disable underline
case '_':
break;
// disable underline
case '_':
@@
-415,7
+415,8
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
switch(*c) {
// enable highlight
case '*':
switch(*c) {
// enable highlight
case '*':
- wattron(window, COLOR_PAIR(CP_RED));
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_RED));
break;
// enable underline
case '_':
break;
// enable underline
case '_':
@@
-439,17
+440,16
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
// pop stack until empty to prevent formated trailing spaces
while(!(stack->empty)(stack)) {
switch((stack->pop)(stack)) {
// pop stack until empty to prevent formated trailing spaces
while(!(stack->empty)(stack)) {
switch((stack->pop)(stack)) {
- case '\\':
- wprintw(window, "%c", '\\');
- break;
// disable highlight
case '*':
// disable highlight
case '*':
- wattron(window, COLOR_PAIR(CP_WHITE));
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_WHITE));
break;
// disable underline
case '_':
wattroff(window, A_UNDERLINE);
break;
break;
// disable underline
case '_':
wattroff(window, A_UNDERLINE);
break;
+ // do nothing for backslashes
}
}
}
}
}
}
@@
-460,7
+460,8
@@
void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols) {
wprintw(window, "%s", " ");
// reset to default color
wprintw(window, "%s", " ");
// reset to default color
- wattron(window, COLOR_PAIR(CP_WHITE));
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_WHITE));
wattroff(window, A_UNDERLINE);
wattroff(window, A_REVERSE);
}
wattroff(window, A_UNDERLINE);
wattroff(window, A_REVERSE);
}