ui

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	App *tview.Application

	MainPage *tview.Pages
	UIPages  *tview.Pages
)

Functions

func AddViews

func AddViews()

AddViews registers the views and their layouts.

func ButtonView

func ButtonView() *tview.TextView

ButtonView returns a display area to show buttons.

func CloseStatusInput

func CloseStatusInput()

CloseStatusInput closes the input field within the status bar.

func ConfirmInput

func ConfirmInput(label string) bool

ConfirmInput returns whether the user has pressed 'y' to confirm.

func ErrorMessage

func ErrorMessage(page string, err error, stopLoading ...struct{})

ErrorMessage sends an error message to the status bar.

func HasTab

func HasTab(tab string) bool

HasTab checks if a tab exists.

func InfoMessage

func InfoMessage(text string, persist bool)

InfoMessage sends an info message to the status bar.

func InitViewByName

func InitViewByName(name string)

InitViewByName searches for a view by name and sets it.

func JobMonitor

func JobMonitor()

JobMonitor monitors currently running jobs and displays them.

func LoginScreen

func LoginScreen()

LoginScreen displays a login screen to enter authentication information.

func MatchProvider

func MatchProvider(providerConfig, provider string) bool

MatchProvider returns true if provider matches the providerConfig string. Taken from: https://github.com/rclone/rclone/blob/master/fs/backend_config.go#L542

func NewForm

func NewForm() *tview.Form

NewForm returns a form. A form is a display area for various form items.

func Normalize

func Normalize(values ...float64) []float64

Normalize returns a set of numbers on the interval [0,1] for a given set of inputs. Adapted from: https://github.com/blend/go-sdk/blob/master/mathutil/normalize.go#L13

func OpenStatusInput

func OpenStatusInput(label string) *tview.InputField

OpenStatusInput opens the input field within the status bar.

func ReadableString

func ReadableString(d time.Duration) string

ReadableString parses d into a human-readable duration. Taken from: https://github.com/rclone/rclone/blob/master/fs/parseduration.go#L132

func RoundDown

func RoundDown(value, roundTo float64) float64

RoundDown rounds down to a given roundTo value. Taken from: https://github.com/blend/go-sdk/blob/master/mathutil/round.go#L18

func SelectTab

func SelectTab(tab string)

SelectTab selects a tab.

func SetInput

func SetInput(label string, multichar ...struct{}) string

SetInput sets the inputfield label and returns the input text.

func SetTabs

func SetTabs(tabs string)

SetTabs sets the provided tabs.

func SetView

func SetView(view View, noexit ...struct{})

SetView brings the provided view into focus.

func SetViewHostname

func SetViewHostname(userInfo string)

SetViewHostname sets the user and host information within the title bar.

func SetViewTitle

func SetViewTitle(title string, appendToCurrent ...struct{})

SetViewTitle sets the title for the current view.

func SetupTabs

func SetupTabs(tabs string, alignTabView int, switchFunc func(reverse bool) bool, changedFunc func(tab string))

SetupTabs sets up the tabs within the display area.

func SetupUI

func SetupUI()

SetupUI sets up the user interface.

func ShowHelp added in v0.0.3

func ShowHelp()

ShowHelp shows a modal with documentation.

func ShowViews

func ShowViews()

ShowViews shows a modal to select a view.

func StartLoading

func StartLoading(text string)

StartLoading starts the loading spinner.

func StopLoading

func StopLoading(text ...string)

StopLoading stops the loading spinner.

func StopUI

func StopUI()

StopUI asks for confirmation before stopping the user interface.

func SuspendApp

func SuspendApp(t tcell.Screen)

SuspendApp suspends the application.

func SwitchTabView

func SwitchTabView(reverse bool, view ...*tview.TextView) string

SwitchTabView cycles through the tabs.

func TabView

func TabView() *tview.TextView

TabView returns the tab display area.

func UpdateButtonView

func UpdateButtonView(buttons []Button, addCondition ...func(label string) bool)

UpdateButtonView updates the button display area. If addCondition is provided, each button label is checked against addCondition before displaying it.

func ViewTitle

func ViewTitle() tview.Primitive

ViewTitle returns the title bar.

Types

type Button

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

Button stores a button's label and the function to be executed when it is selected.

type ButtonDisplay

type ButtonDisplay struct {
	Layout *tview.TextView
	// contains filtered or unexported fields
}

ButtonDisplay stores the layout for the currently configured buttons.

type ConfigUI

type ConfigUI struct {
	WizardUpdating bool
	// contains filtered or unexported fields
}

ConfigUI stores a layout for the configuration page.

