From: Arthur Axel 'fREW' Schmidt Date: Tue, 12 Aug 2014 16:18:30 +0000 (-0500) Subject: Allow the term_width to be regenerated X-Git-Tag: 5.90076~8^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ad9e8de94e240b8668b084ec2714deead7921a98 Allow the term_width to be regenerated --- diff --git a/Changes b/Changes index 2bb1c21..e571b5e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ # This file documents the revision history for Perl extension Catalyst. + - Allow the term_width to be regenerated (see Catalyst::Utils::term_width, + Frew Schmidt) + 5.90071 - 2014-08-10 - Travis config now performs basic reverse dependency testing. - Restored deprecated 'env' code in Engine.pm b/c it is still being used out diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index 78c293a..5ee7451 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -384,11 +384,21 @@ that 'env' now lists COLUMNS.) As last resort, default value of 80 chars will be used. +Calling C with a true value will cause it to be recalculated; you +can use this to cause it to get recalculated when your terminal is resized like +this + + $SIG{WINCH} = sub { Catalyst::Utils::term_width(1) }; + =cut my $_term_width; sub term_width { + my $force_reset = shift; + + undef $_term_width if $force_reset; + return $_term_width if $_term_width; my $width;