-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buttons example, update to latest rye / fyne
- Loading branch information
Showing
7 changed files
with
201,308 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..." } |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters