Documentation
¶
Index ¶
- Constants
- Variables
- func Begin(oidcProvider oidc.OidcProvider) tea.Cmd
- func CloseAction() tea.Cmd
- func CopyCodeAndOpenURL(deviceAuth *oidc.DeviceAuth) tea.Cmd
- func DialogTitle(t *styles.Styles, title string, width int, fromColor, toColor color.Color) string
- func DrawCenter(scr uv.Screen, area uv.Rectangle, view string)
- func DrawCenterCursor(scr uv.Screen, area uv.Rectangle, view string, cur *tea.Cursor)
- func DrawOnboarding(scr uv.Screen, area uv.Rectangle, view string)
- func DrawOnboardingCursor(scr uv.Screen, area uv.Rectangle, view string, cur *tea.Cursor)
- func Finish(oidcProvider oidc.OidcProvider, deviceAuth *oidc.DeviceAuth) tea.Cmd
- func InputCursor(t *styles.Styles, cur *tea.Cursor) *tea.Cursor
- func NewSessionItemDelegate(keys *delegateKeyMap, styles *styles.Styles) list.DefaultDelegate
- type Action
- type ActionClose
- type ActionCloseOAuth
- type ActionCmd
- type ActionInitCompleted
- type ActionInitErrored
- type ActionInitiateBuilder
- type ActionNoop
- type ActionOAuthCompleted
- type ActionOAuthErrored
- type ActionOAuthInitialized
- type ActionOpenDialog
- type ActionQuit
- type ActionToggleHelp
- type CommandItem
- func (c *CommandItem) Action() Action
- func (c *CommandItem) Filter() string
- func (c *CommandItem) Finished() bool
- func (c *CommandItem) ID() string
- func (c *CommandItem) InfoText() string
- func (c *CommandItem) Render(width int) string
- func (c *CommandItem) SetFocused(focused bool)
- func (c *CommandItem) SetHideInfo(v bool)
- func (c *CommandItem) SetMatch(m fuzzy.Match)
- func (c *CommandItem) Shortcut() string
- func (c *CommandItem) WithAliases(aliases ...string) *CommandItem
- func (c *CommandItem) WithDescription(desc string) *CommandItem
- type CommandType
- type Commands
- func (c *Commands) Cursor() *tea.Cursor
- func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
- func (c *Commands) FullHelp() [][]key.Binding
- func (c *Commands) HandleMsg(msg tea.Msg) Action
- func (c *Commands) ID() string
- func (c *Commands) InitialCmd() tea.Cmd
- func (c *Commands) ShortHelp() []key.Binding
- func (c *Commands) StartLoading() tea.Cmd
- func (c *Commands) StopLoading()
- type ConfigDialog
- func (m *ConfigDialog) Cursor() *tea.Cursor
- func (m *ConfigDialog) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
- func (m *ConfigDialog) FullHelp() [][]key.Binding
- func (m *ConfigDialog) HandleMsg(msg tea.Msg) Action
- func (m *ConfigDialog) ID() string
- func (m *ConfigDialog) ShortHelp() []key.Binding
- type DeployDialog
- func (m *DeployDialog) Cursor() *tea.Cursor
- func (m *DeployDialog) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
- func (m *DeployDialog) FullHelp() [][]key.Binding
- func (m *DeployDialog) HandleMsg(msg tea.Msg) Action
- func (m *DeployDialog) ID() string
- func (m *DeployDialog) ShortHelp() []key.Binding
- type Dialog
- type HoverDialog
- type InitDialog
- type InitState
- type ListItem
- type ListItemGenerator
- type ListItemStyles
- type LoadingDialog
- type OAuth
- type OAuthState
- type Overlay
- func (d *Overlay) BringToFront(dialogID string)
- func (d *Overlay) CloseDialog(dialogID string)
- func (d *Overlay) CloseFrontDialog()
- func (d *Overlay) ContainsDialog(dialogID string) bool
- func (d *Overlay) Dialog(id string) Dialog
- func (d *Overlay) DialogLast() Dialog
- func (d *Overlay) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
- func (d *Overlay) HandlesHover() bool
- func (d *Overlay) HasDialogs() bool
- func (d *Overlay) OpenDialog(dialog Dialog)
- func (d *Overlay) OpenDialogWithGrace(dialog Dialog)
- func (d *Overlay) StartLoading() tea.Cmd
- func (d *Overlay) StopLoading()
- func (d *Overlay) Update(msg tea.Msg) tea.Msg
- type Quit
- type RenderContext
- type Session
- type SessionItem
Constants ¶
const CommandsID = "commands"
CommandsID is the identifier for the commands dialog.
const ConfigID = "builder"
const DeployID = "deploy"
const InitID = "init"
InitID is the identifier for the init dialog.
const OAuthID = "oauth"
OAuthID is the identifier for the model selection dialog.
const QuitID = "quit"
QuitID is the identifier for the quit dialog.
const SessionsID = "sessions"
SessionsID is the identifier for the session selector dialog.
Variables ¶
var CloseKey = key.NewBinding( key.WithKeys("esc", "alt+esc"), key.WithHelp("esc", "exit"), )
CloseKey is the default key binding to close dialogs.
Functions ¶
func Begin ¶ added in v0.3.28
func Begin(oidcProvider oidc.OidcProvider) tea.Cmd
Begin initiates the OAuth device flow.
func CloseAction ¶ added in v0.3.28
CloseAction returns a command that closes the dialog and runs the given cleanup command.
func CopyCodeAndOpenURL ¶ added in v0.3.28
func CopyCodeAndOpenURL(deviceAuth *oidc.DeviceAuth) tea.Cmd
CopyCodeAndOpenURL copies the code and opens the URL in the browser.
func DialogTitle ¶ added in v0.3.28
DialogTitle renders a dialog title with a decorative line filling the remaining width. When the title alone exceeds the available width it is truncated with an ellipsis so it never wraps.
func DrawCenter ¶ added in v0.3.28
DrawCenter draws the given string view centered in the screen area.
func DrawCenterCursor ¶ added in v0.3.28
DrawCenterCursor draws the given string view centered in the screen area and adjusts the cursor position accordingly. Content larger than the area is clamped to fit.
func DrawOnboarding ¶ added in v0.3.28
DrawOnboarding draws the given string view centered in the screen area.
func DrawOnboardingCursor ¶ added in v0.3.28
DrawOnboardingCursor draws the given string view positioned at the bottom left area of the screen. Content larger than the area is clamped to fit.
func Finish ¶ added in v0.3.28
func Finish(oidcProvider oidc.OidcProvider, deviceAuth *oidc.DeviceAuth) tea.Cmd
Finish completes the OAuth device flow.
func InputCursor ¶ added in v0.3.28
InputCursor adjusts the cursor position for an input field within a dialog.
func NewSessionItemDelegate ¶ added in v0.3.28
func NewSessionItemDelegate(keys *delegateKeyMap, styles *styles.Styles) list.DefaultDelegate
NewSessionItemDelegate returns a new session item delegate.
Types ¶
type Action ¶ added in v0.3.28
type Action any
Action represents an action taken in a dialog after handling a message.
type ActionCloseOAuth ¶ added in v0.3.28
ActionCloseOAuth closes the OAuth dialog and runs the given cleanup command, cancelling any in-flight authorization. It exists so a dismissed dialog does not leave a poller or loopback listener running in the background.
type ActionInitCompleted ¶ added in v0.3.28
type ActionInitCompleted struct{}
ActionInitCompleted is an action that is dispatched when the init flow completes successfully.
type ActionInitErrored ¶ added in v0.3.28
type ActionInitErrored struct{ Error error }
ActionInitErrored is an action that is dispatched when the init flow encounters an error.
type ActionInitiateBuilder ¶ added in v0.3.28
type ActionInitiateBuilder struct{ URL string }
ActionInitiateBuilder is sent when the OAuth builder is initiated.
type ActionNoop ¶ added in v0.3.28
type ActionNoop = struct{}
ActionNoop is a message to do nothing.
type ActionOAuthCompleted ¶ added in v0.3.28
ActionOAuthCompleted is sent when the OAuth flow is completed successfully.
type ActionOAuthErrored ¶ added in v0.3.28
type ActionOAuthErrored struct {
Error error
}
ActionOAuthErrored is sent when the device flow encounters an error.
type ActionOAuthInitialized ¶ added in v0.3.28
type ActionOAuthInitialized struct {
DeviceAuth *oidc.DeviceAuth
}
ActionOAuthInitialized is sent when the OAuth flow is initialized.
type ActionOpenDialog ¶
type ActionOpenDialog struct {
DialogID string
}
ActionOpenDialog is a message to open a dialog.
type ActionToggleHelp ¶ added in v0.3.28
type ActionToggleHelp struct{}
ActionToggleHelp is a message to toggle the help dialog.
type CommandItem ¶ added in v0.3.28
CommandItem wraps a uicmd.Command to implement the ListItem interface.
func NewCommandItem ¶ added in v0.3.28
func NewCommandItem(t *styles.Styles, id, title, shortcut string, action Action) *CommandItem
NewCommandItem creates a new CommandItem.
func (*CommandItem) Action ¶ added in v0.3.28
func (c *CommandItem) Action() Action
Action returns the action associated with the command item.
func (*CommandItem) Filter ¶ added in v0.3.28
func (c *CommandItem) Filter() string
Filter implements ListItem.
func (*CommandItem) Finished ¶ added in v0.3.28
func (c *CommandItem) Finished() bool
Finished implements list.Item. Command items are render-stable outside of explicit SetFocused / SetMatch.
func (*CommandItem) InfoText ¶ added in v0.3.28
func (c *CommandItem) InfoText() string
InfoText implements infoColumnItem; the command shortcut is its info.
func (*CommandItem) Render ¶ added in v0.3.28
func (c *CommandItem) Render(width int) string
Render implements ListItem.
func (*CommandItem) SetFocused ¶ added in v0.3.28
func (c *CommandItem) SetFocused(focused bool)
SetFocused implements ListItem.
func (*CommandItem) SetHideInfo ¶ added in v0.3.28
func (c *CommandItem) SetHideInfo(v bool)
SetHideInfo controls whether the shortcut hint column is shown. The dialog hides it uniformly when it would crowd the command names.
func (*CommandItem) SetMatch ¶ added in v0.3.28
func (c *CommandItem) SetMatch(m fuzzy.Match)
SetMatch implements ListItem.
func (*CommandItem) Shortcut ¶ added in v0.3.28
func (c *CommandItem) Shortcut() string
Shortcut returns the shortcut associated with the command item.
func (*CommandItem) WithAliases ¶ added in v0.3.28
func (c *CommandItem) WithAliases(aliases ...string) *CommandItem
WithAliases returns the CommandItem with the given aliases for filtering.
func (*CommandItem) WithDescription ¶ added in v0.3.28
func (c *CommandItem) WithDescription(desc string) *CommandItem
WithDescription returns the CommandItem with a description displayed below the title.
type CommandType ¶ added in v0.3.28
type CommandType uint
CommandType represents the type of commands being displayed.
const ( SystemCommands CommandType = iota UserCommands )
func (CommandType) String ¶ added in v0.3.28
func (c CommandType) String() string
String returns the string representation of the CommandType.
type Commands ¶ added in v0.3.28
type Commands struct {
// contains filtered or unexported fields
}
Commands represents a dialog that shows available commands.
func NewCommands ¶ added in v0.3.28
func NewCommands(ui *defaults.UI, sessionID string, hasSession, hasTodos, hasQueue bool) (*Commands, error)
NewCommands creates a new commands dialog.
func (*Commands) Cursor ¶ added in v0.3.28
Cursor returns the cursor position relative to the dialog.
func (*Commands) FullHelp ¶ added in v0.3.28
FullHelp implements help.KeyMap.
func (*Commands) InitialCmd ¶ added in v0.3.28
func (*Commands) ShortHelp ¶ added in v0.3.28
ShortHelp implements help.KeyMap.
func (*Commands) StartLoading ¶ added in v0.3.28
StartLoading implements LoadingDialog.
func (*Commands) StopLoading ¶ added in v0.3.28
func (c *Commands) StopLoading()
StopLoading implements LoadingDialog.
type ConfigDialog ¶ added in v0.3.28
type ConfigDialog struct {
// contains filtered or unexported fields
}
ConfigDialog represents a builder configuration dialog.
func NewConfigDialog ¶ added in v0.3.28
func NewConfigDialog(ui *defaults.UI, url string) (*ConfigDialog, error)
NewConfigDialog creates a new ConfigDialog.
func (*ConfigDialog) Cursor ¶ added in v0.3.28
func (m *ConfigDialog) Cursor() *tea.Cursor
Cursor returns the cursor for the dialog.
func (*ConfigDialog) FullHelp ¶ added in v0.3.28
func (m *ConfigDialog) FullHelp() [][]key.Binding
FullHelp returns the full help view.
func (*ConfigDialog) HandleMsg ¶ added in v0.3.28
func (m *ConfigDialog) HandleMsg(msg tea.Msg) Action
HandleMsg implements Dialog.
func (*ConfigDialog) ShortHelp ¶ added in v0.3.28
func (m *ConfigDialog) ShortHelp() []key.Binding
ShortHelp returns the short help view.
type DeployDialog ¶ added in v0.3.28
type DeployDialog struct {
// contains filtered or unexported fields
}
DeployDialog represents a deploy configuration dialog.
func NewDeploy ¶ added in v0.3.28
func NewDeploy(ui *defaults.UI) *DeployDialog
NewDeploy creates a new DeployDialog.
func (*DeployDialog) Cursor ¶ added in v0.3.28
func (m *DeployDialog) Cursor() *tea.Cursor
Cursor returns the cursor for the dialog.
func (*DeployDialog) FullHelp ¶ added in v0.3.28
func (m *DeployDialog) FullHelp() [][]key.Binding
FullHelp returns the full help view.
func (*DeployDialog) HandleMsg ¶ added in v0.3.28
func (m *DeployDialog) HandleMsg(msg tea.Msg) Action
HandleMsg implements Dialog.
func (*DeployDialog) ShortHelp ¶ added in v0.3.28
func (m *DeployDialog) ShortHelp() []key.Binding
ShortHelp returns the short help view.
type Dialog ¶ added in v0.3.28
type Dialog interface {
// ID returns the unique identifier of the dialog.
ID() string
// HandleMsg processes a message and returns an action. An [Action] can be
// anything and the caller is responsible for handling it appropriately.
HandleMsg(msg tea.Msg) Action
// Draw draws the dialog onto the provided screen within the specified area
// and returns the desired cursor position on the screen.
Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
}
Dialog is a component that can be displayed on top of the UI.
type HoverDialog ¶ added in v0.3.28
type HoverDialog interface {
HandlesHover() bool
}
HoverDialog is a dialog that reacts to mouse hover. While one is open, the terminal must report all mouse motion events, not just clicks.
type InitDialog ¶ added in v0.3.28
type InitDialog struct {
// contains filtered or unexported fields
}
InitDialog handles the initialization flow for the UI.
func NewInit ¶ added in v0.3.28
func NewInit(ui *defaults.UI) (*InitDialog, tea.Cmd)
NewInit creates a new init dialog.
func (*InitDialog) FullHelp ¶ added in v0.3.28
func (m *InitDialog) FullHelp() [][]key.Binding
FullHelp returns the full help view.
func (*InitDialog) HandleMsg ¶ added in v0.3.28
func (m *InitDialog) HandleMsg(msg tea.Msg) Action
HandleMsg handles messages and state transitions.
func (*InitDialog) ShortHelp ¶ added in v0.3.28
func (m *InitDialog) ShortHelp() []key.Binding
ShortHelp returns the full help view.
type InitState ¶ added in v0.3.28
type InitState int
InitState represents the current state of the init flow.
type ListItem ¶ added in v0.3.28
type ListItem interface {
list.FilterableItem
list.Focusable
list.MatchSettable
// ID returns the unique identifier of the item.
ID() string
}
ListItem represents a selectable and searchable item in a dialog list.
type ListItemGenerator ¶ added in v0.3.28
type ListItemGenerator[S ~[]R, R any] func(s S) []R
ListItemGenerator is an interface for generating list items.
type ListItemStyles ¶ added in v0.3.28
type ListItemStyles struct {
ItemBlurred lipgloss.Style
ItemFocused lipgloss.Style
InfoTextBlurred lipgloss.Style
InfoTextFocused lipgloss.Style
}
ListItemStyles holds the styles for list items in a dialog.
type LoadingDialog ¶ added in v0.3.28
LoadingDialog is a dialog that can show a loading state.
type OAuth ¶ added in v0.3.28
type OAuth struct {
// State is the current state of the OAuth flow.
State OAuthState
// contains filtered or unexported fields
}
OAuth handles the OAuth flow authentication.
type OAuthState ¶ added in v0.3.28
type OAuthState int
OAuthState represents the current state of the device flow.
const ( OAuthStateInitializing OAuthState = iota OAuthStateAuthenticating OAuthStateSuccess OAuthStateSaving OAuthStateError )
type Overlay ¶ added in v0.3.28
type Overlay struct {
// contains filtered or unexported fields
}
Overlay manages multiple dialogs as an overlay.
func NewOverlay ¶ added in v0.3.28
NewOverlay creates a new Overlay instance.
func (*Overlay) BringToFront ¶ added in v0.3.28
BringToFront brings the dialog with the specified ID to the front.
func (*Overlay) CloseDialog ¶ added in v0.3.28
CloseDialog closes the dialog with the specified ID from the stack.
func (*Overlay) CloseFrontDialog ¶ added in v0.3.28
func (d *Overlay) CloseFrontDialog()
CloseFrontDialog closes the front dialog in the stack.
func (*Overlay) ContainsDialog ¶ added in v0.3.28
ContainsDialog checks if a dialog with the specified ID exists.
func (*Overlay) Dialog ¶ added in v0.3.28
Dialog returns the dialog with the specified ID, or nil if not found.
func (*Overlay) DialogLast ¶ added in v0.3.28
DialogLast returns the front dialog, or nil if there are no dialogs.
func (*Overlay) HandlesHover ¶ added in v0.3.28
HandlesHover reports whether any open dialog reacts to mouse hover, in which case the terminal should report all mouse motion events.
func (*Overlay) HasDialogs ¶ added in v0.3.28
HasDialogs checks if there are any active dialogs.
func (*Overlay) OpenDialog ¶ added in v0.3.28
OpenDialog opens a new dialog to the stack.
func (*Overlay) OpenDialogWithGrace ¶ added in v0.3.28
OpenDialogWithGrace opens a dialog with an input grace period. All keystrokes are absorbed until either the input has been quiet for graceQuietPeriod or graceMaxDelay has elapsed since opening, whichever comes first. Use this for dialogs that open asynchronously (e.g. permission prompts) where in-flight keystrokes from a previously focused component could act on the dialog before the user sees it.
If the same dialog ID was just closed (within reopenGraceWindow), the grace period is skipped — the user is already focused on this dialog type and rapid successive prompts should not eat keystrokes.
func (*Overlay) StartLoading ¶ added in v0.3.28
StartLoading starts the loading state for the front dialog if it implements LoadingDialog.
func (*Overlay) StopLoading ¶ added in v0.3.28
func (d *Overlay) StopLoading()
StopLoading stops the loading state for the front dialog if it implements LoadingDialog.
type Quit ¶ added in v0.3.28
type Quit struct {
// contains filtered or unexported fields
}
Quit represents a confirmation dialog for quitting the application.
func (*Quit) FullHelp ¶ added in v0.3.28
FullHelp implements help.KeyMap.
func (*Quit) HandlesHover ¶ added in v0.3.28
HandlesHover implements HoverDialog.
type RenderContext ¶ added in v0.3.28
type RenderContext struct {
// Styles is the styles to use for rendering.
Styles *styles.Styles
// TitleStyle is the style of the dialog title by default it uses Styles.Dialog.Title
TitleStyle lipgloss.Style
// ViewStyle is the style of the dialog title by default it uses Styles.Dialog.View
ViewStyle lipgloss.Style
// TitleGradientFromColor is the color the title gradient starts by default
// its Styles.Dialog.TitleGradFromColor
TitleGradientFromColor color.Color
// TitleGradientToColor is the color the title gradient ends by default its
// Styles.Dialog.TitleGradToColor
TitleGradientToColor color.Color
// Width is the total width of the dialog including any margins, borders,
// and paddings.
Width int
// Gap is the gap between content parts. Zero means no gap.
Gap int
// Title is the title of the dialog. This will be styled using the default
// dialog title style and prepended to the content parts slice.
Title string
// TitleInfo is additional information to display next to the title. This
// part is displayed as is, any styling must be applied before setting this
// field.
TitleInfo string
// Parts are the rendered parts of the dialog.
Parts []string
// Help is the fully rendered help footer line. Produce it with
// renderDialogHelp so it is sized and padded consistently; it is
// appended as-is without further styling.
Help string
// IsOnboarding indicates whether to render the dialog as part of the
// onboarding flow. This means that the content will be rendered at the
// bottom left of the screen.
IsOnboarding bool
}
RenderContext is a dialog rendering context that can be used to render common dialog layouts.
func NewRenderContext ¶ added in v0.3.28
func NewRenderContext(t *styles.Styles, width int) *RenderContext
NewRenderContext creates a new RenderContext with the provided styles and width.
func (*RenderContext) AddPart ¶ added in v0.3.28
func (rc *RenderContext) AddPart(part string)
AddPart adds a rendered part to the dialog.
func (*RenderContext) Render ¶ added in v0.3.28
func (rc *RenderContext) Render() string
Render renders the dialog using the provided context.
type Session ¶ added in v0.3.28
type Session struct {
// contains filtered or unexported fields
}
Session is a session selector dialog.
func NewSessions ¶ added in v0.3.28
NewSessions creates a new Session dialog.
func (*Session) FullHelp ¶ added in v0.3.28
FullHelp implements help.KeyMap.
type SessionItem ¶ added in v0.3.28
type SessionItem struct {
// contains filtered or unexported fields
}
SessionItem represents a session item in the list.
func (SessionItem) Description ¶ added in v0.3.28
func (s SessionItem) Description() string
Description returns the description of the session item.
func (SessionItem) FilterValue ¶ added in v0.3.28
func (s SessionItem) FilterValue() string
FilterValue returns the filter value of the session item.
func (SessionItem) Title ¶ added in v0.3.28
func (s SessionItem) Title() string
Title returns the title of the session item.