list

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SectionDocuments = iota
	SectionFilter
)

Variables

This section is empty.

Functions

func FilterYAMLs

func FilterYAMLs(m ListModel) tea.Cmd

func LoadYAML

func LoadYAML(md *yamls.Document) tea.Cmd

Types

type Config

type Config struct {
	CommonModel *common.CommonModel
	KeyBinds    *KeyBinds
	Compact     bool
}

type DocumentList added in v0.18.0

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

DocumentList handles rendering of document lists.

func NewDocumentList added in v0.18.0

func NewDocumentList(t *theme.Theme, indent int, compact bool) *DocumentList

NewDocumentList creates a new document list.

func (*DocumentList) GetItemHeight added in v0.18.0

func (dlr *DocumentList) GetItemHeight() int

func (*DocumentList) Render added in v0.18.0

func (dlr *DocumentList) Render(params DocumentListConfig) string

Render renders a list of documents with pagination and empty states.

type DocumentListConfig added in v0.18.0

type DocumentListConfig struct {
	Paginator   Paginator
	FilterValue string
	Documents   []*yamls.Document
	Cursor      int
	Width       int
	FilterState FilterState
	SectionKey  SectionKey
	IsLoaded    bool
}

DocumentListConfig contains all parameters needed to render a document list.

type DocumentListItem added in v0.18.0

type DocumentListItem struct {
	Document          *yamls.Document
	Theme             *theme.Theme
	FilterValue       string
	Index             int
	Width             int
	MaxGroupWidth     int // Maximum width of the group across all items.
	MaxKindWidth      int // Maximum width of the kind across all items.
	MaxNameWidth      int // Maximum width of the name across all items.
	Cursor            int
	FilterState       FilterState
	VisibleYAMLsCount int
	IsFilterSelected  bool
	Compact           bool
}

DocumentListItem represents a single item in the list with its data and rendering capabilities.

func (*DocumentListItem) Render added in v0.18.0

func (li *DocumentListItem) Render(b *strings.Builder)

Render renders the list item to the provided string builder.

type FetchedYAMLMsg

type FetchedYAMLMsg *yamls.Document

type FilterState

type FilterState int

FilterState is the current filtering state in the file listing.

const (
	Unfiltered    FilterState = iota // No filter set.
	Filtering                        // User is actively setting a filter.
	FilterApplied                    // A filter is applied and user is not editing filter.
)

type FilteredYAMLMsg

type FilteredYAMLMsg []*yamls.Document

type KeyBinds

type KeyBinds struct {
	Open     *keys.KeyBind `json:"open,omitempty"`
	Find     *keys.KeyBind `json:"find,omitempty"`
	Home     *keys.KeyBind `json:"home,omitempty"`
	End      *keys.KeyBind `json:"end,omitempty"`
	PageUp   *keys.KeyBind `json:"pageUp,omitempty"`
	PageDown *keys.KeyBind `json:"pageDown,omitempty"`
}

func (*KeyBinds) EnsureDefaults

func (kb *KeyBinds) EnsureDefaults()

func (*KeyBinds) GetKeyBinds

func (kb *KeyBinds) GetKeyBinds() []keys.KeyBind

type KeyHandler

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

KeyHandler provides key handling for list view.

func NewKeyHandler

func NewKeyHandler(kb *KeyBinds, ckb *common.KeyBinds, t *theme.Theme) *KeyHandler

NewKeyHandler creates a new ListKeyHandler.

func (*KeyHandler) HandleDocumentBrowsing

func (h *KeyHandler) HandleDocumentBrowsing(m ListModel, msg tea.KeyMsg) (ListModel, tea.Cmd)

HandleDocumentBrowsing handles key events for document browsing in list view.

func (*KeyHandler) HandleFilteringMode

func (h *KeyHandler) HandleFilteringMode(m ListModel, msg tea.Msg) (ListModel, tea.Cmd)

HandleFilteringMode handles events when in filtering mode.

type ListModel

type ListModel struct {

	// The master set of yaml documents we're working with.
	YAMLs []*yamls.Document

	ViewState ViewState

	FilterState FilterState

	ShowHelp bool
	// contains filtered or unexported fields
}

