sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 33dee611a50f84f22dda96227adcc9259f1aaa4e
parent ab60e88c18c49fef8907fe42ebf49a6437cbddb7
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Fri,  6 Jul 2007 14:44:49 +0000

attachment tweaks

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

Diffstat:
M lib/sup/modes/edit-message-mode.rb | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -72,7 +72,7 @@ class EditMessageMode < LineCursorMode
   end
 
   def delete_attachment
-    i = curpos - @top_lines
+    i = curpos - @attachment_lines_offset
     if i >= 0 && i < @attachments.size && BufferManager.ask_yes_or_no("Delete attachment #{@attachments[i]}?")
       @attachments.delete_at i
       update
@@ -88,10 +88,14 @@ protected
 
   def regen_text
     top = header_lines(@header - NON_EDITABLE_HEADERS) + [""]
-    @text = top + @body + 
-      @attachments.map { |f| [[:attachment_color, "+ Attachment: #{f} (#{f.human_size})"]] }
-    @top_lines = top.size
+    @text = top + @body
     @text += sig_lines unless $config[:edit_signature]
+
+    unless @attachments.empty?
+      @text += [""]
+      @attachment_lines_offset = @text.length
+      @text += @attachments.map { |f| [[:attachment_color, "+ Attachment: #{f} (#{f.human_size})"]] }
+    end
   end
 
   def parse_file fn