ui

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorPrimary   = lipgloss.Color("#4285F4") // Google Blue
	ColorSecondary = lipgloss.Color("#34A853") // Google Green
	ColorWarning   = lipgloss.Color("#FBBC05") // Google Yellow
	ColorError     = lipgloss.Color("#EA4335") // Google Red
	ColorMuted     = lipgloss.Color("#9AA0A6") // Gray
	ColorBg        = lipgloss.Color("#202124") // Dark background
	ColorBgLight   = lipgloss.Color("#303134") // Lighter background
)

Color palette - GCP inspired colors

Functions

func MaxLineWidth

func MaxLineWidth(content string) int

MaxLineWidth finds the maximum terminal width among all lines in content.

func SafeWidth

func SafeWidth(terminalWidth int, content string) int

SafeWidth returns the maximum width that can be used for content to avoid line wrapping due to emoji width miscalculation. Pass the terminal width and the string that will be rendered.

lipgloss.Place() pads ALL lines to the target width. So if any line has emojis that terminals render wider than lipgloss measures, those lines will overflow. We must reduce width by the max emoji count on any line to ensure the worst-case line still fits.

func SafeWidthForEmojis

func SafeWidthForEmojis(terminalWidth int, emojiCount int) int

SafeWidthForEmojis returns the terminal width reduced by the expected number of emojis that will appear on a line. Use this when you know how many emojis will be rendered but don't have the final string yet.

func TerminalWidth

func TerminalWidth(s string) int

TerminalWidth calculates the actual terminal width of a string, accounting for emoji characters that lipgloss.Width() miscounts.

lipgloss.Width() counts most emojis as 1 character, but native terminals (Kitty, Alacritty, macOS Terminal) render them as 2 characters wide. This function adds 1 for each emoji to get the true terminal width.

Types

type App

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

App is the main application model

func NewApp

func NewApp(client *gcp.Client, opts AppOptions) *App

NewApp creates a new application instance

func (*App) GetContext

func (a *App) GetContext() *context.ProgramContext

GetContext returns the shared program context. Views can use this to access dimensions, styles, and task tracking.

func (*App) Init

func (a *App) Init() tea.Cmd

Init implements tea.Model

func (*App) ShowProjectSelectorOnStartup

func (a *App) ShowProjectSelectorOnStartup()

ShowProjectSelectorOnStartup configures the app to show project selector on startup

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*App) View

func (a *App) View() string

View implements tea.Model

type AppOptions

type AppOptions struct {
	// InitialProjectID skips project selector and goes directly to this project
	InitialProjectID string
}

AppOptions configures the application

type ErrorMsg

type ErrorMsg struct {
	Err     error
	Context string // Additional context about where the error occurred
}

ErrorMsg is sent when an error occurs

type FocusedPanel

type FocusedPanel int

FocusedPanel indicates which panel has keyboard focus

const (
	FocusContent FocusedPanel = iota
	FocusSidebar
)

type InitialProjectErrorMsg

type InitialProjectErrorMsg struct {
	Err       error
	ProjectID string // The project ID that failed to load
}

InitialProjectErrorMsg is sent when loading initial project fails

type InitialProjectLoadedMsg

type InitialProjectLoadedMsg struct {
	Project gcp.Project
}

InitialProjectLoadedMsg is sent when the initial project (from config/flag) is loaded

type KeyMap

type KeyMap struct {
	Up             key.Binding
	Down           key.Binding
	Left           key.Binding
	Right          key.Binding
	Select         key.Binding
	Back           key.Binding
	Quit           key.Binding
	Help           key.Binding
	Refresh        key.Binding
	Search         key.Binding
	Tab            key.Binding
	ShiftTab       key.Binding
	SelectSidebar  key.Binding // '[' - focus sidebar
	SelectContent  key.Binding // ']' - focus content
	ToggleSidebar  key.Binding // '{' - show/hide sidebar
	ActionMenu     key.Binding
	CommandPalette key.Binding
}

KeyMap defines all application key bindings

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings

func (KeyMap) FullHelp

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

FullHelp returns key bindings for the expanded help view

func (KeyMap) ShortHelp

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

ShortHelp returns key bindings for the mini help view

type LoadingMsg

type LoadingMsg struct {
	Loading bool
	Message string
}

LoadingMsg indicates a loading state change

type ProjectSelectedMsg

type ProjectSelectedMsg struct {
	Project gcp.Project
}

ProjectSelectedMsg is sent when a project is selected

type ProjectsLoadedMsg

type ProjectsLoadedMsg struct {
	Projects []gcp.Project
}

ProjectsLoadedMsg is sent when projects are fetched from GCP

type RefreshMsg

type RefreshMsg struct{}

RefreshMsg triggers a refresh of the current view

type Styles

