gui

package
v0.40.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 55 Imported by: 1

Documentation

Index

Constants

View Source
const HORIZONTAL_SCROLL_FACTOR = 3
View Source
const StartupPopupVersion = 5

Variables

View Source
var OverlappingEdges = false

OverlappingEdges determines if panel edges overlap

View Source
var RuneReplacements = map[rune]string{

	graph.MergeSymbol:  "M",
	graph.CommitSymbol: "o",
}

Functions

func Headless added in v0.36.0

func Headless() bool

func NewDummyUpdater added in v0.30.1

func NewDummyUpdater() *updates.Updater

NewDummyGui creates a new dummy GUI for testing

func OnFocusWrapper added in v0.32.1

func OnFocusWrapper(f func() error) func(opts types.OnFocusOpts) error

using this wrapper for when an onFocus function doesn't care about any potential props that could be passed

Types

type BackgroundRoutineMgr added in v0.39.0

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

func (*BackgroundRoutineMgr) PauseBackgroundRefreshes added in v0.39.0

func (self *BackgroundRoutineMgr) PauseBackgroundRefreshes(pause bool)

type ContextMgr added in v0.39.0

type ContextMgr struct {
	ContextStack []types.Context
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewContextMgr added in v0.39.0

func NewContextMgr(
	gui *Gui,
	allContexts *context.ContextTree,
) *ContextMgr

func (*ContextMgr) ActivateContext added in v0.39.0

func (self *ContextMgr) ActivateContext(c types.Context, opts types.OnFocusOpts) error

func (*ContextMgr) AllFilterable added in v0.39.0

func (self *ContextMgr) AllFilterable() []types.IFilterableContext

func (*ContextMgr) AllList added in v0.39.0

func (self *ContextMgr) AllList() []types.IListContext

all list contexts

func (*ContextMgr) AllPatchExplorer added in v0.39.0

func (self *ContextMgr) AllPatchExplorer() []types.IPatchExplorerContext

func (*ContextMgr) AllSearchable added in v0.39.0

func (self *ContextMgr) AllSearchable() []types.ISearchableContext

func (*ContextMgr) ContextForKey added in v0.40.0

func (self *ContextMgr) ContextForKey(key types.ContextKey) types.Context

func (*ContextMgr) Current added in v0.39.0

func (self *ContextMgr) Current() types.Context

func (*ContextMgr) CurrentSide added in v0.39.0

func (self *ContextMgr) CurrentSide() types.Context

Note that this could return the 'status' context which is not itself a list context.

func (*ContextMgr) CurrentStatic added in v0.39.0

func (self *ContextMgr) CurrentStatic() types.Context

static as opposed to popup

func (*ContextMgr) ForEach added in v0.39.0

func (self *ContextMgr) ForEach(f func(types.Context))

func (*ContextMgr) IsCurrent added in v0.39.0

func (self *ContextMgr) IsCurrent(c types.Context) bool

func (*ContextMgr) Pop added in v0.39.0

func (self *ContextMgr) Pop() error

func (*ContextMgr) Push added in v0.39.0

func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) error

func (*ContextMgr) RemoveContexts added in v0.39.0

func (self *ContextMgr) RemoveContexts(contextsToRemove []types.Context) error

func (*ContextMgr) Replace added in v0.39.0

func (self *ContextMgr) Replace(c types.Context) error

use when you don't want to return to the original context upon hitting escape: you want to go that context's parent instead.

type Gui

type Gui struct {
	*common.Common

	// this is the state of the GUI for the current repo
	State *GuiRepoState

	CustomCommandsClient *custom_commands.Client

	// this is a mapping of repos to gui states, so that we can restore the original
	// gui state when returning from a subrepo.
	// In repos with multiple worktrees, we store a separate repo state per worktree.
	RepoStateMap map[Repo]*GuiRepoState
	Config       config.AppConfigurer
	Updater      *updates.Updater

	Mutexes types.Mutexes

	// when you enter into a submodule we'll append the superproject's path to this array
	// so that you can return to the superproject
	RepoPathStack *utils.StringStack

	// this tells us whether our views have been initially set up
	ViewsSetup bool

	Views types.Views

	// Log of the commands/actions logged in the Command Log panel.
	GuiLog []string

	// the extras window contains things like the command log
	ShowExtrasWindow bool

	PopupHandler types.IPopupHandler

	IsNewRepo bool

	IsRefreshingFiles bool

	// we use this to decide whether we'll return to the original directory that
	// lazygit was opened in, or if we'll retain the one we're currently in.
	RetainOriginalDir bool

	PrevLayout PrevLayout

	// this is the initial dir we are in upon opening lazygit. We hold onto this
	// in case we want to restore it before quitting for users who have set up
	// the feature for changing directory upon quit.
	// The reason we don't just wait until quit time to handle changing directories
	// is because some users want to keep track of the current lazygit directory in an outside
	// process
	InitialDir string

	BackgroundRoutineMgr *BackgroundRoutineMgr

	Updating bool
	// contains filtered or unexported fields
}

