ui

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Controllers struct {
	Tree    *FileTreeController
	Layer   *LayerController
	Status  *StatusController
	Filter  *FilterController
	Details *DetailsController
	// contains filtered or unexported fields
}

Controllers contains all rendered UI panes.

View Source
var Formatting struct {
	Header                func(...interface{}) string
	Selected              func(...interface{}) string
	StatusSelected        func(...interface{}) string
	StatusNormal          func(...interface{}) string
	StatusControlSelected func(...interface{}) string
	StatusControlNormal   func(...interface{}) string
	CompareTop            func(...interface{}) string
	CompareBottom         func(...interface{}) string
}

Formatting defines standard functions for formatting UI sections.

View Source
var GlobalKeybindings struct {
	// contains filtered or unexported fields
}

Functions

func CursorDown

func CursorDown(g *gocui.Gui, v *gocui.View) error

CursorDown moves the cursor down in the currently selected gocui pane, scrolling the screen as needed.

func CursorStep added in v0.7.0

func CursorStep(g *gocui.Gui, v *gocui.View, step int) error

Moves the cursor the given step distance, setting the origin to the new cursor line

func CursorUp

func CursorUp(g *gocui.Gui, v *gocui.View) error

CursorUp moves the cursor up in the currently selected gocui pane, scrolling the screen as needed.

func Render

func Render()

Render flushes the state objects to the screen.

func Run

func Run(analysis *image.AnalysisResult, cache filetree.TreeCache)

Run is the UI entrypoint.

func Update

func Update()

Update refreshes the state objects for future rendering.

Types

type CompareType

type CompareType int
const (
	CompareLayer CompareType = iota
	CompareAll
)

type DetailsController added in v0.7.0

type DetailsController struct {
	Name string
	// contains filtered or unexported fields
}

DetailsController holds the UI objects and data models for populating the lower-left pane. Specifically the pane that shows the layer details and image statistics.

func NewDetailsController added in v0.7.0

func NewDetailsController(name string, gui *gocui.Gui, efficiency float64, inefficiencies filetree.EfficiencySlice) (controller *DetailsController)

NewDetailsController creates a new view object attached the the global gocui screen object.

func (*DetailsController) CursorDown added in v0.7.0

func (controller *DetailsController) CursorDown() error

CursorDown moves the cursor down in the details pane (currently indicates nothing).

func (*DetailsController) CursorUp added in v0.7.0

func (controller *DetailsController) CursorUp() error

CursorUp moves the cursor up in the details pane (currently indicates nothing).

func (*DetailsController) IsVisible added in v0.7.0

func (controller *DetailsController) IsVisible() bool

IsVisible indicates if the details view pane is currently initialized.

func (*DetailsController) KeyHelp added in v0.7.0

func (controller *DetailsController) KeyHelp() string

KeyHelp indicates all the possible actions a user can take while the current pane is selected (currently does nothing).

func (*DetailsController) Render added in v0.7.0

func (controller *DetailsController) Render() error

Render flushes the state objects to the screen. The details pane reports: 1. the current selected layer's command string 2. the image efficiency score 3. the estimated wasted image space 4. a list of inefficient file allocations

func (*DetailsController) Setup added in v0.7.0

func (controller *DetailsController) Setup(v *gocui.View, header *gocui.View) error

Setup initializes the UI concerns within the context of a global gocui view object.

func (*DetailsController) Update added in v0.7.0

func (controller *DetailsController) Update() error

Update refreshes the state objects for future rendering.

type FileTreeController added in v0.7.0

type FileTreeController struct {
	Name string
	// contains filtered or unexported fields
}

FileTreeController holds the UI objects and data models for populating the right pane. Specifically the pane that shows selected layer or aggregate file ASCII tree.

func NewFileTreeController added in v0.7.0

func NewFileTreeController(name string, gui *gocui.Gui, tree *filetree.FileTree, refTrees []*filetree.FileTree, cache filetree.TreeCache) (controller *FileTreeController)

NewFileTreeController creates a new view object attached the the global gocui screen object.

func (*FileTreeController) CursorDown added in v0.7.0

func (controller *FileTreeController) CursorDown() error

CursorDown moves the cursor down and renders the view. Note: we cannot use the gocui buffer since any state change requires writing the entire tree to the buffer. Instead we are keeping an upper and lower bounds of the tree string to render and only flushing this range into the view buffer. This is much faster when tree sizes are large.

func (*FileTreeController) CursorLeft added in v0.7.0

func (controller *FileTreeController) CursorLeft() error

CursorLeft moves the cursor up until we reach the Parent Node or top of the tree

func (*FileTreeController) CursorRight added in v0.7.0

func (controller *FileTreeController) CursorRight() error

CursorRight descends into directory expanding it if needed

func (*FileTreeController) CursorUp added in v0.7.0

func (controller *FileTreeController) CursorUp() error

CursorUp moves the cursor up and renders the view. Note: we cannot use the gocui buffer since any state change requires writing the entire tree to the buffer. Instead we are keeping an upper and lower bounds of the tree string to render and only flushing this range into the view buffer. This is much faster when tree sizes are large.

func (*FileTreeController) IsVisible added in v0.7.0

func (controller *FileTreeController) IsVisible() bool

IsVisible indicates if the file tree view pane is currently initialized

func (*FileTreeController) KeyHelp added in v0.7.0

func (controller *FileTreeController) KeyHelp() string

KeyHelp indicates all the possible actions a user can take while the current pane is selected.

func (*FileTreeController) PageDown added in v0.7.0

func (controller *FileTreeController) PageDown() error

PageDown moves to next page putting the cursor on top

func (*FileTreeController) PageUp added in v0.7.0

func (controller *FileTreeController) PageUp() error

PageUp moves to previous page putting the cursor on top

func (*FileTreeController) Render added in v0.7.0

func (controller *FileTreeController) Render() error

Render flushes the state objects (file tree) to the pane.

func (*FileTreeController) Setup added in v0.7.0

func (controller *FileTreeController) Setup(v *gocui.View, header *gocui.View) error

Setup initializes the UI concerns within the context of a global gocui view object.

func (*FileTreeController) Update added in v0.7.0

func (controller *FileTreeController) Update() error

Update refreshes the state objects for future rendering.

type FileTreeViewModel added in v0.7.0

type FileTreeViewModel struct {
	ModelTree *filetree.FileTree
	ViewTree  *filetree.FileTree
	RefTrees  []*filetree.FileTree

	CollapseAll     bool
	ShowAttributes  bool
	HiddenDiffTypes []bool
	TreeIndex       int
	// contains filtered or unexported fields
}

FileTreeViewModel holds the UI objects and data models for populating the right pane. Specifically the pane that shows selected layer or aggregate file ASCII tree.

func NewFileTreeViewModel added in v0.7.0

func NewFileTreeViewModel(tree *filetree.FileTree, refTrees []*filetree.FileTree, cache filetree.TreeCache) (treeViewModel *FileTreeViewModel)

NewFileTreeController creates a new view object attached the the global gocui screen object.

func (*FileTreeViewModel) CursorDown added in v0.7.0

func (vm *FileTreeViewModel) CursorDown() bool

doCursorDown performs the internal view's buffer adjustments on cursor down. Note: this is independent of the gocui buffer.

func (*FileTreeViewModel) CursorLeft added in v0.7.0

func (vm *FileTreeViewModel) CursorLeft(filterRegex *regexp.Regexp) error

CursorLeft moves the cursor up until we reach the Parent Node or top of the tree

func (*FileTreeViewModel) CursorRight added in v0.7.0

func (vm *FileTreeViewModel) CursorRight(filterRegex *regexp.Regexp) error

CursorRight descends into directory expanding it if needed

func (*FileTreeViewModel) CursorUp added in v0.7.0

func (vm *FileTreeViewModel) CursorUp() bool

doCursorUp performs the internal view's buffer adjustments on cursor up. Note: this is independent of the gocui buffer.

func (*FileTreeViewModel) IsVisible added in v0.7.0

func (vm *FileTreeViewModel) IsVisible() bool

IsVisible indicates if the file tree view pane is currently initialized

func (*FileTreeViewModel) PageDown added in v0.7.0

func (vm *FileTreeViewModel) PageDown() error

PageDown moves to next page putting the cursor on top

func (*FileTreeViewModel) PageUp added in v0.7.0

func (vm *FileTreeViewModel) PageUp() error

PageUp moves to previous page putting the cursor on top

func (*FileTreeViewModel) Render added in v0.7.0

func (vm *FileTreeViewModel) Render() error

Render flushes the state objects (file tree) to the pane.

func (*FileTreeViewModel) Setup added in v0.7.0

func (vm *FileTreeViewModel) Setup(lowerBound, height int)

Setup initializes the UI concerns within the context of a global gocui view object.

func (*FileTreeViewModel) Update added in v0.7.0

func (vm *FileTreeViewModel) Update(filterRegex *regexp.Regexp, width, height int) error

Update refreshes the state objects for future rendering.

type FilterController added in v0.7.0

type FilterController struct {
	Name string
	// contains filtered or unexported fields
}

FilterController holds the UI objects and data models for populating the bottom row. Specifically the pane that allows the user to filter the file tree by path.

func NewFilterController added in v0.7.0

func NewFilterController(name string, gui *gocui.Gui) (controller *FilterController)

NewFilterController creates a new view object attached the the global gocui screen object.

func (*FilterController) CursorDown added in v0.7.0

func (controller *FilterController) CursorDown() error

CursorDown moves the cursor down in the filter pane (currently indicates nothing).

func (*FilterController) CursorUp added in v0.7.0

func (controller *FilterController) CursorUp() error

CursorUp moves the cursor up in the filter pane (currently indicates nothing).

func (*FilterController) Edit added in v0.7.0

func (controller *FilterController) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier)

Edit intercepts the key press events in the filer view to update the file view in real time.

