gui

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 33 Imported by: 2

Documentation

Index

Constants

View Source
const INFO_SECTION_PADDING = " "
View Source
const UNKNOWN_VIEW_ERROR_MSG = "unknown view"

Variables

View Source
var OverlappingEdges = false

OverlappingEdges determines if panel edges overlap

Functions

func GetGocuiAttribute added in v0.18.1

func GetGocuiAttribute(key string) gocui.Attribute

GetAttribute gets the gocui color attribute from the string

func GetGocuiStyle added in v0.18.1

func GetGocuiStyle(keys []string) gocui.Attribute

GetGocuiStyle bitwise OR's a list of attributes obtained via the given keys

Types

type Binding

type Binding struct {
	ViewName    string
	Handler     func(*gocui.Gui, *gocui.View) error
	Key         interface{} // FIXME: find out how to get `gocui.Key | rune`
	Modifier    gocui.Modifier
	Description string
}

Binding - a keybinding mapping a key and modifier to a handler. The keypress is only handled if the given view has focus, or handled globally if the view is ""

func (*Binding) GetDisplayStrings

func (b *Binding) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the display string of a file

func (*Binding) GetKey

func (b *Binding) GetKey() string

GetKey is a function.

type Gui

type Gui struct {
	Log           *logrus.Entry
	DockerCommand *commands.DockerCommand
	OSCommand     *commands.OSCommand
	State         guiState
	Config        *config.AppConfig
	Tr            *i18n.TranslationSet
	Errors        SentinelErrors

	T             *tasks.TaskManager
	ErrorChan     chan error
	CyclableViews []string
	Views         Views
	// returns true if our views have been created and assigned to gui.Views.
	// Views are setup only once, upon application start.
	ViewsSetup bool

	// if we've suspended the gui (e.g. because we've switched to a subprocess)
	// we typically want to pause some things that are running like background
	// file refreshes
	PauseBackgroundThreads bool

	Mutexes
	// contains filtered or unexported fields
}

Gui wraps the gocui Gui object which handles rendering and events

func NewGui

func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr *i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*Gui, error)

NewGui builds a new gui handler

func (*Gui) GenerateSentinelErrors

func (gui *Gui) GenerateSentinelErrors()

GenerateSentinelErrors makes the sentinel errors for the gui. We're defining it here because we can't do package-scoped errors with localization, and also because it seems like package-scoped variables are bad in general https://dave.cheney.net/2017/06/11/go-without-package-scoped-variables In the future it would be good to implement some of the recommendations of that article. For now, if we don't need an error to be a sentinel, we will just define it inline. This has implications for error messages that pop up everywhere in that we'll be duplicating the default values. We may need to look at having a default localisation bundle defined, and just using keys-only when localising things in the code.

func (*Gui) GetInitialKeybindings

func (gui *Gui) GetInitialKeybindings() []*Binding

GetInitialKeybindings is a function.

func (*Gui) GetOptionsPanelTextColor

func (gui *Gui) GetOptionsPanelTextColor() gocui.Attribute

GetOptionsPanelTextColor gets the color of the options panel text

func (*Gui) PauseContainer added in v0.19.0

func (gui *Gui) PauseContainer(container *commands.Container) error

func (*Gui) Run

func (gui *Gui) Run() error

Run setup the gui with keybindings and start the mainloop

func (*Gui) SetColorScheme

func (gui *Gui) SetColorScheme() error

SetColorScheme sets the color scheme for the app based on the user config

func (*Gui) WithWaitingStatus

func (gui *Gui) WithWaitingStatus(name string, f func() error) error

WithWaitingStatus wraps a function and shows a waiting status while the function is still executing

type Mutexes added in v0.19.0

type Mutexes struct {
	SubprocessMutex sync.Mutex
	ViewStackMutex  sync.Mutex
}

type SentinelErrors

type SentinelErrors struct {
	ErrNoContainers error
	ErrNoImages     error
	ErrNoVolumes    error
}

SentinelErrors are the errors that have special meaning and need to be checked by calling functions. The less of these, the better

type Views added in v0.19.0

type Views struct {
	Project    *gocui.View
	Services   *gocui.View
	Containers *gocui.View
	Images     *gocui.View
	Volumes    *gocui.View

	Main *gocui.View

	Options      *gocui.View
	Confirmation *gocui.View
	Menu         *gocui.View
	Information  *gocui.View
	AppStatus    *gocui.View
	Limit        *gocui.View
}

type WindowMaximisation added in v0.19.0

type WindowMaximisation int

screen sizing determines how much space your selected window takes up (window as in panel, not your terminal's window). Sometimes you want a bit more space to see the contents of a panel, and this keeps track of how much maximisation you've set

const (
	SCREEN_NORMAL WindowMaximisation = iota
	SCREEN_HALF
	SCREEN_FULL
)

Jump to

Keyboard shortcuts

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