David Parsons for his inspiring Markdown implementation in C
https://github.com/Orc/discount
+
+++ /dev/null
-# set some compiler flags
-CFLAGS=-g -Wall -lncurses
-
-# find *.c in the current directory
-SOURCES=$(wildcard *.c)
-
-# define the output objects by replacing .c with .o
-TARGETS=$(SOURCES:.c=)
-
-# this will make all objects
-all: $(TARGETS)
-
-# each objects will be build by a *.c file
-#%.o: %.c
-%: %.c
- cc $(CFLAGS) -o $@ $^
-
-# this will delete all objects
-# if not all objects are there, they will be compiled first
-clean: $(TARGETS)
- rm -f $^
-
+++ /dev/null
-#include <stdio.h>
-
-#include "../include/markdown.h"
-
-int main(int argc, char *argv[]) {
-
- int i = 0;
- printf("INIT: %i\n", i);
-
- SET_BIT(i, IS_H1);
- printf("SET_BIT(%i): %i\n", IS_H1, i);
-
- printf("CHECK_BIT(%i): %i\n", IS_H1, CHECK_BIT(i, IS_H1));
-
- TOGGLE_BIT(i, IS_H2);
- printf("TOGGLE_BIT(%i): %i\n", IS_H2, i);
-
- printf("CHECK_BIT(%i): %i\n", IS_H2, CHECK_BIT(i, IS_H2));
-
- TOGGLE_BIT(i, IS_H2);
- printf("TOGGLE_BIT(%i): %i\n", IS_H2, i);
-
- CLEAR_BIT(i, IS_H1);
- printf("CLEAR_BIT(%i): %i\n", IS_H1, i);
-
- printf("CHECK_BIT(%i): %i\n", IS_H1, CHECK_BIT(i, IS_H1));
- printf("CHECK_BIT(%i): %i\n", IS_H2, CHECK_BIT(i, IS_H2));
-
- return(0);
-}
-
+++ /dev/null
-#include <ncurses.h>
-
-WINDOW *w;
-
-void set_colors(void)
-{
- int i;
- initscr();
- start_color();
- use_default_colors();
-
- for(i=0; i < COLORS; i++)
- {
- init_pair(i, i, -1);
- attron(COLOR_PAIR(i));
- printw(" %3.hd", i);
- if((i + 1) % 36 == 0) printw("\n");
- refresh();
- }
- standend();
- getch();
- endwin();
-}
-
-int main(void)
-{
- set_colors();
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-
-#include "../include/cstack.h"
-#include "../cstack.c"
-
-int main(int argc, char *argv[]) {
-
- cstack_t *s = cstack_init();
- printf("INIT: head: %d, size: %zu, alloc: %zu\n", s->head, s->size, s->alloc);
-
- (s->push)(s, 'a');
- printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
-
- (s->push)(s, 'b');
- printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
-
- (s->push)(s, 'c');
- printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
-
- char ch = (s->pop)(s);
- printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
-
- ch = (s->pop)(s);
- printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
-
- (s->push)(s, 'd');
- printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
-
- (s->push)(s, 'e');
- printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
-
- while(s->size > 0) {
- ch = (s->pop)(s);
- printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
- }
-
- (s->delete)(s);
-
- return(0);
-}
-
+++ /dev/null
-#include <stdio.h>
-
-#include "../include/cstring.h"
-#include "../cstring.c"
-
-int main(int argc, char *argv[]) {
-
- // testing with char
- cstring_t *p = cstring_init();
- printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
-
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand)(p, 'X'); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
-
- (p->reset)(p);
- printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
-
- char x[2] = {'X', '\0'};
-
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
- (p->expand_arr)(p, x); printf("text: %s, size: %zu, alloc: %zu\n", p->text, p->size, p->alloc);
-
- (p->delete)(p);
-
- return(0);
-}
-
+++ /dev/null
-#include <ncurses.h>
-#include <signal.h>
-#include <stdlib.h>
-#define COLOR_PAIR1 1
-#define COLOR_PAIR2 2
-int main()
-{
- initscr();
- curs_set(0);//sets visability of cursor
- noecho();//disable auto-echoing
- cbreak();//making getch() work without a buffer
- keypad(stdscr,TRUE);//allows use of special keys, namely the arrow keys
- if(has_colors() == TRUE)
- {
- start_color();
- use_default_colors();
- init_pair(COLOR_PAIR1,123,-1);
- init_pair(COLOR_PAIR2,213,-1);
- wbkgd(stdscr,COLOR_PAIR(COLOR_PAIR1));
- wmove(stdscr,10,5);
- printw("q = quit");
- WINDOW *test=newwin(10,20,5,20);
- wbkgd(test,COLOR_PAIR(COLOR_PAIR2));
- wprintw(test,"try\nUP or DOWN");
- wrefresh(stdscr);
- wrefresh(test);
-
- // fading colors
- short blue_ramp[] = { 16, 17, 17, 18, 18, 19,
- 19, 20, 20, 21, 27, 32,
- 33, 38, 39, 44, 45, 45,
- 81, 81, 51, 51, 123, 123};
- short red_ramp[] = { 16, 52, 52, 53, 53, 89,
- 89, 90, 90, 126, 127, 127,
- 163, 163, 164, 164, 200, 200,
- 201, 201, 207, 207, 213, 213};
-
- short i = 23;
- for (;;)
- {
- int c = getch();
- if(c == 'q') break;
-
- switch(c) {
- case KEY_UP:
- if(i < 23) i = i + 1;
- break;
-
- case KEY_DOWN:
- if(i > 0)i = i - 1;
- break;
- }
-
- init_pair(COLOR_PAIR1,blue_ramp[i],-1);
- init_pair(COLOR_PAIR2,red_ramp[i],-1);
- wrefresh(stdscr);
- wrefresh(test);
- }
-
- delwin(test);
- }
-
- endwin();
- return 0;
-}