From eb7baf83704e5ffa3d0059e8db34b3c3508b2428 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 27 Oct 2007 15:59:10 +0000 Subject: Minor view code cleanup; this ought to fix the DOS redraw issues as well. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2629 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/libunix.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crawl-ref/source/libunix.cc') diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index 1f8f1d67f9..c4a64a779e 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -593,6 +593,44 @@ int window(int x1, int y1, int x2, int y2) return (refresh()); } +// 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. +// +int cset_adjust(int raw) +{ + if (Options.char_set != CSET_ASCII && Options.char_set != CSET_UNICODE) + { + // 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; + } + } + return (raw); +} + +void puttext(int x1, int y1, int x2, int y2, const screen_buffer_t *buf) +{ + for (int y = y1; y <= y2; ++y) + { + gotoxy(x1, y); + for (int x = x1; x <= x2; ++x) + { + const screen_buffer_t ch = cset_adjust( *buf ); + textattr( buf[1] ); + putwch( ch ); + buf += 2; + } + } + set_altcharset(false); + update_screen(); +} + // These next four are front functions so that we can reduce // the amount of curses special code that occurs outside this // this file. This is good, since there are some issues with -- cgit v1.2.3-54-g00ecf