keys

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package keys provides key binding definitions and utilities for the TUI.

Index

Constants

This section is empty.

Variables

View Source
var (
	Quit = key.NewBinding(
		key.WithKeys("q", "ctrl+c"),
		key.WithHelp("q", "quit"),
	)
	Help = key.NewBinding(
		key.WithKeys("?", "h"),
		key.WithHelp("?/h", "toggle help"),
	)
	Back = key.NewBinding(
		key.WithKeys("esc"),
		key.WithHelp("esc", "go back"),
	)
	ViewDetails = key.NewBinding(
		key.WithKeys("y"),
		key.WithHelp("y", "toggle details"),
	)
	CopyName = key.NewBinding(
		key.WithKeys("n"),
		key.WithHelp("n", "copy name"),
	)
)

Global key bindings (always active)

View Source
var (
	NextCategory = key.NewBinding(
		key.WithKeys("shift+right"),
		key.WithHelp("shift+→", "next category"),
	)
	PrevCategory = key.NewBinding(
		key.WithKeys("shift+left"),
		key.WithHelp("shift+←", "previous category"),
	)
	FilterList = key.NewBinding(
		key.WithKeys("/"),
		key.WithHelp("/", "filter list"),
	)
	JumpTo = key.NewBinding(
		key.WithKeys(":"),
		key.WithHelp(":", "jump to category"),
	)
	PasteFilter = key.NewBinding(
		key.WithKeys("p"),
		key.WithHelp("p", "paste as filter"),
	)
	Confirm = key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "enter context"),
	)
)

Mode-specific key bindings

View Source
var (
	// CopyObject is a key binding for copying the value of an item in the details view.
	CopyObject = key.NewBinding(
		key.WithKeys("o"),
		key.WithHelp("o", "copy object as JSON"),
	)
	// CopyTenant is a key binding for copying the tenant ID in the tenant context.
	CopyTenant = key.NewBinding(
		key.WithKeys("t"),
		key.WithHelp("t", "copy tenant ocid"),
	)
)

Functions

func CatContext

func CatContext() map[domain.Category]map[common.ViewMode][]key.Binding

CatContext returns the mapping of category and view mode to context-specific key bindings.

func DetailsModeKeys

func DetailsModeKeys() []key.Binding

DetailsModeKeys returns a copy of the key bindings for details mode.

func GlobalKeys

func GlobalKeys() []key.Binding

GlobalKeys returns a copy of the global key bindings (always active).

func ListModeKeys

func ListModeKeys() []key.Binding

ListModeKeys returns a copy of the key bindings for list mode.

Types

type KeyMap

type KeyMap struct {
	Global  []key.Binding // always active
	Mode    []key.Binding // active for current UI mode
	Context []key.Binding // category-specific and mode-specific (optional)
}

KeyMap holds key bindings for the TUI, composed of global, mode, and context (category+mode) keys.

func FullKeyMap

func FullKeyMap() KeyMap

FullKeyMap returns a KeyMap with all unique keys in each section.

func ResolveKeys

func ResolveKeys(cat domain.Category, mode common.ViewMode) KeyMap

ResolveKeys returns the composed KeyMap for the given category and UI mode.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns a full list of key bindings for help display, chunked per category.

func (KeyMap) Help

func (k KeyMap) Help() key.Binding

Help returns the help key binding from the global keys.

func (KeyMap) Quit

func (k KeyMap) Quit() key.Binding

Quit returns the quit key binding from the global keys.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns a short list of key bindings for help display.

Jump to

Keyboard shortcuts

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