From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.204.66.147 with SMTP id n19cs132235bki; Thu, 2 Sep 2010 18:38:24 -0700 (PDT) Received: by 10.101.175.23 with SMTP id c23mr10806anp.55.1283477902518; Thu, 02 Sep 2010 18:38:22 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id w39si2514747ana.164.2010.09.02.18.38.22; Thu, 02 Sep 2010 18:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id ACD031858386; Thu, 2 Sep 2010 21:38:21 -0400 (EDT) Received: from leela.laznode.com (magnus.laznode.com [72.51.41.93]) by rubyforge.org (Postfix) with ESMTP id 6BAF21858364 for ; Thu, 2 Sep 2010 21:38:12 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by leela.laznode.com (Postfix) with ESMTP id D58FA380CE; Thu, 2 Sep 2010 20:49:32 +0000 (UTC) Received: from leela.laznode.com ([127.0.0.1]) by localhost (magnus.laznode.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S66tN7wUzS09; Thu, 2 Sep 2010 20:49:28 +0000 (UTC) Received: from rai (rai [10.66.66.1]) by leela.laznode.com (Postfix) with ESMTP id A716A380BF; Thu, 2 Sep 2010 20:49:25 +0000 (UTC) Received: by rai (Postfix, from userid 1000) id 35D85DA828A; Thu, 2 Sep 2010 20:49:25 +0000 (UTC) From: adam lazur To: sup-devel@rubyforge.org Date: Thu, 2 Sep 2010 13:49:24 -0700 Message-Id: <1283460564-18287-1-git-send-email-adam@lazur.org> X-Mailer: git-send-email 1.5.6.5 Cc: adam lazur Subject: [sup-devel] [PATCH] wrap quoted text according to wrap preferences X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org From: adam lazur 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