Skip to content

Commit

Permalink
Fix dancing-ruby Ctrl+C stop
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Oct 21, 2023
1 parent e26e90e commit 7f7dedb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/irb/easter-egg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ def render_frame(i)
canvas = Canvas.new(Reline.get_screen_size)
end
ruby_model = RubyModel.new
print "\e[?1049h"
0.step do |i| # TODO (0..).each needs Ruby 2.6 or later
buff = canvas.draw do
ruby_model.render_frame(i) do |p1, p2|
canvas.line(p1, p2)
STDOUT.cooked do
print "\e[?1049h"
0.step do |i| # TODO (0..).each needs Ruby 2.6 or later
buff = canvas.draw do
ruby_model.render_frame(i) do |p1, p2|
canvas.line(p1, p2)
end
end
buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
print "\e[H" + buff
sleep 0.05
end
buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
print "\e[H" + buff
sleep 0.05
end
rescue Interrupt
ensure
Expand Down

0 comments on commit 7f7dedb

Please sign in to comment.