chores: ratatui span -> lines
This commit is contained in:
@@ -6,7 +6,7 @@ pub mod log_sanitizer {
|
|||||||
text::{Span, Line},
|
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>> {
|
pub fn colorize_logs<'a>(input: &str) -> Vec<Line<'a>> {
|
||||||
vec![Line::from(
|
vec![Line::from(
|
||||||
categorise_text(input)
|
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>> {
|
pub fn remove_ansi<'a>(input: &str) -> Vec<Line<'a>> {
|
||||||
raw(&categorise_text(input)
|
raw(&categorise_text(input)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -47,7 +47,7 @@ pub mod log_sanitizer {
|
|||||||
.collect::<String>())
|
.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>> {
|
pub fn raw<'a>(input: &str) -> Vec<Line<'a>> {
|
||||||
vec![Line::from(Span::raw(input.to_owned()))]
|
vec![Line::from(Span::raw(input.to_owned()))]
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-22
@@ -489,7 +489,7 @@ pub fn heading_bar<B: Backend>(
|
|||||||
|
|
||||||
/// Help popup box needs these three pieces of information
|
/// Help popup box needs these three pieces of information
|
||||||
struct HelpInfo {
|
struct HelpInfo {
|
||||||
spans: Vec<Line<'static>>,
|
lines: Vec<Line<'static>>,
|
||||||
width: usize,
|
width: usize,
|
||||||
height: usize,
|
height: usize,
|
||||||
}
|
}
|
||||||
@@ -527,15 +527,15 @@ impl HelpInfo {
|
|||||||
|
|
||||||
/// Generate the `oxker` name span + metadata
|
/// Generate the `oxker` name span + metadata
|
||||||
fn gen_name() -> Self {
|
fn gen_name() -> Self {
|
||||||
let mut spans = NAME_TEXT
|
let mut lines = NAME_TEXT
|
||||||
.lines()
|
.lines()
|
||||||
.map(|i| Line::from(Self::white_span(i)))
|
.map(|i| Line::from(Self::white_span(i)))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
spans.insert(0, Self::empty_span());
|
lines.insert(0, Self::empty_span());
|
||||||
let width = Self::calc_width(&spans);
|
let width = Self::calc_width(&lines);
|
||||||
let height = spans.len();
|
let height = lines.len();
|
||||||
Self {
|
Self {
|
||||||
spans,
|
lines,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}
|
}
|
||||||
@@ -543,15 +543,15 @@ impl HelpInfo {
|
|||||||
|
|
||||||
/// Generate the description span + metadata
|
/// Generate the description span + metadata
|
||||||
fn gen_description() -> Self {
|
fn gen_description() -> Self {
|
||||||
let spans = [
|
let lines = [
|
||||||
Self::empty_span(),
|
Self::empty_span(),
|
||||||
Line::from(Self::white_span(DESCRIPTION)),
|
Line::from(Self::white_span(DESCRIPTION)),
|
||||||
Self::empty_span(),
|
Self::empty_span(),
|
||||||
];
|
];
|
||||||
let width = Self::calc_width(&spans);
|
let width = Self::calc_width(&lines);
|
||||||
let height = spans.len();
|
let height = lines.len();
|
||||||
Self {
|
Self {
|
||||||
spans: spans.to_vec(),
|
lines: lines.to_vec(),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}
|
}
|
||||||
@@ -564,7 +564,7 @@ impl HelpInfo {
|
|||||||
let or = || button_desc("or");
|
let or = || button_desc("or");
|
||||||
let space = || button_desc(" ");
|
let space = || button_desc(" ");
|
||||||
|
|
||||||
let spans = [
|
let lines = [
|
||||||
Line::from(vec![
|
Line::from(vec![
|
||||||
space(),
|
space(),
|
||||||
button_item("tab"),
|
button_item("tab"),
|
||||||
@@ -613,10 +613,10 @@ impl HelpInfo {
|
|||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
let height = spans.len();
|
let height = lines.len();
|
||||||
let width = Self::calc_width(&spans);
|
let width = Self::calc_width(&lines);
|
||||||
Self {
|
Self {
|
||||||
spans: spans.to_vec(),
|
lines: lines.to_vec(),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ impl HelpInfo {
|
|||||||
|
|
||||||
/// Generate the final lines, GitHub link etc, + metadata
|
/// Generate the final lines, GitHub link etc, + metadata
|
||||||
fn gen_final() -> Self {
|
fn gen_final() -> Self {
|
||||||
let spans = [
|
let lines = [
|
||||||
Self::empty_span(),
|
Self::empty_span(),
|
||||||
Line::from(vec![Self::black_span(
|
Line::from(vec![Self::black_span(
|
||||||
"currently an early work in progress, all and any input appreciated",
|
"currently an early work in progress, all and any input appreciated",
|
||||||
@@ -636,10 +636,10 @@ impl HelpInfo {
|
|||||||
.add_modifier(Modifier::UNDERLINED),
|
.add_modifier(Modifier::UNDERLINED),
|
||||||
)]),
|
)]),
|
||||||
];
|
];
|
||||||
let height = spans.len();
|
let height = lines.len();
|
||||||
let width = Self::calc_width(&spans);
|
let width = Self::calc_width(&lines);
|
||||||
Self {
|
Self {
|
||||||
spans: spans.to_vec(),
|
lines: lines.to_vec(),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}
|
}
|
||||||
@@ -689,22 +689,22 @@ pub fn help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
|||||||
)
|
)
|
||||||
.split(area);
|
.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))
|
.style(Style::default().bg(Color::Magenta).fg(Color::White))
|
||||||
.block(Block::default())
|
.block(Block::default())
|
||||||
.alignment(Alignment::Center);
|
.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))
|
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
|
||||||
.block(Block::default())
|
.block(Block::default())
|
||||||
.alignment(Alignment::Center);
|
.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))
|
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
|
||||||
.block(Block::default())
|
.block(Block::default())
|
||||||
.alignment(Alignment::Left);
|
.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))
|
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
|
||||||
.block(Block::default())
|
.block(Block::default())
|
||||||
.alignment(Alignment::Center);
|
.alignment(Alignment::Center);
|
||||||
|
|||||||
Reference in New Issue
Block a user