resize stdout window works

This commit is contained in:
Jeff Carr 2025-02-06 04:15:36 -06:00
parent 96cb52f3ef
commit d3b25092f8
6 changed files with 36 additions and 61 deletions

View File

@ -89,20 +89,6 @@ func (tk *guiWidget) dumpWidget(s string) {
func printWidgetTree(g *gocui.Gui, v *gocui.View) error { func printWidgetTree(g *gocui.Gui, v *gocui.View) error {
me.treeRoot.ListWidgets() me.treeRoot.ListWidgets()
tk := me.stdout.tk
// msg := fmt.Sprintf("test out kb %d\n", ecount)
// tk.Write([]byte(msg))
if tk == nil {
log.Log(ERROR, "tk = nil")
}
if tk.v == nil {
log.Log(ERROR, "tk.v = nil")
} else {
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
log.CaptureMode(tk)
}
return nil return nil
} }

View File

@ -29,15 +29,6 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
dropdownUnclicked(w, h) dropdownUnclicked(w, h)
/*
if msgMouseDown {
log.Info("setting mousedown to false")
msgMouseDown = false
} else if globalMouseDown {
globalMouseDown = false
g.DeleteView("globalDown")
}
*/
return nil return nil
} }
@ -68,6 +59,9 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
if tk.node.WidgetType == widget.Window { if tk.node.WidgetType == widget.Window {
tk.dragW = mx - tk.gocuiSize.w0 tk.dragW = mx - tk.gocuiSize.w0
tk.dragH = my - tk.gocuiSize.h0 tk.dragH = my - tk.gocuiSize.h0
if (mx-tk.gocuiSize.w0 < 3) && (my-tk.gocuiSize.h0 < 3) {
log.Info("RESIZE WINDOW", tk.dragW, tk.dragH)
}
log.Info("SENDING CLICK TO WINDOW", tk.dragW, tk.dragH) log.Info("SENDING CLICK TO WINDOW", tk.dragW, tk.dragH)
tk.doWidgetClick(mx-tk.dragW, my-tk.dragH) tk.doWidgetClick(mx-tk.dragW, my-tk.dragH)
return nil return nil
@ -75,7 +69,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
if tk.node.WidgetType == widget.Label { if tk.node.WidgetType == widget.Label {
log.Info("IGNORE LABLE") log.Info("IGNORE LABLE")
found = false found = false
log.Info("setting mousedown to true") log.Info("setting mousedown to true for label")
// msgMouseDown = true // msgMouseDown = true
return nil return nil
} }
@ -140,7 +134,18 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
me.stdout.mouseOffsetW = w - vx me.stdout.mouseOffsetW = w - vx
me.stdout.mouseOffsetH = h - vy me.stdout.mouseOffsetH = h - vy
} }
log.Info("setting mousedown to true")
// did the user click in the corner of the stdout window? If so, resize the window.
cornerW := w - vx
cornerH := h - vy
if (me.stdout.w-cornerW < 4) && (me.stdout.h-cornerH < 4) {
log.Info("Resize msg", cornerW, cornerH)
me.stdout.resize = true
} else {
log.Info("not Resize msg", cornerW, cornerH)
me.stdout.resize = false
}
log.Info("setting mousedown to true for msg")
// msgMouseDown = true // msgMouseDown = true
return nil return nil
} }

View File

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

12
help.go
View File

@ -23,22 +23,14 @@ import (
// possible with gocui. it doesn't seem to work for me // possible with gocui. it doesn't seem to work for me
*/ */
var helpText []string = []string{"KEYBINDINGS", var helpText []string = []string{"Help Menu",
"", "",
"H: toggle (H)elp", "H: toggle (H)elp",
"O: toggle (O)output (os.STDOUT)", "O: toggle (O)output (os.STDOUT)",
"S: super mouse", "S: super mouse",
"M: list all widgets positions", "M: list all widgets positions",
"L: list all widgets in tree form", "L: list all widgets in tree",
"d: toggle debugging",
"s/h: show/hide all widgets",
"q: quit()", "q: quit()",
"p: panic()",
"l: log to /tmp/witgui.log",
"Ctrl-D: Toggle Debugging",
"Ctrl-V: Toggle Verbose Debugging",
"Ctrl-C: Exit",
"", "",
} }

View File

@ -99,6 +99,8 @@ func relocateStdoutOffscreen() {
if me.stdout.tk == nil { if me.stdout.tk == nil {
return return
} }
log.CaptureMode(me.stdout.tk)
log.Log(ERROR, "setting log.CaptureMode(tk.v) in relocateStdoutOffscreen()")
newW := 10 newW := 10
newH := 0 - me.stdout.h - 4 newH := 0 - me.stdout.h - 4
me.stdout.tk.relocateStdout(newW, newH) me.stdout.tk.relocateStdout(newW, newH)

View File

@ -84,6 +84,7 @@ type stdout struct {
mouseOffsetW int // the current 'w' offset mouseOffsetW int // the current 'w' offset
mouseOffsetH int // the current 'h' offset mouseOffsetH int // the current 'h' offset
init bool // moves the window offscreen on startup init bool // moves the window offscreen on startup
resize bool // user is resizing the window
} }
// this is the gocui way // this is the gocui way