summaryrefslogtreecommitdiff
path: root/text.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-20 06:55:42 -0500
committerJeff Carr <[email protected]>2022-10-20 06:55:42 -0500
commitb8ef0bb05dc14bc4291f3d156b199fa125cdb9d7 (patch)
tree71280d7f01805dfbd430f71df16858079686b8fc /text.go
parentf3af1f5b7ff78b3f73d7510622fc9633dec36d35 (diff)
Squashed commit of the following:
all non binary tree structs are gone (almost all) Use names from https://en.wikipedia.org/wiki/Graphical_widget toolkit andlabs/ui is isolated from being accessable all direct references to andlabs are removed working dropdown widgets add debugging more buttons and windows
Diffstat (limited to 'text.go')
-rw-r--r--text.go62
1 files changed, 42 insertions, 20 deletions
diff --git a/text.go b/text.go
index 69a9002..6f46998 100644
--- a/text.go
+++ b/text.go
@@ -2,8 +2,7 @@ package gui
import "log"
import "errors"
-
-// import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
+import "regexp"
// functions for handling text related GUI elements
@@ -12,29 +11,52 @@ func (n *Node) NewLabel(text string) *Node {
newNode := n.New(text)
newNode.Dump()
- t := n.Toolkit.NewLabel(text)
- newNode.Toolkit = t
+ t := n.toolkit.NewLabel(text)
+ newNode.toolkit = t
return newNode
}
func (n *Node) SetText(value string) error {
log.Println("gui.SetText() value =", value)
- if (n.Toolkit != nil) {
- n.Toolkit.SetText(value)
- return nil
- }
- if (n.uiText != nil) {
- n.uiText.SetText(value)
- return nil
- }
- if (n.uiButton != nil) {
- n.uiButton.SetText(value)
- return nil
- }
- if (n.uiWindow != nil) {
- n.uiWindow.SetTitle(value)
- return nil
- }
+ panic("redo SetText()")
return errors.New("nothing found for gui.Node.SetText()")
}
+
+/*
+// string handling examples that might be helpful for normalizeInt()
+isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
+
+for _, username := range []string{"userone", "user2", "user-three"} {
+ if !isAlpha(username) {
+ fmt.Printf("%q is not valid\n", username)
+ }
+}
+
+const alpha = "abcdefghijklmnopqrstuvwxyz"
+
+func alphaOnly(s string) bool {
+ for _, char := range s {
+ if !strings.Contains(alpha, strings.ToLower(string(char))) {
+ return false
+ }
+ }
+ return true
+}
+*/
+
+func normalizeInt(s string) string {
+ // reg, err := regexp.Compile("[^a-zA-Z0-9]+")
+ reg, err := regexp.Compile("[^0-9]+")
+ if err != nil {
+ log.Println("normalizeInt() regexp.Compile() ERROR =", err)
+ return s
+ }
+ clean := reg.ReplaceAllString(s, "")
+ log.Println("normalizeInt() s =", clean)
+ return clean
+}
+
+func (n *Node) GetText() string {
+ return n.toolkit.GetText()
+}