From: William Morgan Date: Tue, 25 Aug 2009 13:39:18 +0000 (-0400) Subject: Merge branch 'ncurses-fixes' X-Git-Url: https://git.cworth.org/git?p=sup;a=commitdiff_plain;h=fc260ddb62efcd26747e41d1c8a098bda3174d42 Merge branch 'ncurses-fixes' Conflicts: lib/sup/buffer.rb --- fc260ddb62efcd26747e41d1c8a098bda3174d42 diff --cc bin/sup index 7a51800,b87c112..8a377f7 --- a/bin/sup +++ 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 diff --cc lib/sup/buffer.rb index f053f67,f3b3cd5..4b53fed --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@@ -196,8 -196,15 +196,13 @@@ EO @flash = nil @shelled = @asking = false @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/ + @sigwinch_happened = false + @sigwinch_mutex = Mutex.new - - self.class.i_am_the_instance self 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 @@@ -259,6 -266,14 +264,14 @@@ def completely_redraw_screen return if @shelled + ## 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 } - Redwood::log "new screen size is #{Ncurses.rows} x #{Ncurses.cols}" ++ 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