Skip to main content

ghostty_sgr_set_params

Function ghostty_sgr_set_params 

Source
pub unsafe extern "C" fn ghostty_sgr_set_params(
    parser: GhosttySgrParser_ptr,
    params: *const u16,
    separators: *const c_char,
    len: usize,
) -> GhosttyResult
Expand description

Set SGR parameters for parsing.

Sets the SGR parameter list to parse. Parameters are the numeric values from a CSI SGR sequence (e.g., for ESC[1;31m, params would be {1, 31}).

The separators array optionally specifies the separator type for each parameter position. Each byte should be either ‘;’ for semicolon or ‘:’ for colon. This is needed for certain color formats that use colon separators (e.g., ESC[4:3m for curly underline). Any invalid separator values are treated as semicolons. The separators array must have the same length as the params array, if it is not NULL.

If separators is NULL, all parameters are assumed to be semicolon-separated.

This function makes an internal copy of the parameter and separator data, so the caller can safely free or modify the input arrays after this call.

After calling this function, the parser is automatically reset and ready to iterate from the beginning.

@param parser The parser handle, must not be NULL @param params Array of SGR parameter values @param separators Optional array of separator characters (‘;’ or ‘:’), or NULL @param len Number of parameters (and separators if provided) @return GHOSTTY_SUCCESS on success, or an error code on failure

@ingroup sgr