Terminal

fun Terminal(terminalEmulator: TerminalEmulator, modifier: Modifier = Modifier, typeface: Typeface = Typeface.MONOSPACE, initialFontSize: TextUnit = 11.sp, minFontSize: TextUnit = 6.sp, maxFontSize: TextUnit = 30.sp, backgroundColor: Color = Color.Black, foregroundColor: Color = Color.White, selectionBackgroundColor: Color = Color(0xFFB3D7FF), selectionForegroundColor: Color = Color.Black, keyboardEnabled: Boolean = false, showSoftKeyboard: Boolean = true, focusRequester: FocusRequester = remember { FocusRequester() }, onTerminalTap: () -> Unit = {}, onImeVisibilityChanged: (Boolean) -> Unit = {}, forcedSize: Pair<Int, Int>? = null, modifierManager: ModifierManager? = null, onSelectionControllerAvailable: (SelectionController) -> Unit? = null, onHyperlinkClick: (String) -> Unit = {}, onComposeControllerAvailable: (ComposeController) -> Unit? = null, onPasteRequest: () -> Unit? = null, rightAltMode: RightAltMode = RightAltMode.CharacterModifier, delKeyMode: DelKeyMode = DelKeyMode.Delete, onInterceptKey: (KeyEvent) -> Boolean? = null)(source)

Terminal - A Jetpack Compose terminal screen component.

This component:

  • Renders terminal output using Canvas

  • Handles terminal resize based on available space

  • Displays cursor

  • Supports colors, bold, italic, underline, etc.

Parameters

terminalEmulator

The terminal emulator containing terminal state

modifier

Modifier for the composable

typeface

Typeface for terminal text (default: Typeface.MONOSPACE)

initialFontSize

Initial font size for terminal text (can be changed with pinch-to-zoom)

minFontSize

Minimum font size for pinch-to-zoom

maxFontSize

Maximum font size for pinch-to-zoom

backgroundColor

Default background color

foregroundColor

Default foreground color

keyboardEnabled

Enable keyboard input handling (default: false for display-only mode). When false, no keyboard input (hardware or soft) is accepted.

showSoftKeyboard

Whether to show the soft keyboard/IME (default: true when keyboardEnabled=true). Only applies when keyboardEnabled=true. Hardware keyboard always works when keyboardEnabled=true.

focusRequester

Focus requester for keyboard input (if enabled)

onTerminalTap

Callback for a simple tap event on the terminal (when no selection is active)

onImeVisibilityChanged

Callback invoked when IME visibility changes (true = shown, false = hidden)

forcedSize

Force terminal to specific dimensions (rows, cols). When set, font size is calculated to fit.

onSelectionControllerAvailable

Optional callback providing access to the SelectionController for controlling selection mode

onHyperlinkClick

Callback when user taps on an OSC8 hyperlink. Receives the URL as parameter.

onComposeControllerAvailable

Optional callback providing access to the ComposeController for handling IME compose state

onPasteRequest

Optional callback for handling a request to paste content, normally triggered by a context menu action

rightAltMode

How the right-alt key should behave (CharacterModifier vs Meta)

selectionBackgroundColor

Background color for selected text (default: 0xFFB3D7FF)

selectionForegroundColor

Foreground color for selected text (default: Black)

delKeyMode

How the backspace/delete keys should map to terminal characters

onInterceptKey

Optional callback to intercept raw Compose KeyEvents before the terminal emulator handles them. Return true to consume the event.