summaryrefslogtreecommitdiffstats
path: root/pkg/gui/view_helpers.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-04-02 19:20:40 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-04-06 19:34:32 +1000
commit798d3e2d54e828f25ed4aadcefff11593fa23e10 (patch)
tree3b68eedd78e13836da8d7b8c46c5862c458f02a0 /pkg/gui/view_helpers.go
parente8f99c3326f543b713cafb6420a5b9c3c9b4d50c (diff)
get rid of these positively ghastly method signatures
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r--pkg/gui/view_helpers.go38
1 files changed, 27 insertions, 11 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 522825986..22466cab9 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -251,6 +251,16 @@ func (gui *Gui) getCommitFilesView() *gocui.View {
return v
}
+func (gui *Gui) getCommitsView() *gocui.View {
+ v, _ := gui.g.View("commits")
+ return v
+}
+
+func (gui *Gui) getCredentialsView() *gocui.View {
+ v, _ := gui.g.View("commits")
+ return v
+}
+
func (gui *Gui) getCommitMessageView() *gocui.View {
v, _ := gui.g.View("commitMessage")
return v
@@ -308,6 +318,11 @@ func (gui *Gui) getConfirmationView() *gocui.View {
return v
}
+func (gui *Gui) getInformationView() *gocui.View {
+ v, _ := gui.g.View("confirmation")
+ return v
+}
+
func (gui *Gui) trimmedContent(v *gocui.View) string {
return strings.TrimSpace(v.Buffer())
}
@@ -403,15 +418,6 @@ func (gui *Gui) popupPanelFocused() bool {
return gui.isPopupPanel(gui.currentViewName())
}
-// often gocui wants functions in the form `func(g *gocui.Gui, v *gocui.View) error`
-// but sometimes we just have a function that returns an error, so this is a
-// convenience wrapper to give gocui what it wants.
-func (gui *Gui) wrappedHandler(f func() error) func(g *gocui.Gui, v *gocui.View) error {
- return func(g *gocui.Gui, v *gocui.View) error {
- return f()
- }
-}
-
// secondaryViewFocused tells us whether it appears that the secondary view is focused. The view is actually never focused for real: we just swap the main and secondary views and then you're still focused on the main view so that we can give you access to all its keybindings for free. I will probably regret this design decision soon enough.
func (gui *Gui) secondaryViewFocused() bool {
state := gui.State.Panels.LineByLine
@@ -430,14 +436,24 @@ func (gui *Gui) onViewTabClick(viewName string, tabIndex int) error {
return gui.pushContext(context)
}
-func (gui *Gui) handleNextTab(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleNextTab() error {
+ v := gui.g.CurrentView()
+ if v != nil {
+ return nil
+ }
+
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
)
}
-func (gui *Gui) handlePrevTab(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handlePrevTab() error {
+ v := gui.g.CurrentView()
+ if v != nil {
+ return nil
+ }
+
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),