@@ -273,6 +273,32 @@ struct KeyHelp {
273
273
const char *description;
274
274
};
275
275
276
+ // COLOR_PAIR index names
277
+ enum {
278
+ // First 16 colors are 8 black background and 8 blue background colors,
279
+ // needed by OutputColoredStringTruncated().
280
+ BlackOnBlack = 1 ,
281
+ RedOnBlack,
282
+ GreenOnBlack,
283
+ YellowOnBlack,
284
+ BlueOnBlack,
285
+ MagentaOnBlack,
286
+ CyanOnBlack,
287
+ WhiteOnBlack,
288
+ BlackOnBlue,
289
+ RedOnBlue,
290
+ GreenOnBlue,
291
+ YellowOnBlue,
292
+ BlueOnBlue,
293
+ MagentaOnBlue,
294
+ CyanOnBlue,
295
+ WhiteOnBlue,
296
+ // Other colors, as needed.
297
+ BlackOnWhite,
298
+ MagentaOnWhite,
299
+ LastColorPairIndex = MagentaOnWhite
300
+ };
301
+
276
302
class WindowDelegate {
277
303
public:
278
304
virtual ~WindowDelegate () = default ;
@@ -462,7 +488,7 @@ class Window {
462
488
int saved_opts;
463
489
::wattr_get (m_window, &saved_attr, &saved_pair, &saved_opts);
464
490
if (use_blue_background)
465
- ::wattron (m_window, COLOR_PAIR(16 ));
491
+ ::wattron (m_window, COLOR_PAIR(WhiteOnBlue ));
466
492
while (!string.empty ()) {
467
493
size_t esc_pos = string.find (' \x1b ' );
468
494
if (esc_pos == StringRef::npos) {
@@ -498,7 +524,7 @@ class Window {
498
524
if (value == 0 ) { // Reset.
499
525
::wattr_set (m_window, saved_attr, saved_pair, &saved_opts);
500
526
if (use_blue_background)
501
- ::wattron (m_window, COLOR_PAIR(16 ));
527
+ ::wattron (m_window, COLOR_PAIR(WhiteOnBlue ));
502
528
} else {
503
529
// Mapped directly to first 16 color pairs (black/blue background).
504
530
::wattron (m_window,
@@ -596,7 +622,7 @@ class Window {
596
622
void DrawTitleBox (const char *title, const char *bottom_message = nullptr ) {
597
623
attr_t attr = 0 ;
598
624
if (IsActive ())
599
- attr = A_BOLD | COLOR_PAIR (18 );
625
+ attr = A_BOLD | COLOR_PAIR (BlackOnWhite );
600
626
else
601
627
attr = 0 ;
602
628
if (attr)
@@ -1026,14 +1052,14 @@ void Menu::DrawMenuTitle(Window &window, bool highlight) {
1026
1052
1027
1053
if (m_key_name.empty ()) {
1028
1054
if (!underlined_shortcut && llvm::isPrint (m_key_value)) {
1029
- window.AttributeOn (COLOR_PAIR (19 ));
1055
+ window.AttributeOn (COLOR_PAIR (MagentaOnWhite ));
1030
1056
window.Printf (" (%c)" , m_key_value);
1031
- window.AttributeOff (COLOR_PAIR (19 ));
1057
+ window.AttributeOff (COLOR_PAIR (MagentaOnWhite ));
1032
1058
}
1033
1059
} else {
1034
- window.AttributeOn (COLOR_PAIR (19 ));
1060
+ window.AttributeOn (COLOR_PAIR (MagentaOnWhite ));
1035
1061
window.Printf (" (%s)" , m_key_name.c_str ());
1036
- window.AttributeOff (COLOR_PAIR (19 ));
1062
+ window.AttributeOff (COLOR_PAIR (MagentaOnWhite ));
1037
1063
}
1038
1064
}
1039
1065
}
@@ -1045,7 +1071,7 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) {
1045
1071
Menu::Type menu_type = GetType ();
1046
1072
switch (menu_type) {
1047
1073
case Menu::Type::Bar: {
1048
- window.SetBackground (18 );
1074
+ window.SetBackground (BlackOnWhite );
1049
1075
window.MoveCursor (0 , 0 );
1050
1076
for (size_t i = 0 ; i < num_submenus; ++i) {
1051
1077
Menu *menu = submenus[i].get ();
@@ -1065,7 +1091,7 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) {
1065
1091
int cursor_x = 0 ;
1066
1092
int cursor_y = 0 ;
1067
1093
window.Erase ();
1068
- window.SetBackground (18 );
1094
+ window.SetBackground (BlackOnWhite );
1069
1095
window.Box ();
1070
1096
for (size_t i = 0 ; i < num_submenus; ++i) {
1071
1097
const bool is_selected = (i == static_cast <size_t >(selected_idx));
@@ -2440,7 +2466,7 @@ class ValueObjectListDelegate : public WindowDelegate {
2440
2466
2441
2467
attr_t changd_attr = 0 ;
2442
2468
if (valobj->GetValueDidChange ())
2443
- changd_attr = COLOR_PAIR (2 ) | A_BOLD;
2469
+ changd_attr = COLOR_PAIR (RedOnBlack ) | A_BOLD;
2444
2470
2445
2471
if (value && value[0 ]) {
2446
2472
window.PutCStringTruncated (1 , " = " );
@@ -3309,7 +3335,7 @@ class StatusBarWindowDelegate : public WindowDelegate {
3309
3335
Thread *thread = exe_ctx.GetThreadPtr ();
3310
3336
StackFrame *frame = exe_ctx.GetFramePtr ();
3311
3337
window.Erase ();
3312
- window.SetBackground (18 );
3338
+ window.SetBackground (BlackOnWhite );
3313
3339
window.MoveCursor (0 , 0 );
3314
3340
if (process) {
3315
3341
const StateType state = process->GetState ();
@@ -3581,7 +3607,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
3581
3607
}
3582
3608
3583
3609
const attr_t selected_highlight_attr = A_REVERSE;
3584
- const attr_t pc_highlight_attr = COLOR_PAIR (9 );
3610
+ const attr_t pc_highlight_attr = COLOR_PAIR (BlackOnBlue );
3585
3611
3586
3612
for (size_t i = 0 ; i < num_visible_lines; ++i) {
3587
3613
const uint32_t curr_line = m_first_visible_line + i;
@@ -3600,7 +3626,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
3600
3626
highlight_attr = selected_highlight_attr;
3601
3627
3602
3628
if (bp_lines.find (curr_line + 1 ) != bp_lines.end ())
3603
- bp_attr = COLOR_PAIR (18 );
3629
+ bp_attr = COLOR_PAIR (BlackOnWhite );
3604
3630
3605
3631
if (bp_attr)
3606
3632
window.AttributeOn (bp_attr);
@@ -3641,7 +3667,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
3641
3667
window.Printf (" %*s" , desc_x - window.GetCursorX (), " " );
3642
3668
window.MoveCursor (window_width - stop_description_len - 16 ,
3643
3669
line_y);
3644
- const attr_t stop_reason_attr = COLOR_PAIR (17 );
3670
+ const attr_t stop_reason_attr = COLOR_PAIR (WhiteOnBlue );
3645
3671
window.AttributeOn (stop_reason_attr);
3646
3672
window.PrintfTruncated (1 , " <<< Thread %u: %s " ,
3647
3673
thread->GetIndexID (), stop_description);
@@ -3685,7 +3711,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
3685
3711
}
3686
3712
3687
3713
const attr_t selected_highlight_attr = A_REVERSE;
3688
- const attr_t pc_highlight_attr = COLOR_PAIR (17 );
3714
+ const attr_t pc_highlight_attr = COLOR_PAIR (WhiteOnBlue );
3689
3715
3690
3716
StreamString strm;
3691
3717
@@ -3733,7 +3759,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
3733
3759
3734
3760
if (bp_file_addrs.find (inst->GetAddress ().GetFileAddress ()) !=
3735
3761
bp_file_addrs.end ())
3736
- bp_attr = COLOR_PAIR (18 );
3762
+ bp_attr = COLOR_PAIR (BlackOnWhite );
3737
3763
3738
3764
if (bp_attr)
3739
3765
window.AttributeOn (bp_attr);
@@ -4270,10 +4296,10 @@ void IOHandlerCursesGUI::Activate() {
4270
4296
init_pair (14 , COLOR_MAGENTA, COLOR_BLUE);
4271
4297
init_pair (15 , COLOR_CYAN, COLOR_BLUE);
4272
4298
init_pair (16 , COLOR_WHITE, COLOR_BLUE);
4273
-
4274
- init_pair (17 , COLOR_WHITE, COLOR_BLUE );
4275
- init_pair (18 , COLOR_BLACK , COLOR_WHITE);
4276
- init_pair ( 19 , COLOR_MAGENTA, COLOR_WHITE );
4299
+ // These must match the order in the color indexes enum.
4300
+ init_pair (17 , COLOR_BLACK, COLOR_WHITE );
4301
+ init_pair (18 , COLOR_MAGENTA , COLOR_WHITE);
4302
+ static_assert (LastColorPairIndex == 18 , " Color indexes do not match. " );
4277
4303
}
4278
4304
}
4279
4305
0 commit comments