Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] wrap quoted text according to wrap preferences
@ 2010-09-02 20:49 adam lazur
  2010-09-04 10:40 ` Robin Burchell
  0 siblings, 1 reply; 2+ messages in thread
From: adam lazur @ 2010-09-02 20:49 UTC (permalink / raw)
  To: sup-devel; +Cc: adam lazur

From: adam lazur <laz@facebook.com>

Wrap expanded sections of quoted text at a column boundary, just like
sup already does for unquoted text. I split the existing wrapper code
into a utility function.
---
 lib/sup/modes/thread-view-mode.rb |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 088529b..f648f8b 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -841,6 +841,19 @@ private
     p.longname + (ContactManager.is_aliased_contact?(p) ? " (#{ContactManager.alias_for p})" : "")
   end
 
+  def maybe_wrap_text lines
+    if @wrap
+      config_width = $config[:wrap_width]
+      if config_width and config_width != 0
+        width = [config_width, buffer.content_width].min
+      else
+        width = buffer.content_width
+      end
+      lines = lines.map { |l| l.chomp.wrap width }.flatten
+    end
+    return lines
+  end
+
   ## todo: check arguments on this overly complex function
   def chunk_to_lines chunk, state, start, depth, parent=nil, color=nil, star_color=nil
     prefix = " " * INDENT_SPACES * depth
@@ -856,23 +869,15 @@ private
     else
       raise "Bad chunk: #{chunk.inspect}" unless chunk.respond_to?(:inlineable?) ## debugging
       if chunk.inlineable?
-        lines = chunk.lines
-        if @wrap
-          config_width = $config[:wrap_width]
-          if config_width and config_width != 0
-            width = [config_width, buffer.content_width].min
-          else
-            width = buffer.content_width
-          end
-          lines = lines.map { |l| l.chomp.wrap width }.flatten
-        end
+        lines = maybe_wrap_text(chunk.lines)
         lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
       elsif chunk.expandable?
         case state
         when :closed
           [[[chunk.patina_color, "#{prefix}+ #{chunk.patina_text}"]]]
         when :open
-          [[[chunk.patina_color, "#{prefix}- #{chunk.patina_text}"]]] + chunk.lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
+          lines = maybe_wrap_text(chunk.lines)
+          [[[chunk.patina_color, "#{prefix}- #{chunk.patina_text}"]]] + lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
         end
       else
         [[[chunk.patina_color, "#{prefix}x #{chunk.patina_text}"]]]
-- 
1.7.2.1

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-04 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02 20:49 [sup-devel] [PATCH] wrap quoted text according to wrap preferences adam lazur
2010-09-04 10:40 ` Robin Burchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox