Skip to content

Ghostty Integration

RoyalTerminal uses Ghostty in two different ways: as a high-level native VT and rendering implementation, and as a low-level public wrapper library for hosts that want direct access to the Ghostty C ABI from .NET. The second role is what RoyalTerminal.GhosttySharp exists for.

Ghostty-compatible shaders

RoyalTerminal also supports a Ghostty/Shadertoy-style shader compatibility mode in the managed Skia renderer. This is intentionally separate from the native Ghostty VT binding and from Ghostty renderer interop.

Use TerminalShaderLanguage.GhosttyShadertoy when you have a single-pass mainImage shader that samples iChannel0:

csharp
using RoyalTerminal.Shaders;

Terminal.ShaderSources =
[
    new TerminalShaderSource(
        "Ghostty Compatible Shader",
        ghosttyStyleSource,
        TerminalShaderLanguage.GhosttyShadertoy)
];

The shader runs as a RoyalTerminal framebuffer post-process effect, so it works regardless of whether the active VT engine is managed or Ghostty-backed. Native Ghostty renderer custom-shader injection is not part of the current interop path.

See Ghostty/Shadertoy Shader Compatibility for the supported uniforms, source shape, and limitations.

Start with the high-level wrappers

If you want Ghostty behavior inside RoyalTerminal, you usually begin with the managed wrapper types instead of the raw ABI mirror.

TypePurpose
GhosttyTerminalManaged lifetime wrapper for the native terminal.
GhosttyRenderStateManaged wrapper for render-state extraction from the native terminal.
GhosttyFormatterScreenOptionsScreen-level formatter options.
GhosttyFormatterExtraOptionsFormatter extras for palette, modes, tabstops, keyboard state, and screen details.
GhosttyFormatterOptionsHigh-level formatter request model.
GhosttyFormatterFormatter for exporting terminal state.
GhosttyKeyEncoderNative-backed key encoder.
GhosttyKeyEventMutable key event payload.
GhosttyMouseEncoderNative-backed mouse encoder.
GhosttyMouseEventMutable mouse event payload.
GhosttyPasteStatic helper for paste encoding.
GhosttySelectionManaged selection value used by formatters and helpers.
GhosttyKittyGraphicsManaged helper for Kitty graphics extraction.
GhosttyKittyGraphicsImageManaged Kitty image snapshot.
GhosttyKittyGraphicsPlacementIteratorManaged iterator over Kitty placements.
GhosttySysStatic system helper surface.
GhosttyVtHelpersStatic helper surface for protocol encoders and build info.
GhosttyBuildInfoSnapshotFull native build metadata snapshot.
GhosttyBuildFeaturesCompact native build capability snapshot.
TerminalBufferManaged helper for reading terminal content.
TerminalDataProcessorStatic helper for processing terminal data through Ghostty-backed models.
NativeLibraryLoaderNative library loader for libghostty-vt.

These are the types used by RoyalTerminal itself when it wants native VT behavior without forcing consumers to work directly against raw pointers and C structs.

The raw VT mirror is also public

Under those wrappers, GhosttyVtNative exposes the Ghostty VT ABI directly. This is not the right layer for most applications, but it is the right layer for advanced interop, diagnostics, or custom wrappers.

Root VT exports

GhosttyVtNative, GhosttyResult, GhosttyVtKeyAction, GhosttyVtKey, GhosttyVtMods, GhosttyOscCommandType, GhosttyOscCommandData, GhosttySgrAttributeTag, GhosttySgrUnderline, GhosttySgrUnknown, GhosttySgrAttributeValue, GhosttySgrAttribute, GhosttyColorRgb

Core protocol and build-info exports

GhosttyString, GhosttyMode, GhosttyModeReportState, GhosttyOptimizeMode, GhosttyBuildInfoData, GhosttyFocusEvent, GhosttySizeReportStyle, GhosttySizeReportSize, GhosttyDeviceAttributesPrimary, GhosttyDeviceAttributesSecondary, GhosttyDeviceAttributesTertiary, GhosttyDeviceAttributes, GhosttyPointCoordinate, GhosttyPointTag, GhosttyPoint

Formatter exports

GhosttyFormatterFormat, GhosttyFormatterScreenExtra, GhosttyFormatterTerminalExtra, GhosttyFormatterTerminalOptions

Input and pointer exports

GhosttyKittyKeyFlags, GhosttyOptionAsAlt, GhosttyKeyEncoderOption, GhosttyMouseAction, GhosttyMouseButtonId, GhosttyMousePosition, GhosttyMouseTrackingMode, GhosttyMouseFormat, GhosttyMouseEncoderSize, GhosttyMouseEncoderOption

Kitty graphics exports

GhosttyKittyGraphicsData, GhosttyKittyGraphicsPlacementData, GhosttyKittyPlacementLayer, GhosttyKittyGraphicsPlacementIteratorOption, GhosttyKittyImageFormat, GhosttyKittyImageCompression, GhosttyKittyGraphicsImageData

Render-state exports

