navigation

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollapseToggleMsg

type CollapseToggleMsg struct{}

CollapseToggleMsg is emitted when the user clicks the collapse/expand handle at the top of the sidebar. The router forwards it to the nav's Update so the sidebar can toggle its own collapsed state, then triggers a layout resize.

type Focusable added in v0.1.2

type Focusable interface {
	SetFocused(bool)
}

Focusable is implemented by navigators that support keyboard focus (the sidebar). Navigators with no focus concept (tabs) omit it; the router uses a capability check rather than a concrete-type assertion to drive focus.

type KeyCapturer

type KeyCapturer interface {
	CapturesKeys() bool
}

KeyCapturer can be implemented by page models that need exclusive keyboard focus. When CapturesKeys returns true the router will bypass its own global key shortcuts (quit, page-cycling) and will not forward key events to the navigation component, ensuring every keystroke reaches the active page.

type MinimalTopNav added in v0.1.9

type MinimalTopNav struct {
	Pages       []Page
	ActiveIndex int
	ShowNumbers bool
	KeyMap      NavKeyMap

	page.Base
	// contains filtered or unexported fields
}

MinimalTopNav is a compact top-docked navigator styled like the inspector's tab line: a single horizontal row of labels, the active one highlighted, with no borders. A leading per-tab number ("1:", "2:", …) is optional and defaults to hidden. The number keys 1–9 select a tab directly only when the user has enabled "Number Key Select" in Settings (off by default); the router maps the digits for top-docked navs independently of whether the prefix is shown.

func NewMinimalTopNav added in v0.1.9

func NewMinimalTopNav() *MinimalTopNav

NewMinimalTopNav returns a minimal top nav with the default page set and the number prefixes hidden.

func (*MinimalTopNav) Dock added in v0.1.9

func (m *MinimalTopNav) Dock() Side

func (*MinimalTopNav) GetActiveIndex added in v0.1.9

func (m *MinimalTopNav) GetActiveIndex() int

func (*MinimalTopNav) GetPages added in v0.1.9

func (m *MinimalTopNav) GetPages() []Page

func (*MinimalTopNav) Height added in v0.1.9

func (m *MinimalTopNav) Height() int

func (*MinimalTopNav) Init added in v0.1.9

func (m *MinimalTopNav) Init() tea.Cmd

func (*MinimalTopNav) SetActiveIndex added in v0.1.9

func (m *MinimalTopNav) SetActiveIndex(i int)

func (*MinimalTopNav) SetPages added in v0.1.9

func (m *MinimalTopNav) SetPages(p []Page)

func (*MinimalTopNav) SetShowNumbers added in v0.1.9

func (m *MinimalTopNav) SetShowNumbers(show bool)

SetShowNumbers toggles the leading per-tab number prefix.

func (*MinimalTopNav) Update added in v0.1.9

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

func (*MinimalTopNav) View added in v0.1.9

func (m *MinimalTopNav) View() tea.View

func (*MinimalTopNav) Width added in v0.1.9

func (m *MinimalTopNav) Width() int

Width reports the horizontal layout space consumed; a top nav stacks above content and reserves no side width.

type NavFocusMsg struct{ Focused bool }

NavFocusMsg signals that the sidebar has gained or lost keyboard focus. The sidebar emits NavFocusMsg{Focused: true} when clicked and NavFocusMsg{Focused: false} when Esc is pressed inside it. The router emits NavFocusMsg{Focused: false} when the page-content area is clicked so the sidebar's visual focus indicator is updated.

type NavKeyMap struct {
	PreviousPage key.Binding
	NextPage     key.Binding
	Select       key.Binding
	Dismiss      key.Binding
}

NavKeyMap defines key bindings used when the sidebar has keyboard focus.

func DefaultNavKeyMap

func DefaultNavKeyMap() NavKeyMap

DefaultNavKeyMap returns the default key bindings for sidebar navigation.

func (km NavKeyMap) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (km NavKeyMap) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

