model

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package model contains data required to show and use terminal user interface.

Index

Constants

View Source
const (
	Left  = Side(0)
	Right = Side(1)
)

Left and Right constants for addressing side in slices.

View Source
const (
	ItemDirectory         = ItemType('d')
	ItemFile              = ItemType('f')
	ItemDpConfiguration   = ItemType('A')
	ItemDpDomain          = ItemType('D')
	ItemDpFilestore       = ItemType('F')
	ItemDpObjectClassList = ItemType('L')
	ItemDpObjectClass     = ItemType('O')
	ItemDpObject          = ItemType('o')
	ItemDpStatusClassList = ItemType('l')
	ItemDpStatusClass     = ItemType('S')
	ItemDpStatus          = ItemType('s')
	ItemNone              = ItemType('-')
	ItemAny               = ItemType('*')
)

Available types of Item

View Source
const (
	DpFilestoreMode = DpViewMode('f')
	DpObjectMode    = DpViewMode('o')
	DpStatusMode    = DpViewMode('s')
)

Available DataPower view modes.

Variables

This section is empty.

Functions

This section is empty.

Types

type DpViewMode added in v0.5.0

type DpViewMode byte

ViewMode represent one of available DataPower view modes.

func (DpViewMode) String added in v0.5.0

func (v DpViewMode) String() string

DpViewMode methods

type Item

type Item struct {
	Name     string
	Size     string
	Modified string
	Selected bool
	Config   *ItemConfig
}

Item contains information about File, Directory, DataPower filestore, DataPower domain or DataPower configuration which is shown on screen.

func (Item) DisplayString added in v0.2.0

func (item Item) DisplayString() string

DisplayString method returns formatted string representing how item will be shown.

func (Item) GetDisplayableType added in v0.1.0

func (item Item) GetDisplayableType() string

GetDisplayableType retuns single character string representation of Item type.

func (Item) String

func (item Item) String() string

String method returns Item details.

type ItemConfig added in v0.2.0

type ItemConfig struct {
	Type          ItemType
	Name          string
	Path          string
	DpAppliance   string
	DpDomain      string
	DpFilestore   string
	DpObjectState ItemDpObjectState
	Parent        *ItemConfig
}

ItemConfig contains information about File, Directory, DataPower filestore, DataPower domain or DataPower configuration which is required to uniquely identify Item.

func (ItemConfig) DpViewMode added in v0.5.0

func (ic ItemConfig) DpViewMode() DpViewMode

DpViewMode returns which DataPower view mode ItemConfig contains. Should be called only for DataPower config, all local file will return DpFilestoreMode.

func (ItemConfig) Equals added in v0.2.0

func (ic ItemConfig) Equals(other *ItemConfig) bool

Equals method returns true if other object is refering to same ItemConfig.

func (ItemConfig) String added in v0.2.0

func (ic ItemConfig) String() string

String method returns ItemConfig details.

type ItemDpObjectState added in v0.3.4

type ItemDpObjectState struct {
	OpState     string
	AdminState  string
	EventCode   string
	ErrorCode   string
	ConfigState string
}

ItemDpObjectState contains info about DataPower object state.

func (ItemDpObjectState) String added in v0.3.5

func (idos ItemDpObjectState) String() string

String method returns ItemDpObjectState details.

type ItemList

type ItemList []Item

ItemList is slice extended as a sortable list of Items (implements sort.Interface).

func (ItemList) Len

func (items ItemList) Len() int

Len returns number of items in ItemList.

func (ItemList) Less

func (items ItemList) Less(i, j int) bool

Less returns true if item at first index should be before second one.

func (ItemList) Swap

func (items ItemList) Swap(i, j int)

Swap swaps items with given indices.

type ItemType added in v0.2.0

type ItemType byte

ItemType is used for defining type of Item (or current "directory")

func (ItemType) String added in v0.2.0

func (it ItemType) String() string

func (ItemType) UserFriendlyString added in v0.2.1

