summaryrefslogtreecommitdiffhomepage
path: root/samples/12_c_extensions/02_intermediate/app/main.rb
blob: 2e3fd7cea3ade0234e8e6d24ac5c6870753850d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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