collapse single match blocks (clippy::single_match, clippy::single_match_else)
This commit is contained in:
parent
dcae0a4c2e
commit
011af310d2
2 changed files with 57 additions and 64 deletions
103
src/main.rs
103
src/main.rs
|
|
@ -2326,31 +2326,28 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra work to do to prepare context pages
|
// Extra work to do to prepare context pages
|
||||||
match self.context_page {
|
if let ContextPage::ColorSchemes(color_scheme_kind) = self.context_page {
|
||||||
ContextPage::ColorSchemes(color_scheme_kind) => {
|
self.color_scheme_errors.clear();
|
||||||
self.color_scheme_errors.clear();
|
self.color_scheme_expanded = None;
|
||||||
self.color_scheme_expanded = None;
|
self.color_scheme_renaming = None;
|
||||||
self.color_scheme_renaming = None;
|
self.color_scheme_tab_model = widget::segmented_button::Model::default();
|
||||||
self.color_scheme_tab_model = widget::segmented_button::Model::default();
|
let dark_entity = self
|
||||||
let dark_entity = self
|
.color_scheme_tab_model
|
||||||
.color_scheme_tab_model
|
.insert()
|
||||||
.insert()
|
.text(fl!("dark"))
|
||||||
.text(fl!("dark"))
|
.data(ColorSchemeKind::Dark)
|
||||||
.data(ColorSchemeKind::Dark)
|
.id();
|
||||||
.id();
|
let light_entity = self
|
||||||
let light_entity = self
|
.color_scheme_tab_model
|
||||||
.color_scheme_tab_model
|
.insert()
|
||||||
.insert()
|
.text(fl!("light"))
|
||||||
.text(fl!("light"))
|
.data(ColorSchemeKind::Light)
|
||||||
.data(ColorSchemeKind::Light)
|
.id();
|
||||||
.id();
|
self.color_scheme_tab_model
|
||||||
self.color_scheme_tab_model
|
.activate(match color_scheme_kind {
|
||||||
.activate(match color_scheme_kind {
|
ColorSchemeKind::Dark => dark_entity,
|
||||||
ColorSchemeKind::Dark => dark_entity,
|
ColorSchemeKind::Light => light_entity,
|
||||||
ColorSchemeKind::Light => light_entity,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_context_title(context_page.title());
|
self.set_context_title(context_page.title());
|
||||||
|
|
@ -2449,38 +2446,32 @@ impl Application for App {
|
||||||
.get(&pane)
|
.get(&pane)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(widget::Id::unique);
|
.unwrap_or_else(widget::Id::unique);
|
||||||
match tab_model.data::<Mutex<Terminal>>(entity) {
|
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||||
Some(terminal) => {
|
let mut terminal_box = terminal_box(terminal)
|
||||||
let mut terminal_box = terminal_box(terminal)
|
.id(terminal_id)
|
||||||
.id(terminal_id)
|
.on_context_menu(move |position_opt| {
|
||||||
.on_context_menu(move |position_opt| {
|
Message::TabContextMenu(pane, position_opt)
|
||||||
Message::TabContextMenu(pane, position_opt)
|
})
|
||||||
})
|
.opacity(self.config.opacity_ratio())
|
||||||
.opacity(self.config.opacity_ratio())
|
.padding(space_xxs);
|
||||||
.padding(space_xxs);
|
|
||||||
|
|
||||||
if self.config.focus_follow_mouse {
|
if self.config.focus_follow_mouse {
|
||||||
terminal_box =
|
terminal_box = terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
|
||||||
terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
|
|
||||||
}
|
|
||||||
|
|
||||||
let context_menu = {
|
|
||||||
let terminal = terminal.lock().unwrap();
|
|
||||||
terminal.context_menu
|
|
||||||
};
|
|
||||||
|
|
||||||
let tab_element: Element<'_, Message> = match context_menu {
|
|
||||||
Some(point) => widget::popover(terminal_box.context_menu(point))
|
|
||||||
.popup(menu::context_menu(&self.config, &self.key_binds, entity))
|
|
||||||
.position(widget::popover::Position::Point(point))
|
|
||||||
.into(),
|
|
||||||
None => terminal_box.into(),
|
|
||||||
};
|
|
||||||
tab_column = tab_column.push(tab_element);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let context_menu = {
|
||||||
|
let terminal = terminal.lock().unwrap();
|
||||||
|
terminal.context_menu
|
||||||
|
};
|
||||||
|
|
||||||
|
let tab_element: Element<'_, Message> = match context_menu {
|
||||||
|
Some(point) => widget::popover(terminal_box.context_menu(point))
|
||||||
|
.popup(menu::context_menu(&self.config, &self.key_binds, entity))
|
||||||
|
.position(widget::popover::Position::Point(point))
|
||||||
|
.into(),
|
||||||
|
None => terminal_box.into(),
|
||||||
|
};
|
||||||
|
tab_column = tab_column.push(tab_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only draw find in the currently focused pane
|
//Only draw find in the currently focused pane
|
||||||
|
|
@ -2538,6 +2529,8 @@ impl Application for App {
|
||||||
|
|
||||||
tab_column = tab_column
|
tab_column = tab_column
|
||||||
.push(widget::layer_container(find_widget).layer(cosmic_theme::Layer::Primary));
|
.push(widget::layer_container(find_widget).layer(cosmic_theme::Layer::Primary));
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
pane_grid::Content::new(tab_column)
|
pane_grid::Content::new(tab_column)
|
||||||
|
|
|
||||||
|
|
@ -110,25 +110,25 @@ fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
|
||||||
let rgb = match color {
|
let rgb = match color {
|
||||||
Color::Named(named_color) => match colors[named_color] {
|
Color::Named(named_color) => match colors[named_color] {
|
||||||
Some(rgb) => rgb,
|
Some(rgb) => rgb,
|
||||||
None => match named_color {
|
None => {
|
||||||
NamedColor::Background => {
|
if named_color == NamedColor::Background {
|
||||||
// Allow using an unset background
|
// Allow using an unset background
|
||||||
return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst));
|
return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst));
|
||||||
}
|
} else {
|
||||||
_ => {
|
|
||||||
log::warn!("missing named color {:?}", named_color);
|
log::warn!("missing named color {:?}", named_color);
|
||||||
Rgb::default()
|
Rgb::default()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Color::Spec(rgb) => rgb,
|
Color::Spec(rgb) => rgb,
|
||||||
Color::Indexed(index) => match colors[index as usize] {
|
Color::Indexed(index) => {
|
||||||
Some(rgb) => rgb,
|
if let Some(rgb) = colors[index as usize] {
|
||||||
None => {
|
rgb
|
||||||
|
} else {
|
||||||
log::warn!("missing indexed color {}", index);
|
log::warn!("missing indexed color {}", index);
|
||||||
Rgb::default()
|
Rgb::default()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b)
|
cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue