Skip to content

Commit 0d26865

Browse files
authored
Merge pull request #9 from orhun/chore/bump-tui-deps
Bump dependencies
2 parents 8ddab1d + 2e6c746 commit 0d26865

File tree

14 files changed

+396
-210
lines changed

14 files changed

+396
-210
lines changed

Cargo.lock

Lines changed: 354 additions & 143 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,21 @@ keywords = ["git", "gitignore", "cli"]
1313
categories = ["development-tools", "command-line-utilities"]
1414

1515
[dependencies]
16-
anyhow = "1.0.74"
17-
clap = { version = "4.3.23", features = ["derive"] }
16+
anyhow = "1.0.89"
17+
clap = { version = "4.5.20", features = ["derive"] }
1818
copypasta = "0.8.2"
19-
crossterm = "0.27.0"
2019
dirs = "5.0.1"
21-
human-panic = "1.1.5"
22-
indoc = "2.0.3"
23-
native-tls = { version = "0.2.11", features = [] }
24-
once_cell = "1.18.0"
25-
ratatui = { version = "0.22.0", features = ["default"] }
26-
serde = { version = "1.0.183", features = ["default", "derive"] }
27-
serde_json = "1.0.105"
28-
tui-input = "0.8.0"
29-
ureq = { version = "2.7.1", features = ["gzip", "native-tls"], default-features = false }
30-
url = "2.4.0"
31-
yansi = "1.0.0-rc.1"
20+
human-panic = "1.2.3"
21+
indoc = "2.0.5"
22+
native-tls = { version = "0.2.12", features = [] }
23+
once_cell = "1.20.2"
24+
ratatui = "0.28.1"
25+
serde = { version = "1.0.210", features = ["default", "derive"] }
26+
serde_json = "1.0.128"
27+
tui-input = "0.10.1"
28+
ureq = { version = "2.10.1", features = ["gzip", "native-tls"], default-features = false }
29+
url = "2.5.2"
30+
yansi = "1.0.1"
3231

3332
[profile.release]
3433
lto = true
@@ -66,4 +65,4 @@ pre-build = [
6665
pre-build = [
6766
"dpkg --add-architecture $CROSS_DEB_ARCH",
6867
"apt-get update && apt-get --assume-yes install pkg-config libssl-dev:$CROSS_DEB_ARCH"
69-
]
68+
]

src/commands/search/framework/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, MouseEvent};
2+
use ratatui::crossterm::event::{self, Event as CrosstermEvent, KeyEvent, MouseEvent};
33
use std::sync::mpsc;
44
use std::thread;
55
use std::time::{Duration, Instant};

