2019-06-03 02:20:11 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
2019-06-03 06:57:01 -05:00
|
|
|
// import "fmt"
|
|
|
|
import "time"
|
|
|
|
import "runtime"
|
|
|
|
import "os/exec"
|
|
|
|
import "strings"
|
2019-06-03 02:20:11 -05:00
|
|
|
|
|
|
|
import "git.wit.com/wit/gui"
|
2019-06-03 06:57:01 -05:00
|
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
import "github.com/davecgh/go-spew/spew"
|
2019-06-03 02:20:11 -05:00
|
|
|
|
|
|
|
// import "github.com/andlabs/ui"
|
|
|
|
// import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
func debugClick(b *gui.GuiButton) {
|
|
|
|
log.Println("debugClick() START")
|
|
|
|
gw := b.Box.Window
|
|
|
|
|
|
|
|
// if there is not an account, then go to 'make account'
|
|
|
|
gw = gui.InitGuiWindow("debugClick() Box22", gw)
|
|
|
|
|
|
|
|
log.Println("debugClick() AddGenericBox() START")
|
2019-06-03 02:49:51 -05:00
|
|
|
box := gui.HardBox(gw, gui.Yaxis, "debugClick")
|
2019-06-03 02:20:11 -05:00
|
|
|
log.Println("debugClick() AddGenericBox() END box =", box)
|
|
|
|
|
|
|
|
makeButton(box, nil, nil, "Generate", "SUBDOMAIN", nil)
|
|
|
|
gui.HorizontalBreak(box)
|
|
|
|
makeButton(box, nil, nil, "Create Subdomain Account", "ADD", addSubdomainClick)
|
2019-06-03 07:32:13 -05:00
|
|
|
hardXbox := gui.HardBox(gw, gui.Xaxis, "subdomain test")
|
|
|
|
Ybox1 := gui.NewBox(hardXbox, gui.Yaxis, "subdomain Y test")
|
|
|
|
Xbox1 := gui.NewBox(Ybox1, gui.Xaxis, "subdomain Y test")
|
|
|
|
makeButton(Xbox1, nil, nil, "ping", "SUBDOMAIN", runPingClick)
|
|
|
|
makeButton(Xbox1, nil, nil, "Cross platform shell test", "SUBDOMAIN", runTestExecClick)
|
|
|
|
makeButton(Xbox1, nil, nil, "Generate 3", "SUBDOMAIN", nil)
|
|
|
|
makeButton(Xbox1, nil, nil, "Generate 4", "SUBDOMAIN", nil)
|
2019-06-03 06:57:01 -05:00
|
|
|
|
2019-06-03 07:32:13 -05:00
|
|
|
Ybox2 := gui.NewBox(hardXbox, gui.Yaxis, "subdomain Y test")
|
|
|
|
makeButton(Ybox2, nil, nil, "List all windows & tabs", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Hide()")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Hide()
|
|
|
|
})
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Hide all tabs", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Hide()")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Hide()
|
2019-06-03 02:49:51 -05:00
|
|
|
})
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Hide sleep Show", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Hide()")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Hide()
|
|
|
|
time.Sleep(2000 * time.Millisecond)
|
|
|
|
box.Window.UiTab.Show()
|
|
|
|
})
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Destroy tab 0", "SUBDOMAIN", func (*gui.GuiButton) {
|
2019-06-03 06:57:01 -05:00
|
|
|
log.Println("debugClick() Destroy(0)")
|
|
|
|
box := gw.BoxMap["MAINBOX"]
|
|
|
|
box.Window.UiTab.Delete(0)
|
|
|
|
})
|
2019-06-03 02:20:11 -05:00
|
|
|
|
2019-06-03 07:32:13 -05:00
|
|
|
makeButton(Ybox2, nil, nil, "Load the default test config file", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
newConfig := loadDefaultConfig()
|
|
|
|
config.Accounts = newConfig.Accounts
|
|
|
|
})
|
|
|
|
makeButton(Ybox2, nil, nil, "runtime.Stack() dump", "SUBDOMAIN", func (*gui.GuiButton) {
|
|
|
|
log.Println("\tATTEMPT FULL STACK DUMP")
|
|
|
|
buf := make([]byte, 1<<16)
|
|
|
|
runtime.Stack(buf, true)
|
|
|
|
log.Printf("%s", buf)
|
|
|
|
log.Println("\tFINISHED FULL STACK DUMP")
|
|
|
|
})
|
|
|
|
makeButton(Ybox2, nil, nil, "Close the GUI", "SUBDOMAIN", nil)
|
2019-06-03 02:20:11 -05:00
|
|
|
}
|
2019-06-03 06:57:01 -05:00
|
|
|
|
|
|
|
func runPingClick(b *gui.GuiButton) {
|
|
|
|
log.Println("runPingClick START")
|
|
|
|
values, _ := b.Values.(*myButtonInfo)
|
|
|
|
log.Println("runTestExecClick values.VM", values.VM)
|
|
|
|
hostname := "localhost"
|
|
|
|
if (values.VM != nil) {
|
|
|
|
hostname = values.VM.Hostname
|
|
|
|
}
|
|
|
|
spew.Dump(b)
|
|
|
|
var tmp []string
|
|
|
|
tmp = append(tmp, "xterm", "-geometry", "120x30", "-e", "ping " + hostname + ";sleep 3")
|
|
|
|
go runCommand(tmp)
|
|
|
|
log.Println("runPingClick END")
|
|
|
|
}
|
|
|
|
|
|
|
|
func runTestExecClick(b *gui.GuiButton) {
|
|
|
|
log.Println("runTestExecClick START")
|
|
|
|
if runtime.GOOS == "linux" {
|
|
|
|
go runSimpleCommand("xterm -report-fonts")
|
|
|
|
} else if runtime.GOOS == "windows" {
|
|
|
|
go runSimpleCommand("mintty.exe")
|
|
|
|
} else {
|
|
|
|
go runSimpleCommand("xterm")
|
|
|
|
}
|
|
|
|
log.Println("runTestExecClick END")
|
|
|
|
}
|
|
|
|
|
|
|
|
func runSimpleCommand(s string) {
|
|
|
|
cmd := strings.TrimSpace(s) // this is like 'chomp' in perl
|
|
|
|
cmdArgs := strings.Fields(cmd)
|
|
|
|
runCommand(cmdArgs)
|
|
|
|
}
|
|
|
|
|
|
|
|
func runCommand(cmdArgs []string) {
|
|
|
|
log.Println("runCommand() START", cmdArgs)
|
|
|
|
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
|
|
|
// process := exec.Command("xterm", "-e", "ping localhost")
|
|
|
|
log.Println("runCommand() process.Start()")
|
|
|
|
process.Start()
|
|
|
|
log.Println("runCommand() process.Wait()")
|
|
|
|
process.Wait()
|
|
|
|
log.Println("runCommand() NEED TO CHECK THE TIME HERE TO SEE IF THIS WORKED")
|
|
|
|
log.Println("runCommand() OTHERWISE INFORM THE USER")
|
|
|
|
log.Println("runCommand() END")
|
|
|
|
}
|