filer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

Package filer draws directories and files and handles inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigFinder

func ConfigFinder(config func(*Finder) widget.Keymap)

ConfigFinder sets the finder keymap function.

func SetBorderStyle

func SetBorderStyle(style widget.BorderStyle)

SetBorderStyle sets a directory default border style.

func SetStatView

func SetStatView(size, permission, time bool)

SetStatView sets the file state view.

func SetTimeFormat

func SetTimeFormat(format string)

SetTimeFormat sets the time format of files.

func TogglePermView

func TogglePermView()

TogglePermView toggles the file permission view.

func TogglePriority

func TogglePriority()

TogglePriority toggles the priority for sorting files. The directory is prioritized in sorting if this is true.

func ToggleShowHiddens

func ToggleShowHiddens()

ToggleShowHiddens toggles the showing of hidden files.

func ToggleSizeView

func ToggleSizeView()

ToggleSizeView toggles the file size view.

func ToggleTimeView

func ToggleTimeView()

ToggleTimeView toggles the file time view.

Types

type Directory

type Directory struct {
	*widget.ListBox

	Path string   `json:"path"`
	Sort sortType `json:"sort_kind"`
	// contains filtered or unexported fields
}

Directory is a list box to store file stats.

func NewDirectory

func NewDirectory(x, y, width, height int) *Directory

NewDirectory creates a new directory based on specified size and coordinates.

func (*Directory) Base

func (d *Directory) Base() string

Base returns the directory name.

func (*Directory) Chdir

func (d *Directory) Chdir(path string)

Chdir changes the current directory and reads a new path by the default reader. Sets the cursor to the history name or to the previous directory name if parent destinats.

func (*Directory) EnterDir

func (d *Directory) EnterDir()

EnterDir changes the directory to a path on the cursor.

func (*Directory) File

func (d *Directory) File() *FileStat

File returns a file on the cursor.

func (*Directory) Finder

func (d *Directory) Finder()

Finder starts a finder in the directory for filtering files.

func (*Directory) Glob

func (d *Directory) Glob(pattern string)

Glob sets a reader to matching pattern in the current directory.

func (*Directory) Globdir

func (d *Directory) Globdir(pattern string)

Globdir sets a reader to matching pattern in the directory includeing sub directories.

func (*Directory) InvertMark

func (d *Directory) InvertMark()

InvertMark toggles all file marks.

func (*Directory) IsMark

func (d *Directory) IsMark() bool

IsMark reports whether even one file marked.

func (*Directory) Less

func (d *Directory) Less(i, j int) bool

Less compares based on Sort.

func (*Directory) MarkClear

func (d *Directory) MarkClear()

MarkClear clears all file marks.

func (*Directory) MarkCount

func (d *Directory) MarkCount() int

MarkCount returns a number of marked files.

func (*Directory) MarkfileNames

func (d *Directory) MarkfileNames() []string

MarkfileNames returns marked file names.

func (*Directory) MarkfilePaths

func (d *Directory) MarkfilePaths() []string

MarkfilePaths returns marked file paths.

func (*Directory) MarkfileQuotedNames

func (d *Directory) MarkfileQuotedNames() []string

MarkfileQuotedNames returns quoted file names for marked.

func (*Directory) MarkfileQuotedPaths

func (d *Directory) MarkfileQuotedPaths() []string

MarkfileQuotedPaths returns quoted file paths for marked.

func (*Directory) Markfiles

func (d *Directory) Markfiles() []*FileStat

Markfiles returns marked file lists.

func (*Directory) Reset

func (d *Directory) Reset()

Reset marking or reader.

func (*Directory) Resize

func (d *Directory) Resize(x, y, width, height int)

Resize the window and the finder.

func (*Directory) SortExt

func (d *Directory) SortExt()

SortExt sorts files in ascending order by the file extension.

func (*Directory) SortExtDec

func (d *Directory) SortExtDec()

SortExtDec sorts files in descending order by the file extension.

func (*Directory) SortMtime

func (d *Directory) SortMtime()

SortMtime sorts files in ascending order by the modified time.

func (*Directory) SortMtimeDec

func (d *Directory) SortMtimeDec()

SortMtimeDec sorts files in descending order by the modified time.

func (*Directory) SortName

func (d *Directory) SortName()

SortName sorts files in ascending order by the file name.

func (*Directory) SortNameDec

