ui

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 Views struct {
	Tree    *FileTreeView
	Layer   *LayerView
	Status  *StatusView
	Filter  *FilterView
	Details *DetailsView
	// contains filtered or unexported fields
}

Views contains all rendered UI panes.

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 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(layers []*image.Layer, refTrees []*filetree.FileTree, efficiency float64, inefficiencies filetree.EfficiencySlice)

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 DetailsView

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

DetailsView 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 NewDetailsView

func NewDetailsView(name string, gui *gocui.Gui, efficiency float64, inefficiencies filetree.EfficiencySlice) (detailsView *DetailsView)

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

func (*DetailsView) CursorDown

func (view *DetailsView) CursorDown() error

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

func (*DetailsView) CursorUp

func (view *DetailsView) CursorUp() error

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

func (*DetailsView) IsVisible

func (view *DetailsView) IsVisible() bool

IsVisible indicates if the details view pane is currently initialized.

func (*DetailsView) KeyHelp

func (view *DetailsView) KeyHelp() string

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

func (*DetailsView) Render

func (view *DetailsView) 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 (*DetailsView) Setup

func (view *DetailsView) Setup(v *gocui.View, header *gocui.View) error

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

func (*DetailsView) Update

func (view *DetailsView) Update() error

Update refreshes the state objects for future rendering.

type FileTreeView

type FileTreeView struct {
	Name string

	ModelTree       *filetree.FileTree
	ViewTree        *filetree.FileTree
	RefTrees        []*filetree.FileTree
	HiddenDiffTypes []bool
	TreeIndex       uint
	// contains filtered or unexported fields
}

FileTreeView 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 NewFileTreeView

func NewFileTreeView(name string, gui *gocui.Gui, tree *filetree.FileTree, refTrees []*filetree.FileTree) (treeView *FileTreeView)

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

func (*FileTreeView) CursorDown

func (view *FileTreeView) 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 (*FileTreeView) CursorUp

func (view *FileTreeView) 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 (*FileTreeView) IsVisible

func (view *FileTreeView) IsVisible() bool

IsVisible indicates if the file tree view pane is currently initialized

func (*FileTreeView) KeyHelp

func (view *FileTreeView) KeyHelp() string

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

func (*FileTreeView) Render

func (view *FileTreeView) Render() error

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

func (*FileTreeView) Setup

func (view *FileTreeView) Setup(v *gocui.View, header *gocui.View) error

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

func (*FileTreeView) Update

func (view *FileTreeView) Update() error

Update refreshes the state objects for future rendering.

type FilterView

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

DetailsView 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 NewFilterView

func NewFilterView(name string, gui *gocui.Gui) (filterView *FilterView)

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

func (*FilterView) CursorDown

func (view *FilterView) CursorDown() error

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

func (*FilterView) CursorUp

func (view *FilterView) CursorUp() error

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

func (*FilterView) Edit

func (view *FilterView) 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 (*FilterView) IsVisible

func (view *FilterView) IsVisible() bool

IsVisible indicates if the filter view pane is currently initialized

func (*FilterView) KeyHelp

func (view *FilterView) KeyHelp() string

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

func (*FilterView) Render

func (view *FilterView) Render() error

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

func (*FilterView) Setup

func (view *FilterView) Setup(v *gocui.View, header *gocui.View) error

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

func (*FilterView) Update

func (view *FilterView) Update() error

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

type LayerView

type LayerView struct {
	Name string

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

LayerView 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 NewLayerView

func NewLayerView(name string, gui *gocui.Gui, layers []*image.Layer) (layerView *LayerView)

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

func (*LayerView) CursorDown

func (view *LayerView) CursorDown() error

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

func (*LayerView) CursorUp

func (view *LayerView) CursorUp() error

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

func (*LayerView) IsVisible

func (view *LayerView) IsVisible() bool

IsVisible indicates if the layer view pane is currently initialized.

func (*LayerView) KeyHelp

func (view *LayerView) KeyHelp() string

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

func (*LayerView) Render

func (view *LayerView) 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 (*LayerView) SetCursor

func (view *LayerView) SetCursor(layer int) error

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

func (*LayerView) Setup

func (view *LayerView) Setup(v *gocui.View, header *gocui.View) error

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

func (*LayerView) Update

func (view *LayerView) Update() error

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

type StatusView

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

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

func NewStatusView

func NewStatusView(name string, gui *gocui.Gui) (statusView *StatusView)

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

func (*StatusView) CursorDown

func (view *StatusView) CursorDown() error

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

func (*StatusView) CursorUp

func (view *StatusView) CursorUp() error

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

func (*StatusView) IsVisible

func (view *StatusView) IsVisible() bool

IsVisible indicates if the status view pane is currently initialized.

func (*StatusView) KeyHelp

func (view *StatusView) KeyHelp() string

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

func (*StatusView) Render

func (view *StatusView) Render() error

Render flushes the state objects to the screen.

func (*StatusView) Setup

func (view *StatusView) Setup(v *gocui.View, header *gocui.View) error

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

func (*StatusView) Update

func (view *StatusView) 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