summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventBindings.go21
-rw-r--r--help.go6
-rw-r--r--init.go13
-rw-r--r--structs.go3
4 files changed, 35 insertions, 8 deletions
diff --git a/eventBindings.go b/eventBindings.go
index 09bdcbe..4f09e79 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -5,6 +5,7 @@ package main
import (
"syscall"
+ "time"
"github.com/awesome-gocui/gocui"
"go.wit.com/log"
@@ -76,13 +77,23 @@ func addDropdown() *tree.Node {
// use this to test code ideas // put whatever you want here and hit '2' to activate it
func theNotsure(g *gocui.Gui, v *gocui.View) error {
- if me.dark {
- me.dark = false
+ log.Info("got keypress 2. now what? dark =", me.dark)
+ if me.clock.tk == nil {
+ me.clock.tk = makeNewFlagWidget(me.clock.wId)
+ me.clock.tk.dumpWidget("init() clock")
+ w, h := me.baseGui.MousePosition()
+ me.clock.tk.MoveToOffset(w, h)
+ me.clock.tk.labelN = time.Now().Format("15:04:05")
+ me.clock.tk.frame = false
+ me.clock.tk.setColorLabel()
+ me.clock.tk.Show()
+ me.clock.active = true
+ me.clock.tk.dumpWidget("showClock()")
} else {
- me.dark = true
+ me.clock.tk.v.Clear()
+ me.clock.tk.labelN = time.Now().Format("15:04:05")
+ me.clock.tk.v.WriteString(me.clock.tk.labelN)
}
- log.Info("got keypress 2. now what? dark =", me.dark)
- // findBG()
return nil
}
diff --git a/help.go b/help.go
index 6a64bc4..984de18 100644
--- a/help.go
+++ b/help.go
@@ -85,6 +85,12 @@ func showHelp() error {
}
g.SetViewOnTop("help")
me.helpLabel = help
+ if me.clock.tk != nil {
+ g.SetView("help", maxX-(newW+me.FramePadW), 0, maxX-1, len(helpText)+me.FramePadH, 0)
+ me.clock.tk.MoveToOffset(maxX-10, 1)
+ me.clock.tk.Hide()
+ me.clock.tk.Show()
+ }
return nil
}
diff --git a/init.go b/init.go
index fa57a64..d950806 100644
--- a/init.go
+++ b/init.go
@@ -49,6 +49,7 @@ func init() {
me.dropdown.wId = -77
me.textbox.wId = -55
me.stdout.wId = -4
+ me.clock.wId = -5
me.mouse.mouseUp = true
me.mouse.clicktime = time.Millisecond * 100
@@ -230,16 +231,24 @@ func refreshGocui() {
var lastRefresh time.Time
lastRefresh = time.Now()
for {
- time.Sleep(10 * time.Millisecond)
+ time.Sleep(100 * time.Millisecond)
// log.Info("refresh checking ok")
if !me.ok {
continue
}
- if time.Since(lastRefresh) > 100*time.Millisecond {
+ if time.Since(lastRefresh) > 1000*time.Millisecond {
if me.mouse.mouseUp {
// log.Info("refresh now on mouseUp")
// todo: add logic here to see if the application has changed anything
me.baseGui.Update(testRefresh)
+ if me.clock.tk != nil && !me.showHelp {
+ // also double check the gocui view exists
+ if me.clock.tk.v != nil {
+ me.clock.tk.v.Clear()
+ me.clock.tk.labelN = time.Now().Format("15:04:05")
+ me.clock.tk.v.WriteString(me.clock.tk.labelN)
+ }
+ }
} else {
// log.Info("refresh skip on mouseDown")
// me.baseGui.Update()
diff --git a/structs.go b/structs.go
index bd32005..f49ab46 100644
--- a/structs.go
+++ b/structs.go
@@ -65,12 +65,13 @@ type config struct {
depth int // used for listWidgets() debugging
newWindowTrigger chan *guiWidget // work around hack to redraw windows a bit after NewWindow()
stdout stdout // information for the STDOUT window
- showDebug bool // todo: move this into config struct
dropdown dropdown // the dropdown menu
textbox dropdown // the textbox popup window
+ clock dropdown // the textbox popup window
allwin []*guiWidget // for tracking which window is next
dark bool // use a 'dark' color palette
mouse mouse // mouse settings
+ showDebug bool // todo: move this into config struct
}
// stuff controlling how the mouse works