tui

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultThemeName = "GitHub Dark"

DefaultThemeName is the name of the default theme.

Variables

View Source
var (
	ConfigDirName       = ".config/gitx"
	ConfigFileName      = "config.toml"
	ConfigDirPath       string
	ConfigFilePath      string
	ConfigThemesDirPath string
)
View Source
var Palettes = map[string]Palette{
	"GitHub Dark": {

		Black:   "#24292E",
		Red:     "#ff7b72",
		Green:   "#3fb950",
		Yellow:  "#d29922",
		Blue:    "#58a6ff",
		Magenta: "#bc8cff",
		Cyan:    "#39c5cf",
		White:   "#b1bac4",

		BrightBlack:   "#6e7681",
		BrightRed:     "#ffa198",
		BrightGreen:   "#56d364",
		BrightYellow:  "#e3b341",
		BrightBlue:    "#79c0ff",
		BrightMagenta: "#d2a8ff",
		BrightCyan:    "#56d4dd",
		BrightWhite:   "#f0f6fc",

		DarkBlack:   "#1b1f23",
		DarkRed:     "#d73a49",
		DarkGreen:   "#28a745",
		DarkYellow:  "#dbab09",
		DarkBlue:    "#2188ff",
		DarkMagenta: "#a041f5",
		DarkCyan:    "#12aab5",
		DarkWhite:   "#8b949e",

		Bg: "#0d1117",
		Fg: "#c9d1d9",
	},
	"Gruvbox": {

		Black:   "#282828",
		Red:     "#cc241d",
		Green:   "#98971a",
		Yellow:  "#d79921",
		Blue:    "#458588",
		Magenta: "#b16286",
		Cyan:    "#689d6a",
		White:   "#a89984",

		BrightBlack:   "#928374",
		BrightRed:     "#fb4934",
		BrightGreen:   "#b8bb26",
		BrightYellow:  "#fabd2f",
		BrightBlue:    "#83a598",
		BrightMagenta: "#d3869b",
		BrightCyan:    "#8ec07c",
		BrightWhite:   "#ebdbb2",

		DarkBlack:   "#1d2021",
		DarkRed:     "#9d0006",
		DarkGreen:   "#79740e",
		DarkYellow:  "#b57614",
		DarkBlue:    "#076678",
		DarkMagenta: "#8f3f71",
		DarkCyan:    "#427b58",
		DarkWhite:   "#928374",

		Bg: "#282828",
		Fg: "#ebdbb2",
	},
}

Palettes holds all the available color palettes.

View Source
var Themes = map[string]Theme{}

Themes holds all the available themes, generated from palettes.

Functions

func ThemeNames

func ThemeNames() []string

ThemeNames returns a slice of the available theme names.

Types

type App

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

App is the main application struct.

func NewApp

func NewApp() *App

NewApp initializes a new TUI application.

func (*App) Run

func (a *App) Run() error

Run starts the TUI application and the file watcher.

type BorderStyle

type BorderStyle struct {
	Top         string
	Bottom      string
	Left        string
	Right       string
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Style       lipgloss.Style
}

BorderStyle defines the characters and styles for a panel's border.

type HelpSection

type HelpSection struct {
	Title    string
	Bindings []key.Binding
}

HelpSection is a struct to hold a title and keybindings for a help section.

type KeyMap

type KeyMap struct {
	// miscellaneous keybindings
	Quit       key.Binding
	Escape     key.Binding
	ToggleHelp key.Binding

	// keybindings for changing theme
	SwitchTheme key.Binding

	// keybindings for navigation
	FocusNext  key.Binding
	FocusPrev  key.Binding
	FocusZero  key.Binding
	FocusOne   key.Binding
	FocusTwo   key.Binding
	FocusThree key.Binding
	FocusFour  key.Binding
	FocusFive  key.Binding
	FocusSix   key.Binding
	Up         key.Binding
	Down       key.Binding

	// Keybindings for FilesPanel
	StageItem key.Binding
	StageAll  key.Binding
	Discard   key.Binding
	Stash     key.Binding
	StashAll  key.Binding
	Commit    key.Binding

	// Keybindings for BranchesPanel
	Checkout     key.Binding
	NewBranch    key.Binding
	DeleteBranch key.Binding
	RenameBranch key.Binding

	// Keybindings for CommitsPanel
	AmendCommit   key.Binding
	Revert        key.Binding
	ResetToCommit key.Binding

	// Keybindings for StashPanel
	StashApply key.Binding
	StashPop   key.Binding
	StashDrop  key.Binding
}

