ui

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TableStyle             = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("240"))
	TableHeaderStyle       = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("69"))
	TableSelectedStyle     = lipgloss.NewStyle().Foreground(lipgloss.Color("229")).Bold(true)
	TableSelectedTaskStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("39")).Bold(true).PaddingLeft(1)
)

Table Styles

View Source
var (
	ViewportStyle = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("240"))
	FocusedStyle  = lipgloss.NewStyle().BorderStyle(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("69"))
	HelpStyle     = lipgloss.NewStyle().Foreground(lipgloss.Color("241"))

	// Message Styles
	AppMsgStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("10")).Bold(true) // Green for app messages
	ErrorMsgStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9")).Bold(true)  // Red for error messages
	OutputStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("7"))             // Default color for regular output
)
View Source
var (
	TaskDetailOverlayTitleStyle = lipgloss.NewStyle().
								Bold(true).
								Foreground(lipgloss.Color("63")).
								MarginBottom(1)
	TaskDetailOverlayLabelStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("241"))
)

Task Detail Overlay styles

View Source
var (
	HelpTextTitleStyle   = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("63")).MarginBottom(1)
	HelpTextSectionStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("69")).MarginTop(1).MarginBottom(1)
	HelpTextCommandStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("241"))
)

Help Text styles

View Source
var (
	TaskPickerTitleStyle = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("63")).
		MarginBottom(1)
)

Task Picker styles

Functions

func GeneralOverlayStyle added in v0.3.0

func GeneralOverlayStyle(overlayWidth int) lipgloss.Style

func IsKeyMatch added in v0.3.1

func IsKeyMatch(msg tea.KeyMsg, keyBinding string) bool

IsKeyMatch checks if a key message matches a key binding

func RenderHelpOverlay added in v0.3.0

func RenderHelpOverlay(m *Model) string

RenderHelpOverlay renders an overlay with all available commands

func RenderTaskDetailOverlay

func RenderTaskDetailOverlay(width, height int, selectedTask *task.Task) string

RenderTaskDetailOverlay renders an overlay with detailed task information

func RenderTaskPicker added in v0.3.0

func RenderTaskPicker(width, height int, input string, matches []task.Task, selectedIndex int) string

RenderTaskPicker renders the task picker overlay

func TaskDetailOverlayStyle added in v0.3.0

func TaskDetailOverlayStyle(overlayWidth, overlayHeight int) lipgloss.Style

func TaskPickerInputStyle added in v0.3.0

func TaskPickerInputStyle(overlayWidth int) lipgloss.Style

func TaskPickerMatchStyle added in v0.3.0

func TaskPickerMatchStyle(overlayWidth int) lipgloss.Style

func TaskPickerSelectedMatchStyle added in v0.3.0

func TaskPickerSelectedMatchStyle(overlayWidth int) lipgloss.Style

func TextWrap

func TextWrap(s string, n int) []string

TextWrap wraps text to fit within a specified width

Types

type Context added in v0.3.1

type Context string

Context is a type alias for string representing UI contexts where key bindings are active

const (
	ContextGlobal         Context = "global"
	ContextTaskPicker     Context = "taskPicker"
	ContextHelpOverlay    Context = "helpOverlay"
	ContextDetailsOverlay Context = "detailsOverlay"
	ContextViewport       Context = "viewport"
)

Context constants

type Control

type Control int

Control represents a UI control that can be focused

const (
	ControlTable Control = iota
	ControlViewport

	// put any new controls above this line, so our ControlMax, used for tabbing
	// though the controls, stays the maximum Control value
	ControlMax
)

func (Control) Tab

func (c Control) Tab() Control

Tab cycles to the next control

type KeyBinding added in v0.3.1

type KeyBinding struct {
	Key         string    // The key or key combination (e.g., "ctrl+c", "enter")
	Description string    // Description of what the key does
	Contexts    []Context // Contexts where this key binding is active
}

KeyBinding represents a single key binding with its key, description, and context

type KeyBindingSection added in v0.3.1

type KeyBindingSection struct {
	Name        string       // Section name (e.g., "Navigation", "Task Management")
	KeyBindings []KeyBinding // Key bindings in this section
}

KeyBindingSection represents a section of key bindings in the help text

type KeyBindings added in v0.3.1

type KeyBindings struct {
	Sections []KeyBindingSection // Sections of key bindings
}

KeyBindings contains all key bindings used in the application

func DefaultKeyBindings added in v0.3.1

func DefaultKeyBindings() KeyBindings

DefaultKeyBindings returns the default key bindings for the application

func (KeyBindings) GenerateHelpContent added in v0.3.1

func (kb KeyBindings) GenerateHelpContent(overlayWidth int) string

