types

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Key         Key
	Modifier    gocui.Modifier
	Handler     func() error
	Description string
	Tag         string // e.g. "navigation", used for grouping in help views
}

Binding maps a key press to a handler within a specific context.

type ConfirmOpts

type ConfirmOpts struct {
	Title         string
	Prompt        string
	HandleConfirm func() error
	HandleClose   func() error
}

ConfirmOpts configures a confirmation popup.

type Context

type Context interface {
	IBaseContext

	HandleFocus(opts OnFocusOpts)
	HandleFocusLost(opts OnFocusLostOpts)
	HandleRender()
}

Context extends IBaseContext with lifecycle hooks.

type ContextKey

type ContextKey string

ContextKey uniquely identifies a context.

type ContextKind

type ContextKind int

ContextKind categorises contexts by their role in the layout.

const (
	// SIDE_CONTEXT is a panel on the left-hand side (workspace, migrations).
	SIDE_CONTEXT ContextKind = iota
	// MAIN_CONTEXT is the main content area (details, output).
	MAIN_CONTEXT
	// TEMPORARY_POPUP is a transient popup (confirm, prompt, menu, message).
	TEMPORARY_POPUP
)

type IBaseContext

type IBaseContext interface {
	GetKey() ContextKey
	GetKind() ContextKind
	GetViewName() string
	GetView() *gocui.View
	IsFocusable() bool
	Title() string
}

IBaseContext defines the minimal identity and metadata for a context.

type IController

type IController interface {
	GetKeybindings() []*Binding
	Context() Context
}

IController is the interface that all controllers must implement. Each controller is associated with exactly one context and provides the keybindings for that context.

type IControllerHost added in v0.3.1

type IControllerHost interface {
	IGuiCommon

	// Command lifecycle
	TryStartCommand(name string) bool
	LogCommandBlocked(name string)
	FinishCommand()

	// Full refresh with callbacks
	RefreshAll(onComplete ...func()) bool
	RefreshPanels()
}

IControllerHost is the interface controllers use to interact with the application. It extends IGuiCommon with command lifecycle and refresh methods.

type IGuiCommon

type IGuiCommon interface {
	IPopupHandler

	// LogAction logs a user-visible action to the output panel.
	LogAction(action string, detail ...string)
	// Refresh triggers a data refresh and re-render of all contexts.
	Refresh()
	// OnUIThread schedules a function to run on the UI thread.
	OnUIThread(f func() error)
	// GetTranslationSet returns the current translation set.
	GetTranslationSet() *i18n.TranslationSet
}

IGuiCommon is the common interface available to controllers via dependency injection.

type IListContext

type IListContext interface {
	Context

	GetSelectedIdx() int
	GetItemCount() int
	SelectNext()
	SelectPrev()
}

IListContext is a context that presents a selectable list of items.

type IPopupHandler

type IPopupHandler interface {
	// Alert shows a simple notification popup.
	Alert(title string, message string)
	// Confirm shows a yes/no confirmation popup.
	Confirm(opts ConfirmOpts)
	// Prompt shows a text-input popup.
	Prompt(opts PromptOpts)
	// Menu shows a list of selectable options.
	Menu(opts MenuOpts) error
	// Toast shows a brief, non-blocking message.
	Toast(message string)
	// ErrorHandler is the global error handler for gocui.
	ErrorHandler(err error) error
}

IPopupHandler provides methods for displaying popups to the user.

type IScrollableContext

type IScrollableContext interface {
	Context

	ScrollUp()
	ScrollDown()
	ScrollToTop()
	ScrollToBottom()
}

IScrollableContext is a context that supports vertical scrolling.

type ITabbedContext

type ITabbedContext interface {
	Context

	NextTab()
	PrevTab()
	GetCurrentTab() string
}

ITabbedContext is a context that supports tabbed sub-views.

type Key

type Key = any

Key is an alias for any type that can represent a key (gocui.Key or rune).

type KeybindingsFn

type KeybindingsFn func() []*Binding

KeybindingsFn is a function that returns a slice of key bindings.

type MenuItem struct {
	Label       string
	OnPress     func() error
	Description string
}

MenuItem is a single entry in a menu popup.

type MenuOpts struct {
	Title string
	Items []*MenuItem
}

MenuOpts configures a menu popup.

type OnFocusLostOpts

type OnFocusLostOpts struct {
	NewContextKey ContextKey
}

OnFocusLostOpts carries information when a context loses focus.

type OnFocusOpts

type OnFocusOpts struct {
	ClickedViewLineIdx int
}

OnFocusOpts carries information when a context gains focus.

type PromptOpts

type PromptOpts struct {
	Title            string
	InitialContent   string
	HandleConfirm    func(string) error
	Required         bool
	Subtitle         string
	OnValidationFail func(string)
}

PromptOpts configures a text-input popup.

Jump to

Keyboard shortcuts

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