func (*ConfigUI) Exit

func (c *ConfigUI) Exit(page string) bool

Exit exits the page.

func (*ConfigUI) Focused

func (c *ConfigUI) Focused() string

Focused returns the currently focused view.

func (*ConfigUI) Init

func (c *ConfigUI) Init() bool

Init initializes the page.

func (*ConfigUI) Layout

func (c *ConfigUI) Layout() tview.Primitive

Layout returns this page's layout.

func (*ConfigUI) Name

func (c *ConfigUI) Name() string

Name returns the page's name.

type DashboardUI

type DashboardUI struct {
	Table *tview.Table
	Plot  *tvxwidgets.Plot
	// contains filtered or unexported fields
}

DashboardUI stores a layout to display dashboard information.

func (*DashboardUI) Exit

func (d *DashboardUI) Exit(page string) bool

Exit exits the page.

func (*DashboardUI) Focused

func (d *DashboardUI) Focused() string

Focused returns the currently focused view.

func (*DashboardUI) Init

func (d *DashboardUI) Init() bool

Init initializes the page.

func (*DashboardUI) Layout

func (d *DashboardUI) Layout() tview.Primitive

Layout returns this page's layout.

func (*DashboardUI) Name

func (d *DashboardUI) Name() string

Name returns the page's name.

type ExplorerUI

type ExplorerUI struct {
	Panes []*Pane
	Flex  *tview.Flex
	// contains filtered or unexported fields
}

ExplorerUI stores the layout for the explorer page.

func (*ExplorerUI) Exit

func (e *ExplorerUI) Exit(page string) bool

Exit exits the page.

func (*ExplorerUI) Focused

func (e *ExplorerUI) Focused() string

Focused returns the currently focused view.

func (*ExplorerUI) Init

func (e *ExplorerUI) Init() bool

Init initializes the page.

func (*ExplorerUI) Layout

func (e *ExplorerUI) Layout() tview.Primitive

Layout returns this page's layout.

func (*ExplorerUI) Name

func (e *ExplorerUI) Name() string

Name returns the page's name.

type FormUI

type FormUI struct {
	ManagerTable   *tview.Table
	ManagerPages   *tview.Pages
	ManagerButtons []Button

	WizardPages   *tview.Pages
	WizardButtons []Button
	WizardData    map[string]interface{}
	WizardForms   map[string]*tview.Form
	WizardHelp    *tview.TextView

	Flex *tview.Flex
	// contains filtered or unexported fields
}

FormUI stores the layout for a form page.

func NewFormUI

func NewFormUI(pages ...string) *FormUI

NewFormUI returns a form page. A form page typically consists of two sub-pages, the former to display data and the latter to configure data, like a wizard.

type FormWidget

type FormWidget struct {
	tview.Primitive

	Item tview.FormItem

	Label  string
	Marker *tview.TextView
	// contains filtered or unexported fields
}

FormWidget stores the layout for a form item.

func GetFormCheckBox

func GetFormCheckBox(
	label string,
	setData func(name string, data interface{}), doFunc func(label string),
	value ...string,
) *FormWidget

GetFormCheckBox returns a checkbox.

func GetFormInputField

func GetFormInputField(
	label string, editable, password bool,
	setData func(name string, data interface{}), doFunc func(label string),
	value ...string,
) *FormWidget

GetFormInputField returns an input field.

func GetFormList

func GetFormList(
	label string,
	optionData map[string]string,
	editable, exclusive bool,
	setData func(name string, data interface{}),
	doFunc func(label string),
	changedFunc func(option string),
	value ...string,
) *FormWidget

GetFormList returns a queryable list with options.

func NewFormWidget

func NewFormWidget(label string, primitive tview.FormItem, passwordButton ...*tview.Button) *FormWidget

NewFormWidget returns a form item, which can be added to a form.

func (*FormWidget) DisableMarker

func (f *FormWidget) DisableMarker() *FormWidget

DisableMarker disables the marker for the form item.

func (*FormWidget) EnableMarker

func (f *FormWidget) EnableMarker() *FormWidget

EnableMarker enables the marker for the form item.

func (*FormWidget) GetFieldHeight

func (f *FormWidget) GetFieldHeight() int

func (*FormWidget) GetFieldWidth

func (f *FormWidget) GetFieldWidth() int

GetFieldWidth returns the field width of the form item.

func (*FormWidget) GetFormItem

func (f *FormWidget) GetFormItem() tview.FormItem

GetFormItem returns the form item.

func (*FormWidget) GetLabel

func (f *FormWidget) GetLabel() string

