Documentation
¶
Overview ¶
The doctor diagnostics block: one line block a bug report carries verbatim ("here is my lys-ui doctor output"), covering the session's bound globals and their versions, outputs and scales, the resolved cursor theme, the fonts sysfont selected, and the shm buffer format. Everything is read-only snapshot data; the app prints it at startup behind a flag, and nothing here requires the inspector to be armed.
Package inspect is lys-ui's debug inspector (the GTK-inspector counterpart): a widget-tree overlay drawn over the live UI, the tree dump for bug reports, and the doctor diagnostics block.
Prod visibility: everything here is always compiled in but inert until asked for - LYS_UI_INSPECT=1 at startup, an explicit Application.SetInspect/ToggleInspect call, or (for the dump and doctor) an explicit call. With the inspector off, an app pays one passthrough call per frame operation and one bool check per key press; nothing traces, draws, or allocates. The lysdebug build tag was deliberately NOT used: the inspector exists to debug prod binaries in the field, where tagged builds do not exist. Real trace instrumentation stays behind the tag (internal/debug).
Index ¶
- func Doctor(sess *wlsession.Session, opts DoctorOptions) string
- func DoctorFrom(info wlsession.InspectInfo, opts DoctorOptions) string
- func Dump(root widget.Widget, r *widget.Router) string
- func Enabled() bool
- func PaintAnnotations(cv *render.Canvas, nodes []widget.NodeInfo)
- func SetLabelFont(f *render.Typeface)
- type DoctorOptions
- type Overlay
- func (o *Overlay) Arrange(r render.Rect)
- func (o *Overlay) Children() []widget.Widget
- func (o *Overlay) HitTest(p widget.Point) widget.Widget
- func (o *Overlay) Measure(axis widget.Axis, forSize int) widget.Sizes
- func (o *Overlay) On() bool
- func (o *Overlay) Paint(cv *render.Canvas)
- func (o *Overlay) Root() widget.Widget
- func (o *Overlay) SetOn(on bool)
- func (o *Overlay) SetRouter(r *widget.Router)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Doctor ¶
func Doctor(sess *wlsession.Session, opts DoctorOptions) string
Doctor renders the diagnostics block from a live session. A nil session formats the non-session lines (fonts, buffer) and marks the session lines unavailable, so a doctor run before Connect still produces the block.
func DoctorFrom ¶
func DoctorFrom(info wlsession.InspectInfo, opts DoctorOptions) string
DoctorFrom renders the diagnostics block from a session snapshot. The format is stable: tests pin every line's shape, so tooling (and humans skimming an issue) can rely on it.
func Dump ¶
Dump renders the tree dump for bug reports: one banner line, then the stable widget.DumpTree format (one indented line per widget with type, debug name, bounds, role, tooltip, and input-state flags). Print it to stdout on demand; the exact bytes are pinned by tests, so a dump in an issue means the same thing to everyone.
func Enabled ¶
func Enabled() bool
Enabled reports whether the environment asked for the inspector at startup: LYS_UI_INSPECT set to 1, true, yes, or on (case-insensitive). Anything else - unset, empty, 0, off - leaves it off.
func PaintAnnotations ¶
PaintAnnotations draws the inspector overlay for a snapshot taken with widget.InspectTree: per-widget bounds with an alternating tint per depth, a name/type label chip, the hovered subtree washed stronger, and the router's hover and focus targets outlined in their own colors. It only reads the snapshot and draws; it never touches widget state, so tests can pin it as side-effect free.
func SetLabelFont ¶
SetLabelFont overrides the face overlay labels use.
Types ¶
type DoctorOptions ¶
type DoctorOptions struct {
// Sans and Mono name the resolved default faces; empty resolves
// them through sysfont.Sans/Monospace at format time.
Sans, Mono string
}
DoctorOptions carries the doctor's overridable inputs. Empty fields mean "resolve it yourself": the font names come from sysfont's default resolution.
type Overlay ¶
Overlay wraps a widget tree and paints inspector annotations over it: bounds with a per-depth alternating tint, the debug name or type as a label, the hovered subtree, the router's hover target, and the focus target, each marked distinctly.
The overlay is transparent plumbing while it is off: Measure, Arrange, HitTest, and the tree walks all pass straight through to the wrapped root, so wrapping never changes layout, hit testing, or damage. Painting annotations only reads state (widget.InspectTree); it never invalidates or mutates a widget. It is a node in the parent chain, though: the root's invalidations climb through it to the window's caches, which a parentless root would cut off.
func NewOverlay ¶
NewOverlay wraps root. The overlay starts off; SetOn turns the annotations on. It never wraps nil: a nil root passes through as a harmless empty widget.
func (*Overlay) Arrange ¶
Arrange implements widget.Widget, passing through to the root and parenting it.
func (*Overlay) Children ¶
Children exposes the wrapped root, so tree walks (damage collection, focus traversal) see the real tree.
func (*Overlay) HitTest ¶
HitTest implements widget.Widget, passing through to the root so input routing lands on real widgets, never on the overlay.
func (*Overlay) Paint ¶
Paint implements widget.Widget: the root paints first, then the annotations when the overlay is on. The annotation pass is a pure function of widget state - no invalidation, no state changes.