more work on stdout settings

This commit is contained in:
Jeff Carr 2025-02-06 03:09:13 -06:00
parent d0e35bb98f
commit d2c3db7b58
5 changed files with 64 additions and 33 deletions

View File

@ -137,8 +137,8 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
vx, vy, _, _, err := g.ViewPosition("msg")
if err == nil {
me.stdout.offsetW = w - vx
me.stdout.offsetH = h - vy
me.stdout.mouseOffsetW = w - vx
me.stdout.mouseOffsetH = h - vy
}
log.Info("setting mousedown to true")
// msgMouseDown = true

View File

@ -93,6 +93,29 @@ 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()
@ -108,27 +131,32 @@ func (tk *guiWidget) moveNew() {
tk.dumpWidget(s)
return
} else {
// log.Info("NOT MOVE FLAG. PASSING MOVE TO MSG", tk.node.WidgetType)
// tk.dumpWidget("moveNew() MSG" + tk.cuiName)
w0 := w - me.stdout.offsetW
h0 := h - me.stdout.offsetH
w1 := w - me.stdout.offsetW + me.stdout.w
h1 := h - me.stdout.offsetH + me.stdout.h
me.baseGui.SetView("msg", w0, h0, w1, h1, 0)
newW := w - me.stdout.mouseOffsetW
newH := h - me.stdout.mouseOffsetH
tk.relocateStdout(newW, newH)
/*
// log.Info("NOT MOVE FLAG. PASSING MOVE TO MSG", tk.node.WidgetType)
// tk.dumpWidget("moveNew() MSG" + tk.cuiName)
w0 := w - me.stdout.offsetW
h0 := h - me.stdout.offsetH
w1 := w - me.stdout.offsetW + me.stdout.w
h1 := h - me.stdout.offsetH + me.stdout.h
me.baseGui.SetView("msg", w0, h0, w1, h1, 0)
// me.startOutputW = w - me.stdout.offsetW
// me.startOutputH = h - me.stdout.offsetH
me.baseGui.SetViewOnBottom("msg")
// me.startOutputW = w - me.stdout.offsetW
// me.startOutputH = h - me.stdout.offsetH
me.baseGui.SetViewOnBottom("msg")
tk.gocuiSize.w0 = w0
tk.gocuiSize.w1 = w1
tk.gocuiSize.h0 = h0
tk.gocuiSize.h1 = h1
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
tk.full.w0 = w0
tk.full.w1 = w1
tk.full.h0 = h0
tk.full.h1 = h1
*/
}
// always place the help menu on top
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn

View File

@ -41,8 +41,8 @@ func init() {
// initial stdout window settings
me.stdout.w = 180
me.stdout.h = 40
me.stdout.offsetW = 30
me.stdout.offsetH = 10
me.stdout.lastW = 30
me.stdout.lastH = 10
// Set(&me, "dense")

View File

@ -50,8 +50,8 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
me.stdout.tk = initWidget(n)
tk := me.stdout.tk
tk.gocuiSize.w0 = me.stdout.offsetW
tk.gocuiSize.h0 = me.stdout.offsetH
tk.gocuiSize.w0 = me.stdout.lastW
tk.gocuiSize.h0 = me.stdout.lastH
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
@ -90,6 +90,6 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
g.SetViewOnBottom("msg")
me.stdout.tk.v = v
me.stdout.tk.DrawAt(me.stdout.offsetW, me.stdout.offsetH)
me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH)
return v
}

View File

@ -72,14 +72,17 @@ type config struct {
// settings for the stdout window
type stdout struct {
tk *guiWidget // where to show STDOUT
w int // the width
h int // the width
outputOnTop bool // is the STDOUT window on top?
offscreenW int // where to place the window offscreen
offscreenH int // where to place the window offscreen
offsetW int // the current 'w' offset
offsetH int // the current 'h' offset
tk *guiWidget // where to show STDOUT
w int // the width
h int // the width
outputOnTop bool // is the STDOUT window on top?
outputOffscreen bool // is the STDOUT window offscreen?
// offscreenW int // where to place the window offscreen
// offscreenH int // where to place the window offscreen
lastW int // the last 'w' location (used to move from offscreen to onscreen)
lastH int // the last 'h' location (used to move from offscreen to onscreen)
mouseOffsetW int // the current 'w' offset
mouseOffsetH int // the current 'h' offset
}
// this is the gocui way