Ignore:
Timestamp:
08/08/16 18:25:48 (9 years ago)
Author:
epyon
Message:
  • term_color implementation
  • support for background color
  • support for RGBA encoding
  • initial gfx_terminal implementation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/curses/curses_terminal.cc

    r487 r514  
    2828        PDC_save_key_modifiers( true );
    2929
    30         init_pair( 1, 0, 0 );
    31         init_pair( 2, 1, 0 );
    32         init_pair( 3, 2, 0 );
    33         init_pair( 4, 3, 0 );
    34         init_pair( 5, 4, 0 );
    35         init_pair( 6, 5, 0 );
    36         init_pair( 7, 6, 0 );
    37         init_pair( 8, 7, 0 );
     30        for ( short i = 0; i < 64; ++i )
     31                init_pair( i+1, i % 8, i / 8 );
    3832
    3933        clear();
     
    5347}
    5448
    55 void curses_terminal::print( position p, uint32 color, char ch )
     49void curses_terminal::print( position p, term_color fgcolor, term_color bgcolor, char ch )
    5650{
     51        uint32 fcolor = fgcolor.get_color();
     52        uint32 bcolor = ( bgcolor.get_color() % 8 ) * 8;
    5753        m_update_needed = true;
    58         if ( color > 7 )
    59         {
    60                 attrset(((static_cast<uint32>(color-7) << 24)  & 0xff000000ul ) | 0x00800000ul);
    61         }
    62         else
    63         {
    64                 attrset((static_cast<uint32>(color+1) << 24)  & 0xff000000ul);
    65         }
     54        chtype attr = static_cast<chtype>( ( fcolor > 7 ? fcolor - 7 + bcolor : fcolor + bcolor + 1 ) << 24 );
     55        if ( fcolor > 7 ) attr = attr | 0x00800000ul;
     56        attrset(attr);
    6657        mvaddch( p.y-1, p.x-1, chtype(ch) );
    6758        ::move( m_cursor.y-1, m_cursor.x-1 );
    6859}
    6960
    70 void curses_terminal::clear( rectangle r )
     61void curses_terminal::clear( rectangle r, term_color fgcolor, term_color bgcolor )
    7162{
    72         attrset( 0x00000000ul | 0x00800000ul );
     63        uint32 fcolor = fgcolor.get_color();
     64        uint32 bcolor = ( bgcolor.get_color() % 8 ) * 8;
     65        chtype attr = static_cast<chtype>( ( fcolor > 7 ? fcolor - 7 + bcolor : fcolor + bcolor + 1 ) << 24 );
     66        if ( fcolor > 7 ) attr = attr | 0x00800000ul;
     67        attrset( attr );
    7368        for ( int x = r.ul.x-1; x <= r.lr.x-1; ++x )
    7469                for ( int y = r.ul.y-1; y <= r.lr.y-1; ++y )
Note: See TracChangeset for help on using the changeset viewer.