summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-03 18:54:08 -0600
committerJeff Carr <[email protected]>2024-01-03 18:54:08 -0600
commit49f8029a5fd9c6b33e4d2f0505dee233cd71cb7f (patch)
treef18c716fb6fb702578eb15847f14f59d21e7adff
parent0a20b22a6c13c2ccf6a914cd847be9e3f744b343 (diff)
complete the move to 'go.wit.com/log'
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--args.go12
-rw-r--r--box.go2
-rw-r--r--button.go2
-rw-r--r--checkbox.go2
-rw-r--r--common.go39
-rw-r--r--debug.go79
-rw-r--r--dropdown.go2
-rw-r--r--grid.go2
-rw-r--r--group.go2
-rw-r--r--image.go2
-rw-r--r--label.go2
-rw-r--r--main.go2
-rw-r--r--node.go2
-rw-r--r--plugin.go2
-rw-r--r--redraw.go2
-rw-r--r--slider.go2
-rw-r--r--spinner.go2
-rw-r--r--structs.go2
-rw-r--r--tab.go2
-rw-r--r--textbox.go2
-rw-r--r--toolkit/widget.go204
-rw-r--r--window.go2
22 files changed, 50 insertions, 320 deletions
diff --git a/args.go b/args.go
index b737d4b..a254c73 100644
--- a/args.go
+++ b/args.go
@@ -6,10 +6,12 @@ import (
"go.wit.com/log"
)
+var INFO log.LogFlag
+
var GUI log.LogFlag
var NODE log.LogFlag
var PLUG log.LogFlag
-var INFO log.LogFlag
+var CHANGE log.LogFlag
var argGui ArgsGui
@@ -27,8 +29,6 @@ func ArgToolkit() string {
func init() {
arg.Register(&argGui)
- log.Register("gui", "debugGui", &debugGui)
-
INFO.B = false
INFO.Name = "INFO"
INFO.Subsystem = "gui"
@@ -53,6 +53,12 @@ func init() {
PLUG.Desc = "basic PLUG debugging"
PLUG.Register()
+ CHANGE.B = false
+ CHANGE.Name = "CHANGE"
+ CHANGE.Subsystem = "gui"
+ CHANGE.Desc = "user changed something"
+ CHANGE.Register()
+
for _, s := range log.ListFlags() {
log.Info("go.wit.com/gui/gui ListFlags() returned:", s)
}
diff --git a/box.go b/box.go
index 97f161d..2e8d8a5 100644
--- a/box.go
+++ b/box.go
@@ -1,7 +1,7 @@
package gui
import (
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewBox(name string, b bool) *Node {
diff --git a/button.go b/button.go
index bdba1a5..5c8874f 100644
--- a/button.go
+++ b/button.go
@@ -1,6 +1,6 @@
package gui
-import "go.wit.com/gui/gui/toolkit"
+import "go.wit.com/gui/toolkits"
func (parent *Node) NewButton(name string, custom func()) *Node {
newNode := parent.newNode(name, toolkit.Button)
diff --git a/checkbox.go b/checkbox.go
index 2109098..82a3016 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -1,6 +1,6 @@
package gui
-import "go.wit.com/gui/gui/toolkit"
+import "go.wit.com/gui/toolkits"
func (n *Node) Checked() bool {
return n.B
diff --git a/common.go b/common.go
index fa6527e..423e21a 100644
--- a/common.go
+++ b/common.go
@@ -4,8 +4,9 @@ package gui
import (
"regexp"
- "go.wit.com/gui/gui/toolkit"
- newlog "go.wit.com/log"
+ "errors"
+ "go.wit.com/log"
+ "go.wit.com/gui/toolkits"
)
// functions for handling text related GUI elements
@@ -35,7 +36,7 @@ func (n *Node) Disable() *Node {
}
func (n *Node) Add(str string) {
- newlog.Log(debugGui, "gui.Add() value =", str)
+ log.Log(GUI, "gui.Add() value =", str)
n.S = str
@@ -44,7 +45,7 @@ func (n *Node) Add(str string) {
}
func (n *Node) AddText(str string) {
- newlog.Log(debugChange, "AddText() value =", str)
+ log.Log(CHANGE, "AddText() value =", str)
n.Text = str
n.S = str
@@ -54,7 +55,7 @@ func (n *Node) AddText(str string) {
}
func (n *Node) SetText(text string) *Node {
- newlog.Log(debugChange, "SetText() value =", text)
+ log.Log(CHANGE, "SetText() value =", text)
n.Text = text
n.S = text
@@ -67,11 +68,11 @@ func (n *Node) SetText(text string) *Node {
func (n *Node) SetNext(w int, h int) {
n.NextW = w
n.NextH = h
- newlog.Log(debugNow, "SetNext() w,h =", n.NextW, n.NextH)
+ log.Info("SetNext() w,h =", n.NextW, n.NextH)
}
func (n *Node) Set(val any) {
- newlog.Log(debugChange, "Set() value =", val)
+ log.Log(CHANGE, "Set() value =", val)
switch v := val.(type) {
case bool:
@@ -82,7 +83,7 @@ func (n *Node) Set(val any) {
case int:
n.I = val.(int)
default:
- newlog.Log(debugError, "Set() unknown type =", v)
+ log.Error(errors.New("Set() unknown type"), "v =", v)
}
a := newAction(n, toolkit.Set)
@@ -106,9 +107,9 @@ func (n *Node) AppendText(str string) {
// should get the value of the node
func (n *Node) GetText() string {
if (n.S != n.Text) {
- newlog.Warn("GetText() is screwed up. TODO: fix this dumb crap")
- stuff := newlog.ListFlags()
- newlog.Warn("ListFlags() =", stuff)
+ log.Warn("GetText() is screwed up. TODO: fix this dumb crap")
+ stuff := log.ListFlags()
+ log.Warn("ListFlags() =", stuff)
}
if (n.S != "") {
return n.S
@@ -130,7 +131,7 @@ isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
for _, username := range []string{"userone", "user2", "user-three"} {
if !isAlpha(username) {
- newlog.Log(debugGui, "%q is not valid\n", username)
+ log.Log(GUI, "%q is not valid\n", username)
}
}
@@ -150,11 +151,11 @@ func normalizeInt(s string) string {
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
reg, err := regexp.Compile("[^0-9]+")
if err != nil {
- newlog.Log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
+ log.Log(GUI, "normalizeInt() regexp.Compile() ERROR =", err)
return s
}
clean := reg.ReplaceAllString(s, "")
- newlog.Log(debugGui, "normalizeInt() s =", clean)
+ log.Log(GUI, "normalizeInt() s =", clean)
return clean
}
@@ -162,9 +163,9 @@ func commonCallback(n *Node) {
// TODO: make all of this common code to all the widgets
// This might be common everywhere finally (2023/03/01)
if (n.Custom == nil) {
- newlog.Log(debugChange, "Not Running n.Custom(n) == nil")
+ log.Log(CHANGE, "Not Running n.Custom(n) == nil")
} else {
- newlog.Log(debugChange, "Running n.Custom(n)")
+ log.Log(CHANGE, "Running n.Custom(n)")
n.Custom()
}
}
@@ -206,7 +207,7 @@ func (n *Node) Expand() *Node {
// myFunnyWindow = myGui.NewWindow("Hello").Standard().SetText("Hola")
func (n *Node) Window(title string) *Node {
- newlog.Log(debugError, "Window()", n)
+ log.Warn("Window()", n)
return n.NewWindow(title)
}
@@ -214,12 +215,12 @@ func (n *Node) Window(title string) *Node {
// should be the default way
/*
func (n *Node) Standard() *Node {
- newlog.Log(debugInfo, "Standard() not implemented yet")
+ log.Warn("Standard() not implemented yet")
return n
}
func (n *Node) SetMargin() *Node {
- newlog.Log(debugError, "DoMargin() not implemented yet")
+ log.Warn("DoMargin() not implemented yet")
return n
}
*/
diff --git a/debug.go b/debug.go
index c84c8ca..3d330e7 100644
--- a/debug.go
+++ b/debug.go
@@ -1,6 +1,7 @@
package gui
-// Lots of debugging things:
+// old debugging things. probably deprecate
+// everything should be moved to "go.wit.com/gui/debugger"
// A function dump out the binary tree
import (
@@ -8,88 +9,14 @@ import (
"strconv"
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
-// various debugging flags
-var debugNow bool = true // useful for active development
-var debugGui bool = false
-var debugError bool = true
-var debugDump bool = false
-var debugNode bool = false
-var debugTabs bool = false
-var debugFlags bool = false
-var debugChange bool = false // shows user events like mouse and keyboard
-var debugPlugin bool = false
-var debugAction bool = false
-
// for printing out the binary tree
var listChildrenParent *Node
var listChildrenDepth int = 0
var defaultPadding = " "
-func SetDebug (s bool) {
- debugGui = s
- debugTabs = s
-
- SetFlag("Node", s)
- SetFlag("Tabs", s)
- SetFlag("Dump", s)
- SetFlag("Flags", s)
- SetFlag("Plugin", s)
- SetFlag("Change", s)
- SetFlag("Error", s)
-
- // This flag is only for the internal toolkit debugging
- SetFlag("Toolkit", s)
-}
-
-func SetFlag (s string, b bool) {
- switch s {
- case "Toolkit":
- // This flag is only for internal toolkit debugging
- case "Tabs":
- debugTabs = b
- case "Node":
- debugNode = b
- case "Dump":
- debugDump = b
- case "Error":
- debugError = b
- case "Change":
- debugChange = b
- case "Flags":
- debugFlags = b
- case "Plugin":
- debugPlugin = b
- case "Show":
- // ShowDebugValues() // print them here?
- default:
- log.Log(GUI, "Can't set unknown flag", s)
- }
-
- a := new(toolkit.Action)
- a.ActionType = toolkit.Set
- a.WidgetType = toolkit.Flag
- a.S = s
- a.B = b
- sendAction(a)
-}
-
-func ShowDebugValues() {
- // The order here should match the order in the GUI
- // TODO: get the order from the node binary tree
- log.Log(true, "Debug =", debugGui)
- log.Log(true, "DebugError =", debugError)
- log.Log(true, "DebugChange =", debugChange)
- log.Log(true, "DebugDump =", debugDump)
- log.Log(true, "DebugTabs =", debugTabs)
- log.Log(true, "DebugPlugin =", debugPlugin)
- log.Log(true, "DebugNode =", debugNode)
-
- SetFlag("Show", true)
-}
-
func (n *Node) Dump() {
b := true
Indent(b, "NODE DUMP START")
diff --git a/dropdown.go b/dropdown.go
index c4f748c..2cf33d5 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -6,7 +6,7 @@ package gui
// since it is the same. confusing names? maybe...
import (
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// add a new entry to the dropdown name
diff --git a/grid.go b/grid.go
index e4f3e08..3e51ceb 100644
--- a/grid.go
+++ b/grid.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// Grid numbering examples (H) or (W,H)
diff --git a/group.go b/group.go
index 9f9224c..25bab8e 100644
--- a/group.go
+++ b/group.go
@@ -1,7 +1,7 @@
package gui
import (
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// TODO: make a "Group" a "Grid" ?
diff --git a/image.go b/image.go
index efba8c7..7b3edbd 100644
--- a/image.go
+++ b/image.go
@@ -1,7 +1,7 @@
package gui
import (
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewImage(name string) *Node {
diff --git a/label.go b/label.go
index 0451ae9..6023ed9 100644
--- a/label.go
+++ b/label.go
@@ -1,7 +1,7 @@
package gui
import (
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewLabel(text string) *Node {
diff --git a/main.go b/main.go
index 36705e5..8f3f32f 100644
--- a/main.go
+++ b/main.go
@@ -4,7 +4,7 @@ import (
"os"
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// TODO: make a fake 'plugin' channel of communication to andlabs for mswindows
diff --git a/node.go b/node.go
index 14a1227..b31c3a2 100644
--- a/node.go
+++ b/node.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
/*
diff --git a/plugin.go b/plugin.go
index 5e1ac9d..c0bd811 100644
--- a/plugin.go
+++ b/plugin.go
@@ -11,7 +11,7 @@ import (
"plugin"
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
var err error
diff --git a/redraw.go b/redraw.go
index 3e7ff22..756ea75 100644
--- a/redraw.go
+++ b/redraw.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// This recreates the whole GUI for a plugin
diff --git a/slider.go b/slider.go
index 9b41e22..e755c45 100644
--- a/slider.go
+++ b/slider.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewSlider(name string, x int, y int) *Node {
diff --git a/spinner.go b/spinner.go
index 797ef4e..a005d23 100644
--- a/spinner.go
+++ b/spinner.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewSpinner(name string, x int, y int) *Node {
diff --git a/structs.go b/structs.go
index ccfd6a8..989a4bd 100644
--- a/structs.go
+++ b/structs.go
@@ -3,7 +3,7 @@ package gui
import (
"sync"
"embed"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
//
diff --git a/tab.go b/tab.go
index b202f6b..0123c10 100644
--- a/tab.go
+++ b/tab.go
@@ -3,7 +3,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// This function should make a new node with the parent and
diff --git a/textbox.go b/textbox.go
index f4b156a..e07e694 100644
--- a/textbox.go
+++ b/textbox.go
@@ -3,7 +3,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
func (parent *Node) NewTextbox(name string) *Node {
diff --git a/toolkit/widget.go b/toolkit/widget.go
deleted file mode 100644
index 02dbe3f..0000000
--- a/toolkit/widget.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package toolkit
-
-// passes information between the toolkit library (plugin)
-//
-// This is the only thing that is passed between the toolkit plugin
-//
-// what names should be used? This is not part of [[Graphical Widget]]
-// Event() seems like a good name.
-// Event is used too much: web dev, cloud, etc
-// I'm using "Action". Maybe it should really be
-// "Interaction" as per wikipedia [[User interface]]
-//
-// TODO: convert this to a protobuf (?)
-//
-
-type WidgetType int // Button, Menu, Checkbox, etc.
-type ActionType int // Add, SetText, Click, Hide, Append, Delete, etc
-
-type Action struct {
- ActionType ActionType
- WidgetType WidgetType
-
- WidgetId int
- ParentId int
-
- Text string // what is visable to the user
- Name string // a name useful for programming
-
- // This is how the values are passed back and forth
- // values from things like checkboxes & dropdown's
- B bool
- I int
- S string
-
- // This is used for things like a slider(0,100)
- X int
- Y int
-
- // This is for the grid size & widget position
- W int
- H int
- AtW int
- AtH int
-
- // Put space around elements to improve look & feel
- Margin bool
-
- // Make widgets fill up the space available
- Expand bool
-
- A any // switch to this or deprecate this? pros/cons?
-}
-
-const (
- Unknown WidgetType = iota
- Root // the master 'root' node of the binary tree
- Flag // used to send configuration values to plugins
- Window // in certain gui's (ncurses), these are tabs
- Tab // internally, this is a window
- Frame // deprecate?
- Grid // like drawers in a chest
- Group // like the 'Appetizers' section on a menu
- Box // a vertical or horizontal stack of widgets
- Button
- Checkbox // select 'on' or 'off'
- Dropdown
- Combobox // dropdown with edit=true
- Label
- Textbox // is this a Label with edit=true
- Slider // like a progress bar
- Spinner // like setting the oven temperature
- Separator // TODO
- Image // TODO
- Area // TODO
- Form // TODO
- Font // TODO
- Color // TODO
- Dialog // TODO
- Stdout // can be used to capture and display log output
-)
-
-const (
- Add ActionType = iota
- Delete
- Get
- Set
- GetText
- SetText
- AddText
- Show
- Hide
- Enable
- Disable
- Margin
- Unmargin
- Pad
- Unpad
- Append
- Move
- Dump
- User // the user did something (mouse, keyboard, etc)
- InitToolkit // initializes the toolkit
- CloseToolkit // closes the toolkit
- UserQuit // the user closed the GUI
- EnableDebug // open the debugging window
-)
-
-func (s WidgetType) String() string {
- switch s {
- case Root:
- return "Root"
- case Flag:
- return "Flag"
- case Window:
- return "Window"
- case Tab:
- return "Tab"
- case Frame:
- return "Frame"
- case Grid:
- return "Grid"
- case Group:
- return "Group"
- case Box:
- return "Box"
- case Button:
- return "Button"
- case Checkbox:
- return "Checkbox"
- case Dropdown:
- return "Dropdown"
- case Combobox:
- return "Combobox"
- case Label:
- return "Label"
- case Textbox:
- return "Textbox"
- case Slider:
- return "Slider"
- case Spinner:
- return "Spinner"
- case Separator:
- return "Separator"
- case Image:
- return "Image"
- case Area:
- return "Area"
- case Form:
- return "Form"
- case Font:
- return "Font"
- case Color:
- return "Color"
- case Dialog:
- return "Dialog"
- case Stdout:
- return "Stdout"
- case Unknown:
- return "Unknown"
- }
- return "WidgetType.String() Error"
-}
-
-func (s ActionType) String() string {
- switch s {
- case Add:
- return "Add"
- case Delete:
- return "Delete"
- case Get:
- return "Get"
- case Set:
- return "Set"
- case GetText:
- return "GetText"
- case SetText:
- return "SetText"
- case AddText:
- return "AddText"
- case Show:
- return "Show"
- case Hide:
- return "Hide"
- case Enable:
- return "Enable"
- case Disable:
- return "Disable"
- case Margin:
- return "Margin"
- case Unmargin:
- return "Unmargin"
- case Pad:
- return "Pad"
- case Unpad:
- return "Unpad"
- case Append:
- return "Append"
- case Move:
- return "Move"
- case Dump:
- return "Dump"
- }
- return "ActionType.String() Error"
-}
diff --git a/window.go b/window.go
index 9a0c849..30e9484 100644
--- a/window.go
+++ b/window.go
@@ -2,7 +2,7 @@ package gui
import (
"go.wit.com/log"
- "go.wit.com/gui/gui/toolkit"
+ "go.wit.com/gui/toolkits"
)
// This routine creates a blank window with a Title and size (W x H)