summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-11-01 12:00:58 +0800
committerGitHub <noreply@github.com>2023-11-01 12:00:58 +0800
commit022eade156d0ee815a1f2200fb7ff3fac71087a8 (patch)
treec5ccc68293e5a3f8f755e04e39d5825eb801ff49 /src
parent75a7b38e2ced46aca4b18379f07d77966dae5e9c (diff)
Bump ratatui to 0.24.0 (#327)
Diffstat (limited to 'src')
-rw-r--r--src/display/components/header_details.rs19
-rw-r--r--src/display/components/help_text.rs3
-rw-r--r--src/display/components/layout.rs3
-rw-r--r--src/display/components/table.rs3
-rw-r--r--src/display/raw_terminal_backend.rs13
-rw-r--r--src/tests/fakes/fake_output.rs16
6 files changed, 33 insertions, 24 deletions
diff --git a/src/display/components/header_details.rs b/src/display/components/header_details.rs
index 3f68984..373f09e 100644
--- a/src/display/components/header_details.rs
+++ b/src/display/components/header_details.rs
@@ -1,7 +1,6 @@
use std::time::{Duration, Instant};
use ratatui::{
- backend::Backend,
layout::{Alignment, Rect},
style::{Color, Modifier, Style},
terminal::Frame,
@@ -42,7 +41,7 @@ pub struct HeaderDetails<'a> {
}
impl<'a> HeaderDetails<'a> {
- pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
+ pub fn render(&self, frame: &mut Frame, rect: Rect) {
let bandwidth = self.bandwidth_string();
let color = if self.paused {
Color::Yellow
@@ -63,13 +62,7 @@ impl<'a> HeaderDetails<'a> {
self.render_bandwidth(frame, rect, &bandwidth, color);
}
- fn render_bandwidth(
- &self,
- frame: &mut Frame<impl Backend>,
- rect: Rect,
- bandwidth: &str,
- color: Color,
- ) {
+ fn render_bandwidth(&self, frame: &mut Frame, rect: Rect, bandwidth: &str, color: Color) {
let bandwidth_text = Span::styled(
bandwidth,
Style::default().fg(color).add_modifier(Modifier::BOLD),
@@ -95,13 +88,7 @@ impl<'a> HeaderDetails<'a> {
format!(" Total {t} (Up / Down): {up} / {down}{paused}")
}
- fn render_elapsed_time(
- &self,
- frame: &mut Frame<impl Backend>,
- rect: Rect,
- elapsed_time: &str,
- color: Color,
- ) {
+ fn render_elapsed_time(&self, frame: &mut Frame, rect: Rect, elapsed_time: &str, color: Color) {
let elapsed_time_text = Span::styled(
elapsed_time,
Style::default().fg(color).add_modifier(Modifier::BOLD),
diff --git a/src/display/components/help_text.rs b/src/display/components/help_text.rs
index de7aa37..a186249 100644
--- a/src/display/components/help_text.rs
+++ b/src/display/components/help_text.rs
@@ -1,5 +1,4 @@
use ratatui::{
- backend::Backend,
layout::{Alignment, Rect},
style::{Modifier, Style},
terminal::Frame,
@@ -22,7 +21,7 @@ const TEXT_WHEN_DNS_SHOWN: &str = " (DNS queries shown).";
const TEXT_TAB_TIP: &str = " Use <TAB> to rearrange tables.";
impl HelpText {
- pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
+ pub fn render(&self, frame: &mut Frame, rect: Rect) {
let pause_content = if self.paused {
TEXT_WHEN_PAUSED
} else {
diff --git a/src/display/components/layout.rs b/src/display/components/layout.rs
index 60b7f23..90cca0b 100644
--- a/src/display/components/layout.rs
+++ b/src/display/components/layout.rs
@@ -1,5 +1,4 @@
use ratatui::{
- backend::Backend,
layout::{Constraint, Direction, Rect},
terminal::Frame,
};
@@ -100,7 +99,7 @@ impl<'a> Layout<'a> {
}
}
- pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect, ui_offset: usize) {
+ pub fn render(&self, frame: &mut Frame, rect: Rect, ui_offset: usize) {
let (top, app, bottom) = top_app_and_bottom_split(rect);
let layout_slots = self.build_layout(app);
for i in 0..layout_slots.len() {
diff --git a/src/display/components/table.rs b/src/display/components/table.rs
index ed97349..a80142c 100644
--- a/src/display/components/table.rs
+++ b/src/display/components/table.rs
@@ -3,7 +3,6 @@ use std::{collections::HashMap, fmt, iter::FromIterator, net::IpAddr, ops::Index
use derivative::Derivative;
use itertools::Itertools;
use ratatui::{
- backend::Backend,
layout::{Constraint, Rect},
style::{Color, Style},
terminal::Frame,
@@ -326,7 +325,7 @@ impl Table {
}
/// See [`Table`] for layout rules.
- pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
+ pub fn render(&self, frame: &mut Frame, rect: Rect) {
let (computed_layout, spacer_width) = {
// pick the largest possible layout, constrained by the available width
let &(_, layout) = self
diff --git a/src/display/raw_terminal_backend.rs b/src/display/raw_terminal_backend.rs
index fc08abc..4be38bb 100644
--- a/src/display/raw_terminal_backend.rs
+++ b/src/display/raw_terminal_backend.rs
@@ -10,7 +10,11 @@
use std::io;
-use ratatui::{backend::Backend, buffer::Cell, layout::Rect};
+use ratatui::{
+ backend::{Backend, WindowSize},
+ buffer::Cell,
+ layout::{Rect, Size},
+};
pub struct RawTerminalBackend {}
@@ -46,6 +50,13 @@ impl Backend for RawTerminalBackend {
Ok(Rect::new(0, 0, 0, 0))
}
+ fn window_size(&mut self) -> io::Result<WindowSize> {
+ Ok(WindowSize {
+ columns_rows: Size::default(),
+ pixels: Size::default(),
+ })
+ }
+
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
diff --git a/src/tests/fakes/fake_output.rs b/src/tests/fakes/fake_output.rs
index ac6f3cd..7741cc2 100644
--- a/src/tests/fakes/fake_output.rs
+++ b/src/tests/fakes/fake_output.rs
@@ -4,7 +4,11 @@ use std::{
sync::{Arc, Mutex},
};
-use ratatui::{backend::Backend, buffer::Cell, layout::Rect};
+use ratatui::{
+ backend::{Backend, WindowSize},
+ buffer::Cell,
+ layout::{Rect, Size},
+};
#[derive(Hash, Debug, PartialEq)]
pub enum TerminalEvent {
@@ -109,6 +113,16 @@ impl Backend for TestBackend {
Ok(Rect::new(0, 0, *terminal_width, *terminal_height))
}
+ fn window_size(&mut self) -> io::Result<WindowSize> {
+ let width = *self.terminal_width.lock().unwrap();
+ let height = *self.terminal_height.lock().unwrap();
+
+ Ok(WindowSize {
+ columns_rows: Size { width, height },
+ pixels: Size::default(),
+ })
+ }
+
fn flush(&mut self) -> io::Result<()> {
self.events.lock().unwrap().push(TerminalEvent::Flush);
Ok(())