Skip to main content

terminalAPI

MS Code Extension API


MS Code Extension API / core/extensionAPI/modules/window/terminalAPI

core/extensionAPI/modules/window/terminalAPI

Type Aliases

WrappedTerminal

WrappedTerminal = ReturnType<typeof wrapTerminal>

Defined in: core/extensionAPI/modules/window/terminalAPI.ts:134

Functions

createTerminalAPI()

createTerminalAPI(): object

Defined in: core/extensionAPI/modules/window/terminalAPI.ts:139

Factory function creating the structural ecosystem layout Terminal window management API.

Returns

createTerminal

createTerminal: (options?) => object

Spawns a discrete, configurable terminal workspace execution layer instance window.

Parameters
options?

string | { cwd?: string; name?: string; shell?: string; show?: boolean; }

Pass a simple title string layout name or configuration properties directly.

string


Type Literal

{ cwd?: string; name?: string; shell?: string; show?: boolean; }

Pass a simple title string layout name or configuration properties directly.

cwd?

string

The target absolute working directory file path workspace root directory.

name?

string

The visual display label mapping header title.

shell?

string

Overriding path specification targeting alternative binary shells.

show?

boolean

Dictates whether layout viewports instantly focus-shift elements into place.

Returns

The public descriptor interface structure handles matching instance hooks.

clear

clear: () => void

Requests the underlying stream engine to clear terminal screen buffers. Employs transient buffering intervals if invoked while the system state is spawning.

Returns

void

dispose

dispose: () => void

Terminates the stream, triggers standard OS signaling cleanup traps, and releases store allocation.

Returns

void

hide

hide: () => void

Hides the terminal panel if it is currently focused, switching view hierarchies.

Returns

void

id

id: string = instance.id

The unique identifier assigned to this terminal session.

name

name: string = instance.title

The human-readable display name of the terminal tab.

sendText

sendText: (text, addNewLine?) => void

Evaluates and transmits a string command payload to the underlying shell process instance. Features built-in sequential buffering delays to gracefully support lazy booting processes.

Parameters
text

string

The raw text command string payload.

addNewLine?

boolean = true

Appends a carriage return (\r) execution line-break delimiter when true.

Returns

void

show

show: (_preserveFocus?) => void

Focuses and brings the terminal panel instance into view in the layout.

Parameters
_preserveFocus?

boolean = false

Optional configuration parameter to retain code editor focus.

Returns

void

creationOptions
Get Signature

get creationOptions(): object

The configuration properties utilized to initialize this terminal session.

Returns

object

cwd

cwd: string = instance.workingDir

name

name: string = instance.title

shell

shell: TerminalShell = instance.shell

exitStatus
Get Signature

get exitStatus(): { code: number; } | undefined

The current exit status metadata if the process has terminated.

Returns

{ code: number; } | undefined

Object containing the exit code, or undefined if still active.

processId
Get Signature

get processId(): Promise<number>

Retrieves the system process identifier (PID) asynchronously.

Returns

Promise<number>

Resolves to the process ID, or -1 if unallocated.

onDidChangeActiveTerminal

onDidChangeActiveTerminal: (handler) => object

Fires an event callback notification updating execution parameters when an index changes panel viewport assignments.

Parameters
handler

(terminal) => void

Returns

object

dispose

dispose: () => void

Returns

void

onDidCloseTerminal

onDidCloseTerminal: (handler) => object

Fires an event callback handler tracing historical instance context structures right as closures execute.

Parameters
handler

(terminal) => void

Returns

object

dispose

dispose: () => void

Returns

void

onDidOpenTerminal

onDidOpenTerminal: (handler) => object

Fires an event callback handler whenever a new terminal tab container gets created.

Parameters
handler

(terminal) => void

Returns

object

dispose

dispose: () => void

Returns

void

activeTerminal
Get Signature

get activeTerminal(): { clear: () => void; dispose: () => void; hide: () => void; id: string; name: string; sendText: (text, addNewLine?) => void; show: (_preserveFocus?) => void; get creationOptions(): { cwd: string; name: string; shell: TerminalShell; }; get exitStatus(): { code: number; } | undefined; get processId(): Promise<number>; } | undefined

The currently focused active terminal element.

Returns

The active interface wrapper, or undefined if hidden.

Type Literal

{ clear: () => void; dispose: () => void; hide: () => void; id: string; name: string; sendText: (text, addNewLine?) => void; show: (_preserveFocus?) => void; get creationOptions(): { cwd: string; name: string; shell: TerminalShell; }; get exitStatus(): { code: number; } | undefined; get processId(): Promise<number>; }

clear

clear: () => void

Requests the underlying stream engine to clear terminal screen buffers. Employs transient buffering intervals if invoked while the system state is spawning.

Returns

void

dispose

dispose: () => void

Terminates the stream, triggers standard OS signaling cleanup traps, and releases store allocation.

Returns

void

hide

hide: () => void

Hides the terminal panel if it is currently focused, switching view hierarchies.

Returns

void

id

id: string = instance.id

The unique identifier assigned to this terminal session.

name

name: string = instance.title

The human-readable display name of the terminal tab.

sendText

sendText: (text, addNewLine?) => void

Evaluates and transmits a string command payload to the underlying shell process instance. Features built-in sequential buffering delays to gracefully support lazy booting processes.

Parameters
text

string

The raw text command string payload.

addNewLine?

boolean = true

Appends a carriage return (\r) execution line-break delimiter when true.

Returns

void

show

show: (_preserveFocus?) => void

Focuses and brings the terminal panel instance into view in the layout.

Parameters
_preserveFocus?

boolean = false

Optional configuration parameter to retain code editor focus.

Returns

void

creationOptions
Get Signature

get creationOptions(): object

The configuration properties utilized to initialize this terminal session.

Returns

object

cwd

cwd: string = instance.workingDir

name

name: string = instance.title

shell

shell: TerminalShell = instance.shell

exitStatus
Get Signature

get exitStatus(): { code: number; } | undefined

The current exit status metadata if the process has terminated.

Returns

{ code: number; } | undefined

Object containing the exit code, or undefined if still active.

processId
Get Signature

get processId(): Promise<number>

Retrieves the system process identifier (PID) asynchronously.

Returns

Promise<number>

Resolves to the process ID, or -1 if unallocated.


undefined

terminals
Get Signature

get terminals(): object[]

Array of all existing terminals registered in the environment.

Returns

Fully wrapped active terminal API components.