Skip to content

Commit da28b62

Browse files
committed
remove lines from the top and bottom of the logo and info
1 parent ff7814a commit da28b62

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/ascii_art.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
use colored::{Color, Colorize};
22

33
pub struct AsciiArt<'a> {
4-
content: std::str::Lines<'a>,
4+
content: Box<dyn 'a + Iterator<Item = &'a str>>,
55
colors: Vec<Color>,
66
start: usize,
77
end: usize,
88
}
99
impl<'a> AsciiArt<'a> {
1010
pub fn new(input: &'a str, colors: Vec<Color>) -> AsciiArt<'a> {
11-
let (start, end) = input
12-
.lines()
11+
let mut lines: Vec<_> = input.lines().skip_while(|line| line.is_empty()).collect();
12+
while let Some(line) = lines.last() {
13+
if Tokens(line).is_empty() {
14+
lines.pop();
15+
}
16+
break;
17+
}
18+
19+
let (start, end) = lines
20+
.iter()
1321
.map(|line| {
1422
let line_start = Tokens(line).leading_spaces();
1523
let line_end = Tokens(line).true_length();
@@ -20,7 +28,7 @@ impl<'a> AsciiArt<'a> {
2028
});
2129

2230
AsciiArt {
23-
content: input.lines(),
31+
content: Box::new(lines.into_iter()),
2432
colors: colors,
2533
start: start,
2634
end: end,
@@ -95,6 +103,14 @@ impl<'a> Iterator for Tokens<'a> {
95103
}
96104

97105
impl<'a> Tokens<'a> {
106+
fn is_empty(&mut self) -> bool {
107+
for token in self {
108+
if token.is_solid() {
109+
return false;
110+
}
111+
}
112+
true
113+
}
98114
fn true_length(&mut self) -> usize {
99115
let mut last_non_space = 0;
100116
let mut last = 0;

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
542542
disable_fields,
543543
};
544544

545-
println!("{}", info);
545+
print!("{}", info);
546546
Ok(())
547547
}
548548

0 commit comments

Comments
 (0)