KetraTerm
API · DevelopmentAll versions

create

fun create(terminal: TerminalRenderBuffer, connector: TerminalConnector, hostEvents: HostEventSink = HostEventSink.NONE, hostPolicy: HostPolicy = HostPolicy(), inputPolicy: TerminalInputPolicy = TerminalInputPolicy(), kittyKeyboardSupportedFlags: Int = KittyKeyboardProgressiveFlag.DEFAULT_HOST_SUPPORTED_MASK, workerDispatcher: CoroutineDispatcher = Dispatchers.Default, startupCommand: TerminalStartupCommand? = null, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, modeReportCapabilities: Int = 0, clipboardReader: TerminalClipboardReader? = null, clipboardReadTimeSource: TimeSource = TimeSource.Monotonic, shellIntegration: TerminalShellIntegrationFactory? = null, inputEncoderFactory: TerminalInputEncoderFactory? = null, parserFactory: TerminalOutputParserFactory? = null): TerminalSession

Assembles a production session from a buffer exposing core and render roles.

Uses the same services and customization factories as the separate-reader overload. Ownership transfers only after successful construction. Custom factories must not perform I/O or start jobs during construction.

Return

the assembled session, which owns the supplied runtime collaborators.

Parameters

terminal

exclusively owned core buffer and matching render projection.

connector

exclusively owned transport.

hostEvents

accepted metadata/request receiver.

hostPolicy

initial host authorization and bounds.

inputPolicy

initial input-encoding policy.

kittyKeyboardSupportedFlags

flags the host can implement truthfully.

workerDispatcher

non-owned render, metadata and timeout dispatcher.

startupCommand

command deferred until shell prompt readiness, or null.

ioDispatcher

non-owned dispatcher for connector writes and providers.

modeReportCapabilities

implemented host-action mask.

clipboardReader

session-bound clipboard provider, or null.

clipboardReadTimeSource

monotonic clipboard deadline source.

shellIntegration

sole metadata producer, or null.

inputEncoderFactory

creates independent admission and bulk encoders.

parserFactory

custom parser factory; preserve TerminalGraphicsOutputParser for session decoding.

Throws

for invalid dimensions, startup without shell integration, incompatible render state or a factory reusing an encoder instance.


fun create(terminal: TerminalRenderBuffer, connector: TerminalConnector, hostEvents: HostEventSink = HostEventSink.NONE, hostPolicy: HostPolicy = HostPolicy(), inputPolicy: TerminalInputPolicy = TerminalInputPolicy(), kittyKeyboardSupportedFlags: Int = KittyKeyboardProgressiveFlag.DEFAULT_HOST_SUPPORTED_MASK, workerDispatcher: CoroutineDispatcher = Dispatchers.Default, startupCommand: TerminalStartupCommand? = null, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, modeReportCapabilities: Int = 0, clipboardReader: TerminalClipboardReader? = null, clipboardReadTimeSource: TimeSource = TimeSource.Monotonic, shellIntegration: TerminalShellIntegrationFactory? = null, inputEncoderFactory: TerminalInputEncoderFactory? = null, parserFactory: TerminalOutputParserFactory? = null, cleanupDispatcher: CoroutineDispatcher): TerminalSession

Assembles a production session from a buffer exposing core and render roles.

Uses the same services and customization factories as the separate-reader overload. Ownership transfers only after successful construction. Custom factories must not perform I/O or start jobs during construction.

Return

the assembled session, which owns the supplied runtime collaborators.

Parameters

terminal

exclusively owned core buffer and matching render projection.

connector

exclusively owned transport.

hostEvents

accepted metadata/request receiver.

hostPolicy

initial host authorization and bounds.

inputPolicy

initial input-encoding policy.

kittyKeyboardSupportedFlags

flags the host can implement truthfully.

workerDispatcher

non-owned render, metadata and timeout dispatcher.

startupCommand

command deferred until shell prompt readiness, or null.

ioDispatcher

non-owned dispatcher for connector writes and providers.

modeReportCapabilities

implemented host-action mask.

clipboardReader

session-bound clipboard provider, or null.

clipboardReadTimeSource

monotonic clipboard deadline source.

shellIntegration

sole metadata producer, or null.

inputEncoderFactory

creates independent admission and bulk encoders.

parserFactory

custom parser factory; preserve TerminalGraphicsOutputParser for session decoding.

cleanupDispatcher

non-owned off-UI blocking cleanup dispatcher, independent of connector writes.

Throws

for invalid dimensions, startup without shell integration, incompatible render state or a factory reusing an encoder instance.


fun create(terminal: TerminalBuffer, renderReader: TerminalRenderFrameReader, connector: TerminalConnector, hostEvents: HostEventSink = HostEventSink.NONE, hostPolicy: HostPolicy = HostPolicy(), inputPolicy: TerminalInputPolicy = TerminalInputPolicy(), kittyKeyboardSupportedFlags: Int = KittyKeyboardProgressiveFlag.DEFAULT_HOST_SUPPORTED_MASK, workerDispatcher: CoroutineDispatcher = Dispatchers.Default, startupCommand: TerminalStartupCommand? = null, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, modeReportCapabilities: Int = 0, clipboardReader: TerminalClipboardReader? = null, clipboardReadTimeSource: TimeSource = TimeSource.Monotonic, shellIntegration: TerminalShellIntegrationFactory? = null, inputEncoderFactory: TerminalInputEncoderFactory? = null, parserFactory: TerminalOutputParserFactory? = null): TerminalSession

