shared

package
v0.0.0-...-3ddbc71 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package shared keeps shared domains.

Index

Constants

View Source
const (
	TabsBarHeight = 3
	HelpBarHeight = 2
	FullScreen    = -1
)

Variables

This section is empty.

Functions

func Max

func Max(a, b int) int

Max returns max of two integers.

Types

type Clickable

type Clickable interface {
	GetCoords() Coords
	SetCoords(c Coords)
	SetCallback(callback func() error)
	OnClick() error
}

Clickable is a ui component that can be clicked.

type ClickableComponent

type ClickableComponent int

ClickableComponent represents a logical component that help to identify on which component area clicked.

const (
	TabHeader ClickableComponent = iota
	SnapshotsButtonsBar
	SnapshotsList
	VolumesBar
	ScheduleBar
	HelpFooter
)

Available components.

type ClickableItem

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

func (*ClickableItem) GetCoords

func (ci *ClickableItem) GetCoords() Coords

func (*ClickableItem) OnClick

func (ci *ClickableItem) OnClick() error

func (*ClickableItem) SetCallback

func (ci *ClickableItem) SetCallback(callback func() error)

func (*ClickableItem) SetCoords

func (ci *ClickableItem) SetCoords(c Coords)

type Coords

type Coords struct {
	X1 int
	Y1 int
	X2 int
	Y2 int
}

Coords are coordinates of a clickable ui component.

type KeyMap

type KeyMap struct {
	Tab       key.Binding
	ShiftTab  key.Binding
	Up        key.Binding
	Down      key.Binding
	PrevPage  key.Binding
	NextPage  key.Binding
	Create    key.Binding
	Restore   key.Binding
	Delete    key.Binding
	Volume    key.Binding
	Help      key.Binding
	HelpShort key.Binding
	Quit      key.Binding
}

func GetKeyMaps

func GetKeyMaps() KeyMap

GetKeyMaps returns all the shortcats available.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

func (KeyMap) SettingsHelp

func (k KeyMap) SettingsHelp() [][]key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

func (KeyMap) SnapshotsHelp

func (k KeyMap) SnapshotsHelp() [][]key.Binding

type State

type State struct {
	ScreenHeight      int
	ScreenWidth       int
	CurrentTab        TabItem
	ClickableElements map[ClickableComponent][]Clickable
	Config            *config.Config
	Areas             *uiAreas
	UpdateSnapshots   bool
}

State is the state of the ui application.

func NewState

func NewState(cfg *config.Config) *State

func (*State) AppendClickable

func (s *State) AppendClickable(comp ClickableComponent, cc ...Clickable) error

func (*State) CleanClickable

func (s *State) CleanClickable(comp ClickableComponent)

func (*State) FindClickable

func (s *State) FindClickable(x, y int) Clickable

func (*State) GetActiveVolumesIDs

func (s *State) GetActiveVolumesIDs() []uint64

func (*State) ResizeAreas

func (s *State) ResizeAreas()

func (*State) Update

func (s *State) Update(ti TabItem)

Update changes the current tab.

type TabItem

type TabItem int

TabItem is kind of identifier for tabs. It differs from `elements/tab` which is responsible for look and style, and which is data agnostic. TabItem, on the contrary, represents a concrete tab with a concrete title and related with a specific content.

const (
	SnapshotsTab TabItem = iota
	SettingsTab
	AnyTab // used for elements that don't belong to any tab. As example, tabs themselves.
)

TabItem tabs.

func GetTabItems

func GetTabItems() []TabItem

GetTabItems returns the list of all available (visually) tabs.

func (TabItem) String

func (t TabItem) String() string

String is a string representation of TabItems.

Directories

Path Synopsis
elements
alert
Package alert keeps helpers to create a standard alert window.
Package alert keeps helpers to create a standard alert window.
dialog
Package dialog keeps helpers to create a standard dialog window.
Package dialog keeps helpers to create a standard dialog window.
divider
Package divider keeps helpers to draw dividers.
Package divider keeps helpers to draw dividers.
tab
Package tab keeps helpers to create tabs.
Package tab keeps helpers to create tabs.
Package styles keeps default styles.
Package styles keeps default styles.

Jump to

Keyboard shortcuts

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