Files
aego/editor/panels/scripteditor/virtual.go
sanspie f22242e5aa
ci / release (push) Successful in 5m5s
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / checks (push) Successful in 4m41s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 7m14s
Stage 11g2–11g3: registry texts, CLI and the site in Russian (D348)
The remaining editor strings and undo step names; component, field, enum, setting, diagnostic and Script API texts under schema.*, enum.*, setting.*, diag.* and api.*; the launcher, the in-game Settings View with a Language setting, the CLI and aego schema show --lang. Every documentation page has a .ru.md translation; the site has a full Russian tree with hreflang, a language switch and ru/llms.txt; aego docs check --lang ru. New doc.tutorial and doc.recipe icons. Fix: an animator restored by a rewind prepares its controller before the replayed step.
2026-10-25 15:31:22 +03:00

82 lines
2.1 KiB
Go

package scripteditor
import (
"os"
"sort"
"strings"
"aego/core/errs"
"aego/editor/core/code"
"aego/editor/core/context"
"aego/editor/core/document"
"aego/engine/i18n"
"aego/script/langsvc"
"aego/ui/core"
)
const ()
func (h *Host) virtual(p string) (*document.ScriptDocument, error) {
switch {
case strings.HasPrefix(p, context.StubPrefix):
h.ensure()
st, ok := h.lang.Stub(p)
if !ok {
return nil, errs.New(errs.EditorDocument, "no library stub for "+strings.TrimPrefix(p, context.StubPrefix))
}
return &document.ScriptDocument{Path: p, Code: code.New([]byte(st.Text)), ReadOnly: true, Note: i18n.Tr("editor.scripteditor.stub_note", "Library stub generated from the engine bindings · read-only")}, nil
case strings.HasPrefix(p, context.GoPrefix):
data, err := os.ReadFile(strings.TrimPrefix(p, context.GoPrefix))
if err != nil {
return nil, errs.Wrap(err, errs.EditorDocument, "cannot read the Go source")
}
return &document.ScriptDocument{Path: p, Code: code.New(data), ReadOnly: true, Note: i18n.Tr("editor.scripteditor.go_note", "Go source · read-only")}, nil
}
return nil, errs.New(errs.EditorDocument, "unknown virtual document "+p)
}
func (h *Host) openStub(l langsvc.Location) bool {
st, ok := h.lang.Stub(l.Stub)
if !ok {
return false
}
h.Goto(context.At(l.Stub, st.Lines[l.Symbol]+1, 1))
return true
}
func (p *Panel) stubSource(ui *core.Context) {
if !strings.HasPrefix(p.doc.Path, context.StubPrefix) {
p.flash(ui.Time, i18n.Tr("editor.scripteditor.read_only_go", "This is read-only Go source"))
return
}
st, ok := p.host.lang.Stub(p.doc.Path)
if !ok {
return
}
cur := p.doc.Code.Line(p.doc.Code.Cursor())
type entry struct {
key string
line int
}
var list []entry
for k, l := range st.Lines {
if k != "" {
list = append(list, entry{k, l})
}
}
sort.Slice(list, func(i, j int) bool { return list[i].line < list[j].line })
key := ""
for _, e := range list {
if e.line >= cur {
key = e.key
break
}
}
impl, ok := p.host.lang.StubImplementation(p.doc.Path, key)
if !ok {
p.flash(ui.Time, builtinNote)
return
}
p.host.Goto(context.At(context.GoPrefix+impl.Path, impl.Line, 1))
}