kinda don't believe it, but maybe new mouseMove()

This commit is contained in:
Jeff Carr 2025-02-01 17:38:10 -06:00
parent 2062060dac
commit 9a3f9d0991
4 changed files with 14 additions and 16 deletions

View File

@ -105,7 +105,7 @@ func doPanic(g *gocui.Gui, v *gocui.View) error {
func dumpWidgets(g *gocui.Gui, v *gocui.View) error { func dumpWidgets(g *gocui.Gui, v *gocui.View) error {
me.treeRoot.ListWidgets() me.treeRoot.ListWidgets()
tk := me.logStdout.TK.(*guiWidget) tk := me.logStdout
// msg := fmt.Sprintf("test out kb %d\n", ecount) // msg := fmt.Sprintf("test out kb %d\n", ecount)
// tk.Write([]byte(msg)) // tk.Write([]byte(msg))
if tk == nil { if tk == nil {

View File

@ -63,13 +63,14 @@ func (tk *guiWidget) moveNew(g *gocui.Gui) {
if !me.movingMsg && (mx != initialMouseX || my != initialMouseY) { if !me.movingMsg && (mx != initialMouseX || my != initialMouseY) {
me.movingMsg = true me.movingMsg = true
} }
// tk.MoveToOffset(mx-xOffset, my-yOffset) // tk.DrawAt(mx-xOffset, my-yOffset)
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0) g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
me.startOutputW = mx - xOffset me.startOutputW = mx - xOffset
me.startOutputH = my - yOffset me.startOutputH = my - yOffset
g.SetViewOnBottom("msg") g.SetViewOnBottom("msg")
} }
/*
// this is how the window gets dragged around // this is how the window gets dragged around
func moveMsg(g *gocui.Gui) { func moveMsg(g *gocui.Gui) {
mx, my := g.MousePosition() mx, my := g.MousePosition()
@ -81,14 +82,14 @@ func moveMsg(g *gocui.Gui) {
me.startOutputH = my - yOffset me.startOutputH = my - yOffset
g.SetViewOnBottom("msg") g.SetViewOnBottom("msg")
} }
*/
func createStdout(g *gocui.Gui) bool { func createStdout(g *gocui.Gui) bool {
if widgetView, _ := g.View("msg"); widgetView == nil { if widgetView, _ := g.View("msg"); widgetView == nil {
makeOutputWidget(g, "this is a create before a mouse click") makeOutputWidget(g, "this is a create before a mouse click")
if me.logStdout != nil { if me.logStdout != nil {
w := me.logStdout.TK.(*guiWidget)
msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount) msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount)
w.Write([]byte(msg)) me.logStdout.Write([]byte(msg))
log.Log(NOW, "logStdout test out") log.Log(NOW, "logStdout test out")
} }
return true return true

View File

@ -52,11 +52,9 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
a.ParentId = 0 a.ParentId = 0
// n := addNode(a) // n := addNode(a)
n := me.myTree.AddNode(a) n := me.myTree.AddNode(a)
n.TK = initWidget(n) me.logStdout = initWidget(n)
me.logStdout = n
var tk *guiWidget tk := me.logStdout
tk = me.logStdout.TK.(*guiWidget)
// tk.gocuiSize.w0 = maxX - 32 // tk.gocuiSize.w0 = maxX - 32
// tk.gocuiSize.h0 = maxY / 2 // tk.gocuiSize.h0 = maxY / 2
tk.gocuiSize.w0 = me.startOutputW tk.gocuiSize.w0 = me.startOutputW
@ -75,7 +73,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
// v, err = g.SetView("msg", 3, 3, 30, 30, 0) // v, err = g.SetView("msg", 3, 3, 30, 30, 0)
if me.startOutputW == 0 { if me.startOutputW == 0 {
me.startOutputW = maxX - 32 me.startOutputW = maxX - 132
} }
if me.startOutputW == 0 { if me.startOutputW == 0 {
me.startOutputH = maxY / 2 me.startOutputH = maxY / 2
@ -96,9 +94,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err) log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
return nil return nil
} else { } else {
var tk *guiWidget me.logStdout.v = v
tk = me.logStdout.TK.(*guiWidget)
tk.v = v
} }
v.Clear() v.Clear()
@ -107,5 +103,6 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick) fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick)
g.SetViewOnBottom("msg") g.SetViewOnBottom("msg")
// g.SetViewOnBottom(v.Name()) // g.SetViewOnBottom(v.Name())
me.logStdout.DrawAt(50, 50)
return v return v
} }

View File

@ -35,7 +35,7 @@ type config struct {
myTree *tree.TreeInfo // ? myTree *tree.TreeInfo // ?
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
currentWindow *guiWidget // this is the current tab or window to show currentWindow *guiWidget // this is the current tab or window to show
logStdout *tree.Node // where to show STDOUT logStdout *guiWidget // where to show STDOUT
startOutputW int // ? startOutputW int // ?
startOutputH int // ? startOutputH int // ?
helpLabel *gocui.View // ? helpLabel *gocui.View // ?
@ -63,7 +63,7 @@ type config struct {
menubar bool // for windows menubar bool // for windows
stretchy bool // expand things like buttons to the maximum size stretchy bool // expand things like buttons to the maximum size
margin bool // add space around the frames of windows margin bool // add space around the frames of windows
writeMutex sync.Mutex // TODO: writeMutex protects locks the write process writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
dtoggle bool // is a dropdown or combobox currently active? dtoggle bool // is a dropdown or combobox currently active?
showHelp bool // toggle boolean for the help menu (deprecate?) showHelp bool // toggle boolean for the help menu (deprecate?)
@ -131,8 +131,8 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
w.tainted = true w.tainted = true
me.writeMutex.Lock() me.writeMutex.Lock()
defer me.writeMutex.Unlock() defer me.writeMutex.Unlock()
var tk *guiWidget
tk = me.logStdout.TK.(*guiWidget) tk := me.logStdout
if tk.v == nil { if tk.v == nil {
// optionally write the output to /tmp // optionally write the output to /tmp
s := fmt.Sprint(string(p)) s := fmt.Sprint(string(p))