asciinema_win 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/LICENSE +21 -0
- data/README.md +105 -25
- data/docs/architecture.md +105 -0
- data/docs/cheat-sheet.md +80 -0
- data/docs/customization.md +141 -0
- data/docs/example.md +350 -0
- data/docs/how-to-use.md +153 -0
- data/docs/test-report.md +165 -0
- data/docs/troubleshooting.md +94 -0
- data/docs/windows-notes.md +87 -0
- data/lib/asciinema_win/cli.rb +15 -2
- data/lib/asciinema_win/export.rb +665 -35
- data/lib/asciinema_win/version.rb +1 -1
- data/lib/rich/tree.rb +20 -2
- metadata +22 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46a45a439fb42d920f537b8abc204e4077abf409286f523cc16aa5e0fb7bda97
|
|
4
|
+
data.tar.gz: 132c07a514f7358721c71129d769ddfc59b3028006c8ec9109041c0448777f38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3eb154303aa5657b756044448b514b7ef2c7cda06293846deeb4a3f8ea2dc51820d40e0f4693b6e4a972841851d6d2c831488abd3ebcefa247428525001e888f
|
|
7
|
+
data.tar.gz: 4f4c8583ae097a2ef4ba87209743d041002c9134d9f424deb19f4a19af76dbcfe7081a9b9e865988a6b2c4681bd73c70e85be93684517d4fa8d50d515e57d795
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2025-12-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **FFmpeg Video Export**: Convert `.cast` recordings to GIF, MP4, and WebM
|
|
12
|
+
- Pure Ruby PPM frame renderer with embedded 8x16 VGA bitmap font
|
|
13
|
+
- 2-pass palette optimization for high-quality GIF output
|
|
14
|
+
- H.264 encoding for MP4 (libx264, yuv420p, CRF 23)
|
|
15
|
+
- VP9 encoding for WebM (libvpx-vp9, CRF 30)
|
|
16
|
+
- **New CLI Options**: `--fps`, `--theme`, `--scale` for video export
|
|
17
|
+
- **Video Export Test Suite**: `examples/video_export_test.rb` with comprehensive edge case testing
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- **Rich::Tree markup rendering**: Labels with markup like `[blue]text[/]` now correctly parse to ANSI escape codes instead of rendering as literal text
|
|
21
|
+
- **Unicode characters in video export**: Added block elements (█ ░ ▒ ▓), box-drawing characters, and symbols (✓ ✗ ▶) to embedded font for proper progress bar and table rendering
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Updated gemspec description with video export capabilities
|
|
25
|
+
- Updated README with video export documentation
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
- FFmpeg required for video export (optional, native formats work without it)
|
|
29
|
+
|
|
30
|
+
## [0.1.0] - 2025-12-24
|
|
31
|
+
|
|
32
|
+
### Initial Release
|
|
33
|
+
- Native Windows terminal recording with Win32 Console APIs
|
|
34
|
+
- Asciicast v2 format support (compatible with asciinema.org)
|
|
35
|
+
- Export formats: HTML, SVG, Text, JSON
|
|
36
|
+
- 9 terminal themes (asciinema, dracula, monokai, nord, tokyo-night, etc.)
|
|
37
|
+
- Rich-Ruby integration for beautiful terminal formatting
|
|
38
|
+
- Speed adjustment and idle compression
|
|
39
|
+
- Recording concatenation
|
|
40
|
+
- Thumbnail generation
|
|
41
|
+
- Zero external dependencies for core functionality
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 tigel-agm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
# asciinema-win + Rich-Ruby
|
|
2
2
|
|
|
3
3
|
[](https://www.ruby-lang.org/)
|
|
4
|
-
[](https://github.com/
|
|
4
|
+
[](https://github.com/tigel-agm/asciinema-windows)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/
|
|
7
|
-
[](https://github.com/tigel-agm/asciinema-windows)
|
|
7
|
+
[](https://rubygems.org/gems/asciinema_win)
|
|
8
8
|
|
|
9
|
-
> **Native Windows Terminal Recorder
|
|
9
|
+
> **Native Windows Terminal Recorder and Rich Text Library in Pure Ruby**
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Record terminal sessions, export to GIF/MP4/WebM video, and render beautiful formatted output—all with zero external dependencies (except FFmpeg for video export).
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Demo
|
|
16
|
+
|
|
17
|
+
**Rich-Ruby Terminal Recording exported to GIF:**
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
The GIF above shows Rich-Ruby components (Panel, Table, Tree, Syntax Highlighting, Progress Bar) rendered correctly with ANSI colors. Created with `examples/rich_ruby_demo.rb` and exported using the pure Ruby PPM frame renderer.
|
|
22
|
+
|
|
23
|
+
<details>
|
|
24
|
+
<summary><strong>Common rendering issues and solutions</strong></summary>
|
|
25
|
+
|
|
26
|
+
**Issue 1: Literal markup tags instead of colors**
|
|
27
|
+
|
|
28
|
+
If you see `[blue]text[/]` instead of colored text, the Rich-Ruby markup wasn't parsed:
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
**Solution:** Use `Rich::Text.from_markup()` or `Rich::Console.print()` to properly parse markup before recording.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
**Issue 2: Missing progress bar blocks**
|
|
37
|
+
|
|
38
|
+
If percentage increases but the bar is empty, Unicode block characters weren't in the font:
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
**Solution:** This was fixed in v0.2.0. The embedded font now includes block elements (█ ░ ▒ ▓) and box-drawing characters.
|
|
43
|
+
|
|
44
|
+
</details>
|
|
16
45
|
|
|
17
46
|
---
|
|
18
47
|
|
|
@@ -37,27 +66,31 @@ This project contains two integrated components:
|
|
|
37
66
|
|
|
38
67
|
# asciinema-win
|
|
39
68
|
|
|
40
|
-
Record and playback terminal sessions on native Windows with accurate timing and full color support.
|
|
69
|
+
Record and playback terminal sessions on native Windows with accurate timing and full color support. Export to video formats (GIF, MP4, WebM) using a pure Ruby frame renderer.
|
|
41
70
|
|
|
42
71
|
<a name="asciinema-features"></a>
|
|
43
72
|
## Features
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
- **Multiple Export Formats** - HTML, SVG, text, JSON, and video (with FFmpeg)
|
|
74
|
+
**Core**
|
|
75
|
+
- Zero external dependencies (pure Ruby + Fiddle for Win32 API)
|
|
76
|
+
- Native Windows Console API access
|
|
77
|
+
- asciicast v2 format (compatible with asciinema.org)
|
|
50
78
|
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
79
|
+
**Recording**
|
|
80
|
+
- Screen buffer capture with colors and attributes
|
|
81
|
+
- Microsecond-accurate timing
|
|
54
82
|
- Idle time limiting
|
|
55
83
|
- Command recording mode
|
|
56
84
|
|
|
57
|
-
|
|
85
|
+
**Export**
|
|
86
|
+
- Native: HTML, SVG, Text, JSON (no dependencies)
|
|
87
|
+
- Video: GIF, MP4, WebM (requires FFmpeg)
|
|
88
|
+
- 9 terminal color themes
|
|
89
|
+
- Pure Ruby PPM frame renderer with embedded VGA font
|
|
90
|
+
|
|
91
|
+
**Playback**
|
|
58
92
|
- Accurate timing reproduction
|
|
59
|
-
- Adjustable speed (0.5x
|
|
60
|
-
- Pause on markers
|
|
93
|
+
- Adjustable speed (0.5x to 4x)
|
|
61
94
|
|
|
62
95
|
<a name="asciinema-quick-start"></a>
|
|
63
96
|
## Quick Start
|
|
@@ -151,6 +184,9 @@ Options:
|
|
|
151
184
|
-f, --format <fmt> Output format
|
|
152
185
|
-o, --output <file> Output file path
|
|
153
186
|
-t, --title <title> Title for HTML export
|
|
187
|
+
--fps <n> Frames per second for video (default: 10)
|
|
188
|
+
--theme <name> Color theme for video export
|
|
189
|
+
--scale <n> Scale factor for video output
|
|
154
190
|
```
|
|
155
191
|
|
|
156
192
|
### `asciinema_win cat`
|
|
@@ -230,9 +266,53 @@ end
|
|
|
230
266
|
| SVG | `.svg` | None | Colored terminal snapshot with themes |
|
|
231
267
|
| Text | `.txt` | None | Plain text with ANSI stripped |
|
|
232
268
|
| JSON | `.json` | None | Normalized event data |
|
|
233
|
-
| GIF | `.gif` | FFmpeg | Animated GIF |
|
|
234
|
-
| MP4 | `.mp4` | FFmpeg |
|
|
235
|
-
| WebM | `.webm` | FFmpeg |
|
|
269
|
+
| GIF | `.gif` | FFmpeg | Animated GIF (2-pass palette) |
|
|
270
|
+
| MP4 | `.mp4` | FFmpeg | H.264 video (yuv420p) |
|
|
271
|
+
| WebM | `.webm` | FFmpeg | VP9 video |
|
|
272
|
+
|
|
273
|
+
### Video Export (GIF/MP4/WebM)
|
|
274
|
+
|
|
275
|
+
Export recordings to video formats using FFmpeg. Uses a pure Ruby PPM frame
|
|
276
|
+
renderer with an embedded 8x16 VGA bitmap font—no external libraries needed
|
|
277
|
+
except FFmpeg itself.
|
|
278
|
+
|
|
279
|
+
**CLI Examples:**
|
|
280
|
+
|
|
281
|
+
```powershell
|
|
282
|
+
# Export to GIF (default 10 FPS)
|
|
283
|
+
C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win export demo.cast -o demo.gif
|
|
284
|
+
|
|
285
|
+
# Export to GIF with custom FPS and theme
|
|
286
|
+
C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win export demo.cast -o demo.gif --fps 15 --theme dracula
|
|
287
|
+
|
|
288
|
+
# Export to MP4
|
|
289
|
+
C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win export demo.cast -o demo.mp4 --fps 30
|
|
290
|
+
|
|
291
|
+
# Export to WebM
|
|
292
|
+
C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win export demo.cast -o demo.webm
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Ruby API:**
|
|
296
|
+
|
|
297
|
+
```ruby
|
|
298
|
+
require 'asciinema_win'
|
|
299
|
+
|
|
300
|
+
# Export to GIF with options
|
|
301
|
+
AsciinemaWin::Export.export("demo.cast", "demo.gif",
|
|
302
|
+
format: :gif,
|
|
303
|
+
fps: 15,
|
|
304
|
+
theme: "dracula"
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# Export to MP4
|
|
308
|
+
AsciinemaWin::Export.export("demo.cast", "demo.mp4", format: :mp4, fps: 30)
|
|
309
|
+
|
|
310
|
+
# Export to WebM
|
|
311
|
+
AsciinemaWin::Export.export("demo.cast", "demo.webm", format: :webm)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
> **Note:** GIF export uses 2-pass palette optimization (`palettegen` + `paletteuse`)
|
|
315
|
+
> for high-quality output with proper dithering.
|
|
236
316
|
|
|
237
317
|
### Terminal Themes
|
|
238
318
|
|
|
@@ -491,8 +571,8 @@ cd asciinema-win
|
|
|
491
571
|
### Build and Install Gem
|
|
492
572
|
|
|
493
573
|
```powershell
|
|
494
|
-
C:\RubyMSVC34\bin\gem.
|
|
495
|
-
C:\RubyMSVC34\bin\gem.
|
|
574
|
+
C:\RubyMSVC34\bin\gem.cmd build asciinema_win.gemspec
|
|
575
|
+
C:\RubyMSVC34\bin\gem.cmd install asciinema_win-0.2.0.gem
|
|
496
576
|
```
|
|
497
577
|
|
|
498
578
|
---
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Architecture & Data Flow
|
|
2
|
+
|
|
3
|
+
This document explains the architecture of asciinema-win + Rich-Ruby.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## High-Level Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
11
|
+
│ asciinema-win │
|
|
12
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
13
|
+
│ CLI Layer │ Ruby API │
|
|
14
|
+
│ ├── rec │ ├── AsciinemaWin.record() │
|
|
15
|
+
│ ├── play │ ├── AsciinemaWin.play() │
|
|
16
|
+
│ ├── export │ ├── AsciinemaWin::Export │
|
|
17
|
+
│ ├── cat │ └── AsciinemaWin::Asciicast │
|
|
18
|
+
│ └── info │ │
|
|
19
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
20
|
+
│ Core Engine │
|
|
21
|
+
│ ├── Recorder - Background capture with timing │
|
|
22
|
+
│ ├── Player - Playback with speed control │
|
|
23
|
+
│ ├── Asciicast - File format (Header, Event, Writer, Reader) │
|
|
24
|
+
│ ├── Export - SVG, HTML, JSON, text, thumbnails │
|
|
25
|
+
│ ├── Themes - 9 terminal color palettes │
|
|
26
|
+
│ └── AnsiParser - ANSI escape sequence parsing │
|
|
27
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
28
|
+
│ Rich-Ruby │
|
|
29
|
+
│ ├── Console - Terminal interface │
|
|
30
|
+
│ ├── Panel - Bordered containers │
|
|
31
|
+
│ ├── Table - Data grids │
|
|
32
|
+
│ ├── Tree - Hierarchical views │
|
|
33
|
+
│ ├── Syntax - Code highlighting │
|
|
34
|
+
│ ├── Color - 16/256/TrueColor │
|
|
35
|
+
│ └── Style - Bold, italic, underline, etc. │
|
|
36
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
37
|
+
│ Win32 Console API │
|
|
38
|
+
│ (via Ruby's Fiddle - zero external dependencies) │
|
|
39
|
+
│ ├── GetConsoleScreenBufferInfo │
|
|
40
|
+
│ ├── ReadConsoleOutputW │
|
|
41
|
+
│ ├── SetConsoleMode (enable VT processing) │
|
|
42
|
+
│ └── WriteConsoleW │
|
|
43
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Recording Pipeline
|
|
49
|
+
|
|
50
|
+
1. **Initialization**: Create output file with asciicast v2 header
|
|
51
|
+
2. **Capture Thread**: Background thread captures screen buffer at 30fps
|
|
52
|
+
3. **Delta Detection**: Compare current buffer with previous, emit only changes
|
|
53
|
+
4. **ANSI Generation**: Convert Windows attributes to ANSI escape sequences
|
|
54
|
+
5. **Event Writing**: Write timestamped events to .cast file
|
|
55
|
+
6. **Finalization**: Close file on Ctrl+D or process exit
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Playback Pipeline
|
|
60
|
+
|
|
61
|
+
1. **Load**: Read and parse asciicast v2 file
|
|
62
|
+
2. **Validate**: Check header and event format
|
|
63
|
+
3. **Timing**: Sleep between events (adjusted by speed factor)
|
|
64
|
+
4. **Render**: Write event data to terminal
|
|
65
|
+
5. **Markers**: Optionally pause at marker events
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Export Pipeline
|
|
70
|
+
|
|
71
|
+
1. **Parse**: Load recording and collect all output events
|
|
72
|
+
2. **ANSI Parse**: Parse escape sequences → styled characters
|
|
73
|
+
3. **Theme Apply**: Map ANSI colors to theme palette
|
|
74
|
+
4. **Render**: Generate output format (SVG, HTML, JSON, text)
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Rich-Ruby Rendering Pipeline
|
|
79
|
+
|
|
80
|
+
1. **Input**: Markup string or component (Panel, Table, etc.)
|
|
81
|
+
2. **Parse**: Convert markup to Text with Spans
|
|
82
|
+
3. **Segment**: Break into Segment objects (text + style)
|
|
83
|
+
4. **Measure**: Calculate cell widths (Unicode-aware)
|
|
84
|
+
5. **Layout**: Apply wrapping, alignment, borders
|
|
85
|
+
6. **ANSI**: Generate escape sequences
|
|
86
|
+
7. **Output**: Write to terminal
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Windows Console Integration
|
|
91
|
+
|
|
92
|
+
Rich-Ruby and asciinema-win use `Fiddle` to call Windows Console APIs:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
# Enable ANSI/VT processing
|
|
96
|
+
SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
97
|
+
|
|
98
|
+
# Get terminal dimensions
|
|
99
|
+
GetConsoleScreenBufferInfo(handle, info_ptr)
|
|
100
|
+
|
|
101
|
+
# Read screen buffer for recording
|
|
102
|
+
ReadConsoleOutputW(handle, buffer, size, coord, region)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This is a pure Ruby approach - no C extensions, no external dependencies.
|
data/docs/cheat-sheet.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Cheat Sheet
|
|
2
|
+
|
|
3
|
+
Quick reference for asciinema-win + Rich-Ruby.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## CLI Commands
|
|
8
|
+
|
|
9
|
+
| Command | Description |
|
|
10
|
+
|---------|-------------|
|
|
11
|
+
| `asciinema_win rec file.cast` | Record terminal session |
|
|
12
|
+
| `asciinema_win rec -c "cmd" file.cast` | Record specific command |
|
|
13
|
+
| `asciinema_win play file.cast` | Play back recording |
|
|
14
|
+
| `asciinema_win play -s 2 file.cast` | Play at 2x speed |
|
|
15
|
+
| `asciinema_win export file.cast -o out.html` | Export to HTML |
|
|
16
|
+
| `asciinema_win export file.cast -f svg -o out.svg` | Export to SVG |
|
|
17
|
+
| `asciinema_win export file.cast -o out.gif` | Export to GIF (requires FFmpeg) |
|
|
18
|
+
| `asciinema_win export file.cast -o out.mp4 --fps 30` | Export to MP4 |
|
|
19
|
+
| `asciinema_win export file.cast -o out.gif --theme dracula` | Export with theme |
|
|
20
|
+
| `asciinema_win cat file.cast` | Output to stdout |
|
|
21
|
+
| `asciinema_win info file.cast` | Show recording info |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Ruby API
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
require 'asciinema_win'
|
|
29
|
+
|
|
30
|
+
# Recording
|
|
31
|
+
AsciinemaWin.record("file.cast", title: "Demo")
|
|
32
|
+
AsciinemaWin.record("file.cast", command: "dir")
|
|
33
|
+
|
|
34
|
+
# Playback
|
|
35
|
+
AsciinemaWin.play("file.cast", speed: 2.0)
|
|
36
|
+
|
|
37
|
+
# Export
|
|
38
|
+
AsciinemaWin::Export.export("in.cast", "out.svg", format: :svg, theme: "dracula")
|
|
39
|
+
AsciinemaWin::Export.export("in.cast", "out.gif", format: :gif, fps: 10) # Video export
|
|
40
|
+
AsciinemaWin::Export.export("in.cast", "out.mp4", format: :mp4, fps: 30)
|
|
41
|
+
AsciinemaWin::Export.thumbnail("in.cast", "thumb.svg", frame: :last)
|
|
42
|
+
AsciinemaWin::Export.adjust_speed("in.cast", "out.cast", speed: 2.0, max_idle: 0.5)
|
|
43
|
+
AsciinemaWin::Export.concatenate(["a.cast", "b.cast"], "combined.cast")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Rich-Ruby
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
require 'rich'
|
|
52
|
+
|
|
53
|
+
# Styled output
|
|
54
|
+
Rich.print("[bold red]Error[/] Message")
|
|
55
|
+
Rich.print("[green]Success[/] Done")
|
|
56
|
+
|
|
57
|
+
# Components
|
|
58
|
+
Rich::Panel.new("content", title: "Title").render(max_width: 50)
|
|
59
|
+
Rich::Table.new(title: "Data")
|
|
60
|
+
Rich::Tree.new("Root")
|
|
61
|
+
Rich::Syntax.new(code, language: "ruby", theme: :monokai)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Markup Syntax
|
|
67
|
+
|
|
68
|
+
| Syntax | Effect |
|
|
69
|
+
|--------|--------|
|
|
70
|
+
| `[bold]text[/]` | **Bold** |
|
|
71
|
+
| `[italic]text[/]` | *Italic* |
|
|
72
|
+
| `[red]text[/]` | Red text |
|
|
73
|
+
| `[on blue]text[/]` | Blue background |
|
|
74
|
+
| `[bold red on white]` | Combined |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Available Themes
|
|
79
|
+
|
|
80
|
+
`asciinema`, `dracula`, `monokai`, `solarized-dark`, `solarized-light`, `nord`, `one-dark`, `github-dark`, `tokyo-night`
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Customization
|
|
2
|
+
|
|
3
|
+
How to customize asciinema-win + Rich-Ruby for your needs.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Custom Themes
|
|
8
|
+
|
|
9
|
+
Create your own terminal theme for SVG exports:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
# Define custom theme
|
|
13
|
+
custom_theme = AsciinemaWin::Themes::Theme.new(
|
|
14
|
+
foreground: "#e0e0e0",
|
|
15
|
+
background: "#1e1e2e",
|
|
16
|
+
palette: [
|
|
17
|
+
"#45475a", # Black (0)
|
|
18
|
+
"#f38ba8", # Red (1)
|
|
19
|
+
"#a6e3a1", # Green (2)
|
|
20
|
+
"#f9e2af", # Yellow (3)
|
|
21
|
+
"#89b4fa", # Blue (4)
|
|
22
|
+
"#f5c2e7", # Magenta (5)
|
|
23
|
+
"#94e2d5", # Cyan (6)
|
|
24
|
+
"#bac2de", # White (7)
|
|
25
|
+
"#585b70", # Bright Black (8)
|
|
26
|
+
"#f38ba8", # Bright Red (9)
|
|
27
|
+
"#a6e3a1", # Bright Green (10)
|
|
28
|
+
"#f9e2af", # Bright Yellow (11)
|
|
29
|
+
"#89b4fa", # Bright Blue (12)
|
|
30
|
+
"#f5c2e7", # Bright Magenta (13)
|
|
31
|
+
"#94e2d5", # Bright Cyan (14)
|
|
32
|
+
"#a6adc8" # Bright White (15)
|
|
33
|
+
]
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Use custom theme
|
|
37
|
+
AsciinemaWin::Themes.register("catppuccin", custom_theme)
|
|
38
|
+
AsciinemaWin::Export.export("demo.cast", "out.svg", format: :svg, theme: "catppuccin")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Custom Rich Styles
|
|
44
|
+
|
|
45
|
+
Create reusable styles:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
# Define custom styles
|
|
49
|
+
styles = {
|
|
50
|
+
error: "bold red",
|
|
51
|
+
warning: "yellow",
|
|
52
|
+
success: "bold green",
|
|
53
|
+
info: "cyan",
|
|
54
|
+
muted: "dim"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Use with Rich
|
|
58
|
+
Rich.print("[#{styles[:error]}]ERROR:[/] Something failed")
|
|
59
|
+
Rich.print("[#{styles[:success]}]SUCCESS:[/] All done")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Custom Box Styles
|
|
65
|
+
|
|
66
|
+
Use different box characters for panels:
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
# Built-in box styles
|
|
70
|
+
Rich::Box::ASCII # +--+
|
|
71
|
+
Rich::Box::SQUARE # ┌─┐
|
|
72
|
+
Rich::Box::ROUNDED # ╭─╮
|
|
73
|
+
Rich::Box::HEAVY # ┏━┓
|
|
74
|
+
Rich::Box::DOUBLE # ╔═╗
|
|
75
|
+
Rich::Box::MINIMAL # No corners
|
|
76
|
+
|
|
77
|
+
# Use in Panel
|
|
78
|
+
panel = Rich::Panel.new("Content", box: Rich::Box::DOUBLE)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Custom Output Organization
|
|
84
|
+
|
|
85
|
+
Override output directory structure:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
# Custom base directory
|
|
89
|
+
session = AsciinemaWin::OutputOrganizer.create_session(
|
|
90
|
+
"my_session",
|
|
91
|
+
base_dir: "my_output"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# Or use direct paths
|
|
95
|
+
AsciinemaWin::OutputOrganizer.output_path(
|
|
96
|
+
"demo",
|
|
97
|
+
format: :svg,
|
|
98
|
+
base_dir: "custom_folder",
|
|
99
|
+
timestamp: false # No timestamp in filename
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Custom Syntax Themes
|
|
106
|
+
|
|
107
|
+
Rich::Syntax supports multiple highlighting themes:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
# Available themes
|
|
111
|
+
themes = [:monokai, :dracula, :github, :solarized]
|
|
112
|
+
|
|
113
|
+
themes.each do |theme|
|
|
114
|
+
syntax = Rich::Syntax.new(code, language: "ruby", theme: theme)
|
|
115
|
+
puts "== #{theme} =="
|
|
116
|
+
puts syntax.render
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Recording Options
|
|
123
|
+
|
|
124
|
+
Customize recording behavior:
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
# Create recorder with options
|
|
128
|
+
recorder = AsciinemaWin::Recorder.new(
|
|
129
|
+
output_path: "session.cast",
|
|
130
|
+
title: "My Demo",
|
|
131
|
+
idle_time_limit: 2.0, # Limit idle time
|
|
132
|
+
capture_interval: 0.033 # ~30 fps
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Programmatic control
|
|
136
|
+
recorder.start
|
|
137
|
+
# ... your code ...
|
|
138
|
+
recorder.add_marker("checkpoint")
|
|
139
|
+
# ... more code ...
|
|
140
|
+
recorder.stop
|
|
141
|
+
```
|