Skip to main content

Crate cockpit

Crate cockpit 

Source
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§

CockpitWidget
Widget for rendering the entire multiplexer.
ConfirmDialog
A confirmation dialog widget.
DialogState
State for the confirm dialog.
GitUserPlugin
Plugin that displays the current git user (name and email).
ManagerConfig
Configuration for the pane manager.
PaneHandle
Public handle for controlling a pane.
PaneId
Unique identifier for a pane.
PaneManager
Central manager for all panes.
PaneSize
Pane dimensions in rows and columns.
PaneWidget
Widget for rendering a single pane’s terminal content.
PluginConfig
Configuration for plugin behavior.
PluginContext
Context provided to plugins for accessing cockpit state.
PluginId
Unique identifier for a plugin instance.
PluginRegistry
Registry for managing plugins.
ScreenCell
A single cell in the terminal screen.
ScreenSnapshot
A snapshot of the terminal screen state.
SpawnConfig
Configuration for spawning a new pane.
StatusBarConfig
Configuration for the status bar.
StatusBarSegment
A segment of text for the status bar.
StatusBarWidget
Status bar widget for rendering at the top of the terminal.
SubPaneWidget
Widget for rendering an empty bordered sub-pane.

Enums§

DialogButton
Which button is selected in a confirm dialog.
Error
Errors that can occur in cockpit operations.
PaneEvent
Events emitted by panes.
PaneState
Current state of a pane’s process.
PluginError
Errors that can occur in plugin operations.
ScreenColor
Terminal color representation.

Constants§

STATUS_BAR_HEIGHT
The height of the status bar (always 1 row).

Traits§

Plugin
The core plugin trait.

Type Aliases§

PluginResult
Result type for plugin operations.
Result
Result type alias using cockpit’s Error type.