ghosttea-vt-sys 0.16.3

Native linking contract for Ghosttea's pinned Ghostty VT core
#ifndef GHOSTTEA_GHOSTTY_SHIM_INTERNAL_H
#define GHOSTTEA_GHOSTTY_SHIM_INTERNAL_H

#include "ghostty_shim.h"

#include <ghostty/vt.h>

typedef struct {
  uint8_t* ptr;
  size_t len;
  size_t cap;
} EgBuffer;

struct EgTerminal {
  GhosttyTerminal terminal;
  GhosttyRenderState render;
  GhosttyRenderStateRowIterator rows;
  GhosttyRenderStateRowCells cells;
  GhosttyKeyEncoder key_encoder;
  GhosttyKeyEvent key_event;
  GhosttyMouseEncoder mouse_encoder;
  GhosttyMouseEvent mouse_event;
  EgBuffer response;
  EgBuffer row;
  EgBuffer clipboard;
  EgBuffer hyperlink_uri;
  EgBuffer hyperlink_id;
  EgBuffer grapheme;
  bool mouse_pressed;
  uint32_t effects;
  // Derived from the embedder's default background; answers CSI ? 996 n and
  // drives mode-2031 reports when a theme change flips it.
  GhosttyColorScheme color_scheme;
};

bool eg_buffer_reserve(EgBuffer* buffer, size_t required);
bool eg_buffer_append(EgBuffer* buffer, const uint8_t* data, size_t len);
// Encodes one Unicode scalar value into `out` and returns its length. A
// surrogate or a value above U+10FFFF is the caller's to rule out.
size_t eg_utf8_encode(uint32_t codepoint, uint8_t out[4]);
void eg_terminal_style(GhosttyStyle source, EgTerminalStyle* out);
// Formats the VT stream that recreates the active screen in another
// terminal: its state alone when `state_only`, else its cells as well.
// Returns the bytes written, the size needed when `out` is too small, or
// SIZE_MAX on failure.
size_t eg_format_recovery(EgTerminal* state,
                          bool state_only,
                          uint8_t* out,
                          size_t cap);
int eg_emit_hyperlink_uri(EgTerminal* state,
                          const GhosttyGridRef* ref,
                          uint32_t row,
                          uint16_t column,
                          uint16_t span,
                          EgHyperlinkUriFn hyperlink_fn,
                          void* userdata);

#endif