viewmodel

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileTreeViewModel

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

	CollapseAll    bool
	ShowAttributes bool

	HiddenDiffTypes []bool
	TreeIndex       int

	Buffer bytes.Buffer
	// 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

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

NewFileTreeViewModel creates a new view object attached the the global [gocui] screen object.

func (*FileTreeViewModel) ConstrainLayout

func (vm *FileTreeViewModel) ConstrainLayout()

func (*FileTreeViewModel) CursorDown

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

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

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

CursorRight descends into directory expanding it if needed

func (*FileTreeViewModel) CursorUp

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) ExpandLayout

func (vm *FileTreeViewModel) ExpandLayout()

func (*FileTreeViewModel) IsVisible

func (vm *FileTreeViewModel) IsVisible() bool

IsVisible indicates if the file tree view pane is currently initialized

func (*FileTreeViewModel) PageDown

func (vm *FileTreeViewModel) PageDown() error

PageDown moves to next page putting the cursor on top

func (*FileTreeViewModel) PageUp

func (vm *FileTreeViewModel) PageUp() error

PageUp moves to previous page putting the cursor on top

func (*FileTreeViewModel) Render

func (vm *FileTreeViewModel) Render() error

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

func (*FileTreeViewModel) ResetCursor

func (vm *FileTreeViewModel) ResetCursor()

ResetCursor moves the cursor back to the top of the buffer and translates to the top of the buffer.

func (*FileTreeViewModel) SetTreeByLayer

func (vm *FileTreeViewModel) SetTreeByLayer(bottomTreeStart, bottomTreeStop, topTreeStart, topTreeStop int) error

SetTreeByLayer populates the view model by stacking the indicated image layer file trees.

func (*FileTreeViewModel) Setup

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

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

func (*FileTreeViewModel) ToggleAttributes

func (vm *FileTreeViewModel) ToggleAttributes() error

ToggleCollapse will collapse/expand the selected FileNode.

func (*FileTreeViewModel) ToggleCollapse

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

ToggleCollapse will collapse/expand the selected FileNode.

func (*FileTreeViewModel) ToggleCollapseAll

func (vm *FileTreeViewModel) ToggleCollapseAll() error

ToggleCollapseAll will collapse/expand the all directories.

func (*FileTreeViewModel) ToggleShowDiffType

func (vm *FileTreeViewModel) ToggleShowDiffType(diffType filetree.DiffType)

ToggleShowDiffType will show/hide the selected DiffType in the filetree pane.

func (*FileTreeViewModel) ToggleSortOrder

func (vm *FileTreeViewModel) ToggleSortOrder() error

ToggleSortOrder will toggle the sort order in which files are displayed

func (*FileTreeViewModel) Update

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

Update refreshes the state objects for future rendering.

type LayerCompareMode

type LayerCompareMode int
const (
	CompareSingleLayer LayerCompareMode = iota
	CompareAllLayers
)

type LayerSelection

type LayerSelection struct {
	Layer                                                      *image.Layer
	BottomTreeStart, BottomTreeStop, TopTreeStart, TopTreeStop int
}

type LayerSetState

type LayerSetState struct {
	LayerIndex        int
	Layers            []*image.Layer
	CompareMode       LayerCompareMode
	CompareStartIndex int
}

func NewLayerSetState

func NewLayerSetState(layers []*image.Layer, compareMode LayerCompareMode) *LayerSetState

func (*LayerSetState) GetCompareIndexes

func (state *LayerSetState) GetCompareIndexes() (bottomTreeStart, bottomTreeStop, topTreeStart, topTreeStop int)

getCompareIndexes determines the layer boundaries to use for comparison (based on the current compare mode)

Jump to

Keyboard shortcuts

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