summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventGocui.go1
-rw-r--r--find.go19
-rw-r--r--init.go23
-rw-r--r--libnotify.go42
-rw-r--r--stdoutShow.go6
-rw-r--r--structs.go3
6 files changed, 52 insertions, 42 deletions
diff --git a/eventGocui.go b/eventGocui.go
index 6527bba..7999f14 100644
--- a/eventGocui.go
+++ b/eventGocui.go
@@ -7,7 +7,6 @@ import (
"errors"
"github.com/awesome-gocui/gocui"
-
"go.wit.com/log"
)
diff --git a/find.go b/find.go
index 8fb8318..d3aa19d 100644
--- a/find.go
+++ b/find.go
@@ -94,25 +94,6 @@ func (tk *guiWidget) findWindows() []*guiWidget {
return found
}
-// find the BG widget.
-// This widget is always in the background and covers the whole screen.
-// gocui seems to not return mouse events unless there is something there
-func (tk *guiWidget) findBG() *guiWidget {
- if tk.WidgetType() == widget.Stdout {
- if tk.WidgetId() != me.stdout.wId {
- tk.isBG = true
- return tk
- }
- }
-
- for _, child := range tk.children {
- if found := child.findBG(); found != nil {
- return found
- }
- }
- return nil
-}
-
// used by gocui.TabKey to rotate through the windows
func findNextWindow() *guiWidget {
var found bool
diff --git a/init.go b/init.go
index 425be56..f23c391 100644
--- a/init.go
+++ b/init.go
@@ -26,6 +26,9 @@ var BUILDTIME string
var PLUGIN string = "gocui"
+// this is called at the very initial connection
+// between the app and this gocui plugin
+// this is a good place to initialize gocui's default behavior
func toolkitInit() {
log.Info("gocui toolkitInit() me.ok =", me.ok)
if me.baseGui == nil {
@@ -62,14 +65,19 @@ func toolkitInit() {
setThingsOnTop()
// SETUP STDOUT END
+ // SETUP BG
+ if me.BG.tk == nil {
+ me.BG.tk = makeNewInternalWidget(me.BG.wId)
+ }
+
// PUT INIT DEBUG COOE HERE
var toggle bool
- for i := 0; i < 3; i++ {
+ for i := 0; i < 6; i++ {
w := me.treeRoot.TK.(*guiWidget)
w.dumpTree("MM")
w.dumpWindows("WW")
- time.Sleep(500 * time.Millisecond)
+ time.Sleep(1000 * time.Millisecond)
if toggle {
toggle = false
log.Info("gocui toolkitInit() put testing true stuff here")
@@ -77,6 +85,7 @@ func toolkitInit() {
toggle = true
log.Info("gocui toolkitInit() put testing false stuff here")
}
+ setBottomBG()
}
// PUT INIT DEBUG COOE HERE END
@@ -145,15 +154,15 @@ func initPlugin() {
log.Info("error opening file:", err)
os.Exit(0)
}
+ // todo: some early output still goes to the /tmp/ file
+ //time.Sleep(200 * time.Millisecond)
+ log.CaptureMode(me.stdout)
}
me.starttime = time.Now()
log.Log(INFO, "Init() of awesome-gocui")
// init the config struct default values
Set(&me, "default")
- // todo: some early output still goes to the /tmp/ file
- //time.Sleep(200 * time.Millisecond)
- log.CaptureMode(me.stdout)
// initial app window settings
@@ -167,6 +176,7 @@ func initPlugin() {
me.dropdown.wId = -77
me.textbox.wId = -55
me.stdout.wId = -4
+ me.BG.wId = -22
// the clock widget id and offset
me.notify.clock.wId = -5
@@ -189,8 +199,9 @@ func initPlugin() {
log.Log(NOW, "Init() start pluginChan")
if me.stdout.disable {
- log.Info("USING STDOUT")
+ log.Info("Using STDOUT")
} else {
+ log.Info("Using gocui STDOUT")
os.Stdout = me.outf
log.CaptureMode(me.outf)
}
diff --git a/libnotify.go b/libnotify.go
index fc5e897..58ce3b3 100644
--- a/libnotify.go
+++ b/libnotify.go
@@ -144,19 +144,37 @@ func setThingsOnTop() {
setBottomBG()
}
+// find the "BG" widget and set it to the background on the very very bottom
func setBottomBG() {
- // this attempts to find the "BG" widget and set it to the background on the very very bottom
- rootTK := me.treeRoot.TK.(*guiWidget)
- if tk := rootTK.findBG(); tk != nil {
- // log.Info("found BG. setting to bottom", tk.cuiName)
- if me.dark {
- tk.v.BgColor = gocui.ColorBlack
- } else {
- tk.v.BgColor = gocui.ColorWhite
- }
- tk.v.Clear()
- me.baseGui.SetViewOnBottom(tk.cuiName)
+ if me.BG.tk == nil {
+ log.Info("background tk widget not initialized")
+ return
+ }
+ tk := me.BG.tk
+ log.Info("found BG. setting to bottom", tk.cuiName)
+ if tk.v == nil {
w, h := me.baseGui.Size()
- me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0)
+ a := -1
+ b := -1
+ c := w + 1
+ d := h + 1
+ var err error
+ tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
+ if err == nil {
+ tk.dumpWidget("drawView() err")
+ log.Log(ERROR, "drawView() internal plugin error err = nil")
+ return
+ }
+ log.Info("background tk View not initialized")
+ return
}
+ if me.dark {
+ tk.v.BgColor = gocui.ColorBlack
+ } else {
+ tk.v.BgColor = gocui.ColorWhite
+ }
+ tk.v.Clear()
+ me.baseGui.SetViewOnBottom(tk.cuiName)
+ w, h := me.baseGui.Size()
+ me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0)
}
diff --git a/stdoutShow.go b/stdoutShow.go
index 4bbf59a..fd71efc 100644
--- a/stdoutShow.go
+++ b/stdoutShow.go
@@ -115,8 +115,10 @@ func relocateStdoutOffscreen() {
if me.stdout.tk == nil {
return
}
- log.CaptureMode(me.stdout.tk)
- // log.Log(ERROR, "setting log.CaptureMode(tk.v) in relocateStdoutOffscreen()")
+ if !me.stdout.disable {
+ log.Info("Using gocui STDOUT")
+ log.CaptureMode(me.stdout.tk)
+ }
newW := 10
newH := 0 - me.stdout.h - 4
me.stdout.tk.relocateStdout(newW, newH)
diff --git a/structs.go b/structs.go
index 8b9541c..5d94d50 100644
--- a/structs.go
+++ b/structs.go
@@ -77,6 +77,7 @@ type config struct {
stdout stdout // information for the STDOUT window
dropdown dropdown // the dropdown menu
textbox dropdown // the textbox popup window
+ BG dropdown // the background widget
notify libnotify // emulates the desktop libnotify menu
allwin []*guiWidget // for tracking which window is next
dark bool // use a 'dark' color palette
@@ -187,7 +188,6 @@ type window struct {
currentTab bool // the visible tab
selectedTab *tree.Node // for a window, this is currently selected tab
active bool // means this window is the active one
- isBG bool // means this is the background widget. There is only one of these
order int // what level the window is on
// resize bool // only set the title once
collapsed bool // only show the window title bar
@@ -239,7 +239,6 @@ type guiWidget struct {
color *colorT // what color to use
colorLast colorT // the last color the widget had
defaultColor *colorT // the default colors // TODO: make a function for this instead
- isBG bool // means this is the background widget. There is only one of these
}
// THIS IS GO COMPILER MAGIC