chores: ratatui span -> lines

This commit is contained in:
Jack Wills
2023-06-03 23:41:16 +00:00
parent 4da1fb599d
commit 0d37ac5501
2 changed files with 25 additions and 25 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ pub mod log_sanitizer {
text::{Span, Line},
};
/// Attempt to colorize the given string to tui-rs standards
/// Attempt to colorize the given string to ratatui standards
pub fn colorize_logs<'a>(input: &str) -> Vec<Line<'a>> {
vec![Line::from(
categorise_text(input)
@@ -39,7 +39,7 @@ pub mod log_sanitizer {
)]
}
/// Remove all ansi formatting from a given string and create tui-rs spans
/// Remove all ansi formatting from a given string and create ratatui Lines
pub fn remove_ansi<'a>(input: &str) -> Vec<Line<'a>> {
raw(&categorise_text(input)
.into_iter()
@@ -47,7 +47,7 @@ pub mod log_sanitizer {
.collect::<String>())
}
/// create tui-rs spans that exactly match the given strings
/// create ratatui Lines that exactly match the given strings
pub fn raw<'a>(input: &str) -> Vec<Line<'a>> {
vec![Line::from(Span::raw(input.to_owned()))]
}
+22 -22
View File
@@ -489,7 +489,7 @@ pub fn heading_bar<B: Backend>(
/// Help popup box needs these three pieces of information
struct HelpInfo {
spans: Vec<Line<'static>>,
lines: Vec<Line<'static>>,
width: usize,
height: usize,
}
@@ -527,15 +527,15 @@ impl HelpInfo {
/// Generate the `oxker` name span + metadata
fn gen_name() -> Self {
let mut spans = NAME_TEXT
let mut lines = NAME_TEXT
.lines()
.map(|i| Line::from(Self::white_span(i)))
.collect::<Vec<_>>();
spans.insert(0, Self::empty_span());
let width = Self::calc_width(&spans);
let height = spans.len();
lines.insert(0, Self::empty_span());
let width = Self::calc_width(&lines);
let height = lines.len();
Self {
spans,
lines,
width,
height,
}
@@ -543,15 +543,15 @@ impl HelpInfo {
/// Generate the description span + metadata
fn gen_description() -> Self {
let spans = [
let lines = [
Self::empty_span(),
Line::from(Self::white_span(DESCRIPTION)),
Self::empty_span(),
];
let width = Self::calc_width(&spans);
let height = spans.len();
let width = Self::calc_width(&lines);
let height = lines.len();
Self {
spans: spans.to_vec(),
lines: lines.to_vec(),
width,
height,
}
@@ -564,7 +564,7 @@ impl HelpInfo {
let or = || button_desc("or");
let space = || button_desc(" ");
let spans = [
let lines = [
Line::from(vec![
space(),
button_item("tab"),
@@ -613,10 +613,10 @@ impl HelpInfo {
]),
];
let height = spans.len();
let width = Self::calc_width(&spans);
let height = lines.len();
let width = Self::calc_width(&lines);
Self {
spans: spans.to_vec(),
lines: lines.to_vec(),
width,
height,
}
@@ -624,7 +624,7 @@ impl HelpInfo {
/// Generate the final lines, GitHub link etc, + metadata
fn gen_final() -> Self {
let spans = [
let lines = [
Self::empty_span(),
Line::from(vec![Self::black_span(
"currently an early work in progress, all and any input appreciated",
@@ -636,10 +636,10 @@ impl HelpInfo {
.add_modifier(Modifier::UNDERLINED),
)]),
];
let height = spans.len();
let width = Self::calc_width(&spans);
let height = lines.len();
let width = Self::calc_width(&lines);
Self {
spans: spans.to_vec(),
lines: lines.to_vec(),
width,
height,
}
@@ -689,22 +689,22 @@ pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
)
.split(area);
let name_paragraph = Paragraph::new(name_info.spans)
let name_paragraph = Paragraph::new(name_info.lines)
.style(Style::default().bg(Color::Magenta).fg(Color::White))
.block(Block::default())
.alignment(Alignment::Center);
let description_paragraph = Paragraph::new(description_info.spans)
let description_paragraph = Paragraph::new(description_info.lines)
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
.block(Block::default())
.alignment(Alignment::Center);
let help_paragraph = Paragraph::new(button_info.spans)
let help_paragraph = Paragraph::new(button_info.lines)
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
.block(Block::default())
.alignment(Alignment::Left);
let final_paragraph = Paragraph::new(final_info.spans)
let final_paragraph = Paragraph::new(final_info.lines)
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
.block(Block::default())
.alignment(Alignment::Center);