- Timestamp:
- 08/08/16 18:25:48 (9 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/ascii_printer.cc
r487 r514 15 15 } 16 16 17 void ascii_printer::print( const string_view& text, const position& p, uint32color )17 void ascii_printer::print( const string_view& text, const position& p, term_color color ) 18 18 { 19 19 position coord( p ); 20 20 for ( char c : text ) 21 21 { 22 m_terminal->print( coord, color, c );22 m_terminal->print( coord, color, term_color(), c ); 23 23 ++coord.x; 24 24 if ( coord.x >= m_terminal->get_size().x ) break; … … 26 26 } 27 27 28 void nv::ascii_printer::frame( const nv::rectangle& area, const nv::string_view& border_chars, uint32color )28 void nv::ascii_printer::frame( const nv::rectangle& area, const nv::string_view& border_chars, term_color color ) 29 29 { 30 30 if ( border_chars.length() < 8 ) 31 31 { 32 m_terminal->clear( area );32 m_terminal->clear( area, color, term_color() ); 33 33 return; 34 34 } 35 m_terminal->clear( area.shrinked( 1 ) );35 m_terminal->clear( area.shrinked( 1 ), color, term_color() ); 36 36 for ( int x = 0; x < area.get_width(); ++x ) 37 37 { 38 m_terminal->print( position( area.ul.x + x, area.ul.y ), color, border_chars[0] );39 m_terminal->print( position( area.ul.x + x, area.lr.y ), color, border_chars[1] );38 m_terminal->print( position( area.ul.x + x, area.ul.y ), color, term_color(), border_chars[0] ); 39 m_terminal->print( position( area.ul.x + x, area.lr.y ), color, term_color(), border_chars[1] ); 40 40 } 41 41 42 42 for ( int y = 0; y < area.get_height(); ++y ) 43 43 { 44 m_terminal->print( position( area.ul.x, area.ul.y + y ), color, border_chars[2] );45 m_terminal->print( position( area.lr.x, area.ul.y + y ), color, border_chars[3] );44 m_terminal->print( position( area.ul.x, area.ul.y + y ), color, term_color(), border_chars[2] ); 45 m_terminal->print( position( area.lr.x, area.ul.y + y ), color, term_color(), border_chars[3] ); 46 46 } 47 47 48 m_terminal->print( area.ul, color, border_chars[4] );49 m_terminal->print( area.ur(), color, border_chars[5] );50 m_terminal->print( area.ll(), color, border_chars[6] );51 m_terminal->print( area.lr, color, border_chars[7] );48 m_terminal->print( area.ul, color, term_color(), border_chars[4] ); 49 m_terminal->print( area.ur(), color, term_color(), border_chars[5] ); 50 m_terminal->print( area.ll(), color, term_color(), border_chars[6] ); 51 m_terminal->print( area.lr, color, term_color(), border_chars[7] ); 52 52 } -
trunk/src/curses/curses_terminal.cc
r487 r514 28 28 PDC_save_key_modifiers( true ); 29 29 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 ); 38 32 39 33 clear(); … … 53 47 } 54 48 55 void curses_terminal::print( position p, uint32color, char ch )49 void curses_terminal::print( position p, term_color fgcolor, term_color bgcolor, char ch ) 56 50 { 51 uint32 fcolor = fgcolor.get_color(); 52 uint32 bcolor = ( bgcolor.get_color() % 8 ) * 8; 57 53 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); 66 57 mvaddch( p.y-1, p.x-1, chtype(ch) ); 67 58 ::move( m_cursor.y-1, m_cursor.x-1 ); 68 59 } 69 60 70 void curses_terminal::clear( rectangle r )61 void curses_terminal::clear( rectangle r, term_color fgcolor, term_color bgcolor ) 71 62 { 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 ); 73 68 for ( int x = r.ul.x-1; x <= r.lr.x-1; ++x ) 74 69 for ( int y = r.ul.y-1; y <= r.lr.y-1; ++y ) -
trunk/src/gui/gui_ascii_renderer.cc
r487 r514 15 15 struct ascii_render_data : public render_data 16 16 { 17 ascii_render_data() {}18 bool clear;19 bool border;20 char border_chars[8];21 uint32border_color;22 uint32text_color;17 bool clear; 18 bool border; 19 char border_chars[8]; 20 ivec2 padding; 21 term_color border_color; 22 term_color text_color; 23 23 }; 24 24 … … 38 38 er->border = false; 39 39 er->clear = false; 40 er->text_color = 0;41 40 e->m_render_data = er; 42 41 } … … 57 56 58 57 m_style.get( e, "ascii_color", selector, color ); 59 er->text_color = uint32( color );58 er->text_color = term_color::color( color ); 60 59 er->border = false; 60 vec4 padding; 61 m_style.get( e, "ascii_padding", selector, padding ); 62 er->padding = ivec2( int( padding.x ), int( padding.y ) ); 63 61 64 if ( m_style.get( e, "ascii_border", selector, path ) ) 62 65 { … … 65 68 int border_color = 0; 66 69 if ( m_style.get( e, "ascii_border_color", selector, border_color ) ) 67 er->border_color = uint32( border_color );70 er->border_color = term_color::color( border_color ); 68 71 for ( uint32 i = 0; i < 8 && i < path.length(); i++ ) 69 72 er->border_chars[i] = path[i]; … … 76 79 ascii_render_data* er = static_cast< ascii_render_data* >( e->m_render_data ); 77 80 rectangle abs = e->m_absolute; 78 if ( er->clear ) m_terminal->clear( abs );81 if ( er->clear ) m_terminal->clear( abs, term_color::LIGHTGRAY, term_color() ); 79 82 if ( er->border ) 80 83 { 81 84 for ( int x = 0; x < abs.get_width(); ++x ) 82 85 { 83 m_terminal->print( position( abs.ul.x + x, abs.ul.y ), er->border_color, er->border_chars[0] );84 m_terminal->print( position( abs.ul.x + x, abs.lr.y ), er->border_color, er->border_chars[1] );86 m_terminal->print( position( abs.ul.x + x, abs.ul.y ), er->border_color, term_color(), er->border_chars[0] ); 87 m_terminal->print( position( abs.ul.x + x, abs.lr.y ), er->border_color, term_color(), er->border_chars[1] ); 85 88 } 86 89 87 90 for ( int y = 0; y < abs.get_height(); ++y ) 88 91 { 89 m_terminal->print( position( abs.ul.x, abs.ul.y + y ), er->border_color, er->border_chars[2] );90 m_terminal->print( position( abs.lr.x, abs.ul.y + y ), er->border_color, er->border_chars[3] );92 m_terminal->print( position( abs.ul.x, abs.ul.y + y ), er->border_color, term_color(), er->border_chars[2] ); 93 m_terminal->print( position( abs.lr.x, abs.ul.y + y ), er->border_color, term_color(), er->border_chars[3] ); 91 94 } 92 95 93 m_terminal->print( abs.ul, er->border_color, er->border_chars[4] );94 m_terminal->print( abs.ur(), er->border_color, er->border_chars[5] );95 m_terminal->print( abs.ll(), er->border_color, er->border_chars[6] );96 m_terminal->print( abs.lr, er->border_color, er->border_chars[7] );96 m_terminal->print( abs.ul, er->border_color, term_color(), er->border_chars[4] ); 97 m_terminal->print( abs.ur(), er->border_color, term_color(), er->border_chars[5] ); 98 m_terminal->print( abs.ll(), er->border_color, term_color(), er->border_chars[6] ); 99 m_terminal->print( abs.lr, er->border_color, term_color(), er->border_chars[7] ); 97 100 m_terminal->update(); 98 101 } 99 102 if ( !e->m_text.empty() ) 100 103 { 101 position p = abs.ul ;104 position p = abs.ul + er->padding; 102 105 for ( char c : e->m_text ) 103 106 { 104 m_terminal->print( p, er->text_color, c );107 m_terminal->print( p, er->text_color, term_color(), c ); 105 108 ++p.x; 106 109 }
Note: See TracChangeset
for help on using the changeset viewer.