Subject: Re: [sup-talk] Sup-sync exception

From: Mark Alexander <[email-masked]>
Date: Fri, 06 Nov 2009 23:10:33 -0500

Excerpts from Anthony Martinez's message of Fri Nov 06 21:16:42 -0500 2009:
> That'd be my patch. I used stty because ENV["COLUMNS"] doesn't consistently work
> for me:
> 
> $ echo $COLUMNS
> 132
> $ perl -wE 'say $ENV{COLUMNS}'
> Use of uninitialized value in say at -e line 1.

It sounds like you didn't do this:

export COLUMNS
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Anthony Martinez <[email-masked]>
Date: Fri, 06 Nov 2009 19:16:42 -0700

Excerpts from Mark Anderson's message of Fri Nov 06 13:06:17 -0700 2009:
> There was another patch that is complementary in getting the console to
> recognize the width of the terminal, I forget the tname, but here's what I
> have in my message-chunks.rb:
> 
>   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
> 
> I don't know why that patch preferred `stty` to ENV["COLUMNS"], since that one
> had worked for me.

$ echo $COLUMNS
132

$ ruby -e 'puts ENV["COLUMNS"]'
nil
$ irb
irb(main):001:0> ENV["COLUMNS"]
=> "132"

In Sup's console mode, ENV["COLUMNS"] is set, but when I tried
  WRAP_LEN = ENV["COLUMNS"]
in message-chunks.rb, it gets nil. It appears to have something to do with
readline:

$ irb --noreadline
irb(main):001:0> ENV["COLUMNS"]
=> nil

I also tried Ncurses.cols, as suggested on sup-devel, and got a similar
exception to yours. `stty`, albeit cheesy, works well enough for right now (even
though I'm not quite happy with it, since, in addition to its reliance on the
output of an external command, it also won't react to window size changes)

Perhaps this should be a configuration option -- give it a number to wrap to
that width, :auto to wrap to the terminal size (in some fashion that will allow
it to resize when the terminal does), and in the absence of any configuration,
80.

-- 
Every program has at least one bug and can be shortened by at least one
instruction -- from which, by induction, one can deduce that every
program can be reduced to one instruction which doesn't work.
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk