Tty

expect class Tty : AutoCloseable
actual class Tty : AutoCloseable
actual class Tty : AutoCloseable

Types

Link copied to clipboard
expect interface Callback
actual interface Callback
actual interface Callback
Link copied to clipboard
expect object Companion
actual object Companion
actual object Companion

Functions

Link copied to clipboard
expect open override fun close()

Calls reset and then frees the resources associated with this instance.

actual open override fun close()
actual open override fun close()
Link copied to clipboard
expect fun currentSize(): IntArray
actual fun currentSize(): IntArray
actual fun currentSize(): IntArray
Link copied to clipboard
expect fun enableRawMode()

Save the current terminal settings and enter "raw" mode.

actual fun enableRawMode()
actual fun enableRawMode()
Link copied to clipboard

Use platform-specific window monitoring to call Callback.onResize when the OS determines the terminal window size has changed. You must call setCallback to monitor these events.

Link copied to clipboard
expect fun interruptRead()

Signal blocking calls to read or readWithTimeout to wake up and return 0.

actual fun interruptRead()
actual fun interruptRead()
Link copied to clipboard
expect fun read(buffer: ByteArray, offset: Int, count: Int): Int

Read up to count bytes into buffer at offset from the TTY. The number of bytes read will be returned. 0 will be returned if interruptRead is called while waiting for input. -1 will be returned if the TTY is not interactive.

actual fun read(buffer: ByteArray, offset: Int, count: Int): Int
actual fun read(buffer: ByteArray, offset: Int, count: Int): Int
Link copied to clipboard
expect fun readWithTimeout(buffer: ByteArray, offset: Int, count: Int, timeoutMillis: Int): Int

Read up to count bytes into buffer at offset from the TTY. The number of bytes read will be returned. 0 will be returned if interruptRead is called while waiting for input, or if at least timeoutMillis have passed without data. -1 will be returned if the TTY is not interactive.

actual fun readWithTimeout(buffer: ByteArray, offset: Int, count: Int, timeoutMillis: Int): Int
actual fun readWithTimeout(buffer: ByteArray, offset: Int, count: Int, timeoutMillis: Int): Int
Link copied to clipboard
expect fun reset()

Reset TTY state.

actual fun reset()
actual fun reset()
Link copied to clipboard
expect fun setCallback(callback: Tty.Callback?)

Set or clear the callback used for reporting events about the terminal using platform-specific integration. The callback may be invoked on any thread and must never throw an exception. On Windows the callback will only be invoked during calls to read or readWithTimeout.

actual fun setCallback(callback: Tty.Callback?)
actual fun setCallback(callback: Tty.Callback?)
Link copied to clipboard
expect fun write(buffer: ByteArray, offset: Int, count: Int): Int

Write up to count bytes from buffer at offset to the TTY. The number of bytes written will be returned.

actual fun write(buffer: ByteArray, offset: Int, count: Int): Int
actual fun write(buffer: ByteArray, offset: Int, count: Int): Int