mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-12-01 22:52:01 +02:00
More stuff
This commit is contained in:
50
gui.go
50
gui.go
@@ -20,15 +20,24 @@ import (
|
||||
type stateType struct {
|
||||
GitFiles []GitFile
|
||||
Branches []Branch
|
||||
Commits []Commit
|
||||
PreviousView string
|
||||
}
|
||||
|
||||
var state = stateType{
|
||||
GitFiles: make([]GitFile, 0),
|
||||
PreviousView: "files",
|
||||
Commits: make([]Commit, 0),
|
||||
}
|
||||
|
||||
var cyclableViews = []string{"files", "branches"}
|
||||
var cyclableViews = []string{"files", "branches", "commits"}
|
||||
|
||||
func refreshSidePanels(g *gocui.Gui, v *gocui.View) error {
|
||||
refreshBranches(g)
|
||||
refreshFiles(g)
|
||||
refreshCommits(g)
|
||||
return nil
|
||||
}
|
||||
|
||||
func nextView(g *gocui.Gui, v *gocui.View) error {
|
||||
var focusedViewName string
|
||||
@@ -41,7 +50,8 @@ func nextView(g *gocui.Gui, v *gocui.View) error {
|
||||
break
|
||||
}
|
||||
if i == len(cyclableViews)-1 {
|
||||
panic(v.Name() + " is not in the list of views")
|
||||
devLog(v.Name() + " is not in the list of views")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +78,8 @@ func newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
case "main":
|
||||
return nil
|
||||
case "commits":
|
||||
return handleCommitSelect(g, v)
|
||||
default:
|
||||
panic("No view matching newLineFocused switch statement")
|
||||
}
|
||||
@@ -113,19 +125,25 @@ func keybindings(g *gocui.Gui) error {
|
||||
if err := g.SetKeybinding("", gocui.KeyPgdn, gocui.ModNone, scrollDownMain); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", 'ç', gocui.ModNone, handleCommitPress); err != nil {
|
||||
if err := g.SetKeybinding("files", 'c', gocui.ModNone, handleCommitPress); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", gocui.KeySpace, gocui.ModNone, handleFilePress); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", '®', gocui.ModNone, handleFileRemove); err != nil {
|
||||
if err := g.SetKeybinding("files", 'r', gocui.ModNone, handleFileRemove); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", 'ø', gocui.ModNone, handleFileOpen); err != nil {
|
||||
if err := g.SetKeybinding("files", 'o', gocui.ModNone, handleFileOpen); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", 'ß', gocui.ModNone, handleSublimeFileOpen); err != nil {
|
||||
if err := g.SetKeybinding("files", 's', gocui.ModNone, handleSublimeFileOpen); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", 'p', gocui.ModNone, pullFiles); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("files", 'P', gocui.ModNone, pushFiles); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("commit", gocui.KeyEsc, gocui.ModNone, closeCommitPrompt); err != nil {
|
||||
@@ -137,6 +155,15 @@ func keybindings(g *gocui.Gui) error {
|
||||
if err := g.SetKeybinding("branches", gocui.KeySpace, gocui.ModNone, handleBranchPress); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("branches", 'F', gocui.ModNone, handleForceCheckout); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("commits", 's', gocui.ModNone, handleCommitSquashDown); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("commits", 'r', gocui.ModNone, handleRenameCommit); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", '∑', gocui.ModNone, handleLogState); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -146,6 +173,7 @@ func keybindings(g *gocui.Gui) error {
|
||||
func handleLogState(g *gocui.Gui, v *gocui.View) error {
|
||||
devLog("state is:", state)
|
||||
devLog("previous view:", state.PreviousView)
|
||||
refreshBranches(g)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -171,7 +199,7 @@ func layout(g *gocui.Gui) error {
|
||||
refreshFiles(g)
|
||||
}
|
||||
|
||||
if v, err := g.SetView("main", leftSideWidth+2, 0, width-1, optionsTop-1); err != nil {
|
||||
if v, err := g.SetView("main", leftSideWidth+1, 0, width-1, optionsTop-1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
@@ -181,14 +209,14 @@ func layout(g *gocui.Gui) error {
|
||||
handleFileSelect(g, sideView)
|
||||
}
|
||||
|
||||
if v, err := g.SetView("logs", 0, logsBranchesBoundary, leftSideWidth, optionsTop-1); err != nil {
|
||||
if v, err := g.SetView("commits", 0, logsBranchesBoundary, leftSideWidth, optionsTop-1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
v.Title = "Log"
|
||||
v.Title = "Commits"
|
||||
|
||||
// these are only called once
|
||||
refreshLogs(g)
|
||||
refreshCommits(g)
|
||||
}
|
||||
|
||||
if v, err := g.SetView("branches", 0, filesBranchesBoundary, leftSideWidth, logsBranchesBoundary-1); err != nil {
|
||||
@@ -198,7 +226,7 @@ func layout(g *gocui.Gui) error {
|
||||
v.Title = "Branches"
|
||||
|
||||
// these are only called once
|
||||
refreshBranches(v)
|
||||
refreshBranches(g)
|
||||
nextView(g, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user