filepicker

package
v0.26.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package filepicker provides a file picker component for Bubble Tea applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilteredFS

type FilteredFS interface {
	Close() error
	Name() string
	Open(name string) (*os.File, error)
	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
	Stat(name string) (fs.FileInfo, error)
	ReadDir(name string) ([]os.DirEntry, error)
}

type KeyMap

type KeyMap struct {
	GoToTop  key.Binding
	GoToLast key.Binding
	Down     key.Binding
	Up       key.Binding
	PageUp   key.Binding
	PageDown key.Binding
	Back     key.Binding
	Open     key.Binding
	Select   key.Binding
}

KeyMap defines key bindings for each user action.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap defines the default keybindings.

type Model

type Model struct {
	Styles Styles

	FileSelected string

	// Path is the path which the user has selected with the file picker.
	Path string

	// CurrentDirectory is the directory that the user is currently in.
	CurrentDirectory string

	Cursor string
	KeyMap KeyMap

	// AllowedTypes specifies which file types the user may select.
	// If empty the user may select any file.
	AllowedTypes []string

	// Height of the picker.
	//
	// Deprecated: use [Model.SetHeight] instead.
	Height int

	ShowSize        bool
	DirAllowed      bool
	ShowPermissions bool
	ShowHidden      bool
	AutoHeight      bool
	FileAllowed     bool
	// contains filtered or unexported fields
}

Model represents a file picker.

func New

func New(fsys FilteredFS) Model

New returns a new filepicker model with default styling and key bindings.

func (Model) DidSelectDisabledFile

func (m Model) DidSelectDisabledFile(msg tea.Msg) (bool, string)

DidSelectDisabledFile returns whether a user tried to select a disabled file (on this msg). This is necessary only if you would like to warn the user that they tried to select a disabled file.

func (Model) DidSelectFile

func (m Model) DidSelectFile(msg tea.Msg) (bool, string)

DidSelectFile returns whether a user has selected a file (on this msg).

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the file picker model.

func (*Model) SetHeight

func (m *Model) SetHeight(height int)

SetHeight sets the height of the filepicker.

func (Model) Update

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

Update handles user interactions within the file picker model.

func (Model) View

func (m Model) View() string

View returns the view of the file picker.

type Styles

type Styles struct {
	DisabledCursor   lipgloss.Style
	Cursor           lipgloss.Style
	Symlink          lipgloss.Style
	Directory        lipgloss.Style
	File             lipgloss.Style
	DisabledFile     lipgloss.Style
	Permission       lipgloss.Style
	Selected         lipgloss.Style
	DisabledSelected lipgloss.Style
	FileSize         lipgloss.Style
	EmptyDirectory   lipgloss.Style
}

Styles defines the possible customizations for styles in the file picker.

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles defines the default styling for the file picker.

func DefaultStylesWithRenderer

func DefaultStylesWithRenderer(r *lipgloss.Renderer) Styles

DefaultStylesWithRenderer defines the default styling for the file picker, with a given Lip Gloss renderer.

Jump to

Keyboard shortcuts

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