tiggers gocui on startup
This commit is contained in:
parent
ed024aac70
commit
665d2289e2
34
find.go
34
find.go
|
@ -45,25 +45,25 @@ func (r rectType) inRect(w int, h int) bool {
|
||||||
func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
||||||
var widgets []*guiWidget
|
var widgets []*guiWidget
|
||||||
|
|
||||||
if !tk.Visible() {
|
// if !tk.Visible() {
|
||||||
// ignore widgets that are not visible
|
// ignore widgets that are not visible
|
||||||
} else {
|
// } else {
|
||||||
|
|
||||||
// check the location to see if this is under (W,H)
|
// check the location to see if this is under (W,H)
|
||||||
// if it is, return this widget
|
// if it is, return this widget
|
||||||
// if (tk.gocuiSize.w0 <= w) && (w <= tk.gocuiSize.w1) &&
|
// if (tk.gocuiSize.w0 <= w) && (w <= tk.gocuiSize.w1) &&
|
||||||
// (tk.gocuiSize.h0 <= h) && (h <= tk.gocuiSize.h1) {
|
// (tk.gocuiSize.h0 <= h) && (h <= tk.gocuiSize.h1) {
|
||||||
if tk.gocuiSize.inRect(w, h) {
|
// if tk.gocuiSize.inRect(w, h) {
|
||||||
widgets = append(widgets, tk)
|
// widgets = append(widgets, tk)
|
||||||
} else {
|
// } else {
|
||||||
// if (tk.full.w0 <= w) && (w <= tk.full.w1) &&
|
// if (tk.full.w0 <= w) && (w <= tk.full.w1) &&
|
||||||
// (tk.full.h0 <= h) && (h <= tk.full.h1) {
|
// (tk.full.h0 <= h) && (h <= tk.full.h1) {
|
||||||
if tk.full.inRect(w, h) {
|
if tk.full.inRect(w, h) {
|
||||||
widgets = append(widgets, tk)
|
widgets = append(widgets, tk)
|
||||||
}
|
|
||||||
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// tk.verifyRect()
|
// tk.verifyRect()
|
||||||
|
|
||||||
// search through the children widgets in the binary tree
|
// search through the children widgets in the binary tree
|
||||||
|
|
47
init.go
47
init.go
|
@ -56,6 +56,7 @@ func init() {
|
||||||
|
|
||||||
me.myTree = tree.New()
|
me.myTree = tree.New()
|
||||||
me.myTree.PluginName = "gocui"
|
me.myTree.PluginName = "gocui"
|
||||||
|
go refreshGocui()
|
||||||
|
|
||||||
if val, err := me.myTree.ConfigFind("dark"); err == nil {
|
if val, err := me.myTree.ConfigFind("dark"); err == nil {
|
||||||
if val == "true" {
|
if val == "true" {
|
||||||
|
@ -207,6 +208,47 @@ func gocuiMain() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this hack is to wait for the application to send something
|
||||||
|
// before trying to do anything. todo: rethink this someday
|
||||||
|
func waitOK() {
|
||||||
|
for {
|
||||||
|
if me.ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastRefresh time.Time
|
||||||
|
|
||||||
|
func testRefresh(*gocui.Gui) error {
|
||||||
|
log.Info("in testRefresh")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshGocui() {
|
||||||
|
lastRefresh = time.Now()
|
||||||
|
for {
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
// log.Info("refresh checking ok")
|
||||||
|
if !me.ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if time.Since(lastRefresh) > 1*time.Second {
|
||||||
|
if me.mouse.mouseUp {
|
||||||
|
log.Info("refresh now on mouseUp")
|
||||||
|
me.baseGui.Update(testRefresh)
|
||||||
|
} else {
|
||||||
|
log.Info("refresh skip on mouseDown")
|
||||||
|
// me.baseGui.Update()
|
||||||
|
}
|
||||||
|
lastRefresh = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the widget start width & height
|
||||||
|
|
||||||
func newWindowTrigger() {
|
func newWindowTrigger() {
|
||||||
log.Log(NOW, "newWindowTriggerl() START")
|
log.Log(NOW, "newWindowTriggerl() START")
|
||||||
for {
|
for {
|
||||||
|
@ -222,7 +264,10 @@ func newWindowTrigger() {
|
||||||
relocateStdoutOffscreen()
|
relocateStdoutOffscreen()
|
||||||
}
|
}
|
||||||
tk.makeWindowActive()
|
tk.makeWindowActive()
|
||||||
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
|
// place the new window relative to the mouse
|
||||||
|
tk.redrawWindow(me.mouse.downW+8, me.mouse.downH-2)
|
||||||
|
// tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
|
||||||
|
|
||||||
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
|
||||||
// log.Log(NOW, "newWindowTrigger() after sleep")
|
// log.Log(NOW, "newWindowTrigger() after sleep")
|
||||||
}
|
}
|
||||||
|
|
12
treeAdd.go
12
treeAdd.go
|
@ -4,8 +4,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
log "go.wit.com/log"
|
log "go.wit.com/log"
|
||||||
"go.wit.com/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
|
@ -30,16 +28,6 @@ func setFake(n *tree.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitOK() {
|
|
||||||
for {
|
|
||||||
if me.ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
time.Sleep(10 * time.Millisecond)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the widget start width & height
|
|
||||||
// func (n *node) addWidget(n *tree.Node) {
|
// func (n *node) addWidget(n *tree.Node) {
|
||||||
func addWidget(n *tree.Node) {
|
func addWidget(n *tree.Node) {
|
||||||
if !me.ok {
|
if !me.ok {
|
||||||
|
|
Loading…
Reference in New Issue