28 #define YUILogComponent "ncurses"
29 #include <yui/YUILog.h>
31 #include "NCStyleDef.h"
33 #include "NCstyle.mono.h"
34 #include "NCstyle.braille.h"
35 #include "NCstyle.linux.h"
36 #include "NCstyle.xterm.h"
37 #include "NCstyle.rxvt.h"
38 #include "NCstyle.highcontrast.h"
39 #include "NCstyle.inverted.h"
42 int NCattribute::_colors = ::COLORS;
43 int NCattribute::_pairs = ::COLOR_PAIRS;
47 unsigned NCstyle::Style::sanitycheck()
52 NCattrset NCstyle::Style::attrGlobal( sanitycheck() );
62 return StDialog( StBase( attr( DialogTitle ),
63 attr( DialogBorder ) ),
64 StBase( attr( DialogActiveTitle ),
65 attr( DialogActiveBorder ) ),
66 StBase( attr( DialogHeadline ),
68 StWidget( attr( DialogDisabled ),
69 attr( DialogDisabled ),
70 attr( DialogDisabled ),
71 attr( DialogDisabled ),
72 attr( DialogDisabled ) ),
73 StWidget( attr( DialogPlain ),
78 StWidget( attr( DialogActivePlain ),
79 attr( DialogActiveLabel ),
80 attr( DialogActiveData ),
81 attr( DialogActiveHint ),
82 attr( DialogActiveScrl ) ),
83 StWidget( attr( DialogFramePlain ),
84 attr( DialogFrameLabel ),
85 attr( DialogFrameData ),
86 attr( DialogFrameHint ),
87 attr( DialogFrameScrl ) ),
88 StWidget( attr( DialogActiveFramePlain ),
89 attr( DialogActiveFrameLabel ),
90 attr( DialogActiveFrameData ),
91 attr( DialogActiveFrameHint ),
92 attr( DialogActiveFrameScrl ) ),
93 StList( attr( ListTitle ),
94 StItem( attr( ListPlain ),
98 StItem( attr( ListSelPlain ),
101 attr( ListSelHint ) ) ),
102 StList( attr( ListActiveTitle ),
103 StItem( attr( ListActivePlain ),
104 attr( ListActiveLabel ),
105 attr( ListActiveData ),
106 attr( ListActiveHint ) ),
107 StItem( attr( ListActiveSelPlain ),
108 attr( ListActiveSelLabel ),
109 attr( ListActiveSelData ),
110 attr( ListActiveSelHint ) ) ),
111 StList( attr( DialogDisabled ),
112 StItem( attr( DialogDisabled ),
113 attr( DialogDisabled ),
114 attr( DialogDisabled ),
115 attr( DialogDisabled ) ),
116 StItem( attr( DialogDisabled ),
117 attr( DialogDisabled ),
118 attr( DialogDisabled ),
119 attr( DialogDisabled ) ) ),
120 StProgbar( attr( ProgbarCh ),
121 attr( ProgbarBgch ) ),
122 StRichtext( attr( RichTextPlain ),
123 attr( RichTextTitle ),
124 attr( RichTextLink ),
125 attr( RichTextArmedlink ),
126 attr( RichTextActiveArmedlink ),
127 attr( RichTextVisitedLink ),
134 attr( RichTextBIT ) ),
141 NCstyle::Style::Style()
143 , StDialog( initDialog() )
148 NCstyle::Style::Style(
const Style & rhs )
150 , StDialog( initDialog() )
155 NCstyle::Style::~Style()
162 #define PRT(t) case NCstyle::t: return #t;
164 std::string NCstyle::dumpName( NCstyle::StyleSet a )
173 case NCstyle::MaxStyleSet:
180 std::string NCstyle::dumpName( NCstyle::STglobal a )
187 case NCstyle::MaxSTglobal:
194 std::string NCstyle::dumpName( NCstyle::STlocal a )
200 PRT( DialogActiveBorder );
201 PRT( DialogActiveTitle );
204 PRT( DialogHeadline );
206 PRT( DialogDisabled );
213 PRT( DialogActivePlain );
214 PRT( DialogActiveLabel );
215 PRT( DialogActiveData );
216 PRT( DialogActiveHint );
217 PRT( DialogActiveScrl );
219 PRT( DialogFramePlain );
220 PRT( DialogFrameLabel );
221 PRT( DialogFrameData );
222 PRT( DialogFrameHint );
223 PRT( DialogFrameScrl );
224 PRT( DialogActiveFramePlain );
225 PRT( DialogActiveFrameLabel );
226 PRT( DialogActiveFrameData );
227 PRT( DialogActiveFrameHint );
228 PRT( DialogActiveFrameScrl );
240 PRT( ListActiveTitle );
241 PRT( ListActivePlain );
242 PRT( ListActiveLabel );
243 PRT( ListActiveData );
244 PRT( ListActiveHint );
245 PRT( ListActiveSelPlain );
246 PRT( ListActiveSelLabel );
247 PRT( ListActiveSelData );
248 PRT( ListActiveSelHint );
250 PRT( RichTextPlain );
251 PRT( RichTextTitle );
253 PRT( RichTextArmedlink );
254 PRT( RichTextActiveArmedlink );
255 PRT( RichTextVisitedLink );
269 case NCstyle::MaxSTlocal:
280 NCstyle::NCstyle( std::string term_t )
281 : styleName(
"linux" )
283 , styleSet( MaxStyleSet )
284 , fakestyle_e( MaxStyleSet )
286 char *user_defined_style = getenv(
"Y2NCURSES_COLOR_THEME" );
288 if ( user_defined_style && *user_defined_style )
290 styleName = user_defined_style;
291 yuiMilestone() <<
"User-defined style found: " << styleName.c_str() << std::endl;
295 if ( NCattribute::colors() )
297 if ( getenv(
"Y2_BRAILLE" ) != NULL )
299 styleName =
"braille";
303 if ( ! fnmatch(
"xterm*", term_t.c_str(), 0 ) )
305 else if ( ! fnmatch(
"rxvt*", term_t.c_str(), 0 ) )
315 yuiMilestone() <<
"Init " << term_t <<
" using " << ( NCattribute::colors() ?
"color" :
"bw" )
317 <<
" => " << MaxStyleSet <<
" styles in " << styleName << std::endl;
319 #define IF_STYLE_INIT(n) if ( styleName == #n ) { NCstyleInit_##n( styleSet ); }
320 IF_STYLE_INIT( linux )
321 else IF_STYLE_INIT( xterm )
322 else IF_STYLE_INIT( rxvt )
323 else IF_STYLE_INIT( mono )
324 else IF_STYLE_INIT( braille )
325 else IF_STYLE_INIT( highcontrast )
326 else IF_STYLE_INIT( inverted )
327 else NCstyleInit_linux( styleSet );
338 void NCstyle::nextStyle()
340 if ( !NCattribute::colors() )
return;
342 if ( styleName ==
"mono" )
344 if ( term ==
"xterm" )
347 NCstyleInit_xterm( styleSet );
349 else if ( term ==
"rxvt" )
352 NCstyleInit_rxvt( styleSet );
357 NCstyleInit_linux( styleSet );
360 else if ( styleName ==
"braille" )
363 NCstyleInit_mono( styleSet );
367 styleName =
"braille";
368 NCstyleInit_braille( styleSet );
374 void NCstyle::changeSyle()
376 NCDefineStyle( *
this );
381 void NCstyle::fakestyle( StyleSet f )