filetree

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C = layout.Context

type D

type D = layout.Dimensions

type EntryNavItem

type EntryNavItem struct {
	// contains filtered or unexported fields
}

func NewEntryNavItem

func NewEntryNavItem(rootDir string, skipFolders []string, menuOptionFunc MenuOptionFunc, onSelectFunc OnSelectFunc) *EntryNavItem

Construct a file tree object that loads files and folders from rootDir. `skipFolders` allows you to specify folder name prefixes to exclude from the navigation. `menuOptionFunc` is used to define the operations allowed by context menu(use right click to active it). `onSelectFunc` defines what action to take when a navigable item is clicked (files or folders).

func (*EntryNavItem) Children

func (eitem *EntryNavItem) Children() []navi.NavItem

func (*EntryNavItem) ContextMenuOptions

func (eitem *EntryNavItem) ContextMenuOptions(gtx C) ([][]menu.MenuOption, bool)

func (*EntryNavItem) CreateChild

func (eitem *EntryNavItem) CreateChild(gtx C, kind NodeKind) error

Create file or subfolder under the current folder. File or subfolder is inserted at the beginning of the children.

func (*EntryNavItem) Icon

func (eitem *EntryNavItem) Icon() *widget.Icon

func (*EntryNavItem) IsDir

func (eitem *EntryNavItem) IsDir() bool

func (*EntryNavItem) IsEditing

func (eitem *EntryNavItem) IsEditing(gtx C) bool

IsEditing is used to indicate the current node is being edited.

func (*EntryNavItem) Kind

func (eitem *EntryNavItem) Kind() NodeKind

EntryNode kind of this node

func (*EntryNavItem) Layout

func (eitem *EntryNavItem) Layout(gtx layout.Context, th *theme.Theme, textColor color.NRGBA) D

func (*EntryNavItem) Name

func (eitem *EntryNavItem) Name() string

File or folder name of this node

func (*EntryNavItem) OnSelect

func (eitem *EntryNavItem) OnSelect(gtx C) view.Intent

func (*EntryNavItem) Path

func (eitem *EntryNavItem) Path() string

File or folder path of this node

func (*EntryNavItem) Remove

func (eitem *EntryNavItem) Remove() error

func (*EntryNavItem) SetMenuOptions

func (eitem *EntryNavItem) SetMenuOptions(menuOptionFunc MenuOptionFunc)

func (*EntryNavItem) StartEditing

func (eitem *EntryNavItem) StartEditing(gtx C)

StartEditing inits and focused on the editor to accept user input.

type EntryNode

type EntryNode struct {
	Path string
	Kind NodeKind
	// parent must be of folder kind.
	Parent   *EntryNode
	Children []*EntryNode
	// contains filtered or unexported fields
}

func NewFileTree

func NewFileTree(rootDir string, skipPatterns []string, lazyLoad bool) (*EntryNode, error)

Create a new file tree with a relative or absolute rootDir. Folders matching prefix in any of the skipPatterns will be skipped.

func (*EntryNode) AddChild

func (n *EntryNode) AddChild(name string, kind NodeKind) error

Add new file or folder.

func (*EntryNode) Delete

func (n *EntryNode) Delete(onlyEmptyDir bool) error

Delete removes the current file/folders. If onlyEmptyDir is set, Delete stops removing non-empty dir if n is a folder node and returns an error. TODO: only empty dir is allowed to be removed for now. May add support for removing to recyle bin.

func (*EntryNode) FileType

func (n *EntryNode) FileType() string

what type of the file, e.g, pdf, png。 This is for file nodes only

func (*EntryNode) Name

func (n *EntryNode) Name() string

func (*EntryNode) Print

func (n *EntryNode) Print()

Print the entire tree in console.

func (*EntryNode) Refresh

func (n *EntryNode) Refresh() error

Refresh reload child entries of the current entry node

func (*EntryNode) UpdateName

func (n *EntryNode) UpdateName(newName string) error

Update set a new name for the current file/folder.

type FileTreeNav

type FileTreeNav struct {
	// contains filtered or unexported fields
}

func NewFileTreeNav

func NewFileTreeNav(drawer *navi.NavDrawer, title string, navRoot *EntryNavItem) *FileTreeNav

Construct a FileTreeNav object that loads files and folders from rootDir. The skipFolders parameter allows you to specify folder name prefixes to exclude from the navigation.

func (*FileTreeNav) Attach

func (tn *FileTreeNav) Attach(drawer *navi.NavDrawer)

func (*FileTreeNav) Layout

func (tn *FileTreeNav) Layout(gtx C, th *theme.Theme) D

func (*FileTreeNav) Title

func (tn *FileTreeNav) Title() string
type MenuOptionFunc func(gtx C, item *EntryNavItem) [][]menu.MenuOption

func DefaultFileMenuOptions

func DefaultFileMenuOptions(vm view.ViewManager) MenuOptionFunc

Default operation for file tree nodes. Support file/folder copy, cut, paste, rename, delete and new file/folder creation.

type NodeKind

type NodeKind uint8
const (
	FileNode NodeKind = iota
	FolderNode
)

type OnSelectFunc

type OnSelectFunc func(gtx C, item *EntryNode) view.Intent

Jump to

Keyboard shortcuts

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