X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=tmp.c;h=a806ff446234c39c9bd610167e29896ca96e4c5e;hb=70ce4d7eba90b5da6f9187eb217794db6f153888;hp=f2d7e32108715d4334aca3b93a857e1d78422b4e;hpb=c29cfeaa5c6ab5c7e0c39415fe3c9c103c8bdf64;p=smdp.git diff --git a/tmp.c b/tmp.c index f2d7e32..a806ff4 100644 --- a/tmp.c +++ b/tmp.c @@ -4,12 +4,14 @@ #include #include -#include "include/markdown.h" +#include "include/parser.h" +#include "include/viewer.h" void usage() { fprintf(stderr, "Usage: tmp [OPTION]... [FILE]\n"); fprintf(stderr, "A command-line based markdown presentation tool.\n\n"); fprintf(stderr, " -d, --debug enable debug messages on STDERR\n"); + fprintf(stderr, " add it multiple times to increases debug level\n\n"); fprintf(stderr, " -h, --help display this help and exit\n"); fprintf(stderr, "\nWith no FILE, or when FILE is -, read standard input.\n\n"); exit(EXIT_FAILURE); @@ -28,7 +30,7 @@ int main(int argc, char *argv[]) { int opt, debug = 0; while ((opt = getopt_long(argc, argv, ":dh", longopts, NULL)) != -1) { switch(opt) { - case 'd': debug = 1; break; + case 'd': debug += 1; break; case 'h': usage(); break; case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break; case '?': @@ -57,41 +59,18 @@ int main(int argc, char *argv[]) { input = stdin; } - // load document object from input - document_t *doc; - doc = markdown_load(input); + // load deck object from input + deck_t *deck; + deck = markdown_load(input); - if(debug) { - // print header to STDERR - int offset; - line_t *header; - if(doc->header) { - header = doc->header; - while(header && - header->text->size > 0 && - header->text->text[0] == '%') { + //TODO close file - offset = next_blank(header->text, 0) + 1; - printf("header: %s\n", &header->text->text[offset]); - header = header->next; - } - } - - // print page/line count to STDERR - int cp = 0, cl = 0; - page_t *page = doc->page; - line_t *line; - while(page) { - cp++; - line = page->line; - cl = 0; - while(line) { - cl++; - line = line->next; - } - printf("page %i: %i lines\n", cp, cl); - page = page->next; - } + if(debug > 0) { + markdown_debug(deck, debug); } + + ncurses_display(deck, 0, 0); + + return(EXIT_SUCCESS); }