Documentation
¶
Index ¶
- Constants
- func DecodeColorSchema(path string, cs *ColorSchema) error
- func EntryIcon(e *structure.Entry) string
- func FmtSize[T numeric](bytesSize T, width int) string
- func FmtSizeColor[T numeric](bytesSize T, width, fullWidth int) string
- func FmtUsage(usage, threshold float64, fullWidth int) string
- func InitKeyMap(b *config.Bindings, s *Style)
- 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)
- func WrapPath(path string, limit int) string
- func WrapString(data string, limit int) string
- type BarItem
- type BarItemWrapper
- type Chart
- type ChartColors
- type ColorSchema
- type Column
- type DeleteChoice
- type DeleteDialogModel
- type DiffModel
- type DiffScanFinished
- type DirModel
- type DirsKeyMap
- type DirsStatusBarColors
- type DriveKeyMap
- type DriveModel
- type DrivesStatusBarColors
- type EnqueueRefresh
- type EntryDeleted
- type KeyMap
- type Mode
- type Navigation
- func (n *Navigation) Delete(path string) error
- func (n *Navigation) Diff() (*structure.Tree, chan *structure.Diff, chan 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(name 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) SetCursor(cursor int)
- func (n *Navigation) Settings() config.Settings
- func (n *Navigation) Up(ocl OnChangeLevel)
- type OnChangeLevel
- type PG
- type PGOption
- type PopupModel
- func (pm *PopupModel) Hide()
- func (pm *PopupModel) Init() tea.Cmd
- func (pm *PopupModel) MessageQueueSnapshot() []string
- func (pm *PopupModel) Show(message string)
- func (pm *PopupModel) Style() *PopupStyles
- func (pm *PopupModel) Update(_ tea.Msg) (tea.Model, tea.Cmd)
- func (pm *PopupModel) View() string
- func (pm *PopupModel) Visible() bool
- type PopupStyles
- type RefreshDrives
- type ScanFinished
- type SectorInfo
- type SizeUnitColors
- type SortState
- type State
- type StatusBar
- type StatusBarColors
- type Style
- func (s *Style) ActiveButton() *lipgloss.Style
- func (s *Style) BarBlock(bgColor lipgloss.Color) lipgloss.Style
- func (s *Style) BindKey() *lipgloss.Style
- func (s *Style) CS() *ColorSchema
- func (s *Style) ChartBox() *lipgloss.Style
- func (s *Style) ChartColors() []lipgloss.Color
- func (s *Style) ConfirmButton() *lipgloss.Style
- func (s *Style) DialogBox() *lipgloss.Style
- func (s *Style) Help() *lipgloss.Style
- func (s *Style) MarkedRow() *lipgloss.Style
- func (s *Style) SelectedRow() *lipgloss.Style
- func (s *Style) SizeUnit(unit string) *lipgloss.Style
- func (s *Style) StatusBar() *lipgloss.Style
- func (s *Style) TableHeader() *lipgloss.Style
- func (s *Style) TopFiles() *lipgloss.Style
- func (s *Style) TopTableHeader() *lipgloss.Style
- type Tick
- type TopEntries
- type UpdateDiffState
- type UpdateDirState
- type ViewModel
Constants ¶
const ( InfoTitle = "Info" ErrorTitle = "Error" )
const ( DefaultBorder = '\ue0b0' DefaultBarBGColor = "#353533" DynamicWidth = -1 )
const (
Version = "v0.7.0"
)
Variables ¶
This section is empty.
Functions ¶
func DecodeColorSchema ¶ added in v0.4.1
func DecodeColorSchema(path string, cs *ColorSchema) error
DecodeColorSchema reads the color schema from the file by the provided path and applies it to the *ColorSchema instance. An error will be returned if the path is invalid or the JSON color schema content cannot be decoded.
func EntryIcon ¶
EntryIcon resolves an emoji icon for the provided Entry instance based on the file extension.
func FmtSizeColor ¶ added in v0.3.0
func InitKeyMap ¶ added in v0.5.0
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 ¶
func WrapString ¶ added in v0.4.1
WrapString wraps the string up to the provided limit value. If the string reached the limit, it will be appended with the "..." suffix.
Types ¶
type BarItem ¶
type BarItem struct { Content string BGColor string Width int Border rune Wrapper BarItemWrapper }
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 ¶
func NewBarItem(content, bgColor string, width int, biw BarItemWrapper) *BarItem
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 BarItemWrapper ¶ added in v0.4.1
type Chart ¶ added in v0.1.3
type Chart struct {
// contains filtered or unexported fields
}
Chart represents a chart renderer instance. It contains the initial chart settings, including available width and height, the chart radius, and the aspect ratio fix, which is responsible for adjusting the circle form depending on the ratio of the terminal's font width and height.
type ChartColors ¶ added in v0.2.0
type ChartColors struct { Border string `json:"border"` Sector1 string `json:"sector1"` Sector2 string `json:"sector2"` Sector3 string `json:"sector3"` Sector4 string `json:"sector4"` Sector5 string `json:"sector5"` Sector6 string `json:"sector6"` Sector7 string `json:"sector7"` Sector8 string `json:"sector8"` Sector9 string `json:"sector9"` AspectRatioFix float64 `json:"aspectRatioFix"` }
type ColorSchema ¶ added in v0.2.0
type ColorSchema struct { StatusBar StatusBarColors `json:"statusBar"` ChartColors ChartColors `json:"chart"` CellText string `json:"cellText"` TableHeaderBorder string `json:"tableHeaderBorder"` SelectedRowText string `json:"selectedRowText"` SelectedRowBG string `json:"selectedRowBackground"` MarkedRowText string `json:"markedRowText"` MarkedRowBG string `json:"markedRowBackground"` TopFilesText string `json:"topFilesText"` HelpText string `json:"helpText"` BindingText string `json:"bindingText"` DialogBoxBorder string `json:"dialogBoxBorder"` ConfirmButtonText string `json:"confirmButtonText"` ConfirmButtonBG string `json:"confirmButtonBackground"` ActiveButtonText string `json:"activeButtonText"` ActiveButtonBG string `json:"activeButtonBackground"` FilterText string `json:"filterText"` DiffAddedMarker string `json:"diffAddedText"` DiffRemovedMarker string `json:"diffRemovedText"` UsageThresholdText string `json:"usageThresholdText"` SizeUnit SizeUnitColors `json:"sizeUnit"` ScanProgressBar PG `json:"scanProgressBar"` UsageProgressBar PG `json:"usageProgressBar"` StatusBarBorder bool `json:"statusBarBorder"` }
The ColorSchema schema contains color values for most UI elements, such as text and border colors, element backgrounds, etc. The Style component uses the ColorSchema instance during rendering elements. Each color value must be represented as a hex ("#FFBF69") or ANSI ("240") string color code.
DefaultColorSchema always used as a base schema and all customizations are applied over it.
func DefaultColorSchema ¶ added in v0.2.0
func DefaultColorSchema() ColorSchema
func SimpleColorSchema ¶ added in v0.4.1
func SimpleColorSchema() ColorSchema
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, pathMap map[string]int64) *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 DiffModel ¶ added in v0.3.0
type DiffModel struct {
// contains filtered or unexported fields
}
func NewDiffModel ¶ added in v0.3.0
func NewDiffModel(n *Navigation) *DiffModel
type DiffScanFinished ¶ added in v0.3.0
type DiffScanFinished struct{}
type DirModel ¶
type DirModel struct {
// contains filtered or unexported fields
}
func NewDirModel ¶
func NewDirModel(nav *Navigation, filters ...filter.EntryFilter) *DirModel
type DirsKeyMap ¶ added in v0.2.0
type DirsStatusBarColors ¶ added in v0.2.0
type DriveKeyMap ¶ added in v0.5.0
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 DrivesStatusBarColors ¶ added in v0.2.0
type EnqueueRefresh ¶ added in v0.1.3
type EnqueueRefresh struct{ Mode Mode }
type EntryDeleted ¶ added in v0.1.3
type KeyMap ¶ added in v0.5.0
type KeyMap struct { Drive DriveKeyMap Dirs DirsKeyMap Explore key.Binding Quit key.Binding Refresh key.Binding Help key.Binding Config key.Binding // contains filtered or unexported fields }
var (
Bindings KeyMap
)
func DefaultKeyMap ¶ added in v0.5.0
func (*KeyMap) DirBindings ¶ added in v0.5.0
func (*KeyMap) DriveBindings ¶ added in v0.5.0
func (*KeyMap) NavigateBindings ¶ added in v0.5.0
func (*KeyMap) ShortBindings ¶ added in v0.5.0
type Mode ¶
type Mode string
Mode defines a custom type that represents the current view mode. Depending on the current Mode value, the UI behavior can vary.
const ( // PENDING mode represents the locked model state. This state is enabled // while waiting for task completion to prevent UI state changes. PENDING Mode = "PENDING" // READY mode represents the normal model state when there are no pending // tasks or user inputs. READY Mode = "READY" // INPUT mode represents the model state when the application awaits the // user's input. In that state, any key binding will be processed as plain // text. INPUT Mode = "INPUT" // DELETE mode represents the model state when the application awaits the // deletion confirmation. The UI behavior is limited in this mode. DELETE Mode = "DELETE" // DIFF mode represents the model state while showing the file system state // changes from the previous session. The UI behavior is limited in this mode. DIFF Mode = "DIFF" // CMD mode represents the model state when the application awaits for the // internal command.Model to be executed. CMD Mode = "CMD" )
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, s config.Settings) *Navigation
func NewRootNavigation ¶ added in v0.1.1
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(name 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 drive list.
The navigation will be locked until the scanning is complete and the "done" channel is closed.
func (*Navigation) SetCursor ¶ added in v0.2.0
func (n *Navigation) SetCursor(cursor int)
SetCursor preserves the current position of the table's cursor. The cursor position should be updated on each action and used during rendering.
func (*Navigation) Settings ¶ added in v0.4.1
func (n *Navigation) Settings() config.Settings
Settings returns the current application's settings.
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 PG ¶ added in v0.3.0
type PopupModel ¶ added in v0.7.0
type PopupModel struct {
// contains filtered or unexported fields
}
PopupModel is responsible for rendering the pop-up window message. The rendered window will be shown for a period defined during the creation of a new model instance. The messages will be pushed into a limited-size queue and displayed in a sequence, where each message has its visibility duration.
func NewPopupModel ¶ added in v0.7.0
func NewPopupModel(title string, d time.Duration, ps *PopupStyles) *PopupModel
NewPopupModel creates a new *PopupModel instance with the provided title and visibility duration. The *PopupStyles are optional, and if the value is empty, the DefaultPopupStyle will be used.
func (*PopupModel) Hide ¶ added in v0.7.0
func (pm *PopupModel) Hide()
Hide hides the pop-up window and clears the message queue.
func (*PopupModel) Init ¶ added in v0.7.0
func (pm *PopupModel) Init() tea.Cmd
func (*PopupModel) MessageQueueSnapshot ¶ added in v0.7.0
func (pm *PopupModel) MessageQueueSnapshot() []string
func (*PopupModel) Show ¶ added in v0.7.0
func (pm *PopupModel) Show(message string)
Show triggers the pop-up window to be shown with the provided message. If the message queue is already full, then the most recent message will be replaced with the new one.
func (*PopupModel) Style ¶ added in v0.7.0
func (pm *PopupModel) Style() *PopupStyles
Style returns the current pop-up window elements styles.
func (*PopupModel) View ¶ added in v0.7.0
func (pm *PopupModel) View() string
func (*PopupModel) Visible ¶ added in v0.7.0
func (pm *PopupModel) Visible() bool
Visible checks whether the pop-up window is visible and contains any messages in its queue.
type PopupStyles ¶ added in v0.7.0
type PopupStyles struct { // Title contains style settings for the title which is shown at the top of // the pop-up window. Title lipgloss.Style // Message contains the style setting for the pop-up text message. Message lipgloss.Style // Box contains the style setting for the pop-up dialog box including border // settings, background, etc. Box lipgloss.Style }
PopupStyles contains the styles for the pop-up window elements.
func DefaultPopupStyle ¶ added in v0.7.0
func DefaultPopupStyle() *PopupStyles
func PopupDefaultErrorStyle ¶ added in v0.7.0
func PopupDefaultErrorStyle() *PopupStyles
func WithPopupStyle ¶ added in v0.7.0
func WithPopupStyle(title, message, box lipgloss.Style) *PopupStyles
type RefreshDrives ¶ added in v0.4.1
type RefreshDrives struct{}
type ScanFinished ¶ added in v0.1.1
type ScanFinished struct{ Mode Mode }
type SectorInfo ¶ added in v0.4.1
SectorInfo contains the initial sector info. All other data of the sector will be derived during rendering. The color of the sector cannot be set explicitly and will be chosen based on the sector's position.
type SizeUnitColors ¶ added in v0.7.0
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 StatusBar ¶ added in v0.4.1
type StatusBar struct {
// contains filtered or unexported fields
}
func NewStatusBar ¶
func NewStatusBar() *StatusBar
func (*StatusBar) Render ¶ added in v0.4.1
Render 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.
type StatusBarColors ¶ added in v0.2.0
type StatusBarColors struct { Text string `json:"text"` BlockText string `json:"blockText"` BG string `json:"background"` VersionBG string `json:"versionBackground"` Drives DrivesStatusBarColors `json:"drives"` Dirs DirsStatusBarColors `json:"dirs"` }
type Style ¶ added in v0.2.0
type Style struct {
// contains filtered or unexported fields
}
func InitStyle ¶ added in v0.2.0
func InitStyle(cs ColorSchema) *Style
func (*Style) ActiveButton ¶ added in v0.2.0
func (*Style) CS ¶ added in v0.2.0
func (s *Style) CS() *ColorSchema
func (*Style) ChartColors ¶ added in v0.2.0
func (*Style) ConfirmButton ¶ added in v0.2.0
func (*Style) SelectedRow ¶ added in v0.2.0
func (*Style) TableHeader ¶ added in v0.2.0
func (*Style) TopTableHeader ¶ added in v0.2.0
type TopEntries ¶ added in v0.5.0
type TopEntries struct {
// contains filtered or unexported fields
}
func NewTopEntries ¶ added in v0.5.0
func NewTopEntries() *TopEntries
func (*TopEntries) Clear ¶ added in v0.5.0
func (te *TopEntries) Clear()
func (*TopEntries) Init ¶ added in v0.5.0
func (te *TopEntries) Init() tea.Cmd
func (*TopEntries) UpdateTopEntries ¶ added in v0.5.0
func (te *TopEntries) UpdateTopEntries()
func (*TopEntries) View ¶ added in v0.5.0
func (te *TopEntries) View() string
type UpdateDiffState ¶ added in v0.3.0
type UpdateDiffState struct{}
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
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package table is an altered version of the original bubbles package for the table rendering https://github.com/charmbracelet/bubbles/tree/master/table.
|
Package table is an altered version of the original bubbles package for the table rendering https://github.com/charmbracelet/bubbles/tree/master/table. |