Skip to content

Commit

Permalink
Issued around tput. [GH #6 gregoa]. Bugfix: enable colored output for…
Browse files Browse the repository at this point in the history
… the undef and empty string. Bugix in line_fold: make colored output work with a single prompt line. Set col_width_plus only once.
  • Loading branch information
kuerbis committed Sep 12, 2019
1 parent 34a8bde commit daa0d04
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Changes
@@ -1,6 +1,14 @@
Revision history for Term::Choose



1.701 2019-09-12
- Issued around `tput`. [GH #6 gregoa]
- Bugfix: enable colored output for the 'undef' and 'empty' string.
- Set 'col_width_plus' only once.
- Bugix in line_fold: make colored output work with a single prompt line.


1.700 2019-09-05
- Option 'mouse': changed from 5 to 2 allowed values.
- Renamed option 'justify' to 'alignment'.
Expand Down
20 changes: 15 additions & 5 deletions lib/Term/Choose.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';
use Exporter 'import';
our @EXPORT_OK = qw( choose );

Expand Down Expand Up @@ -831,7 +831,18 @@ sub __wr_cell {
$str = $self->__pad_str_to_colwidth( $idx );
}
if ( $self->{color} ) {
my @color = ( $self->{orig_list}[$idx] || '' ) =~ /(\e\[[\d;]*m)/g;
my @color;
if ( ! $self->{orig_list}[$idx] ) {
if ( ! defined $self->{orig_list}[$idx] ) {
@color = $self->{undef} =~ /(\e\[[\d;]*m)/g;
}
elsif ( ! length $self->{orig_list}[$idx] ) {
@color = $self->{empty} =~ /(\e\[[\d;]*m)/g;
}
}
else {
@color = $self->{orig_list}[$idx] =~ /(\e\[[\d;]*m)/g;
}
if ( $emphasised ) {
for ( @color ) {
# keep cell marked after color escapes
Expand Down Expand Up @@ -958,7 +969,6 @@ sub __list_idx_to_rowcol {
}
}
else {
$self->{col_width_plus} = $self->{col_width} + $self->{pad};
my $tmp_avail_width = $self->{avail_width} + $self->{pad};
# auto_format
if ( $layout == 1 || $layout == 2 ) {
Expand Down Expand Up @@ -1100,7 +1110,7 @@ sub __mouse_info_to_key {
my $idx = $self->{rc2idx}[$row][$col];
$begin_next_col = $begin_this_col + $self->{length}[$idx] + $self->{pad};
}
else { #
else {
$begin_next_col = $begin_this_col + $self->{col_width_plus};
}
if ( $col == 0 ) {
Expand Down Expand Up @@ -1154,7 +1164,7 @@ Term::Choose - Choose items from a list interactively.
=head1 VERSION
Version 1.700
Version 1.701
=cut
Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/Constants.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down
4 changes: 2 additions & 2 deletions lib/Term/Choose/LineFold.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down Expand Up @@ -120,7 +120,7 @@ sub line_fold {
$string =~ s/[^\x{0a}\x{0b}\x{0c}\x{0d}\x{85}\P{Cc}]//g; # remove control chars but keep vertical spaces
$string =~ s/[\p{Noncharacter_Code_Point}\p{Cs}]//g;
my $regex = qr/\x{0d}\x{0a}|[\x{000a}-\x{000d}\x{0085}\x{2028}\x{2029}]/; # \R 5.10
if ( $string !~ /$regex/ && print_columns( $opt->{init_tab} . $string ) <= $avail_width ) {
if ( $string !~ /$regex/ && print_columns( $opt->{init_tab} . $string ) <= $avail_width && ! @color ) {
return $opt->{init_tab} . $string;
}
my @paragraphs;
Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/LineFold/CharWidthAmbiguousWide.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/LineFold/CharWidthDefault.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/Linux.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Term::Choose::Constants qw( :linux :keys TERM_READKEY );
use Term::Choose::Screen qw( hide_cursor show_cursor normal );
Expand Down
4 changes: 2 additions & 2 deletions lib/Term/Choose/Screen.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down Expand Up @@ -34,7 +34,7 @@ my (


BEGIN {
if ( $^O eq 'MSWin32' || $ENV{TC_ANSI_ESCAPES} || system( "tput -V &> /dev/null" ) ) {
if ( $^O eq 'MSWin32' || $ENV{TC_ANSI_ESCAPES} || ! qx(tput cuu 2>/dev/null) ) {
@up = ( "\e[", "A" );
@down = ( "\e[", "B" );
@right = ( "\e[", "C" );
Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/ValidateOptions.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';

use Exporter qw( import );

Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/Win32.pm
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;
use 5.008003;

our $VERSION = '1.700';
our $VERSION = '1.701';


use Encode qw( decode );
Expand Down

0 comments on commit daa0d04

Please sign in to comment.