filetree

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package filetree implements a filetree bubble which can be used to navigate the filesystem and perform actions on files and directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBytesToSizeString

func ConvertBytesToSizeString(size int64) string

ConvertBytesToSizeString converts a byte count to a human readable string.

Types

type Item

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

Item represents a list item.

func (Item) CurrentDirectory

func (i Item) CurrentDirectory() string

CurrentDirectory returns the current directory of the tree.

func (Item) Description

func (i Item) Description() string

Description returns the description of the list item.

func (Item) FileExtension

func (i Item) FileExtension() string

FileExtension returns the extension of the list item.

func (Item) FileName

func (i Item) FileName() string

FileName returns the file name of the list item.

func (Item) FilterValue

func (i Item) FilterValue() string

FilterValue returns the current filter value.

func (Item) IsDirectory

func (i Item) IsDirectory() bool

IsDirectory returns true if the list item is a directory.

func (Item) ShortName

func (i Item) ShortName() string

ShortName returns the short name of the selected item.

func (Item) Title

func (i Item) Title() string

Title returns the title of the list item.

type Model

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

Bubble represents the properties of a filetree.

func New

func New(
	active, borderless bool,
	startDir, selectionPath string,
	borderColor, selectedItemColor, titleBackgroundColor, titleForegroundColor lipgloss.AdaptiveColor,
) Model

New creates a new instance of a filetree.

func (Model) Cursor

func (m Model) Cursor() int

Cursor returns the current position of the cursor in the tree.

func (Model) GetSelectedItem

func (m Model) GetSelectedItem() Item

GetSelectedItem returns the currently selected item in the tree.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the filetree with files from the current directory.

func (Model) IsFiltering

func (m Model) IsFiltering() bool

IsFiltering returns if the tree is currently being filtered.

func (*Model) SetBorderColor

func (m *Model) SetBorderColor(color lipgloss.AdaptiveColor)

SetBorderColor sets the color of the border.

func (*Model) SetBorderless

func (m *Model) SetBorderless(borderless bool)

SetBorderless sets weather or not to show the border.

func (*Model) SetIsActive

func (m *Model) SetIsActive(active bool)

SetIsActive sets if the bubble is currently active.

func (*Model) SetSelectedItemColors

func (m *Model) SetSelectedItemColors(foreground lipgloss.AdaptiveColor)

SetSelectedItemColors sets the foreground of the selected item.

func (*Model) SetSelectionPath

func (m *Model) SetSelectionPath(path string)

SetSelectionPath sets the path in which to write to a file when editing.

func (*Model) SetSize

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

SetSize sets the size of the filetree.

func (*Model) SetStartDir

func (m *Model) SetStartDir(dir string)

SetStartDir sets a starting directory.

func (*Model) SetTitleColors

func (m *Model) SetTitleColors(foreground, background lipgloss.AdaptiveColor)

SetTitleColors sets the background and foreground of the title.

func (*Model) ToggleHelp

func (m *Model) ToggleHelp(showHelp bool)

ToggleHelp sets weather or not to show the help section.

func (*Model) ToggleShowIcons

func (m *Model) ToggleShowIcons(showIcons bool) tea.Cmd

ToggleShowIcons sets weather or not to show icons.

func (Model) TotalItems

func (m Model) TotalItems() int

TotalItems returns the total number of items in the tree.

func (Model) Update

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

Update handles updating the filetree.

func (Model) View

func (m Model) View() string

View returns a string representation of a filetree.

Jump to

Keyboard shortcuts

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