Index: src/display/canvas.cc =================================================================== --- src/display/canvas.cc (revision 719) +++ src/display/canvas.cc (working copy) @@ -64,6 +64,20 @@ noecho(); nodelay(stdscr, TRUE); keypad(stdscr, TRUE); + + if(has_colors()) { + start_color(); + + init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); + init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); + init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); + init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); + init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); + init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); + init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); + } + curs_set(0); } @@ -88,4 +102,81 @@ return std::pair(80, 24); } +void +Canvas::print(int x, int y, char *fmt, ...) { + va_list fmtargs; + // curses has no print funcion to handle move and + // varargs at once, so do them separately + wmove(m_window, y, x); + va_start(fmtargs,fmt); + vw_printw(m_window, fmt, fmtargs); + va_end(fmtargs); } + +void +Canvas::print_color(int x, int y, char *fmt, ...) { + // part 1, do printf formatting + va_list fmtargs; + char input[1024]; + char entity[16]; + unsigned int i = 0, o = 0, e = 0; + + // will we ever want to print a string longer than + // ~200 chars? The terminal isn't that wide... + va_start(fmtargs,fmt); + vsnprintf(input, 1024, fmt, fmtargs); + va_end(fmtargs); + + + // part 2, do color formatting + // allow room for percent-sign doubling + int percs = 0; + for (i=0; i - void print(int x, int y, char* str, A1 a1) { mvwprintw(m_window, y, x, str, a1); } - - template - void print(int x, int y, char* str, A1 a1, A2 a2) { mvwprintw(m_window, y, x, str, a1, a2); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3) { mvwprintw(m_window, y, x, str, a1, a2, a3); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3, A4 a4) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7); } - - template - void print(int x, int y, char* str, - A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7, a8); } - void print_char(const chtype ch) { waddch(m_window, ch); } void print_char(int x, int y, const chtype ch) { mvwaddch(m_window, y, x, ch); }