WinptyShellBackend class
A ShellBackend that runs interactive shells on a real Windows
pseudo-console allocated through libwinpty (winpty.dll, bundled with Git
for Windows) via dart:ffi.
It is the Windows counterpart of `ScriptPtyShellBackend`, which is
POSIX-only. Like that backend it decorates a fallback (the pipe-based
ProcessShellBackend) and delegates to it when:
- the request carries no
PtySpec(e.g.execmode), or - the platform is not Windows, or
winpty.dll/ a usable Git bash cannot be found, or- a spawn fails — after the first such failure the winpty path is disabled for the process and every session uses the pipe fallback.
The winpty CLI is deliberately not used: from pipe-backed stdio it derives
geometry via ioctl(STDIN, TIOCGWINSZ), gets 0×0 and asserts before the child
starts. Calling the library directly with an explicit initial size avoids it.
- Implemented types
Constructors
-
WinptyShellBackend({required ShellBackend fallback, String? defaultShell, String? workingDirectory, Map<
String, String> baseEnvironment = const {}, bool allowCommand(ShellRequest request)?, void onWarning(String message)?}) -
Creates a winpty-based PTY backend decorating
fallback.
Properties
- allowCommand → bool Function(ShellRequest request)?
-
Optional guard; when it returns
falsethe session is refused.final -
baseEnvironment
→ Map<
String, String> -
Extra environment overlaid on the inherited environment for every session.
final
- defaultShell → String
-
The interactive shell (bash) winpty wraps; resolved on Windows.
final
- fallback → ShellBackend
-
Backend used for exec sessions and whenever the winpty path is unavailable.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onWarning → void Function(String message)?
-
Optional sink for a one-time warning when the winpty path is disabled.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- workingDirectory → String?
-
Working directory applied when a request does not specify one.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
ShellRequest request) → Future< ShellSession> -
Starts a session for
request, returning a live ShellSession.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited