gui

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OverlappingEdges = false

OverlappingEdges determines if panel edges overlap

Functions

This section is empty.

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
	Alternative 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 added in v0.8.1

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

GetDisplayStrings returns the display string of a file

func (*Binding) GetKey added in v0.8.1

func (b *Binding) GetKey() string

GetKey is a function.

type Gui

type Gui struct {
	Log        *logrus.Entry
	GitCommand *commands.GitCommand
	OSCommand  *commands.OSCommand
	SubProcess *exec.Cmd
	State      guiState
	Config     config.AppConfigurer
	Tr         *i18n.Localizer
	Errors     SentinelErrors
	Updater    *updates.Updater
	// contains filtered or unexported fields
}

Gui wraps the gocui Gui object which handles rendering and events

func NewGui

func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater) (*Gui, error)

NewGui builds a new gui handler

func (*Gui) GenerateSentinelErrors added in v0.1.62

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) GetAttribute added in v0.1.65

func (gui *Gui) GetAttribute(key string) gocui.Attribute

GetAttribute gets the gocui color attribute from the string

func (*Gui) GetColor added in v0.1.65

func (gui *Gui) GetColor(keys []string) gocui.Attribute

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

func (*Gui) GetContextMap added in v0.8.1

func (gui *Gui) GetContextMap() map[string]map[string][]*Binding

func (*Gui) GetCurrentKeybindings added in v0.8.1

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

GetCurrentKeybindings gets the list of keybindings given the current context

func (*Gui) GetInitialKeybindings added in v0.8.1

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

GetInitialKeybindings is a function.

func (*Gui) GetOptionsPanelTextColor added in v0.1.65

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

GetOptionsPanelTextColor gets the color of the options panel text

func (*Gui) HandleCredentialsPopup added in v0.8.1

func (gui *Gui) HandleCredentialsPopup(g *gocui.Gui, popupOpened bool, cmdErr error)

HandleCredentialsPopup handles the views after executing a command that might ask for credentials

func (*Gui) HandlePasteCommits added in v0.8.1

func (gui *Gui) HandlePasteCommits(g *gocui.Gui, v *gocui.View) error

HandlePasteCommits begins a cherry-pick rebase with the commits the user has copied

func (*Gui) PrepareSubProcess

func (gui *Gui) PrepareSubProcess(g *gocui.Gui, commands ...string)

PrepareSubProcess - prepare a subprocess for execution and tell the gui to switch to it

func (*Gui) RenderCommitLength added in v0.8.1

func (gui *Gui) RenderCommitLength()

RenderCommitLength is a function.

func (*Gui) RenderSelectedBranchUpstreamDifferences added in v0.8.1

func (gui *Gui) RenderSelectedBranchUpstreamDifferences() error

func (*Gui) Run

func (gui *Gui) Run() error

Run setup the gui with keybindings and start the mainloop

func (*Gui) RunWithSubprocesses

func (gui *Gui) RunWithSubprocesses() error

RunWithSubprocesses loops, instantiating a new gocui.Gui with each iteration if the error returned from a run is a ErrSubProcess, it runs the subprocess otherwise it handles the error, possibly by quitting the application

func (*Gui) SetColorScheme added in v0.1.65

func (gui *Gui) SetColorScheme() error

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

func (*Gui) WithWaitingStatus added in v0.8.1

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 SentinelErrors added in v0.1.62

type SentinelErrors struct {
	ErrSubProcess error
	ErrNoFiles    error
	ErrSwitchRepo error
}

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

type Teml added in v0.1.62

type Teml i18n.Teml

Teml is short for template used to make the required map[string]interface{} shorter when using gui.Tr.SLocalize and gui.Tr.TemplateLocalize

Jump to

Keyboard shortcuts

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