deps: bump ratatui to 0.21.0 (#1178)
This commit is contained in:
parent
74953455dc
commit
4e99f31ad0
|
@ -906,9 +906,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.20.1"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829"
|
||||
checksum = "ce841e0486e7c2412c3740168ede33adeba8e154a15107b879d8162d77c7174e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
|
|
|
@ -101,7 +101,7 @@ sysinfo = "=0.29.0"
|
|||
thiserror = "1.0.40"
|
||||
time = { version = "0.3.21", features = ["formatting", "macros"] }
|
||||
toml_edit = { version = "0.19.10", features = ["serde"] }
|
||||
tui = { version = "0.20.1", package = "ratatui" }
|
||||
tui = { version = "0.21.0", package = "ratatui" }
|
||||
typed-builder = "0.14.0"
|
||||
unicode-segmentation = "1.10.1"
|
||||
unicode-width = "0.1.10"
|
||||
|
|
|
@ -5,7 +5,7 @@ use itertools::izip;
|
|||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::Paragraph,
|
||||
Frame, Terminal,
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ pub struct Painter {
|
|||
pub colours: CanvasStyling,
|
||||
height: u16,
|
||||
width: u16,
|
||||
styled_help_text: Vec<Spans<'static>>,
|
||||
styled_help_text: Vec<Line<'static>>,
|
||||
is_mac_os: bool, // TODO: This feels out of place...
|
||||
|
||||
// TODO: Redo this entire thing.
|
||||
|
@ -212,7 +212,7 @@ impl Painter {
|
|||
}
|
||||
});
|
||||
|
||||
self.styled_help_text = styled_help_spans.into_iter().map(Spans::from).collect();
|
||||
self.styled_help_text = styled_help_spans.into_iter().map(Line::from).collect();
|
||||
}
|
||||
|
||||
fn draw_frozen_indicator<B: Backend>(&self, f: &mut Frame<'_, B>, draw_loc: Rect) {
|
||||
|
|
|
@ -5,7 +5,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
terminal::Frame,
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
widgets::{Block, Borders, Paragraph, Wrap},
|
||||
};
|
||||
|
||||
|
@ -22,15 +22,15 @@ impl Painter {
|
|||
pub fn get_dd_spans(&self, app_state: &App) -> Option<Text<'_>> {
|
||||
if let Some(dd_err) = &app_state.dd_err {
|
||||
return Some(Text::from(vec![
|
||||
Spans::default(),
|
||||
Spans::from("Failed to kill process."),
|
||||
Spans::from(dd_err.clone()),
|
||||
Spans::from("Please press ENTER or ESC to close this dialog."),
|
||||
Line::default(),
|
||||
Line::from("Failed to kill process."),
|
||||
Line::from(dd_err.clone()),
|
||||
Line::from("Please press ENTER or ESC to close this dialog."),
|
||||
]));
|
||||
} else if let Some(to_kill_processes) = app_state.get_to_delete_processes() {
|
||||
if let Some(first_pid) = to_kill_processes.1.first() {
|
||||
return Some(Text::from(vec![
|
||||
Spans::from(""),
|
||||
Line::from(""),
|
||||
if app_state
|
||||
.states
|
||||
.proc_state
|
||||
|
@ -40,19 +40,19 @@ impl Painter {
|
|||
.unwrap_or(false)
|
||||
{
|
||||
if to_kill_processes.1.len() != 1 {
|
||||
Spans::from(format!(
|
||||
Line::from(format!(
|
||||
"Kill {} processes with the name \"{}\"? Press ENTER to confirm.",
|
||||
to_kill_processes.1.len(),
|
||||
to_kill_processes.0
|
||||
))
|
||||
} else {
|
||||
Spans::from(format!(
|
||||
Line::from(format!(
|
||||
"Kill 1 process with the name \"{}\"? Press ENTER to confirm.",
|
||||
to_kill_processes.0
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Spans::from(format!(
|
||||
Line::from(format!(
|
||||
"Kill process \"{}\" with PID {}? Press ENTER to confirm.",
|
||||
to_kill_processes.0, first_pid
|
||||
))
|
||||
|
@ -358,7 +358,7 @@ impl Painter {
|
|||
) -> bool {
|
||||
if let Some(dd_text) = dd_text {
|
||||
let dd_title = if app_state.dd_err.is_some() {
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(" Error ", self.colours.widget_title_style),
|
||||
Span::styled(
|
||||
format!(
|
||||
|
@ -372,7 +372,7 @@ impl Painter {
|
|||
),
|
||||
])
|
||||
} else {
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(" Confirm Kill Process ", self.colours.widget_title_style),
|
||||
Span::styled(
|
||||
format!(
|
||||
|
|
|
@ -4,8 +4,8 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
terminal::Frame,
|
||||
text::Line,
|
||||
text::Span,
|
||||
text::Spans,
|
||||
widgets::{Block, Borders, Paragraph, Wrap},
|
||||
};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
@ -19,7 +19,7 @@ impl Painter {
|
|||
pub fn draw_help_dialog<B: Backend>(
|
||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect,
|
||||
) {
|
||||
let help_title = Spans::from(vec![
|
||||
let help_title = Line::from(vec![
|
||||
Span::styled(" Help ", self.colours.widget_title_style),
|
||||
Span::styled(
|
||||
format!(
|
||||
|
|
|
@ -2,8 +2,8 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
terminal::Frame,
|
||||
text::Line,
|
||||
text::Span,
|
||||
text::Spans,
|
||||
widgets::{Block, Paragraph},
|
||||
};
|
||||
|
||||
|
@ -93,16 +93,16 @@ impl Painter {
|
|||
usize::from(draw_loc.width).saturating_sub(6 + left_name.len() + right_name.len());
|
||||
|
||||
let left_arrow_text = vec![
|
||||
Spans::default(),
|
||||
Spans::from(Span::styled(
|
||||
Line::default(),
|
||||
Line::from(Span::styled(
|
||||
format!("◄ {}", left_name),
|
||||
self.colours.text_style,
|
||||
)),
|
||||
];
|
||||
|
||||
let right_arrow_text = vec![
|
||||
Spans::default(),
|
||||
Spans::from(Span::styled(
|
||||
Line::default(),
|
||||
Line::from(Span::styled(
|
||||
format!("{} ►", right_name),
|
||||
self.colours.text_style,
|
||||
)),
|
||||
|
|
|
@ -2,7 +2,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
terminal::Frame,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Cell, Paragraph, Row, Table, Tabs},
|
||||
};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
@ -40,7 +40,7 @@ impl Painter {
|
|||
|
||||
let title = if app_state.is_expanded {
|
||||
const TITLE_BASE: &str = " Battery ── Esc to go back ";
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(" Battery ", self.colours.widget_title_style),
|
||||
Span::styled(
|
||||
format!(
|
||||
|
@ -53,7 +53,7 @@ impl Painter {
|
|||
),
|
||||
])
|
||||
} else {
|
||||
Spans::from(Span::styled(" Battery ", self.colours.widget_title_style))
|
||||
Line::from(Span::styled(" Battery ", self.colours.widget_title_style))
|
||||
};
|
||||
|
||||
let battery_block = if draw_border {
|
||||
|
@ -89,7 +89,7 @@ impl Painter {
|
|||
Tabs::new(
|
||||
battery_names
|
||||
.iter()
|
||||
.map(|name| Spans::from((*name).clone()))
|
||||
.map(|name| Line::from((*name).clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.block(Block::default())
|
||||
|
@ -227,9 +227,9 @@ impl Painter {
|
|||
margined_draw_loc,
|
||||
);
|
||||
} else {
|
||||
let mut contents = vec![Spans::default(); table_gap.into()];
|
||||
let mut contents = vec![Line::default(); table_gap.into()];
|
||||
|
||||
contents.push(Spans::from(Span::styled(
|
||||
contents.push(Line::from(Span::styled(
|
||||
"No data found for this battery",
|
||||
self.colours.text_style,
|
||||
)));
|
||||
|
|
|
@ -2,7 +2,7 @@ use tui::{
|
|||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
terminal::Frame,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Paragraph},
|
||||
};
|
||||
|
||||
|
@ -44,13 +44,13 @@ impl Painter {
|
|||
let total_tx_label = format!("Total TX: {}", &app_state.converted_data.total_tx_display);
|
||||
|
||||
let net_text = vec![
|
||||
Spans::from(Span::styled(rx_label, self.colours.rx_style)),
|
||||
Spans::from(Span::styled(tx_label, self.colours.tx_style)),
|
||||
Line::from(Span::styled(rx_label, self.colours.rx_style)),
|
||||
Line::from(Span::styled(tx_label, self.colours.tx_style)),
|
||||
];
|
||||
|
||||
let total_net_text = vec![
|
||||
Spans::from(Span::styled(total_rx_label, self.colours.total_rx_style)),
|
||||
Spans::from(Span::styled(total_tx_label, self.colours.total_tx_style)),
|
||||
Line::from(Span::styled(total_rx_label, self.colours.total_rx_style)),
|
||||
Line::from(Span::styled(total_tx_label, self.colours.total_tx_style)),
|
||||
];
|
||||
|
||||
f.render_widget(Paragraph::new(net_text).block(Block::default()), net_loc[0]);
|
||||
|
|
|
@ -3,7 +3,7 @@ use tui::{
|
|||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::Style,
|
||||
terminal::Frame,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
@ -185,7 +185,7 @@ impl Painter {
|
|||
self.colours.text_style,
|
||||
);
|
||||
|
||||
let mut search_text = vec![Spans::from({
|
||||
let mut search_text = vec![Line::from({
|
||||
let mut search_vec = vec![Span::styled(
|
||||
SEARCH_TITLE,
|
||||
if is_on_widget {
|
||||
|
@ -225,7 +225,7 @@ impl Painter {
|
|||
} else {
|
||||
("Case(Alt+C)", "Whole(Alt+W)", "Regex(Alt+R)")
|
||||
};
|
||||
let option_text = Spans::from(vec![
|
||||
let option_text = Line::from(vec![
|
||||
Span::styled(case, case_style),
|
||||
Span::raw(" "),
|
||||
Span::styled(whole, whole_word_style),
|
||||
|
@ -233,7 +233,7 @@ impl Painter {
|
|||
Span::styled(regex, regex_style),
|
||||
]);
|
||||
|
||||
search_text.push(Spans::from(Span::styled(
|
||||
search_text.push(Line::from(Span::styled(
|
||||
if let Some(err) = &proc_widget_state.proc_search.search_state.error_message {
|
||||
err.as_str()
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ use concat_string::concat_string;
|
|||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
widgets::{Block, Borders, Row, Table},
|
||||
Frame,
|
||||
};
|
||||
|
@ -98,7 +98,7 @@ where
|
|||
/// Generates a title, given the available space.
|
||||
pub fn generate_title<'a>(
|
||||
&self, draw_info: &'a DrawInfo, total_items: usize,
|
||||
) -> Option<Spans<'a>> {
|
||||
) -> Option<Line<'a>> {
|
||||
self.props.title.as_ref().map(|title| {
|
||||
let current_index = self.state.current_index.saturating_add(1);
|
||||
let draw_loc = draw_info.loc;
|
||||
|
@ -129,12 +129,12 @@ where
|
|||
UnicodeSegmentation::graphemes(title_base.as_str(), true).count() + 2,
|
||||
));
|
||||
let esc = concat_string!("─", lines, "─ Esc to go back ");
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(title, title_style),
|
||||
Span::styled(esc, border_style),
|
||||
])
|
||||
} else {
|
||||
Spans::from(Span::styled(title, title_style))
|
||||
Line::from(Span::styled(title, title_style))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use tui::{
|
|||
layout::{Constraint, Rect},
|
||||
style::Style,
|
||||
symbols::Marker,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, GraphType},
|
||||
Frame,
|
||||
};
|
||||
|
@ -96,10 +96,10 @@ impl<'a> TimeGraph<'a> {
|
|||
}
|
||||
|
||||
/// Generates a title for the [`TimeGraph`] widget, given the available space.
|
||||
fn generate_title(&self, draw_loc: Rect) -> Spans<'_> {
|
||||
fn generate_title(&self, draw_loc: Rect) -> Line<'_> {
|
||||
if self.is_expanded {
|
||||
let title_base = concat_string!(self.title, "── Esc to go back ");
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(self.title.as_ref(), self.title_style),
|
||||
Span::styled(
|
||||
concat_string!(
|
||||
|
@ -113,7 +113,7 @@ impl<'a> TimeGraph<'a> {
|
|||
),
|
||||
])
|
||||
} else {
|
||||
Spans::from(Span::styled(self.title.as_ref(), self.title_style))
|
||||
Line::from(Span::styled(self.title.as_ref(), self.title_style))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ mod test {
|
|||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
symbols::Marker,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
};
|
||||
|
||||
use super::TimeGraph;
|
||||
|
@ -253,14 +253,14 @@ mod test {
|
|||
let title = time_graph.generate_title(draw_loc);
|
||||
assert_eq!(
|
||||
title,
|
||||
Spans::from(Span::styled(" Network ", Style::default().fg(Color::Cyan)))
|
||||
Line::from(Span::styled(" Network ", Style::default().fg(Color::Cyan)))
|
||||
);
|
||||
|
||||
time_graph.is_expanded = true;
|
||||
let title = time_graph.generate_title(draw_loc);
|
||||
assert_eq!(
|
||||
title,
|
||||
Spans::from(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(" Network ", Style::default().fg(Color::Cyan)),
|
||||
Span::styled("───── Esc to go back ", Style::default().fg(Color::Blue))
|
||||
])
|
||||
|
|
|
@ -2,7 +2,7 @@ use tui::{
|
|||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::Style,
|
||||
text::Spans,
|
||||
text::Line,
|
||||
widgets::{Block, Widget},
|
||||
};
|
||||
|
||||
|
@ -25,8 +25,8 @@ impl Default for LabelLimit {
|
|||
pub struct PipeGauge<'a> {
|
||||
block: Option<Block<'a>>,
|
||||
ratio: f64,
|
||||
start_label: Option<Spans<'a>>,
|
||||
inner_label: Option<Spans<'a>>,
|
||||
start_label: Option<Line<'a>>,
|
||||
inner_label: Option<Line<'a>>,
|
||||
label_style: Style,
|
||||
gauge_style: Style,
|
||||
hide_parts: LabelLimit,
|
||||
|
@ -60,7 +60,7 @@ impl<'a> PipeGauge<'a> {
|
|||
/// The label displayed before the bar.
|
||||
pub fn start_label<T>(mut self, start_label: T) -> Self
|
||||
where
|
||||
T: Into<Spans<'a>>,
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
self.start_label = Some(start_label.into());
|
||||
self
|
||||
|
@ -69,7 +69,7 @@ impl<'a> PipeGauge<'a> {
|
|||
/// The label displayed inside the bar.
|
||||
pub fn inner_label<T>(mut self, inner_label: T) -> Self
|
||||
where
|
||||
T: Into<Spans<'a>>,
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
self.inner_label = Some(inner_label.into());
|
||||
self
|
||||
|
@ -125,8 +125,8 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
|
||||
match self.hide_parts {
|
||||
LabelLimit::StartLabel => {
|
||||
let inner_label = self.inner_label.unwrap_or_else(|| Spans::from(""));
|
||||
let _ = buf.set_spans(
|
||||
let inner_label = self.inner_label.unwrap_or_else(|| Line::from(""));
|
||||
let _ = buf.set_line(
|
||||
gauge_area.left(),
|
||||
gauge_area.top(),
|
||||
&inner_label,
|
||||
|
@ -139,8 +139,8 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
LabelLimit::Auto(_)
|
||||
if gauge_area.width < (inner_label_width + start_label_width + 1) as u16 =>
|
||||
{
|
||||
let inner_label = self.inner_label.unwrap_or_else(|| Spans::from(""));
|
||||
let _ = buf.set_spans(
|
||||
let inner_label = self.inner_label.unwrap_or_else(|| Line::from(""));
|
||||
let _ = buf.set_line(
|
||||
gauge_area.left(),
|
||||
gauge_area.top(),
|
||||
&inner_label,
|
||||
|
@ -151,8 +151,8 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
return;
|
||||
}
|
||||
_ => {
|
||||
let start_label = self.start_label.unwrap_or_else(|| Spans::from(""));
|
||||
buf.set_spans(
|
||||
let start_label = self.start_label.unwrap_or_else(|| Line::from(""));
|
||||
buf.set_line(
|
||||
gauge_area.left(),
|
||||
gauge_area.top(),
|
||||
&start_label,
|
||||
|
@ -162,10 +162,10 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
let end_label = self.inner_label.unwrap_or_else(|| Spans::from(""));
|
||||
let end_label = self.inner_label.unwrap_or_else(|| Line::from(""));
|
||||
match self.hide_parts {
|
||||
LabelLimit::Bars => {
|
||||
let _ = buf.set_spans(
|
||||
let _ = buf.set_line(
|
||||
gauge_area
|
||||
.right()
|
||||
.saturating_sub(end_label.width() as u16 + 1),
|
||||
|
@ -177,7 +177,7 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
LabelLimit::Auto(width_limit)
|
||||
if gauge_area.right().saturating_sub(col) < width_limit =>
|
||||
{
|
||||
let _ = buf.set_spans(
|
||||
let _ = buf.set_line(
|
||||
gauge_area
|
||||
.right()
|
||||
.saturating_sub(end_label.width() as u16 + 1),
|
||||
|
@ -187,15 +187,15 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
);
|
||||
}
|
||||
LabelLimit::Auto(_) | LabelLimit::None => {
|
||||
let (start, _) = buf.set_spans(col, row, &Spans::from("["), gauge_area.width);
|
||||
let (start, _) = buf.set_line(col, row, &Line::from("["), gauge_area.width);
|
||||
if start >= gauge_area.right() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (end, _) = buf.set_spans(
|
||||
let (end, _) = buf.set_line(
|
||||
(gauge_area.x + gauge_area.width).saturating_sub(1),
|
||||
row,
|
||||
&Spans::from("]"),
|
||||
&Line::from("]"),
|
||||
gauge_area.width,
|
||||
);
|
||||
|
||||
|
@ -214,7 +214,7 @@ impl<'a> Widget for PipeGauge<'a> {
|
|||
let gauge_end = gauge_area
|
||||
.right()
|
||||
.saturating_sub(end_label.width() as u16 + 1);
|
||||
buf.set_spans(gauge_end, row, &end_label, end_label.width() as u16);
|
||||
buf.set_line(gauge_end, row, &end_label, end_label.width() as u16);
|
||||
}
|
||||
}
|
||||
LabelLimit::StartLabel => unreachable!(),
|
||||
|
|
|
@ -8,9 +8,9 @@ use tui::{
|
|||
layout::{Constraint, Rect},
|
||||
style::{Color, Style},
|
||||
symbols::{self, Marker},
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{
|
||||
canvas::{Line, Points},
|
||||
canvas::{Line as CanvasLine, Points},
|
||||
Block, Borders, GraphType, Widget,
|
||||
},
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ pub type Point = (f64, f64);
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct Axis<'a> {
|
||||
/// Title displayed next to axis end
|
||||
pub title: Option<Spans<'a>>,
|
||||
pub title: Option<Line<'a>>,
|
||||
/// Bounds for the axis (all data points outside these limits will not be represented)
|
||||
pub bounds: [f64; 2],
|
||||
/// A list of labels to put to the left or below the axis
|
||||
|
@ -49,7 +49,7 @@ impl<'a> Default for Axis<'a> {
|
|||
impl<'a> Axis<'a> {
|
||||
pub fn title<T>(mut self, title: T) -> Axis<'a>
|
||||
where
|
||||
T: Into<Spans<'a>>,
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
self.title = Some(title.into());
|
||||
self
|
||||
|
@ -460,7 +460,7 @@ impl<'a> Widget for TimeChart<'a> {
|
|||
);
|
||||
|
||||
if let GraphType::Line = dataset.graph_type {
|
||||
ctx.draw(&Line {
|
||||
ctx.draw(&CanvasLine {
|
||||
x1: interpolated_point.0,
|
||||
y1: interpolated_point.1,
|
||||
x2: newer_point.0,
|
||||
|
@ -478,7 +478,7 @@ impl<'a> Widget for TimeChart<'a> {
|
|||
|
||||
if let GraphType::Line = dataset.graph_type {
|
||||
for data in data_slice.windows(2) {
|
||||
ctx.draw(&Line {
|
||||
ctx.draw(&CanvasLine {
|
||||
x1: data[0].0,
|
||||
y1: data[0].1,
|
||||
x2: data[1].0,
|
||||
|
@ -504,7 +504,7 @@ impl<'a> Widget for TimeChart<'a> {
|
|||
);
|
||||
|
||||
if let GraphType::Line = dataset.graph_type {
|
||||
ctx.draw(&Line {
|
||||
ctx.draw(&CanvasLine {
|
||||
x1: older_point.0,
|
||||
y1: older_point.1,
|
||||
x2: interpolated_point.0,
|
||||
|
@ -551,7 +551,7 @@ impl<'a> Widget for TimeChart<'a> {
|
|||
},
|
||||
original_style,
|
||||
);
|
||||
buf.set_spans(x, y, &title, width);
|
||||
buf.set_line(x, y, &title, width);
|
||||
}
|
||||
|
||||
if let Some((x, y)) = layout.title_y {
|
||||
|
@ -566,7 +566,7 @@ impl<'a> Widget for TimeChart<'a> {
|
|||
},
|
||||
original_style,
|
||||
);
|
||||
buf.set_spans(x, y, &title, width);
|
||||
buf.set_line(x, y, &title, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ use tui::{
|
|||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
symbols,
|
||||
text::Spans,
|
||||
text::Line,
|
||||
widgets::{
|
||||
canvas::{Line, Points},
|
||||
canvas::{Line as CanvasLine, Points},
|
||||
Block, Widget,
|
||||
},
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ pub trait Shape {
|
|||
fn draw(&self, painter: &mut Painter<'_, '_>);
|
||||
}
|
||||
|
||||
impl Shape for Line {
|
||||
impl Shape for CanvasLine {
|
||||
fn draw(&self, painter: &mut Painter<'_, '_>) {
|
||||
let (x1, y1) = match painter.get_point(self.x1, self.y1) {
|
||||
Some(c) => c,
|
||||
|
@ -122,7 +122,7 @@ impl Shape for Points<'_> {
|
|||
pub struct Label<'a> {
|
||||
x: f64,
|
||||
y: f64,
|
||||
spans: Spans<'a>,
|
||||
spans: Line<'a>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -365,6 +365,7 @@ impl<'a> Context<'a> {
|
|||
symbols::Marker::Dot => Box::new(CharGrid::new(width, height, '•')),
|
||||
symbols::Marker::Block => Box::new(CharGrid::new(width, height, '▄')),
|
||||
symbols::Marker::Braille => Box::new(BrailleGrid::new(width, height)),
|
||||
symbols::Marker::Bar => Box::new(CharGrid::new(width, height, '▄')),
|
||||
};
|
||||
Context {
|
||||
x_bounds,
|
||||
|
@ -542,7 +543,7 @@ where
|
|||
{
|
||||
let x = ((label.x - left) * resolution.0 / width) as u16 + canvas_area.left();
|
||||
let y = ((top - label.y) * resolution.1 / height) as u16 + canvas_area.top();
|
||||
buf.set_spans(x, y, &label.spans, canvas_area.right() - x);
|
||||
buf.set_line(x, y, &label.spans, canvas_area.right() - x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::cmp::Ordering;
|
||||
|
||||
use tui::text::{Span, Spans, Text};
|
||||
use tui::text::{Line, Span, Text};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
|
@ -99,7 +99,7 @@ pub fn get_decimal_prefix(quantity: u64, unit: &str) -> (f64, String) {
|
|||
/// Truncates text if it is too long, and adds an ellipsis at the end if needed.
|
||||
pub fn truncate_to_text<'a, U: Into<usize>>(content: &str, width: U) -> Text<'a> {
|
||||
Text {
|
||||
lines: vec![Spans(vec![Span::raw(truncate_str(content, width))])],
|
||||
lines: vec![Line::from(vec![Span::raw(truncate_str(content, width))])],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue