Documentation
¶
Index ¶
- type Binding
- type ConfirmOpts
- type Context
- type ContextKey
- type ContextKind
- type IBaseContext
- type IController
- type IControllerHost
- type IGuiCommon
- type IListContext
- type IPopupHandler
- type IScrollableContext
- type ITabbedContext
- type Key
- type KeybindingsFn
- type MenuItem
- type MenuOpts
- type OnFocusLostOpts
- type OnFocusOpts
- type PromptOpts
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 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 ¶
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 ¶
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 ¶
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 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.