type Navigator interface {
	Init() tea.Cmd
	Update(msg tea.Msg) (tea.Model, tea.Cmd)
	View() tea.View
	Width() int
	Height() int
	// Dock reports which edge the navigator occupies, letting the router lay it
	// out and route input without type-asserting concrete navigator types.
	Dock() Side
	GetPages() []Page
	SetPages([]Page)
	SetActiveIndex(int)
	GetActiveIndex() int
}

type NumberLabeled added in v0.1.9

type NumberLabeled interface {
	SetShowNumbers(bool)
}

NumberLabeled is implemented by navigators that can optionally show a leading per-item number prefix (the minimal top nav). The router applies the user's preference via this capability without asserting a concrete type.

type Page

type Page struct {
	ID    string
	Title string
}

type SelectedMsg

type SelectedMsg struct {
	PageIndex int
}

SelectedMsg is emitted when a navigation item is selected (via click or key).

type Side added in v0.1.2

type Side int

Side indicates where a navigation component docks relative to the page content.

const (
	// DockLeft reserves columns on the left (e.g. a sidebar); the page renders
	// to its right via JoinHorizontal.
	DockLeft Side = iota
	// DockTop reserves rows at the top (e.g. a tab bar); the page renders below
	// it via JoinVertical.
	DockTop
)
type Sidebar struct {

	// Pages is the full page list (Settings last when present).
	Pages []Page

	// ActiveIndex is the globally active page index (mirrors the router).
	ActiveIndex int

	page.Base
	// contains filtered or unexported fields
}

Sidebar is a panel-style Navigator backed by a bubbles/list for the main navigation items, with the Settings page pinned to the very bottom.

func New

func New() *Sidebar

New creates a Sidebar with the standard Home / Inspector / Settings pages.

func (*Sidebar) Dock added in v0.1.2

func (m *Sidebar) Dock() Side

Dock reports that the sidebar occupies the left edge.

func (*Sidebar) GetActiveIndex

func (m *Sidebar) GetActiveIndex() int

func (*Sidebar) GetPages

func (m *Sidebar) GetPages() []Page

func (*Sidebar) Height

func (m *Sidebar) Height() int

func (*Sidebar) Init

func (m *Sidebar) Init() tea.Cmd

func (*Sidebar) SetActiveIndex

func (m *Sidebar) SetActiveIndex(i int)

func (*Sidebar) SetFocused

func (m *Sidebar) SetFocused(f bool)

SetFocused lets the router update the sidebar's visual focus state without going through the message loop (e.g. when Tab cycles pages).

func (*Sidebar) SetPages

func (m *Sidebar) SetPages(p []Page)

SetPages replaces the page list and identifies the Settings pin by ID.

func (*Sidebar) Update

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

func (*Sidebar) View

func (m *Sidebar) View() tea.View

func (*Sidebar) Width

func (m *Sidebar) Width() int

type TabHoverMsg

type TabHoverMsg struct{ Index int }

TabHoverMsg reports that the mouse is over a tab index (or -1 for none).

type Tabs

type Tabs struct {
	Pages       []Page
	ActiveIndex int
	HoverIndex  int
	KeyMap      NavKeyMap

	page.Base
	// contains filtered or unexported fields
}

func NewTabs

func NewTabs() *Tabs

func (*Tabs) Dock added in v0.1.2

func (m *Tabs) Dock() Side

Dock reports that the tab bar occupies the top edge.

func (*Tabs) GetActiveIndex

func (m *Tabs) GetActiveIndex() int

func (*Tabs) GetPages

func (m *Tabs) GetPages() []Page

func (*Tabs) Height

func (m *Tabs) Height() int

func (*Tabs) Init

func (m *Tabs) Init() tea.Cmd

func (*Tabs) SetActiveIndex

func (m *Tabs) SetActiveIndex(i int)

func (*Tabs) SetPages

func (m *Tabs) SetPages(p []Page)

func (*Tabs) Update

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

func (*Tabs) View

func (m *Tabs) View() tea.View

func (*Tabs) Width

func (m *Tabs) Width() int

Width reports the horizontal layout space consumed by this navigator. Tabs are stacked above content, so they do not consume side width.

Jump to

Keyboard shortcuts

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