Skip to content

Commit

Permalink
buttons example, update to latest rye / fyne
Browse files Browse the repository at this point in the history
  • Loading branch information
refaktor committed Feb 26, 2025
1 parent 7ed1bb2 commit 6f60b9d
Show file tree
Hide file tree
Showing 7 changed files with 201,308 additions and 29 deletions.
33 changes: 33 additions & 0 deletions current/fyne_io_fyne_v2/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Add your custom builtins to this file.

package fyne_io_fyne_v2

import (
"strings"

"github.com/refaktor/rye/env"
)

var builtinsCustom = map[string]*env.Builtin{
"nil": {
Doc: "nil value for go types",
Fn: func(ps *env.ProgramState, arg0, arg1, arg2, arg3, arg4 env.Object) env.Object {
return *env.NewInteger(0)
},
},
"kind": {
Doc: "underlying kind of a go native",
Fn: func(ps *env.ProgramState, arg0, arg1, arg2, arg3, arg4 env.Object) env.Object {
nat, ok := arg0.(env.Native)
if !ok {
ps.FailureFlag = true
return env.NewError("kind: arg0: expected native")
}
s := ps.Idx.GetWord(nat.Kind.Index)
s = s[3 : len(s)-1] // remove surrounding "Go()"
s = strings.TrimPrefix(s, "*") // remove potential pointer "*"
return *env.NewString(s)
},
},
// Add your custom builtins here:
}
200,641 changes: 200,641 additions & 0 deletions current/fyne_io_fyne_v2/generated.go

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions examples/buttons.rye
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

rye .needs { fyne }

myctx: context { do load %buttons_my.rye }

current-ctx: ?current

do\par fyne {

win: app .window "Buttons app"
gw: grid-wrap size 120.0 36.0 { }
spl: h-split gw lbl: label "" ,
spl .offset! 0.6

for lc\data\ myctx { ::w
extends myctx {
fnc: ?w
gw .add button to-string w
fn\par { } current-ctx
{ set-text lbl capture-stdout [ fnc ] }
}
}

with win {
.resize size 450.0 350.0 ,
.set-content spl ,
.show-and-run
}
}
















; if w .val .type? = 'function {
; fnc: ?w
; gw .add button to-string w
; fn\par { } current-ctx { set-text lbl capture-stdout [ fnc ] }
; }
; for lc\data\ myctx { ::w
; gw .add button to-string w fn\par { } myctx [ 'set-text 'lbl 'capture-stdout [ w ] ]
; }
; for lc\data\ myctx { ::w
; gw .add button to-string w closure { } { set-text lbl capture-stdout { do { probe w } } }
; }

; for lc\vals\ myctx { ::f
; gw .add button to-string w does combine { set-text lbl capture-stdout apply ?f { } } ; where f are closures
; }



; TODO:
; add apply built-in
; have lc\words lc\vals and ly\words\ lc\vals\
; think about a concept of a stub a word or a value that caries it's context with it
; make evaluator evaluate function in ab xlock of code
45 changes: 45 additions & 0 deletions examples/buttons_my.rye
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

hello: does { print "Hello world!" }

my-ip: fn { } {
get https://api.ipify.org?format=json
|parse-json -> "ip" |print
}

joke: does {
get https://official-joke-api.appspot.com/random_joke
|parse-json
|with { -> "setup" |print , -> "punchline" |print }
}

























; job: "Mining"

; eat: fn { } { print "Jum..." }

; work: fn { } { print "Ugh... " + job }

; sleep: fn { } { print "Zzzz..." }
546 changes: 520 additions & 26 deletions fyne/bindings.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toolchain go1.23.4

replace github.com/refaktor/rye => ../rye

// replace github.com/refaktor/ryegen => ../ryegen
replace github.com/refaktor/ryegen => ../ryegen

require (
fyne.io/fyne/v2 v2.5.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,6 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:Om
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/refaktor/go-peg v0.0.0-20220116201714-31e3dfa8dc7d h1:FXrWUGgPRzhaZIBho8zNLSrMp0VpP8E9+wbRRnJYlbE=
github.com/refaktor/go-peg v0.0.0-20220116201714-31e3dfa8dc7d/go.mod h1:iIkrsFobLIWX8kQ6Oqj4cl4nwdMSE92DWpWwk9YlG9s=
github.com/refaktor/ryegen v0.1.0 h1:g74xYZHv5vnkRn+gV3Hy/28OYqi9DrnXeZzXhNF7zTk=
github.com/refaktor/ryegen v0.1.0/go.mod h1:e0SC24+QY8gh/mI/7r6jaU6MNRfC3JcnJv1RUQDJHHY=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
Expand Down

0 comments on commit 6f60b9d

Please sign in to comment.