]> git.cworth.org Git - sup/commitdiff
Merge branch 'ncurses-fixes'
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Tue, 25 Aug 2009 13:39:18 +0000 (09:39 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Tue, 25 Aug 2009 13:48:20 +0000 (09:48 -0400)
Conflicts:
lib/sup/buffer.rb

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

diff --cc bin/sup
index 7a51800a461c2c82a6a6f35e2b075451f05991bb,b87c11223342aefe977b34e99f053ba548a4fc6d..8a377f78149f5a4b17a56e06036fcae96e2b3fb6
+++ b/bin/sup
@@@ -225,29 -221,39 +228,39 @@@ 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"
++        debug "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
-           :nothing
-         else
-           bm.resolve_input_with_keymap c, global_keymap
-         end
-       rescue InputSequenceAborted
+     action = begin
+       if bm.handle_input c
          :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 f053f676e53262f2680c52b46fb21134d437d69e,f3b3cd5e7fd9cf1b5022303d1dc2668f3e3db8dd..4b53fed697b037656cdec013a64da1bb5e78f59c
@@@ -196,8 -196,15 +196,13 @@@ EO
      @flash = nil
      @shelled = @asking = false
      @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/
 -
 -    self.class.i_am_the_instance self
+     @sigwinch_happened = false
+     @sigwinch_mutex = Mutex.new
    end
  
+   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 focus_on buf
    def completely_redraw_screen
      return if @shelled
  
 -    Redwood::log "new screen size is #{Ncurses.rows} x #{Ncurses.cols}"
+     ## this magic makes Ncurses get the new size of the screen
+     Ncurses.endwin
+     Ncurses.stdscr.keypad 1
+     Ncurses.curs_set 0
+     Ncurses.refresh
+     @sigwinch_mutex.synchronize { @sigwinch_happened = false }
++    debug "new screen size is #{Ncurses.rows} x #{Ncurses.cols}"
      status, title = get_status_and_title(@focus_buf) # must be called outside of the ncurses lock
  
      Ncurses.sync do
Simple merge