From 91cef71048773fff5144fa14119c5d96fac828d3 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 13 Mar 2025 16:02:48 -0700 Subject: [PATCH] feat: set screen size from asciinema cast header --- scripts/redact-cast.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/redact-cast.py b/scripts/redact-cast.py index cb10aba28..78b495c34 100755 --- a/scripts/redact-cast.py +++ b/scripts/redact-cast.py @@ -16,14 +16,19 @@ def main(): input_file = sys.argv[1] output_file = sys.argv[2] - # Initialize pyte screen and stream - screen = pyte.Screen(80, 24) - stream = pyte.Stream(screen) - # Read and parse the cast file with open(input_file, "r") as f: # First line is header header = f.readline().strip() + + # Parse header to extract terminal dimensions + header_data = json.loads(header) + width = header_data.get("width", 80) + height = header_data.get("height", 24) + + # Initialize pyte screen and stream with dimensions from header + screen = pyte.Screen(width, height) + stream = pyte.Stream(screen) # Read the events events = [json.loads(line) for line in f if line.strip()]