From e896cae995a1d0be5f172bf856b732b5fbf14017 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 3 Sep 2025 17:31:22 -0500 Subject: [PATCH] fixing gocui plugin exit() --- Makefile | 6 ++++-- doConfig.go | 4 ++++ doGui.go | 28 ++++++++++++++++++++++------ exit.go | 9 +++++---- structs.go | 9 +++++---- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 56868b1..fabc4c6 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,10 @@ andlabs: clean install forge --gui andlabs --gui-verbose gocui: install - forge --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so >/tmp/forge.log 2>&1 - # forge --gui gocui --gui-verbose --debugger + forge --gui gocui + +gocui-verbose: install + forge --gui gocui --gui-verbose >/tmp/forge.log 2>&1 goimports: reset diff --git a/doConfig.go b/doConfig.go index fedae43..ce4645d 100644 --- a/doConfig.go +++ b/doConfig.go @@ -21,6 +21,7 @@ func doConfig() { log.Info("todo") okExit("") } + if argv.Config.Register != "" { if err := doRegister(argv.Config.Register); err == nil { okExit("attempting to register " + argv.Config.Register) @@ -51,6 +52,9 @@ func doConfig() { os.Exit(0) } + log.Info("config.PathLock =", me.forge.Config.PathLock) + log.Info("config.GoSrc =", me.forge.Config.GoSrc) + me.forge.ConfigPrintTable() okExit("") } diff --git a/doGui.go b/doGui.go index 630e059..f67127f 100644 --- a/doGui.go +++ b/doGui.go @@ -92,23 +92,39 @@ func doGui() { log.Printf("rill repos.Reload() took (%s)\n", shell.FormatDuration(time.Since(now))) os.Exit(0) } - drawWindow(mainWindow) // sits here forever debug() - } func drawWindow(win *gadgets.GenericWindow) { grid := win.Group.RawGrid() - me.goSrcPwd = gadgets.NewOneLiner(grid, "Working Directory") - grid.NewLabel("") + if me.forge.Config.GetPathLock() { + me.goSrcPwd = gadgets.NewOneLiner(grid, "Working Directory") + me.goSrcPwd.SetText(me.forge.GetGoSrc()) + } else { + me.goSrcEdit = gadgets.NewBasicEntry(grid, "Working Directory") + me.goSrcEdit.SetText(me.forge.GetGoSrc()) + me.goSrcEdit.Custom = func() { + log.Info("updating text to", me.goSrcEdit.String()) + } + } + lockpath := grid.NewCheckbox("Lock").SetChecked(me.forge.Config.PathLock) + lockpath.Custom = func() { + if lockpath.IsChecked() { + log.Info("lock working directory") + me.forge.Config.PathLock = true + } else { + log.Info("unlock working directory") + me.forge.Config.PathLock = false + } + me.forge.Config.ConfigSave() + okExit("you must restart forge after changing the Path Lock") + } grid.NextRow() - me.goSrcPwd.SetText(me.forge.GetGoSrc()) - // use ENV GIT_AUTHOR me.gitAuthor = gadgets.NewOneLiner(grid, "Git Author") grid.NextRow() diff --git a/exit.go b/exit.go index 11e78ed..c57e525 100644 --- a/exit.go +++ b/exit.go @@ -6,18 +6,19 @@ package main import ( "os" + "go.wit.com/gui" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func okExit(thing string) { - if thing != "" { - log.Info("forge exit:", thing, "ok") - } + gui.UnloadToolkits() if configSave { me.forge.SetConfigSave(configSave) } - // log.Info("Finished go-clean on", check.GetGoPath(), "ok") + if thing != "" { + log.Info("forge exit:", thing, "ok") + } me.forge.Exit() } diff --git a/structs.go b/structs.go index 012ab28..098142d 100644 --- a/structs.go +++ b/structs.go @@ -31,10 +31,11 @@ type mainType struct { urlbase string // base URL mainWindow *gadgets.BasicWindow - mainbox *gui.Node // the main box. enable/disable this - autoDryRun *gui.Node // checkbox for --dry-run - goSrcPwd *gadgets.OneLiner // what is being used as primary directory for your work - gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL + mainbox *gui.Node // the main box. enable/disable this + autoDryRun *gui.Node // checkbox for --dry-run + goSrcPwd *gadgets.OneLiner // what is being used as primary directory for your work + goSrcEdit *gadgets.BasicEntry // what is being used as primary directory for your work + gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL // these hold the branches that the user can switch all the repositories to them reposWinB *gui.Node // button that opens the repos window