Documentation: engine/docs assembles one registry from the script
bindings, the schema, module docs and module-owned script paths; problems
are reported as warnings at build time. Module registries record doc
sources and script module owners; diag.Codes lists every diagnostic code.
Project bootstrap: project.defaultSpace ("2d"/"3d"), EnsureDirs creates
the default folders when the editor opens a project (reported in the
console), prefabs/ is a pipeline root. Native builds drop -trimpath so
binding locations resolve inside native/.
Editor files: create scene/prefab/script from menus, move/rename/duplicate
/delete with undo, script package retargeting on move, open scenes and
script panels follow renames, Save As / Rename Scene prompts, scene
picker, startup scene. Scoped shortcuts fall back to the global command
when disabled; Save As is Ctrl+Shift+S, Save All Ctrl+Alt+S.
Script editor: Go to Implementation (stub → native/ source), host
definitions always resolve to stubs, bracket match/mismatch states,
rainbow brackets (persisted), mono code font (ui-mono atlases, per-command
fonts in draw.List, PushFont/PopFont restored by Mark/Restore).
Tests: langsvc definition/implementation, bracket states, dispatch
fallback, script renames, font stack, editor file-op integration, golden
mono glyph and bracket references; depcheck rule for engine/docs.
Docs pipeline: engine, render2d and script/engine ship their own res/docs;
keyword hover text comes from the registry through manifest.Keywords;
project script symbols join the registry; aego docs export|check|build|
serve, --tool docs in native binaries, aego check --explain; app/docstool
and the tools/gendocs module (goldmark) build the static site.
Playground: app/playground + cmd/aego-playground (js/wasm, 3.3 MB gzip)
compile, highlight and run scripts in the browser; run blocks in the
language docs become examples. engine/builtin/headless is the module set
without render3d; workspace.Config.FS; StubFor/StubPaths; backends and the
script importer drop out of js builds.
VM: one frame pointer in the interpreter loop, direct host calls, panic
recovery once per run instead of per host call (Update2k -19%,
Schedule10k -24% against the previous head). bench-build/compare/profile
run pre-built, pinned, interleaved binaries.
Editor: structural bracket levels and current-block highlight, indent
guides, occurrence highlighting with write marks, multi-format clipboard
(copy/cut/paste assets, paste images as sprites or textures). gl33 probes
a renderable depth format and reports framebuffer failures by stage.
7 E:
- project templates empty/2d/2.5d/3d, app/projects as the single creation path (D148)
- launcher and recent projects (D149)
- orthographic Camera3D and Scene View (D150)
- reference states in the Inspector, ids.Short (D151)
- sceneio remaps node references when loading without KeepIDs (D152)
- exported ComponentRef<T> (D153)
- aego icons via module.Audit (D146)
105 lines
2.1 KiB
Go
105 lines
2.1 KiB
Go
package richtext
|
|
|
|
import "strings"
|
|
|
|
func push(out []Span, text string, st Style, target string) []Span {
|
|
if text == "" {
|
|
return out
|
|
}
|
|
if n := len(out); n > 0 && out[n-1].Style == st && out[n-1].Target == target {
|
|
out[n-1].Text += text
|
|
return out
|
|
}
|
|
return append(out, Span{Text: text, Style: st, Target: target})
|
|
}
|
|
|
|
func wordChar(c byte) bool {
|
|
return c == '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'
|
|
}
|
|
|
|
func edge(s string, i int, closing bool) bool {
|
|
if closing {
|
|
return i > 0 && s[i-1] != ' '
|
|
}
|
|
if i+1 >= len(s) || s[i+1] == ' ' {
|
|
return false
|
|
}
|
|
return s[i] == '*' || i == 0 || !wordChar(s[i-1])
|
|
}
|
|
|
|
func Inline(s string) []Span {
|
|
return inline(s, "")
|
|
}
|
|
|
|
func inline(s, target string) []Span {
|
|
var out []Span
|
|
var cur strings.Builder
|
|
strong, em := false, false
|
|
style := func() Style {
|
|
switch {
|
|
case strong:
|
|
return Strong
|
|
case em:
|
|
return Emphasis
|
|
}
|
|
return Plain
|
|
}
|
|
emit := func() {
|
|
out = push(out, cur.String(), style(), target)
|
|
cur.Reset()
|
|
}
|
|
for i := 0; i < len(s); i++ {
|
|
c := s[i]
|
|
switch {
|
|
case c == '\\' && i+1 < len(s) && strings.IndexByte("\\`*_[]()#|<>-!", s[i+1]) >= 0:
|
|
cur.WriteByte(s[i+1])
|
|
i++
|
|
case c == '`':
|
|
j := strings.IndexByte(s[i+1:], '`')
|
|
if j < 0 {
|
|
cur.WriteByte(c)
|
|
continue
|
|
}
|
|
emit()
|
|
out = push(out, s[i+1:i+1+j], Code, target)
|
|
i += j + 1
|
|
case c == '[':
|
|
j := strings.Index(s[i:], "](")
|
|
if j < 0 {
|
|
cur.WriteByte(c)
|
|
continue
|
|
}
|
|
k := strings.IndexByte(s[i+j+2:], ')')
|
|
if k < 0 {
|
|
cur.WriteByte(c)
|
|
continue
|
|
}
|
|
emit()
|
|
label, dest := s[i+1:i+j], s[i+j+2:i+j+2+k]
|
|
for _, sp := range inline(label, dest) {
|
|
out = push(out, sp.Text, sp.Style, sp.Target)
|
|
}
|
|
i += j + 2 + k
|
|
case c == '*' && i+1 < len(s) && s[i+1] == '*':
|
|
emit()
|
|
strong = !strong
|
|
i++
|
|
case (c == '*' || c == '_') && edge(s, i, em):
|
|
emit()
|
|
em = !em
|
|
default:
|
|
cur.WriteByte(c)
|
|
}
|
|
}
|
|
emit()
|
|
return out
|
|
}
|
|
|
|
func PlainText(spans []Span) string {
|
|
var b strings.Builder
|
|
for _, sp := range spans {
|
|
b.WriteString(sp.Text)
|
|
}
|
|
return b.String()
|
|
}
|