gui

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 56 Imported by: 0

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

func Headless() bool

func NewDummyUpdater

func NewDummyUpdater() *updates.Updater

NewDummyGui creates a new dummy GUI for testing

func OnFocusWrapper

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

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

func (*BackgroundRoutineMgr) PauseBackgroundRefreshes

func (self *BackgroundRoutineMgr) PauseBackgroundRefreshes(pause bool)

type ContextMgr

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

func NewContextMgr

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

func (*ContextMgr) ActivateContext

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

func (*ContextMgr) AllFilterable

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

func (*ContextMgr) AllList

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

all list contexts

func (*ContextMgr) AllPatchExplorer

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

func (*ContextMgr) AllSearchable

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

func (*ContextMgr) ContextForKey

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

func (*ContextMgr) Current

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

func (*ContextMgr) CurrentSide

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

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

func (*ContextMgr) CurrentStatic

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

static as opposed to popup

func (*ContextMgr) ForEach

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

func (*ContextMgr) IsCurrent

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

func (*ContextMgr) Pop

func (self *ContextMgr) Pop() error

func (*ContextMgr) Push

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

func (*ContextMgr) RemoveContexts

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

func (*ContextMgr) Replace

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

func NewDummyGui() *Gui

func NewGui

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

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

func (*Gui) Contexts

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

func (*Gui) GetCheatsheetKeybindings

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

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

func (*Gui) GetInitialKeybindings

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

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

func (*Gui) Helpers

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

func (*Gui) LogAction

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

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

func (*Gui) RefreshMainView

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

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

func (*Gui) SetKeybinding

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

func (*Gui) SetMouseKeybinding

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

warning: mutates the binding

type GuiDriver

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

func (self *GuiDriver) CheckAllToastsAcknowledged()

func (*GuiDriver) CheckedOutRef

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

func (*GuiDriver) Click

func (self *GuiDriver) Click(x, y int)

func (*GuiDriver) ContextForView

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

func (*GuiDriver) CurrentContext

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

func (*GuiDriver) Fail

func (self *GuiDriver) Fail(message string)

func (*GuiDriver) Keys

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

func (*GuiDriver) Log

func (self *GuiDriver) Log(message string)

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

func (*GuiDriver) LogUI

func (self *GuiDriver) LogUI(message string)

logs in the actual UI (in the commands panel)

func (*GuiDriver) MainView

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

func (*GuiDriver) NextToast

func (self *GuiDriver) NextToast() *string

func (*GuiDriver) PressKey

func (self *GuiDriver) PressKey(keyStr string)

func (*GuiDriver) SecondaryView

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

func (*GuiDriver) SetCaption

func (self *GuiDriver) SetCaption(caption string)

func (*GuiDriver) SetCaptionPrefix

func (self *GuiDriver) SetCaptionPrefix(prefix string)

func (*GuiDriver) View

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

type GuiRepoState

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

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

func (*GuiRepoState) GetScreenMode

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

func (*GuiRepoState) GetSearchState

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

func (*GuiRepoState) GetSplitMainPanel

func (self *GuiRepoState) GetSplitMainPanel() bool

func (*GuiRepoState) GetStartupStage

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

func (*GuiRepoState) GetViewsSetup

func (self *GuiRepoState) GetViewsSetup() bool

func (*GuiRepoState) GetWindowViewNameMap

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

func (*GuiRepoState) InSearchPrompt

func (self *GuiRepoState) InSearchPrompt() bool

func (*GuiRepoState) SetCurrentPopupOpts

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

func (*GuiRepoState) SetScreenMode

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

func (*GuiRepoState) SetSplitMainPanel

func (self *GuiRepoState) SetSplitMainPanel(value bool)

func (*GuiRepoState) SetStartupStage

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

type IntegrationTest

type IntegrationTest interface {
	Run(*GuiDriver)
}

type OptionsMapMgr

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

type PrevLayout

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

type Repo string

type StateAccessor

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

func (*StateAccessor) ClearItemOperation

func (self *StateAccessor) ClearItemOperation(item types.HasUrn)

func (*StateAccessor) GetIsRefreshingFiles

func (self *StateAccessor) GetIsRefreshingFiles() bool

func (*StateAccessor) GetItemOperation

func (self *StateAccessor) GetItemOperation(item types.HasUrn) types.ItemOperation

func (*StateAccessor) GetRepoPathStack

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

func (*StateAccessor) GetRepoState

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

func (*StateAccessor) GetRetainOriginalDir

func (self *StateAccessor) GetRetainOriginalDir() bool

func (*StateAccessor) GetShowExtrasWindow

func (self *StateAccessor) GetShowExtrasWindow() bool

func (*StateAccessor) GetUpdating

func (self *StateAccessor) GetUpdating() bool

func (*StateAccessor) SetIsRefreshingFiles

func (self *StateAccessor) SetIsRefreshingFiles(value bool)

func (*StateAccessor) SetItemOperation

func (self *StateAccessor) SetItemOperation(item types.HasUrn, operation types.ItemOperation)

func (*StateAccessor) SetRetainOriginalDir

func (self *StateAccessor) SetRetainOriginalDir(value bool)

func (*StateAccessor) SetShowExtrasWindow

func (self *StateAccessor) SetShowExtrasWindow(value bool)

func (*StateAccessor) SetUpdating

func (self *StateAccessor) SetUpdating(value bool)

Jump to

Keyboard shortcuts

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