Skip to content

Commit

Permalink
0.103
Browse files Browse the repository at this point in the history
  • Loading branch information
kuerbis committed Mar 1, 2016
1 parent 40e0513 commit 5576468
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,3 +18,4 @@ MYMETA.yml
*.old
*.log
*~
*.pl
6 changes: 6 additions & 0 deletions Changes
@@ -1,6 +1,12 @@
Revision history for Term::Choose


0.103 2016-03-01
- Optional global win
- if ll and (pause() or index=1): on window-resize return -1
- ll works with 'choose', 'choose_multi' and 'pause'
- Update documentation.

0.102 2016-02-25
- Update documentation: only ascii-charater strings are supported

Expand Down
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@ Term::Choose - Choose items from a list interactively.
VERSION
=======

Version 0.102
Version 0.103

SYNOPSIS
========
Expand Down Expand Up @@ -262,6 +262,8 @@ If *ll* is set to a value less than the length of the elements the output could

If the value of *ll* is greater than the screen width the elements will be trimmed to fit into the screen.

If *ll* is set and *index* is set to `1` a window-resize causes a `return -1`.

Allowed values: 1 or greater

(default: undefined)
Expand Down
40 changes: 21 additions & 19 deletions lib/Term/Choose.pm6
@@ -1,7 +1,7 @@
use v6;
unit class Term::Choose;

my $VERSION = '0.102';
my $VERSION = '0.103';

use NCurses;

Expand Down Expand Up @@ -36,6 +36,7 @@ has @!list;
has %.o_global;
has %!o;

has NCurses::WINDOW $.g_win; ##
has NCurses::WINDOW $!win;

has Int $!multiselect;
Expand All @@ -60,10 +61,10 @@ has Int $!cursor_row;
has Array $!marked;


method new ( %o_global? ) {
method new ( %o_global?, $g_win=NCurses::WINDOW ) { ##
_validate_options( %o_global );
_set_defaults( %o_global );
self.bless( :%o_global );
self.bless( :%o_global, :$g_win ); ## opt
}


Expand Down Expand Up @@ -144,7 +145,7 @@ sub _validate_options ( %opt, Int $list_end? ) {
}

submethod DESTROY () { # ###
endwin();
self!_end_term();
}

method !_prepare_new_copy_of_list {
Expand Down Expand Up @@ -209,20 +210,11 @@ method !_init_term {
#mouseinterval( 500 );
}

method !_reset_term {
%!o<default> = $!rc2idx[$!pos[R]][$!pos[C]];
if $!marked.elems {
%!o<mark> = self!_marked_to_idx;
}
#sleep 0.5;
method !_end_term {
return if $!g_win;
endwin();
nc_refresh;
self!_init_term();
self!_wr_first_screen;
}



method !_choose ( @!orig_list, %!o, Int $!multiselect ) {
if ! @!orig_list.elems {
return;
Expand All @@ -243,7 +235,15 @@ method !_choose ( @!orig_list, %!o, Int $!multiselect ) {
my Int $new_term_w = getmaxx( $!win );
my Int $new_term_h = getmaxy( $!win );
if $new_term_w != $!term_w || $new_term_h != $!term_h {
self!_reset_term();
if %!o<ll> && ( %!o<index> || ! $!multiselect.defined ) {
return -1;
}
%!o<default> = $!rc2idx[$!pos[R]][$!pos[C]];
if $!marked.elems {
%!o<mark> = self!_marked_to_idx;
}
clear();
self!_wr_first_screen;
next GET_KEY;
}

Expand Down Expand Up @@ -466,11 +466,11 @@ method !_choose ( @!orig_list, %!o, Int $!multiselect ) {
}
}
when KEY_q | CONTROL_D {
endwin();
self!_end_term();
return;
}
when KEY_RETURN | KEY_ENTER { #
endwin();
self!_end_term();
if ! $!multiselect.defined {
return;
}
Expand Down Expand Up @@ -966,7 +966,7 @@ Term::Choose - Choose items from a list interactively.
=head1 VERSION
Version 0.102
Version 0.103
=head1 SYNOPSIS
Expand Down Expand Up @@ -1245,6 +1245,8 @@ If I<ll> is set to a value less than the length of the elements the output could
If the value of I<ll> is greater than the screen width the elements will be trimmed to fit into the screen.
If I<ll> is set and I<index> is set to C<1> a window-resize causes a C<return -1>.
Allowed values: 1 or greater
(default: undefined)
Expand Down
2 changes: 1 addition & 1 deletion lib/Term/Choose/LineFold.pm6
@@ -1,7 +1,7 @@
use v6;
unit class Term::Choose::LineFold;

my $VERSION = '0.102';
my $VERSION = '0.103';

use Terminal::WCWidth;

Expand Down

0 comments on commit 5576468

Please sign in to comment.