From 11bf64f833379a70fc3f9b2adb365312810a26c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20G=C3=B6hler?= Date: Sun, 14 Sep 2014 15:17:05 +0200 Subject: [PATCH] no offset for normal text added no transparency and no fading parameters new README --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ mdp.c | 18 +++++++++++++----- viewer.c | 5 +++-- 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c4a6f2b --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ + +## mpd - A command-line based markdown presentation tool. + +--- + +*How to get started:* + + $ git clone https://github.com/visit1985/mdp.git + $ cd mdp + $ make + $ make install + $ mdp sample.md + +--- + +*How to use it:* + +_Horizontal rulers are used as slide separator._ + +_Supports basic markdown formatting:_ + +- line wide formatting + - headlines + - code + - quotes + +- in-line formatting + - bold text + - underlined text + +--- + +*Controls:* + +- h, j, k, l, Cursor keys, + Space, Enter, Backspace - next/previous slide +- Home - go to first slide +- End - go to last slide +- 0-9 - go to slide n +- q - exit + diff --git a/mdp.c b/mdp.c index 5ce6990..d641faa 100644 --- a/mdp.c +++ b/mdp.c @@ -28,9 +28,11 @@ void usage() { fprintf(stderr, "%s", "Usage: mdp [OPTION]... [FILE]\n"); fprintf(stderr, "%s", "A command-line based markdown presentation tool.\n\n"); - fprintf(stderr, "%s", " -d, --debug enable debug messages on STDERR\n"); - fprintf(stderr, "%s", " add it multiple times to increases debug level\n\n"); - fprintf(stderr, "%s", " -h, --help display this help and exit\n"); + fprintf(stderr, "%s", " -d, --debug enable debug messages on STDERR\n"); + fprintf(stderr, "%s", " add it multiple times to increases debug level\n"); + fprintf(stderr, "%s", " -f, --nofade disable color fading in 256 color mode\n"); + fprintf(stderr, "%s", " -h, --help display this help and exit\n"); + fprintf(stderr, "%s", " -t, --notrans disable transparency in transparent terminal\n"); fprintf(stderr, "%s", "\nWith no FILE, or when FILE is -, read standard input.\n\n"); exit(EXIT_FAILURE); } @@ -46,21 +48,27 @@ void version() { } int main(int argc, char *argv[]) { + int notrans = 0; + int nofade = 0; // define command-line options struct option longopts[] = { { "debug", no_argument, 0, 'd' }, + { "nofade", no_argument, 0, 'f' }, { "help", no_argument, 0, 'h' }, + { "notrans", no_argument, 0, 't' }, { "version", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; // parse command-line options int opt, debug = 0; - while ((opt = getopt_long(argc, argv, ":dhv", longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, ":dfhtv", longopts, NULL)) != -1) { switch(opt) { case 'd': debug += 1; break; + case 'f': nofade = 1; break; case 'h': usage(); break; + case 't': notrans = 1; break; case 'v': version(); break; case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break; case '?': @@ -100,7 +108,7 @@ int main(int argc, char *argv[]) { markdown_debug(deck, debug); } - ncurses_display(deck, 0, 0); + ncurses_display(deck, notrans, nofade); return(EXIT_SUCCESS); } diff --git a/viewer.c b/viewer.c index 7f1fb85..5494670 100644 --- a/viewer.c +++ b/viewer.c @@ -116,9 +116,11 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { 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(notrans) trans = 16; // black in 256 color mode + // 256 color mode init_pair(CP_WHITE, 255, trans); init_pair(CP_BLUE, 123, trans); @@ -317,7 +319,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 - offset = next_nonblank(line->text, 0); // IS_CODE if(CHECK_BIT(line->bits, IS_CODE)) { -- 2.20.1