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

tui

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentMarkdown = 0
	ContentDiff     = 1
	ContentPlain    = 2
)

Variables

View Source
var (
	ColorGreen  = lipgloss.Color("#04B575")
	ColorRed    = lipgloss.Color("#FF4672")
	ColorYellow = lipgloss.Color("#FFBF00")
	ColorBlue   = lipgloss.Color("#7DC4E4")
	ColorGray   = lipgloss.Color("244")
	ColorPurple = lipgloss.Color("#8B4789")
)

Functions

func InfoStyle

func InfoStyle() lipgloss.Style

func LoadTheme

func LoadTheme()

func NewHuhExecCmd

func NewHuhExecCmd(fn func() error) tea.ExecCommand

func NewPagerCmd

func NewPagerCmd(title, content string, contentType int) tea.Cmd

func RenderChafa

func RenderChafa(url string, termWidth int) (string, error)

RenderChafa runs chafa to convert the image at url into unicode art sized to termWidth columns.

func RenderITerm2

func RenderITerm2(url string, termWidth int) (string, error)

RenderITerm2 encodes the image as an iTerm2 Inline Images Protocol sequence. Spec: https://iterm2.com/documentation-images.html

func RenderKitty

func RenderKitty(url string, _ int) (string, error)

RenderKitty encodes the image at url as a Kitty Graphics Protocol APC sequence (chunked base64, f=100 lets kitty auto-detect format from magic bytes). Spec: https://sw.kovidgoyal.net/kitty/graphics-protocol/

func RenderOSC8

func RenderOSC8(alt, rawURL string) string

RenderOSC8 returns an OSC 8 hyperlink so the user can click the image URL in terminals that support it (kitty, WezTerm, iTerm2, etc.).

func RunPager

func RunPager(title, content string, contentType int) error

func RunTable

func RunTable(cfg TableConfig) error

func StateStyle

func StateStyle(state string) lipgloss.Style

func TitleStyle

func TitleStyle() lipgloss.Style

func Truncate

func Truncate(s string, maxWidth int) string

Types

type EditDoneMsg

type EditDoneMsg struct {
	Err error
}

type FetchResultMsg

type FetchResultMsg struct {
	Branch string
	Err    error
}

type HelpKey

type HelpKey struct {
	Key  string
	Desc string
}

type HuhExecCmd

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

func (*HuhExecCmd) Run

func (h *HuhExecCmd) Run() error

func (*HuhExecCmd) SetStderr

func (h *HuhExecCmd) SetStderr(w io.Writer)

func (*HuhExecCmd) SetStdin

func (h *HuhExecCmd) SetStdin(r io.Reader)

func (*HuhExecCmd) SetStdout

func (h *HuhExecCmd) SetStdout(w io.Writer)

type ImageRef

type ImageRef struct {
	Alt string
	URL string
}

func ExtractImages

func ExtractImages(markdown string) []ImageRef

ExtractImages returns all ![alt](url) references found in raw markdown.

type RendererType

type RendererType int
const (
	RendererNone RendererType = iota
	RendererChafa
	RendererKitty
	RendererITerm2
)

func DetectRenderer

func DetectRenderer() RendererType

DetectRenderer probes the environment for image rendering capability. Priority: Kitty Graphics Protocol > iTerm2 Inline Images > chafa > none (OSC 8 hyperlink fallback).

func RenderImage

func RenderImage(ref ImageRef, renderer RendererType, termWidth int) (string, RendererType)

RenderImage tries each renderer in priority order and returns the rendered content along with the renderer that succeeded.

type TableConfig

type TableConfig struct {
	Columns  []table.Column
	Rows     []table.Row
	Height   int
	HelpKeys []HelpKey
	OnSelect func(row table.Row)
	OnCopy   func(row table.Row)
	OnView   func(row table.Row) tea.Cmd
	OnDiff   func(row table.Row) tea.Cmd
	OnFetch  func(row table.Row) tea.Cmd
	OnEdit   func(row table.Row) tea.ExecCommand
}

type Theme

type Theme struct {
	Accent       lipgloss.Color
	Border       lipgloss.Color
	HeaderFg     lipgloss.Color
	SelectedFg   lipgloss.Color
	SelectedBg   lipgloss.Color
	HelpKey      lipgloss.Color
	HelpDesc     lipgloss.Color
	Success      lipgloss.Color
	Error        lipgloss.Color
	Warning      lipgloss.Color
	GlamourStyle string
}

func ActiveTheme

func ActiveTheme() Theme

type ViewAction

type ViewAction struct {
	Row         table.Row
	ContentType int
	Fetch       bool
	Diff        bool
}

type ViewErrorMsg

type ViewErrorMsg struct {
	Err error
}

Jump to

Keyboard shortcuts

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