type Styles struct {
	App          lipgloss.Style
	Title        lipgloss.Style
	Subtitle     lipgloss.Style
	Selected     lipgloss.Style
	Hover        lipgloss.Style // Mouse hover state
	Normal       lipgloss.Style
	Muted        lipgloss.Style
	Error        lipgloss.Style
	Success      lipgloss.Style
	Warning      lipgloss.Style
	Help         lipgloss.Style
	StatusBar    lipgloss.Style
	ListItem     lipgloss.Style
	ActiveBorder lipgloss.Style
}

Styles holds all application styles

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles returns the default application styles

type TextInputFocusable

type TextInputFocusable interface {
	HasTextInputFocused() bool
}

TextInputFocusable is implemented by views that can have text input fields focused

type ViewType

type ViewType int

ViewType represents different screens in the application

const (
	ViewNone ViewType = -1 // Sentinel value for unset/invalid view

	ViewProjects ViewType = iota
	ViewInstances
	ViewInstanceDetails
	ViewMetadata
	ViewProjectMetadata
	ViewDisks
	ViewDiskDetails
	ViewSnapshots
	ViewSnapshotDetails
	ViewImages
	ViewImageDetails
	ViewBuckets
	ViewObjects        // Browsing objects within a bucket
	ViewObjectDetails  // Viewing object details
	ViewInstanceEditor // Editing instance properties (labels, etc.)
	ViewBucketCreate   // Creating a new GCS bucket
	ViewSnapshotCreate // Creating a snapshot from a disk
	ViewImageCreate    // Creating an image from a disk
	ViewDiskCreate     // Creating a disk from a snapshot
	ViewNetworks
	ViewNetworkDetails
	ViewFirewall
	ViewFirewallDetails
	ViewSubnets
	ViewSubnetDetails
	ViewSubnetCreate
	ViewRoutes
	ViewRouteDetails
	ViewRouteCreate
	ViewSQLInstances
	ViewSQLInstanceDetails
	ViewServiceAccounts
	ViewServiceAccountDetails
	ViewServiceAccountCreate
	ViewIAMPolicy
	ViewCustomRoles
	ViewCustomRoleDetails
	ViewCloudRunServices
	ViewCloudRunServiceDetails
	ViewCloudRunServiceEdit
	ViewInstanceCreate     // Creating a new VM instance
	ViewInstanceConfigEdit // Editing an existing VM instance configuration
	ViewLogs
	ViewFormDemo // Demo view for testing form components
)

Directories

Path Synopsis
actionmenu
Package actionmenu provides a popup action menu component for views.
Package actionmenu provides a popup action menu component for views.
confirm
Package confirm provides confirmation dialogs for destructive actions.
Package confirm provides confirmation dialogs for destructive actions.
diff
Package diff provides a component for displaying before/after comparisons with confirmation dialog for changes.
Package diff provides a component for displaying before/after comparisons with confirmation dialog for changes.
footer
Package footer provides an enhanced footer component with dynamic content.
Package footer provides an enhanced footer component with dynamic content.
forms
Package forms provides reusable form components for editing GCP resources.
Package forms provides reusable form components for editing GCP resources.
inputdialog
Package inputdialog provides a simple modal input dialog for capturing text input.
Package inputdialog provides a simple modal input dialog for capturing text input.
labeledit
Package labeledit provides a component for editing key-value label pairs used in GCP resources like VM instances.
Package labeledit provides a component for editing key-value label pairs used in GCP resources like VM instances.
links
Package links provides a component for navigable links within detail views.
Package links provides a component for navigable links within detail views.
sortmenu
Package sortmenu provides a popup sort column selector for table views.
Package sortmenu provides a popup sort column selector for table views.
table
Package table provides a reusable table component with GCP styling and filtering support.
Package table provides a reusable table component with GCP styling and filtering support.
tabs
Package tabs provides a reusable tab bar component for detail views.
Package tabs provides a reusable tab bar component for detail views.
textarea
Package textarea provides a multi-line text editor with GCP styling.
Package textarea provides a multi-line text editor with GCP styling.
timer
Package timer provides countdown and elapsed time components with GCP styling.
Package timer provides countdown and elapsed time components with GCP styling.
viewport
Package viewport provides a scrollable content container with GCP styling.
Package viewport provides a scrollable content container with GCP styling.
Package context provides shared state that propagates to all views and components.
Package context provides shared state that propagates to all views and components.
Package focus provides a unified focus management system for views with multiple interactive regions (tabs, links, viewport, etc.).
Package focus provides a unified focus management system for views with multiple interactive regions (tabs, links, viewport, etc.).
Package layout provides tile-based layout management using teatile.
Package layout provides tile-based layout management using teatile.
Package symbols provides centralized UI symbols with multiple display modes.
Package symbols provides centralized UI symbols with multiple display modes.
Package timeutil provides time formatting helpers that respect local timezone.
Package timeutil provides time formatting helpers that respect local timezone.
Package views implements the view layer for the gcon TUI.
Package views implements the view layer for the gcon TUI.

Jump to

Keyboard shortcuts

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