ui

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeviceTable *tview.Table
View Source
var (

	// HelpTopics store the various help topics.
	HelpTopics = map[string][]Help{
		"Device Screen": {
			{"Menu", "Open the menu", []cmd.Key{cmd.KeyMenu}, true},
			{"Switch", "Navigate between menus", []cmd.Key{cmd.KeySwitch}, true},
			{"Navigation", "Navigate between devices/options", []cmd.Key{cmd.KeyNavigateUp, cmd.KeyNavigateDown}, true},
			{"Power", "Toggle adapter power state", []cmd.Key{cmd.KeyAdapterTogglePower}, true},
			{"Discoverable", "Toggle discoverable state", []cmd.Key{cmd.KeyAdapterToggleDiscoverable}, false},
			{"Pairable", "Toggle pairable state", []cmd.Key{cmd.KeyAdapterTogglePairable}, false},
			{"Scan", "Toggle scan (discovery state)", []cmd.Key{cmd.KeyAdapterToggleScan}, true},
			{"Adapter", "Change adapter", []cmd.Key{cmd.KeyAdapterChange}, true},
			{"Send", "Send files", []cmd.Key{cmd.KeyDeviceSendFiles}, true},
			{"Network", "Connect to network", []cmd.Key{cmd.KeyDeviceNetwork}, false},
			{"Progress", "Progress view", []cmd.Key{cmd.KeyProgressView}, false},
			{"Player", "Show/Hide player", []cmd.Key{cmd.KeyPlayerShow, cmd.KeyPlayerHide}, false},
			{"Device Info", "Show device information", []cmd.Key{cmd.KeyDeviceInfo}, false},
			{"Connect", "Connect to selected device", []cmd.Key{cmd.KeyDeviceConnect}, true},
			{"Pair", "Pair with selected device", []cmd.Key{cmd.KeyDevicePair}, true},
			{"Trust", "Trust selected device", []cmd.Key{cmd.KeyDeviceTrust}, false},
			{"Remove", "Remove device from adapter", []cmd.Key{cmd.KeyDeviceRemove}, false},
			{"Cancel", "Cancel operation", []cmd.Key{cmd.KeyCancel}, false},
			{"Help", "Show help", []cmd.Key{cmd.KeyHelp}, true},
			{"Quit", "Quit", []cmd.Key{cmd.KeyQuit}, false},
		},
		"File Picker": {
			{"Navigation", "Navigate between directory entries", []cmd.Key{cmd.KeyNavigateUp, cmd.KeyNavigateDown}, true},
			{"ChgDir Fwd/Back", "Enter/Go back a directory", []cmd.Key{cmd.KeyNavigateRight, cmd.KeyNavigateLeft}, true},
			{"One", "Select one file", []cmd.Key{cmd.KeyFilebrowserSelect}, true},
			{"Invert", "Invert file selection", []cmd.Key{cmd.KeyFilebrowserInvertSelection}, true},
			{"All", "Select all files", []cmd.Key{cmd.KeyFilebrowserSelectAll}, true},
			{"Refresh", "Refresh current directory", []cmd.Key{cmd.KeyFilebrowserRefresh}, false},
			{"Hidden", "Toggle hidden files", []cmd.Key{cmd.KeyFilebrowserToggleHidden}, false},
			{"Confirm", "Confirm file(s) selection", []cmd.Key{cmd.KeyFilebrowserConfirmSelection}, true},
			{"Exit", "Exit", []cmd.Key{cmd.KeyClose}, false},
		},
		"Progress View": {
			{"Navigation", "Navigate between transfers", []cmd.Key{cmd.KeyNavigateUp, cmd.KeyNavigateDown}, true},
			{"Suspend", "Suspend transfer", []cmd.Key{cmd.KeyProgressTransferSuspend}, true},
			{"Resume", "Resume transfer", []cmd.Key{cmd.KeyProgressTransferResume}, true},
			{"Cancel", "Cancel transfer", []cmd.Key{cmd.KeyProgressTransferCancel}, true},
			{"Exit", "Exit", []cmd.Key{cmd.KeyClose}, true},
		},
		"Media Player": {
			{"Play/Pause", "Toggle play/pause", []cmd.Key{cmd.KeyNavigateUp, cmd.KeyNavigateDown}, false},
			{"Next", "Next", []cmd.Key{cmd.KeyPlayerNext}, false},
			{"Previous", "Previous", []cmd.Key{cmd.KeyPlayerPrevious}, false},
			{"Rewind", "Rewind", []cmd.Key{cmd.KeyPlayerSeekBackward}, false},
			{"Forward", "Fast forward", []cmd.Key{cmd.KeyPlayerSeekForward}, false},
			{"Stop", "Stop", []cmd.Key{cmd.KeyPlayerStop}, false},
		},
	}
)

Functions

func CancelProgress added in v0.0.5

func CancelProgress()

CancelProgress cancels the transfer. This does not work when a file is being received.

func ErrorMessage

func ErrorMessage(err error)

ErrorMessage sends an error message to the status bar.

func GetDeviceFromPath

func GetDeviceFromPath(devicePath string) (bluez.Device, error)

GetDeviceFromPath gets a device from the device path.

func InfoMessage

func InfoMessage(text string, persist bool)

InfoMessage sends an info message to the status bar.

func KeyHandler added in v0.1.7

func KeyHandler(key cmd.Key, context FunctionContext) func() bool

KeyHandler executes the handler assigned to the key type based on the function context.

func NewConfirmModal added in v0.1.8

func NewConfirmModal(name, title, message string) string

NewConfirmModal displays a modal, shows a message and asks for confirmation.

