Expand description
§Cockpit
A terminal multiplexer library for Ratatui applications.
Cockpit enables running multiple OS processes in split panes with crash isolation. Each pane runs in its own PTY (pseudo-terminal), so if one process crashes, the others continue running unaffected.
§Features
- PTY Management: Spawn processes in pseudo-terminals using
portable-pty - Terminal Emulation: Full VT100/ANSI terminal emulation via
vt100 - Automatic Layout: Side-by-side pane arrangement (max 4 panes)
- Crash Isolation: Each process runs independently
- Ratatui Integration: Widgets for rendering panes
§Example
use cockpit::{PaneManager, SpawnConfig};
use ratatui::layout::Rect;
#[tokio::main]
async fn main() -> cockpit::Result<()> {
// Create a pane manager
let mut manager = PaneManager::new();
// Set terminal size (get from your terminal)
let term_size = Rect::new(0, 0, 120, 40);
manager.set_terminal_size(term_size);
// Spawn panes - layout is automatic!
manager.spawn(SpawnConfig::new_shell())?; // Full screen
manager.spawn(SpawnConfig::new_shell())?; // Now 50/50 side-by-side
// Send input to the focused pane
manager.send_input(b"echo hello\r").await?;
Ok(())
}Structs§
- Cockpit
Widget - Widget for rendering the entire multiplexer.
- Confirm
Dialog - A confirmation dialog widget.
- Dialog
State - State for the confirm dialog.
- GitUser
Plugin - Plugin that displays the current git user (name and email).
- Manager
Config - Configuration for the pane manager.
- Pane
Handle - Public handle for controlling a pane.
- PaneId
- Unique identifier for a pane.
- Pane
Manager - Central manager for all panes.
- Pane
Size - Pane dimensions in rows and columns.
- Pane
Widget - Widget for rendering a single pane’s terminal content.
- Plugin
Config - Configuration for plugin behavior.
- Plugin
Context - Context provided to plugins for accessing cockpit state.
- Plugin
Id - Unique identifier for a plugin instance.
- Plugin
Registry - Registry for managing plugins.
- Screen
Cell - A single cell in the terminal screen.
- Screen
Snapshot - A snapshot of the terminal screen state.
- Spawn
Config - Configuration for spawning a new pane.
- Status
BarConfig - Configuration for the status bar.
- Status
BarSegment - A segment of text for the status bar.
- Status
BarWidget - Status bar widget for rendering at the top of the terminal.
- SubPane
Widget - Widget for rendering an empty bordered sub-pane.
Enums§
- Dialog
Button - Which button is selected in a confirm dialog.
- Error
- Errors that can occur in cockpit operations.
- Pane
Event - Events emitted by panes.
- Pane
State - Current state of a pane’s process.
- Plugin
Error - Errors that can occur in plugin operations.
- Screen
Color - Terminal color representation.
Constants§
- STATUS_
BAR_ HEIGHT - The height of the status bar (always 1 row).
Traits§
- Plugin
- The core plugin trait.
Type Aliases§
- Plugin
Result - Result type for plugin operations.
- Result
- Result type alias using cockpit’s Error type.