sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 1f4e55791d0bac4b2bceb8d586c72e2ba161d624
parent a3787adc0d19ba2a99f9d1191880468c08627b81
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Sat, 10 Feb 2007 20:13:16 +0000

ask when quitting with unsaved buffers

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@319 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M bin/sup | 5 ++---
M lib/sup/buffer.rb | 15 +++++++++++++++
M www/ss3.png | 0
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git 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
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -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
diff --git a/www/ss3.png b/www/ss3.png
Binary files differ.