Documentation
¶
Overview ¶
Package model contains data required to show and use terminal user interface.
Index ¶
- Constants
- type DpViewMode
- type Item
- type ItemConfig
- type ItemDpObjectState
- type ItemList
- type ItemType
- type Model
- func (m *Model) AddNextView(side Side, viewConfig *ItemConfig, viewTitle string)
- func (m *Model) AddStatus(status string)
- func (m *Model) CurrItem() *Item
- func (m *Model) CurrItemForSide(side Side) *Item
- func (m *Model) CurrSide() Side
- func (m *Model) CurrentFilter() string
- func (m *Model) GetSelectedItems(side Side) []Item
- func (m *Model) GetVisibleItem(side Side, rowIdx int) Item
- func (m *Model) GetVisibleItemCount(side Side) int
- func (m *Model) IsCurrentItem(side Side, itemIdx int) bool
- func (m *Model) IsCurrentRow(side Side, rowIdx int) bool
- func (m *Model) IsCurrentSide(side Side) bool
- func (m *Model) IsSelectable() bool
- func (m *Model) LastStatus() string
- func (m *Model) NavBottom()
- func (m *Model) NavCurrentViewBack(side Side) *ItemConfig
- func (m *Model) NavCurrentViewForward(side Side) *ItemConfig
- func (m *Model) NavCurrentViewIdx(side Side, idx int) *ItemConfig
- func (m *Model) NavDown()
- func (m *Model) NavPgDown()
- func (m *Model) NavPgUp()
- func (m *Model) NavTop()
- func (m *Model) NavTopForSide(side Side)
- func (m *Model) NavUp()
- func (m *Model) OtherSide() Side
- func (m *Model) ResizeView()
- func (m *Model) SearchNext(searchStr string) bool
- func (m *Model) SearchPrev(searchStr string) bool
- func (m *Model) SelPgDown()
- func (m *Model) SelPgUp()
- func (m *Model) SelToBottom()
- func (m *Model) SelToTop()
- func (m *Model) SetCurrItemForSide(side Side, itemName string)
- func (m *Model) SetCurrItemForSideAndConfig(side Side, config *ItemConfig)
- func (m *Model) SetCurrentFilter(filterString string)
- func (m *Model) SetCurrentView(side Side, viewConfig *ItemConfig, viewTitle string)
- func (m *Model) SetItems(side Side, items []Item)
- func (m *Model) SetTitle(side Side, title string)
- func (m *Model) SortSide(side Side)
- func (m *Model) Statuses() []string
- func (m *Model) Title(side Side) string
- func (m *Model) ToggleCurrItem()
- func (m *Model) ToggleSide()
- func (m *Model) ViewConfig(side Side) *ItemConfig
- func (m *Model) ViewConfigFromHistory(side Side, idx int) *ItemConfig
- func (m *Model) ViewConfigHistoryList(side Side) []*ItemConfig
- func (m *Model) ViewConfigHistorySelectedIdx(side Side) int
- func (m *Model) ViewConfigHistorySize(side Side) int
- type Side
Constants ¶
const ( Left = Side(0) Right = Side(1) )
Left and Right constants for addressing side in slices.
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
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.
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
DisplayString method returns formatted string representing how item will be shown.
func (Item) GetDisplayableType ¶ added in v0.1.0
GetDisplayableType retuns single character string representation of Item type.
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).
type ItemType ¶ added in v0.2.0
type ItemType byte
ItemType is used for defining type of Item (or current "directory")
func (ItemType) UserFriendlyString ¶ added in v0.2.1
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) CurrItemForSide ¶
CurrItemForSide returns current item under cursor for given side.
func (*Model) CurrentFilter ¶
CurrentFilter returns filter string applied to current side.
func (*Model) GetSelectedItems ¶
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 ¶
GetVisibleItem returns (visible) item from given side at given index.
func (*Model) GetVisibleItemCount ¶
GetVisibleItemCount returns number of items which will be shown for given side.
func (*Model) IsCurrentItem ¶
IsCurrentItem returns true if item at given idx and side is the current item under cursor.
func (*Model) IsCurrentRow ¶
IsCurrentRow returns true if row at given idx and side is the current row under cursor.
func (*Model) IsCurrentSide ¶
IsCurrentSide returns true if given side is currently used.
func (*Model) IsSelectable ¶
IsSelectable returns true if we can select current item (can select directory, file or appliance config).
func (*Model) LastStatus ¶ added in v0.2.0
LastStatus returns last status event added to history.
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) NavPgDown ¶
func (m *Model) NavPgDown()
NavPgDown moves cursor one page down if possible.
func (*Model) NavTopForSide ¶ added in v0.3.4
NavTopForSide moves cursor to first item for 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 ¶
SearchNext moves cursor to next item containing given searchStr and returns true if item is found.
func (*Model) SearchPrev ¶
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 ¶
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 ¶
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) 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
ViewConfigHistorySelectedIdx returns index of current view from history.
func (*Model) ViewConfigHistorySize ¶ added in v0.3.5
ViewConfigHistorySize returns current size of view history.