mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-27 22:38:09 +02:00
appease linter
This commit is contained in:
@@ -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 {
|
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
|
// there is always one and only one cyclable context in the context stack. We'll look from top to bottom
|
||||||
gui.State.ContextManager.RLock()
|
gui.State.ContextManager.RLock()
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
@@ -222,6 +224,19 @@ func (gui *Gui) activateContext(c types.Context, opts ...types.OnFocusOpts) erro
|
|||||||
return nil
|
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.
|
// 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) {
|
func (gui *Gui) ViewContextMapSet(viewName string, c types.Context) {
|
||||||
gui.State.ViewContextMap.Set(viewName, c)
|
gui.State.ViewContextMap.Set(viewName, c)
|
||||||
|
|||||||
@@ -5,34 +5,6 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"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 {
|
func (gui *Gui) contextTree() *context.ContextTree {
|
||||||
return &context.ContextTree{
|
return &context.ContextTree{
|
||||||
Global: context.NewSimpleContext(
|
Global: context.NewSimpleContext(
|
||||||
|
|||||||
@@ -212,18 +212,6 @@ type Controllers struct {
|
|||||||
Global *controllers.GlobalController
|
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
|
// 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
|
// non-mutative, so that we don't accidentally end up
|
||||||
// with mismatches of data. We might change this in the future
|
// with mismatches of data. We might change this in the future
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
|
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) getSelectedReflogCommit() *models.Commit {
|
|
||||||
return gui.State.Contexts.ReflogCommits.GetSelected()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) reflogCommitsRenderToMain() error {
|
func (gui *Gui) reflogCommitsRenderToMain() error {
|
||||||
commit := gui.State.Contexts.ReflogCommits.GetSelected()
|
commit := gui.State.Contexts.ReflogCommits.GetSelected()
|
||||||
var task updateTask
|
var task updateTask
|
||||||
|
|||||||
@@ -2,19 +2,12 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/spkg/bom"
|
"github.com/spkg/bom"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) getCyclableWindows() []string {
|
|
||||||
return []string{"status", "files", "branches", "commits", "stash"}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) resetOrigin(v *gocui.View) error {
|
func (gui *Gui) resetOrigin(v *gocui.View) error {
|
||||||
_ = v.SetCursor(0, 0)
|
_ = v.SetCursor(0, 0)
|
||||||
return v.SetOrigin(0, 0)
|
return v.SetOrigin(0, 0)
|
||||||
@@ -41,19 +34,6 @@ func (gui *Gui) renderString(view *gocui.View, s string) error {
|
|||||||
return nil
|
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 {
|
func (gui *Gui) currentViewName() string {
|
||||||
currentView := gui.g.CurrentView()
|
currentView := gui.g.CurrentView()
|
||||||
if currentView == nil {
|
if currentView == nil {
|
||||||
@@ -85,46 +65,6 @@ func (gui *Gui) resizePopupPanel(v *gocui.View, content string) error {
|
|||||||
return err
|
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 {
|
func (gui *Gui) globalOptionsMap() map[string]string {
|
||||||
keybindingConfig := gui.c.UserConfig.Keybinding
|
keybindingConfig := gui.c.UserConfig.Keybinding
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user