mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
add fyne
This commit is contained in:
parent
fbfb454691
commit
81e525ed70
@ -120,8 +120,8 @@ var Index = &ice.Context{Name: "gdb", Help: "事件模块",
|
||||
kit.MDB_META, kit.Dict("pid", "var/run/ice.pid"),
|
||||
kit.MDB_LIST, kit.List(),
|
||||
kit.MDB_HASH, kit.Dict(
|
||||
"2", []interface{}{"exit", "0"},
|
||||
"3", []interface{}{"exit", "1"},
|
||||
"2", []interface{}{"exit", "1"},
|
||||
"3", []interface{}{"exit", "0"},
|
||||
"15", []interface{}{"exit", "1"},
|
||||
// "20", []interface{}{"void"},
|
||||
"30", []interface{}{"exit"},
|
||||
|
1
go.mod
1
go.mod
@ -3,6 +3,7 @@ module github.com/shylinux/icebergs
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
fyne.io/fyne v1.3.0
|
||||
github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725
|
||||
github.com/gomodule/redigo v2.0.0+incompatible // indirect
|
||||
github.com/gorilla/websocket v1.4.1
|
||||
|
72
go.sum
72
go.sum
@ -1,3 +1,20 @@
|
||||
fyne.io/fyne v1.3.0 h1:FLlgX/JkD3Chal7tEhRL7fOONVAjQJM/yrVNA+cK/dc=
|
||||
fyne.io/fyne v1.3.0/go.mod h1:AcBUeR8hetITnnfaLvuVqioWM/lT18WPeMVAobhMbg8=
|
||||
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
|
||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fyne-io/mobile v0.0.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff h1:W71vTCKoxtdXgnm1ECDFkfQnpdqAO00zzGXLA5yaEX8=
|
||||
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff/go.mod h1:wfqRWLHRBsRgkp5dmbG56SA0DmVtwrF5N3oPdI8t+Aw=
|
||||
github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725 h1:X6sZdr+t2E2jwajTy/FfXbmAKPFTYxEq9hiFgzMiuPQ=
|
||||
github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
|
||||
@ -7,10 +24,21 @@ github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
||||
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc=
|
||||
github.com/josephspurrier/goversioninfo v0.0.0-20200309025242-14b0ab84c6ca/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lucor/goinfo v0.0.0-20200401173949-526b5363a13a/go.mod h1:ORP3/rB5IsulLEBwQZCJyyV6niqmI7P4EWSmkug+1Ng=
|
||||
github.com/maruel/rs v0.0.0-20150922171536-2c81c4312fe4 h1:u9jwvcKbQpghIXgNl/EOL8hzhAFXh4ePrEP493W3tNA=
|
||||
github.com/maruel/rs v0.0.0-20150922171536-2c81c4312fe4/go.mod h1:kcRFpEzolcEklV6rD7W95mG49/sbdX/PlFmd7ni3RvA=
|
||||
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 h1:Yp0zFEufLz0H7jzffb4UPXijavlyqlYeOg7dcyVUNnQ=
|
||||
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/shylinux/toolkits v0.1.4 h1:GW7rRFOSww56x+rUfH0/tho3+FaErxz5+5RwlA8oWnk=
|
||||
github.com/shylinux/toolkits v0.1.4/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
|
||||
github.com/shylinux/toolkits v0.1.5 h1:rGLsEGuPzuib/sOZXCbF8D+JGjqeQJ+a1rX/G6/sc8w=
|
||||
@ -19,6 +47,50 @@ github.com/shylinux/toolkits v0.1.6 h1:x+Bs+oijuS11TWGAsdCEgwDbCS35uJvnP4jYDETJq
|
||||
github.com/shylinux/toolkits v0.1.6/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
|
||||
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs=
|
||||
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564 h1:HunZiaEKNGVdhTRQOVpMmj5MQnGnv+e8uZNu3xFLgyM=
|
||||
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4=
|
||||
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 h1:m59mIOBO4kfcNCEzJNy71UkeF4XIx2EVmL9KLwDQdmM=
|
||||
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 h1:BWVtt2VBY+lmVDu9MGKqLGKl04B+iRHcrW1Ptyi/8tg=
|
||||
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2/go.mod h1:lPnW9HVS0vJdeYyQtOvIvlXgZPNhUAhwz+z5r8AJk0Y=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775 h1:TC0v2RSO1u2kn1ZugjrFXkRZAEaqMN/RW+OTZkBzmLE=
|
||||
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190808195139-e713427fea3f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200328031815-3db5fc6bac03/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
4
init.go
4
init.go
@ -147,6 +147,7 @@ var Pulse = &Message{
|
||||
}
|
||||
|
||||
var Log func(*Message, string, string)
|
||||
var Loop func()
|
||||
|
||||
func Run(arg ...string) string {
|
||||
if len(arg) == 0 {
|
||||
@ -165,6 +166,9 @@ func Run(arg ...string) string {
|
||||
Pulse.Option("begin_time", Pulse.Time())
|
||||
|
||||
if frame.Begin(Pulse.Spawns(), arg...).Start(Pulse, arg...) {
|
||||
if Loop != nil {
|
||||
Loop()
|
||||
}
|
||||
frame.Close(Pulse.Spawns(), arg...)
|
||||
}
|
||||
|
||||
|
150
misc/fyne/fyne.go
Normal file
150
misc/fyne/fyne.go
Normal file
@ -0,0 +1,150 @@
|
||||
package fyne
|
||||
|
||||
import (
|
||||
"github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/core/chat"
|
||||
"github.com/shylinux/toolkits"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/app"
|
||||
"fyne.io/fyne/widget"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var Index = &ice.Context{Name: "fyne", Help: "fyne",
|
||||
Configs: map[string]*ice.Config{},
|
||||
Commands: map[string]*ice.Command{
|
||||
"field": {Name: "field", Help: "field", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, "space")
|
||||
}
|
||||
newField(m, kit.Select("contexts", m.Option("title"))).update(m.Cmd(arg))
|
||||
}},
|
||||
"hide": {Name: "hide", Help: "hide", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
field := m.Optionv("field").(*Field)
|
||||
field.w.Hide()
|
||||
}},
|
||||
"close": {Name: "close", Help: "close", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
field := m.Optionv("field").(*Field)
|
||||
field.w.Close()
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
type Label struct {
|
||||
*widget.Label
|
||||
width int
|
||||
height int
|
||||
}
|
||||
|
||||
func newLabel(str string, width int, height int) *Label {
|
||||
return &Label{width: width, height: height, Label: widget.NewLabel(str)}
|
||||
}
|
||||
func (label *Label) MinSize() fyne.Size {
|
||||
return fyne.NewSize(label.width*10, label.height*20)
|
||||
}
|
||||
|
||||
type Board struct {
|
||||
width int
|
||||
height int
|
||||
*widget.ScrollContainer
|
||||
}
|
||||
|
||||
func newBoard(list fyne.CanvasObject, width int, height int) *Board {
|
||||
return &Board{width: width, height: height, ScrollContainer: widget.NewScrollContainer(list)}
|
||||
}
|
||||
func (board *Board) MinSize() fyne.Size {
|
||||
return fyne.NewSize(board.width*10, board.height*20)
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
widget.Entry
|
||||
w fyne.Window
|
||||
m *ice.Message
|
||||
}
|
||||
|
||||
func newField(m *ice.Message, title string) *Field {
|
||||
w := win.NewWindow(title)
|
||||
w.CenterOnScreen()
|
||||
w.SetMainMenu(fyne.NewMainMenu(
|
||||
fyne.NewMenu("action",
|
||||
fyne.NewMenuItem("contexts", func() { win.OpenURL(kit.ParseURL("http://localhost:9020")) }),
|
||||
fyne.NewMenuItem("fnye", func() { win.OpenURL(kit.ParseURL("https://developer.fyne.io")) }),
|
||||
fyne.NewMenuItem("quit", func() { os.Exit(0) }),
|
||||
),
|
||||
))
|
||||
return &Field{w: w}
|
||||
}
|
||||
func (field *Field) update(m *ice.Message) {
|
||||
field.ExtendBaseWidget(field)
|
||||
field.m = m
|
||||
|
||||
cols := 0
|
||||
rows := 0
|
||||
list := []fyne.CanvasObject{}
|
||||
width := map[int]int{}
|
||||
m.Table(func(index int, value map[string]string, head []string) {
|
||||
if index == 0 {
|
||||
for i, k := range head {
|
||||
if len(k) > width[i] {
|
||||
width[i] = len(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
for i, k := range head {
|
||||
if len(value[k]) > width[i] {
|
||||
width[i] = len(value[k])
|
||||
}
|
||||
}
|
||||
})
|
||||
m.Table(func(index int, value map[string]string, head []string) {
|
||||
rows = index + 1
|
||||
if cols = len(head); index == 0 {
|
||||
line := []fyne.CanvasObject{}
|
||||
for i, k := range head {
|
||||
item := newLabel(k, width[i], 1)
|
||||
line = append(line, item)
|
||||
}
|
||||
list = append(list, widget.NewHBox(line...))
|
||||
}
|
||||
|
||||
line := []fyne.CanvasObject{}
|
||||
for i, k := range head {
|
||||
v := value[k]
|
||||
if len(v) > 40 {
|
||||
v = v[:40] + "..."
|
||||
width[i] = 40
|
||||
}
|
||||
item := newLabel(v, width[i], 1)
|
||||
line = append(line, item)
|
||||
}
|
||||
list = append(list, widget.NewHBox(line...))
|
||||
})
|
||||
table := widget.NewVBox(list...)
|
||||
count := strings.Count(m.Result(), "\n")
|
||||
// board := newBoard(newLabel(m.Result(), 20, count), 20, lines)
|
||||
board := widget.NewScrollContainer(newLabel(m.Result(), 20, count))
|
||||
|
||||
w := field.w
|
||||
w.Resize(fyne.NewSize(kit.Int(kit.Select("600", m.Option("width"))), kit.Int(kit.Select("200", m.Option("height")))))
|
||||
w.SetContent(widget.NewVBox(field, table, board, widget.NewHBox(
|
||||
newLabel(m.Time(), 20, 1),
|
||||
)))
|
||||
w.Show()
|
||||
}
|
||||
func (field *Field) KeyDown(key *fyne.KeyEvent) {
|
||||
switch m := field.m; key.Name {
|
||||
case fyne.KeyReturn:
|
||||
m.Optionv("field", field)
|
||||
field.update(m.Cmd(kit.Split(field.Text)))
|
||||
field.Entry.SetText("")
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
var win = app.New()
|
||||
|
||||
func init() { ice.Loop = win.Run }
|
||||
|
||||
func init() { chat.Index.Register(Index, nil) }
|
Loading…
x
Reference in New Issue
Block a user