gui

package
v0.0.0-...-e704119 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func GetGocuiAttribute

func GetGocuiAttribute(key string) gocui.Attribute

GetAttribute gets the gocui color attribute from the string

func GetGocuiStyle

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

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

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

func (*Gui) FilterString

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

func (*Gui) FocusY

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

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

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

func (*Gui) IgnoreStrings

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

func (*Gui) IsCurrentView

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

func (*Gui) Menu

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

func (*Gui) NewRenderStringTask

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

func (*Gui) NewSimpleRenderStringTask

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

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

func (*Gui) NewTickerTask

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

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

func (*Gui) QueueTask

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

func (*Gui) RenderStringMain

func (gui *Gui) RenderStringMain(s string)

func (*Gui) ResetOrigin

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

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

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

func (*Gui) Update

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

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

type RenderStringTaskOpts

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

type TaskOpts

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

type TickerTaskOpts

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

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

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