summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-13 10:48:41 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit41527270ed9270ef6c463866e9c761f2285af857 (patch)
treeb46231e732b100701f82acbea7269d8e76f2dd07
parent3188526ecb1e48327249a830173de7ab5ce5978a (diff)
appease linter
-rw-r--r--pkg/gui/arrangement.go4
-rw-r--r--pkg/gui/context.go15
-rw-r--r--pkg/gui/context_config.go28
-rw-r--r--pkg/gui/gui.go12
-rw-r--r--pkg/gui/reflog_panel.go5
-rw-r--r--pkg/gui/view_helpers.go60
6 files changed, 19 insertions, 105 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go
index 9766d7885..11336946f 100644
--- a/pkg/gui/arrangement.go
+++ b/pkg/gui/arrangement.go
@@ -313,6 +313,10 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
}
}
+func (gui *Gui) getCyclableWindows() []string {
+ return []string{"status", "files", "branches", "commits", "stash"}
+}
+
func (gui *Gui) currentSideWindowName() string {
// there is always one and only one cyclable context in the context stack. We'll look from top to bottom
gui.State.ContextManager.RLock()
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index b59f0a448..9f097f78a 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -3,6 +3,8 @@ package gui
import (
"errors"
"fmt"
+ "sort"
+ "strings"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
@@ -222,6 +224,19 @@ func (gui *Gui) activateContext(c types.Context, opts ...types.OnFocusOpts) erro
return nil
}
+func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
+ optionsArray := make([]string, 0)
+ for key, description := range optionsMap {
+ optionsArray = append(optionsArray, key+": "+description)
+ }
+ sort.Strings(optionsArray)
+ return strings.Join(optionsArray, ", ")
+}
+
+func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
+ _ = gui.renderString(gui.Views.Options, gui.optionsMapToString(optionsMap))
+}
+
// also setting context on view for now. We'll need to pick one of these two approaches to stick with.
func (gui *Gui) ViewContextMapSet(viewName string, c types.Context) {
gui.State.ViewContextMap.Set(viewName, c)
diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go
index 54f139141..c8e9aa0fa 100644
--- a/pkg/gui/context_config.go
+++ b/pkg/gui/context_config.go
@@ -5,34 +5,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
-func (gui *Gui) allContexts2() []types.Context {
- return []types.Context{
- gui.State.Contexts.Global,
- gui.State.Contexts.Status,
- gui.State.Contexts.Files,
- gui.State.Contexts.Submodules,
- gui.State.Contexts.Branches,
- gui.State.Contexts.Remotes,
- gui.State.Contexts.RemoteBranches,
- gui.State.Contexts.Tags,
- gui.State.Contexts.BranchCommits,
- gui.State.Contexts.CommitFiles,
- gui.State.Contexts.ReflogCommits,
- gui.State.Contexts.Stash,
- gui.State.Contexts.Menu,
- gui.State.Contexts.Confirmation,
- gui.State.Contexts.Credentials,
- gui.State.Contexts.CommitMessage,
- gui.State.Contexts.Normal,
- gui.State.Contexts.Staging,
- gui.State.Contexts.Merging,
- gui.State.Contexts.PatchBuilding,
- gui.State.Contexts.SubCommits,
- gui.State.Contexts.Suggestions,
- gui.State.Contexts.CommandLog,
- }
-}
-
func (gui *Gui) contextTree() *context.ContextTree {
return &context.ContextTree{
Global: context.NewSimpleContext(
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 3966cd48f..7dab1dc99 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -212,18 +212,6 @@ type Controllers struct {
Global *controllers.GlobalController
}
-type listPanelState struct {
- SelectedLineIdx int
-}
-
-func (h *listPanelState) SetSelectedLineIdx(value int) {
- h.SelectedLineIdx = value
-}
-
-func (h *listPanelState) GetSelectedLineIdx() int {
- return h.SelectedLineIdx
-}
-
// for now the staging panel state, unlike the other panel states, is going to be
// non-mutative, so that we don't accidentally end up
// with mismatches of data. We might change this in the future
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index 97fd1dd4f..e45210fdf 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -1,17 +1,12 @@
package gui
import (
- "github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
// list panel functions
-func (gui *Gui) getSelectedReflogCommit() *models.Commit {
- return gui.State.Contexts.ReflogCommits.GetSelected()
-}
-
func (gui *Gui) reflogCommitsRenderToMain() error {
commit := gui.State.Contexts.ReflogCommits.GetSelected()
var task updateTask
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 202504c10..234be7a4c 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -2,19 +2,12 @@ package gui
import (
"fmt"
- "sort"
- "strings"
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/spkg/bom"
)
-func (gui *Gui) getCyclableWindows() []string {
- return []string{"status", "files", "branches", "commits", "stash"}
-}
-
func (gui *Gui) resetOrigin(v *gocui.View) error {
_ = v.SetCursor(0, 0)
return v.SetOrigin(0, 0)
@@ -41,19 +34,6 @@ func (gui *Gui) renderString(view *gocui.View, s string) error {
return nil
}
-func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
- optionsArray := make([]string, 0)
- for key, description := range optionsMap {
- optionsArray = append(optionsArray, key+": "+description)
- }
- sort.Strings(optionsArray)
- return strings.Join(optionsArray, ", ")
-}
-
-func (gui *Gui) renderOptionsMap(optionsMap map[string]string) {
- _ = gui.renderString(gui.Views.Options, gui.optionsMapToString(optionsMap))
-}
-
func (gui *Gui) currentViewName() string {
currentView := gui.g.CurrentView()
if currentView == nil {
@@ -85,46 +65,6 @@ func (gui *Gui) resizePopupPanel(v *gocui.View, content string) error {
return err
}
-func (gui *Gui) changeSelectedLine(panelState types.IListPanelState, total int, change int) {
- // TODO: find out why we're doing this
- line := panelState.GetSelectedLineIdx()
-
- if line == -1 {
- return
- }
- var newLine int
- if line+change < 0 {
- newLine = 0
- } else if line+change >= total {
- newLine = total - 1
- } else {
- newLine = line + change
- }
-
- panelState.SetSelectedLineIdx(newLine)
-}
-
-func (gui *Gui) refreshSelectedLine(panelState types.IListPanelState, total int) {
- line := panelState.GetSelectedLineIdx()
-
- if line == -1 && total > 0 {
- panelState.SetSelectedLineIdx(0)
- } else if total-1 < line {
- panelState.SetSelectedLineIdx(total - 1)
- }
-}
-
-func (gui *Gui) renderDisplayStrings(v *gocui.View, displayStrings [][]string) {
- list := utils.RenderDisplayStrings(displayStrings)
- v.SetContent(list)
-}
-
-func (gui *Gui) renderDisplayStringsInViewPort(v *gocui.View, displayStrings [][]string) {
- list := utils.RenderDisplayStrings(displayStrings)
- _, y := v.Origin()
- v.OverwriteLines(y, list)
-}
-
func (gui *Gui) globalOptionsMap() map[string]string {
keybindingConfig := gui.c.UserConfig.Keybinding