From: Anthony Martinez <pi+sup@pihost.us>
To: sup-talk <sup-talk@rubyforge.org>
Cc: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-talk] Sup-sync exception
Date: Fri, 06 Nov 2009 19:16:42 -0700 [thread overview]
Message-ID: <1257556260-sup-1272@home.mrtheplague.net> (raw)
In-Reply-To: <1257537789-sup-1961@testarossa>
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.
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.
$ 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
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next parent reply other threads:[~2009-11-07 2:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1257452860-sup-7983@testarossa>
[not found] ` <1257520288-sup-8595@onnadayr.ca>
[not found] ` <1257537789-sup-1961@testarossa>
2009-11-07 2:16 ` Anthony Martinez [this message]
2009-11-07 4:10 ` Mark Alexander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1257556260-sup-1272@home.mrtheplague.net \
--to=pi+sup@pihost.us \
--cc=sup-devel@rubyforge.org \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox