Skip to content

Commit

Permalink
chore(ratatui): update to 'ratatui:0.21.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed Oct 17, 2023
1 parent 3be7d29 commit cfae65e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 35 deletions.
105 changes: 85 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md"]
edition = "2021"

[dependencies]
tui = { package = "ratatui", version = "0.20.1", default-features = false, features = ["termion"] }
tui = { package = "ratatui", version = "0.23.0", default-features = false, features = ["termion"] }
termion = "2.0.1"
bytesize = "1.3.0"
unicode-width = "0.1.11"
Expand Down
8 changes: 4 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use termion::event::Key;
use tui::backend::Backend;
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use tui::style::Style as TuiStyle;
use tui::text::{Span, Spans, Text};
use tui::text::{Line, Span, Text};
use tui::widgets::{
Block as TuiBlock, Borders, Clear, List, ListItem, Paragraph, Row, Table, Wrap,
};
Expand Down Expand Up @@ -256,12 +256,12 @@ impl App {
let mut help_text = Vec::new();
let mut help_text_raw = Vec::new();
for (key, desc) in &key_bindings {
help_text.push(Spans::from(Span::styled(
help_text.push(Line::from(Span::styled(
format!("{}:", &key),
self.style.colored,
)));
help_text_raw.push(format!("{key}:"));
help_text.push(Spans::from(Span::styled(
help_text.push(Line::from(Span::styled(
format!("{}{}", self.style.unicode.get(Symbol::Blank), &desc),
self.style.default,
)));
Expand Down Expand Up @@ -306,7 +306,7 @@ impl App {
);
let mut dependent_modules = Vec::new();
for module in &dependent_modules_list {
dependent_modules.push(Spans::from(vec![
dependent_modules.push(Line::from(vec![
Span::styled("-", self.style.colored),
Span::styled(format!(" {module}"), self.style.default),
]));
Expand Down
14 changes: 7 additions & 7 deletions src/kernel/lkm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::util;
use bytesize::ByteSize;
use clap::ArgMatches;
use std::slice::Iter;
use tui::text::{Span, Spans, Text};
use tui::text::{Line, Span, Text};

/* Type of the sorting of module list */
#[derive(Clone, Copy, Debug)]
Expand Down Expand Up @@ -168,15 +168,15 @@ impl KernelModules<'_> {
self.current_info.set(
Text::from({
let mut spans = vec![
Spans::from(Span::styled(
Line::from(Span::styled(
"Execute the following command? [y/N]:",
self.style.colored,
)),
Spans::from(Span::styled(
Line::from(Span::styled(
self.get_current_command().cmd,
self.style.default,
)),
Spans::default(),
Line::default(),
];
spans.append(
&mut Text::styled(
Expand Down Expand Up @@ -207,15 +207,15 @@ impl KernelModules<'_> {
self.current_info.set(
Text::from({
let mut spans = vec![
Spans::from(Span::styled(
Line::from(Span::styled(
"Failed to execute command:",
self.style.colored,
)),
Spans::from(Span::styled(
Line::from(Span::styled(
format!("'{}'", self.get_current_command().cmd),
self.style.default,
)),
Spans::default(),
Line::default(),
];
spans.append(
&mut Text::styled(e.to_string(), self.style.default)
Expand Down
6 changes: 3 additions & 3 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::ArgMatches;
use colorsys::Rgb;
use std::collections::HashMap;
use tui::style::{Color, Modifier, Style as TuiStyle};
use tui::text::{Span, Spans, Text};
use tui::text::{Line, Span, Text};

/* Unicode symbol */
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
Expand Down Expand Up @@ -202,14 +202,14 @@ impl<'a> StyledText<'a> {
for line in text.lines() {
let data = line.split(delimiter).collect::<Vec<&str>>();
if data.len() > 1 && data[0].trim().len() > 2 {
self.styled_text.lines.push(Spans::from(vec![
self.styled_text.lines.push(Line::from(vec![
Span::styled(format!("{}{}", data[0], delimiter), style.colored),
Span::styled(data[1..data.len()].join(delimiter), style.default),
]));
} else {
self.styled_text
.lines
.push(Spans::from(Span::styled(line, style.default)))
.push(Line::from(Span::styled(line, style.default)))
}
}
self.styled_text.clone()
Expand Down

0 comments on commit cfae65e

Please sign in to comment.