~laumann/acme-git

ff40d8d940308be1496dcf4817703b20c84742ac — Thomas Bracht Laumann Jespersen 2 years ago 15d124f
Have Acme integration and GIT_EDITOR in the same binary
1 files changed, 34 insertions(+), 1 deletions(-)

M Git.go
M Git.go => Git.go +34 -1
@@ 94,7 94,31 @@ func commit() {
	win.Ctl("clean")
}

func main() {
func giteditor() {
	cwin, err := acme.New()
	if err != nil {
		log.Fatal(err)
	}

	cwin.Ctl("name " + os.Args[1])
	cwin.Ctl("get")

	for e := range cwin.EventChan() {
		switch e.C2 {
		case 'x', 'X': // execute
			text := string(e.Text)
			switch text {
			case "Del":
				cwin.Ctl("delete")
				break
			}
		}
		cwin.WriteEvent(e)
	}
	os.Exit(0)
}

func acmegit() {
	var err error

	win, err = acme.New()


@@ 126,6 150,15 @@ func main() {
	}
}

func main() {
	_, isGitEditor := os.LookupEnv("GIT_EXEC_PATH")
	if isGitEditor {
		giteditor()
	} else {
		acmegit()
	}
}

func events() {
	for e := range win.EventChan() {
		switch e.C2 {