gui

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 63 Imported by: 1

Documentation

Index

Constants

View Source
const COMMIT_THRESHOLD = 200

after selecting the 200th commit, we'll load in all the rest

View Source
const HORIZONTAL_SCROLL_FACTOR = 3
View Source
const INFO_SECTION_PADDING = " "
View Source
const MAX_WATCHED_FILES = 50

macs for some bizarre reason cap the number of watchable files to 256. there's no obvious platform agnostic way to check the situation of the user's computer so we're just arbitrarily capping at 200. This isn't so bad because file watching is only really an added bonus for faster refreshing.

View Source
const SEARCH_PREFIX = "search: "
View Source
const StartupPopupVersion = 5
View Source
const UNKNOWN_VIEW_ERROR_MSG = "unknown view"

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 GetRecordingSpeed added in v0.36.0

func GetRecordingSpeed() float64

func Headless added in v0.36.0

func Headless() bool

func LoadRecording added in v0.36.0

func LoadRecording() (*gocui.Recording, error)

func MergeMaps added in v0.35.0

func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V

func NewDummyUpdater added in v0.30.1

func NewDummyUpdater() *updates.Updater

NewDummyGui creates a new dummy GUI for testing

func NewFileWatcher added in v0.12.1

func NewFileWatcher(log *logrus.Entry) *fileWatcher

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

func RecordingEvents added in v0.36.0

func RecordingEvents() bool

func Replaying added in v0.36.0

func Replaying() bool

func SaveRecording added in v0.36.0

func SaveRecording(recording *gocui.Recording) error

Types

type ContextManager added in v0.27.1

type ContextManager struct {
	ContextStack []types.Context
	sync.RWMutex
}

func NewContextManager added in v0.27.1

func NewContextManager(initialContext types.Context) ContextManager

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

	// Log of the commands that get run, to be displayed to the user.
	CmdLog []string

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

	PopupHandler types.IPopupHandler

	IsNewRepo bool

	// flag as to whether or not the diff view should ignore whitespace
	IgnoreWhitespaceInDiffView 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
	// 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,
	gitConfig git_config.IGitConfig,
	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) 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) 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) Refresh added in v0.35.0

func (gui *Gui) Refresh(options types.RefreshOptions) error

func (*Gui) RefreshMainView added in v0.36.0

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

func (*Gui) RenderCommitLength added in v0.2.2

func (gui *Gui) RenderCommitLength()

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

func (*Gui) SwitchToCommitFilesContext added in v0.35.0

func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesContextOpts) error

func (*Gui) TransientContexts added in v0.35.0

func (gui *Gui) TransientContexts() []types.Context

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) 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) Model added in v0.36.0

func (self *GuiDriver) Model() *types.Model

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

	// Suggestions will sometimes appear when typing into a prompt
	Suggestions []*types.Suggestion

	Updating       bool
	SplitMainPanel bool
	LimitCommits   bool

	IsRefreshingFiles bool
	Searching         searchingState
	StartupStage      StartupStage // Allows us to not load everything at once

	ContextManager ContextManager
	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 WindowMaximisation

	CurrentPopupOpts *types.CreatePopupPanelOpts
	// contains filtered or unexported fields
}

type IntegrationTest added in v0.36.0

type IntegrationTest interface {
	Run(guiAdapter *GuiDriver)
}

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 StartupStage added in v0.27.1

type StartupStage int

startup stages so we don't need to load everything at once

const (
	INITIAL StartupStage = iota
	COMPLETE
)

type Views added in v0.27.1

type Views struct {
	Status         *gocui.View
	Submodules     *gocui.View
	Files          *gocui.View
	Branches       *gocui.View
	Remotes        *gocui.View
	Tags           *gocui.View
	RemoteBranches *gocui.View
	ReflogCommits  *gocui.View
	Commits        *gocui.View
	Stash          *gocui.View

	Main                   *gocui.View
	Secondary              *gocui.View
	Staging                *gocui.View
	StagingSecondary       *gocui.View
	PatchBuilding          *gocui.View
	PatchBuildingSecondary *gocui.View
	MergeConflicts         *gocui.View

	Options       *gocui.View
	Confirmation  *gocui.View
	Menu          *gocui.View
	CommitMessage *gocui.View
	CommitFiles   *gocui.View
	SubCommits    *gocui.View
	Information   *gocui.View
	AppStatus     *gocui.View
	Search        *gocui.View
	SearchPrefix  *gocui.View
	Limit         *gocui.View
	Suggestions   *gocui.View
	Tooltip       *gocui.View
	Extras        *gocui.View
}

type WindowMaximisation added in v0.27.1

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
)

Jump to

Keyboard shortcuts

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