Gui wraps the gocui Gui object which handles rendering and events

func NewDummyGui added in v0.30.1

func NewDummyGui() *Gui

func NewGui

func NewGui(
	cmn *common.Common,
	config config.AppConfigurer,
	gitVersion *git_commands.GitVersion,
	updater *updates.Updater,
	showRecentRepos bool,
	initialDir string,
) (*Gui, error)

for now the split view will always be on NewGui builds a new gui handler

func (*Gui) Contexts added in v0.22.0

func (gui *Gui) Contexts() *context.ContextTree

func (*Gui) GetCheatsheetKeybindings added in v0.35.0

func (self *Gui) GetCheatsheetKeybindings() []*types.Binding

only to be called from the cheatsheet generate script. This mutates the Gui struct.

func (*Gui) GetInitialKeybindings added in v0.7.1

func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBinding)

renaming receiver to 'self' to aid refactoring. Will probably end up moving all Gui handlers to this pattern eventually.

func (*Gui) GetInitialKeybindingsWithCustomCommands added in v0.39.0

func (self *Gui) GetInitialKeybindingsWithCustomCommands() ([]*types.Binding, []*gocui.ViewMouseBinding)

func (*Gui) Helpers added in v0.39.0

func (gui *Gui) Helpers() *helpers.Helpers

func (*Gui) LogAction added in v0.35.0

func (gui *Gui) LogAction(action string)

our UI command log looks like this: Stage File: git add -- 'filename' Unstage File: git reset HEAD 'filename'

The 'Stage File' and 'Unstage File' lines are actions i.e they group up a set of command logs (typically there's only one command under an action but there may be more). So we call logAction to log the 'Stage File' part and then we call logCommand to log the command itself. We pass logCommand to our OSCommand struct so that it can handle logging commands for us.

func (*Gui) LogCommand added in v0.35.0

func (gui *Gui) LogCommand(cmdStr string, commandLine bool)

func (*Gui) RefreshMainView added in v0.36.0

func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Context) error

func (*Gui) Run

func (gui *Gui) Run(startArgs appTypes.StartArgs) error

Run: setup the gui with keybindings and start the mainloop

func (*Gui) RunAndHandleError added in v0.27.1

func (gui *Gui) RunAndHandleError(startArgs appTypes.StartArgs) error

func (*Gui) SetKeybinding added in v0.35.0

func (gui *Gui) SetKeybinding(binding *types.Binding) error

func (*Gui) SetMouseKeybinding added in v0.35.0

func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error

warning: mutates the binding

type GuiDriver added in v0.36.0

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

this gives our integration test a way of interacting with the gui for sending keypresses and reading state.

func (*GuiDriver) CheckedOutRef added in v0.36.0

func (self *GuiDriver) CheckedOutRef() *models.Branch

func (*GuiDriver) ContextForView added in v0.38.0

func (self *GuiDriver) ContextForView(viewName string) types.Context

func (*GuiDriver) CurrentContext added in v0.36.0

func (self *GuiDriver) CurrentContext() types.Context

func (*GuiDriver) Fail added in v0.36.0

func (self *GuiDriver) Fail(message string)

func (*GuiDriver) Keys added in v0.36.0

func (self *GuiDriver) Keys() config.KeybindingConfig

func (*GuiDriver) Log added in v0.36.0

func (self *GuiDriver) Log(message string)

logs to the normal place that you log to i.e. viewable with `lazygit --logs`

func (*GuiDriver) LogUI added in v0.36.0

func (self *GuiDriver) LogUI(message string)

logs in the actual UI (in the commands panel)

func (*GuiDriver) MainView added in v0.36.0

func (self *GuiDriver) MainView() *gocui.View

func (*GuiDriver) PressKey added in v0.36.0

func (self *GuiDriver) PressKey(keyStr string)

func (*GuiDriver) SecondaryView added in v0.36.0

func (self *GuiDriver) SecondaryView() *gocui.View

func (*GuiDriver) SetCaption added in v0.40.0

func (self *GuiDriver) SetCaption(caption string)

func (*GuiDriver) SetCaptionPrefix added in v0.40.0

func (self *GuiDriver) SetCaptionPrefix(prefix string)

func (*GuiDriver) View added in v0.36.0

