Skip to main content

Module paste

Module paste 

Source
Expand description

Utilities for validating paste data safety.

§Example

§Safety Check

use libghostty_vt::paste;

let safe_data = "hello world";
let unsafe_data = "rm -rf /\n";

if paste::is_safe(safe_data) {
    println!("Safe to paste");
}

if !paste::is_safe(unsafe_data) {
    println!("Unsafe! Contains newline");
}

§Encoding

use libghostty_vt::paste;

let mut data = *b"hello\nworld";
let mut buf = [0u8; 64];

if let Ok(len) = paste::encode(&mut data, true, &mut buf) {
    println!("Encoded {len} bytes: {}", buf[..len].escape_ascii());
}

Functions§

encode
Encode paste data for writing to the terminal pty.
is_safe
Check if paste data is safe to paste into the terminal.