keyhints

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 3 Imported by: 0

README

Key hints

Compact footer of key-and-description pairs separated by a thin divider.

key-hints preview

Install

glyph add key-hints

This copies key-hints.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no key-hints library to keep in sync.

Hello, world

package main

import (
	"fmt"

	keyhints "github.com/truffle-dev/glyph/components/key-hints"
	"github.com/truffle-dev/glyph/components/theme"
)

func main() {
	hints := keyhints.New(theme.Default).
		WithHints([]keyhints.Hint{
			{Key: "Tab", Desc: "next pane"},
			{Key: "q", Desc: "quit"},
		})
	fmt.Println(hints.View())
}

API surface

Package: keyhints

API surface inferred from source — see pkg.go.dev.

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/lipgloss@v1.1.0

Notes

Pure render. Build a []keyhints.Hint{{Key, Desc}, ...} from your model's current binding set; the bar lays it out left-to-right and clamps to WithWidth.

See also

License

MIT, same as the rest of glyph.

Documentation

Overview

Package keyhints renders a compact footer of "<key> <description>" pairs separated by a thin divider. It's the bottom-row cheatsheet almost every TUI grows into; building it as a primitive saves the same render code from being rewritten in every parent model.

Hints are pure render: there is no Update, no message. Build the hint set from your model and let key-hints lay it out.

Index

Constants

View Source
const DefaultSeparator = "  "

Default separator placed between adjacent hints.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

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

Bar is a row of key hints.

func New

func New(t theme.Theme) Bar

New constructs an empty hint bar.

func (Bar) View

func (b Bar) View() string

View renders the bar.

func (Bar) WithHints

func (b Bar) WithHints(hints []Hint) Bar

WithHints replaces the hint set.

func (Bar) WithSeparator

func (b Bar) WithSeparator(s string) Bar

WithSeparator overrides the inter-hint separator.

func (Bar) WithWidth

func (b Bar) WithWidth(w int) Bar

WithWidth clamps the render width. The bar truncates from the right when the natural width exceeds the clamp. Values <= 0 mean natural.

type Hint

type Hint struct {
	Key  string
	Desc string
}

Hint is one key/description pair.

Jump to

Keyboard shortcuts

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