diff options
| author | holli-holzer <holli.holzer@gmail.com> | 2019-10-03 23:58:47 +0200 |
|---|---|---|
| committer | holli-holzer <holli.holzer@gmail.com> | 2019-10-03 23:58:47 +0200 |
| commit | 338887a46029253aed2c775ca6f9fbacbc931fe7 (patch) | |
| tree | 747ba85cef17fc176f3caa4131c5c492cd7c3b27 /challenge-028 | |
| parent | 530b4ea1b0c513526640bc44004fd58d6efaadef (diff) | |
| download | perlweeklychallenge-club-338887a46029253aed2c775ca6f9fbacbc931fe7.tar.gz perlweeklychallenge-club-338887a46029253aed2c775ca6f9fbacbc931fe7.tar.bz2 perlweeklychallenge-club-338887a46029253aed2c775ca6f9fbacbc931fe7.zip | |
properly handle CTRL-C on Win
Diffstat (limited to 'challenge-028')
| -rw-r--r-- | challenge-028/markus-holzer/perl6/ch-2.pl6 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/challenge-028/markus-holzer/perl6/ch-2.pl6 b/challenge-028/markus-holzer/perl6/ch-2.pl6 index 896caded55..6008c55528 100644 --- a/challenge-028/markus-holzer/perl6/ch-2.pl6 +++ b/challenge-028/markus-holzer/perl6/ch-2.pl6 @@ -8,23 +8,24 @@ my @numbers = map *.comb(3).Array, "╻━╻┃ ┃╹━╹", " ╻ ┃ ╹", "╺━╻╻━╹╹━╸", "╺━╻╺━┃╺━╹", "╻ ╻╹━┃ ╹", "╻━╸╹━╻╺━╹", "╻━╸┃━╻╹━╹", "╺━╻ ┃ ╹", "╻━╻┃━┃╹━╹", "╻━╻╹━┃╺━╹"; - -sub MAIN( CoordStr :$at ) +sub MAIN( CoordStr :$at = "2,2" ) { my ($x, $y) = $at.Str.split(','); react { whenever Supply.interval(1) -> $v { print clear-screen; - display-time( $x, $y, DateTime.now ); + display-time( $x, $y, DateTime.now.hh-mm-ss ); print go-to(0,0); } + + whenever signal(SIGINT) { exit 0; } } } sub display-time( $x, $y, $time ) { - for $time.hh-mm-ss.comb.kv -> $column, $part + for $time.comb.kv -> $column, $part { if $part ~~ /\d/ { @@ -44,3 +45,5 @@ sub clear-screen() { escape("2J") ~ escape(";H"); } sub go-to( $column, $row ) { escape( "$row;$column" ~ "H" ); } sub escape( $value ) { "\e[" ~ $value; } + + |
