nav

package
v0.0.0-...-63b292e Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirState

type DirState struct {
	NavState
	// contains filtered or unexported fields
}

DirState represents the state of the directory

func (DirState) BackActive

func (d DirState) BackActive() bool

BackActive returns true if there is a back history

func (DirState) Entries

func (d DirState) Entries() []entry.Entry

Entries returns the directory entries

func (DirState) Error

func (d DirState) Error() error

Error returns the error or nil

func (DirState) ForwardActive

func (d DirState) ForwardActive() bool

ForwardActive returns true if there is a forward history

func (DirState) UpActive

func (d DirState) UpActive() bool

UpActive returns true if the current directory is not the root

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

func NewNav

func NewNav(showHidden bool, dirsMixed bool, startPath string, fsys afero.Fs, previewDelay int, dryRun bool) *Nav

NewNav creates a new Nav struct. The startPath is the path to start the navigation at. The fsys is the filesystem to use. The previewDelay is the delay in milliseconds before previewing a file. If dryRun is true, no changes will be made to the filesystem.

func (n *Nav) Back(currSelected []string, currCursor string) DirState

Back moves back in the history stack and returns a DirState struct

func (n *Nav) ClipboardCopy(selectedNames map[string]struct{}, cut bool)

ClipboardCopy sets the internal clipboard to the selected entries

func (n *Nav) CurrentPath() string

CurrentPath returns the path to the current directory of the navigation instance.

func (n *Nav) Delete(ctx context.Context, names []string) []error

Delete removes the files or directories with the given names from the current directory. If the Nav instance is in dry run mode, no files or directories will be removed. Returns a slice of errors encountered during the deletion process.

func (n *Nav) Forward(currSelected []string, currCursor string) DirState

Forward moves forward in the history stack and returns a DirState struct

func (n *Nav) GetPreview(ctx context.Context, path string) entry.Preview

GetPreview returns the preview for the file at the given path. The preview is generated using the Nav instance's PreviewHandler.

func (n *Nav) Go(path string, currCursor string, currSelected []string) DirState

Go changes the current directory to the given path and returns a Dirstate struct. If the path is "~", the home directory is used.

func (n *Nav) MkDir(ctx context.Context, name string) []error

MkDir creates a directory with the given name in the current directory. If the Nav instance is in dry run mode, no directory will be created. Returns a slice of errors encountered during the creation process.

func (n *Nav) MkFile(ctx context.Context, name string) []error

MkFile creates a file with the given name in the current directory. If the Nav instance is in dry run mode, no file will be created. Returns a slice of errors encountered during the creation process.

func (n *Nav) Reload(currSelected []string, currCursor string) DirState

Reload reads and returns the current directory contents

func (n *Nav) Rename(ctx context.Context, name, newName string) []error

Rename renames the file or directory with the given name to the given newName. If the Nav instance is in dry run mode, no files or directories will be renamed. Returns a slice of errors encountered during the rename process.

func (n *Nav) SetDirsMixed(dirsMixed bool)
func (n *Nav) SetShowHidden(showHidden bool)
func (n *Nav) ShowHidden() bool
type NavState struct {
	// contains filtered or unexported fields
}

NavState represents the state of the navigation within a directory

func (n NavState) Cursor() string

Cursor returns the cursor in the directory

func (n NavState) Path() string

Path returns the path to the directory of the NavState

func (n NavState) Selected() map[string]struct{}

Selected returns the selected items in the directory

type PreviewHandler

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

func NewPreviewHandler

func NewPreviewHandler(ctx context.Context, previewDelay int, maxBytes int, cacheSize int, pruneInterval time.Duration) *PreviewHandler

NewPreviewHandler creates a new PreviewHandler ctx is used to cancel periodic pruning of the cache previewDelay is the delay in milliseconds to wait before reading a file maxBytes is the maximum number of bytes to read from a file to form the preview cacheSize is the maximum number of previews to store in the cache pruneInterval is the interval at which to prune the cache

func (*PreviewHandler) GetPreview

func (ph *PreviewHandler) GetPreview(ctx context.Context, fsys afero.Fs, path string) entry.Preview

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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