Skip to main content

ghostty_paste_encode

Function ghostty_paste_encode 

Source
pub unsafe extern "C" fn ghostty_paste_encode(
    data: *mut c_char,
    data_len: usize,
    bracketed: bool,
    buf: *mut c_char,
    buf_len: usize,
    out_written: *mut usize,
) -> Type
Expand description

Encode paste data for writing to the terminal pty.

This function prepares paste data for terminal input by:

  • Stripping unsafe control bytes (NUL, ESC, DEL, etc.) by replacing them with spaces
  • Wrapping the data in bracketed paste sequences if @p bracketed is true
  • Replacing newlines with carriage returns if @p bracketed is false

The input @p data buffer is modified in place during encoding. The encoded result (potentially with bracketed paste prefix/suffix) is written to the output buffer.

If the output buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE and sets the required size in @p out_written. The caller can then retry with a sufficiently sized buffer.

        GHOSTTY_OUT_OF_SPACE, the required buffer size.
    is too small