Documentation
¶
Index ¶
- type Binding
- type CheckoutRefOptions
- type ConfirmOpts
- type Context
- type ContextCommon
- type ContextKey
- type ContextKind
- type CreateMenuOptions
- type CreatePopupPanelOpts
- type DiffableContext
- type DisabledReason
- type Guard
- type HasKeybindings
- type HasUrn
- type HelperCommon
- type IBaseContext
- type IContextMgr
- type IController
- type IFilterableContext
- type IGuiCommon
- type IList
- type IListContext
- type IListCursor
- type IListPanelState
- type IModeMgr
- type IPatchExplorerContext
- type IPopupHandler
- type IRepoStateAccessor
- type ISearchHistoryContext
- type ISearchableContext
- type IStateAccessor
- type IViewTrait
- type ItemOperation
- type Key
- type KeybindingGuards
- type KeybindingsFn
- type KeybindingsOpts
- type ListItem
- type MainContextPair
- type MainViewPairs
- type MenuItem
- type MenuSection
- type Model
- type Modes
- type MouseKeybindingsFn
- type Mutexes
- type OnFocusLostOpts
- type OnFocusOpts
- type ParentContexter
- type PromptOpts
- type Ref
- type RefreshMainOpts
- type RefreshMode
- type RefreshOptions
- type RefreshableView
- type RenderStringTask
- type RenderStringWithScrollTask
- type RenderStringWithoutScrollTask
- type RunCommandTask
- type RunPtyTask
- type SearchState
- type SearchType
- type StartupStage
- type Suggestion
- type ToastKind
- type UpdateTask
- type VersionNumber
- type ViewUpdateOpts
- type Views
- type WindowMaximisation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binding ¶
type Binding struct { ViewName string Handler func() error Key Key Modifier gocui.Modifier Description string // If defined, this is used in place of Description when showing the keybinding // in the options view at the bottom left of the screen. ShortDescription string Alternative string Tag string // e.g. 'navigation'. Used for grouping things in the cheatsheet OpensMenu bool // If true, the keybinding will appear at the bottom of the screen. // Even if set to true, the keybinding will not be displayed if it is currently // disabled. We could instead display it with a strikethrough, but there's // limited realestate to show all the keybindings we want, so we're hiding it instead. DisplayOnScreen bool // if unset, the binding will be displayed in the default color. Only applies to the keybinding // on-screen, not in the keybindings menu. DisplayStyle *style.TextStyle // to be displayed if the keybinding is highlighted from within a menu Tooltip string // Function to decide whether the command is enabled, and why. If this // returns an empty string, it is; if it returns a non-empty string, it is // disabled and we show the given text in an error message when trying to // invoke it. When left nil, the command is always enabled. Note that this // function must not do expensive calls. GetDisabledReason func() *DisabledReason }
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) IsDisabled ¶
type CheckoutRefOptions ¶
type ConfirmOpts ¶
type Context ¶
type Context interface { IBaseContext HandleFocus(opts OnFocusOpts) error HandleFocusLost(opts OnFocusLostOpts) error HandleRender() error HandleRenderToMain() error }
type ContextCommon ¶
type ContextCommon struct { *common.Common IGuiCommon }
type ContextKey ¶
type ContextKey string
type ContextKind ¶
type ContextKind int
const ( // this is your files, branches, commits, contexts etc. They're all on the left hand side // and you can cycle through them. SIDE_CONTEXT ContextKind = iota // This is either the left or right 'main' contexts that appear to the right of the side contexts MAIN_CONTEXT // A persistent popup is one that has its own identity e.g. the commit message context. // When you open a popup over it, we'll let you return to it upon pressing escape PERSISTENT_POPUP // A temporary popup is one that could be used for various things (e.g. a generic menu or confirmation popup). // Because we re-use these contexts, they're temporary in that you can't return to them after you've switched from them // to some other context, because the context you switched to might actually be the same context but rendering different content. // We should really be able to spawn new contexts for menus/prompts so that we can actually return to old ones. TEMPORARY_POPUP // This contains the command log, underneath the main contexts. EXTRAS_CONTEXT // only used by the one global context, purely for the sake of defining keybindings globally GLOBAL_CONTEXT // a display context only renders a view. It has no keybindings associated and // it cannot receive focus. DISPLAY_CONTEXT )
type CreateMenuOptions ¶
type CreatePopupPanelOpts ¶
type DiffableContext ¶
type DiffableContext interface { Context // Returns the current diff terminals of the currently selected item. // in the case of a branch it returns both the branch and it's upstream name, // which becomes an option when you bring up the diff menu, but when you're just // flicking through branches it will be using the local branch name. GetDiffTerminals() []string }
type DisabledReason ¶
type DisabledReason struct { Text string // When trying to invoke a disabled key binding or menu item, we normally // show the disabled reason as a toast; setting this to true shows it as an // error panel instead. This is useful if the text is very long, or if it is // important enough to show it more prominently, or both. ShowErrorInPanel bool }
type Guard ¶
A guard is a decorator which checks something before executing a handler and potentially early-exits if some precondition hasn't been met.
type HasKeybindings ¶
type HasKeybindings interface { GetKeybindings(opts KeybindingsOpts) []*Binding GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding GetOnClick() func() error GetOnRenderToMain() func() error GetOnFocus() func(OnFocusOpts) error GetOnFocusLost() func(OnFocusLostOpts) error }
type HelperCommon ¶
type HelperCommon struct {
*ContextCommon
}
type IBaseContext ¶
type IBaseContext interface { HasKeybindings ParentContexter GetKind() ContextKind GetViewName() string GetView() *gocui.View GetViewTrait() IViewTrait GetWindowName() string SetWindowName(string) GetKey() ContextKey IsFocusable() bool // if a context is transient, then it only appears via some keybinding on another // context. Until we add support for having multiple of the same context, no two // of the same transient context can appear at once meaning one might be 'stolen' // from another window. IsTransient() bool // this tells us if the view's bounds are determined by its window or if they're // determined independently. HasControlledBounds() bool // true if the view needs to be rerendered when its width changes NeedsRerenderOnWidthChange() bool // returns the desired title for the view upon activation. If there is no desired title (returns empty string), then // no title will be set Title() string GetOptionsMap() map[string]string AddKeybindingsFn(KeybindingsFn) AddMouseKeybindingsFn(MouseKeybindingsFn) // This is a bit of a hack at the moment: we currently only set an onclick function so that // our list controller can come along and wrap it in a list-specific click handler. // We'll need to think of a better way to do this. AddOnClickFn(func() error) AddOnRenderToMainFn(func() error) AddOnFocusFn(func(OnFocusOpts) error) AddOnFocusLostFn(func(OnFocusLostOpts) error) }
type IContextMgr ¶
type IContextMgr interface { Push(context Context, opts ...OnFocusOpts) error Pop() error Replace(context Context) error Current() Context CurrentStatic() Context CurrentSide() Context IsCurrent(c Context) bool ForEach(func(Context)) AllList() []IListContext AllFilterable() []IFilterableContext AllSearchable() []ISearchableContext AllPatchExplorer() []IPatchExplorerContext }
type IController ¶
type IController interface { HasKeybindings Context() Context }
type IFilterableContext ¶
type IFilterableContext interface { Context IListPanelState ISearchHistoryContext SetFilter(string) GetFilter() string ClearFilter() ReApplyFilter() IsFiltering() bool IsFilterableContext() }
type IGuiCommon ¶
type IGuiCommon interface { IPopupHandler LogAction(action string) LogCommand(cmdStr string, isCommandLine bool) // we call this when we want to refetch some models and render the result. Internally calls PostRefreshUpdate Refresh(RefreshOptions) error // we call this when we've changed something in the view model but not the actual model, // e.g. expanding or collapsing a folder in a file view. Calling 'Refresh' in this // case would be overkill, although refresh will internally call 'PostRefreshUpdate' PostRefreshUpdate(Context) error // renders string to a view without resetting its origin SetViewContent(view *gocui.View, content string) // resets cursor and origin of view. Often used before calling SetViewContent ResetViewOrigin(view *gocui.View) // this just re-renders the screen Render() // allows rendering to main views (i.e. the ones to the right of the side panel) // in such a way that avoids concurrency issues when there are slow commands // to display the output of RenderToMainViews(opts RefreshMainOpts) error // used purely for the sake of RenderToMainViews to provide the pair of main views we want to render to MainViewPairs() MainViewPairs // returns true if command completed successfully RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) RunSubprocessAndRefresh(oscommands.ICmdObj) error PushContext(context Context, opts ...OnFocusOpts) error PopContext() error ReplaceContext(context Context) error // Removes all given contexts from the stack. If a given context is not in the stack, it is ignored. // This is for when you have a group of contexts that are bundled together e.g. with the commit message panel. // If you want to remove a single context, you should probably use PopContext instead. RemoveContexts([]Context) error CurrentContext() Context CurrentStaticContext() Context CurrentSideContext() Context IsCurrentContext(Context) bool // TODO: replace the above context-based methods with just using Context() e.g. replace PushContext() with Context().Push() Context() IContextMgr ContextForKey(key ContextKey) Context ActivateContext(context Context) error GetConfig() config.AppConfigurer GetAppState() *config.AppState SaveAppState() error SaveAppStateAndLogError() // Runs the given function on the UI thread (this is for things like showing a popup asking a user for input). // Only necessary to call if you're not already on the UI thread i.e. you're inside a goroutine. // All controller handlers are executed on the UI thread. OnUIThread(f func() error) // Runs a function in a goroutine. Use this whenever you want to run a goroutine and keep track of the fact // that lazygit is still busy. See docs/dev/Busy.md OnWorker(f func(gocui.Task)) // Function to call at the end of our 'layout' function which renders views // For example, you may want a view's line to be focused only after that view is // resized, if in accordion mode. AfterLayout(f func() error) // Wraps a function, attaching the given operation to the given item while // the function is executing, and also causes the given context to be // redrawn periodically. This allows the operation to be visualized with a // spinning loader animation (e.g. when a branch is being pushed). WithInlineStatus(item HasUrn, operation ItemOperation, contextKey ContextKey, f func(gocui.Task) error) error // returns the gocui Gui struct. There is a good chance you don't actually want to use // this struct and instead want to use another method above GocuiGui() *gocui.Gui Views() Views Git() *commands.GitCommand OS() *oscommands.OSCommand Model() *Model Modes() *Modes Mutexes() Mutexes State() IStateAccessor KeybindingsOpts() KeybindingsOpts CallKeybindingHandler(binding *Binding) error // hopefully we can remove this once we've moved all our keybinding stuff out of the gui god struct. GetInitialKeybindingsWithCustomCommands() ([]*Binding, []*gocui.ViewMouseBinding) // Returns true if we're running an integration test RunningIntegrationTest() bool // Returns true if we're in a demo recording/playback InDemo() bool }
type IListContext ¶
type IListCursor ¶
type IListCursor interface { GetSelectedLineIdx() int SetSelectedLineIdx(value int) SetSelection(value int) MoveSelectedLine(delta int) ClampSelection() CancelRangeSelect() GetRangeStartIdx() (int, bool) GetSelectionRange() (int, int) IsSelectingRange() bool AreMultipleItemsSelected() bool ToggleStickyRange() ExpandNonStickyRange(int) }
type IListPanelState ¶
type IPatchExplorerContext ¶
type IPatchExplorerContext interface { Context GetState() *patch_exploring.State SetState(*patch_exploring.State) GetIncludedLineIndices() []int RenderAndFocus(isFocused bool) error Render(isFocused bool) error Focus() error GetContentToRender(isFocused bool) string GetMutex() *deadlock.Mutex IsPatchExplorerContext() // used for type switch }
type IPopupHandler ¶
type IPopupHandler interface { // Shows a popup with a (localized) "Error" caption and the given error message (in red). // // This is a convenience wrapper around Alert(). ErrorMsg(message string) error Error(err error) error // Shows a notification popup with the given title and message to the user. // // This is a convenience wrapper around Confirm(), thus the popup can be closed using both 'Enter' and 'ESC'. Alert(title string, message string) error // Shows a popup asking the user for confirmation. Confirm(opts ConfirmOpts) error // Shows a popup prompting the user for input. Prompt(opts PromptOpts) error WithWaitingStatus(message string, f func(gocui.Task) error) error WithWaitingStatusSync(message string, f func() error) error Menu(opts CreateMenuOptions) error Toast(message string) ErrorToast(message string) SetToastFunc(func(string, ToastKind)) GetPromptInput() string }
type IRepoStateAccessor ¶
type IRepoStateAccessor interface { GetViewsSetup() bool GetWindowViewNameMap() *utils.ThreadSafeMap[string, string] GetStartupStage() StartupStage SetStartupStage(stage StartupStage) GetCurrentPopupOpts() *CreatePopupPanelOpts SetCurrentPopupOpts(*CreatePopupPanelOpts) GetScreenMode() WindowMaximisation SetScreenMode(WindowMaximisation) InSearchPrompt() bool GetSearchState() *SearchState SetSplitMainPanel(bool) GetSplitMainPanel() bool }
type ISearchHistoryContext ¶
type ISearchHistoryContext interface { Context GetSearchHistory() *utils.HistoryBuffer[string] }
type ISearchableContext ¶
type IStateAccessor ¶
type IStateAccessor interface { GetRepoPathStack() *utils.StringStack GetRepoState() IRepoStateAccessor // tells us whether we're currently updating lazygit GetUpdating() bool SetUpdating(bool) SetIsRefreshingFiles(bool) GetIsRefreshingFiles() bool GetShowExtrasWindow() bool SetShowExtrasWindow(bool) GetRetainOriginalDir() bool SetRetainOriginalDir(bool) GetItemOperation(item HasUrn) ItemOperation SetItemOperation(item HasUrn, operation ItemOperation) ClearItemOperation(item HasUrn) }
type IViewTrait ¶
type IViewTrait interface { FocusPoint(yIdx int) SetRangeSelectStart(yIdx int) CancelRangeSelect() SetViewPortContent(content string) SetContent(content string) SetOriginX(value int) ViewPortYBounds() (int, int) ScrollLeft() ScrollRight() ScrollUp(value int) ScrollDown(value int) PageDelta() int SelectedLineIdx() int SetHighlight(bool) }
type ItemOperation ¶
type ItemOperation int
A long-running operation associated with an item. For example, we'll show that a branch is being pushed from so that there's visual feedback about what's happening and so that you can see multiple branches' concurrent operations
const ( ItemOperationNone ItemOperation = iota ItemOperationPushing ItemOperationPulling ItemOperationFastForwarding ItemOperationDeleting ItemOperationFetching )
type KeybindingGuards ¶
type KeybindingsFn ¶
type KeybindingsFn func(opts KeybindingsOpts) []*Binding
type KeybindingsOpts ¶
type KeybindingsOpts struct { GetKey func(key string) Key Config config.KeybindingConfig Guards KeybindingGuards }
type ListItem ¶
type ListItem interface { // ID is a SHA when the item is a commit, a filename when the item is a file, 'stash@{4}' when it's a stash entry, 'my_branch' when it's a branch ID() string // Description is something we would show in a message e.g. '123as14: push blah' for a commit Description() string }
type MainContextPair ¶
func NewMainContextPair ¶
func NewMainContextPair(main Context, secondary Context) MainContextPair
type MainViewPairs ¶
type MainViewPairs struct { Normal MainContextPair MergeConflicts MainContextPair Staging MainContextPair PatchBuilding MainContextPair }
type MenuItem ¶
type MenuItem struct { Label string // alternative to Label. Allows specifying columns which will be auto-aligned LabelColumns []string OnPress func() error // Only applies when Label is used OpensMenu bool // If Key is defined it allows the user to press the key to invoke the menu // item, as opposed to having to navigate to it Key Key // The tooltip will be displayed upon highlighting the menu item Tooltip string // If non-nil, show this in a tooltip, style the menu item as disabled, // and refuse to invoke the command DisabledReason *DisabledReason // Can be used to group menu items into sections with headers. MenuItems // with the same Section should be contiguous, and will automatically get a // section header. If nil, the item is not part of a section. // Note that pointer comparison is used to determine whether two menu items // belong to the same section, so make sure all your items in a given // section point to the same MenuSection instance. Section *MenuSection }
type MenuSection ¶
type Model ¶
type Model struct { CommitFiles []*models.CommitFile Files []*models.File Submodules []*models.SubmoduleConfig Branches []*models.Branch Commits []*models.Commit StashEntries []*models.StashEntry SubCommits []*models.Commit Remotes []*models.Remote Worktrees []*models.Worktree // FilteredReflogCommits are the ones that appear in the reflog panel. // when in filtering mode we only include the ones that match the given path FilteredReflogCommits []*models.Commit // ReflogCommits are the ones used by the branches panel to obtain recency values // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be // one and the same ReflogCommits []*models.Commit BisectInfo *git_commands.BisectInfo WorkingTreeStateAtLastCommitRefresh enums.RebaseMode RemoteBranches []*models.RemoteBranch Tags []*models.Tag // Name of the currently checked out branch. This will be set even when // we're on a detached head because we're rebasing or bisecting. CheckedOutBranch string // for displaying suggestions while typing in a file name FilesTrie *patricia.Trie Authors map[string]*models.Author }
type Modes ¶
type Modes struct { Filtering filtering.Filtering CherryPicking *cherrypicking.CherryPicking Diffing diffing.Diffing MarkedBaseCommit marked_base_commit.MarkedBaseCommit }
type MouseKeybindingsFn ¶
type MouseKeybindingsFn func(opts KeybindingsOpts) []*gocui.ViewMouseBinding
type Mutexes ¶
type Mutexes struct { RefreshingFilesMutex *deadlock.Mutex RefreshingBranchesMutex *deadlock.Mutex RefreshingStatusMutex *deadlock.Mutex LocalCommitsMutex *deadlock.Mutex SubCommitsMutex *deadlock.Mutex AuthorsMutex *deadlock.Mutex SubprocessMutex *deadlock.Mutex PopupMutex *deadlock.Mutex PtyMutex *deadlock.Mutex }
if you add a new mutex here be sure to instantiate it. We're using pointers to mutexes so that we can pass the mutexes to controllers.
type OnFocusLostOpts ¶
type OnFocusLostOpts struct {
NewContextKey ContextKey
}
type OnFocusOpts ¶
type ParentContexter ¶
type PromptOpts ¶
type RefreshMainOpts ¶
type RefreshMainOpts struct { Pair MainContextPair Main *ViewUpdateOpts Secondary *ViewUpdateOpts }
type RefreshMode ¶
type RefreshMode int
const ( SYNC RefreshMode = iota // wait until everything is done before returning ASYNC // return immediately, allowing each independent thing to update itself BLOCK_UI // wrap code in an update call to ensure UI updates all at once and keybindings aren't executed till complete )
type RefreshOptions ¶
type RefreshOptions struct { Then func() Scope []RefreshableView // e.g. []RefreshableView{COMMITS, BRANCHES}. Leave empty to refresh everything Mode RefreshMode // one of SYNC (default), ASYNC, and BLOCK_UI // Normally a refresh of the branches tries to keep the same branch selected // (by name); this is usually important in case the order of branches // changes. Passing true for KeepBranchSelectionIndex suppresses this and // keeps the selection index the same. Useful after checking out a detached // head, and selecting index 0. KeepBranchSelectionIndex bool }
type RefreshableView ¶
type RefreshableView int
models/views that we can refresh
const ( COMMITS RefreshableView = iota REBASE_COMMITS SUB_COMMITS BRANCHES FILES STASH REFLOG TAGS REMOTES WORKTREES STATUS SUBMODULES STAGING PATCH_BUILDING MERGE_CONFLICTS COMMIT_FILES // not actually a view. Will refactor this later BISECT_INFO )
type RenderStringTask ¶
type RenderStringTask struct {
Str string
}
func NewRenderStringTask ¶
func NewRenderStringTask(str string) *RenderStringTask
func (*RenderStringTask) IsUpdateTask ¶
func (t *RenderStringTask) IsUpdateTask()
type RenderStringWithScrollTask ¶
func NewRenderStringWithScrollTask ¶
func NewRenderStringWithScrollTask(str string, originX int, originY int) *RenderStringWithScrollTask
func (*RenderStringWithScrollTask) IsUpdateTask ¶
func (t *RenderStringWithScrollTask) IsUpdateTask()
type RenderStringWithoutScrollTask ¶
type RenderStringWithoutScrollTask struct {
Str string
}
func NewRenderStringWithoutScrollTask ¶
func NewRenderStringWithoutScrollTask(str string) *RenderStringWithoutScrollTask
func (*RenderStringWithoutScrollTask) IsUpdateTask ¶
func (t *RenderStringWithoutScrollTask) IsUpdateTask()
type RunCommandTask ¶
func NewRunCommandTask ¶
func NewRunCommandTask(cmd *exec.Cmd) *RunCommandTask
func NewRunCommandTaskWithPrefix ¶
func NewRunCommandTaskWithPrefix(cmd *exec.Cmd, prefix string) *RunCommandTask
func (*RunCommandTask) IsUpdateTask ¶
func (t *RunCommandTask) IsUpdateTask()
type RunPtyTask ¶
func NewRunPtyTask ¶
func NewRunPtyTask(cmd *exec.Cmd) *RunPtyTask
func (*RunPtyTask) IsUpdateTask ¶
func (t *RunPtyTask) IsUpdateTask()
type SearchState ¶
TODO: could we remove this entirely?
func NewSearchState ¶
func NewSearchState() *SearchState
func (*SearchState) SearchType ¶
func (self *SearchState) SearchType() SearchType
type SearchType ¶
type SearchType int
const ( SearchTypeNone SearchType = iota // searching is where matches are highlighted but the content is not filtered down SearchTypeSearch // filter is where the list is filtered down to only matches SearchTypeFilter )
type StartupStage ¶
type StartupStage int
startup stages so we don't need to load everything at once
const ( INITIAL StartupStage = iota COMPLETE )
type Suggestion ¶
type Suggestion struct { // value is the thing that we're matching on and the thing that will be submitted if you select the suggestion Value string // label is what is actually displayed so it can e.g. contain color Label string }
func (*Suggestion) ID ¶
func (self *Suggestion) ID() string
Conforming to the HasID interface, which is needed for list contexts
type UpdateTask ¶
type UpdateTask interface {
IsUpdateTask()
}
type VersionNumber ¶
type VersionNumber struct {
Major, Minor, Patch int
}
func ParseVersionNumber ¶
func ParseVersionNumber(versionStr string) (*VersionNumber, error)
func (*VersionNumber) IsOlderThan ¶
func (v *VersionNumber) IsOlderThan(otherVersion *VersionNumber) bool
type ViewUpdateOpts ¶
type ViewUpdateOpts struct { Title string SubTitle string Task UpdateTask }
type Views ¶
type Views struct { Status *gocui.View Submodules *gocui.View Files *gocui.View Branches *gocui.View Remotes *gocui.View Worktrees *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 CommitDescription *gocui.View CommitFiles *gocui.View SubCommits *gocui.View Information *gocui.View AppStatus *gocui.View Search *gocui.View SearchPrefix *gocui.View StatusSpacer1 *gocui.View StatusSpacer2 *gocui.View Limit *gocui.View Suggestions *gocui.View Tooltip *gocui.View Extras *gocui.View // for playing the easter egg snake game Snake *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 )