Skip to content

Commit

Permalink
Fix dancing-ruby Ctrl+C stop (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Oct 21, 2023
1 parent e26e90e commit 802b1cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/irb/easter-egg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def render_frame(i)
end
end
when :dancing
begin
STDOUT.cooked do
interrupted = false
prev_trap = trap("SIGINT") { interrupted = true }
canvas = Canvas.new(Reline.get_screen_size)
Reline::IOGate.set_winch_handler do
canvas = Canvas.new(Reline.get_screen_size)
Expand All @@ -125,10 +127,12 @@ def render_frame(i)
buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
print "\e[H" + buff
sleep 0.05
break if interrupted
end
rescue Interrupt
ensure
print "\e[0m\e[?1049l"
trap("SIGINT", prev_trap)
end
end
end
Expand Down

0 comments on commit 802b1cb

Please sign in to comment.