Help us shape the future of Go! Take the 2026 Go Developer Survey

filepicker

package
v0.0.0-...-e61c77c Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnterDirMsg

func NewEnterDirMsg(path string) tea.Cmd

Types

type AdvancedKeyMap

type AdvancedKeyMap struct {
	// Navigation
	Up   key.Binding
	Down key.Binding
	Home key.Binding
	End  key.Binding

	// Selection
	Enter          key.Binding
	Space          key.Binding
	SelectAll      key.Binding
	DeselectAll    key.Binding
	SelectAllFiles key.Binding

	// File operations
	Delete  key.Binding
	Copy    key.Binding
	Cut     key.Binding
	Paste   key.Binding
	Rename  key.Binding
	NewFile key.Binding
	NewDir  key.Binding

	// Navigation
	Escape    key.Binding
	Backspace key.Binding
	Refresh   key.Binding
	Back      key.Binding
	Forward   key.Binding

	// Tier 4 features
	TogglePreview key.Binding
	Search        key.Binding
	Glob          key.Binding
	ClearGlob     key.Binding
	ToggleHidden  key.Binding
	ToggleDetail  key.Binding
	CycleSort     key.Binding

	// Directory selection
	SelectCurrentDir   key.Binding
	ToggleDirSelection key.Binding

	// System
	Help key.Binding
	Quit key.Binding
}

AdvancedKeyMap defines the key bindings for the advanced file picker

func DefaultAdvancedKeyMap

func DefaultAdvancedKeyMap() *AdvancedKeyMap

DefaultAdvancedKeyMap returns the default key bindings for the advanced file picker

func (AdvancedKeyMap) FullHelp

