lib/sup/buffer.rb in sup-0.10.2 vs lib/sup/buffer.rb in sup-0.11

- old
+ new

@@ -28,17 +28,25 @@ end def mutex; @mutex ||= Mutex.new; end def sync &b; mutex.synchronize(&b); end + ## magically, this stuff seems to work now. i could swear it didn't + ## before. hm. def nonblocking_getch ## INSANTIY ## it is NECESSARY to wrap Ncurses.getch in a select() otherwise all ## background threads will be BLOCKED. (except in very modern versions ## of libncurses-ruby. the current one on ubuntu seems to work well.) if IO.select([$stdin], nil, nil, 0.5) - c = Ncurses.getch + if Redwood::BufferManager.shelled? + # If we get input while we're shelled, we'll ignore it for the + # moment and use Ncurses.sync to wait until the shell_out is done. + Ncurses.sync { nil } + else + Ncurses.getch + end end end ## pretends ctrl-c's are ctrl-g's def safe_nonblocking_getch @@ -214,10 +222,11 @@ def sigwinch_happened!; @sigwinch_mutex.synchronize { @sigwinch_happened = true } end def sigwinch_happened?; @sigwinch_mutex.synchronize { @sigwinch_happened } end def buffers; @name_map.to_a; end + def shelled?; @shelled; end def focus_on buf return unless @buffers.member? buf return if buf == @focus_buf @focus_buf.blur if @focus_buf @@ -601,10 +610,10 @@ @asking = false Ncurses.sync do tf.deactivate draw_screen :sync => false, :status => status, :title => title end - tf.value + tf.value.tap { |x| x.force_encoding Encoding::UTF_8 if x && x.respond_to?(:encoding) } end def ask_getch question, accept=nil raise "impossible!" if @asking