![]() |
libghostty
|
A grid reference is a resolved reference to a specific cell position in the terminal's internal page structure. Obtain a grid reference from ghostty_terminal_grid_ref(), then extract the cell or row via ghostty_grid_ref_cell() and ghostty_grid_ref_row().
A grid reference is only valid until the next update to the terminal instance. There is no guarantee that a grid reference will remain valid after ANY operation, even if a seemingly unrelated part of the grid is changed, so any information related to the grid reference should be read and cached immediately after obtaining the grid reference.
This API is not meant to be used as the core of render loop. It isn't built to sustain the framerates needed for rendering large screens. Use the render state API for that.
Functions | |
| GHOSTTY_API GhosttyResult | ghostty_grid_ref_cell (const GhosttyGridRef *ref, GhosttyCell *out_cell) |
| GHOSTTY_API GhosttyResult | ghostty_grid_ref_row (const GhosttyGridRef *ref, GhosttyRow *out_row) |
| GHOSTTY_API GhosttyResult | ghostty_grid_ref_graphemes (const GhosttyGridRef *ref, uint32_t *buf, size_t buf_len, size_t *out_len) |
| GHOSTTY_API GhosttyResult | ghostty_grid_ref_hyperlink_uri (const GhosttyGridRef *ref, uint8_t *buf, size_t buf_len, size_t *out_len) |
| GHOSTTY_API GhosttyResult | ghostty_grid_ref_style (const GhosttyGridRef *ref, GhosttyStyle *out_style) |
Data Structures | |
| struct | GhosttyGridRef |
| GHOSTTY_API GhosttyResult ghostty_grid_ref_cell | ( | const GhosttyGridRef * | ref, |
| GhosttyCell * | out_cell ) |
Get the cell from a grid reference.
| ref | Pointer to the grid reference | |
| [out] | out_cell | On success, set to the cell at the ref's position (may be NULL) |
| GHOSTTY_API GhosttyResult ghostty_grid_ref_graphemes | ( | const GhosttyGridRef * | ref, |
| uint32_t * | buf, | ||
| size_t | buf_len, | ||
| size_t * | out_len ) |
Get the grapheme cluster codepoints for the cell at the grid reference's position.
Writes the full grapheme cluster (the cell's primary codepoint followed by any combining codepoints) into the provided buffer. If the cell has no text, out_len is set to 0 and GHOSTTY_SUCCESS is returned.
If the buffer is too small (or NULL), the function returns GHOSTTY_OUT_OF_SPACE and writes the required number of codepoints to out_len. The caller can then retry with a sufficiently sized buffer.
| ref | Pointer to the grid reference | |
| buf | Output buffer of uint32_t codepoints (may be NULL) | |
| buf_len | Number of uint32_t elements in the buffer | |
| [out] | out_len | On success, the number of codepoints written. On GHOSTTY_OUT_OF_SPACE, the required buffer size in codepoints. |
| GHOSTTY_API GhosttyResult ghostty_grid_ref_hyperlink_uri | ( | const GhosttyGridRef * | ref, |
| uint8_t * | buf, | ||
| size_t | buf_len, | ||
| size_t * | out_len ) |
Get the hyperlink URI for the cell at the grid reference's position.
Writes the URI bytes into the provided buffer. If the cell has no hyperlink, out_len is set to 0 and GHOSTTY_SUCCESS is returned.
If the buffer is too small (or NULL), the function returns GHOSTTY_OUT_OF_SPACE and writes the required number of bytes to out_len. The caller can then retry with a sufficiently sized buffer.
| ref | Pointer to the grid reference | |
| buf | Output buffer for the URI bytes (may be NULL) | |
| buf_len | Size of the output buffer in bytes | |
| [out] | out_len | On success, the number of bytes written. On GHOSTTY_OUT_OF_SPACE, the required buffer size in bytes. |
| GHOSTTY_API GhosttyResult ghostty_grid_ref_row | ( | const GhosttyGridRef * | ref, |
| GhosttyRow * | out_row ) |
Get the row from a grid reference.
| ref | Pointer to the grid reference | |
| [out] | out_row | On success, set to the row at the ref's position (may be NULL) |
| GHOSTTY_API GhosttyResult ghostty_grid_ref_style | ( | const GhosttyGridRef * | ref, |
| GhosttyStyle * | out_style ) |
Get the style of the cell at the grid reference's position.
| ref | Pointer to the grid reference | |
| [out] | out_style | On success, set to the cell's style (may be NULL) |