gui

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 36 Imported by: 4

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) GetKey

func (b *Binding) GetKey() string

GetKey is a function.

type CreateMenuOptions added in v0.20.0

type CreateMenuOptions struct {
	Title      string
	Items      []*types.MenuItem
	HideCancel bool
}

type Gui

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

	ErrorChan chan error
	Views     Views

	// 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

	Panels Panels
	// 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) CurrentView added in v0.20.0

func (gui *Gui) CurrentView() *gocui.View

func (*Gui) FilterString added in v0.20.0

func (gui *Gui) FilterString(view *gocui.View) string

func (*Gui) FocusY added in v0.20.0

func (gui *Gui) FocusY(selectedY int, lineCount int, v *gocui.View)

func (*Gui) GetInitialKeybindings

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

GetInitialKeybindings is a function.

func (*Gui) GetMainView added in v0.20.0

func (gui *Gui) GetMainView() *gocui.View

func (*Gui) GetOptionsPanelTextColor

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

GetOptionsPanelTextColor gets the color of the options panel text

func (*Gui) HandleClick added in v0.20.0

func (gui *Gui) HandleClick(v *gocui.View, itemCount int, selectedLine *int, handleSelect func() error) error

func (*Gui) IgnoreStrings added in v0.20.0

func (gui *Gui) IgnoreStrings() []string

func (*Gui) IsCurrentView added in v0.20.0

func (gui *Gui) IsCurrentView(view *gocui.View) bool

func (*Gui) Menu added in v0.20.0

func (gui *Gui) Menu(opts CreateMenuOptions) error

func (*Gui) NewRenderStringTask added in v0.20.0

func (gui *Gui) NewRenderStringTask(opts RenderStringTaskOpts) tasks.TaskFunc

func (*Gui) NewSimpleRenderStringTask added in v0.20.0

func (gui *Gui) NewSimpleRenderStringTask(getContent func() string) tasks.TaskFunc

assumes it's cheap to obtain the content (otherwise we would pass a function that returns the content)

func (*Gui) NewTask added in v0.20.0

func (gui *Gui) NewTask(opts TaskOpts) tasks.TaskFunc

func (*Gui) NewTickerTask added in v0.20.0

func (gui *Gui) NewTickerTask(opts TickerTaskOpts) tasks.TaskFunc

NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second the before function gets called after the lock is obtained, but before the ticker starts. if you handle a message on the stop channel in f() you need to send a message on the notifyStopped channel because returning is not sufficient. Here, unlike in a regular task, simply returning means we're now going to wait till the next tick to run again.

func (*Gui) PauseContainer added in v0.19.0

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

func (*Gui) QueueTask added in v0.20.0

func (gui *Gui) QueueTask(f func(ctx context.Context)) error

func (*Gui) RenderStringMain added in v0.20.0

func (gui *Gui) RenderStringMain(s string)

func (*Gui) ResetOrigin added in v0.20.0

func (gui *Gui) ResetOrigin(v *gocui.View)

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) SetupFakeGui added in v0.20.0

func (gui *Gui) SetupFakeGui()

this is used by our cheatsheet code to generate keybindings. We need some views and panels to exist for us to know what keybindings there are, so we invoke gocui in headless mode and create them.

func (*Gui) ShouldRefresh added in v0.20.0

func (gui *Gui) ShouldRefresh(key string) bool

func (*Gui) Update added in v0.20.0

func (gui *Gui) Update(f func() error)

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 deadlock.Mutex
	ViewStackMutex  deadlock.Mutex
}

type RenderStringTaskOpts added in v0.20.0

type RenderStringTaskOpts struct {
	Autoscroll    bool
	Wrap          bool
	GetStrContent func() string
}

type TaskOpts added in v0.20.0

type TaskOpts struct {
	Autoscroll bool
	Wrap       bool
	Func       func(ctx context.Context)
}

type TickerTaskOpts added in v0.20.0

type TickerTaskOpts struct {
	Duration   time.Duration
	Before     func(ctx context.Context)
	Func       func(ctx context.Context, notifyStopped chan struct{})
	Autoscroll bool
	Wrap       bool
}

type Views added in v0.19.0

type Views struct {
	// side panels
	Project    *gocui.View
	Services   *gocui.View
	Containers *gocui.View
	Images     *gocui.View
	Volumes    *gocui.View
	Networks   *gocui.View

	// main panel
	Main *gocui.View

	// bottom line
	Options     *gocui.View
	Information *gocui.View
	AppStatus   *gocui.View
	// text that prompts you to enter text in the Filter view
	FilterPrefix *gocui.View
	// appears next to the SearchPrefix view, it's where you type in the search string
	Filter *gocui.View

	// popups
	Confirmation *gocui.View
	Menu         *gocui.View

	// will cover everything when it appears
	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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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