filetree

package
v2.0.0-dev0.0.18 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: BSD-3-Clause Imports: 40 Imported by: 2

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 NodeType = gti.AddType(&gti.Type{
	Name:      "goki.dev/gi/v2/filetree.Node",
	ShortName: "filetree.Node",
	IDName:    "node",
	Doc:       "Node represents a file in the file system, as a TreeView node.\nThe name of the node is the name of the file.\nFolders have children containing further nodes.",
	Directives: gti.Directives{
		&gti.Directive{Tool: "goki", Directive: "embedder", Args: []string{}},
	},
	Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"FPath", &gti.Field{Name: "FPath", Type: "goki.dev/gi/v2/gi.FileName", LocalType: "gi.FileName", Doc: "full path to this file", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
		{"Info", &gti.Field{Name: "Info", Type: "goki.dev/pi/v2/fi.FileInfo", LocalType: "fi.FileInfo", Doc: "full standard file info about this file", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
		{"Buf", &gti.Field{Name: "Buf", Type: "*goki.dev/gi/v2/texteditor.Buf", LocalType: "*texteditor.Buf", Doc: "file buffer for editing this file", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
		{"FRoot", &gti.Field{Name: "FRoot", Type: "*goki.dev/gi/v2/filetree.Tree", LocalType: "*Tree", Doc: "root of the tree -- has global state", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
		{"DirRepo", &gti.Field{Name: "DirRepo", Type: "goki.dev/vci/v2.Repo", LocalType: "vci.Repo", Doc: "version control system repository for this directory,\nonly non-nil if this is the highest-level directory in the tree under vcs control", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
		{"RepoFiles", &gti.Field{Name: "RepoFiles", Type: "goki.dev/vci/v2.Files", LocalType: "vci.Files", Doc: "version control system repository file status -- only valid during ReadDir", Directives: gti.Directives{}, Tag: "edit:\"-\" set:\"-\" json:\"-\" xml:\"-\" copy:\"-\""}},
	}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"TreeView", &gti.Field{Name: "TreeView", Type: "goki.dev/gi/v2/giv.TreeView", LocalType: "giv.TreeView", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{
		{"OpenFilesDefault", &gti.Method{Name: "OpenFilesDefault", Doc: "OpenFilesDefault opens selected files with default app for that file type (os defined).\nruns open on Mac, xdg-open on Linux, and start on Windows", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"DuplicateFiles", &gti.Method{Name: "DuplicateFiles", Doc: "makes a copy of selected files", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"DeleteFiles", &gti.Method{Name: "DeleteFiles", Doc: "deletes any selected files or directories. If any directory is selected,\nall files and subdirectories in that directory are also deleted.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"RenameFiles", &gti.Method{Name: "RenameFiles", Doc: "renames any selected files", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"RenameFile", &gti.Method{Name: "RenameFile", Doc: "RenameFile renames file to new name", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"newpath", &gti.Field{Name: "newpath", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"err", &gti.Field{Name: "err", Type: "error", LocalType: "error", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		})}},
		{"NewFiles", &gti.Method{Name: "NewFiles", Doc: "makes a new file in selected directory", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"filename", &gti.Field{Name: "filename", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
			{"addToVcs", &gti.Field{Name: "addToVcs", Type: "bool", LocalType: "bool", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"NewFolders", &gti.Method{Name: "NewFolders", Doc: "makes a new folder in the given selected directory", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"foldername", &gti.Field{Name: "foldername", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"NewFolder", &gti.Method{Name: "NewFolder", Doc: "NewFolder makes a new folder (directory) in this directory node", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"foldername", &gti.Field{Name: "foldername", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"ShowFileInfo", &gti.Method{Name: "ShowFileInfo", Doc: "Shows file information about selected file(s)", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"SortBys", &gti.Method{Name: "SortBys", Doc: "SortBys determines how to sort the selected files in the directory.\nDefault is alpha by name, optionally can be sorted by modification time.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"modTime", &gti.Field{Name: "modTime", Type: "bool", LocalType: "bool", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"OpenAll", &gti.Method{Name: "OpenAll", Doc: "OpenAll opens all directories under this one", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"CloseAll", &gti.Method{Name: "CloseAll", Doc: "CloseAll closes all directories under this one, this included", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"RemoveFromExterns", &gti.Method{Name: "RemoveFromExterns", Doc: "RemoveFromExterns removes file from list of external files", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"AddToVcsSel", &gti.Method{Name: "AddToVcsSel", Doc: "AddToVcsSel adds selected files to version control system", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"DeleteFromVcsSel", &gti.Method{Name: "DeleteFromVcsSel", Doc: "DeleteFromVcsSel removes selected files from version control system", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"CommitToVcsSel", &gti.Method{Name: "CommitToVcsSel", Doc: "CommitToVcsSel commits to version control system based on last selected file", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"RevertVcsSel", &gti.Method{Name: "RevertVcsSel", Doc: "RevertVcsSel removes selected files from version control system", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"DiffVcsSel", &gti.Method{Name: "DiffVcsSel", Doc: "DiffVcsSel shows the diffs between two versions of selected files, given by the\nrevision specifiers -- if empty, defaults to A = current HEAD, B = current WC file.\n-1, -2 etc also work as universal ways of specifying prior revisions.\nDiffs are shown in a DiffViewDialog.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"rev_a", &gti.Field{Name: "rev_a", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
			{"rev_b", &gti.Field{Name: "rev_b", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"LogVcsSel", &gti.Method{Name: "LogVcsSel", Doc: "LogVcsSel shows the VCS log of commits for selected files, optionally with a\nsince date qualifier: If since is non-empty, it should be\na date-like expression that the VCS will understand, such as\n1/1/2020, yesterday, last year, etc.  SVN only understands a\nnumber as a maximum number of items to return.\nIf allFiles is true, then the log will show revisions for all files, not just\nthis one.\nReturns the Log and also shows it in a VCSLogView which supports further actions.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"allFiles", &gti.Field{Name: "allFiles", Type: "bool", LocalType: "bool", Doc: "", Directives: gti.Directives{}, Tag: ""}},
			{"since", &gti.Field{Name: "since", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"BlameVcsSel", &gti.Method{Name: "BlameVcsSel", Doc: "BlameVcsSel shows the VCS blame report for this file, reporting for each line\nthe revision and author of the last change.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
	}),
	Instance: &Node{},
})

NodeType is the gti.Type for Node

View Source
var TreeType = gti.AddType(&gti.Type{
	Name:       "goki.dev/gi/v2/filetree.Tree",
	ShortName:  "filetree.Tree",
	IDName:     "tree",
	Doc:        "Tree is the root of a tree representing files in a given directory\n(and subdirectories thereof), and has some overall management state for how to\nview things.  The Tree can be viewed by a TreeView to provide a GUI\ninterface into it.",
	Directives: gti.Directives{},
	Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"ExtFiles", &gti.Field{Name: "ExtFiles", Type: "[]string", LocalType: "[]string", Doc: "external files outside the root path of the tree -- abs paths are stored -- these are shown in the first sub-node if present -- use AddExtFile to add and update", Directives: gti.Directives{}, Tag: ""}},
		{"Dirs", &gti.Field{Name: "Dirs", Type: "goki.dev/gi/v2/filetree.DirFlagMap", LocalType: "DirFlagMap", Doc: "records state of directories within the tree (encoded using paths relative to root),\ne.g., open (have been opened by the user) -- can persist this to restore prior view of a tree", Directives: gti.Directives{}, Tag: ""}},
		{"DirsOnTop", &gti.Field{Name: "DirsOnTop", Type: "bool", LocalType: "bool", Doc: "if true, then all directories are placed at the top of the tree view\notherwise everything is mixed", Directives: gti.Directives{}, Tag: ""}},
		{"NodeType", &gti.Field{Name: "NodeType", Type: "*goki.dev/gti.Type", LocalType: "*gti.Type", Doc: "type of node to create -- defaults to giv.Node but can use custom node types", Directives: gti.Directives{}, Tag: "view:\"-\" json:\"-\" xml:\"-\""}},
		{"InOpenAll", &gti.Field{Name: "InOpenAll", Type: "bool", LocalType: "bool", Doc: "if true, we are in midst of an OpenAll call -- nodes should open all dirs", Directives: gti.Directives{}, Tag: ""}},
		{"Watcher", &gti.Field{Name: "Watcher", Type: "*gopkg.in/fsnotify.v1.Watcher", LocalType: "*fsnotify.Watcher", Doc: "change notify for all dirs", Directives: gti.Directives{}, Tag: "view:\"-\""}},
		{"DoneWatcher", &gti.Field{Name: "DoneWatcher", Type: "chan bool", LocalType: "chan bool", Doc: "channel to close watcher watcher", Directives: gti.Directives{}, Tag: "view:\"-\""}},
		{"WatchedPaths", &gti.Field{Name: "WatchedPaths", Type: "map[string]bool", LocalType: "map[string]bool", Doc: "map of paths that have been added to watcher -- only active if bool = true", Directives: gti.Directives{}, Tag: "view:\"-\""}},
		{"LastWatchUpdt", &gti.Field{Name: "LastWatchUpdt", Type: "string", LocalType: "string", Doc: "last path updated by watcher", Directives: gti.Directives{}, Tag: "view:\"-\""}},
		{"LastWatchTime", &gti.Field{Name: "LastWatchTime", Type: "time.Time", LocalType: "time.Time", Doc: "timestamp of last update", Directives: gti.Directives{}, Tag: "view:\"-\""}},
		{"UpdtMu", &gti.Field{Name: "UpdtMu", Type: "sync.Mutex", LocalType: "sync.Mutex", Doc: "Update mutex", Directives: gti.Directives{}, Tag: "view:\"-\""}},
	}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Node", &gti.Field{Name: "Node", Type: "goki.dev/gi/v2/filetree.Node", LocalType: "Node", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods:  ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
	Instance: &Tree{},
})

TreeType is the gti.Type for Tree

View Source
var VCSLogViewType = gti.AddType(&gti.Type{
	Name:       "goki.dev/gi/v2/filetree.VCSLogView",
	ShortName:  "filetree.VCSLogView",
	IDName:     "vcs-log-view",
	Doc:        "VCSLogView is a view of the VCS log data",
	Directives: gti.Directives{},
	Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Log", &gti.Field{Name: "Log", Type: "goki.dev/vci/v2.Log", LocalType: "vci.Log", Doc: "current log", Directives: gti.Directives{}, Tag: ""}},
		{"File", &gti.Field{Name: "File", Type: "string", LocalType: "string", Doc: "file that this is a log of -- if blank then it is entire repository", Directives: gti.Directives{}, Tag: ""}},
		{"Since", &gti.Field{Name: "Since", Type: "string", LocalType: "string", Doc: "date expression for how long ago to include log entries from", Directives: gti.Directives{}, Tag: ""}},
		{"Repo", &gti.Field{Name: "Repo", Type: "goki.dev/vci/v2.Repo", LocalType: "vci.Repo", Doc: "version control system repository", Directives: gti.Directives{}, Tag: "json:\"-\" xml:\"-\" copy:\"-\""}},
		{"RevA", &gti.Field{Name: "RevA", Type: "string", LocalType: "string", Doc: "revision A -- defaults to HEAD", Directives: gti.Directives{}, Tag: "set:\"-\""}},
		{"RevB", &gti.Field{Name: "RevB", Type: "string", LocalType: "string", Doc: "revision B -- blank means current working copy", Directives: gti.Directives{}, Tag: "set:\"-\""}},
		{"SetA", &gti.Field{Name: "SetA", Type: "bool", LocalType: "bool", Doc: "double-click will set the A revision -- else B", Directives: gti.Directives{}, Tag: ""}},
	}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Layout", &gti.Field{Name: "Layout", Type: "goki.dev/gi/v2/gi.Layout", LocalType: "gi.Layout", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods:  ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
	Instance: &VCSLogView{},
})

VCSLogViewType is the gti.Type for VCSLogView

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

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

Functions

func BlameDialog

func BlameDialog(ctx gi.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 gi.Widget, repo vci.Repo, file, rev string) *gi.Body

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

func IsVersCtrlSystem

func IsVersCtrlSystem(str string) bool

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

func NodeNameCountSort

func NodeNameCountSort(ecs []NodeNameCount)

func OSOpenCommand

func OSOpenCommand() string

OSOpenCommand returns the generic file 'open' command to open file with default app open on Mac, xdg-open on Linux, and start on Windows

func VCSLabelFunc

func VCSLabelFunc(fn *Node, label string) string

VCSLabelFunc gets the appropriate label for removing from version control

func VCSLogViewDialog

func VCSLogViewDialog(ctx gi.Widget, repo vci.Repo, lg vci.Log, file, since string) *gi.Body

VCSLogViewDialog 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 `view:"-" json:"-" xml:"-"`
}

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

func (dm *DirFlagMap) ClearMarks()

ClearMarks clears all the marks -- do this prior to traversing full set of active paths -- can then call DeleteStale to get rid of unused paths.

func (*DirFlagMap) DeleteStale

func (dm *DirFlagMap) DeleteStale()

DeleteStale removes all entries with a bool = false value indicating that they have not been accessed since ClearFlags was called.

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

func (dm *DirFlagMap) SetMark(path string)

SetMark sets the mark flag indicating we visited file

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.

const (
	// DirMark means directory is marked -- unmarked entries are deleted post-update
	DirMark DirFlags = iota

	// DirIsOpen means directory is open -- else closed
	DirIsOpen

	// 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 = 4

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

func (i DirFlags) IsValid() bool

IsValid returns whether the value is a valid option for type DirFlags.

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 Node

type Node struct {
	giv.TreeView

	// full path to this file
	FPath gi.FileName `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`

	// full standard file info about this file
	Info fi.FileInfo `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`

	// file buffer for editing this file
	Buf *texteditor.Buf `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`

	// root of the tree -- has global state
	FRoot *Tree `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`

	// version control system repository for this directory,
	// only non-nil if this is the highest-level directory in the tree under vcs control
	DirRepo vci.Repo `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`

	// version control system repository file status -- only valid during ReadDir
	RepoFiles vci.Files `edit:"-" set:"-" json:"-" xml:"-" copy:"-"`
}

Node represents a file in the file system, as a TreeView node. The name of the node is the name of the file. Folders have children containing further nodes.

func AsNode

func AsNode(k ki.Ki) *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(par ki.Ki, name ...string) *Node

NewNode adds a new Node with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.

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

func (t *Node) AsNode() *Node

AsNode satisfies the NodeEmbedder interface

func (*Node) BaseType

func (fn *Node) BaseType() *gti.Type

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

func (fn *Node) CloseAll()

CloseAll closes all directories under this one, this included

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

func (fn *Node) CloseDir()

CloseDir closes given directory node -- updates memory state

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

func (fn *Node) ConfigOfFiles(path string) ki.Config

ConfigOfFiles returns a type-and-name list for configuring nodes based on files immediately within given path

func (*Node) ContextMenu

func (fn *Node) ContextMenu(m *gi.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) DeleteFile

func (fn *Node) DeleteFile() (err 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 DiffViewDialog.

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 DiffViewDialog.

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

makes a copy of selected files

func (*Node) FileExtCounts

func (fn *Node) FileExtCounts(cat fi.Cat) []NodeNameCount

FileExtCounts returns a count of all the different file extensions, sorted from highest to lowest. If cat is != fi.Unknown then it only uses files of that type (e.g., fi.Code to find any code files)

func (*Node) FileNodeContextMenu

func (fn *Node) FileNodeContextMenu(m *gi.Scene)

func (*Node) FileNodeStyles

func (fn *Node) FileNodeStyles()

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() (vci.Repo, *Node)

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

func (*Node) FlagType

func (fn *Node) FlagType() enums.BitFlagSetter

func (*Node) HandleFileNodeEvents

func (fn *Node) HandleFileNodeEvents()

func (*Node) HasClosedParent

func (fn *Node) HasClosedParent() bool

HasClosedParent returns true if node has a parent node with !IsOpen flag set

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 (fn *Node) IsSymLink() bool

IsSymLink returns true if file is a symlink

func (*Node) KeyInput

func (fn *Node) KeyInput(kt events.Event)

func (*Node) KiType

func (t *Node) KiType() *gti.Type

KiType returns the *gti.Type of Node

func (*Node) LatestFileMod

func (fn *Node) LatestFileMod(cat fi.Cat) time.Time

LatestFileMod returns the most recent mod time of files in the tree. If cat is != fi.Unknown then it only uses files of that type (e.g., fi.Code to find any code files)

func (*Node) LogVcs

func (fn *Node) LogVcs(allFiles bool, since string) (vci.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 VCSLogView which supports further actions.

func (*Node) LogVcsSel

func (fn *Node) LogVcsSel(allFiles bool, since string)

LogVcsSel shows the VCS log of commits for selected files, 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 VCSLogView which supports further actions.

func (*Node) MyRelPath

func (fn *Node) MyRelPath() string

MyRelPath returns the relative path from root for this node

func (*Node) New

func (t *Node) New() ki.Ki

New returns a new *Node value

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)

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

func (fn *Node) OnInit()

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

func (fn *Node) OpenDirs()

OpenDirs opens directories for selected views

func (*Node) OpenEmptyDir

func (fn *Node) OpenEmptyDir() bool

OpenEmptyDir will attempt to open a directory that has no children which presumably was not processed originally

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

func (fn *Node) ReadDir(path string) error

ReadDir reads all the files at given directory into this directory node -- uses config children to preserve extra info already stored about files. The root node represents the directory at the given path. Returns os.Stat error if path cannot be accessed.

func (*Node) RelPath

func (fn *Node) RelPath(fpath gi.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) (err 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() (vci.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) SetClass

func (t *Node) SetClass(v string) *Node

SetClass sets the [Node.Class]

func (*Node) SetCustomContextMenu

func (t *Node) SetCustomContextMenu(v func(m *gi.Scene)) *Node

SetCustomContextMenu sets the [Node.CustomContextMenu]

func (*Node) SetFileIcon

func (fn *Node) SetFileIcon()

func (*Node) SetIcon

func (t *Node) SetIcon(v icons.Icon) *Node

SetIcon sets the [Node.Icon]

func (*Node) SetIndent

func (t *Node) SetIndent(v units.Value) *Node

SetIndent sets the [Node.Indent]

func (*Node) SetNodePath

func (fn *Node) SetNodePath(path string) error

SetNodePath sets the path for given node and updates it based on associated file

func (*Node) SetOpenDepth

func (t *Node) SetOpenDepth(v int) *Node

SetOpenDepth sets the [Node.OpenDepth]

func (*Node) SetPriorityEvents

func (t *Node) SetPriorityEvents(v []events.Types) *Node

SetPriorityEvents sets the [Node.PriorityEvents]

func (*Node) SetRootView

func (t *Node) SetRootView(v *giv.TreeView) *Node

SetRootView sets the [Node.RootView]

func (*Node) SetSelectedNodes

func (t *Node) SetSelectedNodes(v []giv.TreeViewer) *Node

SetSelectedNodes sets the [Node.SelectedNodes]

func (*Node) SetText

func (t *Node) SetText(v string) *Node

SetText sets the [Node.Text]

func (*Node) SetTooltip

func (t *Node) SetTooltip(v string) *Node

SetTooltip sets the [Node.Tooltip]

func (*Node) SetViewIdx

func (t *Node) SetViewIdx(v int) *Node

SetViewIdx sets the [Node.ViewIdx]

func (*Node) SetWidgetSize

func (t *Node) SetWidgetSize(v mat32.Vec2) *Node

SetWidgetSize sets the [Node.WidgetSize]

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

func (fn *Node) SortConfigByModTime(confg ki.Config)

SortConfigByModTime sorts given config list by mod time

func (*Node) UpdateAllVcs

func (fn *Node) UpdateAllVcs()

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

func (*Node) UpdateBranchIcons

func (fn *Node) UpdateBranchIcons()

func (*Node) UpdateDir

func (fn *Node) UpdateDir()

UpdateDir updates the directory and all the nodes under it

func (*Node) UpdateNode

func (fn *Node) UpdateNode() error

UpdateNode updates information in node based on its associated file in FPath. This is intended to be called ad-hoc for individual nodes that might need updating -- use ReadDir for mass updates as it is more efficient.

func (*Node) UpdateRepoFiles

func (fn *Node) UpdateRepoFiles()

type NodeEmbedder

type NodeEmbedder interface {
	AsNode() *Node
}

NodeEmbedder is an interface that all types that embed Node satisfy

type NodeFlags

type NodeFlags giv.TreeViewFlags //enums:bitflag -trim-prefix Node

NodeFlags define bitflags for Node state -- these extend TreeViewFlags and storage is an int64

const (
	// NodeOpen means file is open. For directories, this means that
	// sub-files should be / have been loaded. For files, means that they
	// have been opened e.g., for editing.
	NodeOpen NodeFlags = NodeFlags(giv.TreeViewFlagsN) + iota

	// NodeSymLink indicates that file is a symbolic link.
	// File info is all for the target of the symlink.
	NodeSymLink
)
const NodeFlagsN NodeFlags = 13

NodeFlagsN is the highest valid value for type NodeFlags, plus one.

func NodeFlagsValues

func NodeFlagsValues() []NodeFlags

NodeFlagsValues returns all possible values for the type NodeFlags.

func (NodeFlags) BitIndexString

func (i NodeFlags) BitIndexString() string

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

func (NodeFlags) Desc

func (i NodeFlags) Desc() string

Desc returns the description of the NodeFlags value.

func (NodeFlags) HasFlag

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

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

func (NodeFlags) Int64

func (i NodeFlags) Int64() int64

Int64 returns the NodeFlags value as an int64.

func (NodeFlags) IsValid

func (i NodeFlags) IsValid() bool

IsValid returns whether the value is a valid option for type NodeFlags.

func (NodeFlags) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface.

func (*NodeFlags) SetFlag

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

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

func (*NodeFlags) SetInt64

func (i *NodeFlags) SetInt64(in int64)

SetInt64 sets the NodeFlags value from an int64.

func (*NodeFlags) SetString

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

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

func (*NodeFlags) SetStringOr

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

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

func (NodeFlags) String

func (i NodeFlags) String() string

String returns the string representation of this NodeFlags value.

func (*NodeFlags) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (NodeFlags) Values

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

Values returns all possible values for the type NodeFlags.

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 Tree

type Tree struct {
	Node

	// external files outside the root path of the tree -- abs paths are stored -- these are shown in the first sub-node if present -- use AddExtFile to add and update
	ExtFiles []string

	// 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

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

	// type of node to create -- defaults to giv.Node but can use custom node types
	NodeType *gti.Type `view:"-" json:"-" xml:"-"`

	// if true, we are in midst of an OpenAll call -- nodes should open all dirs
	InOpenAll bool

	// change notify for all dirs
	Watcher *fsnotify.Watcher `view:"-"`

	// channel to close watcher watcher
	DoneWatcher chan bool `view:"-"`

	// map of paths that have been added to watcher -- only active if bool = true
	WatchedPaths map[string]bool `view:"-"`

	// last path updated by watcher
	LastWatchUpdt string `view:"-"`

	// timestamp of last update
	LastWatchTime time.Time `view:"-"`

	// Update mutex
	UpdtMu sync.Mutex `view:"-"`
}

Tree is the root of a tree representing files in a given directory (and subdirectories thereof), and has some overall management state for how to view things. The Tree can be viewed by a TreeView to provide a GUI interface into it.

func NewTree

func NewTree(par ki.Ki, name ...string) *Tree

NewTree adds a new Tree with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.

func (*Tree) AddExtFile

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

AddExtFile 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) CopyFieldsFrom

func (ft *Tree) CopyFieldsFrom(frm any)

func (*Tree) Destroy

func (fv *Tree) Destroy()

func (*Tree) DirSortByModTime

func (ft *Tree) DirSortByModTime(fpath gi.FileName) bool

DirSortByModTime returns true if dir is sorted by mod time

func (*Tree) DirSortByName

func (ft *Tree) DirSortByName(fpath gi.FileName) bool

DirSortByName returns true if dir is sorted by name

func (*Tree) ExtNodeByPath

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

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

func (*Tree) HasExtFile

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

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

func (*Tree) IsDirOpen

func (ft *Tree) IsDirOpen(fpath gi.FileName) bool

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

func (*Tree) KiType

func (t *Tree) KiType() *gti.Type

KiType returns the *gti.Type of Tree

func (*Tree) New

func (t *Tree) New() ki.Ki

New returns a new *Tree value

func (*Tree) OnInit

func (ft *Tree) OnInit()

func (*Tree) OpenPath

func (ft *Tree) OpenPath(path string)

OpenPath opens a filetree at given directory path -- reads all the files at given path into this tree -- uses config children to preserve extra info already stored about files. Only paths listed in Dirs will be opened.

func (*Tree) RemoveExtFile

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

RemoveExtFile removes external file from maintained list, returns true if removed

func (*Tree) SetClass

func (t *Tree) SetClass(v string) *Tree

SetClass sets the [Tree.Class]

func (*Tree) SetCustomContextMenu

func (t *Tree) SetCustomContextMenu(v func(m *gi.Scene)) *Tree

SetCustomContextMenu sets the [Tree.CustomContextMenu]

func (*Tree) SetDirClosed

func (ft *Tree) SetDirClosed(fpath gi.FileName)

SetDirClosed sets the given directory path to be closed

func (*Tree) SetDirOpen

func (ft *Tree) SetDirOpen(fpath gi.FileName)

SetDirOpen sets the given directory path to be open

func (*Tree) SetDirSortBy

func (ft *Tree) SetDirSortBy(fpath gi.FileName, modTime bool)

SetDirSortBy sets the given directory path sort by option

func (*Tree) SetDirs

func (t *Tree) SetDirs(v DirFlagMap) *Tree

SetDirs sets the [Tree.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

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 view otherwise everything is mixed

func (*Tree) SetDoneWatcher

func (t *Tree) SetDoneWatcher(v chan bool) *Tree

SetDoneWatcher sets the [Tree.DoneWatcher]: channel to close watcher watcher

func (*Tree) SetExtFiles

func (t *Tree) SetExtFiles(v []string) *Tree

SetExtFiles sets the [Tree.ExtFiles]: external files outside the root path of the tree -- abs paths are stored -- these are shown in the first sub-node if present -- use AddExtFile to add and update

func (*Tree) SetIcon

func (t *Tree) SetIcon(v icons.Icon) *Tree

SetIcon sets the [Tree.Icon]

func (*Tree) SetInOpenAll

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

SetInOpenAll sets the [Tree.InOpenAll]: if true, we are in midst of an OpenAll call -- nodes should open all dirs

func (*Tree) SetIndent

func (t *Tree) SetIndent(v units.Value) *Tree

SetIndent sets the [Tree.Indent]

func (*Tree) SetLastWatchTime

func (t *Tree) SetLastWatchTime(v time.Time) *Tree

SetLastWatchTime sets the [Tree.LastWatchTime]: timestamp of last update

func (*Tree) SetLastWatchUpdt

func (t *Tree) SetLastWatchUpdt(v string) *Tree

SetLastWatchUpdt sets the [Tree.LastWatchUpdt]: last path updated by watcher

func (*Tree) SetNodeType

func (t *Tree) SetNodeType(v *gti.Type) *Tree

SetNodeType sets the [Tree.NodeType]: type of node to create -- defaults to giv.Node but can use custom node types

func (*Tree) SetOpenDepth

func (t *Tree) SetOpenDepth(v int) *Tree

SetOpenDepth sets the [Tree.OpenDepth]

func (*Tree) SetPriorityEvents

func (t *Tree) SetPriorityEvents(v []events.Types) *Tree

SetPriorityEvents sets the [Tree.PriorityEvents]

func (*Tree) SetRootView

func (t *Tree) SetRootView(v *giv.TreeView) *Tree

SetRootView sets the [Tree.RootView]

func (*Tree) SetSelectedNodes

func (t *Tree) SetSelectedNodes(v []giv.TreeViewer) *Tree

SetSelectedNodes sets the [Tree.SelectedNodes]

func (*Tree) SetText

func (t *Tree) SetText(v string) *Tree

SetText sets the [Tree.Text]

func (*Tree) SetTooltip

func (t *Tree) SetTooltip(v string) *Tree

SetTooltip sets the [Tree.Tooltip]

func (*Tree) SetUpdtMu

func (t *Tree) SetUpdtMu(v sync.Mutex) *Tree

SetUpdtMu sets the [Tree.UpdtMu]: Update mutex

func (*Tree) SetViewIdx

func (t *Tree) SetViewIdx(v int) *Tree

SetViewIdx sets the [Tree.ViewIdx]

func (*Tree) SetWatchedPaths

func (t *Tree) SetWatchedPaths(v map[string]bool) *Tree

SetWatchedPaths sets the [Tree.WatchedPaths]: map of paths that have been added to watcher -- only active if bool = true

func (*Tree) SetWatcher

func (t *Tree) SetWatcher(v *fsnotify.Watcher) *Tree

SetWatcher sets the [Tree.Watcher]: change notify for all dirs

func (*Tree) SetWidgetSize

func (t *Tree) SetWidgetSize(v mat32.Vec2) *Tree

SetWidgetSize sets the [Tree.WidgetSize]

func (*Tree) UnWatchPath

func (ft *Tree) UnWatchPath(path gi.FileName)

UnWatchPath removes given path from those watched

func (*Tree) UpdateAll

func (ft *Tree) UpdateAll()

UpdateAll does a full update of the tree -- calls ReadDir on current path

func (*Tree) UpdateExtFiles

func (ft *Tree) UpdateExtFiles(efn *Node)

UpdateExtFiles returns a type-and-name list for configuring nodes for ExtFiles

func (*Tree) UpdateNewFile

func (ft *Tree) UpdateNewFile(filename string)

UpdateNewFile should be called with path to a new file that has just been created -- will update view to show that file, and if that file doesn't exist, it updates the directory containing that file

func (*Tree) WatchPath

func (ft *Tree) WatchPath(path gi.FileName) error

WatchPath adds given path to those watched

func (*Tree) WatchUpdt

func (ft *Tree) WatchUpdt(path string)

WatchUpdt 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 VCSLogView

type VCSLogView struct {
	gi.Layout

	// current log
	Log vci.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 vci.Repo `json:"-" xml:"-" copy:"-"`

	// 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
}

VCSLogView is a view of the VCS log data

func NewVCSLogView

func NewVCSLogView(par ki.Ki, name ...string) *VCSLogView

NewVCSLogView adds a new VCSLogView with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.

func (*VCSLogView) ConfigRepo

func (lv *VCSLogView) ConfigRepo(repo vci.Repo, lg vci.Log, file, since string)

ConfigRepo configures to given repo, log and file (file could be empty)

func (*VCSLogView) ConfigToolbar

func (lv *VCSLogView) ConfigToolbar()

ConfigToolbar

func (*VCSLogView) KiType

func (t *VCSLogView) KiType() *gti.Type

KiType returns the *gti.Type of VCSLogView

func (*VCSLogView) New

func (t *VCSLogView) New() ki.Ki

New returns a new *VCSLogView value

func (*VCSLogView) OnInit

func (lv *VCSLogView) OnInit()

func (*VCSLogView) SetClass

func (t *VCSLogView) SetClass(v string) *VCSLogView

SetClass sets the [VCSLogView.Class]

func (*VCSLogView) SetCustomContextMenu

func (t *VCSLogView) SetCustomContextMenu(v func(m *gi.Scene)) *VCSLogView

SetCustomContextMenu sets the [VCSLogView.CustomContextMenu]

func (*VCSLogView) SetFile

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

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

func (*VCSLogView) SetLog

func (t *VCSLogView) SetLog(v vci.Log) *VCSLogView

SetLog sets the [VCSLogView.Log]: current log

func (*VCSLogView) SetPriorityEvents

func (t *VCSLogView) SetPriorityEvents(v []events.Types) *VCSLogView

SetPriorityEvents sets the [VCSLogView.PriorityEvents]

func (*VCSLogView) SetRepo

func (t *VCSLogView) SetRepo(v vci.Repo) *VCSLogView

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

func (*VCSLogView) SetRevA

func (lv *VCSLogView) SetRevA(rev string)

SetRevA sets the revision to use for buffer A

func (*VCSLogView) SetRevB

func (lv *VCSLogView) SetRevB(rev string)

SetRevB sets the revision to use for buffer B

func (*VCSLogView) SetSetA

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

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

func (*VCSLogView) SetSince

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

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

func (*VCSLogView) SetStackTop

func (t *VCSLogView) SetStackTop(v int) *VCSLogView

SetStackTop sets the [VCSLogView.StackTop]

func (*VCSLogView) SetTooltip

func (t *VCSLogView) SetTooltip(v string) *VCSLogView

SetTooltip sets the [VCSLogView.Tooltip]

func (*VCSLogView) TableView

func (lv *VCSLogView) TableView() *giv.TableView

TableView returns the tableview

func (*VCSLogView) ToggleRev

func (lv *VCSLogView) ToggleRev()

ToggleRev switches the active revision to set

func (*VCSLogView) Toolbar

func (lv *VCSLogView) Toolbar() *gi.Toolbar

Toolbar returns the toolbar

type VersCtrlName

type VersCtrlName string

VersCtrlName is the name of a version control system

func VersCtrlNameProper

func VersCtrlNameProper(vc string) VersCtrlName

func (VersCtrlName) String

func (vn VersCtrlName) String() string

func (VersCtrlName) Value

func (kn VersCtrlName) Value() giv.Value

Value registers VersCtrlValue as the viewer of VersCtrlName

type VersCtrlValue

type VersCtrlValue struct {
	giv.ValueBase
}

VersCtrlValue presents an action for displaying an VersCtrlName and selecting from StringPopup

func (*VersCtrlValue) ConfigWidget

func (vv *VersCtrlValue) ConfigWidget(w gi.Widget)

func (*VersCtrlValue) HasDialog

func (vv *VersCtrlValue) HasDialog() bool

func (*VersCtrlValue) OpenDialog

func (vv *VersCtrlValue) OpenDialog(ctx gi.Widget, fun func())

func (*VersCtrlValue) UpdateWidget

func (vv *VersCtrlValue) UpdateWidget()

func (*VersCtrlValue) WidgetType

func (vv *VersCtrlValue) WidgetType() *gti.Type

Jump to

Keyboard shortcuts

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