Documentation ¶
Index ¶
- Variables
- func NodeNameCountSort(ecs []NodeNameCount)
- type DirFlagMap
- type Filer
- type FindLocation
- func (i FindLocation) Desc() string
- func (i FindLocation) Int64() int64
- func (i FindLocation) MarshalText() ([]byte, error)
- func (i *FindLocation) SetInt64(in int64)
- func (i *FindLocation) SetString(s string) error
- func (i FindLocation) String() string
- func (i *FindLocation) UnmarshalText(text []byte) error
- func (i FindLocation) Values() []enums.Enum
- 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) DragDrop(e events.Event)
- func (fn *Node) DropDeleteSource(e events.Event)
- func (fn *Node) FileExtensionCounts(cat fileinfo.Categories) []NodeNameCount
- 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) IsNotSaved() 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) OpenBuf() (bool, error)
- 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) UpdateAllVCS()
- func (fn *Node) VCSContextMenu(m *core.Scene)
- type NodeEmbedder
- type NodeNameCount
- type SearchResults
- type Tree
- func (ft *Tree) AddExternalFile(fpath string) (*Node, error)
- 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 (t *Tree) SetDirsOnTop(v bool) *Tree
- func (t *Tree) SetFileNodeType(v *types.Type) *Tree
- func (ft *Tree) UpdatePath(path string)
- 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 // contains filtered or unexported fields }
DirFlagMap is a map for encoding directories that are open in the file tree. The strings are typically relative paths. The bool value is used to mark active paths and inactive (unmarked) ones can be removed. 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() // 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.
type FindLocation ¶ added in v0.2.3
type FindLocation int32 //enums:enum -trim-prefix FindLocation
FindLocation corresponds to the search scope
const ( // FindOpen finds in all open folders in the left file browser FindLocationOpen FindLocation = iota // FindLocationAll finds in all directories under the root path. can be slow for large file trees FindLocationAll // FindLocationFile only finds in the current active file FindLocationFile // FindLocationDir only finds in the directory of the current active file FindLocationDir // FindLocationNotTop finds in all open folders *except* the top-level folder FindLocationNotTop )
const FindLocationN FindLocation = 5
FindLocationN is the highest valid value for type FindLocation, plus one.
func FindLocationValues ¶ added in v0.2.3
func FindLocationValues() []FindLocation
FindLocationValues returns all possible values for the type FindLocation.
func (FindLocation) Desc ¶ added in v0.2.3
func (i FindLocation) Desc() string
Desc returns the description of the FindLocation value.
func (FindLocation) Int64 ¶ added in v0.2.3
func (i FindLocation) Int64() int64
Int64 returns the FindLocation value as an int64.
func (FindLocation) MarshalText ¶ added in v0.2.3
func (i FindLocation) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FindLocation) SetInt64 ¶ added in v0.2.3
func (i *FindLocation) SetInt64(in int64)
SetInt64 sets the FindLocation value from an int64.
func (*FindLocation) SetString ¶ added in v0.2.3
func (i *FindLocation) SetString(s string) error
SetString sets the FindLocation value from its string representation, and returns an error if the string is invalid.
func (FindLocation) String ¶ added in v0.2.3
func (i FindLocation) String() string
String returns the string representation of this FindLocation value.
func (*FindLocation) UnmarshalText ¶ added in v0.2.3
func (i *FindLocation) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FindLocation) Values ¶ added in v0.2.3
func (i FindLocation) Values() []enums.Enum
Values returns all possible values for the type FindLocation.
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:"-"` // Buffer is the file buffer for editing this file. Buffer *texteditor.Buffer `edit:"-" set:"-" json:"-" xml:"-" copier:"-"` // FileRoot is the root [Tree] of the tree, which has global state. FileRoot *Tree `edit:"-" set:"-" json:"-" xml:"-" copier:"-"` // 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:"-"` // contains filtered or unexported fields }
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 ¶ added in v0.2.1
func (*Node) Cut ¶
func (fn *Node) Cut()
Cut copies the selected files to the clipboard and then deletes them.
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 ¶ added in v0.2.3
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 ¶ added in v0.3.3
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) IsNotSaved ¶
IsNotSaved returns true if the file is open and has been changed (edited) since last Save
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) OpenBuf ¶
OpenBuf opens the file in its buffer if it is not already open. returns true if file is newly opened
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 ¶ added in v0.2.3
RelativePath returns the relative path from root for this node
func (*Node) RelativePathFrom ¶ added in v0.2.3
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 ¶ added in v0.2.0
SelectedFunc runs the given function on all selected nodes in reverse order.
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 SearchResults ¶ added in v0.2.0
SearchResults is used to report search results
func Search ¶ added in v0.2.0
func Search(start *Node, find string, ignoreCase, regExp bool, loc FindLocation, activeDir string, langs []fileinfo.Known, openPath func(path string) *Node) []SearchResults
Search returns list of all nodes starting at given node of given language(s) that contain the given string, sorted in descending order by number of occurrences; ignoreCase transforms everything into lowercase
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 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 ¶ added in v0.2.0
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) 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 ¶ added in v0.3.3
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]: if true, then all directories are placed at the top of the tree. Otherwise everything is mixed.
func (*Tree) SetFileNodeType ¶ added in v0.0.10
SetFileNodeType sets the [Tree.FileNodeType]: type of node to create; defaults to Node but can use custom node types
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 VCSLog ¶ added in v0.2.0
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 ¶ added in v0.2.0
NewVCSLog returns a new VCSLog with the given optional parent: VCSLog is a widget that represents VCS log data.
func (*VCSLog) SetFile ¶ added in v0.2.0
SetFile sets the [VCSLog.File]: file that this is a log of -- if blank then it is entire repository