sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 89153e06366ce062d13a8771483d2bc289515832
parent a6ba8231b67f424e302d9d70d9b9ed69f6678ee6
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sat, 12 Jan 2008 17:19:50 -0800

preserve filename when viewing attachments with text-mode

When a text-mode is spawned to view an attachment, pass in the atachment
filename, so that saving the buffer provies the filename as a default
value.

Diffstat:
M lib/sup/modes/text-mode.rb | 5 +++--
M lib/sup/modes/thread-view-mode.rb | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/sup/modes/text-mode.rb b/lib/sup/modes/text-mode.rb
@@ -7,15 +7,16 @@ class TextMode < ScrollMode
     k.add :pipe, "Pipe to process", '|'
   end
 
-  def initialize text=""
+  def initialize text="", filename=nil
     @text = text
+    @filename = filename
     update_lines
     buffer.mark_dirty if buffer
     super()
   end
   
   def save_to_disk
-    fn = BufferManager.ask_for_filename :filename, "Save to file: "
+    fn = BufferManager.ask_for_filename :filename, "Save to file: ", @filename
     save_to_file(fn) { |f| f.puts text } if fn
   end
 
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -629,7 +629,7 @@ private
     BufferManager.erase_flash
     BufferManager.completely_redraw_screen
     unless success
-      BufferManager.spawn "Attachment: #{chunk.filename}", TextMode.new(chunk.to_s)
+      BufferManager.spawn "Attachment: #{chunk.filename}", TextMode.new(chunk.to_s, chunk.filename)
       BufferManager.flash "Couldn't execute view command, viewing as text."
     end
   end