keys

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package keys provides utilities for key(board) handling and configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultBind

func SetDefaultBind(kb **KeyBind, defaultKb KeyBind)

func ValidateBinds

func ValidateBinds(kbs ...[]KeyBind) error

Types

type Key

type Key struct {
	// Code is the key code identifier.
	Code string `json:"code" jsonschema:"title=Code"`
	// Alias is an alternative display name for the key.
	Alias string `json:"alias,omitempty" jsonschema:"title=Alias"`
	// Hidden determines if the key should be hidden from display.
	Hidden bool `json:"hidden,omitempty" jsonschema:"title=Hidden"`
}

Key represents a keyboard key with optional alias and visibility settings.

func New

func New(code string, opts ...KeyOpt) Key

func (Key) String

func (k Key) String() string

type KeyBind

type KeyBind struct {
	// Description provides a description of what the key binding does.
	Description string `json:"description" jsonschema:"title=Description"`
	// Keys contains the list of keys that trigger this binding.
	Keys []Key `json:"keys" jsonschema:"title=Keys"`
}

KeyBind represents a key binding with its description and associated keys.

func NewBind

func NewBind(description string, keys ...Key) KeyBind

func (*KeyBind) AddKey

func (kb *KeyBind) AddKey(key Key)

func (*KeyBind) Match

func (kb *KeyBind) Match(key string) bool

func (*KeyBind) String

func (kb *KeyBind) String() string

func (*KeyBind) StringRow

func (kb *KeyBind) StringRow(keyWidth, descWidth int) string

KeyWidth should generally be the maximum width of any individual keybind string in the column.

type KeyBindRenderer

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

func (*KeyBindRenderer) AddColumn

func (kbr *KeyBindRenderer) AddColumn(kbs ...KeyBind)

func (*KeyBindRenderer) Render

func (kbr *KeyBindRenderer) Render(width int) string

type KeyOpt

type KeyOpt func(k *Key)

func Hidden

func Hidden() KeyOpt

func WithAlias

func WithAlias(alias string) KeyOpt

Jump to

Keyboard shortcuts

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