menu

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMenuFile

func ReadMenuFile(file string) ([]byte, error)

ReadMenuFile reads a menu file and returns bytes

func ReadThemeFile

func ReadThemeFile(file string) ([]byte, error)

Types

type Menu struct {
	Items map[string]*MenuItem
}

Menu holds a map of menu items

func NewMenu

func NewMenu(data []byte) (*Menu, error)

NewMenu parses a menu byte slice and returns a new Menu

func (m *Menu) Render(title string, tc ThemeConfig) (string, error)

Render renders the menu and returns the selected command

type MenuItem struct {
	Name      string               // Name of the menu item
	Command   string               // Command to run
	IsSubmenu bool                 // Whether the item is a submenu
	Children  map[string]*MenuItem // Submenu items
}

MenuItem holds all the menu item data

type ThemeConfig

type ThemeConfig struct {
	BaseForeground           string `json:"base_foreground,omitempty"`
	BaseBackground           string `json:"base_background,omitempty"`
	BaseBold                 bool   `json:"base_bold,omitempty"`
	TitleForeground          string `json:"title_foreground,omitempty"`
	TitleBackground          string `json:"title_background,omitempty"`
	TitleBold                bool   `json:"title_bold,omitempty"`
	TitleBorder              string `json:"title_separator,omitempty"`
	OptionForeground         string `json:"option_foreground,omitempty"`
	OptionBackground         string `json:"option_background,omitempty"`
	OptionBold               bool   `json:"option_bold,omitempty"`
	SelectedOptionForeground string `json:"selected_foreground,omitempty"`
	SelectedOptionBackground string `json:"selected_background,omitempty"`
	SelectedOptionBold       bool   `json:"selected_bold,omitempty"`
	SelectSelectorForeground string `json:"selector_foreground,omitempty"`
	SelectSelectorBackground string `json:"selector_background,omitempty"`
	SelectSelectorBold       bool   `json:"selector_bold,omitempty"`
	SelectSelectorString     string `json:"selector_string,omitempty"`
	SubmenuPointer           string `json:"submenu_pointer,omitempty"`
}

Theme holds all the styles for the UI

func DefaultThemeConfig

func DefaultThemeConfig() ThemeConfig

DefaultTheme returns the default theme

func NewThemeConfig

func NewThemeConfig(themeJSON string) (ThemeConfig, error)

func (*ThemeConfig) CreateTheme

func (tc *ThemeConfig) CreateTheme() (*huh.Theme, error)

NewTheme takes a custom JSON string and returns a new theme with the customizations applied

Jump to

Keyboard shortcuts

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