KeyMap defines the keybindings for the application.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns a set of default keybindings.

func (KeyMap) BranchesPanelHelp

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

BranchesPanelHelp returns a slice of key.Binding for the Branches Panel help bar.

func (KeyMap) CommitsPanelHelp

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

CommitsPanelHelp returns a slice of key.Binding for the Commits Panel help bar.

func (KeyMap) FilesPanelHelp

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

FilesPanelHelp returns a slice of key.Binding containing help for keybindings related to Files Panel.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() []HelpSection

FullHelp returns a structured slice of HelpSection, which is used to build the full help view.

func (KeyMap) HelpViewHelp

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

HelpViewHelp returns a slice of key.Binding containing help for keybindings related to Help View.

func (KeyMap) ShortHelp

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

ShortHelp returns a slice of key.Binding containing help for default keybindings.

func (KeyMap) StashPanelHelp

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

StashPanelHelp returns a slice of key.Binding for the Stash Panel help bar.

type Model

type Model struct {

	// New fields for command history
	CommandHistory []string
	// contains filtered or unexported fields
}

Model represents the state of the TUI.

func (Model) Init

func (m Model) Init() tea.Cmd

Init is the first command that is run when the program starts.

func (Model) Update

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

Update is the main message handler for the TUI. It processes user input, window events, and application-specific messages.

func (Model) View

func (m Model) View() string

View is the main render function for the application.

type Node

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

Node represents a file or directory within the file tree structure.

func BuildTree

func BuildTree(gitStatus string) *Node

BuildTree parses the output of `git status --porcelain` to construct a file tree.

func (*Node) Render

func (n *Node) Render(theme Theme) []string

Render traverses the tree and returns a slice of formatted strings for display.

type Palette

type Palette struct {
	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White,
	BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite,
	DarkBlack, DarkRed, DarkGreen, DarkYellow, DarkBlue, DarkMagenta, DarkCyan, DarkWhite,
	Bg, Fg string
}

Palette defines a set of colors for a theme.

type Panel

type Panel int

Panel is an enumeration of all the panels in the UI.

const (
	MainPanel Panel = iota
	StatusPanel
	FilesPanel
	BranchesPanel
	CommitsPanel
	StashPanel
	SecondaryPanel
)

Defines the available panels in the UI.

func (Panel) ID

func (p Panel) ID() string

ID returns a string ID for the panel, used for mouse zone detection.

type Theme

type Theme struct {
	ActiveTitle    lipgloss.Style
	InactiveTitle  lipgloss.Style
	NormalText     lipgloss.Style
	HelpTitle      lipgloss.Style
	HelpKey        lipgloss.Style
	HelpButton     lipgloss.Style
	ScrollbarThumb lipgloss.Style
	SelectedLine   lipgloss.Style
	Hyperlink      lipgloss.Style
	WelcomeHeading lipgloss.Style
	WelcomeMsg     lipgloss.Style
	UserName       lipgloss.Style
	GitStaged      lipgloss.Style
	GitUnstaged    lipgloss.Style
	GitUntracked   lipgloss.Style
	GitConflicted  lipgloss.Style
	BranchCurrent  lipgloss.Style
	BranchDate     lipgloss.Style
	CommitSHA      lipgloss.Style
	CommitAuthor   lipgloss.Style
	CommitMerge    lipgloss.Style
	GraphEdge      lipgloss.Style
	GraphNode      lipgloss.Style
	GraphColors    []lipgloss.Style
	StashName      lipgloss.Style
	StashMessage   lipgloss.Style
	ActiveBorder   BorderStyle
	InactiveBorder BorderStyle
	Tree           TreeStyle
	ErrorText      lipgloss.Style
}

Theme represents the styles for different components of the UI.

func NewThemeFromPalette

func NewThemeFromPalette(p Palette) Theme

NewThemeFromPalette creates a Theme from a given color Palette.

type ThemeFile added in v1.2.5

type ThemeFile struct {
	Fg     string            `toml:"fg"`
	Bg     string            `toml:"bg"`
	Normal map[string]string `toml:"normal"`
	Bright map[string]string `toml:"bright"`
	Dark   map[string]string `toml:"dark"`
}

custom_theme.toml

type TreeStyle

type TreeStyle struct {
	Connector, ConnectorLast, Prefix, PrefixLast string
}

TreeStyle defines the characters used to render the file tree.

Jump to

Keyboard shortcuts

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