summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tab.go19
-rw-r--r--toolkit/gocui/add.go1
-rw-r--r--toolkit/gocui/common.go2
-rw-r--r--toolkit/gocui/main.go5
-rw-r--r--toolkit/gocui/showStdout.go2
-rw-r--r--toolkit/gocui/structs.go9
-rw-r--r--toolkit/gocui/tab.go42
-rw-r--r--toolkit/gocui/view.go5
8 files changed, 72 insertions, 13 deletions
diff --git a/tab.go b/tab.go
index 5cdc0ad..0669cf6 100644
--- a/tab.go
+++ b/tab.go
@@ -10,20 +10,23 @@ import (
func (n *Node) NewTab(text string) *Node {
// check to make sure n is actually a window
+
if (n.WidgetType != toolkit.Window) {
// figure out what the actual window is
log(logError, "NewTab() is being requested on something that isn't a Window. node =", n)
- log(logError, "NewTab() parent", n.parent)
- return n.parent.NewTab(text)
- /*
- if (n.parent.WidgetType == toolkit.Window) {
- } else {
- if (n.parent.WidgetType == toolkit.Window) {
- return n.parent.NewTab(text)
+ if (n.parent == nil) {
// TODO: find a window. any window. never give up. never die.
+ log(logError, "NewTab() TODO: make a window here", n)
panic("NewTab did not get passed a window")
}
- */
+ log(logError, "NewTab() parent =", n.parent)
+ if (n.parent.WidgetType == toolkit.Root) {
+ // also broken
+ log(logError, "NewTab() TODO: make a window here", n)
+ panic("NewTab did not get passed a window")
+ }
+ // go up the binary tree until we find a window widget to add a tab too
+ return n.parent.NewTab(text)
}
newNode := n.newNode(text, toolkit.Tab, nil)
diff --git a/toolkit/gocui/add.go b/toolkit/gocui/add.go
index 64dbdd5..345b913 100644
--- a/toolkit/gocui/add.go
+++ b/toolkit/gocui/add.go
@@ -44,6 +44,7 @@ func (w *cuiWidget) addWidget() {
case toolkit.Window:
w.setTabWH()
w.drawView()
+ // w.frame = false
return
case toolkit.Tab:
w.setTabWH()
diff --git a/toolkit/gocui/common.go b/toolkit/gocui/common.go
index e348ab1..1b0d61f 100644
--- a/toolkit/gocui/common.go
+++ b/toolkit/gocui/common.go
@@ -30,6 +30,8 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
w.id = a.WidgetId
// set the name used by gocui to the id
w.cuiName = strconv.Itoa(w.id)
+ // set the gocui view.Frame = true by default
+ w.frame = true
if w.widgetType == toolkit.Root {
log(logInfo, "setupWidget() FOUND ROOT w.id =", w.id, "w.parent", w.parent, "ParentId =", a.ParentId)
diff --git a/toolkit/gocui/main.go b/toolkit/gocui/main.go
index c3418a6..34cea92 100644
--- a/toolkit/gocui/main.go
+++ b/toolkit/gocui/main.go
@@ -13,7 +13,10 @@ import (
// to this toolkit from the wit/gui golang package
func init() {
log(logInfo, "Init() of awesome-gocui")
- Set(&me, "default")
+ var test config
+ Set(&test, "default")
+ log(logNow, "Init() me.rawW", me.rawW)
+ // exit("test init()")
me.defaultBehavior = true
me.groupPadding = 4
diff --git a/toolkit/gocui/showStdout.go b/toolkit/gocui/showStdout.go
index d6469f7..4e20dda 100644
--- a/toolkit/gocui/showStdout.go
+++ b/toolkit/gocui/showStdout.go
@@ -16,6 +16,7 @@ func moveMsg(g *gocui.Gui) {
movingMsg = true
}
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH, 0)
+ g.SetViewOnBottom("msg")
}
func showMsg(g *gocui.Gui, v *gocui.View) error {
@@ -53,5 +54,6 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) {
v.SelFgColor = gocui.ColorBlack
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n" + stringFromMouseClick)
g.SetViewOnBottom("msg")
+ // g.SetViewOnBottom(v.Name())
return
}
diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go
index 4ee74c7..a9ceae9 100644
--- a/toolkit/gocui/structs.go
+++ b/toolkit/gocui/structs.go
@@ -131,6 +131,7 @@ type cuiWidget struct {
tainted bool
v *gocui.View
+ frame bool
// writeMutex protects locks the write process
writeMutex sync.Mutex
@@ -161,6 +162,7 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
func Set(ptr interface{}, tag string) error {
if reflect.TypeOf(ptr).Kind() != reflect.Ptr {
+ log("Set() Not a pointer", ptr, "with tag =", tag)
return fmt.Errorf("Not a pointer")
}
@@ -168,9 +170,12 @@ func Set(ptr interface{}, tag string) error {
t := v.Type()
for i := 0; i < t.NumField(); i++ {
+ log("Set() i =", i, t.Field(i))
if defaultVal := t.Field(i).Tag.Get(tag); defaultVal != "-" {
+ log("Set() tried something")
if err := setField(v.Field(i), defaultVal); err != nil {
- return err
+ log("Set() failed", err)
+ // return err
}
}
@@ -181,7 +186,7 @@ func Set(ptr interface{}, tag string) error {
func setField(field reflect.Value, defaultVal string) error {
if !field.CanSet() {
- log("Can't set value\n")
+ log("setField() Can't set value", field, defaultVal)
return fmt.Errorf("Can't set value\n")
}
diff --git a/toolkit/gocui/tab.go b/toolkit/gocui/tab.go
index cc00b6c..80447aa 100644
--- a/toolkit/gocui/tab.go
+++ b/toolkit/gocui/tab.go
@@ -72,8 +72,48 @@ func (w *cuiWidget) setTabWH() {
w.showWidgetPlacement(logNow, "setTabWH:")
}
+func (w *cuiWidget) setLabel() {
+ // set the start and size of the tab gocui button
+ t := len(w.text)
+ w.gocuiSize.width = t + me.buttonPadding
+ w.gocuiSize.height = 2
+ w.gocuiSize.w0 = me.rootNode.nextW
+ w.gocuiSize.h0 = me.rootNode.nextH
+
+ // move the rootNode width over for the next window or tab
+ me.rootNode.nextW += w.gocuiSize.width + me.padW
+
+ w.startW = me.rawW
+ w.startH = me.rawH
+ w.nextW = me.rawW
+ w.nextH = me.rawH
+
+ w.setWH()
+ w.showWidgetPlacement(logNow, "setLabel:")
+}
+
func (w *cuiWidget) redoTabs(draw bool) {
- if ((w.widgetType == toolkit.Window) || (w.widgetType == toolkit.Tab)) {
+ if (w.widgetType == toolkit.Window) {
+ var tabs bool = false
+ // figure out if the window is just a bunch of tabs
+ for _, child := range w.children {
+ if (child.widgetType == toolkit.Tab) {
+ tabs = true
+ }
+ }
+ if (tabs) {
+ // window is tabs. Don't show it as a standard button
+ w.frame = false
+ w.setLabel()
+ } else {
+ w.frame = true
+ w.setTabWH()
+ }
+
+ w.deleteView()
+ w.drawView()
+ }
+ if (w.widgetType == toolkit.Tab) {
w.deleteView()
w.drawView()
}
diff --git a/toolkit/gocui/view.go b/toolkit/gocui/view.go
index a6cca04..82d0594 100644
--- a/toolkit/gocui/view.go
+++ b/toolkit/gocui/view.go
@@ -8,7 +8,7 @@ import (
"strings"
"github.com/awesome-gocui/gocui"
-// "git.wit.org/wit/gui/toolkit"
+ "git.wit.org/wit/gui/toolkit"
)
func splitLines(s string) []string {
@@ -85,6 +85,9 @@ func (w *cuiWidget) drawView() {
me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click)
w.v.Wrap = true
+ if (w.widgetType == toolkit.Window) {
+ w.v.Frame = w.frame
+ }
fmt.Fprintln(w.v, w.text)
w.setDefaultWidgetColor()