lib/textbringer/utils.rb in textbringer-0.2.1 vs lib/textbringer/utils.rb in textbringer-0.2.2

- old
+ new

@@ -47,11 +47,35 @@ def sleep_for(secs) sleep(secs) end + def background + Thread.start do + begin + yield + rescue Exception => e + next_tick do + raise e + end + end + end + end + + def next_tick(*args, &block) + Controller.current.next_tick(*args, &block) + end + + def read_event + Controller.current.read_event + end + def read_char - Controller.current.read_char + event = Controller.current.read_event + if !event.is_a?(String) + raise EditorError, "Non character event: #{event.inspect}" + end + event end def received_keyboard_quit? Controller.current.received_keyboard_quit? end