Skip to content

Commit f1e0d62

Browse files
author
fri
committed
Updated to ratatui 0.29
1 parent 1d52b59 commit f1e0d62

19 files changed

+534
-521
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include = [
2121

2222
[dependencies]
2323
termion = "4"
24-
ratatui = { version = "0.28", default-features = false, features = ["termion", "serde"] }
24+
ratatui = { version = "0.29", default-features = false, features = ["termion", "serde"] }
2525
crossbeam-channel = "0.5"
2626
signal-hook = "0.3"
2727
anyhow = "1"
@@ -31,13 +31,13 @@ clap = { version = "4", features = ["derive", "cargo"] }
3131
encoding_rs = "0.8"
3232
#syntect = { version = "5", default-features = false, features = ["default-fancy"] }
3333
syntect = "5"
34-
#bat = { version = "0.24", default-features = false, features = ["regex-fancy"] }
35-
bat = { version = "0.24", default-features = false, features = ["regex-onig"] }
34+
#bat = { version = "0.25", default-features = false, features = ["regex-fancy"] }
35+
bat = { version = "0.25", default-features = false, features = ["regex-onig"] }
3636
serde = "1"
3737
toml = "0.8"
3838
xdg = "2"
3939
libc = "0.2"
40-
unicode-width = "0.1"
40+
unicode-width = "0.2"
4141
unicode-normalization = "0.1"
4242
regex = "1"
4343
uzers = "0.12"
@@ -52,7 +52,7 @@ tempfile = "3"
5252
wait-timeout = "0.2"
5353
shlex = "1"
5454
pathdiff = "0.2"
55-
itertools = "0.13"
55+
itertools = "0.14"
5656
thousands = "0.2"
5757
rusqlite = { version = "0.32", features = ["bundled"] }
5858
rustix = { version = "0.38", features = ["fs"] }

src/button_bar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ButtonBar {
3737
}
3838

3939
impl Component for ButtonBar {
40-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
40+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
4141
if let MouseButton::Left = button {
4242
for (i, rect) in self.rects.iter().enumerate() {
4343
if rect.contains(mouse_position) {

src/dlg_error.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
use std::rc::Rc;
22

33
use crossbeam_channel::Sender;
4-
use ratatui::{
5-
prelude::*,
6-
widgets::{
7-
block::{Position, Title},
8-
*,
9-
},
10-
};
4+
use ratatui::{prelude::*, widgets::*};
115
use termion::event::*;
126

137
use unicode_width::UnicodeWidthStr;
@@ -80,7 +74,7 @@ impl Component for DlgError {
8074
key_handled
8175
}
8276

83-
fn handle_mouse(&mut self, button: MouseButton, _mouse_position: layout::Position) {
77+
fn handle_mouse(&mut self, button: MouseButton, _mouse_position: Position) {
8478
if let MouseButton::Left = button {
8579
if matches!(self.dialog_type, DialogType::Error | DialogType::Warning) {
8680
self.pubsub_tx.send(PubSub::CloseDialog).unwrap();
@@ -120,10 +114,8 @@ impl Component for DlgError {
120114
)))
121115
.block(
122116
Block::default()
123-
.title(
124-
Title::from(Span::styled(format!(" {} ", self.title), title_style))
125-
.position(Position::Top)
126-
.alignment(Alignment::Center),
117+
.title_top(
118+
Line::from(Span::styled(format!(" {} ", self.title), title_style)).centered(),
127119
)
128120
.borders(Borders::ALL)
129121
.padding(Padding::uniform(1))

src/fm/cp_mv_rm/dlg_cp_mv.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ use std::{
55
};
66

77
use crossbeam_channel::Sender;
8-
use ratatui::{
9-
prelude::*,
10-
widgets::{
11-
block::{Position, Title},
12-
*,
13-
},
14-
};
8+
use ratatui::{prelude::*, widgets::*};
159
use termion::event::*;
1610

1711
use unicode_width::UnicodeWidthStr;
@@ -168,7 +162,7 @@ impl Component for DlgCpMv {
168162
key_handled
169163
}
170164

171-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
165+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
172166
if matches!(button, MouseButton::Left | MouseButton::Right) {
173167
if self.input_rect.contains(mouse_position) {
174168
self.section_focus_position = 0;
@@ -230,13 +224,12 @@ impl Component for DlgCpMv {
230224
let title = self.operation.to_string();
231225

232226
let upper_block = Block::default()
233-
.title(
234-
Title::from(Span::styled(
227+
.title_top(
228+
Line::from(Span::styled(
235229
tilde_layout(&format!(" {} ", title), sections[0].width as usize),
236230
self.palette.dialog_title,
237231
))
238-
.position(Position::Top)
239-
.alignment(Alignment::Center),
232+
.centered(),
240233
)
241234
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
242235
.padding(Padding::horizontal(1))

src/fm/cp_mv_rm/dlg_cp_mv_progress.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ use std::{
77
};
88

99
use crossbeam_channel::{Receiver, Sender};
10-
use ratatui::{
11-
prelude::*,
12-
widgets::{
13-
block::{Position, Title},
14-
*,
15-
},
16-
};
10+
use ratatui::{prelude::*, widgets::*};
1711
use termion::event::*;
1812

1913
use thousands::Separable;
@@ -252,7 +246,7 @@ impl Component for DlgCpMvProgress {
252246
key_handled
253247
}
254248

255-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
249+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
256250
if matches!(button, MouseButton::Left | MouseButton::Right) {
257251
if self.btn_suspend_rect.contains(mouse_position) {
258252
self.focus_position = 0;
@@ -355,13 +349,12 @@ impl Component for DlgCpMvProgress {
355349
// Upper section
356350

357351
let upper_block = Block::default()
358-
.title(
359-
Title::from(Span::styled(
352+
.title_top(
353+
Line::from(Span::styled(
360354
tilde_layout(&format!(" {} ", self.operation), sections[0].width as usize),
361355
self.palette.dialog_title,
362356
))
363-
.position(Position::Top)
364-
.alignment(Alignment::Center),
357+
.centered(),
365358
)
366359
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
367360
.padding(Padding::horizontal(1))
@@ -458,17 +451,16 @@ impl Component for DlgCpMvProgress {
458451
// Middle section
459452

460453
let middle_block = Block::default()
461-
.title(
462-
Title::from(Span::raw(tilde_layout(
454+
.title_top(
455+
Line::from(Span::raw(tilde_layout(
463456
&format!(
464457
" Total: {}/{} ",
465458
human_readable_size(self.total_bytes),
466459
human_readable_size(self.total_size)
467460
),
468461
sections[0].width as usize,
469462
)))
470-
.position(Position::Top)
471-
.alignment(Alignment::Center),
463+
.centered(),
472464
)
473465
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
474466
.border_set(MIDDLE_BORDER_SET)

src/fm/cp_mv_rm/dlg_dirscan.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ use std::{
66
};
77

88
use crossbeam_channel::{Receiver, Sender};
9-
use ratatui::{
10-
prelude::*,
11-
widgets::{
12-
block::{Position, Title},
13-
*,
14-
},
15-
};
9+
use ratatui::{prelude::*, widgets::*};
1610
use termion::event::*;
1711

1812
use thousands::Separable;
@@ -203,7 +197,7 @@ impl Component for DlgDirscan {
203197
key_handled
204198
}
205199

206-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
200+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
207201
if matches!(button, MouseButton::Left | MouseButton::Right) {
208202
if self.btn_suspend_rect.contains(mouse_position) {
209203
self.focus_position = 0;
@@ -327,13 +321,12 @@ impl Component for DlgDirscan {
327321
// Upper section
328322

329323
let upper_block = Block::default()
330-
.title(
331-
Title::from(Span::styled(
324+
.title_top(
325+
Line::from(Span::styled(
332326
tilde_layout(" Directory scanning ", sections[0].width as usize),
333327
self.palette.dialog_title,
334328
))
335-
.position(Position::Top)
336-
.alignment(Alignment::Center),
329+
.centered(),
337330
)
338331
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
339332
.padding(Padding::horizontal(1))

src/fm/cp_mv_rm/dlg_pending_job.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ use std::{
55
};
66

77
use crossbeam_channel::Sender;
8-
use ratatui::{
9-
prelude::*,
10-
widgets::{
11-
block::{Position, Title},
12-
*,
13-
},
14-
};
8+
use ratatui::{prelude::*, widgets::*};
159
use termion::event::*;
1610

1711
use pathdiff::diff_paths;
@@ -186,7 +180,7 @@ impl Component for DlgPendingJob {
186180
key_handled
187181
}
188182

189-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
183+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
190184
match button {
191185
MouseButton::Left | MouseButton::Right => {
192186
if self.btn_continue_rect.contains(mouse_position) {
@@ -254,13 +248,12 @@ impl Component for DlgPendingJob {
254248
// Upper section
255249

256250
let upper_block = Block::default()
257-
.title(
258-
Title::from(Span::styled(
251+
.title_top(
252+
Line::from(Span::styled(
259253
tilde_layout(" Interrupted Job ", sections[0].width as usize),
260254
self.palette.dialog_title,
261255
))
262-
.position(Position::Top)
263-
.alignment(Alignment::Center),
256+
.centered(),
264257
)
265258
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
266259
.padding(Padding::horizontal(1))

src/fm/cp_mv_rm/dlg_question.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
use std::{cmp::max, rc::Rc};
22

33
use crossbeam_channel::Sender;
4-
use ratatui::{
5-
prelude::*,
6-
widgets::{
7-
block::{Position, Title},
8-
*,
9-
},
10-
};
4+
use ratatui::{prelude::*, widgets::*};
115
use termion::event::*;
126

137
use unicode_width::UnicodeWidthStr;
@@ -96,7 +90,7 @@ impl Component for DlgQuestion {
9690
key_handled
9791
}
9892

99-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
93+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
10094
if matches!(button, MouseButton::Left | MouseButton::Right) {
10195
if self.btn_yes_rect.contains(mouse_position) {
10296
self.focus_position = 0;
@@ -139,13 +133,12 @@ impl Component for DlgQuestion {
139133
// Upper section
140134

141135
let upper_block = Block::default()
142-
.title(
143-
Title::from(Span::styled(
136+
.title_top(
137+
Line::from(Span::styled(
144138
tilde_layout(&self.title, sections[0].width as usize),
145139
self.palette.error_title,
146140
))
147-
.position(Position::Top)
148-
.alignment(Alignment::Center),
141+
.centered(),
149142
)
150143
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
151144
.padding(Padding::horizontal(1))

src/fm/cp_mv_rm/dlg_report.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ use std::{
55
};
66

77
use crossbeam_channel::Sender;
8-
use ratatui::{
9-
prelude::*,
10-
widgets::{
11-
block::{Position, Title},
12-
*,
13-
},
14-
};
8+
use ratatui::{prelude::*, widgets::*};
159
use termion::event::*;
1610

1711
use atomicwrites::{AllowOverwrite, AtomicFile};
@@ -249,7 +243,7 @@ impl Component for DlgReport {
249243
key_handled
250244
}
251245

252-
fn handle_mouse(&mut self, button: MouseButton, mouse_position: layout::Position) {
246+
fn handle_mouse(&mut self, button: MouseButton, mouse_position: Position) {
253247
match button {
254248
MouseButton::Left | MouseButton::Right => {
255249
if self.btn_close_rect.contains(mouse_position) {
@@ -362,13 +356,12 @@ impl Component for DlgReport {
362356
// Upper section
363357

364358
let upper_block = Block::default()
365-
.title(
366-
Title::from(Span::styled(
359+
.title_top(
360+
Line::from(Span::styled(
367361
tilde_layout(" Report ", sections[0].width as usize),
368362
title_style,
369363
))
370-
.position(Position::Top)
371-
.alignment(Alignment::Center),
364+
.centered(),
372365
)
373366
.borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
374367
.padding(Padding::horizontal(1))

0 commit comments

Comments
 (0)