diff --git a/debug.go b/debug.go index 0a662dd..47765a0 100644 --- a/debug.go +++ b/debug.go @@ -89,20 +89,6 @@ func (tk *guiWidget) dumpWidget(s string) { func printWidgetTree(g *gocui.Gui, v *gocui.View) error { 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 } diff --git a/eventMouse.go b/eventMouse.go index 35372e8..6d0c684 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -29,15 +29,6 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error { dropdownUnclicked(w, h) - /* - if msgMouseDown { - log.Info("setting mousedown to false") - msgMouseDown = false - } else if globalMouseDown { - globalMouseDown = false - g.DeleteView("globalDown") - } - */ return nil } @@ -68,6 +59,9 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { if tk.node.WidgetType == widget.Window { tk.dragW = mx - tk.gocuiSize.w0 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) tk.doWidgetClick(mx-tk.dragW, my-tk.dragH) return nil @@ -75,7 +69,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { if tk.node.WidgetType == widget.Label { log.Info("IGNORE LABLE") found = false - log.Info("setting mousedown to true") + log.Info("setting mousedown to true for label") // msgMouseDown = true return nil } @@ -140,7 +134,18 @@ func msgDown(g *gocui.Gui, v *gocui.View) error { me.stdout.mouseOffsetW = w - vx 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 return nil } diff --git a/eventMouseMove.go b/eventMouseMove.go index 01e49f3..5fe98d3 100644 --- a/eventMouseMove.go +++ b/eventMouseMove.go @@ -108,32 +108,21 @@ func (tk *guiWidget) moveNew() { tk.dumpWidget(s) return } else { - me.stdout.lastW = w - me.stdout.mouseOffsetW - me.stdout.lastH = h - me.stdout.mouseOffsetH - tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) - /* - // 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") - - 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 - */ + if me.stdout.resize { + newW := w - me.stdout.lastW + newH := h - me.stdout.lastH + me.stdout.w = newW + me.stdout.h = newH + log.Info("Resize true", w, h, newW, newH) + // me.stdout.lastW = w - me.stdout.mouseOffsetW + // me.stdout.lastH = h - me.stdout.mouseOffsetH + tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) + } else { + // log.Info("Resize false", w, h) + me.stdout.lastW = w - me.stdout.mouseOffsetW + me.stdout.lastH = h - me.stdout.mouseOffsetH + tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) + } } // always place the help menu on top setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn diff --git a/help.go b/help.go index df18594..ac69f37 100644 --- a/help.go +++ b/help.go @@ -23,22 +23,14 @@ import ( // 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", "O: toggle (O)output (os.STDOUT)", "S: super mouse", "M: list all widgets positions", - "L: list all widgets in tree form", - "d: toggle debugging", - "s/h: show/hide all widgets", - + "L: list all widgets in tree", "q: quit()", - "p: panic()", - "l: log to /tmp/witgui.log", - "Ctrl-D: Toggle Debugging", - "Ctrl-V: Toggle Verbose Debugging", - "Ctrl-C: Exit", "", } diff --git a/stdoutShow.go b/stdoutShow.go index 752f0ed..6d36861 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -99,6 +99,8 @@ func relocateStdoutOffscreen() { if me.stdout.tk == nil { return } + log.CaptureMode(me.stdout.tk) + log.Log(ERROR, "setting log.CaptureMode(tk.v) in relocateStdoutOffscreen()") newW := 10 newH := 0 - me.stdout.h - 4 me.stdout.tk.relocateStdout(newW, newH) diff --git a/structs.go b/structs.go index 9deb246..5539d52 100644 --- a/structs.go +++ b/structs.go @@ -84,6 +84,7 @@ type stdout struct { mouseOffsetW int // the current 'w' offset mouseOffsetH int // the current 'h' offset init bool // moves the window offscreen on startup + resize bool // user is resizing the window } // this is the gocui way