stdout window remembers where it was
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
145bad6c9a
commit
8f9e47c117
78
click.go
78
click.go
|
@ -20,46 +20,42 @@ func (w *guiWidget) doWidgetClick() {
|
|||
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||
case widget.Window:
|
||||
log.Log(NOW, "doWidgetClick() START on window", w.String())
|
||||
if me.currentWindow == w.node {
|
||||
// if the user clicked on the current window, do nothing
|
||||
/* Ignore this for now and redraw the window anyway
|
||||
if me.currentWindow == w {
|
||||
if !w.active {
|
||||
return
|
||||
}
|
||||
}
|
||||
if me.currentWindow != nil {
|
||||
var curw *guiWidget
|
||||
curw = me.currentWindow.TK.(*guiWidget)
|
||||
// curw.unsetCurrent()
|
||||
curw.setColor(&colorWindow)
|
||||
curw.hideWidgets()
|
||||
}
|
||||
me.currentWindow = w.node
|
||||
*/
|
||||
|
||||
// if there is a current window, hide it
|
||||
if me.currentWindow != nil {
|
||||
me.currentWindow.setColor(&colorWindow)
|
||||
me.currentWindow.hideWidgets()
|
||||
me.currentWindow.isCurrent = false
|
||||
}
|
||||
|
||||
// now set this window as the current window
|
||||
me.currentWindow = w
|
||||
w.isCurrent = true
|
||||
|
||||
// draw the current window
|
||||
log.Log(NOW, "doWidgetClick() set currentWindow to", w.String())
|
||||
w.setColor(&colorActiveW)
|
||||
|
||||
w.DrawAt(3, 2)
|
||||
w.placeWidgets(3, 2) // compute the sizes & places for each widget
|
||||
w.active = false
|
||||
// w.dumpTree("before")
|
||||
w.placeWidgets(3, 2)
|
||||
w.showWidgets()
|
||||
|
||||
hideFake()
|
||||
showDebug = true
|
||||
|
||||
// w.dumpTree("after")
|
||||
/*
|
||||
hideFake()
|
||||
showDebug = true
|
||||
*/
|
||||
case widget.Group:
|
||||
// n.placeWidgets(p.tk.startH, newH)
|
||||
// w.dumpTree("click start")
|
||||
if w.active {
|
||||
w.active = false
|
||||
w.placeWidgets(w.startW, w.startH)
|
||||
w.showWidgets()
|
||||
/*
|
||||
for _, child := range w.children {
|
||||
log.Log(INFO, "START W,H", startW, startH)
|
||||
child.placeWidgets(startW, startH)
|
||||
child.showWidgets()
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
w.active = true
|
||||
for _, child := range w.children {
|
||||
|
@ -111,36 +107,6 @@ func (w *guiWidget) doWidgetClick() {
|
|||
}
|
||||
}
|
||||
|
||||
var toggle bool = true
|
||||
|
||||
func (w *guiWidget) toggleTree() {
|
||||
if toggle {
|
||||
w.drawTree(toggle)
|
||||
toggle = false
|
||||
} else {
|
||||
w.hideWidgets()
|
||||
toggle = true
|
||||
}
|
||||
}
|
||||
|
||||
// display the widgets in the binary tree
|
||||
func (w *guiWidget) drawTree(draw bool) {
|
||||
if w == nil {
|
||||
return
|
||||
}
|
||||
w.showWidgetPlacement("drawTree()")
|
||||
if draw {
|
||||
// w.textResize()
|
||||
w.showView()
|
||||
} else {
|
||||
w.deleteView()
|
||||
}
|
||||
|
||||
for _, child := range w.children {
|
||||
child.drawTree(draw)
|
||||
}
|
||||
}
|
||||
|
||||
func click(g *gocui.Gui, v *gocui.View) error {
|
||||
mouseW, mouseH := me.baseGui.MousePosition()
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
var toggle bool = true
|
||||
|
||||
func (w *guiWidget) DrawAt(offsetW, offsetH int) {
|
||||
w.setColor(&colorActiveW)
|
||||
w.placeWidgets(offsetW, offsetH) // compute the sizes & places for each widget
|
||||
w.active = false
|
||||
w.showWidgets()
|
||||
}
|
||||
|
||||
func (w *guiWidget) toggleTree() {
|
||||
if toggle {
|
||||
w.drawTree(toggle)
|
||||
toggle = false
|
||||
} else {
|
||||
w.hideWidgets()
|
||||
toggle = true
|
||||
}
|
||||
}
|
||||
|
||||
// display the widgets in the binary tree
|
||||
func (w *guiWidget) drawTree(draw bool) {
|
||||
if w == nil {
|
||||
return
|
||||
}
|
||||
w.showWidgetPlacement("drawTree()")
|
||||
if draw {
|
||||
// w.textResize()
|
||||
w.showView()
|
||||
} else {
|
||||
w.deleteView()
|
||||
}
|
||||
|
||||
for _, child := range w.children {
|
||||
child.drawTree(draw)
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ func moveMsg(g *gocui.Gui) {
|
|||
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")
|
||||
}
|
||||
|
||||
|
@ -61,8 +63,10 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
|||
|
||||
var tk *guiWidget
|
||||
tk = me.logStdout.TK.(*guiWidget)
|
||||
tk.gocuiSize.w0 = maxX - 32
|
||||
tk.gocuiSize.h0 = maxY / 2
|
||||
// tk.gocuiSize.w0 = maxX - 32
|
||||
// tk.gocuiSize.h0 = maxY / 2
|
||||
tk.gocuiSize.w0 = me.startOutputW
|
||||
tk.gocuiSize.h0 = me.startOutputH
|
||||
tk.gocuiSize.w1 = tk.gocuiSize.w0 + outputW
|
||||
tk.gocuiSize.h1 = tk.gocuiSize.h0 + outputH
|
||||
}
|
||||
|
@ -76,7 +80,15 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
|||
// help, err := g.SetView("help", maxX-32, 0, maxX-1, 13, 0)
|
||||
// v, err = g.SetView("msg", 3, 3, 30, 30, 0)
|
||||
|
||||
v, err = g.SetView("msg", maxX-32, maxY/2, maxX/2+outputW, maxY/2+outputH, 0)
|
||||
if me.startOutputW == 0 {
|
||||
me.startOutputW = maxX - 32
|
||||
}
|
||||
if me.startOutputW == 0 {
|
||||
me.startOutputH = maxY / 2
|
||||
}
|
||||
|
||||
// v, err = g.SetView("msg", maxX-32, maxY/2, maxX/2+outputW, maxY/2+outputH, 0)
|
||||
v, err = g.SetView("msg", me.startOutputW, me.startOutputH, maxX/2+outputW, maxY/2+outputH, 0)
|
||||
if errors.Is(err, gocui.ErrUnknownView) {
|
||||
log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ var showHelp bool = true
|
|||
var redoWidgets bool = true
|
||||
|
||||
// This is the window that is currently active
|
||||
var currentWindow *tree.Node
|
||||
// var currentWindow *tree.Node
|
||||
|
||||
type config struct {
|
||||
baseGui *gocui.Gui // the main gocui handle
|
||||
|
@ -40,8 +40,10 @@ type config struct {
|
|||
myTree *tree.TreeInfo
|
||||
|
||||
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
||||
currentWindow *tree.Node // 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
|
||||
startOutputW int
|
||||
startOutputH int
|
||||
helpLabel *gocui.View
|
||||
|
||||
// this is a floating widget that we show whenever the user clicks on a
|
||||
|
|
5
view.go
5
view.go
|
@ -62,11 +62,6 @@ func (w *guiWidget) showView() {
|
|||
log.Log(INFO, "showView() labelN =", w.labelN)
|
||||
|
||||
w.recreateView()
|
||||
/*
|
||||
w.textResize()
|
||||
w.v.Clear()
|
||||
fmt.Fprint(w.v, w.labelN)
|
||||
*/
|
||||
}
|
||||
|
||||
// create or recreate the gocui widget visible
|
||||
|
|
Loading…
Reference in New Issue