ASS-Editor
A high-performance, ergonomic editor layer for ASS (Advanced SubStation Alpha) subtitles, built on top of ass-core. Designed for interactive subtitle editing with zero-copy efficiency, incremental updates, and comprehensive command support.
๐ Key Features
- ๐ Interactive Editing: Fluent API with undo/redo, multi-document sessions, and incremental parsing
- โก High Performance: <1ms edits, <5ms re-parses, zero-copy spans from ass-core
- ๐ Advanced Search: FST-based indexing for fast regex queries across large scripts
- ๐ Extensible: Plugin system for custom commands, syntax highlighting, and auto-completion
- ๐งต Thread-Safe: Optional multi-threading support with Arc/Mutex (feature-gated)
- ๐ฆ Zero Dependencies: Core functionality with minimal external dependencies
- ๐ Platform Support: Native, WASM, and no_std compatibility
๐ Performance Targets
- Edit Operations: <1ms for single-event modifications
- Incremental Parsing: <5ms for typical script changes
- Memory Usage: ~1.2x input size (including undo history)
- Session Switching: <100ยตs between documents
- Search Queries: <10ms for regex across 1000+ events
๐ฏ Quick Start
Add to your Cargo.toml:
[]
= "0.1"
# With additional features
= { = "0.1", = ["search-index", "plugins"] }
Basic Usage
use ;
// Create a new document
let mut doc = from_content.unwrap;
// Basic text operations
let pos = new;
doc.insert_at.unwrap;
// Undo/redo support
doc.undo.unwrap;
doc.redo.unwrap;
println!;
Fluent API
use ;
let mut doc = new;
// Fluent command chaining
doc.at_pos
.insert_text
.and_then
.and_then
.unwrap;
// Range operations
let range = new;
doc.command
.range
.replace
.unwrap;
assert_eq!;
Style and Event Management
use ;
let mut doc = from_content.unwrap;
// Create and apply styles
let style = new
.fontname
.fontsize
.primary_colour
.build;
doc.styles
.create
.execute
.unwrap;
// Create events with the fluent API
doc.events
.create_dialogue
.start_time
.end_time
.style
.text
.execute
.unwrap;
Karaoke Support
use ;
let mut doc = from_content.unwrap;
let range = new;
// Generate karaoke timing
doc.karaoke
.in_range
.generate // 50 centiseconds per syllable
.karaoke_type
.execute
.unwrap;
// Adjust existing karaoke timing
doc.karaoke
.in_range
.adjust
.scale // Make 50% longer
.execute
.unwrap;
Search and Indexing
use ;
let mut doc = from_content.unwrap;
// Build search index for fast queries
doc.build_search_index.unwrap;
// Fast regex search
let results = doc.search
.pattern // Find bold tags with numbers
.case_insensitive
.execute
.unwrap;
for result in results
Multi-Document Sessions
use ;
let mut manager = new;
// Create multiple sessions
let session1 = manager.create_session.unwrap;
let session2 = manager.create_session.unwrap;
// Switch between sessions with shared resources
manager.activate_session.unwrap;
// Edit session1...
manager.activate_session.unwrap;
// Edit session2...
// Sessions share extension registry and memory pools
๐ง Feature Flags
ass-editor uses feature flags to enable optional functionality:
Core Features (enabled by default)
minimal: Core editing with rope, arena, and stream support (no_std compatible)full: All features including std, analysis, plugins, formats, search, concurrency, serde
Optional Features
std: Standard library support (required for most features)analysis: Script analysis and linting integration from ass-coreplugins: Extension system with syntax highlighting and auto-completionsearch-index: FST-based advanced search indexingformats: Import/export support for SRT, WebVTT formatsserde: Serialization support for editor stateconcurrency: Multi-threading and async supportsimd: SIMD acceleration for parsing performancestream: Incremental parsing for large files
Platform Features
nostd: No-standard library support for embedded/WASMdev-benches: Development benchmarking
Usage Examples
# Minimal editor for lightweight integrations
= { = "0.1", = false, = ["minimal"] }
# Full-featured desktop editor
= { = "0.1", = ["full", "simd"] }
# WASM/embedded build
= { = "0.1", = false, = ["minimal", "nostd"] }
# Server-side processing
= { = "0.1", = ["full", "concurrency", "formats"] }
๐๏ธ Architecture
ASS-Editor is built in layers:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Applications โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ EditorSessionManager โ Multi-document Management โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ EditorDocument โ Single Document Editing โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Commands โ Extensions โ Events โ Search โ Validation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ass-core โ
โ (Zero-copy parsing & AST manipulation) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Components
- EditorDocument: Core document wrapper around ass-core::Script
- Commands: Undoable operations (text edits, style changes, event management)
- Extensions: Plugin system for syntax highlighting, auto-completion
- Events: Reactive event system for UI updates and notifications
- Search: FST-based indexing for fast regex queries
- Sessions: Multi-document management with shared resources
๐ฎ Command System
All operations in ass-editor go through a command system that provides:
- Undo/Redo: Every operation is reversible
- Batching: Multiple operations can be grouped atomically
- Progress Tracking: Long operations report progress
- Validation: Commands validate their inputs before execution
Available Commands
| Category | Commands | Description |
|---|---|---|
| Text | Insert, Delete, Replace | Basic text operations |
| Events | Create, Split, Merge, Timing | Event management |
| Styles | Create, Edit, Delete, Clone, Apply | Style operations |
| Tags | Insert, Remove, Replace, Wrap, Parse | Override tag handling |
| Karaoke | Generate, Split, Adjust, Apply | Karaoke timing management |
๐ Search System
ASS-Editor provides powerful search capabilities:
- Text Search: Simple string matching with case sensitivity options
- Regex Search: Full regex support with capture groups
- Tag Search: Search within override tags and parameters
- Event Search: Search by timing, style, or other event properties
- Indexed Search: FST-based indexing for large scripts (1000+ events)
๐งช Testing
Run the comprehensive test suite:
# Unit tests
# Integration tests
# Performance tests
# All features
# Specific feature combinations
๐ Benchmarks
Run performance benchmarks:
# All benchmarks
# Specific benchmarks
Expected performance on typical subtitle files:
| Operation | Target | Typical Result |
|---|---|---|
| Document creation | <5ms | ~2ms |
| Single edit | <1ms | ~0.3ms |
| Undo/redo | <1ms | ~0.2ms |
| Search (indexed) | <10ms | ~3ms |
| Session switch | <100ยตs | ~50ยตs |
๐ค Contributing
Contributions are welcome! Please see the main CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
# Run tests
# Run benchmarks
# Check code quality
๐ License
Licensed under the MIT license.
๐ Related Crates
- ass-core: Zero-copy ASS parsing and analysis
- ass-renderer: High-performance subtitle rendering
- ass-cli: Command-line tools for subtitle processing
- ass-wasm: WebAssembly bindings for browser use
Built with โค๏ธ in Rust for subtitle editors worldwide