tools

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GEAR_ICON     icon = " "
	INFO_ICON     icon = " "
	USER_ICON     icon = " "
	PROFILE_ICON  icon = "󱃶 "
	PACKAGE_ICON  icon = " "
	GAME_ICON     icon = "󰍳 "
	LIST_ICON     icon = "󱉯 "
	SAVE_ICON     icon = "󰆓 "
	HOME_ICON     icon = " "
	NEW_USER_ICON icon = " "
	WARNING_ICON  icon = " "
	LOADING_ICON  icon = " "
	DELETE_ICON   icon = " "
	STAR_ICON     icon = " "
)

https://www.nerdfonts.com/cheat-sheet

View Source
const FULL_HELP_HEIGHT = 4

Variables

View Source
var GlobalKeybinds = Keybinds{
	"scroll.up": key.NewBinding(
		key.WithKeys("K", "up"),
		key.WithHelp("󰘶 K/󱕑", "scroll up"),
	),
	"scroll.down": key.NewBinding(
		key.WithKeys("J", "down"),
		key.WithHelp("󰘶 J/󱕐", "scroll down"),
	),
	"goto.top": key.NewBinding(
		key.WithKeys("ctrl+u", "home"),
		key.WithHelp("^U/home", "go to top"),
	),
	"goto.bottom": key.NewBinding(
		key.WithKeys("ctrl+d", "end"),
		key.WithHelp("^D/end", "go to bottom"),
	),
}
View Source
var HelpKeybind = key.NewBinding(
	key.WithKeys("?"),
	key.WithHelp("?", "help"),
)
View Source
var QuitKeybind = key.NewBinding(
	key.WithKeys("q", "ctrl+c"),
	key.WithHelp("q", "quit"),
)

Functions

func AppendContent

func AppendContent(contents *[]string, text string, width int)

Appends a text render with specified width

func FillGap

func FillGap(height int) string

Fills vertical gap with new lines

func IconFallback

func IconFallback(icon icon, fallback string) string

Returns an icon if --icons CLI flag is on, otherwise the fallback string

func ScrollBar

func ScrollBar(windowHeight int, contentHeight int, scroll int) (height int, position int)

Calculates the height and position of a scrollbar

func UpdateModel

func UpdateModel[T tea.Model](commands *[]tea.Cmd, model tea.Model, raw tea.Msg) T

A util function that calls the model.Update() method, appends the command, and maps the return value from tea.Model

func WithIcon

func WithIcon(icon icon, str string) string

Prepends an icon if --icons CLI flag is on

Types

type Keybinds

type Keybinds map[string]key.Binding

func (Keybinds) FullHelp

func (keybinds Keybinds) FullHelp() [][]key.Binding

func (Keybinds) ShortHelp

func (keybinds Keybinds) ShortHelp() []key.Binding

type Message

type Message interface{}

type Notification

type Notification struct {
	Type NotificationType
	Text string
}

type NotificationType

type NotificationType uint8
const (
	HELP NotificationType = iota
	TASK
	ERROR
)

type OverflowBottomMsg

type OverflowBottomMsg struct{}

type OverflowTopMsg

type OverflowTopMsg struct{}

Jump to

Keyboard shortcuts

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