ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorIndigo       = lipgloss.AdaptiveColor{Dark: "#7571F9", Light: "#5A56E0"}
	ColorSubtleIndigo = lipgloss.AdaptiveColor{Dark: "#514DC1", Light: "#7D79F6"}
	ColorCream        = lipgloss.AdaptiveColor{Dark: "#FFFDF5", Light: "#FFFDF5"}
	ColorYellowGreen  = lipgloss.AdaptiveColor{Dark: "#ECFD65", Light: "#04B575"}
	ColorFuschia      = lipgloss.AdaptiveColor{Dark: "#EE6FF8", Light: "#EE6FF8"}
	ColorGreen        = lipgloss.AdaptiveColor{Dark: "#04B575", Light: "#04B575"}
	ColorRed          = lipgloss.AdaptiveColor{Dark: "#ED567A", Light: "#FF4672"}
	ColorFaintRed     = lipgloss.AdaptiveColor{Dark: "#C74665", Light: "#FF6F91"}
	ColorGrey         = lipgloss.AdaptiveColor{Light: "#B2B2B2", Dark: "#4A4A4A"}
	ColorNoColor      = lipgloss.AdaptiveColor{Dark: "", Light: ""}
)

Colors for dark and light backgrounds.

View Source
var (
	StyleTitle    = lipgloss.NewStyle().Foreground(ColorCream).Background(ColorIndigo)
	StyleSubtitle = lipgloss.NewStyle().Foreground(ColorCream).Background(ColorSubtleIndigo)
	StyleComment  = lipgloss.NewStyle().Foreground(ColorGrey)

	StyleTableFunc = func() table.Styles {
		s := table.DefaultStyles()
		s.Header = s.Header.
			BorderStyle(lipgloss.NormalBorder()).
			BorderForeground(lipgloss.Color("240")).
			BorderBottom(true).
			Bold(false)
		s.Selected = s.Selected.
			Foreground(lipgloss.Color("229")).
			Background(lipgloss.Color("57")).
			Bold(false)
		return s
	}
	StyleTableBase = lipgloss.NewStyle().
					BorderStyle(lipgloss.NormalBorder()).
					BorderForeground(lipgloss.Color("240"))

	StyleActiveDot   = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "235", Dark: "252"}).Render("•")
	StyleInactiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "250", Dark: "238"}).Render("•")

	StyleQuitMsg  = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"})
	StyleErrorMsg = lipgloss.NewStyle().Foreground(ColorRed)
)

Functions

func ResourceStatusEmoji

func ResourceStatusEmoji(status ResourceStatus) string

Types

type Diags

type Diags []json.Diagnostic

func (Diags) HasError

func (diags Diags) HasError() bool

type KeyMap

type KeyMap struct {
	TableKeyMap  table.KeyMap
	PaginatorMap paginator.KeyMap

	Follow key.Binding
	Quit   key.Binding
	Copy   key.Binding

	Help key.Binding
}

func NewKeyMap

func NewKeyMap(clipboardEnabled bool) KeyMap

func (*KeyMap) EnablePaginator

func (km *KeyMap) EnablePaginator()

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type OutputInfo

type OutputInfo struct {
	Name string

	Sensitive bool
	Type      string
	ValueStr  gojson.RawMessage
	Action    json.ChangeAction
}

type OutputInfos

type OutputInfos []*OutputInfo

func (OutputInfos) ToColumns

func (infos OutputInfos) ToColumns(width int) []table.Column

func (OutputInfos) ToRows

func (infos OutputInfos) ToRows() []table.Row

type ResourceInfo

type ResourceInfo struct {
	RawResourceAddr json.ResourceAddr
	Loc             ResourceInfoLocator
	Status          ResourceStatus
	StartTime       time.Time
	EndTime         time.Time
}

func (ResourceInfo) Duration

func (info ResourceInfo) Duration(now time.Time) time.Duration

type ResourceInfoLocator

type ResourceInfoLocator struct {
	Module       string
	ResourceAddr string
	Action       string
}

type ResourceInfoUpdate

type ResourceInfoUpdate struct {
	Status  *ResourceStatus
	Endtime *time.Time
}

type ResourceInfos

type ResourceInfos []*ResourceInfo

ResourceInfos records the operation information for each resource's action.

func (ResourceInfos) ToColumns

func (infos ResourceInfos) ToColumns(width int) []table.Column

func (ResourceInfos) ToCsv

func (infos ResourceInfos) ToCsv(stage string) []string

func (ResourceInfos) ToRows

func (infos ResourceInfos) ToRows(total int) []table.Row

ToRows turns the ResourceInfos into table rows. The total is used to decorate the index as a fraction, if total > 0.

func (ResourceInfos) Update

func (infos ResourceInfos) Update(loc ResourceInfoLocator, update ResourceInfoUpdate) bool

type ResourceStatus

type ResourceStatus string
const (
	// Once received one OperationStart hook message
	ResourceStatusStart ResourceStatus = "start"
	// Once received one OperationComplete hook message
	ResourceStatusComplete ResourceStatus = "complete"
	// Once received one OperationErrored hook message
	ResourceStatusErrored ResourceStatus = "error"
)

type Size

type Size struct {
	Height int
	Width  int
}

type UIModel

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

func NewRuntimeModel

func NewRuntimeModel(logger *log.Logger, reader reader.Reader, startTime time.Time) UIModel

func (UIModel) Diags

func (m UIModel) Diags() Diags

func (UIModel) Init

func (m UIModel) Init() tea.Cmd

func (UIModel) IsEOF

func (m UIModel) IsEOF() bool

func (UIModel) ToCsv

func (m UIModel) ToCsv() []byte

func (UIModel) Update

func (m UIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (UIModel) View

func (m UIModel) View() string

type ViewState

type ViewState int
const (
	ViewStateUnknown ViewState = iota
	ViewStateIdle
	ViewStateRefresh
	ViewStatePlan
	ViewStateApply
	ViewStateSummary
)

func (ViewState) NextState

func (s ViewState) NextState(msg views.Message) (ViewState, bool)

func (ViewState) String

func (s ViewState) String() string

Jump to

Keyboard shortcuts

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