From 95a190f90994e0405a0f62a51faf27dc4d9c75a6 Mon Sep 17 00:00:00 2001 From: tompng Date: Tue, 3 Sep 2024 23:14:56 +0900 Subject: [PATCH] EasterEgg no longer depend on RDoc --- lib/irb/easter-egg.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb index 439e5755b..14dc93fc9 100644 --- a/lib/irb/easter-egg.rb +++ b/lib/irb/easter-egg.rb @@ -107,13 +107,14 @@ def render_frame(i) end private def easter_egg(type = nil) + print "\e[?1049h" type ||= [:logo, :dancing].sample case type when :logo - require "rdoc" - RDoc::RI::Driver.new.page do |io| - type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large - io.write easter_egg_logo(type) + Pager.page do |io| + logo_type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large + io.write easter_egg_logo(logo_type) + STDIN.raw { STDIN.getc } if io == STDOUT end when :dancing STDOUT.cooked do @@ -138,10 +139,11 @@ def render_frame(i) end rescue Interrupt ensure - print "\e[0m\e[?1049l" trap("SIGINT", prev_trap) end end + ensure + print "\e[0m\e[?1049l" end end end