func (it ItemType) UserFriendlyString() string

UserFriendlyString ruturns ItemType as text understandable to user.

type Model

type Model struct {
	ItemMaxRows  int
	HorizScroll  int
	SearchBy     string
	SyncModeOn   bool
	SyncInitial  bool
	SyncDpDomain string
	SyncDirDp    string
	SyncDirLocal string
	// contains filtered or unexported fields
}

Model is a structure representing our dpcmder view of files, both left-side DataPower view and right-side local filesystem view.

func (*Model) AddNextView added in v0.3.5

func (m *Model) AddNextView(side Side, viewConfig *ItemConfig, viewTitle string)

AddNextView sets title and add next view config for given Side - appends new view to view history.

func (*Model) AddStatus added in v0.2.0

func (m *Model) AddStatus(status string)

AddStatus adds new status event to history of statuses.

func (*Model) CurrItem

func (m *Model) CurrItem() *Item

CurrItem returns current item under cursor for used side.

func (*Model) CurrItemForSide

func (m *Model) CurrItemForSide(side Side) *Item

CurrItemForSide returns current item under cursor for given side.

func (*Model) CurrSide

func (m *Model) CurrSide() Side

CurrSide returns currently used Side.

func (*Model) CurrentFilter

func (m *Model) CurrentFilter() string

CurrentFilter returns filter string applied to current side.

func (*Model) GetSelectedItems

func (m *Model) GetSelectedItems(side Side) []Item

GetSelectedItems returns all selected items for given side. It skips parent directories since we don't want to perform any actions (except navigation) on parent directory.

func (*Model) GetVisibleItem

func (m *Model) GetVisibleItem(side Side, rowIdx int) Item

GetVisibleItem returns (visible) item from given side at given index.

func (*Model) GetVisibleItemCount

func (m *Model) GetVisibleItemCount(side Side) int

GetVisibleItemCount returns number of items which will be shown for given side.

func (*Model) IsCurrentItem

func (m *Model) IsCurrentItem(side Side, itemIdx int) bool

IsCurrentItem returns true if item at given idx and side is the current item under cursor.

func (*Model) IsCurrentRow

func (m *Model) IsCurrentRow(side Side, rowIdx int) bool

IsCurrentRow returns true if row at given idx and side is the current row under cursor.

func (*Model) IsCurrentSide

func (m *Model) IsCurrentSide(side Side) bool

IsCurrentSide returns true if given side is currently used.

func (*Model) IsSelectable

func (m *Model) IsSelectable() bool

IsSelectable returns true if we can select current item (can select directory, file or appliance config).

func (*Model) LastStatus added in v0.2.0

func (m *Model) LastStatus() string

LastStatus returns last status event added to history.

func (*Model) NavBottom

func (m *Model) NavBottom()

NavBottom moves cursor to last item.

func (*Model) NavCurrentViewBack added in v0.3.5

func (m *Model) NavCurrentViewBack(side Side) *ItemConfig

NavCurrentViewBack sets the current view to the previous one from view history (if previous view exists).

func (*Model) NavCurrentViewForward added in v0.3.5

func (m *Model) NavCurrentViewForward(side Side) *ItemConfig

NavCurrentViewForward sets the current view to the next one from view history (if next view exists).

func (*Model) NavCurrentViewIdx added in v0.3.5

func (m *Model) NavCurrentViewIdx(side Side, idx int) *ItemConfig

NavCurrentViewIdx sets the current view to the view at given index.

func (*Model) NavDown

func (m *Model) NavDown()

NavDown moves cursor one item down if possible.

func (*Model) NavPgDown

func (m *Model) NavPgDown()

NavPgDown moves cursor one page down if possible.

func (*Model) NavPgUp

func (m *Model) NavPgUp()

NavPgUp moves cursor one page up if possible.

func (*Model) NavTop

func (m *Model) NavTop()

NavTop moves cursor to first item for current side.

func (*Model) NavTopForSide added in v0.3.4