GenerateHelpContent creates the help content with a two-column layout using the key bindings

func (KeyBindings) GetKeyBindingsForContext added in v0.3.1

func (kb KeyBindings) GetKeyBindingsForContext(context Context) []KeyBinding

GetKeyBindingsForContext returns all key bindings for a specific context

func (KeyBindings) GetKeyBindingsForDetailsOverlay added in v0.3.1

func (kb KeyBindings) GetKeyBindingsForDetailsOverlay() []KeyBinding

GetKeyBindingsForDetailsOverlay returns key bindings for the details overlay

func (KeyBindings) GetKeyBindingsForGlobal added in v0.3.1

func (kb KeyBindings) GetKeyBindingsForGlobal() []KeyBinding

GetKeyBindingsForGlobal returns key bindings for the global context

func (KeyBindings) GetKeyBindingsForHelpOverlay added in v0.3.1

func (kb KeyBindings) GetKeyBindingsForHelpOverlay() []KeyBinding

GetKeyBindingsForHelpOverlay returns key bindings for the help overlay

func (KeyBindings) GetKeyBindingsForTaskPicker added in v0.3.1

func (kb KeyBindings) GetKeyBindingsForTaskPicker() []KeyBinding

GetKeyBindingsForTaskPicker returns key bindings specific to the task picker

func (KeyBindings) RenderHelpView added in v0.3.1

func (kb KeyBindings) RenderHelpView(taskRunning bool, showTaskPicker bool, hasSelectedTasks bool) string

RenderHelpView renders the help text at the bottom of the screen using the key bindings

type Model

type Model struct {
	MessageBus msgbus.PublisherSubscriber[task.Message] `json:"-"`

	Tasks         []task.Task `json:"-"`
	TasksLoading  bool
	Result        *string        `json:"-"`
	Viewport      viewport.Model `json:"-"`
	Table         table.Model    `json:"-"`
	Focused       Control
	Width         int
	Height        int
	Initialised   bool
	SelectedTask  *task.Task
	State         UIState        // Current UI state (normal, task picker, details overlay, help overlay)
	HelpViewport  viewport.Model `json:"-"` // Viewport for scrollable help content
	Command       *exec.Cmd      `json:"-"`
	CommandCancel context.CancelFunc
	TaskRunning   bool
	KeyBindings   KeyBindings `json:"-"` // Key bindings for the application

	// Task picker fields
	TaskPickerInput    string
	TaskPickerMatches  []task.Task `json:"-"`
	TaskPickerSelected int

	// Selected tasks for batch execution
	SelectedTasks         []task.Task
	ExecutingBatch        bool
	CurrentBatchTaskIndex int
	// contains filtered or unexported fields
}

Model represents the UI model for the application

func NewModel

NewModel creates a new UI model

func (*Model) AppendAppMsg

func (m *Model) AppendAppMsg(msg string)

AppendAppMsg adds an application message to the viewport

func (*Model) AppendCommandOutput

func (m *Model) AppendCommandOutput(msg string)

AppendCommandOutput adds command output to the viewport

func (*Model) AppendErrorMsg

func (m *Model) AppendErrorMsg(msg string)

AppendErrorMsg adds an error message to the viewport

func (*Model) AppendToViewport

func (m *Model) AppendToViewport(msg string, style lipgloss.Style)

AppendToViewport adds text to the viewport

func (*Model) ExecuteSelectedTask

func (m *Model) ExecuteSelectedTask() tea.Cmd

ExecuteSelectedTask executes the selected task

func (*Model) HandleWindowResize

func (m *Model) HandleWindowResize(width, height int)

HandleWindowResize handles window resize events

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (*Model) RefreshTaskList

func (m *Model) RefreshTaskList() tea.Cmd

RefreshTaskList refreshes the task list

func (Model) Update

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

Update handles messages and updates the model

func (*Model) UpdateTaskTable

func (m *Model) UpdateTaskTable()

UpdateTaskTable updates the task table with the current tasks

func (Model) View

func (m Model) View() string

View renders the UI

type TickMessage added in v0.5.0

type TickMessage struct{}

type UIState added in v0.3.1

type UIState int

UIState represents the different states of the UI

const (
	// StateNormal is the default state of the UI
	StateNormal UIState = iota

	// StateTaskPicker is the state when the task picker is active
	StateTaskPicker

	// StateDetailsOverlay is the state when the task details overlay is active
	StateDetailsOverlay

	// StateHelpOverlay is the state when the help overlay is active
	StateHelpOverlay
)

func (UIState) String added in v0.3.1

func (s UIState) String() string

String returns a string representation of the UIState

Jump to

Keyboard shortcuts

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