Documentation
¶
Overview ¶
Package filepicker is a modal file and folder picker, or a browser for copying paths, over a file system the app lists, possibly on another machine: places and disks in a sidebar, the browsed folder's entries in an icon or list view, and the folder's address, shown as breadcrumbs and typed into on request. The app loads folders and supplies every label, icon and place, and decides what may be chosen.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dialog ¶
type Dialog struct {
State *State
Open func() bool
OnOpen func(open bool)
// OnClose follows the dialog being gone, once its motion ended.
OnClose func()
Labels Labels
// Device names the machine browsed, leading the breadcrumbs.
Device string
// Hint is a sentence beside the dialog's buttons, such as what the
// chosen folder is for.
Hint string
Sections []Section
// SectionsFunc, when set, gives Sections as they change, which keeps
// the dialog as they load.
SectionsFunc func() []Section
// Files lets files be chosen. Otherwise only folders are: Choose takes
// the selected folder, or the one shown, and files show dimmed.
Files bool
// Icon draws an entry's icon at size; nil draws a folder or file icon.
Icon func(cx *core.Scope, e Entry, size core.Points) core.Node
// FormatTime and FormatSize format an entry's details; nil uses a
// numeric date and decimal units.
FormatTime func(time.Time) string
FormatSize func(int64) string
// Choose receives the chosen path; the dialog closes first. Without it
// the dialog only browses: its header closes it, it has no buttons and
// no entry shows dimmed.
Choose func(path string)
TestID string
}
Dialog shows the picker in a modal dialog while Open. Choosing closes it and calls Choose. With CopyPath labeled, Command-C (Control-C elsewhere) copies the selected entry's path, or the folder's.
type Entry ¶
type Entry struct {
Name, Path string
Dir bool
Size int64
Modified time.Time
// Hidden marks an entry the system hides, shown only on request.
Hidden bool
// Data is the app's own value for the entry, for its Icon.
Data any
}
Entry is a file or folder of a listed folder.
type Folder ¶
Folder is a listed folder. Parent is empty at a root; Trail leads from the root to the folder itself, and without it the address shows the path.
type Labels ¶
type Labels struct {
Title, Address string
Icons, List, Hidden string
Name, Modified, Size string
Empty, Cancel, Choose string
Close, CopyPath string
}
Labels are the picker's texts. Title and Address name the dialog and the address field. Close names a browser's close button; CopyPath, when set, is the menu item copying an entry's or the folder's path.
type State ¶
type State struct {
// Load lists path, the app's starting folder when empty, and calls done
// with the result on the engine.
Load func(path string, done func(Folder, error))
// contains filtered or unexported fields
}
State keeps a picker's folder, selection and view. Make it with NewState.
func NewState ¶
NewState makes a picker's state, showing view with hidden entries as shown and a sidebar width wide, its default when not positive.