gitoriaLog in with ident

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchmain3bc905c5components #15 (mission 003) 2/2: docs (README Look, STATUS, LOG), reportmremain/components/code-editor/README.md

2.9 KB

  1. # Code editor
  2. A code field: the code is **coloured while you type**, line numbers follow, **Tab** indents and **Shift+Tab** outdents,
  3. **Ctrl+Z / Ctrl+Shift+Z** undo and redo. A port of custom-ide's CodeJar editor as a pure Hybriel component: no JavaScript
  4. of its own. Demo: `/code-editor`.
  5. Use it in a page:
  6. ```
  7. import CodeEditor from './code-editor.hl'
  8. form { method = "post" action = "/save"
  9. CodeEditor { name = "source" value = "let x = 1" language = "js" }
  10. }
  11. ```
  12. ## Files
  13. Copy `code-editor.hl` (one file; it has its own `Style`). Nothing else. Every colour is `var(--color-…, <base value>)`
  14. (the syntax colours use the palette tokens `--orange`, `--green-light`, `--yellow`, `--green-dark`): without them the code is
  15. black and the syntax greys (the base look: black, white, greys, no frames — root README "Look"); an app that declares the
  16. WorldAPI tokens (and its `--color-accent`) restyles it.
  17. ## Attributes
  18. | Attribute | Meaning |
  19. |---|---|
  20. | `name` | the field name the text posts under (default `code`) |
  21. | `value` | the start text |
  22. | `language` | `hybriel` (default), `js` (or `javascript`), `plain` (no colours) |
  23. | `spaces` | 0 (default): Tab writes a tab character; N: Tab writes N spaces |
  24. ## What it does
  25. - **Highlighting** while typing: comments (`//`, `/* */`), strings (`'` `"` `` ` ``), numbers, keywords, function names (a name
  26. before `(`), Capitalised names (types). The caret stays where it was.
  27. - **Line numbers** in a gutter that follows the number of lines (it scrolls sideways with the code).
  28. - **Tab / Shift+Tab**: at the caret a tab (or `spaces` spaces) is inserted / removed; with several lines selected every line is
  29. indented / outdented.
  30. - **Enter** keeps the indent of the line; after `(` `[` `{` it indents once more, and a closing bracket right behind the caret
  31. moves to its own line.
  32. - **Brackets and quotes** close themselves (a selection is wrapped); typing the closing character right before the same one
  33. steps over it; an apostrophe inside a word (`don't`) stays alone.
  34. - **Undo / redo**: Ctrl+Z, Ctrl+Shift+Z (or Ctrl+Y). The editor keeps its own history (snapshots of text and caret, 300 at
  35. most); typing within 300 ms is one step, Enter / Tab / a bracket / a paste are their own steps.
  36. - **Paste** is taken as plain text; the text is never treated as HTML.
  37. ## Reading the value
  38. The text is in a hidden `<input name>`, so it posts in a form. A change is announced with a bubbling DOM `input` event on that
  39. field (`e.target.name`, `e.target.value`); the demo shows it below each editor:
  40. ```
  41. form { on input(e) { emit gotCode(e) } … }
  42. on gotCode(e) { if (e.target.name == 'source') { source = e.target.value } }
  43. ```
  44. ## Not in it (custom-ide has more)
  45. Search, minimap, breadcrumbs, change bars, per-language grammars beyond the three above, read-only mode. Not tested: Firefox,
  46. Safari, touch, IME input (composition is left alone until it ends), very large files. Editing needs the page to be live
  47. (Hybriel has no mount event; the code appears when the page has loaded).

Branches

  • mainmain branch

Latest commits

  • 3bc905c5components #15 (mission 003) 2/2: docs (README Look, STATUS, LOG), reportmre
  • 5a98d77ecomponents #15 (mission 003) 1/2: black/white base look — greys for nuances, no WorldAPI fallbacks, no decorative frames; site + icon black/white; gate 230/0mre
  • 3f93d716components code order (mission 002) 4/4: docs, tests/letcount.py, tests/same-output*, reportmre
  • e747cfa0components code order (mission 002) 3/4: let only where reassigned (257 dropped, 0 never-reassigned left); gate 220/0, layouts gate 73/0, same outputmre
  • 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