Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultKeyMap = KeyMap{ GoToTop: key.NewBinding(key.WithKeys("g"), key.WithHelp("g", "first")), GoToLast: key.NewBinding(key.WithKeys("G"), key.WithHelp("G", "last")), Down: key.NewBinding(key.WithKeys("j", "down", "ctrl+n"), key.WithHelp("j", "down")), Up: key.NewBinding(key.WithKeys("k", "up", "ctrl+p"), key.WithHelp("k", "up")), PageUp: key.NewBinding(key.WithKeys("K", "pgup"), key.WithHelp("pgup", "page up")), PageDown: key.NewBinding(key.WithKeys("J", "pgdown"), key.WithHelp("pgdown", "page down")), Back: key.NewBinding(key.WithKeys("h", "backspace", "left", "esc"), key.WithHelp("h", "back")), Open: key.NewBinding(key.WithKeys("l", "right", "enter"), key.WithHelp("l", "open")), Select: key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")), }
DefaultKeyMap defines the default keybindings.
View Source
var DefaultStyles = Styles{ DisabledCursor: lipgloss.NewStyle().Foreground(lipgloss.Color("247")), Cursor: lipgloss.NewStyle().Foreground(lipgloss.Color("212")), Symlink: lipgloss.NewStyle().Foreground(lipgloss.Color("36")), Directory: lipgloss.NewStyle().Foreground(lipgloss.Color("99")), File: lipgloss.NewStyle(), DisabledFile: lipgloss.NewStyle().Foreground(lipgloss.Color("243")), DisabledSelected: lipgloss.NewStyle().Foreground(lipgloss.Color("247")), Permission: lipgloss.NewStyle().Foreground(lipgloss.Color("244")), Selected: lipgloss.NewStyle().Foreground(lipgloss.Color("212")).Bold(true), FileSize: lipgloss.NewStyle().Foreground(lipgloss.Color("240")).Width(fileSizeWidth).Align(lipgloss.Right), EmptyDirectory: lipgloss.NewStyle().Foreground(lipgloss.Color("240")).PaddingLeft(paddingLeft).SetString("Bummer. No Files Found."), }
DefaultStyles defines the default styling for the file picker.
Functions ¶
Types ¶
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.
type Model ¶
type Model struct {
// 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
// AllowedTypes specifies which file types the user may select.
// If empty the user may select any file.
AllowedTypes []string
KeyMap KeyMap
ShowHidden bool
DirAllowed bool
FileAllowed bool
FileSelected string
Height int
AutoHeight bool
Cursor string
Styles Styles
// contains filtered or unexported fields
}
Model represents a file picker.
func New ¶
func New() Model
New returns a new filepicker model with default styling and key bindings.
func (Model) DidSelectDisabledFile ¶
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 ¶
DidSelectFile returns whether a user has selected a file (on this msg).
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.
Click to show internal directories.
Click to hide internal directories.