X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bin%2Fsup;h=8a377f78149f5a4b17a56e06036fcae96e2b3fb6;hb=fc260ddb62efcd26747e41d1c8a098bda3174d42;hp=7a51800a461c2c82a6a6f35e2b075451f05991bb;hpb=aa5608229171a78694c64d0a30375e765ffe86e0;p=sup diff --git a/bin/sup b/bin/sup index 7a51800..8a377f7 100755 --- a/bin/sup +++ b/bin/sup @@ -161,6 +161,9 @@ begin Redwood::start Index.load + trap("TERM") { |x| SuicideManager.please_die! } + trap("WINCH") { |x| BufferManager.sigwinch_happened! } + if(s = Redwood::SourceManager.source_for DraftManager.source_name) DraftManager.source = s else @@ -225,29 +228,39 @@ begin 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? + 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