sources/interface.cpp

changeset 117
39e05a6ba8d7
parent 116
552909484712
child 118
ae284bf1b5ff
equal deleted inserted replaced
116:552909484712 117:39e05a6ba8d7
41 41
42 // ------------------------------------------------------------------------------------------------- 42 // -------------------------------------------------------------------------------------------------
43 // 43 //
44 chtype Interface::color_pair (Color fg, Color bg) 44 chtype Interface::color_pair (Color fg, Color bg)
45 { 45 {
46 return COLOR_PAIR (1 + (int (fg) * NUM_COLORS) + int (bg)); 46 if (fg == DEFAULT && bg == DEFAULT)
47 return 0;
48 else
49 return COLOR_PAIR (1 + (int (fg) * NUM_COLORS) + int (bg));
47 } 50 }
48 51
49 // ------------------------------------------------------------------------------------------------- 52 // -------------------------------------------------------------------------------------------------
50 // 53 //
51 const String& Interface::current_input() 54 const String& Interface::current_input()
169 reset_title(); 172 reset_title();
170 173
171 if (::has_colors()) 174 if (::has_colors())
172 { 175 {
173 ::start_color(); 176 ::start_color();
174 ::use_default_colors(); 177 bool hasDefaultColors = ::use_default_colors();
175 178 int defaultFg = (hasDefaultColors == OK) ? -1 : COLOR_WHITE;
176 int defaultFg = (use_default_colors() == OK) ? -1 : COLOR_WHITE; 179 int defaultBg = (hasDefaultColors == OK) ? -1 : COLOR_BLACK;
177 int defaultBg = (use_default_colors() == OK) ? -1 : COLOR_BLACK;
178 180
179 // Initialize color pairs 181 // Initialize color pairs
180 for (int i = 0; i < NUM_COLORS; ++i) 182 for (int i = 0; i < NUM_COLORS; ++i)
181 for (int j = 0; j < NUM_COLORS; ++j) 183 for (int j = 0; j < NUM_COLORS; ++j)
182 { 184 {
183 int pairnum = 1 + (i * NUM_COLORS + j); 185 int pairnum = 1 + (i * NUM_COLORS + j);
184 int fg = (i == DEFAULT) ? defaultFg : i; 186 int fg = (i == DEFAULT) ? defaultFg : i;
185 int bg = (j == DEFAULT) ? defaultBg : j; 187 int bg = (j == DEFAULT) ? defaultBg : j;
186 188
187 if (::init_pair (pairnum, fg, bg) == ERR) 189 if (fg != -1 || bg != -1)
188 print_warning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); 190 {
189 } 191 if (::init_pair (pairnum, fg, bg) == ERR)
190 } 192 print_warning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg);
191 else 193 }
192 { 194 }
193 print_warning ("This terminal does not appear to support colors.\n");
194 } 195 }
195 196
196 render_full(); 197 render_full();
197 refresh(); 198 refresh();
198 NeedRefresh = false; 199 NeedRefresh = false;
930 { 931 {
931 va_list args; 932 va_list args;
932 va_start (args, fmtstr); 933 va_start (args, fmtstr);
933 print_to_console (TEXTCOLOR_BrightBlue); 934 print_to_console (TEXTCOLOR_BrightBlue);
934 vprint (fmtstr, args); 935 vprint (fmtstr, args);
935 print_to_console (TEXTCOLOR_Reset);
936 va_end (args); 936 va_end (args);
937 } 937 }
938 938
939 // ------------------------------------------------------------------------------------------------- 939 // -------------------------------------------------------------------------------------------------
940 // 940 //
942 { 942 {
943 va_list args; 943 va_list args;
944 va_start (args, fmtstr); 944 va_start (args, fmtstr);
945 print_to_console (TEXTCOLOR_BrightYellow "-!- "); 945 print_to_console (TEXTCOLOR_BrightYellow "-!- ");
946 vprint (fmtstr, args); 946 vprint (fmtstr, args);
947 print_to_console (TEXTCOLOR_Reset);
948 va_end (args); 947 va_end (args);
949 } 948 }
950 949
951 // ------------------------------------------------------------------------------------------------- 950 // -------------------------------------------------------------------------------------------------
952 // 951 //
954 { 953 {
955 va_list args; 954 va_list args;
956 va_start (args, fmtstr); 955 va_start (args, fmtstr);
957 print_to_console (TEXTCOLOR_BrightRed "!!! "); 956 print_to_console (TEXTCOLOR_BrightRed "!!! ");
958 vprint (fmtstr, args); 957 vprint (fmtstr, args);
959 print_to_console (TEXTCOLOR_Reset);
960 va_end (args); 958 va_end (args);
961 } 959 }
962 960
963 // ------------------------------------------------------------------------------------------------- 961 // -------------------------------------------------------------------------------------------------
964 // 962 //

mercurial