multiSelect

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package multiSelect provides functions that help define and draw a multi-select step

Index

Constants

This section is empty.

Variables

View Source
var (
	Directory = lipgloss.NewStyle().Foreground(lipgloss.Color("99"))
	File      = lipgloss.NewStyle()
)

Functions

func FetchAllFolders

func FetchAllFolders(model *Model) tea.Cmd

func FetchRepoFiles

func FetchRepoFiles(url string, fetch *Fetch) ([]api.TreeElement, error)

Types

type ContentTree

type ContentTree struct {
	Tree         map[string]*Node
	CurPath      string
	RootPath     string
	SelectedRepo map[string][]api.TreeElement
	FolderRepo   []api.TreeElement
	Mu           sync.Mutex
}

TODO: Rename the FolderRepo to SelectedFolders and SelectedRepo to SelectedFiles

func (*ContentTree) AppendSelected

func (c *ContentTree) AppendSelected()

AppendSelected compiles all selected repositories from the ContentTree's Tree map into the SelectedRepo slice. It filters and returns a slice of repositories with type "dir".

Returns: - []api.Repo: Slice of "dir" type selected repositories.

func (*ContentTree) RemoveAllCurTreeRepo

func (c *ContentTree) RemoveAllCurTreeRepo()

RemoveAllCurTreeRepo deselects (removes) all selected repositories at the current path within the tree.

func (*ContentTree) SelectAllCurTreeRepo

func (c *ContentTree) SelectAllCurTreeRepo()

SelectAllCurTreeRepo selects all repositories at the current path within the tree.

func (*ContentTree) SelectedRepoLen

func (c *ContentTree) SelectedRepoLen() int

func (*ContentTree) UpdateTreesSelected

func (c *ContentTree) UpdateTreesSelected(index int)

UpdateTreesSelected updates the selection status of a repository at the current path (CurPath) identified by index.

type Fetch

type Fetch struct {
	Err       error
	Clint     *api.Clint
	FetchMess string
	Repo      []api.TreeElement
	FethDone  bool
}

type Model

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

func InitialModelMultiSelect

func InitialModelMultiSelect(clintFetch *Fetch, conTree *ContentTree, header string, quit *bool) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

TODO: Check if code could be reduce.

func (Model) View

func (m Model) View() string

View is called to draw the multiSelect step

type Node

type Node struct {
	SelectedRepo map[int]struct{}
	Repo         []api.TreeElement
}

func (*Node) RemoveAllRepo

func (n *Node) RemoveAllRepo()

RemoveAllRepo deselects (removes) all selected repositories within this node.

func (*Node) SelecteAllRepo

func (n *Node) SelecteAllRepo()

SelecteAllRepo selects all repositories within this node. It does so by adding all indices to SelectedRepo if the number of repositories is greater than the number of selected repositories.

func (*Node) UpdateSelectedRepo

func (n *Node) UpdateSelectedRepo(key int)

UpdateSelectedRepo toggles the selection status of a repository identified by key. If the repository is already selected, it is deselected (removed from SelectedRepo); if it is not selected, it is added

Jump to

Keyboard shortcuts

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