Code editor: keys, gutter, highlighting and completion

The Scripting page's editor is a transparent textarea over a synchronised gutter and a coloured layer. It adds line numbers, indentation keys, syntax colours and an API completion list without pulling in an editor library.

Senzoukria · Documentation · Updated September 2026


Where to find it

Where
Scripting page → the central editing surface
Indent unit
Two spaces — the same as the sample scripts and the assistant's output
Spell check
Off
Completion source
lib.* in JavaScript, of.* in Python — the language decides which list is offered
Accessible name
"Script source code"

What it does

A plain textarea loses Tab to focus navigation, shows no line numbers and offers no shortcuts — three things that matter as soon as you write a real script. This editor keeps the browser's native typing behaviour (selection, undo, IME, accessibility) and adds the missing parts around it: a gutter that scrolls with the text, a coloured layer underneath and a completion list.

The gutter marks the caret line, and the line reported by a failed run is highlighted in red, so "Line 23" from the console points at something you can see.

Keys

Keys handled by the editor
KeyDefaultWhat it changes
Tabinsert two spacesOn a multi-line selection it indents the whole block instead.
Shift+TabRemoves one indent level from the line or the selected block.
Enterkeep indentKeeps the current line's indentation, and adds one level after a line that opens a block.
Ctrl/Cmd+SSaves the script.
Ctrl/Cmd+EnterRuns the script on the sample data.
Arrow Up / DownMoves through the completion list while it is open.
Enter or Tab (list open)Accepts the highlighted completion, replacing the typed prefix.
EscapeCloses the completion list without inserting.

Highlighting and completion

  • The tokeniser makes a single pass, character by character, and emits CSS classes rather than colours, so the palette lives with the product's design tokens and follows the theme.
  • Keyword sets are per language: JavaScript, Python and C++ each have their own.
  • The completion list offers the calculation helpers shared by both languages — sma, ema, wilder, stdev, highest, lowest, rsi and atr — plus the output builders of the declared language.
  • JavaScript output builders are line, histogram, markers, levels, table and panel. Python has the same six plus bands, a single marker() and a single level(), and takes time as its first argument instead of bars.
  • Every completion is transcribed from the code that implements it, never written from memory: a wrong completion would teach an API that does not exist.

Limits and pitfalls

  • Scrolling closes the completion list on purpose — an absolutely positioned list would otherwise end up pointing at a different line of code.
  • There is no folding, no multi-cursor and no language server: this is a small editor by design, and it adds no weight to the bundle.
  • The coloured layer and the textarea must share the same metrics. If you override fonts or spacing in a custom theme, the colours can drift from the typed text.

This page in other languages

Frequently asked questions

Why does the completion offer of.* in one script and lib.* in another?
The list follows the script's declared language. JavaScript scripts build outputs through lib, Python scripts through of, and offering both would teach half an API that does not exist in the file you are writing.
Can I use four-space indentation?
You can type it, but Tab inserts two spaces, which is what the sample scripts and the assistant produce. Mixing the two in one Python file is the usual source of an indentation error.
Does the editor validate my code as I type?
No. Validation happens when you run: the run reports the failing line, and that line is then highlighted in the gutter.

Keep reading