func NewDisplayModal added in v0.1.8

func NewDisplayModal(name, title, message string)

NewDisplayModal displays a modal with a message.

func ResizeModal added in v0.1.7

func ResizeModal()

ResizeModal resizes the modal according to the current screen dimensions.

func ResumeProgress added in v0.0.5

func ResumeProgress()

ResumeProgress resumes the transfer. This does not work when a file is being received.

func SetConnections added in v0.1.7

func SetConnections(b *bluez.Bluez, o *bluez.Obex, n *network.Network, warn string)

SetConnections sets the connections to bluez and networkmanager.

func SetInput

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

SetInput sets the inputfield label and returns the input text.

func SetPrimaryFocus added in v0.1.7

func SetPrimaryFocus()

SetPrimaryFocus sets the focus to the appropriate primitive.

func SetTrusted

func SetTrusted(devicePath string, enable bool) error

SetTrusted sets the trusted state of a device.

func StartMediaPlayer added in v0.0.9

func StartMediaPlayer()

StartMediaPlayer shows the media player.

func StartProgress added in v0.0.5

func StartProgress(transferPath dbus.ObjectPath, props bluez.ObexTransferProperties, path ...string) bool

StartProgress creates a new progress indicator, monitors the OBEX DBus interface for transfer events, and displays the progress on the screen. If the optional path parameter is provided, it means that a file is being received, and on transfer completion, the received file should be moved to a user-accessible directory.

func StartUI

func StartUI()

StartUI starts the UI.

func StopMediaPlayer added in v0.0.9

func StopMediaPlayer()

StopMediaPlayer closes the media player.

func StopUI

func StopUI()

StopUI stops the UI.

func SuspendProgress added in v0.0.5

func SuspendProgress()

SuspendProgress suspends the transfer. This does not work when a file is being received.

Types

type AdapterStatus added in v0.1.7

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

AdapterStatus describes the adapter status display.

type Application added in v0.1.7

type Application struct {
	// Pages holds the DeviceTable, along with
	// any menu popups that will be added.
	Pages *tview.Pages

	// Layout holds the layout of the application.
	Layout *tview.Flex

	// Status holds the status bar.
	Status Status

	// Bluez holds the current bluez DBus connection.
	Bluez *bluez.Bluez

	// Obex holds the current bluez obex DBus connection.
	Obex *bluez.Obex

	// network holds the current network connection.
	Network *network.Network

	*tview.Application
	// contains filtered or unexported fields
}
var UI Application

type FilePicker added in v0.1.7

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

FilePicker describes a filepicker.

type FunctionContext added in v0.1.7

type FunctionContext string

FunctionContext describes the context in which the function is supoosed to be executed in.

const (
	FunctionClick   FunctionContext = "Click"
	FunctionCreate  FunctionContext = "Create"
	FunctionVisible FunctionContext = "Visible"
)

The different context types for functions.

type Help added in v0.2.0

type Help struct {
	Title, Description string
	Keys               []cmd.Key
	ShowInStatus       bool
}

Help describes the help item.

type HelpArea added in v0.2.1

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

type MediaPlayer added in v0.1.7

type MediaPlayer struct {
	// contains filtered or unexported fields
}
type Menu struct {
	// contains filtered or unexported fields
}

Menu describes a region to display menu items.

type MenuOption struct {
	Key cmd.Key

	Display           string
	Enabled, Disabled string

	Toggled                    bool
	OnCreate, OnClick, Visible bool

	*cmd.KeyData
	// contains filtered or unexported fields
}

MenuOption describes an option layout for a submenu.

type Modal struct {
	Name          string
	Open          bool
	Height, Width int

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

Modal stores a layout to display a floating modal.

func ModalExists added in v0.1.7

func ModalExists(name string) (*Modal, bool)

ModalExists returns whether the modal with the given name is displayed.

func NewMenuModal added in v0.1.7

func NewMenuModal(name string, regionX, regionY int) *Modal

NewMenuModal returns a menu modal.

func NewModal added in v0.1.7

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

NewModal returns a modal. If a primitive is not provided, a table is attach to it.

func (*Modal) Exit added in v0.1.7

func (m *Modal) Exit(focusInput bool)

Exit exits the modal.

func (*Modal) Show added in v0.1.7

func (m *Modal) Show()

Show shows the modal.

type Operation added in v0.1.7

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

type ProgressIndicator added in v0.1.7

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

ProgressIndicator describes a progress indicator, which will display a description and a progress bar.

func NewProgress added in v0.0.5

func NewProgress(transferPath dbus.ObjectPath, props bluez.ObexTransferProperties, recv bool) *ProgressIndicator

NewProgress returns a new Progress.

func (*ProgressIndicator) FinishProgress added in v0.1.7

func (p *ProgressIndicator) FinishProgress(transferPath dbus.ObjectPath, path ...string)

FinishProgress removes the progress indicator from view. If a file was received, as indicated by the path parameter, the file is moved from the "root" (usually the ~/.cache/obexd folder) to the user's home directory.

func (*ProgressIndicator) Write added in v0.1.7

func (p *ProgressIndicator) Write(b []byte) (int, error)

Write is used by the progressbar to display the progress on the screen.

type ProgressUI added in v0.1.7

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

ProgressUI describes a file transfer progress display.

type Status

type Status struct {
	// MessageBox is an area to display messages.
	MessageBox *tview.TextView

	// Help is an area to display help keybindings.
	Help *tview.TextView

	// InputField is an area to interact with messages.
	InputField *tview.InputField

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

Jump to

Keyboard shortcuts

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