leave this code as a reminder for later
This commit is contained in:
parent
b8b8a409ea
commit
eba5ea8cc0
16
init.go
16
init.go
|
@ -263,11 +263,21 @@ func refreshGocui() {
|
|||
me.clock.tk.v.WriteString(me.clock.tk.labelN)
|
||||
}
|
||||
}
|
||||
lastRefresh = time.Now()
|
||||
} else {
|
||||
// log.Info("refresh skip on mouseDown")
|
||||
// me.baseGui.Update()
|
||||
me.baseGui.Update(testRefresh)
|
||||
if time.Since(lastRefresh) > 3*time.Second {
|
||||
if me.clock.tk != nil && !me.showHelp {
|
||||
// also double check the gocui view exists
|
||||
if me.clock.tk.v != nil {
|
||||
me.clock.tk.v.Clear()
|
||||
me.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.clock.tk.v.WriteString(me.clock.tk.labelN)
|
||||
}
|
||||
}
|
||||
lastRefresh = time.Now()
|
||||
}
|
||||
}
|
||||
lastRefresh = time.Now()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
|||
return len(p), nil
|
||||
}
|
||||
if tk.v == nil {
|
||||
// redo this old code
|
||||
v, _ := me.baseGui.View("msg")
|
||||
if v != nil {
|
||||
// fmt.Fprintln(outf, "found msg")
|
||||
|
@ -171,35 +172,6 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
|||
return len(p), nil
|
||||
}
|
||||
tk.refreshStdout()
|
||||
/*
|
||||
// optionally write the output to /tmp
|
||||
s := fmt.Sprint(string(p))
|
||||
s = strings.TrimSuffix(s, "\n")
|
||||
fmt.Fprintln(outf, s)
|
||||
v, _ := me.baseGui.View("msg")
|
||||
if v != nil {
|
||||
// fmt.Fprintln(outf, "found msg")
|
||||
tk.v = v
|
||||
}
|
||||
} else {
|
||||
// display the output in the gocui window
|
||||
var cur []string
|
||||
// chop off the last lines in the buffer
|
||||
chop := len(me.stdout.outputS) - (me.stdout.h - 1)
|
||||
if chop < 0 {
|
||||
chop = 0
|
||||
}
|
||||
if len(me.stdout.outputS) > chop {
|
||||
cur = append(cur, me.stdout.outputS[chop:]...)
|
||||
} else {
|
||||
cur = append(cur, me.stdout.outputS...)
|
||||
}
|
||||
slices.Reverse(cur)
|
||||
tk.v.Clear()
|
||||
fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
|
||||
}
|
||||
*/
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue