SyntaxHighlightedTextEditorDefaults

Default values used by SyntaxHighlightedTextEditor and rememberSyntaxHighlightedEditorValue.

Singletons here let parameter defaults reference a pre-allocated value instead of constructing a fresh instance per call. For composables that recompose on every keystroke (the editor), this avoids minor GC pressure during the worst possible time - while the user is typing.

Usage

// Build on top of the default text style without re-declaring fontFamily.
val myEditorStyle = SyntaxHighlightedTextEditorDefaults.DefaultTextStyle.copy(fontSize = 15.sp)

SyntaxHighlightedTextEditor(
value = editorValue,
onValueChange = { editorValue = it },
language = "kotlin",
textStyle = myEditorStyle,
)

Properties

Link copied to clipboard
const val AUTO_INDENT_ENABLED: Boolean = true

Default enablement of auto-indentation.

Link copied to clipboard

Default KeyboardOptions tuned for source-code input.

Link copied to clipboard
const val DEBOUNCE_MS: Long = 150

Default debounce window in milliseconds after the last keystroke before the editor triggers a new highlight call. 150 ms is a balance between responsiveness and avoiding unnecessary WebView calls on fast typists.

Link copied to clipboard

Default indentation string: 4 spaces.

Link copied to clipboard

Default TextStyle for the editor: monospace family. Pre-allocated singleton so the editor's textStyle parameter default does not allocate a fresh TextStyle per recomposition. Callers can copy(...) this to derive customised styles.

Link copied to clipboard

Default enablement of Tab key interception to insert spaces rather than shift focus.