Documentation
¶
Index ¶
- Variables
- func NodeNameCountSort(ecs []NodeNameCount)
- type DirFlagMap
- type Filer
- type Node
- func (fn *Node) AddToVCS()
- func (fn *Node) AsFileNode() *Node
- func (t *Node) AsNode() *Node
- func (fn *Node) CanOpen() bool
- func (fn *Node) Cut()
- func (fn *Node) DeleteFile() error
- func (fn *Node) DeleteFiles()
- func (fn *Node) DeleteFilesNoPrompts()
- func (fn *Node) DragDrop(e events.Event)
- func (fn *Node) DropDeleteSource(e events.Event)
- func (fn *Node) FileExtensionCounts(cat fileinfo.Categories) []NodeNameCount
- func (fn *Node) FileRoot() *Tree
- func (fn *Node) FindFile(fnm string) (*Node, bool)
- func (fn *Node) FirstVCS() (vcs.Repo, *Node)
- func (fn *Node) GetFileInfo() error
- func (fn *Node) Init()
- func (fn *Node) InitFileInfo() error
- func (fn *Node) IsDir() bool
- func (fn *Node) IsExec() bool
- func (fn *Node) IsIrregular() bool
- func (fn *Node) LatestFileMod(cat fileinfo.Categories) time.Time
- func (fn *Node) LogVCS(allFiles bool, since string) (vcs.Log, error)
- func (fn *Node) MimeData(md *mimedata.Mimes)
- func (fn *Node) OnClose()
- func (fn *Node) OnOpen()
- func (fn *Node) OpenFile() error
- func (fn *Node) OpenFileDefault() error
- func (fn *Node) OpenFilesDefault()
- func (fn *Node) Paste()
- func (fn *Node) RelativePath() string
- func (fn *Node) RelativePathFrom(fpath core.Filename) string
- func (fn *Node) RenameFile(newpath string) error
- func (fn *Node) RenameFiles()
- func (fn *Node) Repo() (vcs.Repo, *Node)
- func (fn *Node) SelectedFunc(fun func(n *Node))
- func (fn *Node) SelectedPaths() []string
- func (t *Node) SetFileIsOpen(v bool) *Node
- func (fn *Node) UpdateAllVCS()
- func (fn *Node) VCSContextMenu(m *core.Scene)
- type NodeEmbedder
- type NodeNameCount
- type Tree
- func (ft *Tree) AddExternalFile(fpath string) (*Node, error)
- func (ft *Tree) AsFileTree() *Tree
- func (fv *Tree) Destroy()
- func (ft *Tree) Init()
- func (ft *Tree) OpenPath(path string) *Tree
- func (ft *Tree) OpenPathFS(fsys fs.FS, path string) *Tree
- func (ft *Tree) OpenPaths() []string
- func (t *Tree) SetDirsOnTop(v bool) *Tree
- func (t *Tree) SetFS(v fs.FS) *Tree
- func (t *Tree) SetFileNodeType(v *types.Type) *Tree
- func (t *Tree) SetFilterFunc(v func(path string, info fs.FileInfo) bool) *Tree
- func (t *Tree) SetSortByModTime(v bool) *Tree
- func (ft *Tree) UpdatePath(path string)
- type Treer
- type VCSLog
Constants ¶
This section is empty.
Variables ¶
var NodeHighlighting = highlighting.StyleDefault
NodeHighlighting is the default style for syntax highlighting to use for file node buffers
Functions ¶
func NodeNameCountSort ¶
func NodeNameCountSort(ecs []NodeNameCount)
Types ¶
type DirFlagMap ¶
type DirFlagMap struct {
// map of paths and associated flags
Map map[string]dirFlags
// mutex for accessing map
sync.Mutex
}
DirFlagMap is a map for encoding open directories and sorting preferences. The strings are typically relative paths. Map access is protected by Mutex.
type Filer ¶
type Filer interface {
core.Treer
// AsFileNode returns the [Node]
AsFileNode() *Node
// RenameFiles renames any selected files.
RenameFiles()
// DeleteFiles deletes any selected files.
DeleteFiles()
// GetFileInfo updates the .Info for this file
GetFileInfo() error
// OpenFile opens the file for node. This is called by OpenFilesDefault
OpenFile() error
}
Filer is an interface for file tree file actions that all [Node]s satisfy. This allows apps to intervene and apply any additional logic for these actions.
type Node ¶
type Node struct {
core.Tree
// Filepath is the full path to this file.
Filepath core.Filename `edit:"-" set:"-" json:"-" xml:"-" copier:"-"`
// Info is the full standard file info about this file.
Info fileinfo.FileInfo `edit:"-" set:"-" json:"-" xml:"-" copier:"-"`
// FileIsOpen indicates that this file has been opened, indicated by Italics.
FileIsOpen bool
// DirRepo is the version control system repository for this directory,
// only non-nil if this is the highest-level directory in the tree under vcs control.
DirRepo vcs.Repo `edit:"-" set:"-" json:"-" xml:"-" copier:"-"`
}
Node represents a file in the file system, as a core.Tree node. The name of the node is the name of the file. Folders have children containing further nodes.
func AsNode ¶
AsNode returns the given value as a value of type Node if the type of the given value embeds Node, or nil otherwise
func NewNode ¶
NewNode returns a new Node with the given optional parent: Node represents a file in the file system, as a core.Tree node. The name of the node is the name of the file. Folders have children containing further nodes.
func (*Node) AsFileNode ¶
func (*Node) Cut ¶
func (fn *Node) Cut()
Cut copies the selected files to the clipboard and then deletes them.
func (*Node) DeleteFiles ¶
func (fn *Node) DeleteFiles()
DeleteFiles deletes any selected files or directories. If any directory is selected, all files and subdirectories in that directory are also deleted.
func (*Node) DeleteFilesNoPrompts ¶
func (fn *Node) DeleteFilesNoPrompts()
DeleteFilesNoPrompts does the actual deletion, no prompts.
func (*Node) DropDeleteSource ¶
Dragged is called after target accepts the drop -- we just remove elements that were moved satisfies core.DragNDropper interface and can be overridden by subtypes
func (*Node) FileExtensionCounts ¶
func (fn *Node) FileExtensionCounts(cat fileinfo.Categories) []NodeNameCount
FileExtensionCounts returns a count of all the different file extensions, sorted from highest to lowest. If cat is != fileinfo.Unknown then it only uses files of that type (e.g., fileinfo.Code to find any code files)
func (*Node) FindFile ¶
FindFile finds first node representing given file (false if not found) -- looks for full path names that have the given string as their suffix, so you can include as much of the path (including whole thing) as is relevant to disambiguate. See FilesMatching for a list of files that match a given string.
func (*Node) FirstVCS ¶
FirstVCS returns the first VCS repository starting from this node and going down. also returns the node having that repository
func (*Node) GetFileInfo ¶
GetFileInfo is a Filer interface method that can be overwritten to do custom file info.
func (*Node) IsIrregular ¶
IsIrregular returns true if file is a special "Irregular" node
func (*Node) LatestFileMod ¶
func (fn *Node) LatestFileMod(cat fileinfo.Categories) time.Time
LatestFileMod returns the most recent mod time of files in the tree. If cat is != fileinfo.Unknown then it only uses files of that type (e.g., fileinfo.Code to find any code files)
func (*Node) LogVCS ¶
LogVCS shows the VCS log of commits for this file, optionally with a since date qualifier: If since is non-empty, it should be a date-like expression that the VCS will understand, such as 1/1/2020, yesterday, last year, etc. SVN only understands a number as a maximum number of items to return. If allFiles is true, then the log will show revisions for all files, not just this one. Returns the Log and also shows it in a VCSLog which supports further actions.
func (*Node) MimeData ¶
MimeData adds mimedata for this node: a text/plain of the Path, text/plain of filename, and text/
func (*Node) OpenFileDefault ¶
OpenFileDefault opens file with default app for that file type (os defined) runs open on Mac, xdg-open on Linux, and start on Windows
func (*Node) OpenFilesDefault ¶
func (fn *Node) OpenFilesDefault()
OpenFilesDefault opens selected files with default app for that file type (os defined). runs open on Mac, xdg-open on Linux, and start on Windows
func (*Node) RelativePath ¶
RelativePath returns the relative path from root for this node
func (*Node) RelativePathFrom ¶
RelativePathFrom returns the relative path from node for given full path
func (*Node) RenameFile ¶
RenameFile renames file to new name
func (*Node) Repo ¶
Repo returns the version control repository associated with this file, and the node for the directory where the repo is based. Goes up the tree until a repository is found.
func (*Node) SelectedFunc ¶
SelectedFunc runs the given function on all selected nodes in reverse order.
func (*Node) SelectedPaths ¶
SelectedPaths returns the paths of selected nodes.
func (*Node) SetFileIsOpen ¶
SetFileIsOpen sets the [Node.FileIsOpen]: FileIsOpen indicates that this file has been opened, indicated by Italics.
func (*Node) UpdateAllVCS ¶
func (fn *Node) UpdateAllVCS()
UpdateAllVCS does an update on any repositories below this one in file tree
func (*Node) VCSContextMenu ¶
type NodeEmbedder ¶
type NodeEmbedder interface {
AsNode() *Node
}
NodeEmbedder is an interface that all types that embed Node satisfy
type NodeNameCount ¶
NodeNameCount is used to report counts of different string-based things in the file tree
type Tree ¶
type Tree struct {
Node
// Dirs records state of directories within the tree (encoded using paths relative to root),
// e.g., open (have been opened by the user) -- can persist this to restore prior view of a tree
Dirs DirFlagMap `set:"-"`
// DirsOnTop indicates whether all directories are placed at the top of the tree.
// Otherwise everything is mixed. This is the default.
DirsOnTop bool
// SortByModTime causes files to be sorted by modification time by default.
// Otherwise it is a per-directory option.
SortByModTime bool
// FileNodeType is the type of node to create; defaults to [Node] but can use custom node types
FileNodeType *types.Type `display:"-" json:"-" xml:"-"`
// FilterFunc, if set, determines whether to include the given node in the tree.
// return true to include, false to not. This applies to files and directories alike.
FilterFunc func(path string, info fs.FileInfo) bool
// FS is the file system we are browsing, if it is an FS (nil = os filesystem)
FS fs.FS
// contains filtered or unexported fields
}
Tree is the root widget of a file tree representing files in a given directory (and subdirectories thereof), and has some overall management state for how to view things.
func AsTree ¶
AsTree returns the given value as a Tree if it has an AsFileTree() method, or nil otherwise.
func NewTree ¶
NewTree returns a new Tree with the given optional parent: Tree is the root widget of a file tree representing files in a given directory (and subdirectories thereof), and has some overall management state for how to view things.
func (*Tree) AddExternalFile ¶
AddExternalFile adds an external file outside of root of file tree and triggers an update, returning the Node for it, or error if filepath.Abs fails.
func (*Tree) AsFileTree ¶
func (*Tree) OpenPath ¶
OpenPath opens the filetree at the given os file system directory path. It reads all the files at the given path into this tree. Only paths listed in [Tree.Dirs] will be opened.
func (*Tree) OpenPathFS ¶
OpenPathFS opens the filetree at the given fs file system directory path. It reads all the files at the given path into this tree. Only paths listed in [Tree.Dirs] will be opened.
func (*Tree) SetDirsOnTop ¶
SetDirsOnTop sets the [Tree.DirsOnTop]: DirsOnTop indicates whether all directories are placed at the top of the tree. Otherwise everything is mixed. This is the default.
func (*Tree) SetFS ¶
SetFS sets the [Tree.FS]: FS is the file system we are browsing, if it is an FS (nil = os filesystem)
func (*Tree) SetFileNodeType ¶
SetFileNodeType sets the [Tree.FileNodeType]: FileNodeType is the type of node to create; defaults to Node but can use custom node types
func (*Tree) SetFilterFunc ¶
SetFilterFunc sets the [Tree.FilterFunc]: FilterFunc, if set, determines whether to include the given node in the tree. return true to include, false to not. This applies to files and directories alike.
func (*Tree) SetSortByModTime ¶
SetSortByModTime sets the [Tree.SortByModTime]: SortByModTime causes files to be sorted by modification time by default. Otherwise it is a per-directory option.
func (*Tree) UpdatePath ¶
UpdatePath updates the tree at the directory level for given path and everything below it. It flags that it needs render update, but if a deletion or insertion happened, then NeedsLayout should also be called.
type Treer ¶
type Treer interface {
AsFileTree() *Tree
}
Treer is an interface for getting the Root node if it implements Treer.
type VCSLog ¶
type VCSLog struct {
core.Frame
// current log
Log vcs.Log
// file that this is a log of -- if blank then it is entire repository
File string
// date expression for how long ago to include log entries from
Since string
// version control system repository
Repo vcs.Repo `json:"-" xml:"-" copier:"-"`
// contains filtered or unexported fields
}
VCSLog is a widget that represents VCS log data.
func NewVCSLog ¶
NewVCSLog returns a new VCSLog with the given optional parent: VCSLog is a widget that represents VCS log data.
func (*VCSLog) SetFile ¶
SetFile sets the [VCSLog.File]: file that this is a log of -- if blank then it is entire repository