panel

package
v0.0.0-...-692cb10 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(size int64) string

FormatSize returns a human-readable file size.

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns a formatted modification time.

func SortEntries

func SortEntries(entries []fs.DirEntry, mode SortMode)

SortEntries sorts directory entries. Directories always come first.

Types

type DirLoadedMsg

type DirLoadedMsg struct {
	Path    string
	Entries []fs.DirEntry
	Err     error
}

DirLoadedMsg is sent when a directory listing completes.

type ExecuteFileMsg

type ExecuteFileMsg struct {
	Path string
}

ExecuteFileMsg is sent when the user wants to execute a file (Enter on executable file).

type KeyMap

type KeyMap struct {
	Up           key.Binding
	Down         key.Binding
	PageUp       key.Binding
	PageDown     key.Binding
	Home         key.Binding
	End          key.Binding
	GoBack       key.Binding
	ToggleSelect key.Binding
	SelectUp     key.Binding
	SelectDown   key.Binding
	QuickSearch  key.Binding
}

KeyMap defines configurable panel keybindings.

type Model

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

Model represents a single file panel.

func New

func New(filesystem vfs.FS, path string, km KeyMap, cfg config.Config) Model

New creates a new panel browsing the given directory.

func (Model) Active

func (m Model) Active() bool

Active returns whether this panel has focus.

func (Model) ArchiveLabel

func (m Model) ArchiveLabel() string

ArchiveLabel returns a display string for the archive being browsed, or "".

func (*Model) ChangeSortMode

func (m *Model) ChangeSortMode()

ChangeSortMode cycles to the next sort mode and re-sorts.

func (Model) CurrentEntry

func (m Model) CurrentEntry() fs.DirEntry

CurrentEntry returns the entry under the cursor, or nil.

func (Model) CurrentInfo

func (m Model) CurrentInfo() fs.FileInfo

CurrentInfo returns the FileInfo of the entry under the cursor, or nil.

func (Model) CurrentPath

func (m Model) CurrentPath() string

CurrentPath returns the full path of the entry under the cursor. For archive browsing this returns the path within the archive, not a real filesystem path.

func (*Model) HandleDirLoaded

func (m *Model) HandleDirLoaded(msg DirLoadedMsg)

HandleDirLoaded processes a completed directory load.

func (Model) InArchive

func (m Model) InArchive() bool

InArchive returns whether this panel is browsing inside an archive.

func (*Model) LoadDir

func (m *Model) LoadDir() tea.Cmd

LoadDir reads the current directory and populates entries.

func (Model) Path

func (m Model) Path() string

Path returns the current directory path.

func (*Model) RestoreCursor

func (m *Model) RestoreCursor(name string)

RestoreCursor places cursor on the named entry (used after going up).

func (Model) Searching

func (m Model) Searching() (bool, string)

Searching returns whether quick search is active and the current query.

func (Model) SelectedPaths

func (m Model) SelectedPaths() []string

SelectedPaths returns full paths of all tagged files. If none are tagged, returns the current entry.

func (*Model) SetActive

func (m *Model) SetActive(active bool)

SetActive marks this panel as focused/unfocused.

func (*Model) SetPath

func (m *Model) SetPath(path string)

SetPath changes the directory path (call LoadDir after).

func (*Model) SetSize

func (m *Model) SetSize(w, h int)

SetSize sets the panel dimensions.

func (Model) ShowHidden

func (m Model) ShowHidden() bool

ShowHidden returns the current hidden-file visibility state.

func (*Model) ToggleHidden

func (m *Model) ToggleHidden()

ToggleHidden flips whether dotfiles are shown.

func (*Model) Update

func (m *Model) Update(msg tea.KeyMsg) tea.Cmd

Update handles key events for this panel. Only called when the panel is active.

func (Model) View

func (m Model) View(th theme.Theme) string

View renders the panel as a string.

type OpenFileMsg

type OpenFileMsg struct {
	Path string
}

OpenFileMsg is sent when the user wants to open a file (Enter on file).

type PreviewFileMsg

type PreviewFileMsg struct {
	Path string
}

PreviewFileMsg is sent when the user wants to preview a file (Space on file).

type RestoreCursorMsg

type RestoreCursorMsg struct {
	Name string
}

RestoreCursorMsg requests placing the cursor on a named entry after navigation.

type SortMode

type SortMode int

SortMode determines how directory entries are sorted.

const (
	SortByName SortMode = iota
	SortBySize
	SortByTime
	SortByExtension
)

Jump to

Keyboard shortcuts

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