commit 182827ca5d43b98b46c092bfda9bc79e4dff2cec
parent 22fcff8b1e668987d32bc044f7b94b5251a8ef7c
Author: Hamish Downer <dmishd@gmail.com>
Date: Sun, 29 May 2011 18:06:09 +0100
Merge branch 'wrap_quoted' into next
Diffstat:
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -838,6 +838,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
@@ -853,23 +866,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}"]]]