comp

package
v0.0.0-...-41dac6c Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const PaintingDuration = 1200 * time.Millisecond

PaintingDuration is how long the painting overlay shows.

Variables

This section is empty.

Functions

func FloatButtons

func FloatButtons(c *ui.Context, helpImg, runImg *ui.Bitmap, onHelp, onRun func())

FloatButtons renders the help and run buttons in the bottom corners.

func IconButton

func IconButton(c *ui.Context, opt IconButtonOption) ui.Element

func ImageButton

func ImageButton(c *ui.Context, img *ui.Bitmap, onClick func())

ImageButton renders an image button sized for the floating corners. The image eases larger while the pointer is over the button.

func LevelGroups

func LevelGroups(n int, id func(int) string) [][]int

LevelGroups groups level indexes by chapter, from each level id's leading digit: 1.03 is chapter one, 2.20 is chapter two.

func LoadPrefs

func LoadPrefs()

LoadPrefs reads the settings file and applies sound and theme. Call once at startup, before the first frame.

func Painting

func Painting(c *ui.Context, left, right *ui.Bitmap)

Painting draws the painting overlay across the window.

func PaintingActive

func PaintingActive(c *ui.Context, until time.Time) bool

PaintingActive reports whether the painting overlay shows until.

func SaveSVG

func SaveSVG(defaultName string, data []byte, notice *Notice)

SaveSVG writes data to a user-chosen SVG file and reports the result.

func ShowDialogWithImage

func ShowDialogWithImage(c *ui.Context, opt DialogOption)

ShowDialogWithImage shows an image dialog; the last button is the primary action.

Types

type Alert

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

Alert is a feedback alert that closes itself on outside click, Escape or through the close function passed to content.

func (*Alert) Close

func (a *Alert) Close()

Close dismisses the alert.

func (*Alert) IsOpen

func (a *Alert) IsOpen() bool

IsOpen reports whether the alert shows.

func (*Alert) Open

func (a *Alert) Open()

Open shows the alert.

func (*Alert) View

func (a *Alert) View(c *ui.Context, tone feedback.Tone, title, body string, content func(close func()))

View renders the alert; content receives the function that closes it.

type CopyButton

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

CopyButton copies code to the clipboard and shows a check mark briefly.

func NewCopyButton

func NewCopyButton(getContent func() string) *CopyButton

NewCopyButton creates a CopyButton.

func (*CopyButton) View

func (b *CopyButton) View(c *ui.Context)

View renders the copy button.

type DialogOption

type DialogOption struct {
	Title   string
	Open    *bool
	Img     *ui.Bitmap
	Buttons []string
	OnClick func(btnIndex int)
}

type Help

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

Help owns the docs viewer state.

func NewHelp

func NewHelp(cfg HelpConfig) *Help

NewHelp creates a Help component.

func (*Help) Open

func (h *Help) Open()

Open shows the document viewer directly.

func (*Help) View

func (h *Help) View(c *ui.Context)

View renders the document modal when open.

type HelpConfig

type HelpConfig struct {
	LoadDoc func(locale string, tab int) string
}

HelpConfig configures the Help component.

type IconButtonOption

type IconButtonOption struct {
	Icon       *ui.SVG
	SecondIcon *ui.SVG
	ShowSecond bool
	OnClick    func()
	Primary    bool
}

type Notice

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

Notice shows a message in the middle of the window for a while.

func (*Notice) Show

func (n *Notice) Show(tone feedback.Tone, title, body string, dur time.Duration)

Show shows the notice for dur.

func (*Notice) View

func (n *Notice) View(c *ui.Context)

View renders the notice while its time lasts.

type Workspace

type Workspace struct {
	Editor *editor.State
	// contains filtered or unexported fields
}

Workspace lays out the canvas, code editor, help dialog and floating buttons.

func NewWorkspace

func NewWorkspace(fsys fs.FS, cfg WorkspaceConfig) *Workspace

NewWorkspace creates a workspace.

func (*Workspace) ClearError

func (w *Workspace) ClearError()

ClearError removes the marks.

func (*Workspace) Docs

func (w *Workspace) Docs()

Docs opens the help document modal.

func (*Workspace) FocusEditor

func (w *Workspace) FocusEditor()

FocusEditor focuses the code editor in the next frame.

func (*Workspace) MakeError

func (w *Workspace) MakeError(line int, msg string)

MakeError marks line, from 1, and shows msg under it.

func (*Workspace) View

func (w *Workspace) View(c *ui.Context)

View renders the workspace.

type WorkspaceConfig

type WorkspaceConfig struct {
	Code       string
	DocModule  string
	Canvas     func(c *ui.Context)
	OnRun      func(c *ui.Context)
	OnPractice func(level int) // fired on tutorial toggle: 0 to enter, -1 to leave
	OnHelp     func()          // replaces opening the docs, e.g. with a level hint
}

WorkspaceConfig configures the shared workspace shell.

Jump to

Keyboard shortcuts

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