mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
Mid refactor change some more stuff
This commit is contained in:
@@ -5,6 +5,9 @@ import (
|
||||
// "io"
|
||||
// "io/ioutil"
|
||||
|
||||
"errors"
|
||||
"log"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -19,6 +22,13 @@ import (
|
||||
// OverlappingEdges determines if panel edges overlap
|
||||
var OverlappingEdges = false
|
||||
|
||||
// ErrSubprocess tells us we're switching to a subprocess so we need to
|
||||
// close the Gui until it is finished
|
||||
var (
|
||||
ErrSubprocess = errors.New("running subprocess")
|
||||
subprocess *exec.Cmd
|
||||
)
|
||||
|
||||
type stateType struct {
|
||||
GitFiles []git.File
|
||||
Branches []git.Branch
|
||||
@@ -273,6 +283,20 @@ func resizePopupPanels(g *gocui.Gui) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunWithSubprocesses() {
|
||||
for {
|
||||
if err := run(); err != nil {
|
||||
if err == gocui.ErrQuit {
|
||||
break
|
||||
} else if err == ErrSubprocess {
|
||||
subprocess.Run()
|
||||
} else {
|
||||
log.Panicln(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func run() (err error) {
|
||||
g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -123,7 +123,8 @@ func refreshBranches(g *gocui.Gui) error {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
state.Branches = git.GetGitBranches()
|
||||
builder := git.newBranchListBuilder() // TODO: add constructor params
|
||||
state.Branches = builder.build()
|
||||
v.Clear()
|
||||
for _, branch := range state.Branches {
|
||||
fmt.Fprintln(v, branch.getDisplayString())
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import "github.com/jesseduffield/gocui"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
|
||||
@@ -194,6 +194,17 @@ func handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func runSubprocess(g *gocui.Gui, commands string...) error {
|
||||
var err error
|
||||
// need this OsCommand to be available
|
||||
if subprocess, err = osCommand.RunSubProcess(commands...); err != nil {
|
||||
return err
|
||||
}
|
||||
g.Update(func(g *gocui.Gui) error {
|
||||
return gui.ErrSubprocess
|
||||
})
|
||||
}
|
||||
|
||||
func genericFileOpen(g *gocui.Gui, v *gocui.View, open func(*gocui.Gui, string) (string, error)) error {
|
||||
file, err := getSelectedFile(g)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// though this panel is called the merge panel, it's really going to use the main panel. This may change in the future
|
||||
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package panels
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
Reference in New Issue
Block a user