diff options
| author | tomoya ishida <tomoyapenguin@gmail.com> | 2023-10-21 20:56:21 +0900 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-11-08 09:17:23 +0900 |
| commit | c8d4b103a924aca45c6170a5f6122eec3084641a (patch) | |
| tree | 1bb265dfaa148c2c2ca30d56066d3ab4d88df24b | |
| parent | d8e0337d02476f53bd4e33ffa014c7bf41e8ab15 (diff) | |
[ruby/irb] Fix dancing-ruby Ctrl+C stop
(https://github.com/ruby/irb/pull/735)
https://github.com/ruby/irb/commit/802b1cb6d8
| -rw-r--r-- | lib/irb/easter-egg.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb index 1d7460abcd..adc0834d55 100644 --- a/lib/irb/easter-egg.rb +++ b/lib/irb/easter-egg.rb @@ -115,7 +115,9 @@ module IRB io.write easter_egg_logo(:large) 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) @@ -131,10 +133,12 @@ module IRB 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 |
