[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] Add config option to limit text wrapping width



This patch adds a configuration `wrap_width' option to limit the width
text wrapping uses(e.g. to wrap after 80 characters).
---
 lib/sup.rb                        |    3 ++-
 lib/sup/modes/thread-view-mode.rb |    7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/sup.rb b/lib/sup.rb
index b9dc749..df85636 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -263,7 +263,8 @@ else
     :discard_snippets_from_encrypted_messages => false,
     :default_attachment_save_dir => "",
     :sent_source => "sup://sent",
-    :poll_interval => 300
+    :poll_interval => 300,
+    :wrap_width => 0
   }
   begin
     FileUtils.mkdir_p Redwood::BASE_DIR
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 0e935a4..e109a2d 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -792,7 +792,12 @@ private
       if chunk.inlineable?
         lines = chunk.lines
         if @wrap
-          width = buffer.content_width
+          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.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
-- 
1.6.6.1

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