diff --git a/.gitignore b/.gitignore index 8ff91f3..916e534 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ MYMETA.yml *.old *.log *~ +*.pl diff --git a/Changes b/Changes index 201ef0b..e0ad542 100644 --- a/Changes +++ b/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 diff --git a/README.md b/README.md index 2cbd770..b84789e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Term::Choose - Choose items from a list interactively. VERSION ======= -Version 0.102 +Version 0.103 SYNOPSIS ======== @@ -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) diff --git a/lib/Term/Choose.pm6 b/lib/Term/Choose.pm6 index d6a5bd2..11eae94 100644 --- a/lib/Term/Choose.pm6 +++ b/lib/Term/Choose.pm6 @@ -1,7 +1,7 @@ use v6; unit class Term::Choose; -my $VERSION = '0.102'; +my $VERSION = '0.103'; use NCurses; @@ -36,6 +36,7 @@ has @!list; has %.o_global; has %!o; +has NCurses::WINDOW $.g_win; ## has NCurses::WINDOW $!win; has Int $!multiselect; @@ -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 } @@ -144,7 +145,7 @@ sub _validate_options ( %opt, Int $list_end? ) { } submethod DESTROY () { # ### - endwin(); + self!_end_term(); } method !_prepare_new_copy_of_list { @@ -209,20 +210,11 @@ method !_init_term { #mouseinterval( 500 ); } -method !_reset_term { - %!o = $!rc2idx[$!pos[R]][$!pos[C]]; - if $!marked.elems { - %!o = 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; @@ -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 && ( %!o || ! $!multiselect.defined ) { + return -1; + } + %!o = $!rc2idx[$!pos[R]][$!pos[C]]; + if $!marked.elems { + %!o = self!_marked_to_idx; + } + clear(); + self!_wr_first_screen; next GET_KEY; } @@ -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; } @@ -966,7 +966,7 @@ Term::Choose - Choose items from a list interactively. =head1 VERSION -Version 0.102 +Version 0.103 =head1 SYNOPSIS @@ -1245,6 +1245,8 @@ If I is set to a value less than the length of the elements the output could If the value of I is greater than the screen width the elements will be trimmed to fit into the screen. +If I is set and I is set to C<1> a window-resize causes a C. + Allowed values: 1 or greater (default: undefined) diff --git a/lib/Term/Choose/LineFold.pm6 b/lib/Term/Choose/LineFold.pm6 index 0bef161..fdf6602 100644 --- a/lib/Term/Choose/LineFold.pm6 +++ b/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;