+ // move the cursor in position
+ wmove(window, y, x);
+
+ // for each char in line
+ c = line->text->text;
+ while(*c) {
+
+ // if char is in special char list
+ if(strchr(special, *c)) {
+
+ // closing special char (or second backslash)
+ if((stack->top)(stack, *c)) {
+
+ switch(*c) {
+ // print escaped backslash
+ case '\\':
+ wprintw(window, "%c", *c);
+ break;
+ // disable highlight
+ case '*':
+ wattron(window, COLOR_PAIR(CP_WHITE));
+ break;
+ // disable underline
+ case '_':
+ wattroff(window, A_UNDERLINE);
+ break;
+ }
+
+ // remove top special char from stack
+ (stack->pop)(stack);
+
+ // treat special as regular char
+ } else if((stack->top)(stack, '\\')) {
+ wprintw(window, "%c", *c);
+
+ // remove backslash from stack
+ (stack->pop)(stack);
+
+ // opening special char
+ } else {
+ switch(*c) {
+ // enable highlight
+ case '*':
+ wattron(window, COLOR_PAIR(CP_RED));
+ break;
+ // enable underline
+ case '_':
+ wattron(window, A_UNDERLINE);
+ break;
+ // do nothing for backslashes
+ }
+
+ // push special char to stack
+ (stack->push)(stack, *c);
+ }
+
+ } else {
+ // print regular char
+ wprintw(window, "%c", *c);
+ }
+
+ c++;
+ }
+
+ //TODO pop stack until empty