| 1 |
package Test2::Harness::Util::Term; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
our $VERSION = '1.000179'; |
| 6 |
|
| 7 |
use Test2::Util qw/IS_WIN32/; |
| 8 |
|
| 9 |
use Importer Importer => 'import'; |
| 10 |
our @EXPORT_OK = qw/USE_ANSI_COLOR/; |
| 11 |
|
| 12 |
{ |
| 13 |
my $use = 0; |
| 14 |
local ($@, $!); |
| 15 |
|
| 16 |
if (eval { require Term::ANSIColor; Term::ANSIColor->VERSION('4.03') }) { |
| 17 |
if (IS_WIN32) { |
| 18 |
if (eval { require Win32::Console::ANSI }) { |
| 19 |
Win32::Console::ANSI->import(); |
| 20 |
$use = 1; |
| 21 |
} |
| 22 |
} |
| 23 |
else { |
| 24 |
$use = 1; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
if ($use) { |
| 29 |
*USE_ANSI_COLOR = sub() { 1 }; |
| 30 |
} |
| 31 |
else { |
| 32 |
*USE_ANSI_COLOR = sub() { 0 }; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
1; |
| 37 |
|
| 38 |
__END__ |
| 39 |
|
| 40 |
=pod |
| 41 |
|
| 42 |
=encoding UTF-8 |
| 43 |
|
| 44 |
=head1 NAME |
| 45 |
|
| 46 |
Test2::Harness::Util::Term - Terminal utilities for Test2::Harness |
| 47 |
|
| 48 |
=head1 DESCRIPTION |
| 49 |
|
| 50 |
This module provides information about the terminal in which the harness is |
| 51 |
running. |
| 52 |
|
| 53 |
=head1 SYNOPSIS |
| 54 |
|
| 55 |
use Test2::Harness::Util::Term qw/USE_ANSI_COLOR/; |
| 56 |
|
| 57 |
if (USE_ANSI_COLOR) { |
| 58 |
... |
| 59 |
} |
| 60 |
else { |
| 61 |
... |
| 62 |
} |
| 63 |
|
| 64 |
=head1 EXPORTS |
| 65 |
|
| 66 |
=over 4 |
| 67 |
|
| 68 |
=item $bool = USE_ANSI_COLOR() |
| 69 |
|
| 70 |
True if L<Term::ANSIColor> is available and usable. |
| 71 |
|
| 72 |
=back |
| 73 |
|
| 74 |
=head1 SOURCE |
| 75 |
|
| 76 |
The source code repository for Test2-Harness can be found at |
| 77 |
F<http://github.com/Test-More/Test2-Harness/>. |
| 78 |
|
| 79 |
=head1 MAINTAINERS |
| 80 |
|
| 81 |
=over 4 |
| 82 |
|
| 83 |
=item Chad Granum E<lt>[email protected]<gt> |
| 84 |
|
| 85 |
=back |
| 86 |
|
| 87 |
=head1 AUTHORS |
| 88 |
|
| 89 |
=over 4 |
| 90 |
|
| 91 |
=item Chad Granum E<lt>[email protected]<gt> |
| 92 |
|
| 93 |
=back |
| 94 |
|
| 95 |
=head1 COPYRIGHT |
| 96 |
|
| 97 |
Copyright 2020 Chad Granum E<lt>[email protected]<gt>. |
| 98 |
|
| 99 |
This program is free software; you can redistribute it and/or |
| 100 |
modify it under the same terms as Perl itself. |
| 101 |
|
| 102 |
See F<http://dev.perl.org/licenses/> |
| 103 |
|
| 104 |
=cut |