tui

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DrPurple      = lipgloss.Color("#7770F9") // purple-60
	DrPurpleLight = lipgloss.Color("#B4B0FF") // purple-40
	DrIndigo      = lipgloss.Color("#5C41FF") // indigo-70
	DrRed         = lipgloss.Color("#9A3131") // red-80
	DrGreen       = lipgloss.Color("#81FBA5") // green-60
	DrYellow      = lipgloss.Color("#F6EB61") // yellow-60
	DrBlack       = lipgloss.Color("#0B0B0B") // black-90
)

DataRobot brand colors, utilizing the Design System palette

View Source
const (
	DrPurpleDark      = lipgloss.Color("#5500DD") // Darker purple
	DrPurpleDarkLight = lipgloss.Color("#7755DD") // Darker purple-light
	DrIndigoDark      = lipgloss.Color("#4400FF") // Darker indigo
	DrGreenDark       = lipgloss.Color("#00AA00") // Darker green
	DrYellowDark      = lipgloss.Color("#AA8800") // Darker yellow
	DrGray            = lipgloss.Color("252")     // Light gray for dark backgrounds
	DrGrayDark        = lipgloss.Color("240")     // Dark gray for light backgrounds
)

Light mode color variants (darker for visibility on light backgrounds)

View Source

Banner contains the DataRobot ASCII art logo

View Source
const DebugLogFile = "dr-tui-debug.log"

DebugLogFile is the filename for TUI debug logs

View Source
const DebugLogLevelWidth = 5

Variables

View Source
var (
	BaseTextStyle = lipgloss.NewStyle().Foreground(GetAdaptiveColor(DrPurple, DrPurpleDark))
	ErrorStyle    = lipgloss.NewStyle().Foreground(DrRed).Bold(true)
	InfoStyle     = lipgloss.NewStyle().Foreground(GetAdaptiveColor(DrPurpleLight, DrPurpleDarkLight)).Bold(true)
	DimStyle      = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))

	// Specific UI styles
	LogoStyle     = BaseTextStyle
	WelcomeStyle  = BaseTextStyle.Bold(true)
	SubTitleStyle = BaseTextStyle.Bold(true).
					Foreground(DrPurpleLight).
					BorderBottom(true).
					BorderStyle(lipgloss.NormalBorder()).
					BorderForeground(DrGreen)
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(DrPurple).
				Padding(1, 2)
	NoteBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(GetAdaptiveColor(DrPurpleLight, DrPurpleDarkLight)).
					Padding(0, 1)
	StatusBarStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(DrPurpleLight).
					Foreground(DrPurpleLight).
					Padding(0, 1)
)

Common style definitions using DataRobot branding

View Source
var DebugLogStyles = func() *log.Styles {
	styles := log.DefaultStyles()
	for level, style := range styles.Levels {
		styles.Levels[level] = style.MaxWidth(DebugLogLevelWidth).PaddingRight(1)
	}

	return styles
}()

DebugLogStyles customizes the log styles for debug logging in the TUI

Functions

func ClearStatusAfter added in v0.2.14

func ClearStatusAfter(duration time.Duration, msgID int) tea.Cmd
func Footer() string

Footer renders the common footer with quit instructions

func GetAdaptiveColor added in v0.2.11

func GetAdaptiveColor(darkColor, lightColor lipgloss.Color) lipgloss.Color

GetAdaptiveColor returns a color that works on both light and dark backgrounds

func Header() string

Header renders the common header with DataRobot logo

func RenderStatusBar added in v0.2.7

func RenderStatusBar(width int, s spinner.Model, message string, isLoading bool) string

RenderStatusBar creates a status bar with optional spinner and message. Based on lipgloss layout example.

func ResetForegroundColor added in v0.2.3

func ResetForegroundColor() string

func Run added in v0.2.28

func Run(model tea.Model, opts ...tea.ProgramOption) (tea.Model, error)

Run is a wrapper for tea.NewProgram and (p *Program) Run() Configures debug logging for the TUI if debug mode is enabled Wraps a model in NewInterruptibleModel

func SetAnsiForegroundColor added in v0.2.3

func SetAnsiForegroundColor(hexColor lipgloss.Color) string

Types

type ClearStatusMsg added in v0.2.14

type ClearStatusMsg struct {
	MsgID int
}

type InterruptibleModel added in v0.1.5

type InterruptibleModel struct {
	Model tea.Model
}

InterruptibleModel wraps any Bubble Tea model to ensure Ctrl-C always works. This wrapper intercepts ALL messages before they reach the underlying model, checking for Ctrl-C and immediately quitting if detected. This guarantees users can never get stuck in the program, regardless of what the model does.

func NewInterruptibleModel added in v0.1.5

func NewInterruptibleModel(model tea.Model) InterruptibleModel

NewInterruptibleModel wraps a model to ensure Ctrl-C always works everywhere. Use this when creating any Bubble Tea program to guarantee users can exit.

Example:

m := myModel{}
p := tea.NewProgram(tui.NewInterruptibleModel(m), tea.WithAltScreen())

func (InterruptibleModel) Init added in v0.1.5

func (m InterruptibleModel) Init() tea.Cmd

func (InterruptibleModel) Update added in v0.1.5

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

func (InterruptibleModel) View added in v0.1.5

func (m InterruptibleModel) View() string

Jump to

Keyboard shortcuts

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