Documentation ¶
Index ¶
- Constants
- Variables
- func FormatBytes(bytes int64) string
- func FormatDuration(duration time.Duration) string
- func PoggersAnimationFrame(t int) string
- func RenderSplit(left string, right string, width int, style lipgloss.Style) string
- type Appmenu
- func (appmenu *Appmenu) Activate() tea.Cmd
- func (appmenu *Appmenu) CloseSubmenu()
- func (appmenu *Appmenu) CursorDown()
- func (appmenu *Appmenu) CursorUp()
- func (appmenu *Appmenu) IsSubmenuOpen() bool
- func (appmenu *Appmenu) Render(height int) string
- func (appmenu *Appmenu) SetItems(items []*AppmenuItem)
- type AppmenuItem
- type ComputedSubmenuItem
- type DividerSubmenuItem
- type LabeledSubmenuItem
- type SettingSubmenuItem
- type SpacerSubmenuItem
- type Submenu
- type SubmenuExclusivity
- type SubmenuItem
- type SubmenuItemVariant
- type TitleSubmenuItem
- type ToggleableSubmenuItem
Constants ¶
const ( Primary = lipgloss.Color("207") Secondary = lipgloss.Color("135") Red = lipgloss.Color("203") Blue = lipgloss.Color("039") Green = lipgloss.Color("040") Yellow = lipgloss.Color("214") White = lipgloss.Color("231") DarkGray = lipgloss.Color("237") Black = lipgloss.Color("016") )
const PoggersAnimationInterval = 80 * time.Millisecond
Designed rendering rate of the PoggersAnimationFrame animation.
Variables ¶
var Logo = strings.Join([]string{
` __ _ `,
` / /________ __(_)`,
` / __/ ___/ / / / / `,
`/ /_(__ ) /_/ / / `,
`\__/____/\__,_/_/ `,
` by neuralink `,
}, "\n")
Functions ¶
func FormatBytes ¶
Formate a byte count to a human-friendly string.
func FormatDuration ¶
Format a Duration to a human-friendly string.
func PoggersAnimationFrame ¶
Render a frame of the cool loading animation I designed.
Types ¶
type Appmenu ¶
type Appmenu struct {
// contains filtered or unexported fields
}
A state container for the main application menu. Each menu item contains a submenu which can be opened and closed.
func (*Appmenu) Activate ¶
If a submenu is open, activate the item in the submenu. Otherwise, open the currently selected submenu.
func (*Appmenu) CursorDown ¶
func (appmenu *Appmenu) CursorDown()
Move the cursor to the next selectable item in the currently active menu.
func (*Appmenu) CursorUp ¶
func (appmenu *Appmenu) CursorUp()
Move the cursor to the previous selectable item in the currently active menu.
func (*Appmenu) IsSubmenuOpen ¶
Returns true if a submenu is currently open.
func (*Appmenu) SetItems ¶
func (appmenu *Appmenu) SetItems(items []*AppmenuItem)
Set the items list and ensure the cursor is within bounds.
type AppmenuItem ¶
An item in the main menu, containing a submenu.
type ComputedSubmenuItem ¶ added in v0.2.0
type ComputedSubmenuItem struct {
// contains filtered or unexported fields
}
A rendered submenu item and its computed layout info.
type LabeledSubmenuItem ¶
type LabeledSubmenuItem struct { string AdditionalLabel string Variant SubmenuItemVariant OnActivate tea.Cmd IsDim bool }Label
A menu item with a label.
type SettingSubmenuItem ¶
type SettingSubmenuItem struct { string OnChange func(newLabel string) tea.Msg // contains filtered or unexported fields }Label
A submenu item for a "settings control" that can have multiple values and activated to switch between them.
func NewSettingsSubmenuItem ¶
func NewSettingsSubmenuItem(label string, options []string, initialOption string, onChange func(newLabel string) tea.Msg) *SettingSubmenuItem
Create a new SettingsSubmenuItem. initialOption must be one of the options.
func NewYesNoSettingsSubmenuItem ¶
func NewYesNoSettingsSubmenuItem(label string, initialValue bool, onChange func(newValue bool) tea.Msg) *SettingSubmenuItem
Create a new SettingsSubmenuItem that is just a yes/no toggle.
type Submenu ¶
type Submenu struct { // SubmenuExclusivityNone, SubmenuExclusivityOne Exclusivity SubmenuExclusivity // contains filtered or unexported fields }
State container for a submenu with its cursor and items.
func (*Submenu) Activate ¶
Call the currently selected item's activate callback. Returns a bubbletea command that can be run asynchronously.
func (*Submenu) CursorDown ¶
func (submenu *Submenu) CursorDown()
Move the cursor to the next selectable item.
func (*Submenu) CursorUp ¶
func (submenu *Submenu) CursorUp()
Move the cursor to the previous selectable item.
func (*Submenu) ResetCursor ¶
func (submenu *Submenu) ResetCursor()
Reset the cursor to the first selectable item.
func (*Submenu) SetItems ¶
func (submenu *Submenu) SetItems(items []SubmenuItem)
Set the items list and ensure the cursor is within bounds and on a selectable item.
type SubmenuExclusivity ¶
type SubmenuExclusivity int
const ( SubmenuExclusivity = iota SubmenuExclusivityOne )SubmenuExclusivityNone
type SubmenuItem ¶
type SubmenuItem interface {
// contains filtered or unexported methods
}
A generic submenu item.
type SubmenuItemVariant ¶
type SubmenuItemVariant int
Visual variant of a submenu item:
SubmenuItemVariantDefault, SubmenuItemVariantDanger
const ()
type TitleSubmenuItem ¶
type TitleSubmenuItem struct { string }Label
A title for a section of a menu.
type ToggleableSubmenuItem ¶
type ToggleableSubmenuItem struct { bool }IsActive
A menu item with a label that can be toggled active or inactive.