Skip to content

Commit

Permalink
Lock .protect bar .show and .hide
Browse files Browse the repository at this point in the history
  • Loading branch information
hythm7 committed Oct 20, 2023
1 parent 844068d commit 5560b7b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/Pakku/Log.rakumod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
unit class Pakku::Log;

my Lock::Async $lock .= new;

enum Color is export ( :reset(0) :black(30) :red(31) :green(32) :yellow(33) :blue(34) :magenta(35) :cyan(36) :white(37) );

my class Level {
Expand Down Expand Up @@ -170,22 +172,29 @@ my class Bar {

method show( ) {

return unless $!active;
$lock.protect: {

print "\r";
return unless $!active;

print "\r";

$!level.msg: :$!header, msg => ~self;
$!level.msg: :$!header, msg => ~self;

}
}

method hide ( ) {

return unless $!active;
$lock.protect: {

my $space = $!length + @!sym.uniprops( 'East_Asian_Width' ).grep( 'W' ) + $!header.chars + 7;
return unless $!active;

print "\r";
print " " x $space ~ "\b \b" x $space;
my $space = $!length + @!sym.uniprops( 'East_Asian_Width' ).grep( 'W' ) + $!header.chars + 7;

print "\r";
print " " x $space ~ "\b \b" x $space;

}

}

Expand Down

0 comments on commit 5560b7b

Please sign in to comment.