mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Add "r" (resize) event as the first event when appending
This ensures the appended events are can rely on their assumed terminal window size. Addresses part of #636.
This commit is contained in:
@@ -33,7 +33,7 @@ impl cli::Convert {
|
||||
match format {
|
||||
Format::AsciicastV3 => Box::new(AsciicastV3Encoder::new(false)),
|
||||
Format::AsciicastV2 => Box::new(AsciicastV2Encoder::new(false, 0)),
|
||||
Format::Raw => Box::new(RawEncoder::new(false)),
|
||||
Format::Raw => Box::new(RawEncoder::new()),
|
||||
Format::Txt => Box::new(TextEncoder::new()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ impl cli::Session {
|
||||
|
||||
Format::Raw => {
|
||||
let writer = Box::new(file);
|
||||
let encoder = Box::new(RawEncoder::new(append));
|
||||
let encoder = Box::new(RawEncoder::new());
|
||||
|
||||
FileWriterStarter {
|
||||
writer,
|
||||
|
||||
@@ -16,7 +16,8 @@ impl AsciicastV2Encoder {
|
||||
impl super::Encoder for AsciicastV2Encoder {
|
||||
fn header(&mut self, header: &Header) -> Vec<u8> {
|
||||
if self.append {
|
||||
Vec::new()
|
||||
let size = (header.term_cols, header.term_rows);
|
||||
self.inner.event(&Event::resize(0, size))
|
||||
} else {
|
||||
self.inner.header(header)
|
||||
}
|
||||
@@ -47,7 +48,8 @@ impl AsciicastV3Encoder {
|
||||
impl super::Encoder for AsciicastV3Encoder {
|
||||
fn header(&mut self, header: &Header) -> Vec<u8> {
|
||||
if self.append {
|
||||
Vec::new()
|
||||
let size = (header.term_cols, header.term_rows);
|
||||
self.inner.event(&Event::resize(0, size))
|
||||
} else {
|
||||
self.inner.header(header)
|
||||
}
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
use crate::asciicast::{Event, EventData, Header};
|
||||
|
||||
pub struct RawEncoder {
|
||||
append: bool,
|
||||
}
|
||||
pub struct RawEncoder;
|
||||
|
||||
impl RawEncoder {
|
||||
pub fn new(append: bool) -> Self {
|
||||
RawEncoder { append }
|
||||
pub fn new() -> Self {
|
||||
RawEncoder
|
||||
}
|
||||
}
|
||||
|
||||
impl super::Encoder for RawEncoder {
|
||||
fn header(&mut self, header: &Header) -> Vec<u8> {
|
||||
if self.append {
|
||||
Vec::new()
|
||||
} else {
|
||||
format!("\x1b[8;{};{}t", header.term_rows, header.term_cols).into_bytes()
|
||||
}
|
||||
format!("\x1b[8;{};{}t", header.term_rows, header.term_cols).into_bytes()
|
||||
}
|
||||
|
||||
fn event(&mut self, event: Event) -> Vec<u8> {
|
||||
@@ -40,7 +34,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn encoder() {
|
||||
let mut enc = RawEncoder::new(false);
|
||||
let mut enc = RawEncoder::new();
|
||||
|
||||
let header = Header {
|
||||
term_cols: 100,
|
||||
|
||||
Reference in New Issue
Block a user