filepicker

package module
v0.0.0-...-2741f69 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 10 Imported by: 1

README

filepicker-bubble

This is a fork of the filepicker bubble by Charm created to add the selection of multiple files for use in goscope.

License

This repository is licensed under the MIT License; please see LICENSE. The original filepicker bubble is also licensed under the MIT License (© 2020-2023 Charmbracelet, Inc); for more information, please see LICENSE-bubbles.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHidden

func IsHidden(file string) (bool, error)

IsHidden reports whether a file is hidden or not.

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.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap defines the default keybindings.

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

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) GetChosenFiles

func (m Model) GetChosenFiles() []string

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the file picker model.

func (*Model) ResetChosenFiles

func (m *Model) ResetChosenFiles()

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
	Chosen           lipgloss.Style
	SelectedChosen   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