src/commands/search/framework/tui.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use crate::commands::search::framework::event::EventHandler;
22
use crate::commands::search::state::UIState;
33
use crate::commands::search::views::render;
44
use anyhow::Result;
5-
use crossterm::event::{
5+
use ratatui::backend::Backend;
6+
use ratatui::crossterm::event::{
67
DisableMouseCapture, EnableMouseCapture, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags,
78
PushKeyboardEnhancementFlags,
89
};
9-
use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
10-
use ratatui::backend::Backend;
10+
use ratatui::crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
1111
use ratatui::Terminal;
1212
use std::io;
1313
use std::panic;
@@ -38,7 +38,7 @@ impl<B: Backend> Tui<B> {
3838

3939
if cfg!(target_family = "unix") {
4040
// Keyboard event types are only reported on Windows by default, enable on Unix too
41-
crossterm::execute!(
41+
ratatui::crossterm::execute!(
4242
io::stderr(),
4343
EnterAlternateScreen,
4444
EnableMouseCapture,
@@ -47,7 +47,7 @@ impl<B: Backend> Tui<B> {
4747
} else {
4848
// Don't add the keyboard enhancement flags on Windows, as it produces error:
4949
// - Keyboard progressive enhancement not implemented for the legacy Windows API.
50-
crossterm::execute!(io::stderr(), EnterAlternateScreen, EnableMouseCapture)?;
50+
ratatui::crossterm::execute!(io::stderr(), EnterAlternateScreen, EnableMouseCapture)?;
5151
}
5252

5353
// Define a custom panic hook to reset the terminal properties.
@@ -84,14 +84,14 @@ impl<B: Backend> Tui<B> {
8484
fn reset() -> Result<()> {
8585
terminal::disable_raw_mode()?;
8686
if cfg!(target_family = "unix") {
87-
crossterm::execute!(
87+
ratatui::crossterm::execute!(
8888
io::stdout(),
8989
LeaveAlternateScreen,
9090
DisableMouseCapture,
9191
PopKeyboardEnhancementFlags
9292
)?;
9393
} else {
94-
crossterm::execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture)?;
94+
ratatui::crossterm::execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture)?;
9595
}
9696
Ok(())
9797
}

src/commands/search/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use crate::commands::search::state::view_preview::{UIStatePreview, UIStatePrevie
33
use crate::commands::search::state::{UIState, UIStateView};
44
use crate::template::list::TemplateList;
55
use anyhow::Result;
6-
use crossterm::event::{
6+
use ratatui::backend::CrosstermBackend;
7+
use ratatui::crossterm::event::{
78
Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseButton, MouseEvent, MouseEventKind,
89
};
9-
use ratatui::backend::CrosstermBackend;
1010
use std::io::Stderr;
1111
use std::time::{Duration, Instant};
1212
use tui_input::backend::crossterm::EventHandler;

src/commands/search/state/view_preview.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl UIStatePreview {
5555
};
5656

5757
let scroll_pos = 0;
58-
let scroll_state = ScrollbarState::default().content_length(content_lines);
58+
let scroll_state = ScrollbarState::default().content_length(content_lines.into());
5959

6060
Ok(Self {
6161
state,
@@ -78,13 +78,13 @@ impl UIStatePreview {
7878
/// Scrolls to the bottom of the preview content
7979
pub fn scroll_to_bottom(&mut self) {
8080
self.scroll_pos = self.content_lines.saturating_sub(1);
81-
self.scroll_state = self.scroll_state.position(self.scroll_pos);
81+
self.scroll_state = self.scroll_state.position(self.scroll_pos.into());
8282
}
8383

8484
/// Scrolls to the preview content up one increment
8585
pub fn scroll_up(&mut self) {
8686
self.scroll_pos = self.scroll_pos.saturating_sub(1);
87-
self.scroll_state = self.scroll_state.position(self.scroll_pos);
87+
self.scroll_state = self.scroll_state.position(self.scroll_pos.into());
8888
}
8989

9090
/// Scrolls to the preview content down one increment
@@ -93,7 +93,7 @@ impl UIStatePreview {
9393
.scroll_pos
9494
.saturating_add(1)
9595
.clamp(0, self.content_lines.saturating_sub(1));
96-
self.scroll_state = self.scroll_state.position(self.scroll_pos);
96+
self.scroll_state = self.scroll_state.position(self.scroll_pos.into());
9797
}
9898

9999
/// Copies the preview content to the clipboard

src/commands/search/views/home/footer.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
use crate::commands::search::state::UIState;
22
use indoc::formatdoc;
3-
use ratatui::backend::Backend;
43
use ratatui::layout::{Constraint, Direction, Layout, Rect};
54
use ratatui::style::{Style, Stylize};
65
use ratatui::widgets::{Block, Padding, Paragraph};
76
use ratatui::{text, Frame};
87

98
/// Renders the home UI footer (help section)
10-
pub fn render_home_footer<B: Backend>(
11-
_app: &mut UIState,
12-
f: &mut Frame<'_, B>,
13-
chunk: Rect,
14-
) -> anyhow::Result<()> {
9+
pub fn render_home_footer(_app: &mut UIState, f: &mut Frame, chunk: Rect) -> anyhow::Result<()> {
1510
let chunks = Layout::default()
1611
.direction(Direction::Horizontal)
1712
.constraints([

src/commands/search/views/home/header.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::commands::search::state::UIState;
2-
use ratatui::backend::Backend;
32
use ratatui::layout::{Constraint, Direction, Layout, Rect};
43
use ratatui::style::{Color, Style, Stylize};
54
use ratatui::symbols::DOT;
@@ -27,11 +26,7 @@ fn create_tabs<'a>(tab_titles: Vec<String>, list_tab: usize) -> anyhow::Result<T
2726
}
2827

2928
/// Renders the home view header (collection tabs)
30-
pub fn render_home_header<B: Backend>(
31-
app: &mut UIState,
32-
f: &mut Frame<'_, B>,
33-
chunk: Rect,
34-
) -> anyhow::Result<()> {
29+
pub fn render_home_header(app: &mut UIState, f: &mut Frame, chunk: Rect) -> anyhow::Result<()> {
3530
let chunks = Layout::default()
3631
.direction(Direction::Horizontal)
3732
.constraints([

src/commands/search/views/home/main_list.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::commands::search::state::collection::UICollectionSelection;
22
use crate::commands::search::state::UIState;
33
use crate::commands::search::views::util;
44
use crate::template::item::Template;
5-
use ratatui::backend::Backend;
65
use ratatui::layout::Rect;
76
use ratatui::style::{Color, Modifier, Style, Stylize};
87
use ratatui::widgets::{Block, BorderType, Borders, List, ListItem, ListState, Padding};
@@ -47,11 +46,7 @@ fn create_list<'a>(
4746
}
4847

4948
/// Renders the main collection templates list
50-
pub fn render_home_main_list<B: Backend>(
51-
app: &mut UIState,
52-
f: &mut Frame<'_, B>,
53-
chunk: Rect,
54-
) -> anyhow::Result<()> {
49+
pub fn render_home_main_list(app: &mut UIState, f: &mut Frame, chunk: Rect) -> anyhow::Result<()> {
5550
let list = app.collection();
5651
let state = &mut list.state.lock().unwrap();
5752
let widget = create_list(&list.values, state, &app.selected.lock().unwrap())?;

src/commands/search/views/home/main_side.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::commands::search::state::collection::UICollectionSelection;
22
use crate::commands::search::state::UIState;
33
use crate::commands::search::views::util;
4-
use ratatui::backend::Backend;
5-
use ratatui::layout::{Constraint, Layout, Rect};
4+
use ratatui::layout::{Constraint, Layout, Position, Rect};
65
use ratatui::style::{Color, Style, Stylize};
76
use ratatui::widgets::block::Title;
87
use ratatui::widgets::{Block, BorderType, Borders, List, ListItem, Padding, Paragraph};
@@ -59,11 +58,7 @@ fn create_selected<'a>(
5958
}
6059

6160
/// Render the right sidebar of the home view (filter input & selected templates)
62-
pub fn render_home_main_side<B: Backend>(
63-
app: &mut UIState,
64-
f: &mut Frame<'_, B>,
65-
chunk: Rect,
66-
) -> anyhow::Result<()> {
61+
pub fn render_home_main_side(app: &mut UIState, f: &mut Frame, chunk: Rect) -> anyhow::Result<()> {
6762
let chunks = Layout::default()
6863
.constraints(vec![Constraint::Length(3), Constraint::Min(0)])
6964
.split(chunk);
@@ -82,12 +77,12 @@ pub fn render_home_main_side<B: Backend>(
8277
f.render_widget(selected_widget, bottom);
8378

8479
if is_filtering {
85-
f.set_cursor(
80+
f.set_cursor_position(Position::new(
8681
// Put cursor past the end of the input text
8782
top.x + app.collection_filter.visual_cursor() as u16 + 2,
8883
// Move one line down, from the border to the input line
8984
top.y + 1,
90-
)
85+
))
9186
}
9287

9388
Ok(())

src/commands/search/views/home/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ use crate::commands::search::views::home::header::render_home_header;
99
use crate::commands::search::views::home::main_list::render_home_main_list;
1010
use crate::commands::search::views::home::main_side::render_home_main_side;
1111
use anyhow::{bail, Result};
12-
use ratatui::backend::Backend;
1312
use ratatui::layout::{Constraint, Direction, Layout};
1413
use ratatui::Frame;
1514

1615
/// Renders the main home UI
17-
pub fn render_home<B: Backend>(app: &mut UIState, f: &mut Frame<'_, B>) -> Result<()> {
16+
pub fn render_home(app: &mut UIState, f: &mut Frame) -> Result<()> {
1817
match &mut app.view {
1918
UIStateView::Home => {
2019
// let app = Mutex::new(app);
@@ -27,7 +26,7 @@ pub fn render_home<B: Backend>(app: &mut UIState, f: &mut Frame<'_, B>) -> Resul
2726
])
2827
.vertical_margin(0)
2928
.horizontal_margin(1)
30-
.split(f.size());
29+
.split(f.area());
3130

3231
let main = Layout::default()
3332
.direction(Direction::Horizontal)

src/commands/search/views/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ mod preview;
33
mod util;
44

55
use crate::commands::search::state::{UIState, UIStateView};
6-
use ratatui::backend::Backend;
76
use ratatui::Frame;
87

98
/// Renders the user interface
10-
pub fn render<B: Backend>(app: &mut UIState, f: &mut Frame<'_, B>) -> anyhow::Result<()> {
9+
pub fn render(app: &mut UIState, f: &mut Frame) -> anyhow::Result<()> {
1110
match &app.view {
1211
UIStateView::Home => home::render_home(app, f)?,
1312
UIStateView::Preview { .. } => preview::render_preview(app, f)?,

src/commands/search/views/preview/footer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use indoc::formatdoc;
2-
use ratatui::backend::Backend;
32
use ratatui::layout::{Constraint, Direction, Layout, Rect};
43
use ratatui::style::{Style, Stylize};
54
use ratatui::widgets::{Block, Padding, Paragraph};
65
use ratatui::{text, Frame};
76

87
/// Renders the preview footer (help section)
9-
pub fn render_preview_footer<B: Backend>(f: &mut Frame<'_, B>, chunk: Rect) -> anyhow::Result<()> {
8+
pub fn render_preview_footer(f: &mut Frame, chunk: Rect) -> anyhow::Result<()> {
109
let chunks = Layout::default()
1110
.direction(Direction::Horizontal)
1211
.constraints([

src/commands/search/views/preview/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::commands::search::state::{UIState, UIStateView};
55
use crate::commands::search::views::preview::footer::render_preview_footer;
66
use crate::commands::search::views::util::rect_center;
77
use anyhow::{bail, Result};
8-
use ratatui::backend::Backend;
98
use ratatui::layout::{Constraint, Layout};
109
use ratatui::style::{Style, Stylize};
1110
use ratatui::text::{Line, Text};
@@ -15,10 +14,10 @@ use ratatui::widgets::{
1514
use ratatui::{text, Frame};
1615

1716
/// Renders the preview view
18-
pub fn render_preview<B: Backend>(app: &mut UIState, f: &mut Frame<'_, B>) -> Result<()> {
17+
pub fn render_preview(app: &mut UIState, f: &mut Frame) -> Result<()> {
1918
match &mut app.view {
2019
UIStateView::Preview(ref mut p) => {
21-
let size = f.size();
20+
let size = f.area();
2221
let title = text::Span::from(p.title.as_str()).bold().white();
2322

2423
let layout = Layout::default()
@@ -59,7 +58,7 @@ pub fn render_preview<B: Backend>(app: &mut UIState, f: &mut Frame<'_, B>) -> Re
5958
.begin_symbol(Some(""))
6059
.end_symbol(Some(""))
6160
.thumb_style(Style::new().on_light_yellow())
62-
.track_symbol("-") // ─
61+
.track_symbol(Some("-")) // ─
6362
.thumb_symbol("░"); //
6463

6564
f.render_widget(content, layout[1]);

0 commit comments

Comments
 (0)