func (d *Directory) SortNameDec()

SortNameDec sorts files in descending order by the file name.

func (*Directory) SortSize

func (d *Directory) SortSize()

SortSize sorts files in ascending order by the file size.

func (*Directory) SortSizeDec

func (d *Directory) SortSizeDec()

SortSizeDec sorts files in descending order by the file size.

func (*Directory) ToggleMark

func (d *Directory) ToggleMark()

ToggleMark toggles the file mark on the cursor.

type FileStat

type FileStat struct {
	os.FileInfo // os.Lstat(path)
	// contains filtered or unexported fields
}

FileStat is file information.

func NewFileStat

func NewFileStat(dir string, name string) *FileStat

NewFileStat creates a new file stat of the file in the directory.

func (*FileStat) Draw

func (f *FileStat) Draw(x, y, width int, focus bool)

Draw the file name and file stats.

func (*FileStat) Ext

func (f *FileStat) Ext() string

Ext retruns the file extension.

func (*FileStat) IsCharDevice

func (f *FileStat) IsCharDevice() bool

IsCharDevice reports whether the character device file.

func (*FileStat) IsDevice

func (f *FileStat) IsDevice() bool

IsDevice reports whether the device file.

func (*FileStat) IsExec

func (f *FileStat) IsExec() bool

IsExec reports whether the executable file.

func (*FileStat) IsFIFO

func (f *FileStat) IsFIFO() bool

IsFIFO reports whether the named pipe file.

func (f *FileStat) IsLink() bool

IsLink reports whether the symlink.

func (*FileStat) IsMarked

func (f *FileStat) IsMarked() bool

IsMarked reports whether the marked file.

func (*FileStat) IsSocket

func (f *FileStat) IsSocket() bool

IsSocket reports whether the socket file.

func (*FileStat) Mark

func (f *FileStat) Mark()

Mark the file.

func (*FileStat) Markoff

func (f *FileStat) Markoff()

Markoff the file.

func (*FileStat) Name

func (f *FileStat) Name() string

Name returns the file name.

func (*FileStat) Path

func (f *FileStat) Path() string

Path returns the file path.

func (*FileStat) ResetDisplay

func (f *FileStat) ResetDisplay()

ResetDisplay resets the display name to the file name.

func (*FileStat) SetDisplay

func (f *FileStat) SetDisplay(name string)

SetDisplay sets the display name for drawing.

func (*FileStat) ToggleMark

func (f *FileStat) ToggleMark()

ToggleMark toggles the file mark.

type Filer

type Filer struct {
	*widget.Window

	Workspaces []*Workspace `json:"workspaces"`
	Current    int          `json:"current"`
	// contains filtered or unexported fields
}

Filer is a file manager with workspaces to layout directorires to list files.

func New

func New(x, y, width, height int) *Filer

New creates a new filer based on specified size and coordinates. Creates five workspaces and default path is home directory.

func NewFromState

func NewFromState(path string, x, y, width, height int) *Filer

NewFromState creates a new filer form the state json file.

func (*Filer) AddExtmap

func (f *Filer) AddExtmap(a ...interface{})

AddExtmap adds to the filer extmap.

func (*Filer) AddKeymap

func (f *Filer) AddKeymap(keys ...interface{})

AddKeymap adds to the filer keymap.

func (*Filer) CloseWorkspace

func (f *Filer) CloseWorkspace()

CloseWorkspace closes a workspace on the current.

func (*Filer) CreateWorkspace

func (f *Filer) CreateWorkspace()

CreateWorkspace creates and adds a workspace to the end.

func (*Filer) Dir

func (f *Filer) Dir() *Directory

Dir returns the focused directory on the current workspace.

func (*Filer) Draw

func (f *Filer) Draw()

Draw the current workspace.

func (*Filer) File

func (f *Filer) File() *FileStat

File returns the cursor file in the focused directory on the current workspace.

func (*Filer) Input

func (f *Filer) Input(key string)

Input for key events.

func (*Filer) MergeExtmap

func (f *Filer) MergeExtmap(m widget.Extmap)

MergeExtmap merges to the filer extmap.

func (*Filer) MergeKeymap

func (f *Filer) MergeKeymap(m widget.Keymap)

MergeKeymap merges to the filer keymap.

func (*Filer) MoveWorkspace

func (f *Filer) MoveWorkspace(amount int)

MoveWorkspace moves to the other workspace.

