Skip to content

Commit

Permalink
Temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Apr 25, 2021
1 parent ec38cb3 commit 486c3c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion log

This file was deleted.

23 changes: 17 additions & 6 deletions src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ pub fn ansi_to_text<'t, B: AsRef<[u8]>>(bytes: B) -> Result<Text<'t>, Error> {
}
graphics_start = true;
}

(_, &b'\n') => {
buffer.push(Spans::from(spans_buffer.clone()));
spans_buffer.clear();
}
(_, code) => {
if graphics_start {
if code == &b'm' {
Expand All @@ -197,17 +202,23 @@ pub fn ansi_to_text<'t, B: AsRef<[u8]>>(bytes: B) -> Result<Text<'t>, Error> {
}
} else if code != &b'\x1b' {
line_buffer.push(*code as char)
} else if code == &b'\n' {
buffer.push(Spans::from(spans_buffer.clone()));
spans_buffer.clear();
}
last_byte = code;
}
}
last_byte = byte;
}
// println!("{:?}", buffer);
buffer.push(Spans::from(spans_buffer.clone()));
spans_buffer.clear();
if !spans_buffer.is_empty() {
buffer.push(Spans::from(spans_buffer.clone()));
spans_buffer.clear();
}

// for span in buffer.iter() {
// println!("HELLOA");
// println!("{:?}", span);
// }

println!("bufferlen {}", buffer.len());
println!("{:?}", &buffer);
Ok(buffer.into())
}
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
mod ansi;
mod code;
mod color;
Expand Down Expand Up @@ -26,7 +27,7 @@ pub fn main() {

file.read_to_end(&mut buffer).unwrap();
let _text = ansi_to_text(buffer).unwrap();
println!("{:?}", _text);
// println!("{:?}", _text);

Paragraph::new(_text).render(Rect::new(1, 1, 10, 10), &mut tmp_buffer);
write_buffer_to_console(&mut backend, &mut tmp_buffer).unwrap();
Expand Down

0 comments on commit 486c3c9

Please sign in to comment.