]> git.cworth.org Git - sup/commitdiff
refactor message chunk to determine its own initial message state, and tweak rfc822...
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 27 Oct 2007 23:04:37 +0000 (23:04 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 27 Oct 2007 23:04:37 +0000 (23:04 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@632 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup
lib/sup/message-chunks.rb
lib/sup/message.rb
lib/sup/modes/thread-view-mode.rb

diff --git a/bin/sup b/bin/sup
index 68d9c7314f7e553d93b91e6b7628f5a4e20e7e60..785462a8114ad4bf93b394c5f3dfa1313b2566fb 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -130,7 +130,7 @@ begin
     c.add :cryptosig_valid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD
     c.add :cryptosig_unknown_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
     c.add :cryptosig_invalid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_RED, Ncurses::A_BOLD
-    c.add :generic_notice_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
+    c.add :generic_notice_patina_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
     c.add :quote_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
     c.add :sig_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
     c.add :quote_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
index bcd5775ecdea16586843f9dab30821991f7bd6a9..9168aa7c51d703e39abfaf06d72572e5dc97e813 100644 (file)
@@ -5,7 +5,7 @@
 ## notices like "this message was decrypted" or "this message contains
 ## a valid signature"---basically, anything we want to differentiate
 ## at display time.
-
+##
 ## A chunk can be inlineable, expandable, or viewable. If it's
 ## inlineable, #color and #lines are called and the output is treated
 ## as part of the message text. This is how Text and one-line Quotes
 ## #patina_text are called to generate a "patina" (a one-line widget,
 ## basically), and the user can press enter to toggle the display of
 ## the chunk content, which is generated from #color and #lines as
-## above. This is how Quote, Signature, and most widgets work.
+## above. This is how Quote, Signature, and most widgets
+## work. Exandable chunks can additionally define #initial_state to be
+## :open if they want to start expanded (default is to start collapsed).
 ##
 ## If it's not expandable but is viewable, a patina is displayed using
-## #patina_color and #patina_text, but no toggling is allowed. Instead,
-## if #view! is defined, pressing enter on the widget calls view! and
-## (if that returns false) #to_s. Otherwise, enter does nothing. This
-## is how non-inlineable attachments work.
+###patina_color and #patina_text, but no toggling is allowed. Instead,
+##if #view! is defined, pressing enter on the widget calls view! and
+##(if that returns false) #to_s. Otherwise, enter does nothing. This
+##is how non-inlineable attachments work.
 
 module Redwood
 module Chunk
@@ -75,6 +77,7 @@ EOS
     ## something we can display inline. otherwise, it's viewable.
     def inlineable?; false end
     def expandable?; !viewable? end
+    def initial_state; :open end
     def viewable?; @lines.nil? end
     def view!
       path = write_to_disk
@@ -142,7 +145,7 @@ EOS
     def color; :sig_color end
   end
 
-  class EnclosedMessageNotice
+  class EnclosedMessage
     attr_reader :from, :lines
     def initialize from, body
       @from = from
@@ -151,6 +154,7 @@ EOS
 
     def inlineable?; false end
     def expandable?; true end
+    def initial_state; :open end
     def viewable?; false end
 
     def patina_color; :generic_notice_patina_color end
index 0d4a780dbca979f698e27dea3f6e5e319dda9baf..568179d4f7543bd7be1664991feabecde693258e 100644 (file)
@@ -325,7 +325,7 @@ private
       chunks
     elsif m.header.content_type == "message/rfc822"
       payload = RMail::Parser.read(m.body)
-      [Chunk::EnclosedMessageNotice.new(PersonManager.person_for(payload.header.from.first.format), payload.to_s)]
+      [Chunk::EnclosedMessage.new(PersonManager.person_for(payload.header.from.first.format), payload.to_s)]
     else
       filename =
         ## first, paw through the headers looking for a filename
index 2f25b2551b7f1837bb07785bf852b441f027a03f..c40cf79f98b125b63cfee80ff4169b3efb2ade93 100644 (file)
@@ -377,8 +377,8 @@ private
 
           ## set the default state for chunks
           cl.state ||=
-            if c.is_a?(Chunk::Attachment) && c.expandable?
-              :open
+            if c.expandable? && c.respond_to?(:initial_state)
+              c.initial_state
             else
               :closed
             end