Index: trunk/src/curses/curses_terminal.cc
===================================================================
--- trunk/src/curses/curses_terminal.cc	(revision 487)
+++ trunk/src/curses/curses_terminal.cc	(revision 514)
@@ -28,12 +28,6 @@
 	PDC_save_key_modifiers( true );
 
-	init_pair( 1, 0, 0 );
-	init_pair( 2, 1, 0 );
-	init_pair( 3, 2, 0 );
-	init_pair( 4, 3, 0 );
-	init_pair( 5, 4, 0 );
-	init_pair( 6, 5, 0 );
-	init_pair( 7, 6, 0 );
-	init_pair( 8, 7, 0 );
+	for ( short i = 0; i < 64; ++i )
+		init_pair( i+1, i % 8, i / 8 );
 
 	clear();
@@ -53,22 +47,23 @@
 }
 
-void curses_terminal::print( position p, uint32 color, char ch )
+void curses_terminal::print( position p, term_color fgcolor, term_color bgcolor, char ch )
 {
+	uint32 fcolor = fgcolor.get_color();
+	uint32 bcolor = ( bgcolor.get_color() % 8 ) * 8;
 	m_update_needed = true;
-	if ( color > 7 )
-	{
-		attrset(((static_cast<uint32>(color-7) << 24)  & 0xff000000ul ) | 0x00800000ul);
-	}
-	else
-	{
-		attrset((static_cast<uint32>(color+1) << 24)  & 0xff000000ul);
-	}
+	chtype attr = static_cast<chtype>( ( fcolor > 7 ? fcolor - 7 + bcolor : fcolor + bcolor + 1 ) << 24 );
+	if ( fcolor > 7 ) attr = attr | 0x00800000ul;
+	attrset(attr);
 	mvaddch( p.y-1, p.x-1, chtype(ch) );
 	::move( m_cursor.y-1, m_cursor.x-1 );
 }
 
-void curses_terminal::clear( rectangle r )
+void curses_terminal::clear( rectangle r, term_color fgcolor, term_color bgcolor )
 {
-	attrset( 0x00000000ul | 0x00800000ul );
+	uint32 fcolor = fgcolor.get_color();
+	uint32 bcolor = ( bgcolor.get_color() % 8 ) * 8;
+	chtype attr = static_cast<chtype>( ( fcolor > 7 ? fcolor - 7 + bcolor : fcolor + bcolor + 1 ) << 24 );
+	if ( fcolor > 7 ) attr = attr | 0x00800000ul;
+	attrset( attr );
 	for ( int x = r.ul.x-1; x <= r.lr.x-1; ++x )
 		for ( int y = r.ul.y-1; y <= r.lr.y-1; ++y )