GetLabel returns the label for the form item.

func (*FormWidget) SetFinishedFunc

func (f *FormWidget) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem

SetFinishedFunc sets the handler for when the form item is not focused.

func (*FormWidget) SetFormAttributes

func (f *FormWidget) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem

SetFormAttributes sets the form attributes for the form item.

func (*FormWidget) SetRequired

func (f *FormWidget) SetRequired() *FormWidget

SetRequired marks the form item as required to be filled.

type Help added in v0.0.3

type Help struct {
	Operation, Keybinding string
}

Help provides documentation for a specific operation and keybinding.

type JobUI

type JobUI struct {
	View *tview.TreeView

	Lock sync.Mutex
	// contains filtered or unexported fields
}

JobUI stores a layout to display running job information.

type LoginUI

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

LoginUI stores the authentication parameters.

type Modal struct {
	Name string

	Flex     *tview.Flex
	Table    *tview.Table
	TextView *tview.TextView
	Input    *tview.InputField
	// contains filtered or unexported fields
}

Modal stores a layout to display a floating modal.

func GetList

func GetList(
	name, title, label string,
	optionData map[string]string,
	exitFunc func(text string),
	changedFunc func(option string),
) *Modal

GetList returns a list.

func NewCustomModal

func NewCustomModal(name string, item tview.Primitive, height, width int) *Modal

NewCustomModal returns a modal which includes the given item.

func NewModal

func NewModal(name, title string, withInput, withTextView bool, height, width int) *Modal

NewModal returns a modal with an optional inputfield or textview.

func (*Modal) Exit

func (m *Modal) Exit()

Exit exits the modal.

func (*Modal) Show

func (m *Modal) Show()

Show shows the modal.

type MountsUI

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

MountsUI stores a layout for the mounts page.

func (*MountsUI) Exit

func (m *MountsUI) Exit(page string) bool

Exit exits the page.

func (*MountsUI) Focused

func (m *MountsUI) Focused() string

Focused returns the currently focused view.

func (*MountsUI) Init

func (m *MountsUI) Init() bool

Init initializes the page.

func (*MountsUI) Layout

func (m *MountsUI) Layout() tview.Primitive

Layout returns this page's layout.

func (*MountsUI) Name

func (m *MountsUI) Name() string

Name returns the page's name.

type Pane

type Pane struct {
	ID, FS, Path string

	Title *tview.TextView
	View  *tview.Table

	Flex  *tview.Flex
	Modal *Modal

	Status        *tview.Pages
	Input         *tview.InputField
	AboutText     *tview.TextView
	SortListText  *tview.TextView
	SpinnerText   *tview.TextView
	Spinner       *tvxwidgets.Spinner
	SpinnerCancel chan struct{}

	Lock *semaphore.Weighted
	// contains filtered or unexported fields
}

Pane stores the layout for a single explorer pane.

func (*Pane) ChangeDir

func (p *Pane) ChangeDir(cdback bool)

ChangeDir changes the current directory.

func (*Pane) Filter

func (p *Pane) Filter()

Filter filters the items within the current directory.

func (*Pane) List

func (p *Pane) List(item ...rcfns.ListItem)

List lists the directory items for the current remote and path.

func (*Pane) Operation

func (p *Pane) Operation(key rune)

Operation executes an operation according to the key pressed.

func (*Pane) Select

func (p *Pane) Select(all, inverse bool)

Select selects multiple items within the current directory. The selected items can then be used within an operation, for example copying files.

func (*Pane) ShowRemotes

func (p *Pane) ShowRemotes()

ShowRemotes displays a modal with a list of available remotes.

func (*Pane) Sort

func (p *Pane) Sort()

Sort sorts the current directory list.

type Status

type Status struct {
	Pages *tview.Pages

	Input   *tview.InputField
	Message *tview.TextView

	LoadText    *tview.TextView
	LoadSpinner *tvxwidgets.Spinner
	LoadStatus  bool
	// contains filtered or unexported fields
}

Status stores the layout for a status bar.

type TabDisplay

type TabDisplay struct {
	View *tview.TextView
	// contains filtered or unexported fields
}

TabDisplay stores a layout to display tabs.

type View

type View interface {
	Init() bool

	Exit(page string) bool

	Name() string

	Focused() string

	Layout() tview.Primitive
}

View describes the layout for a view page.

type ViewBar

type ViewBar struct {
	Title *tview.TextView

	Flex          *tview.Flex
	ConnIndicator *tview.TextView
	JobIndicator  *tview.TextView
}

ViewBar stores a layout for the title bar.

Jump to

Keyboard shortcuts

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