commit 036ab5381a396c32cefea8fcc1be8cf57173f25f
parent ebad6f03171c65dd075504c3a1e92612aaa4a243
Author: Daniel Schoepe <daniel.schoepe@googlemail.com>
Date: Wed, 3 Feb 2010 21:16:35 +0100
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).
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -264,7 +264,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
@@ -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}"]] }