Merge pull request #38 from FreeBirdLjj/issue#16
authorMichael Göhler <somebody.here@gmx.de>
Sat, 27 Sep 2014 10:24:02 +0000 (12:24 +0200)
committerMichael Göhler <somebody.here@gmx.de>
Sat, 27 Sep 2014 10:24:02 +0000 (12:24 +0200)
Issue#16

1  2 
README.md
src/viewer.c

diff --combined README.md
+++ b/README.md
@@@ -9,8 -9,7 +9,8 @@@
  
  mdp needs the ncursesw headers to compile.
  So make sure you have them installed:
 -- On Ubuntu/Debian you need `libncursesw5` and `libncursesw5-dev` to be installed.
 +- on Ubuntu/Debian you need `libncursesw5` and `libncursesw5-dev`
 +- on Cygwin you need `libncursesw10` and `libncurses-devel`
  
  Now download and install mdp:
  
@@@ -34,10 -33,12 +34,12 @@@ _Supports basic markdown formating:
      - headlines
      - code
      - quotes
+     - unordered list
  
  - in-line formating
      - bold text
      - underlined text
+     - code
  
  _Supports headers prefixed by @ symbol._
  
diff --combined src/viewer.c
@@@ -114,7 -114,7 +114,7 @@@ int ncurses_display(deck_t *deck, int n
          if(max_lines + bar_top + bar_bottom + 2 > LINES)
              fprintf(stderr, "You may need to add additional horizontal rules ('***') to split your file in shorter slides.\n");
          if(max_cols > COLS)
 -            fprintf(stderr, "Automatic line wrapping is not supported jet. You may need to shorten some lines by inserting line breaks.\n");
 +            fprintf(stderr, "Automatic line wrapping is not supported yet. You may need to shorten some lines by inserting line breaks.\n");
  
          return(1);
      }
@@@ -368,10 -368,40 +368,40 @@@ void add_line(WINDOW *window, int y, in
      char *c; // char pointer for iteration
      char *special = "\\*_`"; // list of interpreted chars
      cstack_t *stack = cstack_init();
+     
      if(line->text->text) {
          int offset = 0; // text offset
  
+         if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_3)) {
+             offset = next_nonblank(line->text, 0);
+             char format_s[15];
+             strcpy(&format_s[0], CHECK_BIT(line->bits, IS_UNORDERED_LIST_1)? "|   " : "    ");
+             strcpy(&format_s[4], CHECK_BIT(line->bits, IS_UNORDERED_LIST_2)? "|   " : "    ");
+             strcpy(&format_s[8], line->next && CHECK_BIT(line->next->bits, IS_UNORDERED_LIST_3)? "+-- %s" : "`-- %s");
+             mvwprintw(window,
+                       y, x,
+                       format_s,
+                       &line->text->text[offset + 2]);
+         } else if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_2)) {
+             offset = next_nonblank(line->text, 0);
+             char format_s[11];
+             strcpy(&format_s[0], CHECK_BIT(line->bits, IS_UNORDERED_LIST_1)? "|   " : "    ");
+             strcpy(&format_s[4], line->next && CHECK_BIT(line->next->bits, IS_UNORDERED_LIST_2)? "+-- %s" : "`-- %s");
+             mvwprintw(window,
+                       y, x,
+                       format_s,
+                       &line->text->text[offset + 2]);
+         } else if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_1)) {
+             offset = next_nonblank(line->text, 0);
+             char format_s[7];
+             strcpy(&format_s[0], line->next && CHECK_BIT(line->next->bits, IS_UNORDERED_LIST_1)? "+-- %s" : "`-- %s");
+             mvwprintw(window,
+                       y, x,
+                       format_s,
+                       &line->text->text[offset + 2]);
+         } else
          // IS_CODE
          if(CHECK_BIT(line->bits, IS_CODE)) {