Assembles core and render collaborators with session-owned host services.

Width must be at least TerminalBuffers.MIN_WIDTH and height must be positive. Dimensions are validated before factory calls or connector ownership transfer. The collaborators must describe the same terminal state; equal dimensions alone cannot establish that relationship. Factory failures leave the connector with its caller and start no session workers.

Return

standard production terminal session.

Parameters

terminal

core buffer transferred to the session's exclusive runtime ownership.

renderReader

render projection of the same core state.

connector

transport connector transferred to the session; closed on every terminal lifecycle path.

hostEvents

metadata events target.

hostPolicy

safety policy.

inputPolicy

key-encoding policy.

modeReportCapabilities

implemented host actions from TerminalHostModeCapability; defaults to none.

kittyKeyboardSupportedFlags

progressive Kitty keyboard flags the active input host can provide truthfully. Defaults to the conservative portable-host profile.

workerDispatcher

non-owned dispatcher used for render publication and timeouts.

startupCommand

optional command submitted once after the selected integration reports prompt readiness. User input before readiness cancels submission.

ioDispatcher

non-owned dispatcher for connector writes, metadata queries, and clipboard providers.

clipboardReader

session-bound clipboard/consent operation, or null for unavailable reads.

clipboardReadTimeSource

monotonic elapsed-time source for clipboard provider and reply-commit deadline checks. Deterministic tests should share its time domain with the worker dispatcher's delay scheduler. This does not change the fixed read timeout or other session timers.

shellIntegration

sole shell metadata producer; null leaves shell features unavailable.

inputEncoderFactory

creates independent admission and bulk encoders bound to session-owned output.

parserFactory

customizes parsing using the assembled host sink and its live clipboard budget. Pass both to TerminalParsers.create when adding a custom OSC handler. Its callback runs under mutation serialization and may read frames before later output. It must not call mutating session APIs or close the session.

Throws

when terminal dimensions are invalid, the initial render frame is absent or has incompatible dimensions, or the input factory reuses one encoder instance.


fun create(terminal: TerminalBuffer, renderReader: TerminalRenderFrameReader, connector: TerminalConnector, hostEvents: HostEventSink = HostEventSink.NONE, hostPolicy: HostPolicy = HostPolicy(), inputPolicy: TerminalInputPolicy = TerminalInputPolicy(), kittyKeyboardSupportedFlags: Int = KittyKeyboardProgressiveFlag.DEFAULT_HOST_SUPPORTED_MASK, workerDispatcher: CoroutineDispatcher = Dispatchers.Default, startupCommand: TerminalStartupCommand? = null, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, modeReportCapabilities: Int = 0, clipboardReader: TerminalClipboardReader? = null, clipboardReadTimeSource: TimeSource = TimeSource.Monotonic, shellIntegration: TerminalShellIntegrationFactory? = null, inputEncoderFactory: TerminalInputEncoderFactory? = null, parserFactory: TerminalOutputParserFactory? = null, cleanupDispatcher: CoroutineDispatcher): TerminalSession

Assembles core and render collaborators with session-owned host services.

Width must be at least TerminalBuffers.MIN_WIDTH and height must be positive. Dimensions are validated before factory calls or connector ownership transfer. The collaborators must describe the same terminal state; equal dimensions alone cannot establish that relationship. Factory failures leave the connector with its caller and start no session workers.

Return

standard production terminal session.

Parameters

terminal

core buffer transferred to the session's exclusive runtime ownership.

renderReader

render projection of the same core state.

connector

transport connector transferred to the session; closed on every terminal lifecycle path.

hostEvents

metadata events target.

hostPolicy

safety policy.

inputPolicy

key-encoding policy.

modeReportCapabilities

implemented host actions from TerminalHostModeCapability; defaults to none.

kittyKeyboardSupportedFlags

progressive Kitty keyboard flags the active input host can provide truthfully. Defaults to the conservative portable-host profile.

workerDispatcher

non-owned dispatcher used for render publication and timeouts.

startupCommand

optional command submitted once after the selected integration reports prompt readiness. User input before readiness cancels submission.

ioDispatcher

non-owned dispatcher for connector writes, metadata queries, and clipboard providers.

clipboardReader

session-bound clipboard/consent operation, or null for unavailable reads.

clipboardReadTimeSource

monotonic elapsed-time source for clipboard provider and reply-commit deadline checks. Deterministic tests should share its time domain with the worker dispatcher's delay scheduler. This does not change the fixed read timeout or other session timers.

shellIntegration

sole shell metadata producer; null leaves shell features unavailable.

inputEncoderFactory

creates independent admission and bulk encoders bound to session-owned output.

cleanupDispatcher

non-owned dispatcher for asynchronous shutdown, independent of blocked connector writes. Must execute blocking cleanup off UI threads.

parserFactory

customizes parsing using the assembled host sink and its live clipboard budget. Pass both to TerminalParsers.create when adding a custom OSC handler. Its callback runs under mutation serialization and may read frames before later output. It must not call mutating session APIs or close the session.

Throws

when terminal dimensions are invalid, the initial render frame is absent or has incompatible dimensions, or the input factory reuses one encoder instance.