refactor: change canvas macOS check to compile-time (#1184)

This commit is contained in:
Clement Tsang 2023-06-04 00:18:24 -04:00 committed by GitHub
parent c6d322263e
commit 5e0900584b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -63,7 +63,6 @@ pub struct Painter {
height: u16,
width: u16,
styled_help_text: Vec<Line<'static>>,
is_mac_os: bool, // TODO: This feels out of place...
// TODO: Redo this entire thing.
row_constraints: Vec<LayoutConstraint>,
@ -157,7 +156,6 @@ impl Painter {
height: 0,
width: 0,
styled_help_text: Vec::default(),
is_mac_os: cfg!(target_os = "macos"),
row_constraints,
col_constraints,
col_row_constraints,

View File

@ -220,10 +220,14 @@ impl Painter {
// TODO: [MOUSE] Mouse support for these in search
// TODO: [MOVEMENT] Movement support for these in search
let (case, whole, regex) = if self.is_mac_os {
("Case(F1)", "Whole(F2)", "Regex(F3)")
} else {
("Case(Alt+C)", "Whole(Alt+W)", "Regex(Alt+R)")
let (case, whole, regex) = {
cfg_if::cfg_if! {
if #[cfg(target_os = "macos")] {
("Case(F1)", "Whole(F2)", "Regex(F3)")
} else {
("Case(Alt+C)", "Whole(Alt+W)", "Regex(Alt+R)")
}
}
};
let option_text = Line::from(vec![
Span::styled(case, case_style),