1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/integration/components/views.go

122 lines
2.4 KiB
Go
Raw Normal View History

2022-12-26 02:12:56 +02:00
package components
import (
"fmt"
"github.com/jesseduffield/gocui"
)
2022-12-27 06:22:31 +02:00
type Views struct {
input *Input
2022-12-27 06:56:02 +02:00
}
// not exporting this because I want the test to always be explicit about what
// view it's dealing with.
func (self *Views) current() *View {
2022-12-27 06:56:02 +02:00
return &View{
context: "current view",
getView: func() *gocui.View { return self.input.gui.CurrentContext().GetView() },
2022-12-27 06:56:02 +02:00
input: self.input,
}
}
func (self *Views) Main() *View {
return &View{
context: "main view",
getView: func() *gocui.View { return self.input.gui.MainView() },
2022-12-27 06:56:02 +02:00
input: self.input,
}
}
func (self *Views) Secondary() *View {
return &View{
context: "secondary view",
getView: func() *gocui.View { return self.input.gui.SecondaryView() },
2022-12-27 06:56:02 +02:00
input: self.input,
}
}
func (self *Views) ByName(viewName string) *View {
return &View{
context: fmt.Sprintf("%s view", viewName),
getView: func() *gocui.View { return self.input.gui.View(viewName) },
2022-12-27 06:56:02 +02:00
input: self.input,
}
}
func (self *Views) Commits() *View {
return self.ByName("commits")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Files() *View {
return self.ByName("files")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Status() *View {
return self.ByName("status")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Submodules() *View {
return self.ByName("submodules")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Information() *View {
return self.ByName("information")
}
func (self *Views) Branches() *View {
return self.ByName("localBranches")
}
2022-12-26 02:12:56 +02:00
func (self *Views) RemoteBranches() *View {
return self.ByName("remoteBranches")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Tags() *View {
return self.ByName("tags")
}
2022-12-26 02:12:56 +02:00
func (self *Views) ReflogCommits() *View {
return self.ByName("reflogCommits")
2022-12-26 02:12:56 +02:00
}
func (self *Views) SubCommits() *View {
return self.ByName("subCommits")
}
2022-12-26 02:12:56 +02:00
func (self *Views) CommitFiles() *View {
return self.ByName("commitFiles")
2022-12-26 02:12:56 +02:00
}
func (self *Views) Stash() *View {
return self.ByName("stash")
}
2022-12-26 02:12:56 +02:00
func (self *Views) Staging() *View {
return self.ByName("staging")
2022-12-26 02:12:56 +02:00
}
2022-12-27 06:22:31 +02:00
func (self *Views) StagingSecondary() *View {
return self.ByName("stagingSecondary")
}
2022-12-27 06:22:31 +02:00
func (self *Views) Menu() *View {
return self.ByName("menu")
}
2022-12-27 06:22:31 +02:00
func (self *Views) Confirmation() *View {
return self.ByName("confirmation")
}
2022-12-27 06:22:31 +02:00
func (self *Views) CommitMessage() *View {
return self.ByName("commitMessage")
}
2022-12-27 06:22:31 +02:00
func (self *Views) Suggestions() *View {
return self.ByName("suggestions")
}
2022-12-27 06:56:02 +02:00
func (self *Views) MergeConflicts() *View {
return self.ByName("mergeConflicts")
}