git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3451 c06c8d41-db1a-0410-9941-cceddc491573
M4MLRSFTU4ROTG2FSBYG3WNA52MR5LFDTQLFZCX3XC2FJYEHB5GQC QOYITYZZM3BXITPZGSQGAVUM4T5H6ZL4QYRG5H5W7PSELOF2PO2QC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC PL6I2CMSTHY5ZHWVMIQE5YTM5S5VPKBNZM6QJVHZSSKOJGIJ5W4AC GCIZIUXO5TYROKDUYB3HAY7H7MRDTJNM7HR7DGSH7KXDIZC2LCDAC CVC5FFFLGVRR3KPYDNB6RF4FNACV3LI3HPSR4MCUNZ4C3FSQYBDAC FWVE7KM7BGEZUFQVM7H7UFGM3QMMPT7QHLNXSP62HG3SMBIPZBSQC // Wrapper around curses waddstr(); handles switching to the alt charset// when necessary, and performing the funny DEC translation.// Returns a curses success value.static int waddstr_with_altcharset(WINDOW* w, const char* str){int ret = OK;if (Options.char_set == CSET_ASCII || Options.char_set == CSET_UNICODE){// In ascii, we don't expect any high-bit chars.// In Unicode, str is UTF-8 and we shouldn't touch anything.ret = waddstr(w, str);}else{// Otherwise, high bit indicates alternate charset.// DEC line-drawing chars don't have the high bit, so// we map them into 0xE0 and above.const bool bDEC = (Options.char_set == CSET_DEC);const char* begin = str;
while (true){const char* end = begin;// Output a range of normal characters (the common case)while (*end && (unsigned char)*end <= 127) ++end;if (end-begin) ret = waddnstr(w, begin, end-begin);// Then a single high-bit characterchtype c = (unsigned char)*end;if (c == 0)break;else if (bDEC && c >= 0xE0)ret = waddch(w, (c & 0x7F) | A_ALTCHARSET);else // if (*end > 127)ret = waddch(w, c | A_ALTCHARSET);begin = end+1;}}return ret;}
// NOTE: This affects libunix.cc draw state; use this just before setting// textcolour and drawing a character and call set_altcharset(false)// after you're done drawing.//unsigned cset_adjust(unsigned raw)
void put_colour_ch(int colour, unsigned ch)
// switch to alternate char set for 8-bit characters:set_altcharset( raw > 127 );// shift the DEC line drawing set:if (Options.char_set == CSET_DEC&& raw >= 0xE0){raw &= 0x7F;}
// Unicode can't or-in curses attributes; but it also doesn't have// to fool around with altcharsettextattr(colour);putwch(ch);
return (raw);}
else{const unsigned oldch = ch;if (oldch & 0x80) ch |= A_ALTCHARSET;// Shift the DEC line drawing setif (oldch >= 0xE0 && Options.char_set == CSET_DEC)ch ^= 0x80;textattr(colour);