diff --git a/eventMouse.go b/eventMouse.go index 20af0de..2385ee9 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -23,15 +23,20 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { } */ + log.Info("mouseUp() setting me.globalMouseDown = false") + me.globalMouseDown = false + dropdownUnclicked(w, h) - if msgMouseDown { - log.Info("setting mousedown to false") - msgMouseDown = false - } else if globalMouseDown { - globalMouseDown = false - g.DeleteView("globalDown") - } + /* + if msgMouseDown { + log.Info("setting mousedown to false") + msgMouseDown = false + } else if globalMouseDown { + globalMouseDown = false + g.DeleteView("globalDown") + } + */ return nil } @@ -40,6 +45,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { // the right response for the toolkit user's app func mouseDown(g *gocui.Gui, v *gocui.View) error { mx, my := g.MousePosition() + me.globalMouseDown = true var found bool = false for _, tk := range findByXY(mx, my) { @@ -85,7 +91,6 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { return msgDown(g, v) } } - globalMouseDown = true maxX, _ := g.Size() diff --git a/eventMouseMove.go b/eventMouseMove.go index 0824faf..97c574a 100644 --- a/eventMouseMove.go +++ b/eventMouseMove.go @@ -33,7 +33,7 @@ func mouseMove(g *gocui.Gui) { } } - if msgMouseDown { + if me.globalMouseDown { // log.Info("msgMouseDown == true") // plugin will segfault if you don't keep this inside a check for msgMouseDown // don't move this code out of here @@ -75,13 +75,16 @@ func (tk *guiWidget) moveNew(g *gocui.Gui) { if tk.node.WidgetType == widget.Label { s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName) tk.dumpWidget(s) + outputW, outputH := tk.Size() g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0) me.startOutputW = w - xOffset me.startOutputH = h - yOffset - g.SetViewOnBottom(tk.cuiName) + // g.SetViewOnBottom(tk.cuiName) return } tk.dumpWidget("moveNew() on " + tk.cuiName) + outputW := 140 + outputH := 40 g.SetView("msg", w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0) me.startOutputW = w - xOffset me.startOutputH = h - yOffset diff --git a/place.go b/place.go index e0c3097..de20467 100644 --- a/place.go +++ b/place.go @@ -192,6 +192,8 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) { func (w *guiWidget) realGocuiSize() *rectType { var f func(tk *guiWidget, r *rectType) newR := new(rectType) + + outputW, outputH := w.Size() // initialize the values to opposite newR.w0 = outputW newR.h0 = outputH diff --git a/stdoutShow.go b/stdoutShow.go index 3ded809..4b6d4d0 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -13,9 +13,6 @@ import ( "go.wit.com/widget" ) -var outputW int = 180 -var outputH int = 40 - func showMsg(g *gocui.Gui, v *gocui.View) error { var l string var err error @@ -39,6 +36,9 @@ func showMsg(g *gocui.Gui, v *gocui.View) error { func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { maxX, maxY := g.Size() + var outputW int = 180 + var outputH int = 40 + if me.treeRoot == nil { // keep skipping this until the binary tree is initialized return nil diff --git a/structs.go b/structs.go index 46c61f6..939b7e7 100644 --- a/structs.go +++ b/structs.go @@ -40,42 +40,43 @@ type config struct { startOutputH int // ? helpLabel *gocui.View // ? // dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a - dropdownW *guiWidget // grab the dropdown choices from this widget - FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side - FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side - PadW int `default:"1" dense:"0"` // pad spacing - PadH int `default:"1" dense:"0"` // pad spacing - WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings - WindowH int `default:"-1"` // how far down to start Window or Tab headings - TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings - TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings - WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets - TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets - GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group - BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box - GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid - RawW int `default:"1"` // the raw beginning of each window (or tab) - RawH int `default:"5"` // the raw beginning of each window (or tab) - FakeW int `default:"20"` // offset for the hidden widgets - padded bool // add space between things like buttons - bookshelf bool // do you want things arranged in the box like a bookshelf or a stack? - canvas bool // if set to true, the windows are a raw canvas - menubar bool // for windows - stretchy bool // expand things like buttons to the maximum size - margin bool // add space around the frames of windows - 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 - dtoggle bool // is a dropdown or combobox currently active? - showHelp bool // toggle boolean for the help menu (deprecate?) - 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 + dropdownW *guiWidget // grab the dropdown choices from this widget + FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side + FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side + PadW int `default:"1" dense:"0"` // pad spacing + PadH int `default:"1" dense:"0"` // pad spacing + WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings + WindowH int `default:"-1"` // how far down to start Window or Tab headings + TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings + TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings + WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets + TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets + GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group + BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box + GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid + RawW int `default:"1"` // the raw beginning of each window (or tab) + RawH int `default:"5"` // the raw beginning of each window (or tab) + FakeW int `default:"20"` // offset for the hidden widgets + padded bool // add space between things like buttons + bookshelf bool // do you want things arranged in the box like a bookshelf or a stack? + canvas bool // if set to true, the windows are a raw canvas + menubar bool // for windows + stretchy bool // expand things like buttons to the maximum size + margin bool // add space around the frames of windows + 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 + dtoggle bool // is a dropdown or combobox currently active? + showHelp bool // toggle boolean for the help menu (deprecate?) + 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 + globalMouseDown bool // yep, mouse is pressed } // deprecate these var ( initialMouseX, initialMouseY, xOffset, yOffset int - globalMouseDown, msgMouseDown bool + msgMouseDown bool ) // this is the gocui way @@ -131,6 +132,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { me.writeMutex.Lock() defer me.writeMutex.Unlock() + // _, outputH := w.Size() + outputH := 33 // special output length for "msg" window until I figure things out + tk := me.logStdout if tk.v == nil { // optionally write the output to /tmp