Skip to content

Commit 3e10c61

Browse files
committed
Improved animation example
* Press Ctrl-C to erase the chart * Same behavior regardless of when SIGINT signal is sent.
1 parent 5eaa7bc commit 3e10c61

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

example/animation.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ def out.tty?; true; end
2222
lines.each do |line|
2323
$stdout.print "\r#{line}"
2424
end
25+
$stdout.print "\e[0J"
2526
$stdout.flush
2627

27-
if continue
28-
n = lines.count
29-
$stdout.print "\e[#{n}F"
30-
shift = (shift + M) % N
31-
end
28+
n = lines.count
29+
$stdout.print "\e[#{n}F"
30+
shift = (shift + M) % N
3231

3332
sleep 0.2
3433
end
34+
35+
$stdout.print "\e[0J"

0 commit comments

Comments
 (0)