tabs

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultForegroundColor         = gloss.AdaptiveColor{Light: "#874Bfd", Dark: "#7d56f4"}
	DefaultUnfocusedColor          = gloss.AdaptiveColor{Light: "#3a3a3a", Dark: "#b0b0b0"}
	DefaultActiveTabIndicatorColor = gloss.AdaptiveColor{Light: "#bb99fe", Dark: "#997bf6"}

	DefaultWindowBorder = gloss.Border{
		Top:         " ",
		Bottom:      "─",
		Left:        "│",
		Right:       "│",
		TopLeft:     "│",
		TopRight:    "│",
		BottomLeft:  "└",
		BottomRight: "┘",
	}

	DefaultTabBorder = gloss.Border{
		Top:         "─",
		Bottom:      "─",
		Left:        "│",
		Right:       "│",
		TopLeft:     "╭'",
		TopRight:    "╮",
		BottomLeft:  "┴",
		BottomRight: "┴",
	}
	DefaultActiveTabBorder = gloss.Border{
		Top:         "─",
		Bottom:      " ",
		Left:        "│",
		Right:       "│",
		TopLeft:     "╭'",
		TopRight:    "╮",
		BottomLeft:  "┘",
		BottomRight: "└",
	}

	DefaultTabSpacerBorder = gloss.Border{
		Bottom:      "─",
		BottomRight: "┐",
	}
)

Functions

This section is empty.

Types

type KeyMap

type KeyMap struct {
	TabLeft  key.Binding
	TabRight key.Binding

	TabNumbers []key.Binding
}

KeyMap contains relevant keys for tab navigation.

func DefaultKeyMap

func DefaultKeyMap(tabs int) KeyMap

DefaultKeyMap contains default key mappings for tab navigation.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model represents a group of tab headers and their content.

func New

func New(tabs ...Tab) Model

New creates a new Model.

func (Model) DefaultDimensions

func (m Model) DefaultDimensions() Model

DefaultDimensions applies the current terminal's dimensions to the tab group.

func (Model) Height

func (m Model) Height(h int) Model

Height sets the Model height.

func (Model) Init

func (m Model) Init() tea.Cmd

Init the Model.

func (Model) NextTab

func (m Model) NextTab() Model

NextTab moves the active tab forward.

func (Model) PreviousTab

func (m Model) PreviousTab() Model

PreviousTab moves the active tab backward.

func (Model) SetTab

func (m Model) SetTab(i int) Model

SetTab sets the active tab.

func (Model) Styles

func (m Model) Styles(styles Styles) Model

Styles sets custom styling.

func (Model) Update

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

Update the Model.

func (Model) View

func (m Model) View() string

View renders the Model.

func (Model) ViewTabs

func (m Model) ViewTabs() string

ViewTabs renders tab headers.

func (Model) ViewWindow

func (m Model) ViewWindow(w int) string

ViewWindow renders the tab window.

func (Model) Width

func (m Model) Width(w int) Model

Width sets the Model width.

func (Model) Wraparound

func (m Model) Wraparound(w bool) Model

Wraparound enables or disables wraparound navigation from the last tab to the first tab and from the first tab back to the last tab.

type Styles

type Styles struct {
	// Inactive tab header
	Tab gloss.Style

	// Active tab header
	ActiveTab gloss.Style

	// Gap between rightmost tab header and right side of screen
	TabSpacer gloss.Style

	// Area to left and right of active tab header title
	TabIndicator gloss.Style

	// Character(s) to left of active tab header title
	TabIndicatorLeft string

	// Character(s) to right of active tab header title
	TabIndicatorRight string

	// Tab content
	TabWindow gloss.Style
}

Styles for tab rendering.

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles provides default tab styles.

type Tab

type Tab struct {
	// contains filtered or unexported fields
}

Tab is the basic model for a single tab.

func NewTab

func NewTab(title string, child tea.Model) Tab

NewTab creates a new tab.

type TabSizeMsg

type TabSizeMsg struct {
	// Width is the tab's total width.
	Width int

	// Height is the tab's total height.
	Height int
}

TabSizeMsg is a message about the dimensions of the tabs.Model. It is used by a Tab to request a resizing of Model and all other Tab windows.

Jump to

Keyboard shortcuts

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