From: William Morgan Date: Sun, 13 Jan 2008 01:19:50 +0000 (-0800) Subject: preserve filename when viewing attachments with text-mode X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=89153e06366ce062d13a8771483d2bc289515832;p=sup 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. --- diff --git a/lib/sup/modes/text-mode.rb b/lib/sup/modes/text-mode.rb index 22214d9..273c028 100644 --- 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 index d5e10a9..9894aba 100644 --- 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