# This file documents the revision history for Perl extension Catalyst.
5.8000_05
+ - Text::SimpleTable's go as wide as $ENV{COLUMNS} (jhannah)
+ Patch written by Oleg Kostyuk <cub.uanic@gmail.com>
- Improve docs for visit (mateu)
- Add docs for finalize hook (dhoss)
- Added ru/ua translations to error page
my @plugins = map { "$_ " . ( $_->VERSION || '' ) } $class->registered_plugins;
if (@plugins) {
- my $t = Text::SimpleTable->new(74);
+ my $column_width = Catalyst::Utils::term_width() - 6;
+ my $t = Text::SimpleTable->new($column_width);
$t->row($_) for @plugins;
$class->log->debug( "Loaded plugins:\n" . $t->draw . "\n" );
}
$class->setup_components;
if ( $class->debug ) {
- my $t = Text::SimpleTable->new( [ 63, 'Class' ], [ 8, 'Type' ] );
+ my $column_width = Catalyst::Utils::term_width() - 8 - 9;
+ my $t = Text::SimpleTable->new( [ $column_width, 'Class' ], [ 8, 'Type' ] );
for my $comp ( sort keys %{ $class->components } ) {
my $type = ref $class->components->{$comp} ? 'instance' : 'class';
$t->row( $comp, $type );
omega: Andreas Marienborg
+Oleg Kostyuk <cub.uanic@gmail.com>
+
phaylon: Robert Sedlacek <phaylon@dunkelheit.at>
rafl: Florian Ragwitz <rafl@debian.org>
use Text::SimpleTable;
use Catalyst::ActionChain;
+use Catalyst::Utils;
use URI;
has _endpoints => (
return unless $self->_endpoints;
+ my $column_width = Catalyst::Utils::term_width() - 35 - 9;
my $paths = Text::SimpleTable->new(
- [ 35, 'Path Spec' ], [ 36, 'Private' ]
- );
+ [ 35, 'Path Spec' ], [ 36, 'Private' ], [ $column_width, 'Private' ]
+ );
my $has_unattached_actions;
my $unattached_actions = Text::SimpleTable->new(
extends 'Catalyst::DispatchType';
use Text::SimpleTable;
+use Catalyst::Utils;
use URI;
has _paths => (
sub list {
my ( $self, $c ) = @_;
- my $paths = Text::SimpleTable->new( [ 35, 'Path' ], [ 36, 'Private' ] );
+ my $column_width = Catalyst::Utils::term_width() - 35 - 9;
+ my $paths = Text::SimpleTable->new(
+ [ 35, 'Path' ], [ $column_width, 'Private' ]
+ );
foreach my $path ( sort keys %{ $self->_paths } ) {
my $display_path = $path eq '/' ? $path : "/$path";
foreach my $action ( @{ $self->_paths->{$path} } ) {
extends 'Catalyst::DispatchType::Path';
use Text::SimpleTable;
+use Catalyst::Utils;
use Text::Balanced ();
has _compiled => (
sub list {
my ( $self, $c ) = @_;
- my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ 36, 'Private' ] );
+ my $column_width = Catalyst::Utils::term_width() - 35 - 9;
+ my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ $column_width, 'Private' ] );
for my $regex ( @{ $self->_compiled } ) {
my $action = $regex->{action};
$re->row( $regex->{path}, "/$action" );
use Catalyst::ActionContainer;
use Catalyst::DispatchType::Default;
use Catalyst::DispatchType::Index;
+use Catalyst::Utils;
use Text::SimpleTable;
use Tree::Simple;
use Tree::Simple::Visitor::FindByPath;
return unless $c->debug;
+ my $column_width = Catalyst::Utils::term_width() - 20 - 36 - 12;
my $privates = Text::SimpleTable->new(
- [ 20, 'Private' ],
- [ 36, 'Class' ],
- [ 12, 'Method' ]
+ [ 20, 'Private' ], [ 36, 'Class' ], [ $column_width, 'Method' ]
);
my $has_private = 0;
use Moose;
use Time::HiRes qw/gettimeofday tv_interval/;
use Text::SimpleTable ();
+use Catalyst::Utils;
use Tree::Simple qw/use_weak_refs/;
use Tree::Simple::Visitor::FindByUID;
sub report {
my $self = shift;
- my $t = Text::SimpleTable->new( [ 62, 'Action' ], [ 9, 'Time' ] );
+ my $column_width = Catalyst::Utils::term_width() - 9 - 13;
+ my $t = Text::SimpleTable->new( [ $column_width, 'Action' ], [ 9, 'Time' ] );
my @results;
$self->traverse(
sub {
=head1 DESCRIPTION
+Catalyst Utilities.
+
=head1 METHODS
=head2 appprefix($class)
return;
}
+=head2 term_width
+
+Try to guess terminal width to use with formatting of debug output
+
+All you need to get this work, is:
+
+1) Install Term::Size::Any, or
+
+2) Export $COLUMNS from your shell.
+
+(Warning to bash users: 'echo $COLUMNS' may be showing you the bash
+variable, not $ENV{COLUMNS}. 'export COLUMNS=$COLUMNS' and you should see
+that 'env' now lists COLUMNS.)
+
+As last resort, default value of 80 chars will be used.
+
+=cut
+
+my $_term_width;
+
+sub term_width {
+ return $_term_width if $_term_width;
+
+ my $width = eval '
+ use Term::Size::Any;
+ my ($columns, $rows) = Term::Size::Any::chars;
+ return $columns;
+ ';
+
+ if ($@) {
+ $width = $ENV{COLUMNS}
+ if exists($ENV{COLUMNS})
+ && $ENV{COLUMNS} =~ m/^\d+$/;
+ }
+
+ $width = 80 unless ($width && $width >= 80);
+ return $_term_width = $width;
+}
+
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm