filetree

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: BSD-3-Clause Imports: 41 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ExternalFilesName is the name of the node that represents external files
	ExternalFilesName = "[external files]"
)

Variables

View Source
var NodeHiStyle = histyle.StyleDefault

NodeHiStyle is the default style for syntax highlighting to use for file node buffers

View Source
var VersionControlSystems = []string{"git", "svn", "bzr", "hg"}

VersionControlSystems is a list of supported Version Control Systems. These must match the VCS Types from vcs which in turn is based on masterminds/vcs

Functions

func BlameDialog

func BlameDialog(ctx core.Widget, fname string, blame, fbytes []byte) *texteditor.TwinEditors

BlameDialog opens a dialog for displaying VCS blame data using textview.TwinViews. blame is the annotated blame code, while fbytes is the original file contents.

func FileAtRevDialog

func FileAtRevDialog(ctx core.Widget, repo vcs.Repo, file, rev string) *core.Body

FileAtRevDialog Shows a file at a given revision in a new dialog window

func IsVersionControlSystem added in v0.0.8

func IsVersionControlSystem(str string) bool

IsVersionControlSystem returns true if the given string matches one of the standard VersionControlSystems -- uses lowercase version of str.

func NodeNameCountSort

func NodeNameCountSort(ecs []NodeNameCount)

func VCSLabelFunc

func VCSLabelFunc(fn *Node, label string) string

VCSLabelFunc gets the appropriate label for removing from version control

func VCSLogDialog added in v0.2.0

func VCSLogDialog(ctx core.Widget, repo vcs.Repo, lg vcs.Log, file, since string) *core.Body

VCSLogDialog returns a VCS Log View for given repo, log and file (file could be empty)

Types

type DirFlagMap

type DirFlagMap struct {

	// map of paths and associated flags
	Map map[string]DirFlags

	// mutex for accessing map
	Mu sync.Mutex `display:"-" json:"-" xml:"-" toml:"-"`
}

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.

func (*DirFlagMap) Init

func (dm *DirFlagMap) Init()

Init initializes the map, and sets the Mutex lock -- must unlock manually

func (*DirFlagMap) IsOpen

func (dm *DirFlagMap) IsOpen(path string) bool

IsOpen returns true if path has IsOpen bit flag set

func (*DirFlagMap) SetOpen

func (dm *DirFlagMap) SetOpen(path string, open bool)

SetOpenState sets the given directory's open flag

func (*DirFlagMap) SetSortBy

func (dm *DirFlagMap) SetSortBy(path string, modTime bool)

SetSortBy sets the given directory's sort by option

func (*DirFlagMap) SortByModTime

func (dm *DirFlagMap) SortByModTime(path string) bool

SortByModTime returns true if path is sorted by mod time

func (*DirFlagMap) SortByName

func (dm *DirFlagMap) SortByName(path string) bool

SortByName returns true if path is sorted by name (default if not in map)

type DirFlags

type DirFlags int64 //enums:bitflag -trim-prefix Dir

DirFlags are flags on directories: Open, SortBy, etc. These flags are stored in the DirFlagMap for persistence. This map is saved to a file, so these flags must be stored as bit flags instead of a struct to ensure efficient serialization.

const (
	// DirIsOpen means directory is open -- else closed
	DirIsOpen DirFlags = iota

	// DirSortByName means sort the directory entries by name.
	// this is mutex with other sorts -- keeping option open for non-binary sort choices.
	DirSortByName

	// DirSortByModTime means sort the directory entries by modification time
	DirSortByModTime
)
const DirFlagsN DirFlags = 3

DirFlagsN is the highest valid value for type DirFlags, plus one.

func DirFlagsValues

func DirFlagsValues() []DirFlags

DirFlagsValues returns all possible values for the type DirFlags.

func (DirFlags) BitIndexString

func (i DirFlags) BitIndexString() string

BitIndexString returns the string representation of this DirFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (DirFlags) Desc

func (i DirFlags) Desc() string

Desc returns the description of the DirFlags value.

func (DirFlags) HasFlag

func (i DirFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (DirFlags) Int64

func (i DirFlags) Int64() int64

Int64 returns the DirFlags value as an int64.

func (DirFlags) MarshalText

func (i DirFlags) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*DirFlags) SetFlag

func (i *DirFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*DirFlags) SetInt64

func (i *DirFlags) SetInt64(in int64)

SetInt64 sets the DirFlags value from an int64.

func (*DirFlags) SetString

func (i *DirFlags) SetString(s string) error

SetString sets the DirFlags value from its string representation, and returns an error if the string is invalid.

func (*DirFlags) SetStringOr

func (i *DirFlags) SetStringOr(s string) error

SetStringOr sets the DirFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (DirFlags) String

func (i DirFlags) String() string

String returns the string representation of this DirFlags value.

func (*DirFlags) UnmarshalText

func (i *DirFlags) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (DirFlags) Values

func (i DirFlags) Values() []enums.Enum

Values returns all possible values for the type DirFlags.

type Filer

type Filer interface {
	core.Treer

	// AsFileNode returns the filetree.Node
	AsFileNode() *Node

	// OpenFilesDefault opens selected files with default app for that file type (os defined).
	// It runs open on Mac, xdg-open on Linux, and start on Windows.
	OpenFilesDefault()

	// OpenFileDefault opens file with default app for that file type (os defined)
	// It runs open on Mac, xdg-open on Linux, and start on Windows.
	OpenFileDefault() error

	// OpenFilesWith opens selected files with user-specified command.
	OpenFilesWith()

	// OpenFileWith opens file with given command.
	// does not wait for command to finish in this routine (separate routine Waits)
	OpenFileWith(command string) error

	// DuplicateFiles makes a copy of selected files
	DuplicateFiles()

	// DuplicateFile creates a copy of given file -- only works for regular files, not
	// directories
	DuplicateFile() error

	// DeleteFiles deletes any selected files or directories. If any directory is selected,
	// all files and subdirectories in that directory are also deleted.
	DeleteFiles()

	// DeleteFilesImpl does the actual deletion, no prompts
	DeleteFilesImpl()

	// DeleteFile deletes this file
	DeleteFile() error

	// RenameFiles renames any selected files
	RenameFiles()

	// RenameFile renames file to new name
	RenameFile(newpath string) error

	// NewFiles makes a new file in selected directory
	NewFiles(filename string, addToVCS bool)

	// NewFile makes a new file in this directory node
	NewFile(filename string, addToVCS bool)

	// NewFolders makes a new folder in the given selected directory
	NewFolders(foldername string)

	// NewFolder makes a new folder (directory) in this directory node
	NewFolder(foldername string)

	// CopyFileToDir copies given file path into node that is a directory.
	// This does NOT check for overwriting -- that must be done at higher level!
	CopyFileToDir(filename string, perm os.FileMode)

	// Shows file information about selected file(s)
	ShowFileInfo()
}

Filer is an interface for file tree file actions that all [Node]s satisfy.

type FindLoc added in v0.2.0

type FindLoc int32 //enums:enum -trim-prefix FindLoc

FindLoc corresponds to the search scope

const (
	// FindOpen finds in all open folders in the left file browser
	FindLocOpen FindLoc = iota

	// FindLocAll finds in all directories under the root path. can be slow for large file trees
	FindLocAll

	// FindLocFile only finds in the current active file
	FindLocFile

	// FindLocDir only finds in the directory of the current active file
	FindLocDir

	// FindLocNotTop finds in all open folders *except* the top-level folder
	FindLocNotTop
)
const FindLocN FindLoc = 5

FindLocN is the highest valid value for type FindLoc, plus one.

func FindLocValues added in v0.2.0

func FindLocValues() []FindLoc

FindLocValues returns all possible values for the type FindLoc.

func (FindLoc) Desc added in v0.2.0

func (i FindLoc) Desc() string

Desc returns the description of the FindLoc value.