GhosttyRenderStateDirty, GhosttyRenderStateCursorVisualStyle, GhosttyRenderStateData, GhosttyRenderStateOption, GhosttyRenderStateRowData, GhosttyRenderStateRowOption, GhosttyRenderStateRowCellsData, GhosttyRenderStateColors

Screen exports

GhosttyStyleColorTag, GhosttyStyleColorValue, GhosttyStyleColor, GhosttyStyle, GhosttyGridRef, GhosttyCellContentTag, GhosttyCellWide, GhosttyCellSemanticContent, GhosttyCellData, GhosttyRowSemanticPrompt, GhosttyRowData

Selection, system, and terminal exports

GhosttySelectionRange, GhosttyAllocatorVtable, GhosttyAllocator, GhosttySysImage, GhosttySysDecodePngCallback, GhosttySysOption, GhosttyTerminalOptions, GhosttyTerminalScrollViewportTag, GhosttyTerminalScrollViewportValue, GhosttyTerminalScrollViewport, GhosttyTerminalScreen, GhosttyTerminalScrollbar, GhosttyTerminalBellCallback, GhosttyTerminalWritePtyCallback, GhosttyTerminalTitleChangedCallback, GhosttyTerminalEnquiryCallback, GhosttyTerminalXtversionCallback, GhosttyTerminalSizeCallback, GhosttyTerminalColorSchemeCallback, GhosttyTerminalDeviceAttributesCallback, GhosttyTerminalOption, GhosttyTerminalData

Runtime enums, structs, and callbacks

The public Ghostty surface also includes the broader runtime enum and action/config mirror types that are not part of GhosttyVtNative itself.

Runtime enums

GhosttyPlatform, GhosttyClipboard, GhosttyClipboardRequest, GhosttyMouseState, GhosttyMouseButton, GhosttyMouseMomentum, GhosttyColorScheme, GhosttyMods, GhosttyBindingFlags, GhosttyInputAction, GhosttyKey, GhosttyInputTriggerTag, GhosttyBuildMode, GhosttyPointTag, GhosttyPointCoord, GhosttySurfaceContext, GhosttyTargetTag, GhosttySplitDirection, GhosttyGotoSplit, GhosttyGotoWindow, GhosttyResizeSplitDirection, GhosttyGotoTab, GhosttyFullscreen, GhosttyFloatWindow, GhosttySecureInput, GhosttyInspectorAction, GhosttyQuitTimer, GhosttyReadonly, GhosttyPromptTitle, GhosttyMouseShape, GhosttyMouseVisibility, GhosttyRendererHealth, GhosttyColorKind, GhosttyOpenUrlKind, GhosttyCloseTabMode, GhosttyProgressState, GhosttyQuickTerminalSizeTag, GhosttyKeyTableTag, GhosttyActionTag, GhosttyIpcTargetTag, GhosttyIpcActionTag

Runtime structs

GhosttyClipboardContent, GhosttyInputKey, GhosttyInputTriggerKey, GhosttyInputTrigger, GhosttyCommand, GhosttyInfo, GhosttyDiagnostic, GhosttyString, GhosttyText, GhosttyPoint, GhosttySelection, GhosttyEnvVar, GhosttyPlatformMacOS, GhosttyPlatformIOS, GhosttyPlatformUnion, GhosttySurfaceConfig, GhosttySurfaceSize, GhosttyConfigColor, GhosttyConfigColorList, GhosttyConfigCommandList, GhosttyConfigPalette, GhosttyQuickTerminalSizeValue, GhosttyQuickTerminalSize, GhosttyConfigQuickTerminalSize, GhosttyTargetUnion, GhosttyTarget, GhosttyResizeSplit, GhosttyMoveTab, GhosttySizeLimit, GhosttyInitialSize, GhosttyCellSize, GhosttyDesktopNotification, GhosttySetTitle, GhosttyPwd, GhosttyMouseOverLink, GhosttyKeySequence, GhosttyKeyTableActivate, GhosttyKeyTableValue, GhosttyKeyTable, GhosttyColorChange, GhosttyConfigChange, GhosttyReloadConfig, GhosttyOpenUrl, GhosttyChildExited, GhosttyProgressReport, GhosttyCommandFinished, GhosttyStartSearch, GhosttySearchTotal, GhosttySearchSelected, GhosttyScrollbar, GhosttyActionValue, GhosttyAction, GhosttyRuntimeConfig

Runtime delegates

GhosttyWakeupCallback, GhosttyActionCallback, GhosttyReadClipboardCallback, GhosttyConfirmReadClipboardCallback, GhosttyWriteClipboardCallback, GhosttyCloseSurfaceCallback

Which layer should you choose?

Use the layers in this order:

  1. stay in the main RoyalTerminal packages if all you need is a terminal control, VT processor, or renderer
  2. use the high-level GhosttySharp wrappers if you need native terminal behavior directly
  3. drop to GhosttyVtNative and the runtime mirror types only if you are building new interop or diagnostics on top of Ghostty itself

That keeps the common path small while still preserving the full native escape hatch for advanced consumers.

MIT Licensed