Skip to content

Commit

Permalink
chore: update deps (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski authored Aug 19, 2024
1 parent 5d03353 commit 47fbb6e
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 130 deletions.
195 changes: 102 additions & 93 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ tokio-util = "0.7"
futures = "0.3"

# TUI
crossterm = { version = "0.27", features = ["event-stream", "serde"] }
ratatui = { version = "0.27", features = ["serde"] }
tui-input = "0.9"
tui-tree-widget = "0.21"
throbber-widgets-tui = "0.6.0"
crossterm = { version = "0.28", features = ["event-stream", "serde"] }
ratatui = { version = "0.28", features = ["serde"] }
tui-input = "0.10"
tui-tree-widget = "0.22"
throbber-widgets-tui = "0.7"

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand Down
2 changes: 1 addition & 1 deletion rm-main/src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl App {

fn render(&mut self, tui: &mut Tui) -> Result<()> {
tui.terminal.draw(|f| {
self.main_window.render(f, f.size());
self.main_window.render(f, f.area());
})?;
Ok(())
}
Expand Down
6 changes: 5 additions & 1 deletion rm-main/src/tui/components/input_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ impl Component for InputManager {
f.render_widget(paragraph, rect);

let cursor_offset = self.input.visual_cursor() + prefix_len;
f.set_cursor(rect.x + u16::try_from(cursor_offset).unwrap(), rect.y);
let cursor_position = Position {
x: rect.x + u16::try_from(cursor_offset).unwrap(),
y: rect.y,
};
f.set_cursor_position(cursor_position);
}
}
16 changes: 4 additions & 12 deletions rm-main/src/tui/components/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,11 @@ impl<T: Clone> GenericTable<T> {
}
}

pub fn scroll_to_home(&mut self) {
let mut state = self.state.borrow_mut();
if !self.items.is_empty() {
state.select(Some(0));
}
pub fn select_first(&mut self) {
self.state.borrow_mut().select_first();
}

pub fn scroll_to_end(&mut self) {
if self.items.is_empty() {
return;
}

let mut state = self.state.borrow_mut();
state.select(Some(self.items.len() - 1));
pub fn select_last(&mut self) {
self.state.borrow_mut().select_last();
}
}
2 changes: 1 addition & 1 deletion rm-main/src/tui/global_popups/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Component for ErrorPopup {
}

fn render(&mut self, f: &mut Frame, _rect: Rect) {
let centered_rect = centered_rect(f.size(), 50, 50);
let centered_rect = centered_rect(f.area(), 50, 50);
let popup_rect = centered_rect.inner(Margin::new(1, 1));
let text_rect = popup_rect.inner(Margin::new(3, 2));
let button_rect = Layout::vertical([Constraint::Percentage(100), Constraint::Length(1)])
Expand Down
2 changes: 1 addition & 1 deletion rm-main/src/tui/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Component for MainWindow {
CurrentTab::Search => self.search_tab.render(f, main_window),
}

self.global_popup_manager.render(f, f.size());
self.global_popup_manager.render(f, f.area());
}
}

Expand Down
15 changes: 8 additions & 7 deletions rm-main/src/tui/tabs/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ impl SearchTab {
}

fn scroll_to_end(&mut self) {
self.table.scroll_to_end();
self.table.select_last();
self.ctx.send_action(Action::Render);
}

fn scroll_to_home(&mut self) {
self.table.scroll_to_home();
self.table.select_first();
self.ctx.send_action(Action::Render);
}

Expand Down Expand Up @@ -386,10 +386,11 @@ impl Component for SearchTab {
f.render_widget(paragraph, search_rect);

let cursor_offset = self.input.visual_cursor() + prefix_len;
f.set_cursor(
search_rect.x + u16::try_from(cursor_offset).unwrap(),
search_rect.y,
);
let cursor_position = Position {
x: search_rect.x + u16::try_from(cursor_offset).unwrap(),
y: search_rect.y,
};
f.set_cursor_position(cursor_position);

let header = Row::new(["S", "Title", "Size"]);

Expand Down Expand Up @@ -421,7 +422,7 @@ impl Component for SearchTab {
f.render_stateful_widget(table, rest, &mut self.table.state.borrow_mut());

self.bottom_bar.render(f, bottom_line);
self.popup_manager.render(f, f.size());
self.popup_manager.render(f, f.area());
}
}

Expand Down
18 changes: 9 additions & 9 deletions rm-main/src/tui/tabs/torrents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Component for TorrentsTab {

self.task_manager.render(f, stats_rect);

self.popup_manager.render(f, f.size());
self.popup_manager.render(f, f.area());
}

fn handle_actions(&mut self, action: Action) -> ComponentAction {
Expand All @@ -86,8 +86,8 @@ impl Component for TorrentsTab {
A::ScrollDownPage => self.scroll_page_down(),
A::ScrollUpBy(amount) => self.scroll_up_by(amount),
A::ScrollDownBy(amount) => self.scroll_down_by(amount),
A::Home => self.scroll_to_home(),
A::End => self.scroll_to_end(),
A::Home => self.select_first(),
A::End => self.select_last(),
A::ShowStats => self.show_statistics_popup(),
A::ShowFiles => self.show_files_popup(),
A::Pause => self.pause_current_torrent(),
Expand All @@ -110,7 +110,7 @@ impl Component for TorrentsTab {
self.task_manager.move_torrent(torrent);
}
}
A::XdgOpen => self.open_current_torrent(),
A::XdgOpen => self.xdg_open_current_torrent(),
other => {
self.task_manager.handle_actions(other);
}
Expand Down Expand Up @@ -262,15 +262,15 @@ impl TorrentsTab {
self.ctx.send_action(Action::Render);
}

fn scroll_to_home(&mut self) {
self.table_manager.table.scroll_to_home();
fn select_first(&mut self) {
self.table_manager.table.select_first();
self.bottom_stats
.update_selected_indicator(&self.table_manager);
self.ctx.send_action(Action::Render);
}

fn scroll_to_end(&mut self) {
self.table_manager.table.scroll_to_end();
fn select_last(&mut self) {
self.table_manager.table.select_last();
self.bottom_stats
.update_selected_indicator(&self.table_manager);
self.ctx.send_action(Action::Render);
Expand All @@ -296,7 +296,7 @@ impl TorrentsTab {
}
}

fn open_current_torrent(&mut self) {
fn xdg_open_current_torrent(&mut self) {
if let Some(torrent) = self.table_manager.current_torrent() {
let torrent_location = torrent.torrent_location();
match open::that_detached(&torrent_location) {
Expand Down

0 comments on commit 47fbb6e

Please sign in to comment.