Skip to main content

Module Terminal

Module Terminal 

Source
Expand description

§Terminal handlers

Two related responsibilities:

  • Terminal* - operate on PTYs that are already registered via the TerminalProvider trait. Every method takes a provider-assigned terminal_id (u64).
  • LocalPTY* - read-only platform queries that don’t touch any registered PTY: discover available shells, default shell, and the current process environment.

Layout (one export per file, file name = identity):

  • TerminalCreate::TerminalCreate, TerminalSendText::TerminalSendText, TerminalDispose::TerminalDispose, TerminalShow::TerminalShow, TerminalHide::TerminalHide.
  • LocalPTYGetProfiles::LocalPTYGetProfiles, LocalPTYGetDefaultShell::LocalPTYGetDefaultShell, LocalPTYGetEnvironment::LocalPTYGetEnvironment.

Modules§

LocalPTYGetDefaultShell
Pick the system default shell. Unix: $SHELL, then probe /bin/{zsh,bash,sh}. Windows: PowerShell 7 if installed, else stock Windows PowerShell. Used by Wind’s “Open Default Terminal” command and by extensions that spawn unparented shells.
LocalPTYGetEnvironment
Snapshot the Mountain process environment as a HashMap. Inherited by every PTY spawned through TerminalCreate. Includes the keys merged in by EnhanceShellEnvironment at boot, so a Finder-launched .app exposes the user’s interactive shell PATH / NVM_DIR / HOMEBREW_PREFIX / … to terminals it spawns.
LocalPTYGetProfiles
Discover available terminal profiles. Probes every well- known shell location plus /etc/shells (Unix) or known Windows install paths. The first existing match flags isDefault=true; on Unix the user’s $SHELL wins.
TerminalCreate
Spawn a new PTY through TerminalProvider::CreateTerminal. Options carries shell path, args, cwd, env, name. Returns a provider-assigned terminal id (u64) which Wind uses for every subsequent send/show/dispose call.
TerminalDispose
Close a PTY, kill its child, and drop the entry from the provider’s terminal registry. Idempotent - disposing an already-disposed id surfaces as a logged warning, not an error.
TerminalHide
Hide a terminal panel without disposing the underlying PTY. The child process keeps running; subsequent TerminalShow reopens the same session. Mirrors vscode.Terminal.hide().
TerminalSendText
Pipe text into a terminal’s PTY stdin. Used both for direct key forwarding (xterm.js → Mountain → PTY) and for programmatic input (vscode.window.terminals[…].sendText).
TerminalShow
Bring a terminal to the foreground in the panel. When PreserveFocus is true, the active editor keeps keyboard focus (mirrors vscode.Terminal.show(preserveFocus)).