]> git.notmuchmail.org Git - sup/commitdiff
Merge branch 'ncurses-fixes' into next
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 6 Aug 2009 18:30:12 +0000 (14:30 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 6 Aug 2009 18:30:12 +0000 (14:30 -0400)
Conflicts:
bin/sup
lib/sup/buffer.rb

1  2 
bin/sup
lib/sup/buffer.rb

diff --cc bin/sup
index 1febefdd5bc0e06e033f6da7a86d1f5bdf2e710f,2d5de6733fcdf76f1a58caa3d64aadce0c02c143..0e2260c210fd609feb1584f85a8300e0889b3952
+++ b/bin/sup
@@@ -218,29 -221,39 +221,40 @@@ begi
    end
  
    until Redwood::exceptions.nonempty? || SuicideManager.die?
-     c = 
-        begin
-          Ncurses.nonblocking_getch
-        rescue Exception => e
-          if e.is_a?(Interrupt)
-            raise if BufferManager.ask_yes_or_no("Die ungracefully now?")
-            bm.draw_screen
-            nil
-          end
-        end
-     next unless c
+     c = begin
+       Ncurses.nonblocking_getch
+     rescue Interrupt => e
+       raise if BufferManager.ask_yes_or_no "Die ungracefully now?"
+       BufferManager.draw_screen
+       nil
+     end
+     if c.nil?
+       if BufferManager.sigwinch_happened?
+         Redwood::log "redrawing screen on sigwinch"
+         BufferManager.completely_redraw_screen
+       end
+       next
+     end
+     if c == 410
+       ## this is ncurses's way of telling us it's detected a refresh.
+       ## since we have our own sigwinch handler, we don't do anything.
+       next
+     end
      bm.erase_flash
  
 -    action = begin
 -      if bm.handle_input c
 +    action =
 +      begin
 +        if bm.handle_input c
 +          :nothing
 +        else
 +          bm.resolve_input_with_keymap c, global_keymap
 +        end
 +      rescue InputSequenceAborted
          :nothing
 -      else
 -        bm.resolve_input_with_keymap c, global_keymap
        end
 -    rescue InputSequenceAborted
 -      :nothing
 -    end
      case action
      when :quit_now
        break if bm.kill_all_buffers_safely
index 5f52d1dff53ab62f80c008a7a25b6a84505e308c,5881febcf7e68c12df715d61baea7d05393232a9..b3a256fdfb79262bb98295a4c7366ccb4dd531e6
@@@ -25,13 -25,13 +25,15 @@@ module Ncurse
    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
-     if IO.select([$stdin], nil, nil, 1)
-       Ncurses.getch
-     else
-       nil
+     ## 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
      end
    end