Skip to content

Commit

Permalink
Merge branch 'asciinema:main' into github-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Neved4 authored Oct 16, 2023
2 parents 32c75ff + 7aa2720 commit 54b85e1
Show file tree
Hide file tree
Showing 4 changed files with 12 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
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Theme {
GithubDark,
GithubLight,
Monokai,
Nord,
SolarizedDark,
SolarizedLight,

Expand All @@ -95,6 +96,7 @@ impl TryFrom<Theme> for theme::Theme {
GithubDark => "171b21,eceff4,6a737d,f97583,a2fca2,fabb72,7db4f9,c4a0f5,1f6feb,6a737d".parse(),
GithubLight => "eceff4,202327,6a737d,f97583,a2fca2,fabb72,7db4f9,c4a0f5,1f6feb,6a737d".parse(),
Monokai => "272822,f8f8f2,272822,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f8f8f2,75715e,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f9f8f5".parse(),
Nord => "2e3440,eceff4,3b4252,bf616a,a3be8c,ebcb8b,81a1c1,b48ead,88c0d0,eceff4,3b4252,bf616a,a3be8c,ebcb8b,81a1c1,b48ead,88c0d0,eceff4".parse(),
SolarizedDark => "002b36,839496,073642,dc322f,859900,b58900,268bd2,d33682,2aa198,eee8d5,002b36,cb4b16,586e75,657b83,839496,6c71c4,93a1a1,fdf6e3".parse(),
SolarizedLight => "fdf6e3,657b83,073642,dc322f,859900,b58900,268bd2,d33682,2aa198,eee8d5,002b36,cb4b16,586e75,657c83,839496,6c71c4,93a1a1,fdf6e3".parse(),
Custom(t) => t.parse(),
Expand Down Expand Up @@ -192,6 +194,7 @@ pub fn run<I: BufRead, O: Write + Send>(input: I, output: O, config: Config) ->
let mut pr = gifski::progress::ProgressBar::new(count);
let result = writer.write(output, &mut pr);
pr.finish();
println!();
result
} else {
let mut pr = gifski::progress::NoProgress {};
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 54b85e1

Please sign in to comment.