Skip to main content

Crate rich_embed

Crate rich_embed 

Source
Expand description

Other programs and web pages inside an intuiTUIve app.

  • terminal runs any program in a pane of the app: a shell, htop, an editor, a terminal browser. Keys, the mouse, pastes and resizes go to the program; its screen is followed by rs-rich-record’s VT emulator (vt100, with rich’s character widths) and drawn in the pane, with scrollback; its exit is a signal and a callback.
  • web_view shows a web page in a pane, with an address bar, and back, forward, reload, the address and the loading state as signals.

Each sits on a trait, as intuiTUIve’s terminals sit on Backend: what runs behind it can be swapped for another implementation, including one the app writes itself.

  • PtyHost starts a program and carries its bytes and size. LocalPty runs one on this machine (a PTY on Unix, ConPTY on Windows); ReplayHost plays bytes back, for tests. An SSH session is a third, passed to terminal_with.
  • WebEngine opens pages, takes input and hands back frames, of cells or of pixels. ProgramEngine (the default) runs a terminal browser (Carbonyl, Browsh, Chawan, w3m) in a pane; ChromeEngine (feature chrome) drives a headless Chrome or Chromium the user installed, over the DevTools protocol; BrowshEngine (feature browsh) reads pages as text from Browsh’s HTTP server. Pixel frames are drawn as coloured half blocks.

No browser ships with this crate, and none is downloaded: each is a program the user chooses and installs.

use intuituive::prelude::*;
use rich_embed::{terminal, web_view_with, ProgramEngine};

fn main() -> std::io::Result<()> {
    App::new(|| {
        let page = web_view_with(ProgramEngine::new("w3m"), "https://example.com");
        row([
            terminal("bash").on_exit(|_, cx| cx.quit()).node().panel("shell"),
            page.node().panel("web"),
        ])
    })
    .run()
}

The panes need a running app: like signal, terminal and web_view are called inside App::new’s closure or a node’s.

Modules§

keys
Keys, the mouse and pastes as the bytes an xterm-compatible terminal sends a program.

Structs§

Command
A program and its arguments, environment and directory, for LocalPty. A string is a program name; an array or a vector is the program and its arguments.
ExitStatus
How a program ended.
LocalPty
A program on this machine, on a PTY (ConPTY on Windows), through portable-pty as rs-rich-record’s tapes run theirs.
PageState
Where the page is and what it is doing.
Pixels
A frame of pixels: width x height, three bytes (red, green, blue) per pixel, rows top to bottom.
ProgramEngine
A terminal browser, named by the app, run in a terminal pane: its screen is the page. Nothing of ours ships with it, and nothing is downloaded; install the browser you want.
ReplayHandle
Feeds a ReplayHost and reads back what it was sent.
ReplayHost
A host that plays bytes back instead of running anything: for tests, demos and recordings. What it plays is given up front (output, exit) or later through a ReplayHandle, which also sees what the pane sent it.
TerminalPane
A terminal pane being built: terminal or terminal_with, then node (or .into()) to place it.
WebHandle
The page’s state as signals, and what the app can ask of it. Copy, like a signal: move it into handlers.
WebView
A web view being built: web_view or web_view_with, then node to place it; handle for its signals and navigation.

Enums§

WebFrame
What an engine draws.
WebInput
Input for the page, in the page’s own cells.

Constants§

BROWSER_VARIABLE
The environment variable ProgramEngine::detect reads first: a browser and its arguments, separated by spaces ("w3m -o confirm_qq=false").
DEFAULT_SCROLLBACK
Rows a pane keeps that scrolled off its top, unless told otherwise.
KNOWN_BROWSERS
Terminal browsers ProgramEngine::detect looks for on PATH, in order: (program, arguments before the address). Carbonyl, a Chromium, takes -- as the end of its options.

Traits§

PtyHost
Starts a program and carries its bytes and its size: what a terminal pane talks to. Every method is called on the app’s thread.
WebEngine
A browser behind a web_view: opens pages, takes input, and hands back frames. Every method is called on the app’s thread; work that takes time happens on the engine’s own threads, which call the Notify when there is a new frame or a new state.

Functions§

half_blocks
pixels scaled to columns x rows cells of half blocks.
terminal
A pane running command on this machine through a LocalPty: a program name, or an array of the program and its arguments.
terminal_with
A pane over any PtyHost: an SSH session, a container, a ReplayHost in a test.
web_view
A web page at url, shown by a terminal browser named by the environment or found on PATH (ProgramEngine::detect). Name one with web_view_with and ProgramEngine::new.
web_view_with
A web page at url, shown by engine.

Type Aliases§

Notify
Called by a host, from any thread, when output arrives or the program exits. It only schedules work: the pane reads the host on the app’s thread.