mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-20 17:22:23 +03:00
Add PagerConfig
This is an object that is owned by Gui, is accessible through GuiCommon.State(), and also passed down to GitCommand, where it is mostly needed. Right now it simply wraps access to the Git.Paging config, which isn't very exciting, but we'll extend it in the next commit to handle a slice of pagers (and maintain the currently selected pager index), and doing this refactoring up front allows us to make that change without having to touch clients.
This commit is contained in:
@@ -69,6 +69,8 @@ type Gui struct {
|
||||
// this is the state of the GUI for the current repo
|
||||
State *GuiRepoState
|
||||
|
||||
pagerConfig *config.PagerConfig
|
||||
|
||||
CustomCommandsClient *custom_commands.Client
|
||||
|
||||
// this is a mapping of repos to gui states, so that we can restore the original
|
||||
@@ -169,6 +171,10 @@ func (self *StateAccessor) GetRepoState() types.IRepoStateAccessor {
|
||||
return self.gui.State
|
||||
}
|
||||
|
||||
func (self *StateAccessor) GetPagerConfig() *config.PagerConfig {
|
||||
return self.gui.pagerConfig
|
||||
}
|
||||
|
||||
func (self *StateAccessor) GetIsRefreshingFiles() bool {
|
||||
return self.gui.IsRefreshingFiles
|
||||
}
|
||||
@@ -307,6 +313,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
|
||||
gui.gitVersion,
|
||||
gui.os,
|
||||
git_config.NewStdCachedGitConfig(gui.Log),
|
||||
gui.pagerConfig,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -653,7 +660,7 @@ func (gui *Gui) Contexts() *context.ContextTree {
|
||||
// NewGui builds a new gui handler
|
||||
func NewGui(
|
||||
cmn *common.Common,
|
||||
config config.AppConfigurer,
|
||||
configurer config.AppConfigurer,
|
||||
gitVersion *git_commands.GitVersion,
|
||||
updater *updates.Updater,
|
||||
showRecentRepos bool,
|
||||
@@ -663,7 +670,7 @@ func NewGui(
|
||||
gui := &Gui{
|
||||
Common: cmn,
|
||||
gitVersion: gitVersion,
|
||||
Config: config,
|
||||
Config: configurer,
|
||||
Updater: updater,
|
||||
statusManager: status.NewStatusManager(),
|
||||
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
||||
@@ -713,7 +720,7 @@ func NewGui(
|
||||
credentialsHelper.PromptUserForCredential,
|
||||
)
|
||||
|
||||
osCommand := oscommands.NewOSCommand(cmn, config, oscommands.GetPlatform(), guiIO)
|
||||
osCommand := oscommands.NewOSCommand(cmn, configurer, oscommands.GetPlatform(), guiIO)
|
||||
|
||||
gui.os = osCommand
|
||||
|
||||
@@ -724,6 +731,8 @@ func NewGui(
|
||||
gui.BackgroundRoutineMgr = &BackgroundRoutineMgr{gui: gui}
|
||||
gui.stateAccessor = &StateAccessor{gui: gui}
|
||||
|
||||
gui.pagerConfig = config.NewPagerConfig(func() *config.UserConfig { return gui.UserConfig() })
|
||||
|
||||
return gui, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user