diff options
| author | Amir Rajan <[email protected]> | 2020-10-13 00:45:16 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-10-13 00:48:54 -0500 |
| commit | 05cbef7fb8224332795e5685be499d81d20e7d93 (patch) | |
| tree | 13ec5f1755c2f45618741f2f016ed8729dbedd41 /samples/12_c_extensions/02_intermediate/app/main.rb | |
| parent | abad948c1154d88d79b9f891e3b7315540e0b0a3 (diff) | |
| download | dragonruby-game-toolkit-contrib-05cbef7fb8224332795e5685be499d81d20e7d93.tar.gz dragonruby-game-toolkit-contrib-05cbef7fb8224332795e5685be499d81d20e7d93.zip | |
Synced with 1.26.
Diffstat (limited to 'samples/12_c_extensions/02_intermediate/app/main.rb')
| -rw-r--r-- | samples/12_c_extensions/02_intermediate/app/main.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/samples/12_c_extensions/02_intermediate/app/main.rb b/samples/12_c_extensions/02_intermediate/app/main.rb new file mode 100644 index 0000000..2e3fd7c --- /dev/null +++ b/samples/12_c_extensions/02_intermediate/app/main.rb @@ -0,0 +1,19 @@ +$gtk.ffi_misc.gtk_dlopen("ext") +include FFI::RE + +def split_words(input) + words = [] + last = IntPointer.new + re = re_compile("\\w+") + first = re_matchp(re, input, last) + while first != -1 + words << input.slice(first, last.value) + input = input.slice(last.value + first, input.length) + first = re_matchp(re, input, last) + end + words +end + +def tick args + args.outputs.labels << [640, 500, split_words("hello, dragonriders!").join(' '), 5, 1] +end |
