Skip to content

Commit

Permalink
Update avt to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Oct 14, 2023
1 parent f10741f commit 7aa2720
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 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 @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
anyhow = "1"
avt = { git = "https://github.com/asciinema/avt.git", tag = "v0.8.2" }
avt = { git = "https://github.com/asciinema/avt.git", tag = "v0.8.3" }
clap = { version = "3.2.15", features = ["derive"] }
env_logger = "0.10"
fontdb = "0.10"
Expand Down
16 changes: 6 additions & 10 deletions src/vt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ pub fn frames(
stdout: impl Iterator<Item = (f64, String)>,
terminal_size: (usize, usize),
) -> impl Iterator<Item = (f64, Vec<Vec<(char, avt::Pen)>>, Option<(usize, usize)>)> {
let mut vt = avt::Vt::new(terminal_size.0, terminal_size.1);
let mut vt = avt::Vt::builder()
.size(terminal_size.0, terminal_size.1)
.scrollback_limit(0)
.build();

let mut prev_cursor = None;

stdout.filter_map(move |(time, data)| {
let (changed_lines, _) = vt.feed_str(&data);
let cursor = cursor_option(vt.cursor());
let cursor: Option<(usize, usize)> = vt.cursor().into();

if !changed_lines.is_empty() || cursor != prev_cursor {
prev_cursor = cursor;
Expand All @@ -30,14 +34,6 @@ pub fn frames(
})
}

fn cursor_option((col, row, visible): (usize, usize, bool)) -> Option<(usize, usize)> {
if visible {
Some((col, row))
} else {
None
}
}

#[cfg(test)]
mod tests {
#[test]
Expand Down

0 comments on commit 7aa2720

Please sign in to comment.