gui

package
v0.0.0-...-a39e74b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetCwd       = errors.New("can't get current dir")
	ErrEdit         = errors.New("can't edit")
	ErrReadFile     = errors.New("can't read file")
	ErrReadDir      = errors.New("can't read dir")
	ErrTokenise     = errors.New("can't tokenise")
	ErrGetTime      = errors.New("can't get timespec")
	ErrNoPathName   = errors.New("no path name")
	ErrNotExistPath = errors.New("not exist path")
	ErrNoEditor     = errors.New("$EDITOR is empty")
)
View Source
var (
	ErrNoDirName       = errors.New("no directory name")
	ErrNoFileName      = errors.New("no file name")
	ErrNoFileOrDirName = errors.New("no file or directory name")
	ErrNoFileOrDir     = errors.New("no file or directory")
	ErrNoNewName       = errors.New("no new name")
)

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	ID   int
	Name string
}

type BookmarkConfig

type BookmarkConfig struct {
	Enable bool   `yaml:"enable"`
	File   string `yaml:"file"`
	Log    bool   `yaml:"log"`
}

type BookmarkStore

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

func NewBookmarkStore

func NewBookmarkStore(file string) (*BookmarkStore, error)

func (*BookmarkStore) Delete

func (b *BookmarkStore) Delete(id int) error

func (*BookmarkStore) HasBookmark

func (b *BookmarkStore) HasBookmark(name string) bool

func (*BookmarkStore) Load

func (b *BookmarkStore) Load() ([]Bookmark, error)

func (*BookmarkStore) Save

func (b *BookmarkStore) Save(bookmark Bookmark) error

type Bookmarks

type Bookmarks struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewBookmark

func NewBookmark(config Config) (*Bookmarks, error)

func (*Bookmarks) Add

func (b *Bookmarks) Add(name string) error

func (*Bookmarks) AddBookmark

func (b *Bookmarks) AddBookmark(gui *Gui)

func (*Bookmarks) BookmarkKeybinding

func (b *Bookmarks) BookmarkKeybinding(gui *Gui)

func (*Bookmarks) CloseBookmark

func (b *Bookmarks) CloseBookmark(gui *Gui)

func (*Bookmarks) Delete

func (b *Bookmarks) Delete(id int) error

func (*Bookmarks) GetSearchWord

func (b *Bookmarks) GetSearchWord() string

func (*Bookmarks) GetSelectEntry

func (b *Bookmarks) GetSelectEntry() *Bookmark

func (*Bookmarks) SearchBookmark

func (e *Bookmarks) SearchBookmark(gui *Gui)

func (*Bookmarks) SetSearchWord

func (b *Bookmarks) SetSearchWord(word string)

func (*Bookmarks) Update

func (b *Bookmarks) Update() error

func (*Bookmarks) UpdateView

func (b *Bookmarks) UpdateView() error

type Config

type Config struct {
	ConfigDir  string
	ConfigFile string
	Log        LogConfig      `yaml:"log"`
	Preview    PreviewConfig  `yaml:"preview"`
	Bookmark   BookmarkConfig `yaml:"bookmark"`
	IgnoreCase bool           `yaml:"ignore_case"`
	OpenCmd    string         `yaml:"open_cmd"`
	EnableTree bool           `yaml:"enable_tree"`
	ShowHidden bool           `yaml:"show_hidden"`
}

func DefaultConfig

func DefaultConfig() Config

type DBLogger

type DBLogger struct{}

func (DBLogger) Print

func (d DBLogger) Print(v ...interface{})

type File

type File struct {
	Name       string // file name
	Path       string // file path
	PathName   string // file's path and name
	Access     string
	Create     string
	Change     string
	Size       int64
	Permission string
	Owner      string
	Group      string
	Viewable   bool
	IsDir      bool
}

File file or dir info

func GetFiles

func GetFiles(path, searchWord string, ignorecase, showHidden bool) []*File

type FileBrowser

type FileBrowser interface {
	tview.Primitive
	GetSearchWord() string
	SetSearchWord(word string)
	SearchFiles(gui *Gui)
	UpdateView()
	GetSelectEntry() *File
	SetEntries(path string) []*File
	ChangeDir(gui *Gui, current, target string) error
	Keybinding(gui *Gui)
}

type FileTable

type FileTable struct {
	*tview.Table
	// contains filtered or unexported fields
}

FileTable file list

func NewFileTable

func NewFileTable(enableIgnorecase, showHidden bool) *FileTable

NewFileTable new entry list

func (*FileTable) ChangeDir

func (e *FileTable) ChangeDir(gui *Gui, current, target string) error

func (*FileTable) Entries

func (e *FileTable) Entries() []*File

Entries get entries

func (*FileTable) GetSearchWord

func (e *FileTable) GetSearchWord() string

func (*FileTable) GetSelectEntry

func (e *FileTable) GetSelectEntry() *File

GetSelectEntry get selected entry

func (*FileTable) Keybinding

func (e *FileTable) Keybinding(gui *Gui)

func (*FileTable) RefreshView

func (e *FileTable) RefreshView()

func (*FileTable) RestorePos

func (e *FileTable) RestorePos(path string)

RestorePos restore select position

func (*FileTable) SearchFiles

func (e *FileTable) SearchFiles(gui *Gui)

func (*FileTable) SetColumns

func (e *FileTable) SetColumns()

SetColumns set entries

func (*FileTable) SetEntries

func (e *FileTable) SetEntries(path string) []*File

SetEntries set entries

func (*FileTable) SetHeader

func (e *FileTable) SetHeader()

