Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

devtui/internal/ui/base_pager_model.go

Index

Constants

View Source
const (
	StatusBarHeight = 1
	Ellipsis        = "…"
)
View Source
const AppTitle = "DevTUI"
View Source
const StatusMessageTimeout = time.Second * 3 // how long to show status messages like "stashed!"

Variables

View Source
var (
	HelpViewStyle = lipgloss.NewStyle().
					Foreground(statusBarNoteFg).
					Background(lipgloss.AdaptiveColor{Light: "#f2f2f2", Dark: "#1B1B1B"}).
					Render

	StatusBarNoteStyle = lipgloss.NewStyle().
						Foreground(statusBarNoteFg).
						Background(statusBarBg).Render

	AppNameStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("230")).
					Background(lipgloss.Color("62")).
					Bold(true).Render

	StatusBarErrorHelpStyle = lipgloss.NewStyle().
							Foreground(lightRed).
							Background(darkRed).Render

	StatusBarMessageHelpStyle = lipgloss.NewStyle().
								Foreground(lipgloss.Color("#B6FFE4")).
								Background(green).Render

	StatusBarHelpStyle = lipgloss.NewStyle().
						Foreground(statusBarNoteFg).
						Background(lipgloss.AdaptiveColor{Light: "#DCDCDC", Dark: "#323232"}).Render

	StatusBarScrollPosStyle = lipgloss.NewStyle().
							Foreground(lipgloss.AdaptiveColor{Light: "#949494", Dark: "#5A5A5A"}).
							Background(statusBarBg).
							Render
	StatusBarMessageStyle = lipgloss.NewStyle().
							Foreground(mintGreen).
							Background(darkGreen).Render
	StatusBarErrorStyle = lipgloss.NewStyle().
						Foreground(lightRed).
						Background(darkRed).Render

	LineNumberStyle = lipgloss.NewStyle().
					Foreground(lineNumberFg).
					Render
)
View Source
var PagePaddingStyle = lipgloss.NewStyle().Padding(2)

Functions

func Indent

func Indent(s string, n int) string

func WaitForStatusMessageTimeout

func WaitForStatusMessageTimeout(t *time.Timer) tea.Cmd

Types

type BasePagerModel

type BasePagerModel struct {
	Common             *CommonModel
	Title              string
	Content            string
	FormattedContent   string
	Viewport           viewport.Model
	ShowHelp           bool
	Ready              bool
	State              PagerState
	StatusMessage      string
	StatusMessageTimer *time.Timer
	HelpHeight         int
}

BasePagerModel provides common functionality for pager-based TUI views. There is a lot of common

func NewBasePagerModel

func NewBasePagerModel(common *CommonModel, title string) BasePagerModel

func (*BasePagerModel) FormatHelpColumns

func (m *BasePagerModel) FormatHelpColumns(col1 []string) string

FormatHelpColumns formats the help view with columns

func (*BasePagerModel) HandleCommonKeys

func (m *BasePagerModel) HandleCommonKeys(msg tea.KeyMsg) (tea.Cmd, bool)

func (*BasePagerModel) HandleWindowSizeMsg

func (m *BasePagerModel) HandleWindowSizeMsg(msg tea.WindowSizeMsg) tea.Cmd

func (BasePagerModel) Init

func (m BasePagerModel) Init() tea.Cmd

func (*BasePagerModel) SetSize

func (m *BasePagerModel) SetSize(w, h int)

func (*BasePagerModel) ShowErrorMessage

func (m *BasePagerModel) ShowErrorMessage(message string) tea.Cmd

func (*BasePagerModel) ShowStatusMessage

func (m *BasePagerModel) ShowStatusMessage(message string) tea.Cmd

func (*BasePagerModel) StatusBarView

func (m *BasePagerModel) StatusBarView() string

func (*BasePagerModel) ToggleHelp

func (m *BasePagerModel) ToggleHelp()

type CommonModel

type CommonModel struct {
	Width  int
	Height int

	LastSelectedItem int

	Lg     *lipgloss.Renderer
	Styles *Styles
}

type PagerState

type PagerState int
const (
	PagerStateBrowse PagerState = iota
	PagerStateStatusMessage
	PagerStateErrorMessage
)

type PagerStatusMsg

type PagerStatusMsg struct {
	Message string
}

type ReturnToListMsg

type ReturnToListMsg struct {
	Common *CommonModel
}

type StatusMessageTimeoutMsg

type StatusMessageTimeoutMsg struct{}

type Styles

type Styles struct {
	Base,
	Title,
	Subtitle,
	Help lipgloss.Style
}

Use huh/examples/dynamic-bubbletea as an example how to style an application with a huh form in it.

func NewStyle

func NewStyle(lg *lipgloss.Renderer) *Styles

Jump to

Keyboard shortcuts

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