diff --git a/init.go b/init.go index 0a37d65..65653b2 100644 --- a/init.go +++ b/init.go @@ -338,28 +338,11 @@ func refreshGocui() { if me.mouse.mouseUp { // log.Info("refresh now on mouseUp") // todo: add logic here to see if the application has changed anything - // me.baseGui.UpdateAsync(testRefresh) // probably don't need this - me.baseGui.Update(testRefresh) - if me.notify.clock.tk != nil { - // also double check the gocui view exists - if me.notify.clock.tk.v != nil { - me.notify.clock.tk.v.Clear() - me.notify.clock.tk.labelN = time.Now().Format("15:04:05") - me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN) - } - } + libNotifyUpdate() lastRefresh = time.Now() } else { - me.baseGui.Update(testRefresh) if time.Since(lastRefresh) > 3*time.Second { - if me.notify.clock.tk != nil && !me.showHelp { - // also double check the gocui view exists - if me.notify.clock.tk.v != nil { - me.notify.clock.tk.v.Clear() - me.notify.clock.tk.labelN = time.Now().Format("15:04:05") - me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN) - } - } + libNotifyUpdate() lastRefresh = time.Now() } } diff --git a/libnotify.go b/libnotify.go index 7cd68df..19be3c0 100644 --- a/libnotify.go +++ b/libnotify.go @@ -67,6 +67,39 @@ func makeClock(wId int) { me.notify.clock.tk.Show() me.notify.clock.active = true me.notify.clock.tk.dumpWidget("showClock()") + +} + +func libNotifyUpdate() { + if me.baseGui == nil { + log.Info("libNotifyUpdate error baseGui == nil") + return + } + + // refresh GOCUI + me.baseGui.Update(testRefresh) + // me.baseGui.UpdateAsync(testRefresh) // Async option. probably don't need this? + + if me.notify.clock.tk == nil { + log.Info("libNotifyUpdate error clock.tk == nil") + return + } + + // check for SIGWINCH. If so, move the libnotify clock + w, h := me.baseGui.Size() + if me.winchW != w || me.winchH != h { + log.Info("handle SIGWINCH!", w, h) + me.notify.clock.tk.MoveToOffset(w-15, 1) + me.notify.clock.tk.Hide() + me.notify.clock.tk.Show() + me.winchW = w + me.winchH = h + } + + // update the time + me.notify.clock.tk.v.Clear() + me.notify.clock.tk.labelN = time.Now().Format("15:04:05") + me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN) } // in the very end of redrawing things, this will place the help and stdout on the top or botton diff --git a/structs.go b/structs.go index 9537b89..b19367d 100644 --- a/structs.go +++ b/structs.go @@ -78,14 +78,15 @@ type config struct { stdout stdout // information for the STDOUT window dropdown dropdown // the dropdown menu textbox dropdown // the textbox popup window - // clock dropdown // the textbox popup window - notify libnotify // emulates the desktop libnotify menu - 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 - debug bool // todo: move this into config struct - starttime time.Time // checks how long it takes on startup + notify libnotify // emulates the desktop libnotify menu + 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 + debug bool // todo: move this into config struct + starttime time.Time // checks how long it takes on startup + winchW int // used to detect SIGWINCH + winchH int // used to detect SIGWINCH } // stuff controlling how the mouse works