libghostty: add cpp-vt-stream example and fix C++ header compatibility

Add a cpp-vt-stream example that verifies libghostty headers compile
cleanly in C++ mode. The example is a simplified C++ port of
c-vt-stream.

The headers used the C idiom `typedef struct Foo* Foo` for opaque
handles, which is invalid in C++ because struct tags and typedefs
share the same namespace. Fix all 12 opaque handle typedefs across the
headers to use a distinct struct tag with an Impl suffix, e.g.
`typedef struct GhosttyTerminalImpl* GhosttyTerminal`. This is a
source-compatible change for existing C consumers since the struct
tags were never referenced directly.
This commit is contained in:
Mitchell Hashimoto
2026-03-28 18:36:23 -07:00
parent 741f1d129a
commit 1fcd80daab
13 changed files with 146 additions and 12 deletions

View File

@@ -111,7 +111,7 @@ typedef struct {
*
* @ingroup formatter
*/
typedef struct GhosttyFormatter* GhosttyFormatter;
typedef struct GhosttyFormatterImpl* GhosttyFormatter;
/**
* Options for creating a terminal formatter.

View File

@@ -22,7 +22,7 @@
*
* @ingroup key
*/
typedef struct GhosttyKeyEncoder *GhosttyKeyEncoder;
typedef struct GhosttyKeyEncoderImpl *GhosttyKeyEncoder;
/**
* Kitty keyboard protocol flags.

View File

@@ -21,7 +21,7 @@
*
* @ingroup key
*/
typedef struct GhosttyKeyEvent *GhosttyKeyEvent;
typedef struct GhosttyKeyEventImpl *GhosttyKeyEvent;
/**
* Keyboard input event types.

View File

@@ -23,7 +23,7 @@
*
* @ingroup mouse
*/
typedef struct GhosttyMouseEncoder *GhosttyMouseEncoder;
typedef struct GhosttyMouseEncoderImpl *GhosttyMouseEncoder;
/**
* Mouse tracking mode.

View File

@@ -20,7 +20,7 @@
*
* @ingroup mouse
*/
typedef struct GhosttyMouseEvent *GhosttyMouseEvent;
typedef struct GhosttyMouseEventImpl *GhosttyMouseEvent;
/**
* Mouse event action type.

View File

@@ -21,7 +21,7 @@
*
* @ingroup osc
*/
typedef struct GhosttyOscParser *GhosttyOscParser;
typedef struct GhosttyOscParserImpl *GhosttyOscParser;
/**
* Opaque handle to a single OSC command.
@@ -31,7 +31,7 @@ typedef struct GhosttyOscParser *GhosttyOscParser;
*
* @ingroup osc
*/
typedef struct GhosttyOscCommand *GhosttyOscCommand;
typedef struct GhosttyOscCommandImpl *GhosttyOscCommand;
/** @defgroup osc OSC Parser
*

View File

@@ -86,21 +86,21 @@ extern "C" {
*
* @ingroup render
*/
typedef struct GhosttyRenderState* GhosttyRenderState;
typedef struct GhosttyRenderStateImpl* GhosttyRenderState;
/**
* Opaque handle to a render-state row iterator.
*
* @ingroup render
*/
typedef struct GhosttyRenderStateRowIterator* GhosttyRenderStateRowIterator;
typedef struct GhosttyRenderStateRowIteratorImpl* GhosttyRenderStateRowIterator;
/**
* Opaque handle to render-state row cells.
*
* @ingroup render
*/
typedef struct GhosttyRenderStateRowCells* GhosttyRenderStateRowCells;
typedef struct GhosttyRenderStateRowCellsImpl* GhosttyRenderStateRowCells;
/**
* Dirty state of a render state after update.

View File

@@ -55,7 +55,7 @@ extern "C" {
*
* @ingroup sgr
*/
typedef struct GhosttySgrParser* GhosttySgrParser;
typedef struct GhosttySgrParserImpl* GhosttySgrParser;
/**
* SGR attribute tags.

View File

@@ -159,7 +159,7 @@ extern "C" {
*
* @ingroup terminal
*/
typedef struct GhosttyTerminal* GhosttyTerminal;
typedef struct GhosttyTerminalImpl* GhosttyTerminal;
/**
* Terminal initialization options.