Documentation
¶
Index ¶
- Constants
- Variables
- func Chart(width, height, radius int, totalSize int64, raw []RawChartSector) string
- func EntryIcon(e *structure.Entry) string
- func FmtSize[T numeric](bytesSize T, width int) string
- func NewProgressBar(width int, full, empty rune) progress.Model
- func NewStatusBar(items []*BarItem, totalWidth int) string
- func Overlay(_ int, background, overlay string, row, col int) string
- func OverlayCenter(fullWidth, fullHeight int, background, overlay string) string
- func ReportError(err error, stackTrace []byte) string
- func SetTeaProgram(tp *tea.Program)
- type BarItem
- type Column
- type DeleteChoice
- type DeleteDialogModel
- type DirModel
- type DriveModel
- type EnqueueRefresh
- type EntryDeleted
- type Mode
- type Navigation
- func (n *Navigation) Delete(path string) error
- func (n *Navigation) Down(path string, cursor int, ocl OnChangeLevel) (chan struct{}, chan error)
- func (n *Navigation) DrivesList() *drive.List
- func (n *Navigation) Entry() *structure.Entry
- func (n *Navigation) Explore(path string) error
- func (n *Navigation) OnDrives() bool
- func (n *Navigation) ParentSize() int64
- func (n *Navigation) RefreshDrives()
- func (n *Navigation) RefreshEntry() (chan struct{}, chan error, error)
- func (n *Navigation) Up(ocl OnChangeLevel)
- type OnChangeLevel
- type RawChartSector
- type ScanFinished
- type SortState
- type State
- type UpdateDirState
- type ViewModel
Constants ¶
const ( DefaultBorder = '\ue0b0' DefaultBarBGColor = "#353533" DynamicWidth = -1 )
const Version = "v0.1.3"
Variables ¶
var ( TableHeaderStyle = lipgloss.NewStyle(). Bold(true). BorderStyle(lipgloss.ThickBorder()). BorderForeground(lipgloss.Color("240")). BorderBottom(true) TopHeaderStyle = lipgloss.NewStyle(). Inherit(TableHeaderStyle). BorderTop(true). BorderStyle(lipgloss.NormalBorder()) SelectedRowStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#262626")). Background(lipgloss.Color("#ebbd34")). Bold(false) )
Functions ¶
func Chart ¶ added in v0.1.3
func Chart(width, height, radius int, totalSize int64, raw []RawChartSector) string
func EntryIcon ¶
EntryIcon resolves an emoji icon for the provided Entry instance based on the file extension.
func NewStatusBar ¶
NewStatusBar builds a new status bar based on the provided list of *BarItem instances. The total bar width is defined by the totalWidth parameter and all bar items will be fit in that width according to their parameters or evenly spread for the available width.
NOTE: This implementation does not guarantee that the manually defined element sizes will not exceed the totalWidth value.
func Overlay ¶ added in v0.1.3
Overlay renders the provided overlay string over the background value. The overlay will be rendered starting at the specified row and column. All characters from the background will be properly wrapped accordingly without breaking the ANSI sequences.
func OverlayCenter ¶ added in v0.1.3
func ReportError ¶ added in v0.1.1
ReportError formats an occurred application error and prints the full report to the standard output. The report will contain the error message, the stack trace, and the info on how to report an issue.
func SetTeaProgram ¶
Types ¶
type BarItem ¶
type BarItem struct {
// contains filtered or unexported fields
}
BarItem represents a single status bar item, including its string content, background color, and width. The width parameter is optional, and the default width equals the content width.
The width value -1 denotes that the item will take all available screen width minus the sum of all other elements' widths. If multiple items have a width value of -1, the resulting width will be spread equally between them.
func DefaultBarItem ¶
DefaultBarItem returns a new *BarItem instance with default values for background color and width.
func NewBarItem ¶
NewBarItem returns a new *BarItem instance based on the provided parameters. If the background color is an empty string, a default color will be assigned.
type DeleteChoice ¶ added in v0.1.3
type DeleteChoice int
const ( CancelChoice DeleteChoice = iota ConfirmChoice )
type DeleteDialogModel ¶ added in v0.1.3
type DeleteDialogModel struct {
// contains filtered or unexported fields
}
func NewDeleteDialogModel ¶ added in v0.1.3
func NewDeleteDialogModel(nav *Navigation, targetPath string) *DeleteDialogModel
func (*DeleteDialogModel) Init ¶ added in v0.1.3
func (ddm *DeleteDialogModel) Init() tea.Cmd
func (*DeleteDialogModel) View ¶ added in v0.1.3
func (ddm *DeleteDialogModel) View() string
type DirModel ¶
type DirModel struct {
// contains filtered or unexported fields
}
func NewDirModel ¶
func NewDirModel(nav *Navigation, filters ...filter.EntryFilter) *DirModel
type DriveModel ¶
type DriveModel struct {
// contains filtered or unexported fields
}
func NewDriveModel ¶
func NewDriveModel(n *Navigation) *DriveModel
func (*DriveModel) Init ¶
func (dm *DriveModel) Init() tea.Cmd
func (*DriveModel) View ¶
func (dm *DriveModel) View() string
type EnqueueRefresh ¶ added in v0.1.3
type EnqueueRefresh struct{}
type EntryDeleted ¶ added in v0.1.3
type Navigation ¶
type Navigation struct {
// contains filtered or unexported fields
}
Navigation defines the behavior for traversing the file system tree structure and handles the changes of state. It contains the current active drive/volume, traversing history, and handles the race condition cases.
func NewNavigation ¶
func NewNavigation(t *structure.Tree) *Navigation
func NewRootNavigation ¶ added in v0.1.1
func NewRootNavigation(t *structure.Tree) (*Navigation, error)
NewRootNavigation creates navigation for a predefined root directory entry. It starts the blocking traversal immediately rather than in interactive mode. Therefore, a root with a wide subdirectory structure might cause a delay.
func (*Navigation) Delete ¶ added in v0.1.3
func (n *Navigation) Delete(path string) error
Delete deletes the file or directory, including all internal content, from the file system by the provided base path value. The entry lookup will be done within the current active *Entry instance, limiting the deletion scope.
If the entry was not found in the current active *Entry instance no error will be returned.
TODO: add soft delete
func (*Navigation) Down ¶ added in v0.1.1
func (n *Navigation) Down(path string, cursor int, ocl OnChangeLevel) (chan struct{}, chan error)
Down changes the current tree level down to the provided path. The path value is a directory relative path within the currently active tree node.
It handles two scenarios. The first is changing the level from drives to dirs, and the second is traversing between directories. In the first case, the function will not block execution but instead returns channels for "done" and "errors" that occurred during the drive scan. The client is responsible for listening to the channels and handling the state of scanning. The navigation will be locked until the "done" channel is closed. In the second case, both channels will be returned as nil values, since the scanning is already done.
func (*Navigation) DrivesList ¶
func (n *Navigation) DrivesList() *drive.List
DrivesList returns the list of drives available on the system. Depending on the specific operating system, some volumes may be filtered. Refer to the corresponding drive.List implementation for details.
func (*Navigation) Entry ¶
func (n *Navigation) Entry() *structure.Entry
Entry returns the current active *structure.Entry instance. It never returns an instance of a file, but only a directory.
func (*Navigation) Explore ¶
func (n *Navigation) Explore(path string) error
func (*Navigation) OnDrives ¶ added in v0.1.1
func (n *Navigation) OnDrives() bool
OnDrives checks whether the current navigation state is Drives or not.
func (*Navigation) ParentSize ¶
func (n *Navigation) ParentSize() int64
func (*Navigation) RefreshDrives ¶ added in v0.1.2
func (n *Navigation) RefreshDrives()
RefreshDrives refreshes the list of the available drives and their memory usage data.
func (*Navigation) RefreshEntry ¶ added in v0.1.2
func (n *Navigation) RefreshEntry() (chan struct{}, chan error, error)
RefreshEntry refreshes the current *Entry root by scanning its structure and updating the navigation state. The function will check the case when the current root has been deleted and tries to fall back to the previous *Entry in the stack. If all entries in the stack do not exist anymore, the navigation will fall back to the drives list.
The navigation will be locked until the scanning is complete and the "done" channel is closed.
func (*Navigation) Up ¶ added in v0.1.1
func (n *Navigation) Up(ocl OnChangeLevel)
Up changes the current tree level up to the previous one. It doesn't accept the target level but instead takes it from navigation history. The Up function will change the level only if the current state is Dirs and will do nothing in case of the Drives state.
If the navigation is currently locked, the function will do nothing and return immediately without an error.
type OnChangeLevel ¶ added in v0.1.1
OnChangeLevel defines a custom type for a function being called on changing the current tree level. It accepts the current active entry instance and the navigation's state: Drives or Dirs.
type RawChartSector ¶ added in v0.1.3
type ScanFinished ¶ added in v0.1.1
type ScanFinished struct{}
type State ¶
type State int
State defines a custom type representing the current GUI state. The application's behavior depends on the current state value.
type UpdateDirState ¶ added in v0.1.1
type UpdateDirState struct{}
type ViewModel ¶
type ViewModel struct {
// contains filtered or unexported fields
}
func NewViewModel ¶
func NewViewModel(n *Navigation, driveModel *DriveModel, dirMode *DirModel) *ViewModel