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

[sup-talk] [CORRECTED PATCH] If we can get the terminal width, use that for WRAP_LEN.



I find that this provides a much smoother terminal experience,
especially with elinks configured to dump to the same size in hook
scripts.

At least on Linux, "stty size"'s second numerical output is the number
of columns, and if that fails somehow, sup will continue to happily
default to 80.
---
 lib/sup/message-chunks.rb |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 581b707..56ddf1e 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -41,7 +41,8 @@ end

 module Redwood
 module Chunk
-  WRAP_LEN = 80 # wrap messages and text attachments at this width
+  TERM_WIDTH = `stty size 2>/dev/null`.split[1].to_i # to_i returns 0 if it fails.
+  WRAP_LEN = TERM_WIDTH > 0 && TERM_WIDTH || 80 # wrap messages and text attachments at this width

   class Attachment
     HookManager.register "mime-decode", <<EOS
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk