diff --git a/bin/commands/patch/select/imui.rs b/bin/commands/patch/select/imui.rs index ec220dd8..5b207311 100644 --- a/bin/commands/patch/select/imui.rs +++ b/bin/commands/patch/select/imui.rs @@ -49,7 +49,7 @@ const HELP: &str = r#"# Generic keybindings Pattern: is: | is:authored | authors:[, ] | Example: is:open is:authored improve"#; -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum Message { Quit, Exit { @@ -243,7 +243,7 @@ impl App { } impl App { - pub fn show_patches(&self, frame: &mut Frame, ui: &mut im::Ui, state: &State) { + pub fn show_patches(&self, frame: &mut Frame, ui: &mut im::Ui, state: &State) { let patches = state .storage .patches @@ -278,7 +278,12 @@ impl App { } } - pub fn show_search_text_edit(&self, frame: &mut Frame, ui: &mut im::Ui, state: &State) { + pub fn show_search_text_edit( + &self, + frame: &mut Frame, + ui: &mut im::Ui, + state: &State, + ) { let (mut search_text, mut search_cursor) = ( state.search.clone().read().text, state.search.clone().read().cursor, @@ -314,7 +319,7 @@ impl im::App for App { type State = State; type Message = Message; - fn update(&self, ctx: &im::Context, frame: &mut Frame, state: &Self::State) -> Result<()> { + fn update(&self, ctx: &im::Context, frame: &mut Frame, state: &State) -> Result<()> { Window::default().show(ctx, |ui| { match state.page { Page::Main => { @@ -481,7 +486,7 @@ impl im::App for App { } } -fn browser_context<'a>(ui: &im::Ui, state: &'a State) -> Vec> { +fn browser_context<'a>(ui: &im::Ui, state: &'a State) -> Vec> { let search = state.search.read().text; let total_count = state.storage.patches.len(); let filtered_count = state @@ -644,7 +649,7 @@ fn browser_context<'a>(ui: &im::Ui, state: &'a State) -> Vec> { } } -fn default_context<'a>(ui: &im::Ui) -> Vec> { +fn default_context<'a>(ui: &im::Ui) -> Vec> { [ Column::new( Span::raw(" ".to_string()) diff --git a/bin/ui/im.rs b/bin/ui/im.rs index adb8fcbe..87dec2d1 100644 --- a/bin/ui/im.rs +++ b/bin/ui/im.rs @@ -9,22 +9,25 @@ use tui::ui::im::widget::{TableState, TextEditState, Widget}; use tui::ui::im::{Borders, BufferedValue, Response, Ui}; use tui::ui::{Column, ToRow}; -pub struct UiExt<'a>(&'a mut Ui); +pub struct UiExt<'a, M>(&'a mut Ui); -impl<'a> UiExt<'a> { - pub fn new(ui: &'a mut Ui) -> Self { +impl<'a, M> UiExt<'a, M> { + pub fn new(ui: &'a mut Ui) -> Self { Self(ui) } } -impl<'a> From<&'a mut Ui> for UiExt<'a> { - fn from(ui: &'a mut Ui) -> Self { +impl<'a, M> From<&'a mut Ui> for UiExt<'a, M> { + fn from(ui: &'a mut Ui) -> Self { Self::new(ui) } } #[allow(dead_code)] -impl<'a> UiExt<'a> { +impl<'a, M> UiExt<'a, M> +where + M: Clone, +{ #[allow(clippy::too_many_arguments)] pub fn browser( &mut self, @@ -106,7 +109,10 @@ impl<'a, R, const W: usize> Widget for Browser<'a, R, W> where R: ToRow + Clone, { - fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response { + fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response + where + M: Clone, + { let mut response = Response::default(); let (_, has_focus) = ui.current_area().unwrap_or_default();