commit 99fe2050cc308fe11f4ffde2a933e1cd2a21f025
parent e4d2c4ce8470cce3ef02cefabe7d46a4ba6bffeb
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Sat, 19 Dec 2009 09:56:38 -0800
Merge branch 'toggle-line-wrap' into next
Diffstat:
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -135,7 +135,6 @@ EOS
@layout[earliest].state = :detailed if earliest.has_label?(:unread) || @thread.size == 1
@thread.remove_label :unread
- regen_text
end
def toggle_wrap
@@ -154,6 +153,14 @@ EOS
def lines; @text.length; end
def [] i; @text[i]; end
+ ## a little hacky---since regen_text can depend on buffer features like the
+ ## content_width, we don't call it in the constructor, and instead call it
+ ## here, which is set before we're responsible for drawing ourself.
+ def buffer= b
+ super
+ regen_text
+ end
+
def show_header
m = @message_lines[curpos] or return
BufferManager.spawn_unless_exists("Full header for #{m.id}") do
@@ -771,7 +778,10 @@ private
raise "Bad chunk: #{chunk.inspect}" unless chunk.respond_to?(:inlineable?) ## debugging
if chunk.inlineable?
lines = chunk.lines
- lines = lines.map { |l| l.chomp.wrap buffer.content_width }.flatten if @wrap
+ if @wrap
+ width = buffer.content_width
+ lines = lines.map { |l| l.chomp.wrap width }.flatten
+ end
lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
elsif chunk.expandable?
case state