Files
aego/editor/panels/crashes/panel.go
sanspie 2fcbaa6c12 Stage 11g1: the editor in Russian (D348)
engine/i18n with catalogs, plural forms and module catalogs; tools/i18n extract and check; the editor UI, menus, panels and notices in Russian with the author's terms; overflow test and tooltip wrapping; the English log.
2026-10-25 15:31:22 +03:00

72 lines
1.7 KiB
Go

package crashes
import (
"strconv"
"aego/core/mathx"
"aego/editor/core/context"
"aego/editor/core/services"
"aego/editor/core/state"
"aego/engine/i18n"
"aego/ui/core"
"aego/ui/widgets"
)
const ID = "crashes"
type Panel struct {
root string
nav services.Navigation
list []state.CrashReport
at float64
scroll float32
}
func New(root string, nav services.Navigation) *Panel {
return &Panel{root: root, nav: nav, at: -10}
}
func (p *Panel) ID() string {
return ID
}
func (p *Panel) Title() string {
return i18n.Tr("editor.crashes.title", "Crash Reports")
}
func (p *Panel) Draw(f *services.Frame, r mathx.Rect) {
ui := f.UI
th := &ui.Theme
if f.Now-p.at > 2 {
p.list, p.at = state.CrashReports(p.root), f.Now
}
if len(p.list) == 0 {
widgets.LabelDim(ui, i18n.Tr("editor.crashes.no_crash_reports_in_aego", "No crash reports in .aego/crash"))
return
}
widgets.LabelDim(ui, i18n.Tr("editor.crashes.list_report_s_click_opens", "{list} report(s); click opens the script line, or copies the folder path", i18n.Str("list", strconv.Itoa(len(p.list)))))
top := ui.Cursor().Y
list := mathx.Rect{X: r.X, Y: top, W: r.W, H: max(0, r.Y+r.H-top)}
widgets.VirtualList(ui, ui.ID("list"), list, len(p.list), th.RowHeight, &p.scroll, func(i int, row mathx.Rect) {
c := &p.list[i]
id := core.IDSeq(ui.ID("row"), i)
if ui.Pressed(id, row) {
if c.Path != "" {
p.nav.Open(context.At(c.Path, c.Line, 1))
} else if ui.Clipboard != nil {
ui.Clipboard.SetText(c.Dir)
}
}
if ui.Hot() == id {
ui.Rect(row, th.WidgetHot)
}
col := th.Error
if c.Kind == "spike" {
col = th.Warn
}
ui.PushClip(row)
ui.Text(c.Time+" "+c.Kind+" "+c.Where+" "+c.Message, mathx.Vec2{X: row.X + 4, Y: ui.TextY(row)}, col)
ui.PopClip()
})
}