Documentation
¶
Overview ¶
Package tab provides configuration options for the tabbed interface.
Package tab provides functionality for managing tabbed interfaces.
Package tab provides functionality for managing tabbed interfaces.
Package tab provides functionality for managing tabbed interfaces.
Package tab provides functionality for managing tabbed interfaces.
Index ¶
- type Content
- type EventHandler
- type Header
- type Manager
- func (m *Manager) AddTab(tab *Tab)
- func (m *Manager) GetActiveIndex() int
- func (m *Manager) GetActiveTab() *Tab
- func (m *Manager) GetNotifiedIndexes() []int
- func (m *Manager) GetNotifiedTabs() []*Tab
- func (m *Manager) GetTabIndex(target *Tab) int
- func (m *Manager) GetTabNames() []string
- func (m *Manager) GetTabNum() int
- func (m *Manager) HasNotificationAt(index int) bool
- func (m *Manager) NextTab() bool
- func (m *Manager) PreviousTab() bool
- func (m *Manager) SetActiveTab(index int) bool
- func (m *Manager) SetNotification(index int, active bool, duration time.Duration) bool
- func (m *Manager) Snapshot() ([]Snapshot, int)
- type Option
- func ActiveIcon(active string) Option
- func ActiveTabColor(color cell.Color) Option
- func ActiveTextColor(color cell.Color) Option
- func AnimatedActiveTab(enable bool) Option
- func EnableLogging(_ bool) Optiondeprecated
- func FollowNotifications(enable bool) Option
- func InactiveIcon(inactive string) Option
- func InactiveTabColor(color cell.Color) Option
- func InactiveTextColor(color cell.Color) Option
- func LabelColor(color cell.Color) Option
- func LogWriter(w io.Writer) Option
- func NotificationColor(color cell.Color) Option
- func NotificationIcon(notification string) Option
- func SweepAccentColor(color cell.Color) Option
- func SweepTextColor(color cell.Color) Option
- func Tabs(tabs ...*Tab) Option
- type Options
- type Snapshot
- type Tab
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content displays the content of the active tab.
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler handles keyboard and mouse events for tab navigation.
func NewEventHandler ¶
func NewEventHandler(ctx context.Context, term terminalapi.Terminal, tm *Manager, th *Header, tc *Content, cont *container.Container, cancel context.CancelFunc, opts *Options) *EventHandler
NewEventHandler initializes a new EventHandler.
func (*EventHandler) HandleKeyboard ¶
func (eh *EventHandler) HandleKeyboard(k *terminalapi.Keyboard)
HandleKeyboard processes keyboard events for tab switching.
func (*EventHandler) HandleMouse ¶
func (eh *EventHandler) HandleMouse(m *terminalapi.Mouse)
HandleMouse processes mouse events for tab switching.
func (*EventHandler) Refresh ¶
func (eh *EventHandler) Refresh()
Refresh redraws the tab header and content after an external state change.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header displays the tab names and highlights the active tab.
func (*Header) Advance ¶
Advance moves the active-tab sweep forward by one frame and redraws the header.
func (*Header) GetClickedTab ¶
GetClickedTab returns the index of the tab that was clicked based on the mouse position. Returns -1 if no tab was clicked.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns tab order, active tab state, and notification routing.
func (*Manager) GetActiveIndex ¶
GetActiveIndex returns the current active tab index.
func (*Manager) GetActiveTab ¶
GetActiveTab returns the current active tab.
func (*Manager) GetNotifiedIndexes ¶
GetNotifiedIndexes returns the indexes of tabs that currently have an active notification.
func (*Manager) GetNotifiedTabs ¶
GetNotifiedTabs returns all tabs that currently have an active notification.
func (*Manager) GetTabIndex ¶
GetTabIndex returns the current index of target.
func (*Manager) GetTabNames ¶
GetTabNames returns a copy of the current tab labels.
func (*Manager) HasNotificationAt ¶
HasNotificationAt reports whether the tab at index currently has an active notification.
func (*Manager) PreviousTab ¶
PreviousTab activates the previous tab, wrapping at the beginning.
func (*Manager) SetActiveTab ¶
SetActiveTab makes the specified index active.
Returns true when the requested index became active.
func (*Manager) SetNotification ¶
SetNotification replaces the notification state for the tab at index.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option represents a configuration option for the Tab.
func ActiveIcon ¶
ActiveIcon sets custom icons for the active state.
func ActiveTabColor ¶
ActiveTabColor sets the background color of the active tab.
func ActiveTextColor ¶
ActiveTextColor sets the text color of the active tab.
func AnimatedActiveTab ¶
AnimatedActiveTab enables or disables the active-tab underline animation.
When enabled, the active tab keeps its underline while a small accent marker moves across it. Callers that prefer a calmer header can leave this disabled and still get a static underline on the active tab.
func EnableLogging
deprecated
func FollowNotifications ¶
FollowNotifications sets whether the app should follow notifications automatically.
func InactiveIcon ¶
InactiveIcon sets custom icons for the inactive state.
func InactiveTabColor ¶
InactiveTabColor sets the background color of inactive tabs.
func InactiveTextColor ¶
InactiveTextColor sets the text color of inactive tabs.
func LabelColor ¶
LabelColor sets the color of the tab labels.
func LogWriter ¶
LogWriter directs debug log output to w. Pass io.Discard (or omit the option) to silence all output. NewEventHandler never opens files.
func NotificationColor ¶
NotificationColor sets the foreground color of the notification/alarm icon shown on tabs that have an active notification. Defaults to bright amber (xterm colour 214) so the icon is impossible to miss.
func NotificationIcon ¶
NotificationIcon sets custom icons for notifications.
func SweepAccentColor ¶
SweepAccentColor sets the accent color used by the moving underline marker.
func SweepTextColor ¶
SweepTextColor sets the text color used while the active sweep passes.
type Options ¶
type Options struct {
Tabs []*Tab // List of tabs.
LabelColor cell.Color // Color of the tab labels.
ActiveTextColor cell.Color // Text color of the active tab.
InactiveTextColor cell.Color // Text color of inactive tabs.
ActiveTabColor cell.Color // Background color of the active tab.
InactiveTabColor cell.Color // Background color of inactive tabs.
ActiveIcon string // Icon for active tabs.
InactiveIcon string // Icon for inactive tabs.
NotificationIcon string // Icon for tabs with notifications.
NotificationColor cell.Color // Foreground color of the notification icon (alarm indicator).
AnimatedActiveTab bool // Enables a moving accent marker in the active tab underline row.
SweepTextColor cell.Color // Text color used under the active sweep.
SweepAccentColor cell.Color // Accent color used for the moving underline marker.
LogWriter io.Writer // Destination for debug logs; nil disables logging.
FollowNotifications bool // Whether to follow notifications automatically.
}
Options holds the configuration for the Tab.
func NewOptions ¶
NewOptions initializes default options or applies provided options.
type Tab ¶
type Tab struct {
// Name is the label shown in the tab header.
Name string
// Content is the container option used to render the tab body.
Content container.Option
// contains filtered or unexported fields
}
Tab stores one tab label and the container content shown when the tab is active.
The notification state is protected separately so callers can cheaply ask a tab whether it still has an active notification without holding the manager lock.
func (*Tab) HasNotification ¶
HasNotification reports whether the tab currently has an active notification.
Expired notifications are cleared lazily when observed so callers do not need a dedicated sweeper.