example: add grid reference traversal example

Add a c-vt-grid-ref example that demonstrates the terminal and grid
reference APIs end-to-end. The example creates a small 10x3 terminal,
writes text with mixed styles via VT sequences, then iterates over
every cell in the active area using ghostty_terminal_grid_ref. For
each cell it extracts the codepoint, and for each row it inspects
the wrap flag and the style bold attribute.

The grid_ref.h defgroup gains a @snippet reference to the new example,
and vt.h gets the corresponding @example entry and @ref listing.
This commit is contained in:
Mitchell Hashimoto
2026-03-19 19:53:52 -07:00
parent 549824842d
commit 93c597ce6b
6 changed files with 180 additions and 0 deletions

View File

@@ -50,6 +50,7 @@
* - @ref c-vt-paste/src/main.c - Paste safety check example
* - @ref c-vt-sgr/src/main.c - SGR parser example
* - @ref c-vt-formatter/src/main.c - Terminal formatter example
* - @ref c-vt-grid-traverse/src/main.c - Grid traversal example using grid refs
*
*/
@@ -84,6 +85,11 @@
* contents as plain text.
*/
/** @example c-vt-grid-traverse/src/main.c
* This example demonstrates how to traverse the entire terminal grid using
* grid refs to inspect cell codepoints, row wrap state, and cell styles.
*/
#ifndef GHOSTTY_VT_H
#define GHOSTTY_VT_H

View File

@@ -35,6 +35,10 @@ extern "C" {
* built to sustain the framerates needed for rendering large screens.
* Use the render state API for that.
*
* ## Example
*
* @snippet c-vt-grid-traverse/src/main.c grid-ref-traverse
*
* @{
*/