Documentation
¶
Overview ¶
Package scrollinglist provides a scrollalbe list bubbletea component
Index ¶
- Variables
- func InitStyles()
- func PrefixSumBreak(list []int, valueToReach int) (int, int)
- func SuffixSumBreak(list []int, valueToReach int) (int, int)
- type KeyMap
- type ScrollingList
- func (sl *ScrollingList) DeleteItemAt(index int)
- func (sl *ScrollingList) FooterView() string
- func (sl *ScrollingList) GetCurrentVisibleRange() (int, int)
- func (sl *ScrollingList) GetFocused() int
- func (sl *ScrollingList) GetFocusedLine() int
- func (sl *ScrollingList) GetItemAtLine(index int) string
- func (sl *ScrollingList) GetStatus() string
- func (sl *ScrollingList) GotoBottom()
- func (sl *ScrollingList) GotoTop()
- func (sl *ScrollingList) HelpView() string
- func (sl ScrollingList) Init() tea.Cmd
- func (sl *ScrollingList) Next()
- func (sl *ScrollingList) PageDown()
- func (sl *ScrollingList) PageUp()
- func (sl *ScrollingList) Prev()
- func (sl *ScrollingList) SetItemAt(item fmt.Stringer, index int)
- func (sl *ScrollingList) SetItems(items []fmt.Stringer)
- func (sl *ScrollingList) SetSize(width, height int)
- func (sl *ScrollingList) TitleView() string
- func (sl ScrollingList) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (sl ScrollingList) View() string
- func (sl *ScrollingList) VisibleLines() []string
Constants ¶
This section is empty.
Variables ¶
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() 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")) DefaultEditingStyle = lipgloss.NewStyle(). AlignHorizontal(lipgloss.Center). Background(lipgloss.AdaptiveColor{Light: "#e2e2e2", Dark: "#1D1D1D"}) )
Functions ¶
func InitStyles ¶ added in v1.0.2
func InitStyles()
func PrefixSumBreak ¶
Find an index such that 0 to index just (over)fills valueToReach i.e. the appropriate value - 1
Types ¶
type KeyMap ¶
type KeyMap struct {
// ! also change the GetAllKeys function when making changes here
Down key.Binding
Up key.Binding
PageDown key.Binding
PageUp key.Binding
GotoBottom key.Binding
GotoTop key.Binding
Quit key.Binding
Edit key.Binding
CancelEdit key.Binding
ShowFullHelp key.Binding
CloseFullHelp key.Binding
ShowHideHelp key.Binding
ToggleTitle key.Binding
}
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
func (KeyMap) GetAllKeys ¶ added in v1.0.16
type ScrollingList ¶
type ScrollingList struct {
// read-only or allow edits/add/deletes
Editable bool
// Styles can be customized
UnfocusedStyle lipgloss.Style
FocusedStyle lipgloss.Style
FocusedLineStyle 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
// Vertical alignment of main text when not enough lines to fill screen, defaults to Top
MainVerticalAlignment lipgloss.Position
// Footer can be toggled and customized, can be multiline
// 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) DeleteItemAt ¶ added in v1.0.10
func (sl *ScrollingList) DeleteItemAt(index int)
Delete one item at index int
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) GetItemAtLine ¶ added in v1.0.15
func (sl *ScrollingList) GetItemAtLine(index int) string
Returns the string at given line
func (*ScrollingList) GetStatus ¶ added in v1.0.12
func (sl *ScrollingList) GetStatus() string
Returns the current status
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) PageDown ¶ added in v1.0.2
func (sl *ScrollingList) PageDown()
Move 1 page down
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) 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