GhosttyVt class final

High-level helpers and wrappers on top of libghostty-vt FFI bindings.

Provides factory methods for OSC/SGR parsers, terminals, formatters, key events, and key encoders, as well as paste-safety checks.

// Create a terminal and formatter
final terminal = GhosttyVt.newTerminal(cols: 80, rows: 24);
final formatter = terminal.createFormatter(
  const VtFormatterTerminalOptions(
    emit: GhosttyFormatterFormat.GHOSTTY_FORMATTER_FORMAT_PLAIN,
    trim: true,
  ),
);
terminal.write('Hello');
print(formatter.formatText());
formatter.close();
terminal.close();

// Check paste safety
if (GhosttyVt.isPasteSafe(clipboardText)) {
  terminal.write(clipboardText);
}

// Create a key encoder
final encoder = GhosttyVt.newKeyEncoder();
final event = GhosttyVt.newKeyEvent();
// ... configure event ...
final bytes = encoder.encode(event);
event.close();
encoder.close();

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

encodeFocus(GhosttyFocusEvent event) Uint8List
Encodes a terminal focus event into bytes.
encodeModeReport(VtMode mode, GhosttyModeReportState state) Uint8List
Encodes a DECRPM/ANSI mode report into bytes.
encodeSizeReport(GhosttySizeReportStyle style, VtSizeReportSize size) Uint8List
Encodes a terminal size report into bytes.
isPasteSafe(String text) bool
Returns whether text is safe to paste into a terminal.
isPasteSafeBytes(List<int> bytes) bool
Returns whether raw UTF-8 bytes are safe to paste into a terminal.
newKeyEncoder() VtKeyEncoder
Creates a key encoder object.
newKeyEvent() VtKeyEvent
Creates a key event object.
newMouseEncoder() VtMouseEncoder
Creates a mouse encoder object.
newMouseEvent() VtMouseEvent
Creates a mouse event object.
newOscParser() VtOscParser
Creates a streaming OSC parser.
newSgrParser() VtSgrParser
Creates an SGR parser.
newTerminal({required int cols, required int rows, int maxScrollback = 10_000}) VtTerminal
Creates a terminal emulator instance.