Skip to content

Terminal

Embeds the retained Ghostty terminal surface and reports process lifecycle events.

#Import

Import Terminal from quickgui.

use quickgui::*;

#Usage

let terminal = Terminal::spawn(
    TerminalOptions {
        program: Some("/bin/zsh".into()),
        arguments: vec!["-l".into()],
        working_directory: Some(directory.into()),
        ..TerminalOptions::default()
    },
    cx.window_invalidator(),
)?;
terminal.element(cx)

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

Terminal

View source
pub fn spawn( options: TerminalOptions, invalidator: WindowInvalidator, ) -> Result<Self, TerminalError>

Start a PTY and terminal-emulation worker. Process-launch failures are published through [`TerminalSnapshot::status`] so a declarative terminal remains mounted and informative.

snapshotpub fn snapshot(&self) -> Arc<TerminalSnapshot>—

Read the latest complete terminal frame without locking the emulator or PTY.

pub fn snapshot(&self) -> Arc<TerminalSnapshot>
View source
writepub fn write(&self, bytes: impl AsRef<[u8]>) -> bool—

Write raw bytes to the PTY. Prefer normal keyboard events or [`Self::paste`] for user input.

pub fn write(&self, bytes: impl AsRef<[u8]>) -> bool
View source
pastepub fn paste(&self, value: impl Into<String>) -> bool—

Encode text using libghostty's bracketed-paste and control-byte rules, then write it.

pub fn paste(&self, value: impl Into<String>) -> bool
View source
scroll_rowspub fn scroll_rows(&self, rows: isize) -> bool—

Scroll libghostty's retained viewport by terminal rows. Negative values move into history.

pub fn scroll_rows(&self, rows: isize) -> bool
View source
resizepub fn resize(&self, cols: u16, rows: u16, cell_width_px: u32, cell_height_px: u32) -> bool—

Resize both the PTY and libghostty viewport, coalescing identical measurements.

pub fn resize(&self, cols: u16, rows: u16, cell_width_px: u32, cell_height_px: u32) -> bool
View source

Terminal::element

View source
pub fn element<V: 'static>( &self, id: impl Into<ElementId>, style: TerminalStyle, cx: &mut ViewContext<'_, V>, ) -> Element

Build the complete retained terminal surface, including focus, keyboard, paste, scroll, and exact bounds-to-PTY resize behavior.