diff options
author | Dawid Dziurla <dawidd0811@gmail.com> | 2018-09-04 16:07:31 +0200 |
---|---|---|
committer | Dawid Dziurla <dawidd0811@gmail.com> | 2018-09-04 16:07:31 +0200 |
commit | e21f739f4fbef045c90ab44365105c2d04334a72 (patch) | |
tree | 48bd16548c471dc6b2e630262b0a6369ce6f5e09 | |
parent | 97ad4a1643f1ef83b151d78314b9c6bcb50adbfe (diff) |
add renderGlobalOptions
render only global options for all panels
-rw-r--r-- | pkg/gui/branches_panel.go | 5 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 5 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 17 | ||||
-rw-r--r-- | pkg/gui/gui.go | 12 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 5 | ||||
-rw-r--r-- | pkg/gui/status_panel.go | 4 | ||||
-rw-r--r-- | pkg/i18n/english.go | 6 |
7 files changed, 23 insertions, 31 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 74ee14b06..26c3c5618 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -115,10 +115,7 @@ func (gui *Gui) getSelectedBranch(v *gocui.View) commands.Branch { } func (gui *Gui) renderBranchesOptions(g *gocui.Gui) error { - return gui.renderOptionsMap(g, map[string]string{ - "← → ↑ ↓": gui.Tr.SLocalize("navigate"), - "?": gui.Tr.SLocalize("help"), - }) + return gui.renderGlobalOptions(g) } // may want to standardise how these select methods work diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 9e8eb681a..06b8490a9 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -59,10 +59,7 @@ func (gui *Gui) handleResetToCommit(g *gocui.Gui, commitView *gocui.View) error } func (gui *Gui) renderCommitsOptions(g *gocui.Gui) error { - return gui.renderOptionsMap(g, map[string]string{ - "← → ↑ ↓": gui.Tr.SLocalize("navigate"), - "?": gui.Tr.SLocalize("help"), - }) + return gui.renderGlobalOptions(g) } func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 43a88c6d2..52366304b 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -172,22 +172,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) renderfilesOptions(g *gocui.Gui, file *commands.File) error { - optionsMap := map[string]string{ - "PgUp/PgDn": gui.Tr.SLocalize("scroll"), - "← → ↑ ↓": gui.Tr.SLocalize("navigate"), - "?": gui.Tr.SLocalize("help"), - } - if gui.State.HasMergeConflicts { - optionsMap["a"] = gui.Tr.SLocalize("abortMerge") - optionsMap["m"] = gui.Tr.SLocalize("resolveMergeConflicts") - } - if file == nil { - return gui.renderOptionsMap(g, optionsMap) - } - if file.Tracked { - optionsMap["d"] = gui.Tr.SLocalize("checkout") - } - return gui.renderOptionsMap(g, optionsMap) + return gui.renderGlobalOptions(g) } func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 74cfd06a6..bd5d5fd2c 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -348,6 +348,18 @@ func (gui *Gui) renderAppStatus(g *gocui.Gui) error { return nil } +func (gui *Gui) renderGlobalOptions(g *gocui.Gui) error { + return gui.renderOptionsMap(g, map[string]string{ + "R": gui.Tr.SLocalize("refresh"), + "p": gui.Tr.SLocalize("pull"), + "P": gui.Tr.SLocalize("push"), + "PgUp/PgDn": gui.Tr.SLocalize("scroll"), + "← → ↑ ↓": gui.Tr.SLocalize("navigate"), + "esc/q": gui.Tr.SLocalize("close"), + "?": gui.Tr.SLocalize("help"), + }) +} + func (gui *Gui) goEvery(g *gocui.Gui, interval time.Duration, function func(*gocui.Gui) error) { go func() { for range time.Tick(interval) { diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index 33f42e5f6..9ca07717b 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -33,10 +33,7 @@ func (gui *Gui) getSelectedStashEntry(v *gocui.View) *commands.StashEntry { } func (gui *Gui) renderStashOptions(g *gocui.Gui) error { - return gui.renderOptionsMap(g, map[string]string{ - "← → ↑ ↓": gui.Tr.SLocalize("navigate"), - "?": gui.Tr.SLocalize("help"), - }) + return gui.renderGlobalOptions(g) } func (gui *Gui) handleStashEntrySelect(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 96eb2d52e..6948e9678 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -42,9 +42,7 @@ func (gui *Gui) refreshStatus(g *gocui.Gui) error { } func (gui *Gui) renderStatusOptions(g *gocui.Gui) error { - return gui.renderOptionsMap(g, map[string]string{ - "?": gui.Tr.SLocalize("help"), - }) + return gui.renderGlobalOptions(g) } func (gui *Gui) handleCheckForUpdate(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 8b0d266f3..5dcb9d544 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -79,6 +79,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { ID: "refresh", Other: "refresh", }, &i18n.Message{ + ID: "push", + Other: "push", + }, &i18n.Message{ + ID: "pull", + Other: "pull", + }, &i18n.Message{ ID: "addPatch", Other: "add patch", }, &i18n.Message{ |