31 #define YUILogComponent "ncurses" 32 #include <yui/YUILog.h> 52 void pbox(
bool on =
false );
55 int movePad(
int key = -1 );
57 static const NCursesPanel & pad() {
return NCStyleDef_p->p; }
59 static void refresh() { NCStyleDef_p->p.
refresh(); }
61 static int movepad(
int key = -1 ) {
return NCStyleDef_p->movePad( key ); }
67 enum ExMode { EX_OFF, EX_ON, EX_TOGGLE, EX_UPDATE };
69 static void showex( ExMode mode );
72 static void fakestyle( NCstyle::StyleSet style )
74 NCStyleDef_p->NCstyle_C.fakestyle( style );
76 if ( style != NCstyle::MaxStyleSet )
78 NCStyleDef_p->doshowset( NCStyleDef_p->wSet.cset,
true );
88 static void attrchanged()
114 static std::string dumpName( SetType a )
116 #define PRT(t) case t: return #t; 122 PRT( DialogBorderActive );
127 PRT( FrameWidgetActive );
153 Aset( chtype & ch,
const std::string & l ) : attr_p( &ch ), label( l )
156 chtype attr()
const {
return *attr_p; }
158 chtype textattr()
const {
return attr() & ~
NCattribute::char_mask; }
160 void setBg(
bool prev ) { NCattribute::setBg( *attr_p, NCattribute::getBg( *attr_p ) + ( prev ? -1 : 1 ) ); }
162 void setFg(
bool prev ) { NCattribute::setFg( *attr_p, NCattribute::getFg( *attr_p ) + ( prev ? -1 : 1 ) ); }
164 void toggleStyle( chtype sty ) { NCattribute::toggleStyle( *attr_p, sty ); }
166 void setStyle( chtype sty ) { NCattribute::setStyle( *attr_p, sty ); }
168 void setChar( chtype sty ) { NCattribute::setChar( *attr_p, sty ); }
172 const chtype & attr( NCstyle::STglobal a )
174 return NCstyle_C.getStyle( NCstyle_C.fakestyle_e ).attr( a );
177 const chtype & attr( NCstyle::STlocal a )
179 return NCstyle_C.getStyle( NCstyle_C.fakestyle_e ).attr( a );
183 void doshowset( SetType a,
bool reset =
false );
185 static void showset( SetType a )
187 NCStyleDef_p->doshowset( a );
197 queryCharEnt( std::string L, chtype C ) { l = L; c = C; }
200 static chtype queryChar(
int column = 0, chtype selbg = A_REVERSE );
204 void doshowstat(
const Aset & a ) { wChstat.stat( a ); }
206 static void showstat(
const Aset & a )
208 NCStyleDef_p->doshowstat( a );
211 static const char * dumpColor(
short c )
261 static const int taglen = 7;
266 : w( P, H, W, L, C,
'r' )
267 , tag( std::string(
"<" ) + T +
">" )
269 changestyle = A_NORMAL;
274 virtual void draw(
bool immediate =
false )
284 if ( tag.size() > 2 )
286 w.
printw( 0, 0,
"%-*.*s", taglen, taglen, tag.c_str() );
287 return w.
width() - taglen;
298 bool continue_bi =
true;
303 switch (( in = getch() ) )
329 while ( continue_bi );
336 virtual void enterchange()
338 changestyle = A_REVERSE;
339 w.
bkgd( changestyle );
343 virtual void leavechange()
345 changestyle = A_NORMAL;
346 w.
bkgd( changestyle );
350 virtual void handle(
int in )
361 NCstyle::StyleSet cset;
363 :
SubWin( T, P, H, W, L, C )
365 cset = ( NCstyle::StyleSet )( 0 );
368 virtual void draw(
bool immediate =
false )
371 w.
printw(
"%-*.*s", len, len, NCstyle::dumpName( cset ).c_str() );
374 w.
addch( 0, 2,
'-' );
376 if ( cset == NCstyle::MaxStyleSet - 1 )
377 w.
addch( 0, 4,
'-' );
379 SubWin::draw( immediate );
382 virtual void handle(
int in )
390 cset = ( NCstyle::StyleSet )( cset - 1 );
398 if ( cset + 1 < NCstyle::MaxStyleSet )
400 cset = ( NCstyle::StyleSet )( cset + 1 );
417 :
SubWin( T, P, H, W, L, C )
419 cset = ( SetType )( 0 );
422 virtual void draw(
bool immediate =
false )
425 w.
printw(
"%-*.*s", len, len, dumpName( cset ).c_str() );
428 w.
addch( 0, 2,
'-' );
430 if ( cset == MaxSetType - 1 )
431 w.
addch( 0, 4,
'-' );
433 SubWin::draw( immediate );
436 virtual void handle(
int in )
444 cset = ( SetType )( cset - 1 );
453 if ( cset + 1 < MaxSetType )
455 cset = ( SetType )( cset + 1 );
471 std::vector<Aset> aset;
475 :
SubWin( T, P, H, W, L, C )
480 virtual void draw(
bool immediate =
false )
484 drawTable( immediate );
487 virtual void handle(
int in )
494 bool redrawall =
true;
510 if ( citem + 1 < aset.size() )
524 aset[citem].setBg(
true );
528 aset[citem].setBg(
false );
532 aset[citem].setFg(
true );
536 aset[citem].setFg(
false );
541 aset[citem].toggleStyle( A_BOLD );
546 aset[citem].setStyle( A_NORMAL );
550 aset[citem].toggleStyle( A_BLINK );
554 aset[citem].toggleStyle( A_STANDOUT );
558 aset[citem].toggleStyle( A_UNDERLINE );
562 aset[citem].toggleStyle( A_REVERSE );
566 aset[citem].toggleStyle( A_DIM );
570 aset[citem].toggleStyle( A_INVIS );
575 chtype ach = queryChar( pad().begx() + 5, aset[citem].textattr() );
577 if ( ach != ( chtype ) - 1 )
578 aset[citem].setChar( ach );
584 redraw = redrawall =
false;
595 void set( std::vector<Aset> & nset,
bool reset = false )
601 void drawTable(
bool immediate =
false )
603 unsigned t = w.
height() - 1;
604 unsigned high = ( t - 1 );
605 unsigned spot = high / 2;
610 else if ( citem >= aset.size() )
611 citem = aset.size() - 1;
613 if ( high >= aset.size() || citem <= spot )
619 fitem = citem - spot;
621 if ( fitem + high >= aset.size() )
622 fitem = aset.size() - high;
625 for (
unsigned i = fitem; l < t; ++i, ++l )
632 int len = w.
width() - 2;
634 w.
printw( 1, 1,
"%-*.*s", len, len,
"<empty>" );
639 SubWin::draw( immediate );
642 void drawItemAt(
unsigned line,
unsigned num )
644 int len = w.
width() - 4;
646 if ( num < aset.size() )
652 w.
addstr( line, 1,
"->" );
653 showstat( aset[num] );
662 w.
printw( line, 3,
"%-*.*s", len, len,
"" );
663 w.
bkgdset( aset[num].textattr() );
664 w.
addstr( line, 3, aset[num].label.c_str(), len );
669 w.
printw( line, 1,
"%-*.*s", len + 2, len + 2,
"" );
681 :
SubWin( T, P, H, W, L, C )
685 virtual int change() {
return -1; }
687 virtual void draw(
bool immediate =
false )
691 SubWin::draw( immediate );
694 void stat(
const Aset & a )
696 static char buf[1024];
697 int len = w.
width() - 2;
698 chtype ch = a.attr();
703 w.
addstr( 0, 1, a.label.c_str(), len );
704 sprintf( buf,
"%s/%s %c%c%c%c%c%c%c %c%3u",
705 dumpColor( NCattribute::fg_color_of( ch ) ),
706 dumpColor( NCattribute::bg_color_of( ch ) ),
707 ( ch&A_INVIS ?
'i' :
'.' ),
708 ( ch&A_BOLD ?
'b' :
'.' ),
709 ( ch&A_DIM ?
'd' :
'.' ),
710 ( ch&A_BLINK ?
'l' :
'.' ),
711 ( ch&A_REVERSE ?
'r' :
'.' ),
712 ( ch&A_UNDERLINE ?
'u' :
'.' ),
713 ( ch&A_STANDOUT ?
's' :
'.' ),
714 ( ch&A_ALTCHARSET ?
'A' :
'.' ),
715 (
unsigned )( ch&A_CHARTEXT )
717 w.
addstr( 1, 1, buf, len );
718 SubWin::draw(
true );
730 :
SubWin( T, P, H, W, L, C )
735 virtual void draw(
bool immediate =
false )
738 w.
printw(
"%-*.*s", len, len,
"Example Dialog" );
739 SubWin::draw( immediate );
762 , p( 19, 30,
NCurses::lines() - 19, 1 )
763 , wStyle(
"F1/2", p, 1, 28, 1, 1 )
764 , wSet(
"F3/4", p, 1, 28, 2, 1 )
765 , wChstat(
"", p, 3, 28, 3, 1 )
766 , wChattr(
"", p, 11, 28, 6, 1 )
767 , wEx(
"F6", p, 1, 28, 17, 1 )
785 std::ostream & dumpChtype( std::ostream & str,
const chtype & ch )
787 static chtype mask = A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_INVIS;
788 chtype base = ch & ~mask;
789 chtype style = ch & mask;
790 #define PRTIF(S) if ( style & S ) str << "|" << #S 793 PRTIF( A_UNDERLINE );
811 NCstyle::STglobal glob;
812 NCstyle::STlocal loc;
813 lookupIdx() { glob = NCstyle::MaxSTglobal; loc = NCstyle::MaxSTlocal; }
815 lookupIdx( NCstyle::STglobal g ) { glob = g; loc = NCstyle::MaxSTlocal; }
817 lookupIdx( NCstyle::STlocal l ) { glob = NCstyle::MaxSTglobal; loc = l; }
819 bool isLoc()
const {
return glob == NCstyle::MaxSTglobal && loc != NCstyle::MaxSTlocal; }
821 bool isGlob()
const {
return glob != NCstyle::MaxSTglobal && loc == NCstyle::MaxSTlocal; }
823 bool isUnknown()
const {
return glob == NCstyle::MaxSTglobal && loc == NCstyle::MaxSTlocal; }
825 unsigned uindex()
const {
if ( isLoc() )
return loc;
return isGlob() ? glob : ( unsigned ) - 1; }
827 const char * stat()
const {
if ( isLoc() )
return "L";
return isGlob() ?
"G" :
"?"; }
838 void NCStyleDef::doshowset( SetType a,
bool reset )
840 std::vector<Aset> aset;
844 #define PRT(T) aset.push_back( Aset( const_cast<chtype&>( attr( NCstyle::T ) ), #T ) ) 856 case DialogBorderActive:
857 PRT( DialogActiveBorder );
858 PRT( DialogActiveTitle );
863 PRT( DialogHeadline );
864 PRT( DialogDisabled );
876 PRT( DialogActivePlain );
877 PRT( DialogActiveLabel );
878 PRT( DialogActiveData );
879 PRT( DialogActiveHint );
880 PRT( DialogActiveScrl );
884 PRT( DialogFramePlain );
885 PRT( DialogFrameLabel );
886 PRT( DialogFrameData );
887 PRT( DialogFrameHint );
888 PRT( DialogFrameScrl );
891 case FrameWidgetActive:
892 PRT( DialogActiveFramePlain );
893 PRT( DialogActiveFrameLabel );
894 PRT( DialogActiveFrameData );
895 PRT( DialogActiveFrameHint );
896 PRT( DialogActiveFrameScrl );
912 PRT( ListActiveTitle );
913 PRT( ListActivePlain );
914 PRT( ListActiveLabel );
915 PRT( ListActiveData );
916 PRT( ListActiveHint );
917 PRT( ListActiveSelPlain );
918 PRT( ListActiveSelLabel );
919 PRT( ListActiveSelData );
920 PRT( ListActiveSelHint );
924 PRT( RichTextPlain );
925 PRT( RichTextTitle );
927 PRT( RichTextArmedlink );
928 PRT( RichTextActiveArmedlink );
929 PRT( RichTextVisitedLink );
950 wChattr.set( aset, reset );
955 void NCStyleDef::pbox(
bool on )
963 p.
addstr( 0, 1,
"<ENTER> done " );
966 p.
addstr( 0, 1,
"<F5> move pad " );
973 int NCStyleDef::movePad(
int key )
978 bool continue_bi =
true;
1002 if ( p.
begy() + p.
height() < NCurses::lines() )
1018 if ( p.
begx() + p.
width() < NCurses::cols() )
1038 continue_bi = false;
1043 while ( continue_bi && key == -1 );
1055 void NCStyleDef::changeStyle()
1057 fakestyle( wStyle.cset );
1060 bool continue_bi =
true;
1081 wStyle.handle( KEY_UP );
1085 wStyle.handle( KEY_DOWN );
1089 wSet.handle( KEY_UP );
1093 wSet.handle( KEY_DOWN );
1101 rein = wEx.change();
1114 continue_bi = false;
1118 rein = wChattr.change();
1122 while ( continue_bi );
1128 fakestyle( NCstyle::MaxStyleSet );
1134 chtype NCStyleDef::queryChar(
int column, chtype selbg )
1136 std::vector<queryCharEnt> men;
1137 men.push_back( queryCharEnt(
"NO CHAR",
' ' ) );
1138 men.push_back( queryCharEnt(
"BLANK",
' ' ) );
1139 #define PUT(a) men.push_back( queryCharEnt( #a, a ) ); 1156 PUT( ACS_STERLING );
1161 PUT( ACS_ULCORNER );
1162 PUT( ACS_URCORNER );
1163 PUT( ACS_LLCORNER );
1164 PUT( ACS_LRCORNER );
1174 chtype defbg = A_NORMAL;
1175 unsigned lrow = men.size() - men.size() / 2;
1178 popup.bkgd( defbg );
1182 chtype ret = ( chtype ) - 1;
1192 for (
unsigned i = 0; i < men.size(); ++i, ++l )
1200 popup.bkgdset( defbg );
1202 popup.addstr( l, c, ( i == idx ?
"->" :
" " ) );
1203 popup.bkgdset( i == idx ? selbg : defbg );
1205 popup.addch( men[i].c );
1206 popup.printw(
" %-*.*s", len, len, men[i].l.c_str() );
1211 switch ( ( in = getch() ) )
1222 if ( idx + 1 < men.size() )
1227 ret = idx ? men[idx].c : 0;
1244 #define BGSET(a) W.bkgdset( st.a ) 1250 inline void frame(
NCursesWindow & w,
int l,
int c,
int H = 0,
int W = 0 )
1259 w.
vline( l, c + W, H );
1261 w.
hline( l + H, c, W );
1263 w.
addch( l, c, ACS_ULCORNER );
1264 w.
addch( l + H, c, ACS_LLCORNER );
1265 w.
addch( l, c + W, ACS_URCORNER );
1266 w.
addch( l + H, c + W, ACS_LRCORNER );
1296 W.
addch( ACS_DARROW );
1307 W.
addch( L + hi, C + 1, ACS_LTEE );
1308 W.
addch( ACS_HLINE );
1309 W.
addch( ACS_RTEE );
1310 W.
addch( L + 1, C + wi, ACS_TTEE );
1311 W.
addch( L + 2, C + wi, ACS_BTEE );
1318 W.
printw( L, C,
"%-*s", wi - 1,
"Title" );
1320 BGSET( item.plain );
1321 W.
printw( L, C,
"%-*s", wi - 1,
"" );
1323 itex( W,
"Item", st.item );
1325 BGSET( selected.plain );
1326 W.
printw( L, C,
"%-*s", wi - 1,
"" );
1328 itex( W,
"Selected", st.selected );
1332 inline void widex(
NCursesWindow & W,
int L,
int C,
const char * T,
1335 butex( W, L, C, T, w );
1337 frameex( W, L, C, T, f );
1339 listex( W, L, C + 1, l );
1344 void NCStyleDef::showex( ExMode mode )
1348 if ( mode == EX_TOGGLE )
1349 mode = W.hidden() ? EX_ON : EX_OFF;
1351 if ( mode == EX_OFF )
1362 if ( mode == EX_ON && W.hidden() )
1370 const NCstyle::Style & st( NCStyleDef_p->NCstyle_C.getStyle( NCStyleDef_p->NCstyle_C.fakestyle_e ) );
1374 BGSET( border.text );
1376 BGSET( border.title );
1377 W.
addstr( 0, 1,
"normal dialog" );
1380 BGSET( activeBorder.text );
1382 BGSET( activeBorder.title );
1383 W.
addstr( l, c + 1,
"active dialog" );
1386 BGSET( dumb.title );
1387 W.
addstr( l, c,
"Heading" );
1389 frame( W, l + 2, c );
1390 W.
addstr( l + 2, c + 1,
"Frame" );
1391 W.
addstr( l + 4, c + 1,
"Some text" );
1393 widex( W, l, c,
"Disabled", st.disabled, st.disabled, st.disabledList );
1395 widex( W, l, c,
"Normal", st.normal, st.frame, st.list );
1397 widex( W, l, c,
"Active", st.active, st.activeFrame, st.activeList );
1400 BGSET( progbar.bar.chattr );
1402 BGSET( progbar.bar.getNonChar() );
1404 BGSET( progbar.nonbar.getNonChar() );
1406 BGSET( progbar.nonbar.chattr );
1412 void NCStyleDef::saveStyle()
1414 std::string fname(
"NCstyle." + NCstyle_C.styleName +
".h" );
1415 std::string hname(
"NCstyle_" + NCstyle_C.styleName +
"_h" );
1416 std::string fpath(
"/tmp/" );
1419 std::ofstream out( fpath.c_str(), std::ios::out );
1420 NCursesPanel p( 5, NCurses::cols() - 4, ( NCurses::lines() - 5 ) / 2, 2 );
1426 p.
bkgd( NCattribute::color_pair( COLOR_WHITE, COLOR_RED ) );
1427 p.
printw( pl, 2,
"Can't open output file \"%s\"!", fpath.c_str() );
1436 p.
bkgd( NCattribute::color_pair( COLOR_CYAN, COLOR_BLACK ) );
1438 p.
printw( pl, 2,
"Saving style \"%s\" in \"%s\" ...", NCstyle_C.styleName.c_str(), fpath.c_str() );
1442 out <<
"/*" << std::endl;
1443 out <<
" Copyright (C) 2000-2012 Novell, Inc" << std::endl;
1444 out <<
" This library is free software; you can redistribute it and/or modify" << std::endl;
1445 out <<
" it under the terms of the GNU Lesser General Public License as" << std::endl;
1446 out <<
" published by the Free Software Foundation; either version 2.1 of the" << std::endl;
1447 out <<
" License, or (at your option) version 3.0 of the License. This library" << std::endl;
1448 out <<
" is distributed in the hope that it will be useful, but WITHOUT ANY" << std::endl;
1449 out <<
" WARRANTY; without even the implied warranty of MERCHANTABILITY or" << std::endl;
1450 out <<
" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public" << std::endl;
1451 out <<
" License for more details. You should have received a copy of the GNU" << std::endl;
1452 out <<
" Lesser General Public License along with this library; if not, write" << std::endl;
1453 out <<
" to the Free Software Foundation, Inc., 51 Franklin Street, Fifth" << std::endl;
1454 out <<
" Floor, Boston, MA 02110-1301 USA" << std::endl;
1455 out <<
"*/" << std::endl;
1458 out <<
"/*-/" << std::endl;
1460 out <<
" File: " << fname << std::endl;
1462 out <<
" Author: Generated by class NCstyle" << std::endl;
1464 out <<
"/-*/" << std::endl;
1465 out <<
"#ifndef " << hname << std::endl;
1466 out <<
"#define " << hname << std::endl;
1467 out <<
"" << std::endl;
1468 out <<
"#include \"NCstyle.h\"" << std::endl;
1469 out <<
"" << std::endl;
1470 out <<
"inline void NCstyleInit_" << NCstyle_C.styleName <<
"( std::vector<NCstyle::Style> & styleSet )" << std::endl;
1471 out <<
"{" << std::endl;
1473 out <<
" //=================================================================" << std::endl;
1474 out <<
" // init global attributes" << std::endl;
1475 out <<
" //=================================================================" << std::endl;
1476 out <<
" NCattrset * attrset( &styleSet[NCstyle::" << NCstyle::dumpName( NCstyle::DefaultStyle ) <<
"].getAttrGlobal() );" << std::endl;
1478 for ( NCstyle::STglobal a = ( NCstyle::STglobal )0; a < NCstyle::MaxSTglobal; a = ( NCstyle::STglobal )( a + 1 ) )
1480 out <<
" attrset->setAttr( NCstyle::" 1481 << NCstyle::dumpName( a )
1483 dumpChtype( out, NCstyle_C( a ) )
1484 <<
" );" << std::endl;
1487 out <<
" //=================================================================" << std::endl;
1488 out <<
" // init local attributes" << std::endl;
1489 out <<
" //=================================================================" << std::endl;
1491 for ( NCstyle::StyleSet sts = ( NCstyle::StyleSet )0; sts < NCstyle::MaxStyleSet; sts = ( NCstyle::StyleSet )( sts + 1 ) )
1493 out <<
" // " << NCstyle::dumpName( sts ) << std::endl;
1494 out <<
" attrset = &styleSet[NCstyle::" << NCstyle::dumpName( sts ) <<
"].getAttrLocal();" << std::endl;
1496 for ( NCstyle::STlocal a = ( NCstyle::STlocal )0; a < NCstyle::MaxSTlocal; a = ( NCstyle::STlocal )( a + 1 ) )
1498 out <<
" attrset->setAttr( NCstyle::" 1499 << NCstyle::dumpName( a )
1501 dumpChtype( out, NCstyle_C.styleSet[sts]( a ) )
1502 <<
" );" << std::endl;
1506 out <<
"}" << std::endl;
1507 out <<
"#endif // " << hname << std::endl;
1512 p.
bkgd( NCattribute::color_pair( COLOR_WHITE, COLOR_RED ) );
1530 void NCStyleDef::restoreStyle()
1532 std::string fname(
"NCstyle." + NCstyle_C.styleName +
".h" );
1533 std::string fpath(
"/tmp/" );
1536 std::ifstream inp( fpath.c_str(), std::ios::in );
1538 NCursesPanel p( ph, NCurses::cols() - 4, ( NCurses::lines() - ph ) / 2, 2 );
1544 p.
bkgd( NCattribute::color_pair( COLOR_WHITE, COLOR_RED ) );
1545 p.
printw( pl, 2,
"Can't open input file \"%s\"!", fpath.c_str() );
1554 p.
bkgd( NCattribute::color_pair( COLOR_CYAN, COLOR_BLACK ) );
1556 p.
printw( pl, 2,
"Reding style \"%s\" from \"%s\" ...", NCstyle_C.styleName.c_str(), fpath.c_str() );
1560 std::list<std::string> data_vec[NCstyle::MaxStyleSet+1];
1561 NCstyle::StyleSet cvec = NCstyle::MaxStyleSet;
1563 std::string initfnc_ti(
"inline void NCstyleInit_" );
1564 initfnc_ti += NCstyle_C.styleName +
"(";
1565 std::string attrdef(
" attrset->setAttr( NCstyle::" );
1566 std::string stydef(
" attrset = &styleSet[NCstyle::" );
1568 enum STATE { PRE, ONFNC, IN, POST, ERROR };
1571 std::string line(
"" );
1572 unsigned lineno = 0;
1574 while ( inp.good() && psaw != POST && psaw != ERROR )
1579 while ( inp.get( c ), inp.good() && c !=
'\n' )
1590 if ( line.find( initfnc_ti ) == 0 )
1596 if ( line ==
"{" || line.find(
" //" ) == 0 )
1599 if ( line ==
" NCattrset * attrset( &styleSet[NCstyle::DefaultStyle].getAttrGlobal() );" )
1602 cvec = NCstyle::MaxStyleSet;
1619 if ( line.find(
" //" ) == 0 )
1622 if ( line.find( attrdef ) == 0 )
1624 data_vec[cvec].push_back( line.substr( attrdef.size() ) );
1627 else if ( line.find( stydef ) == 0 )
1629 line.erase( 0, stydef.size() );
1631 if ( line.find(
"DefaultStyle]" ) == 0 )
1633 cvec = NCstyle::DefaultStyle;
1636 else if ( line.find(
"InfoStyle]" ) == 0 )
1638 cvec = NCstyle::InfoStyle;
1641 else if ( line.find(
"WarnStyle]" ) == 0 )
1643 cvec = NCstyle::WarnStyle;
1646 else if ( line.find(
"PopupStyle]" ) == 0 )
1648 cvec = NCstyle::PopupStyle;
1677 p.
bkgd( NCattribute::color_pair( COLOR_WHITE, COLOR_RED ) );
1678 p.
printw(
" FAILED stage %d!\n[%d]>>%s<<", psaw, lineno, line.c_str() );
1691 std::vector<NCattrset> attr_vec;
1693 for ( cvec = ( NCstyle::StyleSet )0; cvec <= NCstyle::MaxStyleSet; cvec = ( NCstyle::StyleSet )( cvec + 1 ) )
1695 attr_vec.push_back( cvec == NCstyle::MaxStyleSet ?
NCattrset( NCstyle::MaxSTglobal ) :
NCattrset( NCstyle::MaxSTlocal ) );
1698 std::map<std::string, lookupIdx> lookupmap;
1700 for ( NCstyle::STglobal a = ( NCstyle::STglobal )0; a < NCstyle::MaxSTglobal; a = ( NCstyle::STglobal )( a + 1 ) )
1702 std::map<std::string, lookupIdx>::value_type v( NCstyle::dumpName( a ), lookupIdx( a ) );
1703 lookupmap.insert( v );
1706 for ( NCstyle::STlocal a = ( NCstyle::STlocal )0; a < NCstyle::MaxSTlocal; a = ( NCstyle::STlocal )( a + 1 ) )
1708 std::map<std::string, lookupIdx>::value_type v( NCstyle::dumpName( a ), lookupIdx( a ) );
1709 lookupmap.insert( v );
1717 for ( cvec = ( NCstyle::StyleSet )( NCstyle::MaxStyleSet + 1 ); cvec > 0; )
1719 cvec = ( NCstyle::StyleSet )( cvec - 1 );
1724 for ( std::list<std::string>::iterator i = data_vec[cvec].begin(); i != data_vec[cvec].end(); ++i )
1726 std::string::size_type sep = i->find(
", " );
1728 if ( sep != std::string::npos )
1730 std::string id( i->substr( 0, sep ) );
1731 std::string val( i->substr( sep + 2 ) );
1732 sep = val.find(
" " );
1734 if ( sep != std::string::npos )
1739 std::map<std::string, lookupIdx>::const_iterator ldat = lookupmap.find(
id );
1741 if ( ldat == lookupmap.end() || ldat->second.isUnknown() )
1743 p.
printw(
"{UNKNOWN:%s=%s}",
id.c_str(), val.c_str() );
1749 chtype ch = atoi( val.c_str() );
1750 sep = val.find(
"|" );
1752 if ( sep != std::string::npos )
1754 val.erase( 0, sep + 1 );
1756 while ( val.size() )
1758 sep = val.find(
"|" );
1759 std::string tt = val.substr( 0, sep );
1760 #define IFASSIGN(T) if ( tt == #T ) ch |= T 1761 IFASSIGN( A_STANDOUT );
1762 else IFASSIGN( A_UNDERLINE );
1763 else IFASSIGN( A_REVERSE );
1764 else IFASSIGN( A_BLINK );
1765 else IFASSIGN( A_DIM );
1766 else IFASSIGN( A_BOLD );
1767 else IFASSIGN( A_INVIS );
1770 val.erase( 0, ( sep != std::string::npos ) ? sep + 1 : sep );
1775 if ( ldat->second.isLoc() )
1778 if ( cvec == NCstyle::MaxStyleSet )
1781 for (
unsigned ii = 0; ii < NCstyle::MaxStyleSet; ++ii )
1783 attr_vec[ii].setAttr( ldat->second.uindex(), ch );
1789 attr_vec[cvec].setAttr( ldat->second.uindex(), ch );
1792 attr_vec[cvec].setAttr( ldat->second.uindex(), ch );
1794 else if ( ldat->second.isGlob() )
1797 attr_vec[NCstyle::MaxStyleSet].setAttr( ldat->second.uindex(), ch );
1807 p.
printw(
"{NOVAL:%s}", i->c_str() );
1815 cvec = ( NCstyle::StyleSet )0;
1817 NCstyle_C.getStyle( cvec ).getAttrGlobal() = attr_vec[NCstyle::MaxStyleSet];
1819 for ( ; cvec < NCstyle::MaxStyleSet; cvec = ( NCstyle::StyleSet )( cvec + 1 ) )
1821 NCstyle_C.getStyle( cvec ).getAttrLocal() = attr_vec[cvec];
1836 void NCDefineStyle(
NCstyle & style )
1839 cstyle.changeStyle();
int clear()
Clear the window.
int printw(const char *fmt,...)
Do a formatted print to the window.
void syncup()
Propagate the changes up in the hierarchy.
Wchstat: show current attributes definition.
int height() const
Number of lines in this window.
int vline(int len, chtype ch=0)
Draw a vertical line of len characters with the given character.
int bkgd(const chtype ch)
Set the background property and apply it to the window.
virtual int refresh()
Propagate all panel changes to the virtual screen and update the physical screen. ...
void bkgdset(chtype ch)
Set the background property.
void show()
Show the panel, i.e.
int mvwin(int y, int x)
Move window to new position with the new position as top left corner.
Wchattr: handle modification of the current attribute std::set.
virtual int refresh()
Propagate the changes in this window to the virtual screen and call doupdate().
int begx() const
Column of top left corner relative to stdscr.
int box()
Draw a box around the window with the given vertical and horizontal drawing characters.
int begy() const
Line of top left corner relative to stdscr.
int hline(int len, chtype ch=0)
Draw a horizontal line of len characters with the given character.
int addch(const char ch)
Put attributed character to the window.
helper struct to std::map strings to NCstyle enum values
void hide()
Hide the panel.
int move(int y, int x)
Move cursor the this position.
Wex: popup and down the example Dialog.
SubWin: base class for the windows used.
int width() const
Number of columns in this window.
Wstyle: Selection of the current NCstyle::StyleSet to process.
int addstr(const char *str, int n=-1)
Write the std::string str to the window, stop writing if the terminating NUL or the limit n is reache...
Wset: Selection of the current attribute std::set to process.