From 6e57465483d3f03aaa45b1330b670e2130f90fb0 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Wed, 5 Aug 2009 16:39:15 -0400 Subject: [PATCH] Revert "Merge branch 'ncurses-fixes' into next" This reverts commit 96b55e2fd39105679dcbb2aa1449a2a09ed5a8c8. --- bin/sup | 35 ++++++++++++++++++----------------- lib/sup/buffer.rb | 15 ++++++++------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/bin/sup b/bin/sup index d52a0ad..1febefd 100755 --- a/bin/sup +++ b/bin/sup @@ -160,8 +160,6 @@ begin Redwood::start Index.load - trap("TERM") { |x| raise "so speaking as i think, i die, i die!" } - if(s = Redwood::SourceManager.source_for DraftManager.source_name) DraftManager.source = s else @@ -220,26 +218,29 @@ begin end until Redwood::exceptions.nonempty? || SuicideManager.die? - c = begin - Ncurses.nonblocking_getch - rescue Interrupt => e - raise if BufferManager.ask_yes_or_no "Die ungracefully now?" - BufferManager.draw_screen - nil - end - + 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 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 diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index 7939e27..5f52d1d 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -25,13 +25,14 @@ module Ncurses 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 - ## INSANITY - ## it is NECESSARY to call nodelay EVERY TIME otherwise a single ctrl-c - ## will turn a blocking call into a nonblocking one. hours of my life - ## wasted on this trivial bullshit: 3. - Ncurses.nodelay Ncurses.stdscr, false - Ncurses.getch + if IO.select([$stdin], nil, nil, 1) + Ncurses.getch + else + nil + end end module_function :rows, :cols, :curx, :nonblocking_getch, :mutex, :sync @@ -69,7 +70,7 @@ class Buffer def content_height; @height - 1; end def content_width; @width; end - def resize rows, cols + def resize rows, cols return if cols == @width && rows == @height @width = cols @height = rows -- 2.45.2