save the output window state
This commit is contained in:
parent
4523eda0fa
commit
1552eedc18
3
debug.go
3
debug.go
|
@ -86,6 +86,9 @@ func (tk *guiWidget) dumpWidget(s string) {
|
||||||
} else {
|
} else {
|
||||||
end = fmt.Sprintf("%-8s %-8s %s", tk.WidgetType(), tk.cuiName, tk.String())
|
end = fmt.Sprintf("%-8s %-8s %s", tk.WidgetType(), tk.cuiName, tk.String())
|
||||||
}
|
}
|
||||||
|
if tk.findParentTable() != nil {
|
||||||
|
end += " (table)"
|
||||||
|
}
|
||||||
log.Log(GOCUI, s1, s, end)
|
log.Log(GOCUI, s1, s, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,14 @@ import (
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func theStdout(g *gocui.Gui, v *gocui.View) error {
|
func theStdout(g *gocui.Gui, v *gocui.View) error {
|
||||||
// me.stdout.pager = 0
|
// me.stdout.pager = 0
|
||||||
infos := fmt.Sprintf("pager=%d len(%d) ", me.stdout.pager, len(me.stdout.outputS))
|
infos := fmt.Sprintf("pager=%d len(%d) ", me.stdout.pager, len(me.stdout.outputS))
|
||||||
infos += fmt.Sprintf("last(%d,%d)", me.stdout.lastW, me.stdout.lastH)
|
infos += fmt.Sprintf("last(%d,%d)", me.stdout.lastW, me.stdout.lastH)
|
||||||
|
me.stdout.changed = true
|
||||||
|
|
||||||
if me.stdout.outputOnTop {
|
if me.stdout.outputOnTop {
|
||||||
if me.stdout.outputOffscreen {
|
if me.stdout.outputOffscreen {
|
||||||
|
@ -22,18 +24,38 @@ func theStdout(g *gocui.Gui, v *gocui.View) error {
|
||||||
me.stdout.lastW = me.stdout.tk.gocuiSize.w0
|
me.stdout.lastW = me.stdout.tk.gocuiSize.w0
|
||||||
me.stdout.lastH = me.stdout.tk.gocuiSize.h0
|
me.stdout.lastH = me.stdout.tk.gocuiSize.h0
|
||||||
relocateStdoutOffscreen()
|
relocateStdoutOffscreen()
|
||||||
|
new1 := new(tree.ToolkitConfig)
|
||||||
|
new1.Plugin = "gocui"
|
||||||
|
new1.Name = "stdoutoffscreen"
|
||||||
|
new1.Value = "true"
|
||||||
|
me.myTree.ConfigSave(new1)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
me.stdout.outputOffscreen = true
|
me.stdout.outputOffscreen = true
|
||||||
log.Info("stdout moved on screen", infos)
|
log.Info("stdout moved on screen", infos)
|
||||||
|
new1 := new(tree.ToolkitConfig)
|
||||||
|
new1.Plugin = "gocui"
|
||||||
|
new1.Name = "stdoutoffscreen"
|
||||||
|
new1.Value = "false"
|
||||||
|
me.myTree.ConfigSave(new1)
|
||||||
}
|
}
|
||||||
// move the stdout window back onscreen
|
// move the stdout window back onscreen
|
||||||
me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH)
|
me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH)
|
||||||
me.stdout.outputOnTop = false
|
me.stdout.outputOnTop = false
|
||||||
setThingsOnTop()
|
setThingsOnTop()
|
||||||
|
new1 := new(tree.ToolkitConfig)
|
||||||
|
new1.Plugin = "gocui"
|
||||||
|
new1.Name = "stdoutlevel"
|
||||||
|
new1.Value = "bottom"
|
||||||
|
me.myTree.ConfigSave(new1)
|
||||||
} else {
|
} else {
|
||||||
me.stdout.outputOnTop = true
|
me.stdout.outputOnTop = true
|
||||||
setThingsOnTop()
|
setThingsOnTop()
|
||||||
|
new1 := new(tree.ToolkitConfig)
|
||||||
|
new1.Plugin = "gocui"
|
||||||
|
new1.Name = "stdoutlevel"
|
||||||
|
new1.Value = "top"
|
||||||
|
me.myTree.ConfigSave(new1)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ func mouseMove(g *gocui.Gui) {
|
||||||
// old hack. create the 'msg' view if it does not yet exist
|
// old hack. create the 'msg' view if it does not yet exist
|
||||||
// TODO: put this somewhere more correct
|
// TODO: put this somewhere more correct
|
||||||
if widgetView, _ := g.View("msg"); widgetView == nil {
|
if widgetView, _ := g.View("msg"); widgetView == nil {
|
||||||
|
me.stdout.changed = true
|
||||||
if createStdout(g) {
|
if createStdout(g) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -138,5 +139,6 @@ func (tk *guiWidget) moveNew() {
|
||||||
// log.Info("Resize false", w, h, newW, newH)
|
// log.Info("Resize false", w, h, newW, newH)
|
||||||
}
|
}
|
||||||
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
||||||
|
me.stdout.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
find.go
14
find.go
|
@ -186,6 +186,20 @@ func (tk *guiWidget) findParentWindow() *guiWidget {
|
||||||
return tk.parent.findParentWindow()
|
return tk.parent.findParentWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tk *guiWidget) findParentTable() *guiWidget {
|
||||||
|
if tk.isTable {
|
||||||
|
log.Info("findParentTAble()", tk.labelN, tk.cuiName, tk.node.WidgetId)
|
||||||
|
return tk
|
||||||
|
}
|
||||||
|
if tk.node.WidgetId == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if tk.parent == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return tk.parent.findParentWindow()
|
||||||
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
|
func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
|
||||||
if tk.cuiName == name {
|
if tk.cuiName == name {
|
||||||
return tk
|
return tk
|
||||||
|
|
28
init.go
28
init.go
|
@ -14,10 +14,13 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sent via -ldflags
|
// sent via -ldflags
|
||||||
|
@ -184,6 +187,19 @@ func initPlugin() {
|
||||||
me.stdout.lastW = 4
|
me.stdout.lastW = 4
|
||||||
me.stdout.lastH = 20
|
me.stdout.lastH = 20
|
||||||
|
|
||||||
|
if val, err := me.myTree.ConfigFind("stdoutsize"); err == nil {
|
||||||
|
parts := strings.Fields(val)
|
||||||
|
if len(parts) == 4 {
|
||||||
|
log.Info("initial stdout settings:", parts)
|
||||||
|
me.stdout.w, _ = strconv.Atoi(parts[0])
|
||||||
|
me.stdout.h, _ = strconv.Atoi(parts[1])
|
||||||
|
me.stdout.lastW, _ = strconv.Atoi(parts[2])
|
||||||
|
me.stdout.lastH, _ = strconv.Atoi(parts[3])
|
||||||
|
} else {
|
||||||
|
log.Info("initial stdout settings parse error:", parts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// just make up unique values for these
|
// just make up unique values for these
|
||||||
me.dropdown.wId = -77
|
me.dropdown.wId = -77
|
||||||
me.textbox.wId = -55
|
me.textbox.wId = -55
|
||||||
|
@ -376,6 +392,18 @@ func refreshGocui() {
|
||||||
me.newWindowTrigger <- me.treeRoot.TK.(*guiWidget)
|
me.newWindowTrigger <- me.treeRoot.TK.(*guiWidget)
|
||||||
me.refresh = false
|
me.refresh = false
|
||||||
}
|
}
|
||||||
|
if me.stdout.changed {
|
||||||
|
log.Log(NOW, "newWindowTrigger() TODO: gocui should save the stdout size & location here")
|
||||||
|
me.stdout.changed = false
|
||||||
|
me.stdout.tk.dumpWidget("save")
|
||||||
|
new1 := new(tree.ToolkitConfig)
|
||||||
|
new1.Plugin = "gocui"
|
||||||
|
new1.Name = "stdoutsize"
|
||||||
|
width := me.stdout.tk.gocuiSize.w1 - me.stdout.tk.gocuiSize.w0
|
||||||
|
height := me.stdout.tk.gocuiSize.h1 - me.stdout.tk.gocuiSize.h0
|
||||||
|
new1.Value = fmt.Sprintf("%d %d %d %d", width, height, me.stdout.tk.gocuiSize.w0, me.stdout.tk.gocuiSize.h0)
|
||||||
|
me.myTree.ConfigSave(new1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this code updates the clock
|
// this code updates the clock
|
||||||
|
|
|
@ -16,7 +16,7 @@ func newAdd(n *tree.Node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if n.TK != nil {
|
if n.TK != nil {
|
||||||
log.Warn("Tree Add() sent a widget we aleady seem to have")
|
log.Log(INFO, "Tree Add() sent a widget we aleady seem to have")
|
||||||
// this is done to protect the plugin being 'refreshed' with the
|
// this is done to protect the plugin being 'refreshed' with the
|
||||||
// widget binary tree. TODO: find a way to keep them in sync
|
// widget binary tree. TODO: find a way to keep them in sync
|
||||||
return
|
return
|
||||||
|
|
10
structs.go
10
structs.go
|
@ -116,11 +116,10 @@ type stdout struct {
|
||||||
disable bool // disable the stdout window. do not change os.Stdout & os.Stderr
|
disable bool // disable the stdout window. do not change os.Stdout & os.Stderr
|
||||||
lastW int // the last 'w' location (used to move from offscreen to onscreen)
|
lastW int // the last 'w' location (used to move from offscreen to onscreen)
|
||||||
lastH int // the last 'h' location (used to move from offscreen to onscreen)
|
lastH int // the last 'h' location (used to move from offscreen to onscreen)
|
||||||
// mouseOffsetW int // the current 'w' offset
|
init bool // moves the window offscreen on startup
|
||||||
// mouseOffsetH int // the current 'h' offset
|
outputS []string // the buffer of all the output
|
||||||
init bool // moves the window offscreen on startup
|
pager int // allows the user to page through the buffer
|
||||||
outputS []string // the buffer of all the output
|
changed bool // indicates the user has changed stdout. gocui should remember the state here
|
||||||
pager int // allows the user to page through the buffer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// settings for the dropdown window
|
// settings for the dropdown window
|
||||||
|
@ -241,6 +240,7 @@ type guiWidget struct {
|
||||||
color *colorT // what color to use
|
color *colorT // what color to use
|
||||||
colorLast colorT // the last color the widget had
|
colorLast colorT // the last color the widget had
|
||||||
defaultColor *colorT // the default colors // TODO: make a function for this instead
|
defaultColor *colorT // the default colors // TODO: make a function for this instead
|
||||||
|
isTable bool // is this a table?
|
||||||
}
|
}
|
||||||
|
|
||||||
// THIS IS GO COMPILER MAGIC
|
// THIS IS GO COMPILER MAGIC
|
||||||
|
|
15
table.go
15
table.go
|
@ -13,20 +13,6 @@ import (
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
|
||||||
func initGridPB(pb *guipb.Widget) *guiWidget {
|
|
||||||
var w *guiWidget
|
|
||||||
w = new(guiWidget)
|
|
||||||
|
|
||||||
w.pb = pb
|
|
||||||
w.parent = me.treeRoot.TK.(*guiWidget)
|
|
||||||
w.wtype = widget.Window
|
|
||||||
w.cuiName = fmt.Sprintf("%d %s", pb.Id, "TK")
|
|
||||||
w.labelN = pb.Name
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func initGridPB(pb *guipb.Widget) *guiWidget {
|
func initGridPB(pb *guipb.Widget) *guiWidget {
|
||||||
var w *guiWidget
|
var w *guiWidget
|
||||||
w = new(guiWidget)
|
w = new(guiWidget)
|
||||||
|
@ -35,6 +21,7 @@ func initGridPB(pb *guipb.Widget) *guiWidget {
|
||||||
w.wtype = widget.Grid
|
w.wtype = widget.Grid
|
||||||
w.cuiName = fmt.Sprintf("%d %s", pb.Id, "TK")
|
w.cuiName = fmt.Sprintf("%d %s", pb.Id, "TK")
|
||||||
w.labelN = pb.Name
|
w.labelN = pb.Name
|
||||||
|
w.isTable = true
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue