ui

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppStyle = lipgloss.NewStyle().Margin(1, 2)

	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("205"))

	StatusBarStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("241"))

	// StatusBarInfoStyle is for the left section showing table name and page info.
	StatusBarInfoStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("205")).
						Background(lipgloss.Color("236")).
						Bold(true).
						Padding(0, 1)

	// StatusBarKeyStyle highlights the key binding name (e.g. "f", "enter").
	StatusBarKeyStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("252")).
						Background(lipgloss.Color("235"))

	// StatusBarDescStyle is for the key description (e.g. "filter", "detail").
	StatusBarDescStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("242")).
						Background(lipgloss.Color("235"))

	// StatusBarBgStyle is the base background for the full status bar.
	StatusBarBgStyle = lipgloss.NewStyle().
						Background(lipgloss.Color("235"))

	ErrorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("196")).
				Bold(true)

	// FocusedPaneStyle has a bright border — applied to the active panel.
	// Width/Height are set dynamically at render time via .Width()/.Height().
	FocusedPaneStyle = lipgloss.NewStyle().
						BorderStyle(lipgloss.RoundedBorder()).
						BorderForeground(lipgloss.Color("62"))

	// UnfocusedPaneStyle has a dim border — applied to the inactive panel.
	UnfocusedPaneStyle = lipgloss.NewStyle().
						BorderStyle(lipgloss.RoundedBorder()).
						BorderForeground(lipgloss.Color("240"))

	// PopupStyle wraps the row detail modal. Bright border + background
	// so it visually "floats" above the split pane behind it.
	PopupStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color("205")).
				Padding(1, 2)

	// PopupLabelStyle is for the column names in the key-value list.
	PopupLabelStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("63"))

		" ▄▄▄▄  ▄▄▄  ▄▄    ▄▄ ▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄ \n" +
			"███▄▄ ██▀██ ██    ██   ██   ██ ██ ██ \n" +
			"▄▄██▀ ▀███▀ ██▄▄▄ ██   ██   ▀███▀ ██ \n" +
			"         ▀▀                          ")
)
View Source
var Keys = KeyMap{
	Quit: key.NewBinding(
		key.WithKeys("q", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),
	SwitchTab: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "switch pane"),
	),
	FocusRight: key.NewBinding(
		key.WithKeys("right"),
		key.WithHelp("→", "open & focus"),
	),
	FocusLeft: key.NewBinding(
		key.WithKeys("left"),
		key.WithHelp("←", "back"),
	),
	Select: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "select"),
	),
	OpenQuery: key.NewBinding(
		key.WithKeys("ctrl+e"),
		key.WithHelp("ctrl+e", "SQL query"),
	),
	Refresh: key.NewBinding(
		key.WithKeys("ctrl+r"),
		key.WithHelp("ctrl+r", "refresh"),
	),
	NextPage: key.NewBinding(
		key.WithKeys("]"),
		key.WithHelp("]", "next page"),
	),
	PrevPage: key.NewBinding(
		key.WithKeys("["),
		key.WithHelp("[", "prev page"),
	),
}

Functions

This section is empty.

Types

type CloseDetailMsg

type CloseDetailMsg struct{}

CloseDetailMsg is sent when the user dismisses the row detail popup.

type FilePickerModel

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

FilePickerModel shows a text input for typing a path and a list of SQLite files found in the current directory.

func NewFilePickerModel

func NewFilePickerModel() FilePickerModel

func (FilePickerModel) Init

func (m FilePickerModel) Init() tea.Cmd

func (FilePickerModel) Update

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

func (FilePickerModel) View

func (m FilePickerModel) View() string

type KeyMap

type KeyMap struct {
	Quit       key.Binding
	SwitchTab  key.Binding
	FocusRight key.Binding
	FocusLeft  key.Binding
	Select     key.Binding
	OpenQuery  key.Binding
	Refresh    key.Binding
	NextPage   key.Binding
	PrevPage   key.Binding
}

KeyMap defines shared key bindings used across all views. Centralizing them here (DRY) means one place to change shortcuts.

type Model

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

func NewModel

func NewModel(path string) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type QueryInputModel

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

QueryInputModel is the SQL query popup component. It presents a textarea for writing SQL and executes it on ctrl+r.

func NewQueryInputModel

func NewQueryInputModel(database *sql.DB, termWidth, termHeight int) (QueryInputModel, tea.Cmd)

NewQueryInputModel creates the popup, sized ~70% wide x ~50% tall. Returns a tea.Cmd for the textarea cursor blink.

func (QueryInputModel) Update

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

func (QueryInputModel) View

func (m QueryInputModel) View() string

type QueryResultMsg

type QueryResultMsg struct {
	Columns []string
	Rows    [][]string
}

QueryResultMsg is sent when the user successfully executes a query. The parent model handles this to populate the right pane.

type RowDetailModel

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

RowDetailModel displays a single row's data as a vertical key-value list inside a scrollable viewport. This is the "popup" component.

func NewRowDetailModel

func NewRowDetailModel(columns, values []string, termWidth, termHeight int) RowDetailModel

NewRowDetailModel creates the popup. It renders column:value pairs with aligned colons so the values line up neatly.

func (RowDetailModel) Update

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

func (RowDetailModel) View

func (m RowDetailModel) View() string

View renders the viewport content inside the popup border.

type RowSelectedMsg

type RowSelectedMsg struct {
	Columns []string
	Values  []string
}

RowSelectedMsg is sent when the user presses enter on a row. Carries column names + that row's values so the popup can display them.

type TableDataModel

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

TableDataModel wraps bubbles/table.Model to display rows from a DB table. It also stores the raw data so we can pass it to the popup on selection.

func NewTableDataModel

func NewTableDataModel(name string, columns []string, rows [][]string, width, height int, database *sql.DB, page, pageSize, totalRows int) TableDataModel

func (*TableDataModel) SetSize

func (m *TableDataModel) SetSize(width, height int)

func (TableDataModel) StatusText

func (m TableDataModel) StatusText() string

StatusText returns info about the table for the parent's status bar.

func (TableDataModel) Update

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

func (TableDataModel) View

func (m TableDataModel) View() string

type TableItem

type TableItem struct {
	Name string
}

TableItem implements the list.Item interface from bubbles. The list component needs items that can provide a title, description, and a filter value (used for the built-in fuzzy search).

func (TableItem) Description

func (t TableItem) Description() string

func (TableItem) FilterValue

func (t TableItem) FilterValue() string

func (TableItem) Title

func (t TableItem) Title() string

type TableListModel

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

TableListModel wraps bubbles/list.Model. This is the component composition pattern: our model contains a child model and delegates messages to it.

func NewTableListModel

func NewTableListModel(tables []string, width, height int) TableListModel

NewTableListModel creates the table list from a slice of table names.

func (*TableListModel) SetSize

func (m *TableListModel) SetSize(width, height int)

SetSize updates the list dimensions. Called when the terminal resizes.

func (TableListModel) Update

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

Update delegates messages to the inner list and checks for selection. Notice the return type is (TableListModel, tea.Cmd) — not (tea.Model, tea.Cmd). Sub-models don't need to satisfy the tea.Model interface; only the root does.

func (TableListModel) View

func (m TableListModel) View() string

View returns the raw list output — no border wrapping. The parent model handles borders/layout so this component can be placed in any layout without double-bordering.

type TableSelectedMsg

type TableSelectedMsg struct {
	Name string
}

TableSelectedMsg is sent when the user presses enter on a table. This is how the table list communicates upward to the parent model — through messages, not direct function calls.

Jump to

Keyboard shortcuts

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