func (*Filer) Resize

func (f *Filer) Resize(x, y, width, height int)

Resize all workspaces.

func (*Filer) ResizeRelative

func (f *Filer) ResizeRelative(x, y, width, height int)

ResizeRelative resize relative to current sizes.

func (*Filer) SaveState

func (f *Filer) SaveState(path string) error

SaveState saves the filer state to the file.

func (*Filer) Workspace

func (f *Filer) Workspace() *Workspace

Workspace returns the current workspace.

type Finder

type Finder struct {
	*widget.TextBox
	// contains filtered or unexported fields
}

Finder represents textbox for filtering files in the directory.

func NewFinder

func NewFinder(dir *Directory, x, y, width, height int) *Finder

NewFinder returns a new finder to position the directory bottom.

func (*Finder) Draw

func (f *Finder) Draw(focus bool)

Draw the finder and show a cursor if focus is true.

func (*Finder) Exit

func (f *Finder) Exit()

Exit the finder and reload the directory to clear filtering.

func (*Finder) MoveHistory

func (f *Finder) MoveHistory(amount int)

MoveHistory moves histories with specified amounts and sets to textbox.

type Workspace

type Workspace struct {
	*widget.Window
	Dirs   []*Directory `json:"directories"`
	Layout layoutType   `json:"layout"`
	Title  string       `json:"title"`
	Focus  int          `json:"focus"`
}

Workspace is a box storing and layouting directories.

func NewWorkspace

func NewWorkspace(x, y, width, height int, title string) *Workspace

NewWorkspace returns a new workspace of specified sizes.

func (*Workspace) ChdirNeighbor

func (w *Workspace) ChdirNeighbor()

ChdirNeighbor changes the focused path a neighbor directory path.

func (*Workspace) CloseDir

func (w *Workspace) CloseDir()

CloseDir closes the focused directory.

func (*Workspace) CreateDir

func (w *Workspace) CreateDir()

CreateDir adds the home directory to the head.

func (*Workspace) Dir

func (w *Workspace) Dir() *Directory

Dir returns the focused directory.

func (*Workspace) Draw

func (w *Workspace) Draw()

Draw all directories and hide a cursor if all finders not active.

func (*Workspace) LayoutFullscreen

func (w *Workspace) LayoutFullscreen()

LayoutFullscreen allocates to the full screen layout.

func (*Workspace) LayoutOnecolumn

func (w *Workspace) LayoutOnecolumn()

LayoutOnecolumn allocates to the one column layout.

func (*Workspace) LayoutOnerow

func (w *Workspace) LayoutOnerow()

LayoutOnerow allocates to the one line layout.

func (*Workspace) LayoutTile

func (w *Workspace) LayoutTile()

LayoutTile allocates to the tile layout.

func (*Workspace) LayoutTileBottom

func (w *Workspace) LayoutTileBottom()

LayoutTileBottom allocates to the tile bottom layout.

func (*Workspace) LayoutTileTop

func (w *Workspace) LayoutTileTop()

LayoutTileTop allocates to the tile top layout.

func (*Workspace) MoveFocus

func (w *Workspace) MoveFocus(amount int)

MoveFocus moves the focus with specified amounts.

func (*Workspace) NextDir

func (w *Workspace) NextDir() *Directory

NextDir returns the next directory.

func (*Workspace) PrevDir

func (w *Workspace) PrevDir() *Directory

PrevDir returns the previous directory.

func (*Workspace) ReloadAll

func (w *Workspace) ReloadAll()

ReloadAll reloads all directories.

func (*Workspace) Resize

func (w *Workspace) Resize(x, y, width, height int)

Resize and layout allocates.

func (*Workspace) ResizeRelative

func (w *Workspace) ResizeRelative(x, y, width, height int)

ResizeRelative relative resizes and layout allocates.

func (*Workspace) SetFocus

func (w *Workspace) SetFocus(x int)

SetFocus sets the focus to a specified position.

func (*Workspace) SetTitle

func (w *Workspace) SetTitle(title string)

SetTitle sets the workspace title.

func (*Workspace) SwapNextDir

func (w *Workspace) SwapNextDir()

SwapNextDir swaps focus and next directories.

func (*Workspace) SwapPrevDir

func (w *Workspace) SwapPrevDir()

SwapPrevDir swaps focus and previous directories.

Jump to

Keyboard shortcuts

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