forked from iegomez/lds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.go
54 lines (45 loc) · 1.14 KB
/
output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"os"
"time"
l "gioui.org/layout"
"gioui.org/unit"
"gioui.org/widget/material"
xmat "github.com/scartill/giox/material"
log "github.com/sirupsen/logrus"
)
func writeHistory() {
f, err := os.Create(fmt.Sprintf("lds-%d.log", time.Now().UnixNano()))
if err != nil {
log.Errorf("export error: %s", err)
return
}
defer f.Close()
n, err := f.Write([]byte(ow.Text()))
f.Sync()
log.Infof("wrote %d bytes to %s", n, f.Name())
}
func setLevel(level log.Level) {
log.SetLevel(level)
}
var logList l.List
func createOutputForm() {
logList = l.List{Axis: l.Vertical, ScrollToEnd: true}
}
func outputForm(th *material.Theme) l.FlexChild {
widgets := []l.FlexChild{
xmat.RigidSection(th, "Output"),
l.Rigid(func(gtx l.Context) l.Dimensions {
return logList.Layout(gtx, len(ow.Lines), func(gtx l.Context, i int) l.Dimensions {
return material.Body1(th, ow.Lines[i]).Layout(gtx)
})
}),
}
inset := l.Inset{Left: unit.Dp(30)}
return l.Rigid(func(gtx l.Context) l.Dimensions {
return inset.Layout(gtx, func(gtx l.Context) l.Dimensions {
return l.Flex{Axis: l.Vertical}.Layout(gtx, widgets...)
})
})
}