Code Editor
Code to be written and changed: a text of any length, a line to a line, each run of it in the colour of what it is, its lines numbered, and the line the caret is on marked where it has no mark of the app's.
import com.pantrixui.components.data.codeeditor.PantrixCodeEditor
- State. The text, the selection and the history are in a
CodeEditorState, whichrememberCodeEditorStatebuilds. The text is kept a line at a time: a text of megabytes opens at once and is typed in as a short one is. The state says the text (text), how many lines it has (lineCount), a line (line), the line a place is on (lineOf) and where a line starts (lineStart);revisiongrows with each change.revealLinesbrings lines onto the screen without moving the caret. - The app's changes.
replacechanges one place,setTextthe whole text, andeditseveral places in one step; each is undone.undoandredotake back and make again a word of typing at a time;canUndoandcanRedosay whether there is anything to do. - Reader. A
CodeHighlightertakes a line and the state the line before ended in, and gives the line's runs and the state it ends in (CodeHighlight). The editor reads the lines away from the main thread, and after a change only as far as the change altered the state the next line is read from. - Syntax.
CodeSyntaxnames the language's brackets, quotes and comments: a bracket or a quote that is typed is closed at once (closesPairs), and a closing one the editor put in is typed over; Ctrl+/ comments the lines out. - Indent.
indentis one step of indent: two spaces, or a tab. Tab indents and Shift+Tab outdents, the lines of a selection together; a line feed carries the line's indent on, and one step more after an opening bracket. - Keys for lines. Alt+Up and Alt+Down move the lines, and with Shift copy them; Ctrl+Shift+K deletes them; Ctrl+Shift+\ goes to the matching bracket. Cmd in place of Ctrl on a Mac.
- Marks. A line's mark (
lineMarks) draws its tone's fill behind the line and a bar at its edge; the bar can have a tone of its own (bar) or be left out (showBar), and the number can have a sign before it (gutter). With the caret on a marked line, the line stays on its own band. A stretch's mark (CodeRangeMark) puts a wavy line under it and a dot at the start of its line, or a fill behind it (CodeRangeStyle); its message shows while the caret is there or the mouse is over it. - Find and replace. Ctrl+F opens the find bar, and Ctrl+H opens it with its replace row; matching case, whole words and regular expressions are chosen there. Every match is marked in the text and on the scroll bar. The app opens the bar with
find, and does the same without it withfindNext,findAll,replaceNextandreplaceAll. - A phone's row of keys. On a phone a row of keys stands under the editor while it has the focus: Tab, the brackets and signs code is written with, undo, redo and the arrows. The app gives its own row with
keyRow(CodeKey). - Long lines. A line that does not fit is not broken: the code scrolls sideways, and the line numbers stay where they are. With
softWrapthe line goes on under itself as wide as the editor, its number by its first row. A line of more than ten thousand characters is shown that far, with a mark at its end that says how much is left; the line is kept whole. - Colour and style. A colour given with
CodeEditorColorsis used, and the theme's stays for the rest;CodeEditorStylechanges the corners, the spacing and the edge's width. - Automation. With
tagKeythe editor's field isCodeEditor_<tagKey>, a line outside the windowCodeEditor_<tagKey>.Line_<number>, a mark's messageCodeEditor_<tagKey>.Note_<number>and the search fieldCodeEditor_<tagKey>.TextField_find.
Examples
A JSON document
A JSON document with comments, coloured by the app's own reader. The syntax names JSON's brackets, its one quote and its comments: type { and } follows at once, Enter opens an indented line between the two, and Ctrl+/ comments the line out.
The fourth line is marked with a warning, and the app's name with an error: put the caret on them, or the mouse over them, and their messages show under them.
There are two actions under the error's message (CodeMark.actions, CodeMarkAction): "Shorten the name" fixes the name and the error goes, "Show the rule" says the rule. While the mouse is over the note it stays where it is; with the caret in the error, Ctrl+. (Cmd+. on Apple's systems) takes the focus to the first action, and Escape brings it back to the text.
val state = rememberCodeEditorState(initialText = SETTINGS)
val report = LocalExampleEvents.current
val name = remember(state.revision) { state.text.indexOf("\"Formatico\"") }
PantrixCodeEditor(
state = state,
modifier = Modifier.height(320.dp),
highlighter = JsonHighlighter,
syntax = CodeSyntax(quotes = "\"", lineComment = "//", blockCommentStart = "/*", blockCommentEnd = "*/"),
lineMarks = mapOf(3 to CodeMark(CodeTone.Warning, message = "This version is no longer supported.")),
rangeMarks = if (name < 0) {
emptyList()
} else {
val end = name + "\"Formatico\"".length
listOf(
CodeRangeMark(
start = name,
end = end,
mark = CodeMark(
CodeTone.Danger,
message = "A name has at most 8 letters.",
source = "schema",
actions = listOf(
CodeMarkAction("Shorten the name") { state.replace(name, end, "\"Formati\"") },
CodeMarkAction("Show the rule") { report("Schema: name has 8 letters at most") }
)
)
)
)
},
tagKey = "settings"
)
private val SETTINGS = """
{
// What the app opens with.
"name": "Formatico",
"version": 3,
/* The themes it offers,
the first one by default. */
"themes": ["light", "dark"],
"fontSize": 14.5,
"telemetry": false,
"lastOpened": null
}
""".trimStart()
Find and replace with the app's buttons
The app opens the find bar too: "Find" with the search field alone, "Replace" with the replace row, TODO to look for and DONE to put in its place given. While the bar is open, every match is marked in the text and on the scroll bar.
The state does the same without the bar: "Next" selects the next match, "Finish" replaces the selected match and selects the next, and "Finish all" replaces them all in one step to undo. The number under it is findAll's.
val state = rememberCodeEditorState(initialText = TASKS)
val todo = CodeSearch("TODO", matchCase = true, wholeWord = true)
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.xs)) {
PantrixButton(
text = "Find",
onClick = { state.find.open() },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
tagKey = "find"
)
PantrixButton(
text = "Replace",
onClick = {
state.find.search = todo
state.find.replacement = "DONE"
state.find.open(replacing = true)
},
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
tagKey = "replace"
)
PantrixButton(
text = "Close",
onClick = { state.find.close() },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
enabled = state.find.isOpen,
tagKey = "close"
)
PantrixButton(
text = "Next",
onClick = { state.findNext(todo) },
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "next"
)
PantrixButton(
text = "Finish",
onClick = { state.replaceNext(todo, "DONE") },
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "done"
)
PantrixButton(
text = "Finish all",
onClick = { state.replaceAll(todo, "DONE") },
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "doneAll"
)
}
PantrixCodeEditor(state = state, modifier = Modifier.height(240.dp), tagKey = "tasks")
PantrixText(text = "TODOs left: ${state.findAll(todo).size}", color = PantrixTheme.colors.textSecondary)
}
private val TASKS = """
# Before the release
TODO: write the changelog
TODO: record the screenshots again
DONE: raise the version
TODO: push the tag
""".trimStart()
A query with a row of keys of its own
A query box of one line: it has no line numbers, and the query runs 300 ms after the typing stops. On a phone, while the editor has the focus, the query's own keys stand under it: JSONPath's signs, two arrows and undo.
val query = rememberCodeEditorState("$.store.book[*].author")
var ran by remember { mutableStateOf(query.text) }
LaunchedEffect(query) {
snapshotFlow { query.revision }.collectLatest {
delay(300)
ran = query.text
}
}
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
PantrixCodeEditor(
state = query,
modifier = Modifier.height(96.dp),
keyRow = PATH_KEYS,
lineNumbers = false,
contentDescription = "JSONPath query",
tagKey = "query"
)
PantrixText(text = "Query run: $ran", color = PantrixTheme.colors.textSecondary)
}
private val PATH_KEYS: List<CodeKey> =
listOf("$", ".", "[", "]", "*", "?", "@", "'").map { CodeKey.Text(it) } +
listOf(CodeKey.Left, CodeKey.Right, CodeKey.Undo)
The state in the app's hands
The state is in the app's hands. "Undo" and "Redo" use the editor's history, and are off while there is nothing to do. "Add debugging" changes two places in one step (edit), "Comment at the top" writes in one place (replace), and "Reset" changes the whole text (setText); all three are undone.
The line under it says the caret's line and column, and the line itself: the state gives them at once from the text it keeps a line at a time.
val state = rememberCodeEditorState(initialText = SETTINGS)
val caret = state.selection.end
val line = state.lineOf(caret)
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
FlowRow(horizontalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.xs)) {
PantrixButton(
text = "Undo",
onClick = { state.undo() },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
enabled = state.canUndo,
tagKey = "undo"
)
PantrixButton(
text = "Redo",
onClick = { state.redo() },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
enabled = state.canRedo,
tagKey = "redo"
)
PantrixButton(
text = "Add debugging",
onClick = {
val last = state.text.lastIndexOf("null") + "null".length
val member = ",\n \"debug\": true"
val note = " // Debugging is on.\n"
state.edit {
// Two places, in one step to undo: the later one first, so that the earlier one's place does not move.
replace(last, last, member)
replace(2, 2, note)
selection = TextRange(last + member.length + note.length)
}
},
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "debug"
)
PantrixButton(
text = "Comment at the top",
onClick = { state.replace(0, 0, "// Formatico's settings.\n") },
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "comment"
)
PantrixButton(
text = "Reset",
onClick = { state.setText(SETTINGS) },
variant = ButtonVariant.Soft,
size = ButtonSize.Small,
tagKey = "reset"
)
}
PantrixCodeEditor(
state = state,
modifier = Modifier.height(280.dp),
highlighter = JsonHighlighter,
tagKey = "state"
)
PantrixText(
text = "Line ${line + 1} of ${state.lineCount}, column ${caret - state.lineStart(line) + 1}: " +
state.line(line).trim(),
color = PantrixTheme.colors.textSecondary
)
}
private val SETTINGS = """
{
// What the app opens with.
"name": "Formatico",
"version": 3,
/* The themes it offers,
the first one by default. */
"themes": ["light", "dark"],
"fontSize": 14.5,
"telemetry": false,
"lastOpened": null
}
""".trimStart()
A read-only file
A file that is read and copied but not changed: it is selected, searched (Ctrl+F) and copied. It has no replace row and no row of keys on a phone; Tab moves the focus.
PantrixCodeEditor(
state = rememberCodeEditorState(initialText = SETTINGS),
modifier = Modifier.height(240.dp),
highlighter = JsonHighlighter,
readOnly = true,
tagKey = "readOnly"
)
private val SETTINGS = """
{
// What the app opens with.
"name": "Formatico",
"version": 3,
/* The themes it offers,
the first one by default. */
"themes": ["light", "dark"],
"fontSize": 14.5,
"telemetry": false,
"lastOpened": null
}
""".trimStart()
The changes between two versions
The changes between two versions of an order, in one text, to be read: a changed line in the Warning tone, an added one in Success, one taken out in Danger, each with its sign in the gutter (~, +, −). The changed value itself stands on a fill inside its line (CodeRangeStyle.Highlight). The line of the change shown stays in its own tone, with its bar in the brand's colour (bar); the lines of the other changes are on their bands alone (showBar).
"Next difference" and "Previous difference" show a difference: revealLines brings its lines onto the screen, without moving the caret or the selection. With the caret on a marked line, the line stays on its own band. The shown difference's value also stands in a frame (CodeRangeStyle.Current).
A screen reader does not read the gutter's sign; each difference's line is told to it by its CodeMark.description: "status changed".
val state = rememberCodeEditorState(initialText = ORDER)
var shown by remember { mutableIntStateOf(0) }
val lineMarks = remember(shown) {
ORDER_CHANGES.withIndex().associate { (index, change) ->
// The change shown stays on its own band, with its bar in the brand's colour; the others have no bar.
val now = index == shown
change.line to CodeMark(
change.tone,
bar = CodeTone.Primary,
gutter = change.sign,
showBar = now,
description = change.what
)
}
}
val values = remember(state, shown) {
ORDER_CHANGES.withIndex().mapNotNull { (index, change) ->
val value = change.value ?: return@mapNotNull null
val start = state.lineStart(change.line) + state.line(change.line).indexOf(value)
// The shown difference's value is framed, the others only filled.
val style = if (index == shown) CodeRangeStyle.Current else CodeRangeStyle.Highlight
CodeRangeMark(start, start + value.length, CodeMark(change.tone), style = style)
}
}
LaunchedEffect(shown) {
val line = ORDER_CHANGES[shown].line
state.revealLines(line..line)
}
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
FlowRow(
horizontalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.xs),
verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.xs)
) {
PantrixButton(
text = "Previous change",
onClick = { shown = (shown + ORDER_CHANGES.size - 1) % ORDER_CHANGES.size },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
tagKey = "previousChange"
)
PantrixButton(
text = "Next change",
onClick = { shown = (shown + 1) % ORDER_CHANGES.size },
variant = ButtonVariant.Outline,
size = ButtonSize.Small,
tagKey = "nextChange"
)
}
PantrixCodeEditor(
state = state,
modifier = Modifier.height(240.dp),
highlighter = JsonHighlighter,
lineMarks = lineMarks,
rangeMarks = values,
readOnly = true,
tagKey = "compare"
)
PantrixText(
text = "Change ${shown + 1} of ${ORDER_CHANGES.size}: ${ORDER_CHANGES[shown].what}",
color = PantrixTheme.colors.textSecondary
)
}
private val ORDER = """
{
"id": "ord_8842",
"status": "delivered",
"createdAt": "2026-10-28T14:32:00Z",
"deliveredAt": "2026-11-01T10:05:00Z",
"customer": {
"name": "Deniz Kaya",
"email": "deniz@example.com"
},
"shipping": {
"method": "standard",
"carrier": "Kargo Ekspres",
"tracking": "KE-4471-0093",
"address": {
"street": "Moda Caddesi 12",
"district": "Kadıköy",
"city": "İstanbul",
"postalCode": "34710",
"country": "TR"
}
},
"payment": {
"method": "card",
"installments": 1,
"captured": true
},
"coupon": "AUTUMN10",
"items": [
{ "sku": "TS-001", "name": "Tişört", "qty": 2, "price": 34.90 },
{ "sku": "MG-014", "name": "Kupa", "qty": 2, "price": 14.00 },
{ "sku": "ST-220", "name": "Çıkartma", "qty": 5, "price": 1.20 }
],
"subtotal": 103.80,
"shippingCost": 0.00,
"total": 103.80,
"notes": "Kapıya bırakılabilir."
}
""".trimStart()
private val ORDER_CHANGES = listOf(
OrderChange(2, CodeTone.Warning, "~", "the status changed", value = "\"delivered\""),
OrderChange(4, CodeTone.Success, "+", "the delivery date was added"),
OrderChange(12, CodeTone.Success, "+", "the tracking number was added"),
OrderChange(26, CodeTone.Danger, "−", "the coupon was taken out"),
OrderChange(29, CodeTone.Warning, "~", "the mug's price changed", value = "14.00"),
OrderChange(30, CodeTone.Success, "+", "an item was added"),
OrderChange(32, CodeTone.Warning, "~", "the subtotal changed", value = "103.80"),
OrderChange(34, CodeTone.Warning, "~", "the total changed", value = "103.80")
)
private class OrderChange(
val line: Int,
val tone: CodeTone,
val sign: String,
val what: String,
val value: String? = null
)
Long lines go on under themselves
A file of long lines: a JSON object on one line and a long description. With wrapping off, the code scrolls sideways; with it on (softWrap), a long line goes on under itself as wide as the editor, its rest starting where the code starts, with no number in the gutter. Up and Down move the caret a row at a time as the rows are shown.
var wraps by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
PantrixSwitchButton(
checked = wraps,
onCheckedChange = { wraps = it },
label = "Wrap long lines",
tagKey = "wrap"
)
PantrixCodeEditor(
state = rememberCodeEditorState(initialText = LONG_LINES),
modifier = Modifier.height(240.dp),
highlighter = JsonHighlighter,
readOnly = true,
softWrap = wraps,
tagKey = "softWrap"
)
}
private val LONG_LINES = """
{
"description": "Formatico reads JSON, YAML, TOML and XML, checks them against their schemas, and converts one into another without losing a comment or the order of the keys.",
"settings": {"theme": "dark", "fontSize": 14.5, "wrapLongLines": true, "telemetry": false, "lastOpened": ["order.json", "order-v2.json", "settings.toml"]},
"notes": "A line too long for the window goes on under itself when lines wrap, and the code scrolls sideways when they do not."
}
""".trimStart()
With a syntax, colours and a style of its own
An INI file with a syntax of its own: a square bracket opens a section's name and # a comment, and its reader is in the example itself. The indent is four spaces, and a bracket that is typed is not closed. The row of keys on a phone keeps Tab, the arrows and undo, and adds =.
Its colours are its own: the ground is the theme's soft info fill, and the caret's line stands out more. Its style has square corners and a thick edge.
val colors = PantrixTheme.colors
PantrixCodeEditor(
state = rememberCodeEditorState(initialText = INI),
modifier = Modifier.height(220.dp),
highlighter = IniHighlighter,
syntax = CodeSyntax(brackets = "[]", quotes = "\"", lineComment = "#"),
indent = " ",
closesPairs = false,
keyRow = CodeKey.DefaultRow.filterNot { it is CodeKey.Text } + CodeKey.Text("="),
style = CodeEditorStyle(shape = ShapeSpec.Fixed(RectangleShape), borderWidth = 2.dp),
colors = CodeEditorColors(
container = colors.info.container,
currentLine = colors.info.color.copy(alpha = 0.15f)
),
tagKey = "ini"
)
private object IniHighlighter : CodeHighlighter<Unit> {
override val initialState = Unit
override fun highlight(
line: String,
state: Unit
): CodeHighlight<Unit> {
val code = line.trimStart()
val start = line.length - code.length
val equals = line.indexOf('=')
val tokens = when {
code.startsWith("#") -> {
listOf(CodeToken(start, line.length, CodeTokenKind.Comment))
}
code.startsWith("[") -> {
listOf(CodeToken(start, line.length, CodeTokenKind.Tag))
}
equals > 0 -> {
listOf(
CodeToken(start, equals, CodeTokenKind.Property),
CodeToken(equals + 1, line.length, CodeTokenKind.StringLiteral)
)
}
else -> {
emptyList()
}
}
return CodeHighlight(tokens, state)
}
}
private val INI = """
# Formatico
[editor]
indent = 2
theme = "dark"
[files]
recent = 10
""".trimStart()
A large document
A document of fifty thousand lines: it opens, scrolls and is typed in at once. Only the lines on the screen are built; the field the keyboard writes in holds a few hundred lines round the caret, and the editor draws the rest itself. The reader reads the lines in the background, the ones on the screen first.
val state = remember { CodeEditorState(LARGE) }
PantrixCodeEditor(
state = state,
modifier = Modifier.height(420.dp),
highlighter = JsonHighlighter,
tagKey = "large"
)
private val LARGE: String = buildString {
append("[\n")
for (index in 0 until 50_000) {
append(" {\"id\": ").append(index).append(", \"name\": \"item number ").append(index)
append("\", \"active\": ").append(index % 3 == 0).append(", \"score\": ").append(index * 7 % 1000)
append(if (index < 49_999) "},\n" else "}\n")
}
append("]")
}
API
state
Code to be written and changed: a text of any length, a line to a line, each run of it in the colour of what it is, its lines numbered, and the line the caret is on marked where it has no mark of the app's.
| Parameter | Type | Default | What it is |
|---|---|---|---|
state | CodeEditorState | the text, the selection and the history. Create it with rememberCodeEditorState. | |
modifier | Modifier | Modifier | the editor's modifier. A height given here is the room the code scrolls in. |
highlighter | CodeHighlighter<*>? | null | what colours the code: the runs of each line and what each is. None by default, and the code is written in one colour. |
syntax | CodeSyntax | CodeSyntax() | the language's brackets, quotes and comments: round, square and curly brackets and the two quotes by default, and no comments. |
lineMarks | Map<Int, CodeMark> | emptyMap() | what is said about whole lines, by the line's place counted from nought: a band behind the line in the soft fill of the mark's tone, a bar down its left edge, the mark's sign before the line's number, and the line written in the one colour the theme pairs with that fill. The mark's message shows while the caret is on the line. A marked line stays on its band with the caret on it: the band of the caret's line is drawn on a line without a mark of its own, and only while the editor has the focus, when the caret is drawn. |
rangeMarks | List<CodeRangeMark> | emptyList() | what is said about stretches of the text: a wavy line under each in the colour of its tone and a dot before its line, or a fill behind it, as its CodeRangeMark.style says, over the band of the caret's line, and its message while the caret is in it or a mouse is over it. The marks are drawn where they are told: an app that checks the text after each change gives the marks of the new text. |
indent | String | " " | one step of indent: two spaces by default, or as many as the code is indented by, or a tab. A tab is drawn as wide as the type draws one. |
closesPairs | Boolean | true | whether a bracket or a quote that is typed is closed at once, and a closing one the editor put in typed over. |
keyRow | List<CodeKey> | CodeKey.DefaultRow | the keys of the row at the editor's foot while it has the focus on a platform used by touch: Tab, the brackets and signs code is written with, undo and redo, and the arrows, by default. An empty list shows no row, and neither does an editor whose text cannot be changed. |
lineNumbers | Boolean | true | whether each line carries its number before the code. |
readOnly | Boolean | false | whether the text can be selected and copied but not changed. |
enabled | Boolean | true | whether the editor takes the focus at all. A disabled editor is written in the theme's colour for what cannot be used. |
textStyle | TextStyle? | null | what the code is set in: the theme's code where it is not given. |
style | CodeEditorStyle? | null | this call's own style: over every enclosing one and under the density. Only the fields it sets change, on every platform. |
colors | CodeEditorColors? | null | this editor's own colours, where they are not the theme's: the ones set here, with the theme's for the rest. |
contentDescription | String? | null | what a screen reader calls the editor: "Code editor" in the theme's language where it is not given. Where a keyboard writes in the code, the screen reader is also told that Tab indents, and that Escape and then Tab leave the editor. |
softWrap | Boolean | false | whether a line too long for the editor goes on under itself, a row at a time, rather than the code scrolling sideways: for a narrow screen, or a text of long lines that is read more than its columns are. A line broken where the room ends loses what its indent says, and its rows start where the code does. Off by default. |
tagKey | String? | null | the editor's automation key: its text field, which takes the keyboard, is CodeEditor_<tagKey>, and a line outside the window CodeEditor_<tagKey>.Line_<number>. The row's own keys are CodeEditor_<tagKey>.IconButton_<name>: tab, undo, redo, left, up, down and right; a key of text is CodeEditor_<tagKey>.Button_text<place>, by its place in the row counted from nought. |
CodeEditorStyle
PantrixCodeEditor's geometry: the room around its lines, the room before the code where the lines are numbered, and the edge.
| Parameter | Type | Default | What it is |
|---|---|---|---|
shape | ShapeSpec | ShapeSpec.Unspecified | The corners of the editor: a step of the brand's shape scale, or a fixed shape. |
horizontalPadding | Dp | Dp.Unspecified | The room between the editor's sides and what it holds: the line numbers at the start, the end of the longest line at the end. |
verticalPadding | Dp | Dp.Unspecified | The room over the first line and under the last. |
linePadding | Dp | Dp.Unspecified | The room over and under the words of each line. |
gutterGap | Dp | Dp.Unspecified | Between the line numbers and the code. |
borderWidth | Dp | Dp.Unspecified | The width of the edge around the editor. Zero draws none. |
focusedBorderWidth | Dp | Dp.Unspecified | The width of the edge while the editor has the focus: the edge is what shows it. |
barWidth | Dp | Dp.Unspecified | The width of the bar a marked line carries down its left edge. Zero draws none. |
iconSize | Dp | Dp.Unspecified | The width and height of the icon before a mark's message. |
CodeEditorColors
What a PantrixCodeEditor is painted with, for an editor that does not take the theme's colours: a colour that is set is used, and one that is left out stays the theme's.
| Parameter | Type | Default | What it is |
|---|---|---|---|
container | Color | Color.Unspecified | The fill behind the lines: the theme's surface. |
text | Color | Color.Unspecified | What no token colours. The theme's textPrimary. |
comment | Color | Color.Unspecified | A comment, which is slanted too. The theme's textSecondary. |
keyword | Color | Color.Unspecified | A word of the language. The theme's primary role. |
type | Color | Color.Unspecified | The name of a type. The theme's info role. |
string | Color | Color.Unspecified | A string. The theme's success role. |
number | Color | Color.Unspecified | A number. The theme's warning role. |
punctuation | Color | Color.Unspecified | Brackets, commas and semicolons. The theme's textSecondary. |
annotation | Color | Color.Unspecified | A name that says something about what follows it. The theme's danger role. |
property | Color | Color.Unspecified | The name of a member or a setting. The colour of a type where it is not set. |
tag | Color | Color.Unspecified | The name of an element of a markup. The colour of a keyword where it is not set. |
lineNumber | Color | Color.Unspecified | The line numbers and the mark of a line too long to show whole. The theme's textSecondary. |
border | Color | Color.Unspecified | The edge around the editor: the theme's border, as a field's, and on a fill a share of what is written there. |
focusedBorder | Color | Color.Unspecified | The edge while the editor has the focus. The theme's primary role. |
currentLine | Color | Color.Unspecified | The band behind the line the caret is on, while the editor has the focus: a share of the text's colour, which reads on any fill. |
cursor | Color | Color.Unspecified | The caret, which the handles of a selection take too. The theme's primary role. |
selection | Color | Color.Unspecified | The fill behind what is selected: the caret's colour, as faint as the theme's selection. |
matchingBracket | Color | Color.Unspecified | The edge round the bracket by the caret and round the one it pairs with: a share of the text's colour, which reads on any fill. |
match | Color | Color.Unspecified | The fill behind each match of the find bar's search, and, at its full strength, the tick of a line with a match on the scroll bar: a share of the theme's warning role. |
Accessibility
- Keyboard. Tab indents; after Escape, Tab moves the focus on and Shift+Tab back, so that the keyboard can always leave the editor.
- Screen reader. The editor's name is
contentDescription, "Code editor" where it is not given. On a platform that writes with a keyboard, the screen reader is also told what Tab does and how to leave. A mark's message and the find bar's count are said as they change; the line numbers are not read.