func NewModel

func NewModel(c Config) ListModel

func (*ListModel) AddYAMLs

func (m *ListModel) AddYAMLs(yaml ...*yamls.Document)

Adds yaml documents to the model.

func (*ListModel) ClearText added in v0.24.1

func (m *ListModel) ClearText() tea.Cmd

ClearText clears all text from the filter input.

func (ListModel) FilterApplied

func (m ListModel) FilterApplied() bool

func (ListModel) GetSelectedYAML added in v0.24.1

func (m ListModel) GetSelectedYAML() *yamls.Document

GetSelectedYAML returns the current selected yaml in the list.

func (*ListModel) GoToEnd added in v0.24.1

func (m *ListModel) GoToEnd()

GoToEnd goes to the last page and last item.

func (*ListModel) GoToStart added in v0.24.1

func (m *ListModel) GoToStart()

GoToStart goes to the first page and first item.

func (ListModel) IsLoading

func (m ListModel) IsLoading() bool

Whether or not the spinner should be spinning.

func (*ListModel) MoveCursorDown added in v0.24.1

func (m *ListModel) MoveCursorDown()

MoveCursorDown moves the cursor down in the list.

func (*ListModel) MoveCursorUp added in v0.24.1

func (m *ListModel) MoveCursorUp()

MoveCursorUp moves the cursor up in the list.

func (*ListModel) MoveNextPage added in v0.24.1

func (m *ListModel) MoveNextPage()

MoveNextPage moves to the next page.

func (*ListModel) MovePrevPage added in v0.24.1

func (m *ListModel) MovePrevPage()

MovePrevPage moves to the previous page.

func (*ListModel) OpenYAML added in v0.24.1

func (m *ListModel) OpenYAML(md *yamls.Document) tea.Cmd

OpenYAML opens a yaml document in the pager. Note that this also alters the model.

func (*ListModel) ResetFiltering

func (m *ListModel) ResetFiltering()

func (*ListModel) SetCursorToBottom added in v0.24.1

func (m *ListModel) SetCursorToBottom()

SetCursorToBottom sets the cursor to the bottom of the current page.

func (*ListModel) SetCursorToTop added in v0.24.1

func (m *ListModel) SetCursorToTop()

SetCursorToTop sets the cursor to the top of the current page.

func (*ListModel) SetFilterText added in v0.24.1

func (m *ListModel) SetFilterText(text string) tea.Cmd

SetFilterText sets the filter text and updates the filter.

func (*ListModel) SetHelpVisible added in v0.24.1

func (m *ListModel) SetHelpVisible(visible bool)

SetHelpVisible sets help visibility.

func (*ListModel) SetSize

func (m *ListModel) SetSize(width, height int)

func (*ListModel) StartFiltering added in v0.24.1

func (m *ListModel) StartFiltering() tea.Cmd

StartFiltering initializes the filtering mode.

func (*ListModel) ToggleHelp added in v0.24.1

func (m *ListModel) ToggleHelp()

func (ListModel) Update

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

func (ListModel) View

func (m ListModel) View() string

type PaginationRenderer

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

PaginationRenderer handles pagination display.

func NewPaginationRenderer

func NewPaginationRenderer(t *theme.Theme, width int) *PaginationRenderer

NewPaginationRenderer creates a new pagination renderer.

func (*PaginationRenderer) RenderPagination

func (pr *PaginationRenderer) RenderPagination(paginatorModel *paginator.Model, totalPages int) string

RenderPagination renders pagination controls.

type Paginator added in v0.18.0

type Paginator interface {
	GetSliceBounds(total int) (start, end int)
}

Paginator represents the pagination interface needed for document rendering.

type Section

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

Section contains definitions and state information for displaying a tab and its contents in the file listing view.

type SectionKey

type SectionKey int

The types of documents we are currently showing to the user.

type ViewState

type ViewState int

ViewState is the high-level state of the file listing.

const (
	StateReady ViewState = iota
)

Jump to

Keyboard shortcuts

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