Syntax Highlighted Text Editor Defaults
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
Default enablement of auto-indentation.
Default KeyboardOptions tuned for source-code input.
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.
Default indentation string: 4 spaces.
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.
Default enablement of Escape key handling to clear focus and escape the editor.
Default enablement of Tab key interception to insert spaces rather than shift focus.