summaryrefslogtreecommitdiffhomepage
path: root/samples/13_rust_extensions/02_intermediate/app/main.rb
blob: c796e077c189356e60ff2c75fcb7264967bad835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$gtk.ffi_misc.gtk_dlopen("ext")
include FFI::RURE

def split_words(input)
  matches = Rure_matchPointer.new
  words = []
  re = rure_compile_must("\\w+")
  while rure_find(re, input, input.length, 0, matches) == 1
    words << input.slice(matches[0].start...matches[0].end)
    input = input.slice(matches[0].end, input.length)
  end
  words
end

def tick args
  input = "<<Hello, DragonRiders!>>"
  args.outputs.labels  << [640, 500, split_words(input).join(' '), 5, 1]
end