scrollinglist

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package scrollinglist provides a scrollalbe list bubbletea component

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultUnfocusedStyle = lipgloss.NewStyle().
							Border(lipgloss.HiddenBorder(), false, false, false, true).
							PaddingLeft(1).
							Foreground(lipgloss.AdaptiveColor{Light: "#3d473d", Dark: "#C2B8C2"})

	DefaultFocusedStyle = lipgloss.NewStyle().
						Border(lipgloss.HiddenBorder(), false, false, false, true).
						PaddingLeft(1).
						Foreground(lipgloss.Color("#EE6FF8"))

	DefaultFocusedLineStyle = lipgloss.NewStyle().
							Border(lipgloss.ThickBorder(), false, false, false, true).
							BorderForeground(lipgloss.Color("#ff0077")).
							PaddingLeft(1).
							Foreground(lipgloss.Color("#EE6FF8"))

	RightArrowBorder = lipgloss.ThickBorder()

	DefaultFooterStyle = lipgloss.NewStyle().
						Background(lipgloss.AdaptiveColor{Light: "#e2e2e2", Dark: "#1D1D1D"}).
						Foreground(lipgloss.AdaptiveColor{Light: "#984b9e", Dark: "#f7a3fb"})

	DefaultTitleStyle = lipgloss.NewStyle().
						Foreground(lipgloss.AdaptiveColor{Light: "#e2e2e2", Dark: "#1D1D1D"}).
						Background(lipgloss.Color("#ff0077"))
)

Functions

func InitStyles added in v1.0.2

func InitStyles()

func PrefixSumBreak

func PrefixSumBreak(list []int, valueToReach int) (int, int)

Find an index such that 0 to index just (over)fills valueToReach i.e. the appropriate value - 1

func SuffixSumBreak

func SuffixSumBreak(list []int, valueToReach int) (int, int)

Find an index such that index to len(list) just (over)fills valueToReach i.e. the appropriate value + 1

Types

type KeyMap

type KeyMap struct {
	Down key.Binding
	Up   key.Binding

	PageDown key.Binding
	PageUp   key.Binding

	GotoBottom key.Binding
	GotoTop    key.Binding

	Quit key.Binding

	ShowFullHelp  key.Binding
	CloseFullHelp key.Binding
	ShowHideHelp  key.Binding
	ToggleFooter  key.Binding
	ToggleTitle   key.Binding
}

func DefaultKeyMap

func DefaultKeyMap() KeyMap

func (KeyMap) FullHelp added in v1.0.2

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (KeyMap) ShortHelp added in v1.0.2

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

type ScrollingList

type ScrollingList struct {

	// Styles can be customized
	UnfocusedStyle   lipgloss.Style
	FocusedStyle     lipgloss.Style
	FocusedLineStyle lipgloss.Style
	FooterStyle      lipgloss.Style
	TitleStyle       lipgloss.Style

	// Alignment of text within the list
	ListAlignment lipgloss.Position
	// Alignment of the list and footer w.r.t container
	GlobalAlignment lipgloss.Position

	// Footer can be toggled and customized, can be multiline
	ShowFooter   bool
	CustomFooter func() string
	// Title
	Title string
	// Title can be toggled
	ShowTitle bool

	Help help.Model
	// Help can be toggled
	ShowHelp bool

	// The number of lines to keep between focused item and screen edges
	NumLinesFromBorder int

	// Size of the whole list (scroll height is handled automatically based on footer/help)
	Width, Height int

	// KeyMap
	KeyMap KeyMap
	// contains filtered or unexported fields
}

func NewScrollingList

func NewScrollingList() ScrollingList

func (*ScrollingList) FooterView

func (sl *ScrollingList) FooterView() string

returns the rendered footer

func (*ScrollingList) GetCurrentVisibleRange added in v1.0.2

func (sl *ScrollingList) GetCurrentVisibleRange() (int, int)

Returns the currently visible first and last indices

func (*ScrollingList) GetFocused added in v1.0.2

func (sl *ScrollingList) GetFocused() int

Returns the currently focused item id

func (*ScrollingList) GetFocusedLine added in v1.0.7

func (sl *ScrollingList) GetFocusedLine() int

Returns the currently focused line

func (*ScrollingList) GotoBottom

func (sl *ScrollingList) GotoBottom()

Go to last item

func (*ScrollingList) GotoTop

func (sl *ScrollingList) GotoTop()

Go to first item

func (*ScrollingList) HelpView added in v1.0.2

func (sl *ScrollingList) HelpView() string

returns the rendered help

func (ScrollingList) Init

func (sl ScrollingList) Init() tea.Cmd

BubbleTea Init method, does nothing

func (*ScrollingList) Next

func (sl *ScrollingList) Next()

Move 1 item down

func (*ScrollingList) PageDown added in v1.0.2

func (sl *ScrollingList) PageDown()

Move 1 page down

func (*ScrollingList) PageUp added in v1.0.2

func (sl *ScrollingList) PageUp()

Move 1 page up

func (*ScrollingList) Prev

func (sl *ScrollingList) Prev()

Move 1 item up

func (*ScrollingList) SetItemAt added in v1.0.2

func (sl *ScrollingList) SetItemAt(item fmt.Stringer, index int)

Replace one item at index int with given item

func (*ScrollingList) SetItems

func (sl *ScrollingList) SetItems(items []fmt.Stringer)

Replace all items

func (*ScrollingList) SetSize added in v1.0.2

func (sl *ScrollingList) SetSize(width, height int)

Set the width and height for list and set initialized

func (*ScrollingList) TitleView added in v1.0.2

func (sl *ScrollingList) TitleView() string

func (ScrollingList) Update

func (sl ScrollingList) Update(msg tea.Msg) (tea.Model, tea.Cmd)

BubbleTea Update method, handles key presses and window resize

func (ScrollingList) View

func (sl ScrollingList) View() string

BubbleTea View method, returns the actual final rendering result

func (*ScrollingList) VisibleLines

func (sl *ScrollingList) VisibleLines() []string

returns the visible lines, with partial first/last elements s.t. output fits on screen

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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