From c4f9bac85eeafb4916b57d6f8953fa930d6d098e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 8 Feb 2025 13:28:19 -0600 Subject: add config default to show stdout onscreen on start --- help.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'help.go') diff --git a/help.go b/help.go index 984de18..8ae7d7b 100644 --- a/help.go +++ b/help.go @@ -11,6 +11,7 @@ import ( "errors" "fmt" "strings" + "time" "github.com/awesome-gocui/gocui" log "go.wit.com/log" @@ -85,8 +86,13 @@ func showHelp() error { } g.SetViewOnTop("help") me.helpLabel = help + if me.clock.tk == nil { + makeClock() + me.clock.tk.MoveToOffset(maxX-10, 1) + me.clock.tk.Hide() + me.clock.tk.Show() + } 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() @@ -94,6 +100,19 @@ func showHelp() error { return nil } +func makeClock() { + 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()") +} + // in the very end of redrawing things, this will place the help and stdout on the top or botton // depending on the state the user has chosen func setThingsOnTop() { @@ -102,6 +121,9 @@ func setThingsOnTop() { } else { me.baseGui.SetViewOnTop("help") } + if me.clock.tk != nil { + me.baseGui.SetViewOnTop(me.clock.tk.v.Name()) + } if me.dark { me.stdout.tk.v.FgColor = gocui.ColorWhite @@ -116,6 +138,11 @@ func setThingsOnTop() { } else { me.baseGui.SetViewOnBottom("msg") } + if me.stdout.startOnscreen { + log.Info("attempting to locate stdout on screen for the first time") + me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) + me.stdout.startOnscreen = false + } setBottomBG() } -- cgit v1.2.3