]> git.cworth.org Git - sup/commitdiff
ask when quitting with unsaved buffers
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 10 Feb 2007 20:13:16 +0000 (20:13 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 10 Feb 2007 20:13:16 +0000 (20:13 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@319 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup
lib/sup/buffer.rb
www/ss3.png

diff --git a/bin/sup b/bin/sup
index 2038fbdf1d656aee4e68314ad060b0dd795de5ba..3d38aa0fd51adfb9a6ad3bd12322b575f5a7d931 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -128,7 +128,7 @@ begin
         x = global_keymap.action_for c
         case x
         when :quit
-          break
+          break if bm.kill_all_buffers_safely
         when :help
           curmode = bm.focus_buf.mode
           bm.spawn_unless_exists("<help for #{curmode.name}>") { HelpMode.new curmode, global_keymap }
@@ -137,7 +137,7 @@ begin
         when :roll_buffers_backwards
           bm.roll_buffers_backwards
         when :kill_buffer
-          bm.kill_buffer bm.focus_buf if bm.focus_buf.mode.killable?
+          bm.kill_buffer_safely bm.focus_buf
         when :list_buffers
           bm.spawn_unless_exists("Buffer List") { BufferListMode.new }
         when :list_contacts
@@ -192,7 +192,6 @@ begin
       end
     end
   end
-  bm.kill_all_buffers
 rescue Exception => e
   $exception ||= e
 ensure
index d4fe54963eed56c1340f594d1ce0cf013558519d..4785a14e5069ee0bf7610349541534f3d1ce4de3 100644 (file)
@@ -271,6 +271,21 @@ class BufferManager
     b
   end
 
+  def kill_all_buffers_safely
+    until @buffers.empty?
+      ## inbox mode always claims it's unkillable. we'll ignore it.
+      return false unless @buffers.first.mode.is_a?(InboxMode) || @buffers.first.mode.killable?
+      kill_buffer @buffers.first
+    end
+    true
+  end
+
+  def kill_buffer_safely buf
+    return false unless buf.mode.killable?
+    kill_buffer buf
+    true
+  end
+
   def kill_all_buffers
     kill_buffer @buffers.first until @buffers.empty?
   end
index 4038cb56916904a98e2c77996b432d545de9c438..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
Binary files a/www/ss3.png and b/www/ss3.png differ