components
All repositories: gitoria
2.8 KB
# Code editorA code field: the code is **coloured while you type**, line numbers follow, **Tab** indents and **Shift+Tab** outdents,**Ctrl+Z / Ctrl+Shift+Z** undo and redo. A port of custom-ide's CodeJar editor as a pure Hybriel component: no JavaScriptof its own. Demo: `/code-editor`.Use it in a page:```import CodeEditor from './code-editor.hl'form { method = "post" action = "/save"CodeEditor { name = "source" value = "let x = 1" language = "js" }}```## FilesCopy `code-editor.hl` (one file; it has its own `Style`). Nothing else. Every colour is `var(--color-…, <palette value>)`(the syntax colours use the palette tokens `--orange`, `--green-light`, `--yellow`, `--green-dark`), so an app thatdeclares the WorldAPI tokens (and its `--color-accent`) wins and an app without them still looks right.## Attributes| Attribute | Meaning ||---|---|| `name` | the field name the text posts under (default `code`) || `value` | the start text || `language` | `hybriel` (default), `js` (or `javascript`), `plain` (no colours) || `spaces` | 0 (default): Tab writes a tab character; N: Tab writes N spaces |## What it does- **Highlighting** while typing: comments (`//`, `/* */`), strings (`'` `"` `` ` ``), numbers, keywords, function names (a namebefore `(`), Capitalised names (types). The caret stays where it was.- **Line numbers** in a gutter that follows the number of lines (it scrolls sideways with the code).- **Tab / Shift+Tab**: at the caret a tab (or `spaces` spaces) is inserted / removed; with several lines selected every line isindented / outdented.- **Enter** keeps the indent of the line; after `(` `[` `{` it indents once more, and a closing bracket right behind the caretmoves to its own line.- **Brackets and quotes** close themselves (a selection is wrapped); typing the closing character right before the same onesteps over it; an apostrophe inside a word (`don't`) stays alone.- **Undo / redo**: Ctrl+Z, Ctrl+Shift+Z (or Ctrl+Y). The editor keeps its own history (snapshots of text and caret, 300 atmost); typing within 300 ms is one step, Enter / Tab / a bracket / a paste are their own steps.- **Paste** is taken as plain text; the text is never treated as HTML.## Reading the valueThe text is in a hidden `<input name>`, so it posts in a form. A change is announced with a bubbling DOM `input` event on thatfield (`e.target.name`, `e.target.value`); the demo shows it below each editor:```form { on input(e) { emit gotCode(e) } … }on gotCode(e) { if (e.target.name == 'source') { source = e.target.value } }```## Not in it (custom-ide has more)Search, minimap, breadcrumbs, change bars, per-language grammars beyond the three above, read-only mode. Not tested: Firefox,Safari, touch, IME input (composition is left alone until it ends), very large files. Editing needs the page to be live(Hybriel has no mount event; the code appears when the page has loaded).
Branches
- mainmain branch
Latest commits
- 172914a3components code order (mission 002) 2/4: lib/uploads.hl (demo upload storage), thin demo handlers, project.hl map; gate 220/0, same outputmre
- d29f35b1components code order (mission 002) 1/4: styles.hl -> components/styles.hl; gate 220/0, same outputmre
- 09945750components: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, http1 773de63e); gate 220/0mre
- ede4d19acomponents: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 220/0mre
- 2bb9a935components: Hybriel master 8efba065 (re-vendor round 069: #126 memory, #48 lambda copy)mre
- e4f01768antcolony#40: mission references point to the moved missionsmre
- d32b44e2antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- 0fb80b57components: Hybriel master ff51cf46 (re-vendor round)mre
- 57408b6ecomponents#14: installable app (manifest, service worker, offline index), own iconmre
- 317bd09fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- becbd59bcomponents#13: modal dialog (<dialog> based, focus wrap, backdrop/Esc/x close with reason, scroll lock, footer buttons)mre
- 367dd19adeploy.sh: never send .git or .gitignore to Byrodinmre
- 4b4dabe5State of 2026-09-27, before the move to gitoriamre