diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb index 190c7f40d..77545369e 100644 --- a/lib/irb/easter-egg.rb +++ b/lib/irb/easter-egg.rb @@ -98,15 +98,22 @@ def render_frame(i) end end + private def easter_egg_logo(type) + @easter_egg_logos ||= File.binread(File.join(__dir__, 'ruby_logo.aa')) + .force_encoding(Encoding::UTF_8) + .split(/TYPE: ([A-Z]+)\n/)[1..] + .each_slice(2) + .to_h + @easter_egg_logos[type.to_s.upcase] + end + private def easter_egg(type = nil) type ||= [:logo, :dancing].sample case type when :logo - File.open(File.join(__dir__, 'ruby_logo.aa')) do |f| - require "rdoc" - RDoc::RI::Driver.new.page do |io| - IO.copy_stream(f, io) - end + require "rdoc" + RDoc::RI::Driver.new.page do |io| + io.write easter_egg_logo(:large) end when :dancing STDOUT.cooked do diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 454b6db00..ad7b90a61 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -372,11 +372,16 @@ def show_doc_dialog_proc end formatter = RDoc::Markup::ToAnsi.new formatter.width = width - dialog.trap_key = alt_d - mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt" - message = "Press #{mod_key}+d to read the full document" - contents = [message] + doc.accept(formatter).split("\n") - contents = contents.take(preferred_dialog_height) + if name =~ /\ARubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER'] + type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode : :ascii + contents = IRB.send(:easter_egg_logo, type).split("\n").take(preferred_dialog_height) + else + dialog.trap_key = alt_d + mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt" + message = "Press #{mod_key}+d to read the full document" + contents = [message] + doc.accept(formatter).split("\n") + contents = contents.take(preferred_dialog_height) + end y = cursor_pos_to_render.y Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49') diff --git a/lib/irb/ruby_logo.aa b/lib/irb/ruby_logo.aa index a34a3e2f2..61fe22c94 100644 --- a/lib/irb/ruby_logo.aa +++ b/lib/irb/ruby_logo.aa @@ -1,3 +1,4 @@ +TYPE: LARGE -+smJYYN?mm- HB"BBYT TQg NggT @@ -35,3 +36,45 @@ m7 NW H N HSVO1z=?11- NgTH bB kH WBHWWHBHWmQgg&gggggNNN NNggggggNN +TYPE: ASCII + ,,,;;;;''''';;;'';, + ,,;'' ';;,;;; ', + ,,'' ;;'';'''';;;;;; + ,;' ;; ',, ; + ,;' ,;' ';, ; + ;' ,;; ',,,; + ,' ,;;,,,,,,,,,,,;;;; + ;' ;;';;;; ,;; + ;' ,;' ;; '',, ,;;; + ;; ,;' ; '';, ,; ;' +;; ,;;' ;; ;; ;; +;;, ,,;;' ; ;'; ;; +;';;,,,,;;;;;;;,,, ;; ,' ; ;; +; ;;''' ,;'; ''';,,, ; ,;' ;;;; +;;;;, ; '; ''';;;' ';;; +;'; ;, ;' '; ,;' ', ;;; +;;; ; ,; '; ,,' ',, ;; +;;; '; ;' ';,,'' ';,;; + '; ';,; ,,;''''''''';;;;;;,,;;; + ';,,;;,,;;;;;;;;;;'''''''''''''' +TYPE: UNICODE + ⣀⣤⣴⣾⣿⣿⣿⡛⠛⠛⠛⠛⣻⣿⠿⠛⠛⠶⣤⡀ + ⣀⣴⠾⠛⠉⠁ ⠙⣿⣶⣤⣶⣟⣉ ⠈⠻⣦ + ⣀⣴⠟⠋ ⢸⣿⠟⠻⣯⡙⠛⠛⠛⠶⠶⠶⢶⣽⣇ + ⣠⡾⠋⠁ ⣾⡿ ⠈⠛⢦⣄ ⣿ + ⣠⡾⠋ ⣰⣿⠃ ⠙⠷⣤⡀ ⣿ + ⢀⡾⠋ ⣰⣿⡏ ⠈⠻⣦⣄⢠⣿ + ⣰⠟⠁ ⣴⣿⣿⣁⣀⣠⣤⣤⣤⣤⣤⣤⣤⣴⠶⠿⣿⡏ + ⣼⠏ ⢀⣾⣿⠟⣿⠿⣯⣍⠁ ⣰⣿⡇ + ⢀⣼⠋ ⢀⣴⣿⠟⠁ ⢸⡇ ⠙⠻⢦⣄⡀ ⢠⡿⣿⡇ +⢀⣾⡏ ⢀⣴⣿⠟⠁ ⣿ ⠉⠻⢶⣄⡀⣰⡟ ⣿⠃ +⣾⣿⠁ ⣠⣶⡿⠋⠁ ⢹⡇ ⠈⣿⡏ ⢸⣿ +⣿⣿⡆ ⢀⣠⣴⣿⡿⠋ ⠈⣿ ⢀⡾⠋⣿ ⢸⣿ +⣿⠸⣿⣶⣤⣤⣤⣤⣶⣾⠿⠿⣿⣿⠶⣤⣤⣀⡀ ⢹⡇ ⣴⠟⠁ ⣿⡀⢸⣿ +⣿⢀⣿⣟⠛⠋⠉⠁ ⢰⡟⠹⣧ ⠈⠉⠛⠻⠶⢦⣤⣀⡀ ⠈⣿ ⣠⡾⠃ ⢸⡇⢸⡇ +⣿⣾⣿⢿⡄ ⣿⠁ ⠘⣧ ⠉⠙⠛⠷⣿⣿⡋ ⠸⣇⣸⡇ +⣿⠃⣿⠈⢿⡄ ⣸⠇ ⠘⣧ ⢀⣤⠾⠋⠈⠻⣦⡀ ⣿⣿⡇ +⣿⢸⡏ ⠈⣷⡀ ⢠⡿ ⠘⣧⡀ ⣠⡴⠟⠁ ⠈⠻⣦⣀ ⢿⣿⠁ +⢻⣾⡇ ⠘⣷ ⣼⠃ ⠘⣷⣠⣴⠟⠋ ⠙⢷⣄⢸⣿ + ⠻⣧⡀ ⠘⣧⣰⡏ ⢀⣠⣤⠶⠛⠉⠛⠛⠛⠛⠛⠛⠻⢶⣶⣶⣶⣶⣶⣤⣤⣽⣿⣿ + ⠈⠛⠷⢦⣤⣽⣿⣥⣤⣶⣶⡿⠿⠿⠶⠶⠶⠶⠾⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠁