]> git.cworth.org Git - sup/commitdiff
preserve filename when viewing attachments with text-mode
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 13 Jan 2008 01:19:50 +0000 (17:19 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 13 Jan 2008 01:19:50 +0000 (17:19 -0800)
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.

lib/sup/modes/text-mode.rb
lib/sup/modes/thread-view-mode.rb

index 22214d9e8d7df4e933ebe89528490d22cfaeb8f9..273c02850f9cbc331d51dfb62a00ca05fbe9703d 100644 (file)
@@ -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
 
index d5e10a97cc9df23841d17e37524fcc8909a4469e..9894aba4dc186169c073a586a56e2bf4b6e7b1f7 100644 (file)
@@ -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