1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-22 05:29:44 +02:00

134 lines
2.7 KiB
Go
Raw Normal View History

2022-12-26 11:12:56 +11:00
package components
import (
"fmt"
"github.com/jesseduffield/gocui"
)
2022-12-27 15:22:31 +11:00
type Views struct {
2022-12-27 21:35:36 +11:00
t *TestDriver
2022-12-27 15:56:02 +11:00
}
// not exporting this because I want the test to always be explicit about what
// view it's dealing with.
2022-12-28 11:27:48 +11:00
func (self *Views) current() *ViewDriver {
return &ViewDriver{
2022-12-27 15:56:02 +11:00
context: "current view",
2022-12-27 21:35:36 +11:00
getView: func() *gocui.View { return self.t.gui.CurrentContext().GetView() },
t: self.t,
2022-12-27 15:56:02 +11:00
}
}
2022-12-28 11:27:48 +11:00
func (self *Views) Main() *ViewDriver {
return &ViewDriver{
2022-12-27 15:56:02 +11:00
context: "main view",
2022-12-27 21:35:36 +11:00
getView: func() *gocui.View { return self.t.gui.MainView() },
t: self.t,
2022-12-27 15:56:02 +11:00
}
}
2022-12-28 11:27:48 +11:00
func (self *Views) Secondary() *ViewDriver {
return &ViewDriver{
2022-12-27 15:56:02 +11:00
context: "secondary view",
2022-12-27 21:35:36 +11:00
getView: func() *gocui.View { return self.t.gui.SecondaryView() },
t: self.t,
2022-12-27 15:56:02 +11:00
}
}
2022-12-28 11:27:48 +11:00
func (self *Views) byName(viewName string) *ViewDriver {
return &ViewDriver{
2022-12-27 15:56:02 +11:00
context: fmt.Sprintf("%s view", viewName),
2022-12-27 21:35:36 +11:00
getView: func() *gocui.View { return self.t.gui.View(viewName) },
t: self.t,
2022-12-27 15:56:02 +11:00
}
}
2022-12-28 11:27:48 +11:00
func (self *Views) Commits() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("commits")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Files() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("files")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Status() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("status")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Submodules() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("submodules")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Information() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("information")
}
2023-01-26 13:25:56 +11:00
func (self *Views) AppStatus() *ViewDriver {
return self.byName("appStatus")
}
2022-12-28 11:27:48 +11:00
func (self *Views) Branches() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("localBranches")
}
2022-12-26 11:12:56 +11:00
2023-02-19 13:38:15 +11:00
func (self *Views) Remotes() *ViewDriver {
return self.byName("remotes")
}
2022-12-28 11:27:48 +11:00
func (self *Views) RemoteBranches() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("remoteBranches")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Tags() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("tags")
}
2022-12-26 11:12:56 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) ReflogCommits() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("reflogCommits")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) SubCommits() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("subCommits")
}
2022-12-26 11:12:56 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) CommitFiles() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("commitFiles")
2022-12-26 11:12:56 +11:00
}
2022-12-28 11:27:48 +11:00
func (self *Views) Stash() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("stash")
}
2022-12-26 11:12:56 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) Staging() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("staging")
2022-12-26 11:12:56 +11:00
}
2022-12-27 15:22:31 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) StagingSecondary() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("stagingSecondary")
}
2022-12-27 15:22:31 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) Menu() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("menu")
}
2022-12-27 15:22:31 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) Confirmation() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("confirmation")
}
2022-12-27 15:22:31 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) CommitMessage() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("commitMessage")
}
2022-12-27 15:22:31 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) Suggestions() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("suggestions")
}
2022-12-27 15:56:02 +11:00
2022-12-28 11:27:48 +11:00
func (self *Views) MergeConflicts() *ViewDriver {
2022-12-28 10:23:54 +11:00
return self.byName("mergeConflicts")
}
2023-02-22 21:57:32 +11:00
func (self *Views) Search() *ViewDriver {
return self.byName("search")
}