From 9c548faedacfdfbda09d170c6665fcdb988bd877 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 6 Feb 2025 03:28:05 -0600 Subject: [PATCH] try to start with STDOUT offscreen --- eventBindings.go | 10 ++++++++++ eventMouseMove.go | 29 +++-------------------------- stdoutShow.go | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/eventBindings.go b/eventBindings.go index d869474..33602ba 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -101,6 +101,16 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error { func theStdout(g *gocui.Gui, v *gocui.View) error { if me.stdout.outputOnTop { + if me.stdout.outputOffscreen { + me.stdout.outputOffscreen = false + log.Info("set stdout off screen here") + relocateStdoutOffscreen() + return nil + } else { + me.stdout.outputOffscreen = true + log.Info("set stdout on screen here") + } + me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) me.stdout.outputOnTop = false me.baseGui.SetViewOnBottom("msg") } else { diff --git a/eventMouseMove.go b/eventMouseMove.go index ff08b01..01e49f3 100644 --- a/eventMouseMove.go +++ b/eventMouseMove.go @@ -93,29 +93,6 @@ func mouseMove(g *gocui.Gui) { } } -func (tk *guiWidget) relocateStdout(w int, h int) { - me.stdout.lastW = w - me.stdout.lastH = h - - w0 := w - h0 := h - w1 := w + me.stdout.w - h1 := h + me.stdout.h - - tk.gocuiSize.w0 = w0 - tk.gocuiSize.w1 = w1 - tk.gocuiSize.h0 = h0 - tk.gocuiSize.h1 = h1 - - tk.full.w0 = w0 - tk.full.w1 = w1 - tk.full.h0 = h0 - tk.full.h1 = h1 - - me.baseGui.SetView("msg", w0, h0, w1, h1, 0) - me.baseGui.SetViewOnBottom("msg") -} - // this is how the window gets dragged around func (tk *guiWidget) moveNew() { w, h := me.baseGui.MousePosition() @@ -131,9 +108,9 @@ func (tk *guiWidget) moveNew() { tk.dumpWidget(s) return } else { - newW := w - me.stdout.mouseOffsetW - newH := h - me.stdout.mouseOffsetH - tk.relocateStdout(newW, newH) + me.stdout.lastW = w - me.stdout.mouseOffsetW + me.stdout.lastH = h - me.stdout.mouseOffsetH + tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) /* // log.Info("NOT MOVE FLAG. PASSING MOVE TO MSG", tk.node.WidgetType) // tk.dumpWidget("moveNew() MSG" + tk.cuiName) diff --git a/stdoutShow.go b/stdoutShow.go index 6316aed..dd5a403 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -91,5 +91,32 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { me.stdout.tk.v = v me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH) + relocateStdoutOffscreen() return v } + +func relocateStdoutOffscreen() { + newW := 10 + newH := 0 - me.stdout.h - 4 + me.stdout.tk.relocateStdout(newW, newH) +} + +func (tk *guiWidget) relocateStdout(w int, h int) { + w0 := w + h0 := h + w1 := w + me.stdout.w + h1 := h + me.stdout.h + + tk.gocuiSize.w0 = w0 + tk.gocuiSize.w1 = w1 + tk.gocuiSize.h0 = h0 + tk.gocuiSize.h1 = h1 + + tk.full.w0 = w0 + tk.full.w1 = w1 + tk.full.h0 = h0 + tk.full.h1 = h1 + + me.baseGui.SetView("msg", w0, h0, w1, h1, 0) + // me.baseGui.SetViewOnBottom("msg") +}