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