From 557299f304ec334e2bc33ada8766315c1f60fbe6 Mon Sep 17 00:00:00 2001 From: kohashimoto Date: Tue, 24 Oct 2023 14:36:26 +0900 Subject: [PATCH] fix(deps): update rust crate ratatui to 0.24.0 --- src/ui/popup.rs | 3 +-- src/ui/tab.rs | 11 +++++------ src/ui/widget.rs | 4 ++-- src/ui/widget/complex/input.rs | 3 +-- src/ui/widget/complex/multiple_select.rs | 5 ++--- src/ui/widget/complex/single_select.rs | 10 +++------- src/ui/widget/list.rs | 9 ++++----- src/ui/widget/table.rs | 10 +++------- src/ui/widget/table/filter_form.rs | 6 +----- src/ui/widget/text.rs | 15 ++++----------- src/ui/window.rs | 11 +++++------ 11 files changed, 31 insertions(+), 56 deletions(-) diff --git a/src/ui/popup.rs b/src/ui/popup.rs index 1f167228..16820cd8 100644 --- a/src/ui/popup.rs +++ b/src/ui/popup.rs @@ -1,6 +1,5 @@ use crossterm::event::{KeyEvent, MouseEvent}; use ratatui::{ - backend::Backend, layout::{Margin, Rect}, widgets::Clear, Frame, @@ -101,7 +100,7 @@ impl<'a> Popup<'a> { &mut self.widget } - pub fn render(&mut self, f: &mut Frame) { + pub fn render(&mut self, f: &mut Frame) { f.render_widget(Clear, self.chunk); self.widget.render(f, true, false) diff --git a/src/ui/tab.rs b/src/ui/tab.rs index c80e4122..4e1dfdb4 100644 --- a/src/ui/tab.rs +++ b/src/ui/tab.rs @@ -6,7 +6,6 @@ use super::{ use crossterm::event::{MouseButton, MouseEvent, MouseEventKind}; use ratatui::{ - backend::Backend, layout::{Constraint, Layout, Rect}, Frame, }; @@ -179,7 +178,10 @@ impl<'a> Tab<'a> { .iter_mut() .enumerate() .find(|(_, w)| w.chunk().contains_point(pos)) - .map(|(i, w)| (i, w.id().to_string()) ) else { return EventResult::Ignore }; + .map(|(i, w)| (i, w.id().to_string())) + else { + return EventResult::Ignore; + }; match ev.kind { MouseEventKind::Down(MouseButton::Left) => { @@ -198,10 +200,7 @@ impl<'a> Tab<'a> { } impl Tab<'_> { - pub fn render(&mut self, f: &mut Frame) - where - B: Backend, - { + pub fn render(&mut self, f: &mut Frame) { self.widgets.iter_mut().enumerate().for_each(|(i, w)| { w.widget.render( f, diff --git a/src/ui/widget.rs b/src/ui/widget.rs index 54dfdf64..b867374c 100644 --- a/src/ui/widget.rs +++ b/src/ui/widget.rs @@ -22,7 +22,7 @@ use crossterm::event::{KeyEvent, MouseEvent}; use enum_dispatch::enum_dispatch; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; use std::{collections::BTreeMap, hash::Hash}; @@ -200,7 +200,7 @@ pub trait WidgetTrait { #[enum_dispatch] pub trait RenderTrait { - fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool); + fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool); } #[enum_dispatch(WidgetTrait, RenderTrait)] diff --git a/src/ui/widget/complex/input.rs b/src/ui/widget/complex/input.rs index 588eae14..1af9802e 100644 --- a/src/ui/widget/complex/input.rs +++ b/src/ui/widget/complex/input.rs @@ -3,7 +3,6 @@ use crate::ui::{event::EventResult, key_event_to_code, widget::*}; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent}; use ratatui::{ - backend::Backend, layout::Rect, style::*, text::{Line, Span}, @@ -101,7 +100,7 @@ impl InputForm { self.widget_config.render_block(is_active, false) } - pub fn render(&mut self, f: &mut Frame, is_active: bool) { + pub fn render(&mut self, f: &mut Frame, is_active: bool) { let spans = self.render_content(is_active); let block = self.block(is_active); let chunk = self.chunk; diff --git a/src/ui/widget/complex/multiple_select.rs b/src/ui/widget/complex/multiple_select.rs index c2a52b0e..7c1efd37 100644 --- a/src/ui/widget/complex/multiple_select.rs +++ b/src/ui/widget/complex/multiple_select.rs @@ -14,7 +14,6 @@ use derivative::*; use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; use ratatui::{ - backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::*, text::Span, @@ -266,7 +265,7 @@ impl<'a> SelectForm<'a> { } } - fn render(&mut self, f: &mut Frame) { + fn render(&mut self, f: &mut Frame) { let (chunks, arrow) = self.chunks_and_arrow(); let arrow = Paragraph::new(Span::styled( @@ -672,7 +671,7 @@ impl Default for MultipleSelect<'_> { } impl RenderTrait for MultipleSelect<'_> { - fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool) { + fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool) { let block = if let Some(block_injection) = &self.block_injection { (block_injection)(&*self, is_active) } else { diff --git a/src/ui/widget/complex/single_select.rs b/src/ui/widget/complex/single_select.rs index 627074d0..dc50bc96 100644 --- a/src/ui/widget/complex/single_select.rs +++ b/src/ui/widget/complex/single_select.rs @@ -1,7 +1,6 @@ use crossterm::event::{KeyEvent, MouseEvent}; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::{Block, Paragraph}, Frame, @@ -37,7 +36,7 @@ struct SelectForm<'a> { } impl<'a> SelectForm<'a> { - fn render(&mut self, f: &mut Frame) { + fn render(&mut self, f: &mut Frame) { self.list_widget.render(f, true, false); } @@ -167,7 +166,7 @@ impl<'a> SingleSelect<'a> { &self.id } - fn render_status(&mut self, f: &mut Frame) { + fn render_status(&mut self, f: &mut Frame) { let status = self.select_widget.status(); f.render_widget( Paragraph::new(format!("[{}/{}]", status.0, status.1)), @@ -337,10 +336,7 @@ impl WidgetTrait for SingleSelect<'_> { } impl RenderTrait for SingleSelect<'_> { - fn render(&mut self, f: &mut Frame<'_, B>, is_active: bool, is_mouse_over: bool) - where - B: Backend, - { + fn render(&mut self, f: &mut Frame<'_>, is_active: bool, is_mouse_over: bool) { let block = if let Some(block_injection) = &self.block_injection { (block_injection)(&*self, is_active) } else { diff --git a/src/ui/widget/list.rs b/src/ui/widget/list.rs index c1e96e07..05eb0f61 100644 --- a/src/ui/widget/list.rs +++ b/src/ui/widget/list.rs @@ -1,10 +1,9 @@ use std::rc::Rc; use ratatui::{ - backend::Backend, layout::Rect, style::{Modifier, Style}, - widgets::{self, Block, ListState, ScrollbarState, Scrollbar, ScrollbarOrientation}, + widgets::{self, Block, ListState, Scrollbar, ScrollbarOrientation, ScrollbarState}, Frame, }; @@ -408,7 +407,7 @@ impl<'a> List<'a> { } impl RenderTrait for List<'_> { - fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool) { + fn render(&mut self, f: &mut Frame, is_active: bool, is_mouse_over: bool) { let block = if let Some(block_injection) = &self.block_injection { (block_injection)(&*self, is_active) } else { @@ -419,8 +418,8 @@ impl RenderTrait for List<'_> { f.render_stateful_widget(self.widget(block), self.chunk, &mut self.state); let mut scrollbar_state = ScrollbarState::default() - .position(self.state.offset() as u16) - .content_length(self.max_offset() as u16) + .position(self.state.offset()) + .content_length(self.max_offset()) .viewport_content_length(2); f.render_stateful_widget( diff --git a/src/ui/widget/table.rs b/src/ui/widget/table.rs index b4a1e029..cab4d5c0 100644 --- a/src/ui/widget/table.rs +++ b/src/ui/widget/table.rs @@ -4,7 +4,6 @@ mod item; use crossterm::event::{KeyCode, KeyEvent, MouseButton, MouseEvent, MouseEventKind}; use derivative::*; use ratatui::{ - backend::Backend, layout::{Constraint, Rect}, style::{Modifier, Style}, widgets::{Scrollbar, ScrollbarOrientation, ScrollbarState, Table as TuiTable, TableState}, @@ -627,10 +626,7 @@ impl<'a> Table<'a> { } impl RenderTrait for Table<'_> { - fn render(&mut self, f: &mut Frame<'_, B>, is_active: bool, is_mouse_over: bool) - where - B: Backend, - { + fn render(&mut self, f: &mut Frame<'_>, is_active: bool, is_mouse_over: bool) { let widget_config = if let Some(block_injection) = &self.block_injection { (block_injection)(&*self) } else { @@ -676,8 +672,8 @@ impl RenderTrait for Table<'_> { ); let mut scrollbar_state = ScrollbarState::default() - .position(self.state.offset() as u16) - .content_length(self.max_offset() as u16) + .position(self.state.offset()) + .content_length(self.max_offset()) .viewport_content_length(2); f.render_stateful_widget( diff --git a/src/ui/widget/table/filter_form.rs b/src/ui/widget/table/filter_form.rs index b31f9ca4..b0c6f9fb 100644 --- a/src/ui/widget/table/filter_form.rs +++ b/src/ui/widget/table/filter_form.rs @@ -1,6 +1,5 @@ use crossterm::event::KeyEvent; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::{Block, BorderType, Borders, Paragraph}, Frame, @@ -45,10 +44,7 @@ impl FilterForm { self.input_widget.clear(); } - pub fn render(&mut self, f: &mut Frame<'_, B>, is_active: bool) - where - B: Backend, - { + pub fn render(&mut self, f: &mut Frame<'_>, is_active: bool) { let header = "FILTER: "; let content = self.input_widget.render_content(is_active); diff --git a/src/ui/widget/text.rs b/src/ui/widget/text.rs index 964f1a0f..3ce4f286 100644 --- a/src/ui/widget/text.rs +++ b/src/ui/widget/text.rs @@ -9,7 +9,6 @@ use crossterm::event::{KeyCode, KeyEvent, MouseButton, MouseEvent, MouseEventKin use derivative::Derivative; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::{Block, Paragraph, Scrollbar, ScrollbarOrientation, ScrollbarState}, Frame, @@ -149,10 +148,7 @@ impl SearchForm { self.input_widget.on_key_event(ev) } - fn render(&mut self, f: &mut Frame<'_, B>, is_active: bool, status: (usize, usize)) - where - B: Backend, - { + fn render(&mut self, f: &mut Frame<'_>, is_active: bool, status: (usize, usize)) { let header = "Search: "; let content = self.input_widget.render_content(is_active); @@ -836,10 +832,7 @@ impl WidgetTrait for Text { } impl RenderTrait for Text { - fn render(&mut self, f: &mut Frame<'_, B>, is_active: bool, is_mouse_over: bool) - where - B: Backend, - { + fn render(&mut self, f: &mut Frame<'_>, is_active: bool, is_mouse_over: bool) { let block = if let Some(block_injection) = &self.block_injection { (block_injection)(&*self, self.can_activate() && is_active, is_mouse_over) } else { @@ -877,8 +870,8 @@ impl RenderTrait for Text { } let mut scrollbar_state = ScrollbarState::default() - .position(self.scroll.y as u16) - .content_length(self.scroll_y_last_index() as u16) + .position(self.scroll.y) + .content_length(self.scroll_y_last_index()) .viewport_content_length(2); f.render_stateful_widget( diff --git a/src/ui/window.rs b/src/ui/window.rs index 58eb3843..a3253e63 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -3,7 +3,6 @@ use std::rc::Rc; use crossterm::event::{KeyCode, KeyEvent, MouseButton, MouseEvent, MouseEventKind}; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, text::{Line, Span}, @@ -362,7 +361,7 @@ impl<'a> Window<'a> { // Render impl<'a> Window<'a> { - pub fn render(&mut self, f: &mut Frame) { + pub fn render(&mut self, f: &mut Frame) { let size = f.size(); if self.last_known_size != size { @@ -380,11 +379,11 @@ impl<'a> Window<'a> { self.render_popup(f); } - fn render_tab(&mut self, f: &mut Frame) { + fn render_tab(&mut self, f: &mut Frame) { f.render_widget(self.widget(), self.tab_chunk()); } - fn render_header(&self, f: &mut Frame) { + fn render_header(&self, f: &mut Frame) { if let Some(header) = &self.header { let w = match &header.content { HeaderContent::Static(content) => Paragraph::new(content.to_vec()), @@ -394,11 +393,11 @@ impl<'a> Window<'a> { } } - fn render_contents(&mut self, f: &mut Frame) { + fn render_contents(&mut self, f: &mut Frame) { self.active_tab_mut().render(f); } - fn render_popup(&mut self, f: &mut Frame) { + fn render_popup(&mut self, f: &mut Frame) { if let Some(id) = &self.open_popup_id { if let Some(popup) = self.popups.iter_mut().find(|p| p.id() == id) { popup.render(f);