Skip to content

Commit

Permalink
ui/Options: add fallback constant for enable_colors
Browse files Browse the repository at this point in the history
This allows removing several "#ifdef ENABLE_COLORS".
  • Loading branch information
MaxKellermann committed Sep 6, 2024
1 parent 7be7220 commit 2216cd8
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/ProgressBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ ProgressBar::ProgressBar(Point p, unsigned _width) noexcept
:window(p, {_width, 1u})
{
leaveok(window.w, true);
#ifdef ENABLE_COLORS

if (ui_options.enable_colors)
window.SetBackgroundStyle(Style::PROGRESSBAR);
#endif
}

void
Expand Down
2 changes: 0 additions & 2 deletions src/StatusBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ StatusBar::StatusBar(EventLoop &event_loop,
leaveok(window.w, false);
keypad(window.w, true);

#ifdef ENABLE_COLORS
if (ui_options.enable_colors)
window.SetBackgroundStyle(Style::STATUS);
#endif
}

StatusBar::~StatusBar() noexcept
Expand Down
2 changes: 0 additions & 2 deletions src/TitleBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ TitleBar::TitleBar(Point p, unsigned width) noexcept
leaveok(window.w, true);
keypad(window.w, true);

#ifdef ENABLE_COLORS
if (ui_options.enable_colors)
window.SetBackgroundStyle(Style::TITLE);
#endif
}

static inline int
Expand Down
2 changes: 0 additions & 2 deletions src/screen_init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ ScreenManager::ScreenManager(EventLoop &event_loop) noexcept

keypad(main_window.w, true);

#ifdef ENABLE_COLORS
if (ui_options.enable_colors) {
/* set background attributes */
main_window.SetBackgroundStyle(Style::LIST);
}
#endif
}

ScreenManager::~ScreenManager() noexcept
Expand Down
3 changes: 3 additions & 0 deletions src/ui/Options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ struct UiOptions {

#ifdef ENABLE_COLORS
bool enable_colors = true;
#else
static constexpr bool enable_colors = false;
#endif

bool audible_bell = true;
bool visible_bell;
bool bell_on_wrap = true;
Expand Down

0 comments on commit 2216cd8

Please sign in to comment.