help

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package help provides a dumb, reusable, lazygit-style help overlay: a centered, capped-size box listing key-binding sections. It holds no application state and knows nothing about actual keybindings beyond what SetSections is given — callers own deciding what to show, when to show it, and closing it (this component never consumes esc/? itself).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Keys string
	Desc string
}

Binding is a single key-binding entry: the key(s) that trigger it and a short description of what they do.

type Model

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

Model is the help overlay component.

func New

func New(r theme.Roles) Model

New creates a help overlay drawn from the semantic palette.

func (Model) IsVisible

func (m Model) IsVisible() bool

IsVisible reports whether the overlay is currently shown.

func (*Model) SetFooter

func (m *Model) SetFooter(text string)

SetFooter overrides the footer hint line (default: "↑↓/jk: scroll · Esc/?: close"). Pass "" to fall back to the default. Exists because the actual keys that scroll/close the overlay are decided by the caller (e.g. a configurable/rebound keys.help), not by this component — a hardcoded footer here would silently drift out of sync with whatever the caller actually binds.

func (*Model) SetSections

func (m *Model) SetSections(s []Section)

SetSections replaces the sections shown, in the order given. Resets scroll to the top, since a previous scroll offset is unlikely to still make sense against different content.

func (*Model) SetSize

func (m *Model) SetSize(w, h int)

SetSize sets the window size the overlay is centered/clamped within.

func (*Model) SetVisible

func (m *Model) SetVisible(v bool)

SetVisible shows or hides the overlay. Resets scroll to the top on show, so re-opening the overlay always starts from the beginning.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update handles j/k/up/down/pgup/pgdown/g/G scroll keys while the overlay is visible.

This is NOT part of help's required contract (New/SetSections/ SetVisible/IsVisible/SetSize/View): a caller that never invokes it still gets a fully working, correctly rendered overlay — it just can't scroll content that overflows the box height. A caller that wants scroll support should route key events here while IsVisible() is true; esc/? must stay handled by the caller outside Update (this component never closes itself), typically by checking those keys before ever reaching this method.

func (Model) View

func (m Model) View() string

View renders the overlay: a centered box with a title, the (possibly scrolled) section content, and a footer hint — or an empty string when not visible.

type Section

type Section struct {
	Title    string
	Bindings []Binding
}

Section is one titled group of key bindings shown in the overlay (e.g. "Navigation", "Search", "Folders"), rendered in the order given.

Jump to

Keyboard shortcuts

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