func (*FilterController) IsVisible added in v0.7.0

func (controller *FilterController) IsVisible() bool

IsVisible indicates if the filter view pane is currently initialized

func (*FilterController) KeyHelp added in v0.7.0

func (controller *FilterController) KeyHelp() string

KeyHelp indicates all the possible actions a user can take while the current pane is selected.

func (*FilterController) Render added in v0.7.0

func (controller *FilterController) Render() error

Render flushes the state objects to the screen. Currently this is the users path filter input.

func (*FilterController) Setup added in v0.7.0

func (controller *FilterController) Setup(v *gocui.View, header *gocui.View) error

Setup initializes the UI concerns within the context of a global gocui view object.

func (*FilterController) Update added in v0.7.0

func (controller *FilterController) Update() error

Update refreshes the state objects for future rendering (currently does nothing).

type LayerController added in v0.7.0

type LayerController struct {
	Name string

	LayerIndex        int
	Layers            []image.Layer
	CompareMode       CompareType
	CompareStartIndex int
	ImageSize         uint64
	// contains filtered or unexported fields
}

LayerController holds the UI objects and data models for populating the lower-left pane. Specifically the pane that shows the image layers and layer selector.

func NewLayerController added in v0.7.0

func NewLayerController(name string, gui *gocui.Gui, layers []image.Layer) (controller *LayerController)

NewLayerController creates a new view object attached the the global gocui screen object.

func (*LayerController) CursorDown added in v0.7.0

func (controller *LayerController) CursorDown() error

CursorDown moves the cursor down in the layer pane (selecting a higher layer).

func (*LayerController) CursorUp added in v0.7.0

func (controller *LayerController) CursorUp() error

CursorUp moves the cursor up in the layer pane (selecting a lower layer).

func (*LayerController) IsVisible added in v0.7.0

func (controller *LayerController) IsVisible() bool

IsVisible indicates if the layer view pane is currently initialized.

func (*LayerController) KeyHelp added in v0.7.0

func (controller *LayerController) KeyHelp() string

KeyHelp indicates all the possible actions a user can take while the current pane is selected.

func (*LayerController) PageDown added in v0.7.0

func (controller *LayerController) PageDown() error

PageDown moves to next page putting the cursor on top

func (*LayerController) PageUp added in v0.7.0

func (controller *LayerController) PageUp() error

PageUp moves to previous page putting the cursor on top

func (*LayerController) Render added in v0.7.0

func (controller *LayerController) Render() error

Render flushes the state objects to the screen. The layers pane reports: 1. the layers of the image + metadata 2. the current selected image

func (*LayerController) SetCursor added in v0.7.0

func (controller *LayerController) SetCursor(layer int) error

SetCursor resets the cursor and orients the file tree view based on the given layer index.

func (*LayerController) Setup added in v0.7.0

func (controller *LayerController) Setup(v *gocui.View, header *gocui.View) error

Setup initializes the UI concerns within the context of a global gocui view object.

func (*LayerController) Update added in v0.7.0

func (controller *LayerController) Update() error

Update refreshes the state objects for future rendering (currently does nothing).

type StatusController added in v0.7.0

type StatusController struct {
	Name string
	// contains filtered or unexported fields
}

StatusController holds the UI objects and data models for populating the bottom-most pane. Specifically the panel shows the user a set of possible actions to take in the window and currently selected pane.

func NewStatusController added in v0.7.0

func NewStatusController(name string, gui *gocui.Gui) (controller *StatusController)

NewStatusController creates a new view object attached the the global gocui screen object.

func (*StatusController) CursorDown added in v0.7.0

func (controller *StatusController) CursorDown() error

CursorDown moves the cursor down in the details pane (currently indicates nothing).

func (*StatusController) CursorUp added in v0.7.0

func (controller *StatusController) CursorUp() error

CursorUp moves the cursor up in the details pane (currently indicates nothing).

func (*StatusController) IsVisible added in v0.7.0

func (controller *StatusController) IsVisible() bool

IsVisible indicates if the status view pane is currently initialized.

func (*StatusController) KeyHelp added in v0.7.0

func (controller *StatusController) KeyHelp() string

KeyHelp indicates all the possible global actions a user can take when any pane is selected.

func (*StatusController) Render added in v0.7.0

func (controller *StatusController) Render() error

Render flushes the state objects to the screen.

func (*StatusController) Setup added in v0.7.0

func (controller *StatusController) Setup(v *gocui.View, header *gocui.View) error

Setup initializes the UI concerns within the context of a global gocui view object.

func (*StatusController) Update added in v0.7.0

func (controller *StatusController) Update() error

Update refreshes the state objects for future rendering (currently does nothing).

type View

type View interface {
	Setup(*gocui.View, *gocui.View) error
	CursorDown() error
	CursorUp() error
	Render() error
	Update() error
	KeyHelp() string
	IsVisible() bool
}

View defines the a renderable terminal screen pane.

Jump to

Keyboard shortcuts

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