Skip to main content

ghostty_mode_report_encode

Function ghostty_mode_report_encode 

Source
pub unsafe extern "C" fn ghostty_mode_report_encode(
    mode: GhosttyMode,
    state: GhosttyModeReportState,
    buf: *mut c_char,
    buf_len: usize,
    out_written: *mut usize,
) -> GhosttyResult
Expand description

Encode a DECRPM (DEC Private Mode Report) response sequence.

Writes a mode report escape sequence into the provided buffer. The generated sequence has the form:

  • DEC private mode: CSI ? Ps1 ; Ps2 $ y
  • ANSI mode: CSI Ps1 ; Ps2 $ y

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

@param mode The mode identifying the mode to report on @param state The report state for this mode @param buf Output buffer to write the encoded sequence into (may be NULL) @param buf_len Size of the output buffer in bytes @param[out] out_written On success, the number of bytes written. On GHOSTTY_OUT_OF_SPACE, the required buffer size. @return GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer is too small