start working on movingMsg

This commit is contained in:
Jeff Carr 2025-02-01 16:50:01 -06:00
parent 3d5ee3f89b
commit 4dad234532
4 changed files with 17 additions and 20 deletions

View File

@ -50,8 +50,8 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
if msgMouseDown {
msgMouseDown = false
if movingMsg {
movingMsg = false
if me.movingMsg {
me.movingMsg = false
return nil
} else {
g.DeleteView("msg")

View File

@ -44,17 +44,24 @@ func mouseMove(g *gocui.Gui) {
}
}
/*
func dragOutputWindow() {
log.Log(GOCUI, "todo: make dragOutputWindow")
// this is how the window gets dragged around
func moveMsg(g *gocui.Gui) {
mx, my := g.MousePosition()
if !me.movingMsg && (mx != initialMouseX || my != initialMouseY) {
me.movingMsg = true
}
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
me.startOutputW = mx - xOffset
me.startOutputH = my - yOffset
g.SetViewOnBottom("msg")
}
*/
// this somehow is letting me drag around the stdout window
func mouseMoveOld(g *gocui.Gui) bool {
me.ecount += 1
maxX, maxY := g.Size()
mx, my := g.MousePosition()
log.Log(NOW, "handleEvent() START", maxX, maxY, mx, my, msgMouseDown)
// log.Log(NOW, "handleEvent() START", maxX, maxY, mx, my, msgMouseDown)
if _, err := g.View("msg"); msgMouseDown && err == nil {
moveMsg(g)
return true
@ -75,6 +82,6 @@ func mouseMoveOld(g *gocui.Gui) bool {
} else {
log.Log(NOW, "output widget already exists", maxX, maxY, mx, my)
}
log.Log(NOW, "handleEvent() END ", maxX, maxY, mx, my, msgMouseDown)
// log.Log(NOW, "handleEvent() END ", maxX, maxY, mx, my, msgMouseDown)
return false
}

View File

@ -16,17 +16,6 @@ import (
var outputW int = 180
var outputH int = 40
func moveMsg(g *gocui.Gui) {
mx, my := g.MousePosition()
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
movingMsg = true
}
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
me.startOutputW = mx - xOffset
me.startOutputH = my - yOffset
g.SetViewOnBottom("msg")
}
func showMsg(g *gocui.Gui, v *gocui.View) error {
var l string
var err error

View File

@ -70,12 +70,13 @@ type config struct {
ecount int // counts how many mouse and keyboard events have occurred
supermouse bool // prints out every widget found while you move the mouse around
depth int // used for listWidgets() debugging
movingMsg bool // means the user id dragging something around with the mouse
}
// deprecate these
var (
initialMouseX, initialMouseY, xOffset, yOffset int
globalMouseDown, msgMouseDown, movingMsg bool
globalMouseDown, msgMouseDown bool
)
// this is the gocui way