[rogueclone-devel] ncurses & control characters
Brought to you by:
mlehotay
From: Michael L. <mle...@us...> - 2005-04-04 13:05:24
|
I don't think anybody actually reads this mailing list but I will post my message anyway. Maybe it will be funny in a year or two. I am trying to make rogue clone use curses again. The following program works just fine in Windows (win2k, djgpp, pdcurses). But in Linux (knoppix, gcc, ncurses) some of the characters are printed as control characters (like backspaces, not like ^D). If anybody can offer any insights, I'd appreciate it. I have a feeling the mailing list may do something crazy to the single quotes in my code when it puts this message in the web archive. That would be the funny part, I guess. -ML #include <curses.h> #define CLR_YELLOW 1 #define CLR_BLUE 2 #define CLR_RED 3 #define CLR_WHITE 4 #define CLR_GREEN 5 #define CLR_MAGENTA 6 #define CLR_STAIRS 7 struct _screenchars { chtype unx; chtype ibm; attr_t color; }; struct _screenchars rchars[] = { { '@', 0x01, COLOR_PAIR(CLR_YELLOW)|A_BOLD }, { ']', 0x08, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { ')', 0x18, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { '?', 0x0D, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { '!', 0xAD, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { '*', 0x0F, COLOR_PAIR(CLR_YELLOW)|A_BOLD }, { ':', 0x05, COLOR_PAIR(CLR_RED) }, { '/', 0xE7, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { '=', 0x09, COLOR_PAIR(CLR_BLUE)|A_BOLD }, { ',', 0x0C, COLOR_PAIR(CLR_BLUE)|A_BOLD }, /* vga blink = bright background */ { '%', 0xF0, COLOR_PAIR(CLR_STAIRS)|A_BLINK }, { '-', 0xCD, COLOR_PAIR(CLR_YELLOW) }, { '|', 0xBA, COLOR_PAIR(CLR_YELLOW) }, { '-', 0xC9, COLOR_PAIR(CLR_YELLOW) }, { '-', 0xBB, COLOR_PAIR(CLR_YELLOW) }, { '-', 0xC8, COLOR_PAIR(CLR_YELLOW) }, { '-', 0xBC, COLOR_PAIR(CLR_YELLOW) }, { '+', 0xCE, COLOR_PAIR(CLR_YELLOW) }, { '.', 0xFA, COLOR_PAIR(CLR_GREEN)|A_BOLD }, { '#', 0xB1, COLOR_PAIR(CLR_WHITE) }, { '^', 0x04, COLOR_PAIR(CLR_MAGENTA) } }; int main(void) { int i; initscr(); start_color(); init_pair(CLR_YELLOW, COLOR_YELLOW, COLOR_BLACK); init_pair(CLR_BLUE, COLOR_BLUE, COLOR_BLACK); init_pair(CLR_RED, COLOR_RED, COLOR_BLACK); init_pair(CLR_WHITE, COLOR_WHITE, COLOR_BLACK); init_pair(CLR_GREEN, COLOR_GREEN, COLOR_BLACK); init_pair(CLR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); init_pair(CLR_STAIRS, COLOR_BLACK, COLOR_GREEN); for(i=0; i<21; i++) { mvaddch(i, 0, rchars[i].unx); mvaddch(i, 2, rchars[i].unx | rchars[i].color); mvaddch(i, 4, rchars[i].ibm | A_ALTCHARSET); mvaddch(i, 6, rchars[i].ibm | A_ALTCHARSET | rchars[i].color); } refresh(); endwin(); return 0; } |