func (k AdvancedKeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view

func (AdvancedKeyMap) ShortHelp

func (k AdvancedKeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view

type AdvancedModel

type AdvancedModel struct {
	CurrentPath string

	Styles *AdvancedStyles
	// contains filtered or unexported fields
}

AdvancedModel represents the advanced file picker model

func New

func New(options ...Option) *AdvancedModel

New creates a new file picker with the specified options

func NewAdvancedModel

func NewAdvancedModel(startPath string) *AdvancedModel

NewAdvancedModel creates a new advanced file picker Deprecated: Use New(WithStartPath(startPath)) instead

func (*AdvancedModel) FullHelpForMode

func (fp *AdvancedModel) FullHelpForMode() [][]key.Binding

FullHelpForMode returns keybindings for the expanded help view based on the current mode

func (*AdvancedModel) GetDirectorySelectionMode

func (fp *AdvancedModel) GetDirectorySelectionMode() bool

GetDirectorySelectionMode returns whether directory selection mode is enabled

func (*AdvancedModel) GetError

func (fp *AdvancedModel) GetError() error

GetError returns any error that occurred

func (*AdvancedModel) GetSelected

func (fp *AdvancedModel) GetSelected() ([]string, bool)

GetSelected returns the selected file paths

func (*AdvancedModel) Init

func (fp *AdvancedModel) Init() tea.Cmd

Init initializes the file picker

func (*AdvancedModel) IsDirectorySelectionMode

func (fp *AdvancedModel) IsDirectorySelectionMode() bool

IsDirectorySelectionMode returns whether directory selection mode is enabled

func (*AdvancedModel) SelectedFile

func (fp *AdvancedModel) SelectedFile() string

SelectedFile returns the currently selected files

func (*AdvancedModel) SetDirectorySelectionMode

func (fp *AdvancedModel) SetDirectorySelectionMode(enabled bool)

SetDirectorySelectionMode enables or disables directory selection mode

func (*AdvancedModel) SetShowHidden

func (fp *AdvancedModel) SetShowHidden(show bool)

SetShowHidden sets whether to show hidden files

func (*AdvancedModel) SetShowPreview

func (fp *AdvancedModel) SetShowPreview(show bool)

SetShowPreview sets whether to show file preview

func (*AdvancedModel) SetSize

func (fp *AdvancedModel) SetSize(width, height int)

SetSize sets the width and height of the file picker

func (*AdvancedModel) Update

func (fp *AdvancedModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for Tier 4

func (*AdvancedModel) View

func (fp *AdvancedModel) View() string

View renders the advanced file picker (Tier 4)

type AdvancedStyles

type AdvancedStyles struct {
	BorderStyle        lipgloss.Style
	TitleStyle         lipgloss.Style
	PathStyle          lipgloss.Style
	SelectedStyle      lipgloss.Style
	MultiSelectedStyle lipgloss.Style
	NormalStyle        lipgloss.Style
	DirStyle           lipgloss.Style
	DirSelectionStyle  lipgloss.Style
	HiddenStyle        lipgloss.Style
	StatusStyle        lipgloss.Style
	PreviewTitleStyle  lipgloss.Style
	SearchStyle        lipgloss.Style
	ConfirmStyle       lipgloss.Style
	ErrorStyle         lipgloss.Style
}

AdvancedStyles defines the styles

func DefaultAdvancedStyles

func DefaultAdvancedStyles() *AdvancedStyles

DefaultAdvancedStyles returns the default styles

type CancelFilePickerMsg

type CancelFilePickerMsg struct{}

type CompatFilepicker

type CompatFilepicker struct {
	DirAllowed       bool
	FileAllowed      bool
	CurrentDirectory string
	Height           int
	// contains filtered or unexported fields
}

CompatFilepicker provides compatibility with the old bubbles filepicker interface

type EnterDirMsg

type EnterDirMsg struct {
	Path string
}

EnterDirMsg sends a msg to enter a directory

type File

type File struct {
	Name     string
	Path     string
	IsDir    bool
	Size     int64
	ModTime  time.Time
	Mode     os.FileMode
	Selected bool
	Hidden   bool
}

File represents a file or directory with extended metadata

type Model

type Model struct {
	*AdvancedModel

	// Compatibility fields
	Title        string
	Error        string
	Filepicker   CompatFilepicker
	SelectedPath string
	// contains filtered or unexported fields
}

Model provides backward compatibility with the original bobatea filepicker API

func NewModel

func NewModel() Model

NewModel creates a new file picker with backward compatibility This maintains the original bobatea API while using the advanced implementation

func NewModelWithOptions

func NewModelWithOptions(options ...Option) Model

NewModelWithOptions creates a new file picker with backward compatibility using options

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the compatibility wrapper

func (Model) Update

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

Update handles updates for the compatibility wrapper

func (Model) View

func (m Model) View() string

View renders the compatibility wrapper

type Operation

type Operation int

Operation represents file operations

const (
	OpNone Operation = iota
	OpCopy
	OpCut
)

type Option

type Option func(*AdvancedModel)

Option represents a configuration option for the file picker

func WithCompatibilityMode

func WithCompatibilityMode(compat bool) Option

WithCompatibilityMode enables compatibility mode (no additional effect currently)

func WithDetailedView

func WithDetailedView(detailed bool) Option

WithDetailedView sets whether to show detailed file information

func WithDirectorySelection

func WithDirectorySelection(enabled bool) Option

WithDirectorySelection enables or disables directory selection mode

func WithGlobPattern

func WithGlobPattern(pattern string) Option

WithGlobPattern sets the initial glob pattern filter

func WithJailDirectory

func WithJailDirectory(path string) Option

WithJailDirectory sets a directory restriction boundary - navigation will be limited to this directory and subdirectories

func WithKeyMap

func WithKeyMap(keys *AdvancedKeyMap) Option

WithKeyMap sets the key map for the filepicker

func WithMaxHistorySize

func WithMaxHistorySize(size int) Option

WithMaxHistorySize sets the maximum number of history entries

func WithPreviewWidth

func WithPreviewWidth(width int) Option

WithPreviewWidth sets the width of the preview panel

func WithShowHidden

func WithShowHidden(show bool) Option

WithShowHidden sets whether to show hidden files

func WithShowIcons

func WithShowIcons(show bool) Option

WithShowIcons sets whether to show file icons

func WithShowPreview

func WithShowPreview(show bool) Option

WithShowPreview sets whether to show file preview

func WithShowSizes

func WithShowSizes(show bool) Option

WithShowSizes sets whether to show file sizes

func WithSortMode

func WithSortMode(mode SortMode) Option

WithSortMode sets the initial sort mode

func WithStartPath

func WithStartPath(path string) Option

WithStartPath sets the starting directory path

func WithStyles

func WithStyles(styles *AdvancedStyles) Option

WithStyles sets the key map for the filepicker

type SelectFileMsg

type SelectFileMsg struct {
	Path string
}

Messages for compatibility with existing bobatea filepicker API

type SortMode

type SortMode int

SortMode represents different sorting options

const (
	SortByName SortMode = iota
	SortBySize
	SortByDate
	SortByType
)

type ViewState

type ViewState int

ViewState represents the current state of the file picker

const (
	ViewStateNormal ViewState = iota
	ViewStateConfirmDelete
	ViewStateRename
	ViewStateCreateFile
	ViewStateCreateDir
	ViewStateSearch
	ViewStateGlob
)

Jump to

Keyboard shortcuts

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