Browse documentation
Code editor
Edit large source buffers with syntax highlighting and viewport-only shaping.
Import
Load the optional component layer before using the examples below.
Ruby
require "zaniah/ui"Basic editor
Pass a string or a line-addressable buffer. Specify language: for bundled syntax scopes.
Rendered example

Ruby
Zaniah::UI::CodeEditor.new(
"def hello\n :world\nend\n",
language: :ruby, line_numbers: true)
Buffer and highlighting
A custom buffer exposes line_count, line, line_start, line_of, replace, undo, and redo. An optional highlighter returns scoped token ranges.
API summary
Constructor options and behaviors are drawn from the component reference.
| Component | Constructor and methods | Variants or behavior |
|---|---|---|
CodeEditor | (value, buffer:, highlighter:, wrap:, language:, line_numbers:, read_only:); on_change | viewport-only multiline editor with syntax scopes and Tab indentation |
Accessibility
CodeEditor exposes a multiline textbox with keyboard selection, IME, Tab indentation, and undo/redo.
| Component | Semantic role |
|---|---|
CodeEditor | textbox |