GOOD: add flags, start using vim-go
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0f8ed0da1f
commit
1acd29f3b6
|
@ -0,0 +1,14 @@
|
||||||
|
//go:build !js || !wasm
|
||||||
|
// +build !js !wasm
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
)
|
||||||
|
|
||||||
|
func parseFlags(g *game) {
|
||||||
|
flag.IntVar(&g.w, "width", 100, "Enable width mode")
|
||||||
|
flag.IntVar(&g.h, "noclip", 50, "Enable noclip mode")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
//go:build js && wasm
|
||||||
|
// +build js,wasm
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func parseFlags(g *game) {
|
||||||
|
g.disableEsc = true
|
||||||
|
}
|
26
main.go
26
main.go
|
@ -1,17 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import origlog "log"
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.wit.org/jcarr/log"
|
origlog "log"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.wit.org/jcarr/log"
|
||||||
"git.wit.org/wit/gui"
|
"git.wit.org/wit/gui"
|
||||||
// "github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/gobuffalo/packr"
|
"github.com/gobuffalo/packr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
var GITCOMMIT string // this is passed in as an ldflag
|
var GITCOMMIT string // this is passed in as an ldflag
|
||||||
var GOVERSION string // this is passed in as an ldflag
|
var GOVERSION string // this is passed in as an ldflag
|
||||||
var VERSION string // this is passed in as an ldflag
|
var VERSION string // this is passed in as an ldflag
|
||||||
|
@ -39,6 +39,12 @@ func customExit(n *gui.Node) {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type game struct {
|
||||||
|
w, h int
|
||||||
|
|
||||||
|
levelNum int
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("starting my Control Panel")
|
log.Println("starting my Control Panel")
|
||||||
log.Println("GOVERSION =", GOVERSION)
|
log.Println("GOVERSION =", GOVERSION)
|
||||||
|
@ -46,6 +52,13 @@ func main() {
|
||||||
|
|
||||||
log.Println("packr ./resources box")
|
log.Println("packr ./resources box")
|
||||||
|
|
||||||
|
g := &game{
|
||||||
|
w: 5,
|
||||||
|
h: 20,
|
||||||
|
}
|
||||||
|
|
||||||
|
parseFlags(g)
|
||||||
|
|
||||||
// This puts all the files in that directory in the binary
|
// This puts all the files in that directory in the binary
|
||||||
// This directory includes the default config file if there is not already one
|
// This directory includes the default config file if there is not already one
|
||||||
packrBox = packr.NewBox("./resources")
|
packrBox = packr.NewBox("./resources")
|
||||||
|
@ -65,6 +78,11 @@ func main() {
|
||||||
// only os.Exit() on close of the main Window
|
// only os.Exit() on close of the main Window
|
||||||
// TODO: Change to only exit from systray(?)
|
// TODO: Change to only exit from systray(?)
|
||||||
func initGUI() {
|
func initGUI() {
|
||||||
|
g := &gui.GuiConfig{
|
||||||
|
Exit: customExit,
|
||||||
|
Stretchy: false,
|
||||||
|
}
|
||||||
|
log.Println("g =", g)
|
||||||
gui.Config.Exit = customExit
|
gui.Config.Exit = customExit
|
||||||
gui.Config.Stretchy = false
|
gui.Config.Stretchy = false
|
||||||
mainWindow(nil)
|
mainWindow(nil)
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
import "os"
|
"bufio"
|
||||||
import "bufio"
|
"errors"
|
||||||
import "strings"
|
"log"
|
||||||
import "errors"
|
"os"
|
||||||
import "git.wit.org/wit/gui"
|
"strings"
|
||||||
|
|
||||||
|
"git.wit.org/wit/gui"
|
||||||
|
)
|
||||||
|
|
||||||
func aptPackagesWindow(w *gui.Node) {
|
func aptPackagesWindow(w *gui.Node) {
|
||||||
var aptoutput *gui.Node
|
var aptoutput *gui.Node
|
||||||
var aptNode *gui.Node
|
var aptNode *gui.Node
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
if (w == nil) {
|
if w == nil {
|
||||||
gui.Config.Title = "apt configuration and package installer"
|
gui.Config.Title = "apt configuration and package installer"
|
||||||
gui.Config.Width = 1600
|
gui.Config.Width = 1600
|
||||||
gui.Config.Height = 800
|
gui.Config.Height = 800
|
||||||
|
@ -23,15 +26,15 @@ func aptPackagesWindow(w *gui.Node) {
|
||||||
tab := w.AddTab("apt", nil)
|
tab := w.AddTab("apt", nil)
|
||||||
// populateNEW(tab, "new")
|
// populateNEW(tab, "new")
|
||||||
|
|
||||||
////////////// filename /////////////////////////
|
////////////// filename /////////////////////////
|
||||||
gNode := tab.AddGroup("Options")
|
gNode := tab.AddGroup("Options")
|
||||||
|
|
||||||
gNode.AddButton("default packages", func (*gui.Node) {
|
gNode.AddButton("default packages", func(*gui.Node) {
|
||||||
log.Println("STARTED HOSTNAME")
|
log.Println("STARTED HOSTNAME")
|
||||||
aptNode.SetText("bin/install-default-packages.sh")
|
aptNode.SetText("bin/install-default-packages.sh")
|
||||||
filename = "bin/install-default-packages.sh"
|
filename = "bin/install-default-packages.sh"
|
||||||
b, _ := packrBox.FindString(filename)
|
b, _ := packrBox.FindString(filename)
|
||||||
if (aptoutput != nil) {
|
if aptoutput != nil {
|
||||||
aptoutput.SetText(b)
|
aptoutput.SetText(b)
|
||||||
}
|
}
|
||||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||||
|
@ -39,12 +42,12 @@ func aptPackagesWindow(w *gui.Node) {
|
||||||
|
|
||||||
gNode.CreateFontButton("fonts")
|
gNode.CreateFontButton("fonts")
|
||||||
|
|
||||||
gNode.AddButton("Configure apt-file", func (*gui.Node) {
|
gNode.AddButton("Configure apt-file", func(*gui.Node) {
|
||||||
log.Println("STARTED HOSTNAME")
|
log.Println("STARTED HOSTNAME")
|
||||||
aptNode.SetText("bin/apt-file.sh")
|
aptNode.SetText("bin/apt-file.sh")
|
||||||
filename = "bin/apt-file.sh"
|
filename = "bin/apt-file.sh"
|
||||||
b, _ := packrBox.FindString(filename)
|
b, _ := packrBox.FindString(filename)
|
||||||
if (aptoutput != nil) {
|
if aptoutput != nil {
|
||||||
aptoutput.SetText(b)
|
aptoutput.SetText(b)
|
||||||
}
|
}
|
||||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||||
|
@ -62,22 +65,22 @@ func aptPackagesWindow(w *gui.Node) {
|
||||||
aptNode = gNode.AddComboBox("test", tmp...)
|
aptNode = gNode.AddComboBox("test", tmp...)
|
||||||
|
|
||||||
aptNode.SetText(filename)
|
aptNode.SetText(filename)
|
||||||
aptNode.OnChanged = func () {
|
aptNode.OnChanged = func() {
|
||||||
log.Println("STARTED HOSTNAME")
|
log.Println("STARTED HOSTNAME")
|
||||||
filename = aptNode.GetText()
|
filename = aptNode.GetText()
|
||||||
b, _ := packrBox.FindString(filename)
|
b, _ := packrBox.FindString(filename)
|
||||||
if (aptoutput != nil) {
|
if aptoutput != nil {
|
||||||
aptoutput.SetText(b)
|
aptoutput.SetText(b)
|
||||||
}
|
}
|
||||||
log.Println("ENDED GetText() HOSTNAME =", filename)
|
log.Println("ENDED GetText() HOSTNAME =", filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// connect /////////////////////////
|
////////////// connect /////////////////////////
|
||||||
gNode = tab.AddGroup("")
|
gNode = tab.AddGroup("")
|
||||||
|
|
||||||
gNode.AddButton("Run Script", func (*gui.Node) {
|
gNode.AddButton("Run Script", func(*gui.Node) {
|
||||||
sudo( func() error {
|
sudo(func() error {
|
||||||
log.Println("set resolv.conf to",filename)
|
log.Println("set resolv.conf to", filename)
|
||||||
b, _ := packrBox.FindString(filename)
|
b, _ := packrBox.FindString(filename)
|
||||||
// spew.Dump(b)
|
// spew.Dump(b)
|
||||||
b = aptoutput.GetText()
|
b = aptoutput.GetText()
|
||||||
|
@ -98,8 +101,8 @@ func aptPackagesWindow(w *gui.Node) {
|
||||||
})
|
})
|
||||||
|
|
||||||
gui.Config.Stretchy = true
|
gui.Config.Stretchy = true
|
||||||
gNode.AddButton("set output", func (*gui.Node) {
|
gNode.AddButton("set output", func(*gui.Node) {
|
||||||
if (aptoutput != nil) {
|
if aptoutput != nil {
|
||||||
aptoutput.SetText("wow")
|
aptoutput.SetText("wow")
|
||||||
aptoutput.SetMargined(false)
|
aptoutput.SetMargined(false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue