Allow the term_width to be regenerated
Arthur Axel 'fREW' Schmidt [Tue, 12 Aug 2014 16:18:30 +0000 (11:18 -0500)]
Changes
lib/Catalyst/Utils.pm

diff --git a/Changes b/Changes
index 2bb1c21..e571b5e 100644 (file)
--- 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
index 78c293a..5ee7451 100644 (file)
@@ -384,11 +384,21 @@ that 'env' now lists COLUMNS.)
 
 As last resort, default value of 80 chars will be used.
 
+Calling C<term_width> 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;