func (FindLoc) Int64 added in v0.2.0

func (i FindLoc) Int64() int64

Int64 returns the FindLoc value as an int64.

func (FindLoc) MarshalText added in v0.2.0

func (i FindLoc) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FindLoc) SetInt64 added in v0.2.0

func (i *FindLoc) SetInt64(in int64)

SetInt64 sets the FindLoc value from an int64.

func (*FindLoc) SetString added in v0.2.0

func (i *FindLoc) SetString(s string) error

SetString sets the FindLoc value from its string representation, and returns an error if the string is invalid.

func (FindLoc) String added in v0.2.0

func (i FindLoc) String() string

String returns the string representation of this FindLoc value.

func (*FindLoc) UnmarshalText added in v0.2.0

func (i *FindLoc) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FindLoc) Values added in v0.2.0

func (i FindLoc) Values() []enums.Enum

Values returns all possible values for the type FindLoc.

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:"-"`

	// RepoFiles has the version control system repository file status,
	// providing a much faster way to get file status, vs. the repo.Status
	// call which is exceptionally slow.
	RepoFiles vcs.Files `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

func AsNode(n tree.Node) *Node

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

func NewNode(parent ...tree.Node) *Node

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

func (fn *Node) AddToVCS()

AddToVCS adds file to version control

func (*Node) AddToVCSSel

func (fn *Node) AddToVCSSel()

AddToVCSSel adds selected files to version control system

func (*Node) AsFileNode added in v0.2.1

func (fn *Node) AsFileNode() *Node

func (*Node) AsNode

func (t *Node) AsNode() *Node

AsNode satisfies the NodeEmbedder interface

func (*Node) BlameVCS

func (fn *Node) BlameVCS() ([]byte, error)

BlameVCS shows the VCS blame report for this file, reporting for each line the revision and author of the last change.

func (*Node) BlameVCSSel

func (fn *Node) BlameVCSSel()

BlameVCSSel shows the VCS blame report for this file, reporting for each line the revision and author of the last change.

func (*Node) CanOpen

func (fn *Node) CanOpen() bool

func (*Node) CloseBuf

func (fn *Node) CloseBuf() bool

CloseBuf closes the file in its buffer if it is open. returns true if closed.

func (*Node) CommitToVCS

func (fn *Node) CommitToVCS(message string) (err error)

CommitToVCS commits file changes to version control system

func (*Node) CommitToVCSSel

func (fn *Node) CommitToVCSSel()

CommitToVCSSel commits to version control system based on last selected file

func (*Node) ContextMenu

func (fn *Node) ContextMenu(m *core.Scene)

func (*Node) CopyFileToDir

func (fn *Node) CopyFileToDir(filename string, perm os.FileMode)

CopyFileToDir copies given file path into node that is a directory. This does NOT check for overwriting -- that must be done at higher level!

func (*Node) Cut

func (fn *Node) Cut()

Cut copies the selected files to the clipboard and then deletes them.

func (*Node) DeleteFile

func (fn *Node) DeleteFile() error

DeleteFile deletes this file

func (*Node) DeleteFiles

func (fn *Node) DeleteFiles()

deletes any selected files or directories. If any directory is selected, all files and subdirectories in that directory are also deleted.

func (*Node) DeleteFilesImpl

func (fn *Node) DeleteFilesImpl()

DeleteFilesImpl does the actual deletion, no prompts

func (*Node) DeleteFromVCS

func (fn *Node) DeleteFromVCS()

DeleteFromVCS removes file from version control

func (*Node) DeleteFromVCSSel

func (fn *Node) DeleteFromVCSSel()

DeleteFromVCSSel removes selected files from version control system

func (*Node) DetectVCSRepo

func (fn *Node) DetectVCSRepo(updateFiles bool) bool

DetectVCSRepo detects and configures DirRepo if this directory is root of a VCS repository. if updateFiles is true, gets the files in the dir. returns true if a repository was newly found here.

func (*Node) DiffVCS

func (fn *Node) DiffVCS(rev_a, rev_b string) error

DiffVCS shows the diffs between two versions of this file, given by the revision specifiers -- if empty, defaults to A = current HEAD, B = current WC file. -1, -2 etc also work as universal ways of specifying prior revisions. Diffs are shown in a DiffEditorDialog.

func (*Node) DiffVCSSel

func (fn *Node) DiffVCSSel(rev_a string, rev_b string)

DiffVCSSel shows the diffs between two versions of selected files, given by the revision specifiers -- if empty, defaults to A = current HEAD, B = current WC file. -1, -2 etc also work as universal ways of specifying prior revisions. Diffs are shown in a DiffEditorDialog.

func (*Node) DirFileList added in v0.2.1

func (fn *Node) DirFileList() []os.FileInfo

DirFileList returns the list of files in this directory, sorted according to DirsOnTop and SortByModTime options

func (*Node) DirsTo

func (fn *Node) DirsTo(path string) (*Node, error)

DirsTo opens all the directories above the given filename, and returns the node for element at given path (can be a file or directory itself -- not opened -- just returned)

func (*Node) DragDrop

func (fn *Node) DragDrop(e events.Event)

func (*Node) DropDeleteSource

func (fn *Node) DropDeleteSource(e events.Event)

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

func (fn *Node) DuplicateFile() error

DuplicateFile creates a copy of given file -- only works for regular files, not directories

func (*Node) DuplicateFiles

func (fn *Node) DuplicateFiles()

DuplicateFiles makes a copy of selected files

func (*Node) FileExtCounts

func (fn *Node) FileExtCounts(cat fileinfo.Categories) []NodeNameCount

FileExtCounts 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) FilesMatching

func (fn *Node) FilesMatching(match string, ignoreCase bool) []*Node

FilesMatching returns list of all nodes whose file name contains given string (no regexp). ignoreCase transforms everything into lowercase

func (*Node) FindDirNode

func (fn *Node) FindDirNode(path string) (*Node, error)

FindDirNode finds directory node by given path. Must be a relative path already rooted at tree, or absolute path within tree.

func (*Node) FindFile

func (fn *Node) FindFile(fnm string) (*Node, bool)

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

func (fn *Node) FirstVCS() (vcs.Repo, *Node)

FirstVCS returns the first VCS repository starting from this node and going down. also returns the node having that repository

func (*Node) Init added in v0.2.0

func (fn *Node) Init()

func (*Node) InitFileInfo

func (fn *Node) InitFileInfo() error

InitFileInfo initializes file info

func (*Node) IsAutoSave

func (fn *Node) IsAutoSave() bool

IsAutoSave returns true if file is an auto-save file (starts and ends with #)

func (*Node) IsChanged

func (fn *Node) IsChanged() bool

IsChanged returns true if the file is open and has been changed (edited) since last EditDone

func (*Node) IsDir

func (fn *Node) IsDir() bool

IsDir returns true if file is a directory (folder)

func (*Node) IsExec

func (fn *Node) IsExec() bool

IsExec returns true if file is an executable file

func (*Node) IsExternal

func (fn *Node) IsExternal() bool

IsExternal returns true if file is external to main file tree

func (*Node) IsIrregular

func (fn *Node) IsIrregular() bool

IsIrregular returns true if file is a special "Irregular" node

func (*Node) IsNotSaved

func (fn *Node) IsNotSaved() bool

IsNotSaved returns true if the file is open and has been changed (edited) since last Save

func (*Node) IsOpen

func (fn *Node) IsOpen() bool

IsOpen returns true if file is flagged as open

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

func (fn *Node) LogVCS(allFiles bool, since string) (vcs.Log, error)

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

func (fn *Node) LogVCSSel()

LogVCSSel shows the VCS log of commits for selected files.

func (*Node) MimeData

func (fn *Node) MimeData(md *mimedata.Mimes)

MimeData adds mimedata for this node: a text/plain of the Path, text/plain of filename, and text/

func (*Node) MyRelPath

func (fn *Node) MyRelPath() string

MyRelPath returns the relative path from root for this node

func (*Node) NewFile

func (fn *Node) NewFile(filename string, addToVCS bool)

NewFile makes a new file in this directory node

func (*Node) NewFiles

func (fn *Node) NewFiles(filename string, addToVCS bool)

NewFiles makes a new file in selected directory

func (*Node) NewFolder

func (fn *Node) NewFolder(foldername string)

NewFolder makes a new folder (directory) in this directory node

func (*Node) NewFolders

func (fn *Node) NewFolders(foldername string)

makes a new folder in the given selected directory

func (*Node) OnClose

func (fn *Node) OnClose()

func (*Node) OnOpen

func (fn *Node) OnOpen()

func (*Node) OpenAll

func (fn *Node) OpenAll()

OpenAll opens all directories under this one

func (*Node) OpenBuf

func (fn *Node) OpenBuf() (bool, error)

OpenBuf opens the file in its buffer if it is not already open. returns true if file is newly opened

func (*Node) OpenDir

func (fn *Node) OpenDir()

OpenDir opens given directory node

func (*Node) OpenFileDefault

func (fn *Node) OpenFileDefault() error

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

func (fn *Node) OpenFileWith(command string) error

OpenFileWith opens file with given command. does not wait for command to finish in this routine (separate routine Waits)

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

func (fn *Node) OpenFilesWith()

OpenFilesWith opens selected files with user-specified command.

func (*Node) Paste

func (fn *Node) Paste()

Paste inserts files from the clipboard.

func (*Node) PasteCheckExisting

func (fn *Node) PasteCheckExisting(tfn *Node, md mimedata.Mimes, externalDrop bool) ([]string, *Node)

PasteCheckExisting checks for existing files in target node directory if that is non-nil (otherwise just uses absolute path), and returns list of existing and node for last one if exists.

func (*Node) PasteCopyFiles

func (fn *Node) PasteCopyFiles(tdir *Node, md mimedata.Mimes, externalDrop bool)

PasteCopyFiles copies files in given data into given target directory

func (*Node) PasteCopyFilesCheck

func (fn *Node) PasteCopyFilesCheck(tdir *Node, md mimedata.Mimes, externalDrop bool, dropFinal func())

PasteCopyFilesCheck copies files into given directory node, first checking if any already exist -- if they exist, prompts.

func (*Node) PasteFiles

func (fn *Node) PasteFiles(md mimedata.Mimes, externalDrop bool, dropFinal func())

PasteFiles applies a paste / drop of mime data onto this node. always does a copy of files into / onto target. externalDrop is true if this is an externally generated Drop event (from OS)

func (*Node) RelPath

func (fn *Node) RelPath(fpath core.Filename) string

RelPath returns the relative path from node for given full path

func (*Node) RemoveFromExterns

func (fn *Node) RemoveFromExterns()

RemoveFromExterns removes file from list of external files

func (*Node) RenameFile

func (fn *Node) RenameFile(newpath string) error

RenameFile renames file to new name

func (*Node) RenameFiles

func (fn *Node) RenameFiles()

renames any selected files

func (*Node) Repo

func (fn *Node) Repo() (vcs.Repo, *Node)

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

func (fn *Node) RevertVCS() (err error)

RevertVCS reverts file changes since last commit

func (*Node) RevertVCSSel

func (fn *Node) RevertVCSSel()

RevertVCSSel removes selected files from version control system

func (*Node) SelectedFunc added in v0.2.0

func (fn *Node) SelectedFunc(fun func(n *Node))

SelectedFunc runs the given function on all selected nodes in reverse order.

func (*Node) SetFileIcon

func (fn *Node) SetFileIcon()

func (*Node) ShowFileInfo

func (fn *Node) ShowFileInfo()

Shows file information about selected file(s)

func (*Node) SortBy

func (fn *Node) SortBy(modTime bool)

SortBy determines how to sort the files in the directory -- default is alpha by name, optionally can be sorted by modification time.

func (*Node) SortBys

func (fn *Node) SortBys(modTime bool)

SortBys determines how to sort the selected files in the directory. Default is alpha by name, optionally can be sorted by modification time.

func (*Node) UpdateAllVCS

func (fn *Node) UpdateAllVCS()

UpdateAllVCS does an update on any repositories below this one in file tree

func (*Node) UpdateRepoFiles

func (fn *Node) UpdateRepoFiles()

func (*Node) VCSContextMenu

func (fn *Node) VCSContextMenu(m *core.Scene)

type NodeEmbedder

type NodeEmbedder interface {
	AsNode() *Node
}

NodeEmbedder is an interface that all types that embed Node satisfy

type NodeNameCount

type NodeNameCount struct {
	Name  string
	Count int
}

NodeNameCount is used to report counts of different string-based things in the file tree

type SearchResults added in v0.2.0

type SearchResults struct {
	Node    *Node
	Count   int
	Matches []textbuf.Match
}

SearchResults is used to report search results

func FindAll added in v0.2.0

func FindAll(start *Node, find string, ignoreCase, regExp bool, langs []fileinfo.Known, openPath func(path string) *Node) []SearchResults

FindAll returns list of all files (regardless of what is currently open) 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.

func Search(start *Node, find string, ignoreCase, regExp bool, loc FindLoc, 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

	// ExternalFiles are external files outside the root path of the tree.
	// They are stored in terms of their absolute paths. These are shown
	// in the first sub-node if present; use [Tree.AddExternalFile] to add one.
	ExternalFiles []string `set:"-"`

	// 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:"-"`

	// if true, then all directories are placed at the top of the tree.
	// Otherwise everything is mixed.
	DirsOnTop bool

	// type of node to create; defaults to [Node] but can use custom node types
	FileNodeType *types.Type `display:"-" json:"-" xml:"-"`
	// 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

func NewTree(parent ...tree.Node) *Tree

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

func (ft *Tree) AddExternalFile(fpath string) (*Node, error)

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

func (ft *Tree) ConfigWatcher() error

ConfigWatcher configures a new watcher for tree

func (*Tree) Destroy

func (fv *Tree) Destroy()

func (*Tree) DirSortByModTime

func (ft *Tree) DirSortByModTime(fpath core.Filename) bool

DirSortByModTime returns true if dir is sorted by mod time

func (*Tree) DirSortByName

func (ft *Tree) DirSortByName(fpath core.Filename) bool

DirSortByName returns true if dir is sorted by name

func (*Tree) ExternalNodeByPath added in v0.2.0

func (ft *Tree) ExternalNodeByPath(fpath string) (*Node, error)

ExternalNodeByPath returns Node for given file path, and true, if it exists in the external files list. Otherwise returns nil, false.

func (*Tree) HasExternalFile added in v0.2.0

func (ft *Tree) HasExternalFile(fpath string) (bool, int)

HasExternalFile returns true and index if given abs path exists on ExtFiles list. false and -1 if not.

func (*Tree) Init added in v0.2.0

func (ft *Tree) Init()

func (*Tree) IsDirOpen

func (ft *Tree) IsDirOpen(fpath core.Filename) bool

IsDirOpen returns true if given directory path is open (i.e., has been opened in the view)

func (*Tree) OpenPath

func (ft *Tree) OpenPath(path string) *Tree

OpenPath opens the filetree at the given 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) RemoveExternalFile added in v0.2.0

func (ft *Tree) RemoveExternalFile(fpath string) bool

RemoveExternalFile removes external file from maintained list; returns true if removed.

func (*Tree) SetDirClosed

func (ft *Tree) SetDirClosed(fpath core.Filename)

SetDirClosed sets the given directory path to be closed

func (*Tree) SetDirOpen

func (ft *Tree) SetDirOpen(fpath core.Filename)

SetDirOpen sets the given directory path to be open

func (*Tree) SetDirSortBy

func (ft *Tree) SetDirSortBy(fpath core.Filename, modTime bool)

SetDirSortBy sets the given directory path sort by option

func (*Tree) SetDirsOnTop

func (t *Tree) SetDirsOnTop(v bool) *Tree

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

func (t *Tree) SetFileNodeType(v *types.Type) *Tree

SetFileNodeType sets the [Tree.FileNodeType]: type of node to create; defaults to Node but can use custom node types

func (*Tree) UnWatchPath

func (ft *Tree) UnWatchPath(path core.Filename)

UnWatchPath removes given path from those watched

func (*Tree) UpdatePath

func (ft *Tree) UpdatePath(path string)

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.

func (*Tree) WatchPath

func (ft *Tree) WatchPath(path core.Filename) error

WatchPath adds given path to those watched

func (*Tree) WatchUpdate added in v0.0.10

func (ft *Tree) WatchUpdate(path string)

WatchUpdate does the update for given path

func (*Tree) WatchWatcher

func (ft *Tree) WatchWatcher()

WatchWatcher monitors the watcher channel for update events. It must be called once some paths have been added to watcher -- safe to call multiple times.

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:"-"`

	// revision A -- defaults to HEAD
	RevA string `set:"-"`

	// revision B -- blank means current working copy
	RevB string `set:"-"`

	// double-click will set the A revision -- else B
	SetA bool
}

VCSLog is a widget that represents VCS log data.

func NewVCSLog added in v0.2.0

func NewVCSLog(parent ...tree.Node) *VCSLog

NewVCSLog returns a new VCSLog with the given optional parent: VCSLog is a widget that represents VCS log data.

func (*VCSLog) Init added in v0.2.0

func (lv *VCSLog) Init()

func (*VCSLog) MakeToolbar added in v0.2.0

func (lv *VCSLog) MakeToolbar(p *tree.Plan)

func (*VCSLog) SetFile added in v0.2.0

func (t *VCSLog) SetFile(v string) *VCSLog

SetFile sets the [VCSLog.File]: file that this is a log of -- if blank then it is entire repository

func (*VCSLog) SetLog added in v0.2.0

func (t *VCSLog) SetLog(v vcs.Log) *VCSLog

SetLog sets the [VCSLog.Log]: current log

func (*VCSLog) SetRepo added in v0.2.0

func (t *VCSLog) SetRepo(v vcs.Repo) *VCSLog

SetRepo sets the [VCSLog.Repo]: version control system repository

func (*VCSLog) SetRevA added in v0.2.0

func (lv *VCSLog) SetRevA(rev string)

SetRevA sets the revision to use for buffer A

func (*VCSLog) SetRevB added in v0.2.0

func (lv *VCSLog) SetRevB(rev string)

SetRevB sets the revision to use for buffer B

func (*VCSLog) SetSetA added in v0.2.0

func (t *VCSLog) SetSetA(v bool) *VCSLog

SetSetA sets the [VCSLog.SetA]: double-click will set the A revision -- else B

func (*VCSLog) SetSince added in v0.2.0

func (t *VCSLog) SetSince(v string) *VCSLog

SetSince sets the [VCSLog.Since]: date expression for how long ago to include log entries from

func (*VCSLog) Table added in v0.2.0

func (lv *VCSLog) Table() *core.Table

Table returns the table

func (*VCSLog) ToggleRev added in v0.2.0

func (lv *VCSLog) ToggleRev()

ToggleRev switches the active revision to set

func (*VCSLog) Toolbar added in v0.2.0

func (lv *VCSLog) Toolbar() *core.Toolbar

Toolbar returns the toolbar

type VersionControlName added in v0.0.8

type VersionControlName string

VersionControlName is the name of a version control system

func VersionControlNameProper added in v0.0.8

func VersionControlNameProper(vc string) VersionControlName

func (VersionControlName) Value added in v0.0.8

func (kn VersionControlName) Value() core.Value

Value registers core.Chooser as the core.Value widget for VersionControlName

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL