GhosttyTerminalController class
Controller for a terminal session backed by a subprocess.
On supported native platforms this prefers a shared PTY session backed by
portable_pty. If that is disabled, it falls back to a regular process.
Unlike the earlier preview-oriented controller, this controller keeps a real VtTerminal alive and derives visible text from formatter snapshots so cursor movement, clears, wrapping, and other VT semantics are preserved.
- Inheritance
-
- Object
- ChangeNotifier
- GhosttyTerminalController
- Implemented types
Constructors
Properties
- activeShellLaunch → GhosttyTerminalShellLaunch?
-
Most recent shell launch metadata associated with this controller.
no setter
- cols → int
-
Current terminal width in cells.
no setteroverride
- defaultShell → String?
-
Optional default shell path for start.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- initialCols → int
-
Initial terminal width in cells before the view reports a real size.
final
- initialRows → int
-
Initial terminal height in cells before the view reports a real size.
final
- isRunning → bool
-
Whether a subprocess is currently active.
no setteroverride
- lineCount → int
-
Number of buffered lines.
no setter
-
lines
→ List<
String> -
Current buffered terminal lines.
no setter
- maxLines → int
-
Maximum retained line count in the formatted terminal snapshot.
final
- maxScrollback → int
-
Maximum terminal scrollback depth retained by VtTerminal.
final
- plainText → String
-
Current formatted plain-text terminal snapshot.
no setter
- preferPty → bool
-
Whether to attempt a native PTY launch when possible.
final
- ptySession → GhosttyTerminalPtySession?
-
Active native PTY session when the shared PTY backend is in use.
no setter
- renderSnapshot → GhosttyTerminalRenderSnapshot?
-
Native Ghostty render-state snapshot for the live visible viewport.
no setter
- revision → int
-
Monotonic value that increments whenever buffered output/state changes.
no setteroverride
- rows → int
-
Current terminal height in cells.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- snapshot → GhosttyTerminalSnapshot
-
Current styled terminal snapshot used by GhosttyTerminalView.
no setter
- terminal → VtTerminal
-
Live VT terminal state backing this controller.
no setter
- title → String
-
Terminal title (updated from OSC commands when available).
no setteroverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
appendDebugOutput(
String text) → void - Injects decoded terminal output directly into the VT model.
-
clear(
) → void - Clears terminal contents and scrollback while preserving dimensions.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
formatTerminal(
{GhosttyFormatterFormat emit = GhosttyFormatterFormat.GHOSTTY_FORMATTER_FORMAT_PLAIN, bool unwrap = false, bool trim = true, VtFormatterTerminalExtra extra = const VtFormatterTerminalExtra()}) → String - Returns a formatted terminal snapshot using the requested formatter mode.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
resize(
{required int cols, required int rows}) → void -
Resizes the VT grid.
override
-
restartLaunch(
GhosttyTerminalShellLaunch launch) → Future< void> - Restarts the controller using a resolved launch plan.
-
sendKey(
{required GhosttyKey key, GhosttyKeyAction action = GhosttyKeyAction.GHOSTTY_KEY_ACTION_PRESS, int mods = 0, int consumedMods = 0, bool composing = false, String utf8Text = '', int unshiftedCodepoint = 0}) → bool - Encodes and sends a key event using Ghostty's keyboard protocol rules.
-
start(
{String? shell, List< String> arguments = const <String>[], Map<String, String> ? environment}) → Future<void> - Starts a terminal subprocess.
-
startLaunch(
GhosttyTerminalShellLaunch launch) → Future< void> - Starts a resolved launch plan and stores its metadata on the controller.
-
startShellProfile(
{required GhosttyTerminalShellProfile profile, Map< String, String> ? platformEnvironment, Map<String, String> environmentOverrides = const <String, String>{'TERM' : 'xterm-256color'}}) → Future<GhosttyTerminalShellLaunch?> - Starts one of the shared shell profiles and returns the resolved launch.
-
stop(
) → Future< void> - Stops the subprocess if running.
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
String text, {bool sanitizePaste = false}) → bool -
Writes text to terminal stdin.
override
-
writeBytes(
List< int> bytes) → bool -
Writes already-encoded bytes directly to terminal stdin.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited