Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80.
@ 2009-11-04  3:05 Anthony Martinez
  2009-11-04  3:22 ` Anthony Martinez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Anthony Martinez @ 2009-11-04  3:05 UTC (permalink / raw)
  To: sup-talk, sup-devel; +Cc: Anthony Martinez

From: Anthony Martinez <pi@pihost.us>

I find that this provides a much smoother terminal experience,
especially with dumped HTML output. At least on Linux+zsh, this
environment variable is automatically updated, and if it doesn't exist,
sup will continue to happily default to 80.
---
 lib/sup/message-chunks.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 581b707..881ac4b 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -41,7 +41,7 @@ end
 
 module Redwood
 module Chunk
-  WRAP_LEN = 80 # wrap messages and text attachments at this width
+  WRAP_LEN = ENV["COLUMNS"] || 80 # wrap messages and text attachments at this width
 
   class Attachment
     HookManager.register "mime-decode", <<EOS
-- 
1.6.5

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80.
  2009-11-04  3:05 [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Anthony Martinez
@ 2009-11-04  3:22 ` Anthony Martinez
  2009-11-04  3:51 ` [sup-talk] [CORRECTED PATCH] If we can get the terminal width, use that for WRAP_LEN Anthony Martinez
  2009-11-04 19:06 ` [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Mark Alexander
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Martinez @ 2009-11-04  3:22 UTC (permalink / raw)
  To: sup-talk, sup-devel

Excerpts from Anthony Martinez's message of Tue Nov 03 20:05:19 -0700 2009:
> I find that this provides a much smoother terminal experience,
Or it would if I tested it. Sorry about the bad patch, seems today isn't my day.
:)

Either way, I'd like to see something like this. Discussion?
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [CORRECTED PATCH] If we can get the terminal width, use that for WRAP_LEN.
  2009-11-04  3:05 [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Anthony Martinez
  2009-11-04  3:22 ` Anthony Martinez
@ 2009-11-04  3:51 ` Anthony Martinez
  2009-11-04 19:06 ` [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Mark Alexander
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Martinez @ 2009-11-04  3:51 UTC (permalink / raw)
  To: sup-talk, sup-devel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80.
  2009-11-04  3:05 [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Anthony Martinez
  2009-11-04  3:22 ` Anthony Martinez
  2009-11-04  3:51 ` [sup-talk] [CORRECTED PATCH] If we can get the terminal width, use that for WRAP_LEN Anthony Martinez
@ 2009-11-04 19:06 ` Mark Alexander
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Alexander @ 2009-11-04 19:06 UTC (permalink / raw)
  To: Anthony Martinez; +Cc: sup-talk, Anthony Martinez, sup-devel

Excerpts from Anthony Martinez's message of Tue Nov 03 22:05:19 -0500 2009:
> +  WRAP_LEN = ENV["COLUMNS"] || 80 # wrap messages and text attachments at this width

How about using Ncurses.cols?  That's what I did in a similar patch on
my copy of sup.
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-04 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04  3:05 [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Anthony Martinez
2009-11-04  3:22 ` Anthony Martinez
2009-11-04  3:51 ` [sup-talk] [CORRECTED PATCH] If we can get the terminal width, use that for WRAP_LEN Anthony Martinez
2009-11-04 19:06 ` [sup-talk] [PATCH] If we have a COLUMNS environment variable, wrap to that instead of 80 Mark Alexander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox