Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dancing-ruby Ctrl+C stop #735

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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