TerminalSession

class TerminalSession(val terminal: TerminalBuffer, val publisher: TerminalRenderPublisher, renderReader: TerminalRenderFrameReader, responseReader: TerminalHostResponseReader, connector: TerminalConnector, parser: TerminalOutputParser, inputEncoder: TerminalInputEncoder, hyperlinkResolver: TerminalHyperlinkResolver = TerminalHyperlinkResolver.NONE, outboundWriteLock: Any = Any(), val shellIntegrationState: TerminalShellIntegrationState = TerminalShellIntegrationState(), hostCommandAdapter: HostCommandAdapter? = null, inputPolicy: TerminalInputPolicy = TerminalInputPolicy()) : TerminalConnectorListener, TerminalInputEncoder, TerminalRenderFrameReader, AutoCloseable

Runtime terminal session that binds core, parser, input encoding, and a transport connector.

The connector owns transport threads. This session owns parser/core mutation serialization and all host-bound write ordering.

Constructors

Link copied to clipboard
constructor(terminal: TerminalBuffer, publisher: TerminalRenderPublisher, renderReader: TerminalRenderFrameReader, responseReader: TerminalHostResponseReader, connector: TerminalConnector, parser: TerminalOutputParser, inputEncoder: TerminalInputEncoder, hyperlinkResolver: TerminalHyperlinkResolver = TerminalHyperlinkResolver.NONE, outboundWriteLock: Any = Any(), shellIntegrationState: TerminalShellIntegrationState = TerminalShellIntegrationState(), hostCommandAdapter: HostCommandAdapter? = null, inputPolicy: TerminalInputPolicy = TerminalInputPolicy())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Remote process exit code after onClosed receives one.

Link copied to clipboard

Transport failure reported by onError, or null when the remote closed normally or the session was locally closed.

Link copied to clipboard

Returns true after either local shutdown, remote closure, or transport failure has made the session unable to accept more input.

Link copied to clipboard
var onDirty: () -> Unit?

Optional callback invoked after a render frame is published.

Link copied to clipboard

the render publisher responsible for frames updates.

Link copied to clipboard

shared host-side prompt and command marker state.

Link copied to clipboard

public terminal buffer mutated by host output.

Functions

Link copied to clipboard

Registers a listener that is invoked exactly once when this session reaches a terminal lifecycle state.

Link copied to clipboard
fun addDirtyListener(listener: () -> Unit)

Registers a listener to be notified when the session needs a render repaint.

Link copied to clipboard
open override fun close()

Requests local connector shutdown and closes parser input exactly once.

Link copied to clipboard

Returns the latest valid OSC 7 current-working-directory URI.

Link copied to clipboard
open override fun encodeFocus(event: TerminalFocusEvent)

Encodes a focus event and writes it to the connector unless closed.

Link copied to clipboard
open override fun encodeKey(event: TerminalKeyEvent)
Link copied to clipboard
open override fun encodeMouse(event: TerminalMouseEvent)

Encodes a mouse event and writes it to the connector unless closed.

Link copied to clipboard
open override fun encodePaste(event: TerminalPasteEvent)

Encodes a paste event and writes it to the connector unless closed.

Link copied to clipboard
fun hyperlinkUri(hyperlinkId: Int): String?

Resolves a primitive render-frame hyperlink id to a target URI.

Link copied to clipboard

Submits a render task to the worker thread.

Link copied to clipboard
open override fun onBytes(bytes: ByteArray, offset: Int, length: Int)

Consumes host bytes synchronously, mutating parser/core before returning.

Link copied to clipboard
open override fun onClosed(exitCode: Int?)

Records remote closure and closes the parser exactly once.

Link copied to clipboard
open override fun onError(error: Throwable)

Records transport failure and treats it as remote closure without a process exit code.

Link copied to clipboard
open override fun readRenderFrame(consumer: TerminalRenderFrameConsumer)

Reads a short-lived render frame while holding the terminal mutation lock.

open override fun readRenderFrame(scrollbackOffset: Int, consumer: TerminalRenderFrameConsumer)

Reads a render frame with a specified scrollback offset.

open override fun readRenderFrame(scrollbackOffset: Int, viewportRows: Int, consumer: TerminalRenderFrameConsumer)

Reads a render frame with a specified scrollback offset and viewport rows limit.

Link copied to clipboard

Unregisters a previously registered session close listener.

Link copied to clipboard
fun removeDirtyListener(listener: () -> Unit)

Unregisters a previously registered render repaint listener.

Link copied to clipboard
fun requestRender(scrollbackOffset: Int)

Requests a render-cache publication for a caller-owned scrollback viewport.

fun requestRender(scrollbackOffset: Int, viewportRows: Int)

Requests a render-cache publication with optional render-only viewport overscan rows.

Link copied to clipboard
fun resize(columns: Int, rows: Int, oldScrollbackOffset: Int = 0): Pair<Int, Int>

Resizes core, publisher, and the active connector.

Link copied to clipboard

Updates the current and default cursor shape for the session.

Link copied to clipboard

Updates the active host security policy dynamically.

Link copied to clipboard
open override fun setInputPolicy(policy: TerminalInputPolicy)

Updates the active terminal input policy dynamically.

Link copied to clipboard

Updates only the active paste sanitization policy.

Link copied to clipboard

Sets the theme-configured color palette for the session.

Link copied to clipboard

Applies the host's East Asian Ambiguous width policy for future writes.

Link copied to clipboard
fun start(columns: Int, rows: Int)

Starts the connector after resizing core and transport to columns x rows.