func (m *Model) NavTopForSide(side Side)

NavTopForSide moves cursor to first item for Side.

func (*Model) NavUp

func (m *Model) NavUp()

NavUp moves cursor one item up if possible.

func (*Model) OtherSide

func (m *Model) OtherSide() Side

OtherSide returns currently non-used Side.

func (*Model) ResizeView added in v0.5.0

func (m *Model) ResizeView()

ResizeView ensures view is showing proper items after resizing and current item is visible.

func (*Model) SearchNext

func (m *Model) SearchNext(searchStr string) bool

SearchNext moves cursor to next item containing given searchStr and returns true if item is found.

func (*Model) SearchPrev

func (m *Model) SearchPrev(searchStr string) bool

SearchPrev moves cursor to previous item containing given searchStr and returns true if item is found.

func (*Model) SelPgDown

func (m *Model) SelPgDown()

SelPgDown selects all items one page down from current one.

func (*Model) SelPgUp

func (m *Model) SelPgUp()

SelPgUp selects all items one page up from current one.

func (*Model) SelToBottom

func (m *Model) SelToBottom()

SelToBottom selects all items from current one to last one.

func (*Model) SelToTop

func (m *Model) SelToTop()

SelToTop selects all items from current one to first one.

func (*Model) SetCurrItemForSide

func (m *Model) SetCurrItemForSide(side Side, itemName string)

SetCurrItemForSide sets current item under cursor for given side and item name.

func (*Model) SetCurrItemForSideAndConfig added in v0.2.0

func (m *Model) SetCurrItemForSideAndConfig(side Side, config *ItemConfig)

SetCurrItemForSideAndConfig sets current item under cursor for Side to ItemConfig.

func (*Model) SetCurrentFilter

func (m *Model) SetCurrentFilter(filterString string)

SetCurrentFilter sets filter string to apply to current side.

func (*Model) SetCurrentView added in v0.2.0

func (m *Model) SetCurrentView(side Side, viewConfig *ItemConfig, viewTitle string)

SetCurrentView sets title and view config for given Side - overwrites current view in view history.

func (*Model) SetItems

func (m *Model) SetItems(side Side, items []Item)

SetItems changes list of items for given side.

func (*Model) SetTitle

func (m *Model) SetTitle(side Side, title string)

SetTitle sets title for given Side.

func (*Model) SortSide

func (m *Model) SortSide(side Side)

SortSide sorts all items in given side.

func (*Model) Statuses added in v0.2.0

func (m *Model) Statuses() []string

Statuses returns history of all status events.

func (*Model) Title

func (m *Model) Title(side Side) string

Title returns title for given Side.

func (*Model) ToggleCurrItem

func (m *Model) ToggleCurrItem()

ToggleCurrItem toggles selection of current item under cursor.

func (*Model) ToggleSide

func (m *Model) ToggleSide()

ToggleSide switch usage from one side to other.

func (*Model) ViewConfig added in v0.2.0

func (m *Model) ViewConfig(side Side) *ItemConfig

ViewConfig returns view config for given Side.

func (*Model) ViewConfigFromHistory added in v0.3.5

func (m *Model) ViewConfigFromHistory(side Side, idx int) *ItemConfig

ViewConfigFromHistory returns view config for given Side and history position.

func (*Model) ViewConfigHistoryList added in v0.3.5

func (m *Model) ViewConfigHistoryList(side Side) []*ItemConfig

ViewConfigHistoryList returns all view history.

func (*Model) ViewConfigHistorySelectedIdx added in v0.3.5

func (m *Model) ViewConfigHistorySelectedIdx(side Side) int

ViewConfigHistorySelectedIdx returns index of current view from history.

func (*Model) ViewConfigHistorySize added in v0.3.5

func (m *Model) ViewConfigHistorySize(side Side) int

ViewConfigHistorySize returns current size of view history.

type Side

type Side int

Side type is used for Left/Right constants.

Jump to

Keyboard shortcuts

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