help

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package help is vigo's contextual-help slot. Every view carries a HelpCtx; pressing F1 should open the topic registered for the focused view's context. v0.2 ships only the wiring and an About dialog; the real topic browser arrives in v0.7.

Index

Constants

This section is empty.

Variables

View Source
var Version = "v0.2.0"

Version is the human-readable build label shown in the About dialog. Hosts override it from main if they want a richer string (commit hash, build date, etc.).

Functions

func About

func About(r *Registry) *dialog.Dialog

About returns a small modal Dialog displaying the About topic from r. The dialog is not inserted anywhere; pass it to Application.ExecView (or similar) to show it modally.

Types

type HelpCtx

type HelpCtx uint16

HelpCtx identifies a help topic. Zero (CtxNone) means the view has no specific topic; F1 then falls back to the About dialog.

const (
	CtxNone  HelpCtx = 0
	CtxAbout HelpCtx = 1

	CtxUser HelpCtx = 100
)

Reserved help contexts. User contexts start at CtxUser.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps HelpCtx values to topics. The zero value is ready to use; pass it around by pointer so writes are visible everywhere.

func Default

func Default() *Registry

Default returns a registry seeded with the About topic. Hosts use it as a starting point and Register additional contexts on top.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Lookup

func (r *Registry) Lookup(ctx HelpCtx) (Topic, bool)

Lookup returns the topic registered for ctx and whether one was found. Callers should fall back to CtxAbout when ok is false.

func (*Registry) Register

func (r *Registry) Register(ctx HelpCtx, t Topic)

Register stores t under ctx, replacing any prior topic.

func (*Registry) Resolve

func (r *Registry) Resolve(ctx HelpCtx) Topic

Resolve returns the topic for ctx, or the About topic when ctx is not registered. If neither is registered it returns the zero Topic.

type Topic

type Topic struct {
	Title string
	Body  string
}

Topic is one entry in the registry: a short title plus the body text shown in the help viewer. v0.2 only renders Title in the About dialog; v0.7 will paint Body in a scrolling Help window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL