command

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package command provides a command palette component for the memtui application.

Package command provides a command palette component for the memtui application. It implements a VS Code-style command palette with fuzzy search functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzyMatch

func FuzzyMatch(query, text string) (bool, int)

FuzzyMatch performs a fuzzy match of query against text. It returns whether there is a match and a score (higher is better). The matching is case-insensitive and supports substring matching.

Types

type Command

type Command struct {
	Name        string         // Display name of the command
	Description string         // Brief description of what the command does
	Shortcut    string         // Keyboard shortcut (e.g., "r", "Ctrl+S")
	Action      func() tea.Msg // Function to execute when command is selected
}

Command represents a single command that can be executed from the palette.

func DefaultCommands

func DefaultCommands() []Command

DefaultCommands returns the standard set of commands for memtui.

func RankCommands

func RankCommands(commands []Command, query string) []Command

RankCommands ranks commands by their fuzzy match score against the query. It returns commands sorted by score (highest first).

type CommandCancelMsg

type CommandCancelMsg struct{}

CommandCancelMsg is sent when the command palette is canceled (Escape).

type CommandExecuteMsg

type CommandExecuteMsg struct {
	Command Command
}

CommandExecuteMsg is sent when a command is executed from the palette.

type CommandPalette

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

CommandPalette is a VS Code-style command palette component.

func New

func New(commands []Command) *CommandPalette

New creates a new CommandPalette with the given commands.

func (*CommandPalette) Hide

func (p *CommandPalette) Hide()

Hide hides the command palette.

func (*CommandPalette) Init

func (p *CommandPalette) Init() tea.Cmd

Init implements tea.Model.

func (*CommandPalette) SelectedCommand

func (p *CommandPalette) SelectedCommand() *Command

SelectedCommand returns the currently selected command, or nil if none.

func (*CommandPalette) SetSize

func (p *CommandPalette) SetSize(width, height int)

SetSize sets the dimensions for the command palette.

func (*CommandPalette) Show

func (p *CommandPalette) Show()

Show makes the command palette visible.

func (*CommandPalette) Toggle

func (p *CommandPalette) Toggle()

Toggle toggles the command palette visibility.

func (*CommandPalette) Update

func (p *CommandPalette) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (*CommandPalette) View

func (p *CommandPalette) View() string

View implements tea.Model.

func (*CommandPalette) Visible

func (p *CommandPalette) Visible() bool

Visible returns whether the command palette is currently visible.

type CopyValueMsg

type CopyValueMsg struct{}

CopyValueMsg requests copying the current value to clipboard.

type DeleteKeyMsg

type DeleteKeyMsg struct{}

DeleteKeyMsg requests deletion of the selected key.

type EditValueMsg

type EditValueMsg struct{}

EditValueMsg requests editing of the current value.

type FilterKeysMsg

type FilterKeysMsg struct{}

FilterKeysMsg requests key filtering mode.

type NewKeyMsg

type NewKeyMsg struct{}

NewKeyMsg requests creation of a new key.

type QuitMsg

type QuitMsg struct{}

QuitMsg requests application exit.

type RefreshKeysMsg

type RefreshKeysMsg struct{}

RefreshKeysMsg requests the key list to be refreshed.

type ShowHelpMsg

type ShowHelpMsg struct{}

ShowHelpMsg requests display of the help screen.

type ShowStatsMsg

type ShowStatsMsg struct{}

ShowStatsMsg requests display of server statistics.

type ToggleThemeMsg

type ToggleThemeMsg struct{}

ToggleThemeMsg requests toggling between light and dark themes.

Jump to

Keyboard shortcuts

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