3 def _wait_for_return_value(pb)
4 origCount = pb.changeCount
5 sleep 0.125 while pb.changeCount == origCount
8 def perform_service(service, in_string, wait_for_return_value=false)
9 p = OSX::NSPasteboard.pasteboardWithUniqueName
10 p.declareTypes_owner([OSX::NSStringPboardType], nil)
11 p.setString_forType(in_string, OSX::NSStringPboardType)
12 raise "Unable to call service #{service}" unless OSX::NSPerformService(service, p)
13 _wait_for_return_value(p) if wait_for_return_value
14 p.stringForType(OSX::NSStringPboardType)
18 system %Q{osascript -e 'tell app "TextMate" to activate'};
22 perform_service("Factor/Evaluate in Listener", code)
26 r = perform_service("Factor/Evaluate Selection", code, true)
31 def doc_using_statements(document)
32 document.scan(/\b(USING:\s[^;]*\s;|USE:\s+\S+|IN:\s\S+)/).join("\n") << "\n"
35 def line_current_word(line, point)
36 left = line.rindex(/\s/, point - 1) || 0; right = line.index(/\s/, point) || line.length