#!/usr/bin/env raku

use Terminal::ANSI;

save-screen;
clear-screen;
home;

hide-cursor;

sub scroll($row,$col = 1, $height = 7) {
  print-at $row,$col, "━" x 20;
  print-at $row + $height,$col, "━" x 20;
  my $on = $row;
  for 20000, 19999 ... 0 {
    atomically {
      set-scroll-region($row + 1,$row + $height - 1);
      scroll-up if $on >= $row + $height - 1;
      print-at ++$on min $row + $height - 1, $col, "counting down..$_";
      reset-scroll-region;
    }
  }
}

my $p1 = start scroll(2);
my $p2 = start scroll(12,10,10);
my $p3 = start scroll(24);
await Promise.allof($p1,$p2,$p3);
sleep 1;

show-cursor;
restore-screen;