func (self *GuiDriver) View(viewName string) *gocui.View

type GuiRepoState added in v0.35.0

type GuiRepoState struct {
	Model *types.Model
	Modes *types.Modes

	SplitMainPanel bool
	LimitCommits   bool

	SearchState  *types.SearchState
	StartupStage types.StartupStage // Allows us to not load everything at once

	ContextMgr *ContextMgr
	Contexts   *context.ContextTree

	// WindowViewNameMap is a mapping of windows to the current view of that window.
	// Some views move between windows for example the commitFiles view and when cycling through
	// side windows we need to know which view to give focus to for a given window
	WindowViewNameMap *utils.ThreadSafeMap[string, string]

	// tells us whether we've set up our views for the current repo. We'll need to
	// do this whenever we switch back and forth between repos to get the views
	// back in sync with the repo state
	ViewsSetup bool

	ScreenMode types.WindowMaximisation

	CurrentPopupOpts *types.CreatePopupPanelOpts
}

func (*GuiRepoState) GetCurrentPopupOpts added in v0.39.0

func (self *GuiRepoState) GetCurrentPopupOpts() *types.CreatePopupPanelOpts

func (*GuiRepoState) GetScreenMode added in v0.39.0

func (self *GuiRepoState) GetScreenMode() types.WindowMaximisation

func (*GuiRepoState) GetSearchState added in v0.39.0

func (self *GuiRepoState) GetSearchState() *types.SearchState

func (*GuiRepoState) GetSplitMainPanel added in v0.39.0

func (self *GuiRepoState) GetSplitMainPanel() bool

func (*GuiRepoState) GetStartupStage added in v0.39.0

func (self *GuiRepoState) GetStartupStage() types.StartupStage

func (*GuiRepoState) GetViewsSetup added in v0.39.0

func (self *GuiRepoState) GetViewsSetup() bool

func (*GuiRepoState) GetWindowViewNameMap added in v0.39.0

func (self *GuiRepoState) GetWindowViewNameMap() *utils.ThreadSafeMap[string, string]

func (*GuiRepoState) InSearchPrompt added in v0.39.0

func (self *GuiRepoState) InSearchPrompt() bool

func (*GuiRepoState) SetCurrentPopupOpts added in v0.39.0

func (self *GuiRepoState) SetCurrentPopupOpts(value *types.CreatePopupPanelOpts)

func (*GuiRepoState) SetScreenMode added in v0.39.0

func (self *GuiRepoState) SetScreenMode(value types.WindowMaximisation)

func (*GuiRepoState) SetSplitMainPanel added in v0.39.0

func (self *GuiRepoState) SetSplitMainPanel(value bool)

func (*GuiRepoState) SetStartupStage added in v0.39.0

func (self *GuiRepoState) SetStartupStage(value types.StartupStage)

type IntegrationTest added in v0.36.0

type IntegrationTest interface {
	Run(*GuiDriver)
}

type OptionsMapMgr added in v0.39.0

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

type PrevLayout added in v0.35.0

type PrevLayout struct {
	Information string
	MainWidth   int
	MainHeight  int
}

we keep track of some stuff from one render to the next to see if certain things have changed

type Repo added in v0.27.1

type Repo string

type StateAccessor added in v0.39.0

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

func (*StateAccessor) GetIsRefreshingFiles added in v0.39.0

func (self *StateAccessor) GetIsRefreshingFiles() bool

func (*StateAccessor) GetRepoPathStack added in v0.39.0

func (self *StateAccessor) GetRepoPathStack() *utils.StringStack

func (*StateAccessor) GetRepoState added in v0.39.0

func (self *StateAccessor) GetRepoState() types.IRepoStateAccessor

func (*StateAccessor) GetRetainOriginalDir added in v0.39.0

func (self *StateAccessor) GetRetainOriginalDir() bool

func (*StateAccessor) GetShowExtrasWindow added in v0.39.0

func (self *StateAccessor) GetShowExtrasWindow() bool

func (*StateAccessor) GetUpdating added in v0.39.0

func (self *StateAccessor) GetUpdating() bool

func (*StateAccessor) SetIsRefreshingFiles added in v0.39.0

func (self *StateAccessor) SetIsRefreshingFiles(value bool)

func (*StateAccessor) SetRetainOriginalDir added in v0.39.0

func (self *StateAccessor) SetRetainOriginalDir(value bool)

func (*StateAccessor) SetShowExtrasWindow added in v0.39.0

func (self *StateAccessor) SetShowExtrasWindow(value bool)

func (*StateAccessor) SetUpdating added in v0.39.0

func (self *StateAccessor) SetUpdating(value bool)

Jump to

Keyboard shortcuts

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