SetHeader set table header

func (*FileTable) SetSearchWord

func (e *FileTable) SetSearchWord(word string)

func (*FileTable) SetSelectPos

func (e *FileTable) SetSelectPos(path string)

SetSelectPos save select position

func (*FileTable) SetViewable

func (e *FileTable) SetViewable(viewable bool)

func (*FileTable) UpdateColor

func (e *FileTable) UpdateColor()

func (*FileTable) UpdateView

func (e *FileTable) UpdateView()

type Gui

type Gui struct {
	CurrentPanel   Panel
	Config         Config
	InputPath      *tview.InputField
	Register       *Register
	HistoryManager *HistoryManager
	FileBrowser    FileBrowser
	Preview        *Preview
	Bookmark       *Bookmarks
	Help           *Help
	App            *tview.Application
	Pages          *tview.Pages
	// contains filtered or unexported fields
}

Gui gui have some manager

func New

func New(config Config) *Gui

New create new gui

func (*Gui) Confirm

func (gui *Gui) Confirm(message, doneLabel string, panel Panel, doneFunc func() error)

func (*Gui) EditFile

func (gui *Gui) EditFile(file string) error

func (*Gui) ExecCmd

func (gui *Gui) ExecCmd(attachStd bool, cmd string, args ...string) error

ExecCmd execute command

func (*Gui) FocusPanel

func (gui *Gui) FocusPanel(panel Panel)

func (*Gui) Form

func (gui *Gui) Form(fieldLabel map[string]string, doneLabel, title, pageName string, panel Panel,
	height int, doneFunc func(values map[string]string) error)

func (*Gui) InputPathKeybinding

func (gui *Gui) InputPathKeybinding()

func (*Gui) Message

func (gui *Gui) Message(message string, panel Panel)

func (*Gui) Modal

func (gui *Gui) Modal(p tview.Primitive, width, height int) tview.Primitive

func (*Gui) Run

func (gui *Gui) Run() error

Run run ff

func (*Gui) SetKeybindings

func (gui *Gui) SetKeybindings()

func (*Gui) Stop

func (gui *Gui) Stop()

Stop stop ff

type Help

type Help struct {
	*tview.Table
}

func NewHelp

func NewHelp() *Help

func (*Help) Keybinding

func (h *Help) Keybinding(gui *Gui)

func (*Help) UpdateView

func (h *Help) UpdateView(panel Panel)

type History

type History struct {
	RowIdx int
	Path   string
}

History history info

type HistoryManager

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

HistoryManager have the move history TODO limit max history

func NewHistoryManager

func NewHistoryManager() *HistoryManager

NewHistoryManager new history manager

func (*HistoryManager) Next

func (h *HistoryManager) Next() *History

Next return the next history

func (*HistoryManager) Previous

func (h *HistoryManager) Previous() *History

Previous return the previous history

func (*HistoryManager) Save

func (h *HistoryManager) Save(rowIdx int, path string)

Save save the move history

type LogConfig

type LogConfig struct {
	Enable bool   `yaml:"enable"`
	File   string `yaml:"file"`
}

type Panel

type Panel int
const (
	PathPanel Panel = iota + 1
	FileTablePanel
	FileTreePanel
	BookmarkPanel
)

type Preview

type Preview struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func NewPreview

func NewPreview(colorscheme string) *Preview

func (*Preview) Highlight

func (p *Preview) Highlight(entry *File) string

func (*Preview) ScrollDown

func (p *Preview) ScrollDown()

func (*Preview) ScrollUp

func (p *Preview) ScrollUp()

func (*Preview) UpdateView

func (p *Preview) UpdateView(g *Gui, entry *File)

type PreviewConfig

type PreviewConfig struct {
	Enable      bool   `yaml:"enable"`
	Colorscheme string `yaml:"colorscheme"`
}

type Register

type Register struct {
	MoveSources []*File
	CopySources []*File
	CopySource  *File
	MoveSource  *File
}

Register copy/paste file resource

func (*Register) ClearCopyResources

func (r *Register) ClearCopyResources()

ClearCopyResources clear resouces

func (*Register) ClearMoveResources

func (r *Register) ClearMoveResources()

ClearMoveResources clear resources

type Tree

type Tree struct {
	*tview.TreeView
	// contains filtered or unexported fields
}

func NewTree

func NewTree(ignorecase, showHidden bool) *Tree

func (*Tree) AddNode

func (t *Tree) AddNode(parent *tview.TreeNode, files []*File)

func (*Tree) ChangeDir

func (t *Tree) ChangeDir(gui *Gui, current string, target string) error

func (*Tree) GetCurrentlyNode

func (t *Tree) GetCurrentlyNode(oldpath string, target *tview.TreeNode) *tview.TreeNode

func (*Tree) GetSearchWord

func (t *Tree) GetSearchWord() string

func (*Tree) GetSelectEntry

func (t *Tree) GetSelectEntry() *File

func (*Tree) Keybinding

func (t *Tree) Keybinding(gui *Gui)

func (*Tree) RestorePos

func (t *Tree) RestorePos(path string)

func (*Tree) SearchFiles

func (t *Tree) SearchFiles(gui *Gui)

func (*Tree) SetEntries

func (t *Tree) SetEntries(path string) []*File

func (*Tree) SetSearchWord

func (t *Tree) SetSearchWord(word string)

func (*Tree) SetSelectPos

func (t *Tree) SetSelectPos(path string)

func (*Tree) UpdateView

func (t *Tree) UpdateView()

Jump to

Keyboard shortcuts

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